Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does the "END PROGRAM" statement come before or after the subroutines?

Status
Not open for further replies.

efoss

Technical User
Nov 27, 2005
16
US
Does the "END PROGRAM" statement come before or after the subroutines?

I'm a beginner with Fortran. I'm having problems with a program that has several subroutines. I've seen the "END PROGRAM" statement both before and after the subroutines. My program (running on Compaq Visual Fortran) seems to much prefer the "END PROGRAM" before the subroutines, but I'm still getting the following error message:

Error: Syntax error, found END-OF-FILE when expecting one of: <LABEL> <END-OF-STATEMENT> ; BLOCK BLOCKDATA PROGRAM TYPE COMPLEX BYTE CHARACTER ...

I've searched the manuals and Googled this to find an explanation, but haven't been successful. It sounds like I don't have some sort of "END" statement at the end of the program, since it always says that the problem line is the last line in the program.

Thanks.

Eric
 
It comes at the end of the program segment. It doesn't have to be at the beginning or the end although that is where most people will put it. For instance your layout could be
Code:
function xxx
...
end function

program main
...
stop
end program
subroutine fred
...
end subroutine
 
Thanks, xwb. That makes sense. That's how my compiler seemed to want it, but I was confused by the error message. I've now figured out that the error message came from some other mistake in my code (though I haven't yet figured out what that is).

Thanks again for the help.

Eric
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top