I’m trying to get some code compiled under gfortran that compiles fine under g77. The problem seems to be from a return statement:
ffuncs.f:934.13:
RETURN E
1
Error: Alternate RETURN statement at (1) requires a SCALAR-INTEGER return specifier
In the code anything E was specified as real*8:
IMPLICIT REAL*8 ( A – H , O -Z )
However, E was never given a value or anything in fact you never see it until the return statement. I know almost nothing about fortran. What is the meaning of a return statement with an argument in fortran?
Thanks.
In FORTRAN (up to Fortran 77, which I’m very familiar with),
RETURN nis not used to return a function value; instead, it does something like what in other languages would be handled by an exception: An exit to a code location other than the normal one.You’d normally call such a
SUBROUTINEorFUNCTIONwith labels as arguments, e.g.and if things go wrong in MYSUB then you do
RETURN 1orRETURN 2(rather than the normal RETURN) and you’d be hopping straight to label 998 or 999 in the calling routine.That’s why normally you want an integer on that RETURN – it’s not a value but an index to which error exit you want to take.
RETURN Esounds wrong to me. Unless there’s a syntax I’m unaware of, the previous compiler should have flagged that as an error.