FORTRAN Reference Manual

Mixed-Language Programming
FORTRAN Reference Manual528615-001
13-19
Calling COBOL85 Subprograms From FORTRAN
TAL convention, and does not stack length words for character parameters. For
example, if the TAL procedure is declared by:
PROC p (s: l);
STRING .EXT s;
INT l;
EXTERNAL;
the colon between S and L causes the TAL compiler to declare (to the Binder) that
L is a parameter pair. The corresponding references to this procedure P in the
following FORTRAN and TAL subprograms are equivalent:
PROC tal;
SUBROUTINE fortran BEGIN
CHARACTER * 20 c STRING .c[0: 19];
CALL p(c) CALL p( c:20);
CALL p(c (6: 12)) CALL p( c[5]:7 );
END END;
In each subprogram the first CALL statement passes all of C with a length of
twenty characters, and the second CALL statement passes a substring consisting
of the sixth through twelfth characters of C with a length of seven characters. Note
that each CALL statement in the FORTRAN routine has only one argument. The
length value argument is implicit.
Calling COBOL85 Subprograms From FORTRAN
If you write a FORTRAN subprogram that calls a subprogram written in COBOL85, you
must observe the following rules:
If your COBOL85 and FORTRAN programs are compiled with ENV OLD in effect,
the main program must be written in COBOL85, so that it establishes the run-time
environment required by COBOL85 object code. FORTRAN’s requirements are a
subset of COBOL85’s. This restriction does not apply if you specify ENV
COMMON.
Regardless of whether you compile with ENV OLD or ENV COMMON, you can do
I/O in COBOL85 and FORTRAN in the same program but not, in general, on the
same file.
If you specify ENV COMMON, your FORTRAN and COBOL85 routines can share the
same file open to the standard input and standard output files—unit 5 and unit 6 in
FORTRAN. In COBOL85 you reference the standard input file when you execute an
ACCEPT verb; you reference standard output when you execute a DISPLAY verb. See
Using Shared Files on page 13-27.
If the FORTRAN program does not declare the COBOL85 subprogram with a
CONSULT directive: