Prev: elemental function question regarding use of array slices
Next: Variable scope: how fortran deals with undeclared variables in subroutines?
From: robin on 18 Feb 2010 02:15 "renatoab" <renato_eq(a)yahoo.com.br> wrote in message news:7e197bea-7e7b-42e0-8759-ae4abf8d2a7e(a)g11g2000yqe.googlegroups.com... | Hi everyone, | | I'm trying to fix a program which have many subroutines and many | problems with undeclared variables. What version of Fortran are you using? F77? F90 + ? How are the subroutines organised? Is every one a separate unit? Not contained within anything else? If this is the case, it's quite OK to declare all variables. | I know the best way to do this is to declare them in every subroutines | or pass by parameters, but the program is very complicated, and first | I am trying to understand what happens with the variables, because I'm | afraid to mess something if I make many changes. The complexity of the program has nothing to do with declarations of variables. | Sometimes a variable is used in a subroutine A, without being declared | first, and it has a value. Where this value come from? This depends on the answers to the first questions that I asked. | - the last time a variable with the same name is declared out of the | routine? (it doesn't seem to be the answer, because when the variable | is declared in a subroutine B that calls the subroutine A, the values | in A and B are different) | - the last time a variable is used in a previous call to that | subroutine? | - any value stored in the memory? | I'm confused because it seems to store a value set in a subroutine C | that does not have anything to do with A. There is no "common" in any | subroutine. |