FORTRAN Reference Manual
Mixed-Language Programming
FORTRAN Reference Manual—528615-001
13-12
Calling Other Language Procedures From
FORTRAN
because the top few words of the stack will be as follows:
'L' - 0 Caller's (L)
'L' - 1 Caller's (E)
'L' - 2 Caller's (P)
'L' - 3, 4 Extended address of DOYLE
'L' - 5, 6 Extended address of MORIARITY
'L' - 7, 8 Extended address of HOLMES
'L' - 9,10 Extended address of RESULT
'L' - 11 Length of MORIARITY
'L' - 12 Length of RESULT
Calling Other Language Procedures From 
FORTRAN
If you write a FORTRAN program that calls subprograms written in other languages, 
you can use:
•
The GUARDIAN directive for Guardian procedures and utility routines
•
The CONSULT directive for user-supplied procedures written in C, COBOL85, 
FORTRAN, Pascal, and TAL
to give the FORTRAN compiler the information it needs so that you can invoke such 
routines from your FORTRAN program in the same way that you would call a 
FORTRAN subroutine or function subprogram. The compiler translates the argument 
list into an appropriate calling sequence according to the declaration of the referenced 
procedure, without special coding on your part.
To use the GUARDIAN and CONSULT directives you must have an object file from 
which the FORTRAN compiler can get the information about the called procedures.
The procedures in the file can be stubs (with empty or incomplete executable portions), 
because the FORTRAN compiler needs only the procedure’s name and attributes and 
attributes of each of its parameters.
The files required for the GUARDIAN directive are provided by HP along with the 
FORTRAN compiler, but you must create any files referenced by CONSULT directives. 
This means that procedures must exist (at least as stubs) before you can compile a 
FORTRAN program that refers to them with CONSULT directives.
You can also call subprograms written in another language from a FORTRAN program 
without using GUARDIAN or CONSULT directives, but you must code the procedure 
header to expect the default calling sequences that FORTRAN generates without 
these directives, as described in the preceding subsection.










