Re: What's Wrong With a Loop?
It's worse than that. Not only can you have multiple entry points, you can pass the possible exit points to the function
That is to say you can do
CALL RANK ( N, *8, *9 )
WRITE (*,*) 'OK - Normal Return'
STOP
8 WRITE (*,*) 'Minor - 1st alternate return'
STOP
9 WRITE (*,*) 'Major - 2nd alternate return'
END
SUBROUTINE RANK (N, *, *)
IF ( N .EQ. 0 ) RETURN
IF ( N .EQ. 1 ) RETURN 1
RETURN 2
END
I'm pretty sure this is what the 'no multiple returns from a function' rule refers to. IMHO it makes absolutely no sense except for fortran