Search code examples
fortransubroutinevariable-declaration

Fortran don't allow variable value to change


Is there any way to force a variable to be constant even if a subroutine (part of a standard library) tries to change it? Obviously intent(in) throws an error.


Solution

  • Pass a copy of the variable to the library.

    Or pass to your subroutine by VALUE instead of INTENT(IN). It will be changed, but only inside your own subroutine.