Operating System - OpenVMS
cancel
Showing results for 
Search instead for 
Did you mean: 

Fortran problem

 
SOLVED
Go to solution
Willem Grooters
Honored Contributor

Fortran problem

See attachement (Fortan 8.2, Alpha)

The documentation is not clear about specifying STRUCTURE in an INTERFACE block.
What worries me most is that the strcucure isn't recognized at all. If I remove the Interface block or use INTEGER*4 and CHARACTER*(*), it's no problem at all.

What did I miss?

Willem Grooters
OpenVMS Developer & System Manager
5 REPLIES 5
John Reagan
Respected Contributor
Solution

Re: Fortran problem

The manual clearly says: "An interface block comprises its own scoping unit, and does not inherit anything from its host though host association." That means that the structure X declared earlier is not visible inside the interface block. Things like INTERGER*4 or CHAR*(*) are builtin types that are available at any time.
Jess Goodman
Esteemed Contributor

Re: Fortran problem

You do need to define an explicit interface for function Y because it has an optional argument. However there are other ways to do this besides using an interface block.

You could just make function Y an internal procedure by defining it after a CONTAINS statement and moving the END PROGRAM to after END FUNCTION Y. You would then not need the INCLUDE statement inside the Y function definition.

Or you could define function Y in a MODULE. You would then add a "USE module_name" statement right after the PROGRAM X line.

For either of these alternatives remove the interface block from the include file.
I have one, but it's personal.
Willem Grooters
Honored Contributor

Re: Fortran problem

John:
I must have overlooked that sentence, so that explaines why the strcuture isn't recognized in the INTERFACE block. I _think_ I found a way to get around it.

Jess:
This is just the reproducer, and in that context you are right, and I would have followed your suggestion anyway. In real, the problem occurs where the called routine ("Y" in the reproducer) is one of many in a library, called by many others. So your solution doesn't work here.
Willem Grooters
OpenVMS Developer & System Manager
Willem Grooters
Honored Contributor

Re: Fortran problem

Jess:
Overlooked the second alternative :) That might work, if that allows "PRESENT" as a check whether an argument has been passed or not (IARGCOUNT may be sufficient in some cases and ís used where possible. But in some cases, this is not enough)
Willem Grooters
OpenVMS Developer & System Manager
Willem Grooters
Honored Contributor

Re: Fortran problem

Could get around the problem - those routines that have a STRUCTURE typed argument have no optional arguments so can be kept outsize INTERFACE - for the sources at hand.
Willem Grooters
OpenVMS Developer & System Manager