FORTRAN Reference Manual
Mixed-Language Programming
FORTRAN Reference Manual—528615-001
13-24
Calling FORTRAN Subprograms From COBOL85
If the FORTRAN routine is not compiled with any of these directives, declare all the
address parameters in the TAL external declaration as standard (that is, word)
reference parameters (without .EXT) as in the following example:
PROC fort_sub = "THE_SUB" (a, b, c) LANGUAGE FORTRAN;
INT .a,
.b,
.c;
EXTERNAL;
Precede the CALL with STACK and PUSH statements to place CHARACTER
parameter lengths on the stack as expected by the FORTRAN subprogram, and follow
the CALL with an ADDS instruction to delete those length words.
You can omit the CHARACTER parameter length words if you know that the
FORTRAN subprogram does not declare them as assumed length dummy arguments
with CHARACTER * (*) declarations.
Calling FORTRAN Subprograms From COBOL85
If you write a COBOL85 program that calls a FORTRAN subprogram, you must
compile the FORTRAN subprogram first, because the COBOL85 compiler examines
the object file that contains the compiled subprogram, and generates object code that
sets up parameters in the way the called subprogram expects them.
The Procedure Division statement format is:
ENTER [ FORTRAN ] subprogram [ IN object-file ]
[ USING parameter [ , parameter ] ... ]
[ GIVING return-value ].
where object-file is a file-mnemonic defined in the SPECIAL-NAMES paragraph
of the Environment Division. If you omit the IN (or OF) object-file phrase, the COBOL85
compiler searches the object files named in SEARCH directives, LIBRARY directives,
and CONSULT directives, in that order.
The parameters listed in the USING phrase must agree in number, order, kind, data
type, and dimensions with those of the called subprogram. For data type
correspondence rules, see Appendix D, Data Type Correspondence and Return Value
Sizes. If the called subprogram is a FORTRAN procedure, COBOL85 ensures that the
FORTRAN run-time receives parameter addresses according to the declaration of your
FORTRAN routine and CHARACTER parameter lengths as it expects them.
The GIVING phrase must be present if and only if the called subprogram is a function,
and the data type of return-value must be compatible with that of the subprogram itself.
The called FORTRAN subprogram can be compiled with or without the
EXTENDEDREF compiler directive. COBOL85 generates the correct word or










