The return statement is used to transfer control from a function or subroutine back to the program unit that referenced it.
The return statement is another basic statement in the FORTRAN language. Its purpose as stated above is pretty simple, functioning as a fancy GO TO statement. Although, it should be noted that it is not required that it even appear inside of a subroutine or function. The end statement at the termination of the function or subroutine will serve the same purpose if the RETURN statement is not present. Also, the RETURN statement doesn't have to appear at the end of the procedure. It can appear anywhere inside of a subprogram unit and in multiple places. For instance look at the following subroutine to see how it can be used to in several different places.
Subroutine run_it(x,y,z) implicit none real x,y,z,a,b,c a = y + z b = z * (x + y) c = z/y if (x.lt.a) then return else if (b.lt.x.or.c.gt.a) then go to 1000 else go to 1100 end if 1000 x = a+b+c return 1100 x=y-z return end subroutine run_it
plot2.f and roof.f
Written by Jason Wehr : email@example.com and Maintained by John Mahaffy : firstname.lastname@example.org