COBOL Manual for TNS and TNS/R Programs

Calling Other Programs and Routines
HP COBOL Manual for TNS and TNS/R Programs522555-006
23-30
Passing Parameters to Non-COBOL Routines
In both the non-CRE environment and the CRE:
An HP COBOL program cannot pass anything to a formal FORTRAN parameter of
the type COMPLEX.
FORTRAN stores multidimensional arrays in column-major order and HP COBOL
stores them in row-major order. To illustrate, FORTRAN declares the array
DIMENSION X (3,2)
and allocates memory for its elements in this order:
X(1,1), X(2,1), X(3,1), X(1,2), X(2,2), X(3,2)
HP COBOL would allocate memory for the same array (table) elements in this
order:
X(1,1), X(1,2), X(2,1), X(2,2), X(3,1), X(3,2)
For more information about FORTRAN routines, see the FORTRAN Reference
Manual.
Example 23-8. Passing Parameters to a FORTRAN Routine
COBOL95 code:
...
* DOUBLEWORDS, SCALED BY 1000, SO THAT THE VALUE DELIVERED
* IS THE NUMBER OF THOUSANDTHS
01 THE-PARAMETER USAGE IS COMPUTATIONAL.
03 BASE PICTURE S9(5)V9(3).
03 POWER PICTURE S9(5)V9(3).
03 RAISED PICTURE S9(5)V9(3).
...
MOVE 89 TO BASE.
MOVE .5 TO POWER
ENTER FORTRAN "ROUTINEX"
USING BASE
POWER
GIVING RAISED.
...
FORTRAN code:
INTEGER*4 FUNCTION ROUTINEX ( IA, IB )
INTEGER*4 IA, IB
DOUBLE PRECISION DA, DB
C SCALE DOWN
DA = DBLE (IA) / 1000
DB = DBLE (IB) / 1000
C RAISE TO POWER AND SCALE UP BEFORE GOING ON
ROUTINEX = INT4 ( (DA ** DB) * 1000.D0)
RETURN
END