- #1
kanato
- 415
- 1
I have this line in a Fortran 77 program, and I don't understand how it works:
nran(i)=mod(int(i*ranw(Idum)),i) + 1
What I don't understand is that nran is not a function, nor is it dimensioned anywhere (its type is implicitly an integer). This line only works if it comes right after the variable declarations in the function. If I put some non-declaration statement above it then the compiler (ifort 9.1, Linux ia64) complains that nran is not a function or dimensioned anywhere. That's sort of a big "duh" but I don't understand why this works if it's above with the variable declarations. It seems to be declaring an array for nran, but I have no idea how it knows what size/bounds to make it, as there is no indication of what values i should take.
If you are interested, this is a program based off the lisaqmc.f program available http://www.physics.rutgers.edu/~udo/qmc/readme_lisaqmc.html" .
(I should mention, I understand what mod and int are, and ranw is a function which returns a random real number using the seed given in Idum. This line would be totally clear to me if it was in a loop and nran was dimensioned somewhere.)
nran(i)=mod(int(i*ranw(Idum)),i) + 1
What I don't understand is that nran is not a function, nor is it dimensioned anywhere (its type is implicitly an integer). This line only works if it comes right after the variable declarations in the function. If I put some non-declaration statement above it then the compiler (ifort 9.1, Linux ia64) complains that nran is not a function or dimensioned anywhere. That's sort of a big "duh" but I don't understand why this works if it's above with the variable declarations. It seems to be declaring an array for nran, but I have no idea how it knows what size/bounds to make it, as there is no indication of what values i should take.
If you are interested, this is a program based off the lisaqmc.f program available http://www.physics.rutgers.edu/~udo/qmc/readme_lisaqmc.html" .
(I should mention, I understand what mod and int are, and ranw is a function which returns a random real number using the seed given in Idum. This line would be totally clear to me if it was in a loop and nran was dimensioned somewhere.)
Last edited by a moderator: