This is a fortran 90 function that I have within a main program. As you can see several variables types such as ZLAMS are not declared at the top. But gfortran 5.2 does not report any error whatsoever. If however I move this code to a separate module and then call this function in the main module all the undeclared variables report a compilation error. Why ?
REAL(kind=sp) FUNCTION ABCTEST (PHIS, LAMS, POLPHI, POLLAM)
use k_parameters,ONLY:&
sp
REAL(KIND=SP) LAMS,PHIS,POLPHI,POLLAM
DATA ZRPI18 , ZPIR18 / 57.2957795 , 0.0174532925 /
SINPOL = SIN(ZPIR18*POLPHI)
COSPOL = COS(ZPIR18*POLPHI)
ZPHIS = ZPIR18*PHIS
ZLAMS = LAMS
IF(ZLAMS.GT.180.0) ZLAMS = ZLAMS - 360.0
ZLAMS = ZPIR18*ZLAMS
ARG = COSPOL*COS(ZPHIS)*COS(ZLAMS) + SINPOL*SIN(ZPHIS)
ABCTEST = ZRPI18*ASIN(ARG)
RETURN
END FUNCTION ABCTEST