Reputation: 1334
To remind me that a variable from a module used in a subroutine is an input rather than an output, I usually add comments to indicate this, which provides nothing to compilers.
Upvotes: 3
Views: 450
Reputation: 60078
There is no such thing in Fortran that would import a module variable as a constant. As roygvib mentioned, you can declare a variable protected
inside the module to make it read only for all other modules. But you cannot import a non-protected variable as read-only in Fortran.
I recommend not to treat module variables, which are really just better global variables, as input or output. If something is clearly an input or output of your subroutine, make it an argument explicitly and call it in such a way that is clear what you are doing - with the global variable as an actual argument.
Upvotes: 3