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
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.