I am modifying the old source code written in F77 to F90. I suffer the pain to sort out the which variable is intent(in), intent(out) and intent(inout).
Do you have any guidelines or tips?
Any thoughts and suggestions are appreciated.
Michael
intent (inout) will always work if the actual argument is a variable (see Fortran intent(inout) versus omitting intent), but provides the programmer and compiler with no information. Nor is an intent attribute required so you can gradually improve the code. If the variable only appears on the RHS of assignment statements, then intent (in) is best. If only on the LHS, then intent (out). It gets more complicated if the variable is used as an argument to one or more procedure calls because then you have to trace the usage in that procedure. Thus easiest if you start with the lowest level procedures and work your way up. Most compilers will warn of mistakes, e.g., assigning to an intent (in) argument. For the compiler to check consistency across procedures the interface of each called procedure needs to be explicit to the caller. The easiest way to make the interface known is to place your procedures into a module or modules and "use" that module. The interfaces are explicit between procedures in the same module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With