COBOL Manual for TNS and TNS/R Programs
Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs—522555-006
23-29
Passing Parameters to Non-COBOL Routines
FORTRAN
By default, FORTRAN routines use 16-bit addressing for parameters. You can specify
32-bit addressing using either of two FORTRAN compiler directives: EXTENDEDREF
or LARGECOMMON (LARGECOMMON also specifies that common blocks are to be
allocated in extended memory). Each FORTRAN routine uses the same addressing
mode for all parameters it receives or passes. All FORTRAN routines bound into one
object file must use the same addressing mode.
You must pass parameters to FORTRAN routines by reference. To pass a noninteger
numeric value to a FORTRAN routine, an HP COBOL program must pass a
COMPUTATIONAL item of 2, 4, or 8 bytes and either pass a scale factor (power of 10)
as a separate parameter or have an agreed-upon scale factor for the item. The
FORTRAN program must receive the parameter as an integer of the appropriate size
and perform the corresponding scaling operation explicitly.
C code:
char *work; /* global to share with HP COBOL program */
int x;
...
work = (char*)malloc(2);
...
x = *(int*)flip;
*(int*)flip++;
y = ...
Example 23-7. Passing a String to a C Routine
HP COBOL code:
DATA DIVISION.
WORKING-STORAGE SECTION.
01 A-STRING PICTURE X(25).
...
PROCEDURE DIVISION.
...
ENTER C "FUNCT1" USING A-STRING
C routine:
FUNCT1 (char *d)
...
return void;
Note. This topic applies only to TNS HP COBOL programs. Native HP COBOL programs
cannot call FORTRAN routines. If you want your native HP COBOL program to call a
FORTRAN routine, convert the FORTRAN routine to native HP C, native HP C++, or pTAL.
Example 23-6. Using External Declarations to Pass Integers to C
Routine (page 2 of 2)