I've been given old FORTRAN code (parts of it seem to even suggest FORTRAN66, though I'm not sure), an excerpt of which is included below.
PROGRAM FOO
! ------------------------------------------
! Code calling subroutine bar multiple times
! ------------------------------------------
END
subroutine bar(number,x,y,ic,imax)
implicit real*8(a-h,o-z)
dimension x(1000),y(1000),ic(1000)
rmin = -rmax
do n = 1,number
ic(n) = 0
rmax = dmax1(rmax,sqrt(x(n)**2+y(n)**2))
rmin = dmin1(rmin,sqrt(x(n)**2+y(n)**2))
end do
delta = 1.3*sqrt((rmax**2-rmin**2)/number)
! ---------
! More code
! ---------
end
The line that caught my interest is the fourth one of the subroutine: rmin = -rmax
. I've checked and the only occurrences of both rmin
and rmax
in the entire program are those shown here. They aren't even declared anywhere (and not present in any common
block).
However, the code compiles and the program runs just fine. What's going on there? Is this a valid declaration/initialization for both variables? Are they both initialized to zero this way? I assume they are, because (going off of this post) initialization at the time of declaration would mean their value will be conserved between calls to bar
and then the rmin = -rmax
statement makes sense to me.
Any clarification on this kind of declaration/initialization would be greatly appreciated.