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!

Subroutine Arguments

Status
Not open for further replies.

Talyrond

Technical User
Mar 30, 2005
2
GB
Hi, I am trying to compile some Legacy Fortran Code I have been given, I believe it is Fortran 77. I am new to Fortran and have searched all I can to resolve this issue, but with no luck!
I am getting compiler errors say I am passing the incorrect number of arguments

Declaration example:

SUBROUTINE TEST (PARA1, PARA2, PARA3, PARA4, *)

I believe the problem is related to the last argument, as you can see it contains a '*', I can only assume that this is some sort of optional parameter, but I cant get the code to compile. I am using FTN95 Fortran 95 for Windows from SilverFrost.
The number of calls to the routine do vary and sometimes, use '*9999' as a passing value for the last argument, strange!

Any help would be appreciated

Thank you
 
Optional arguments aren't standard in F77. This must be a compiler feature. In F9x, they have to declared as optional eg
Code:
SUBROUTINE TEST (A,B,C,D,E)
OPTIONAL E
...
 
Thanks for the info, that would explain things
 
Talyrond,
I think that parameter is a return label. Inside the subroutine, you should see a RETURN statement, but you should also see a RETURN 1 statement. The RETURN 1 statement tells the calling routine to jump to the label passed in for that last parameter upon return from the subroutine. In your example, when the RETURN 1 statement is executed within the subroutine, the calling routine should jump to line 9999. Otherwise, it will continue on in the calling program starting with the next statement after the call to your subroutine. It's been a while since I've done any of this. Hopefully this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top