Microsoft KB Archive/57745

Passing Common Numeric Types from COBOL to FORTRAN

PSS ID Number: Q57745 Article last modified on 12-06-1990

3.00 3.00a MS-DOS

Summary: The two programs shown below demonstrate how a COBOL program can pass common numeric data types to Microsoft FORTRAN. This information about interlanguage calling applies to Microsoft COBOL versions 3.00 and 3.00a for MS-DOS.

More Information: For more examples of passing other types of parameters between COBOL and FORTRAN, query on the following word: COB2FOR For a complete discussion about mixed-language programming with COBOL, search in the Software/Data Library for the following word: COBMIXED

Code Example
To demonstrate these programs from an .EXE program, compile and link as follows: COBOL COB.CBL; FL /c /FPi /Lr FOR.FOR ; LINK /NOE /NOD COB MINITF FOR,,,LCOBOL LLIBFE ; Please note that the above FORTRAN library LLIBFE.LIB may be called LLIBFER.LIB, depending on how you installed FORTRAN. Note: MINITF works only with Microsoft FORTRAN version 4.10. If you are doing interlanguage calling with other versions of FORTRAN, FORTRAN must be the main program. Starting from FORTRAN, the COBOL program can be called, which in turn can call back into the FORTRAN program. The following COBOL program is COB.CBL, which calls a FORTRAN procedure and passes passing an integer and a long integer by both value and reference. After returning from the FORTRAN procedure, the items passed by reference are displayed. $SET LITLINK IDENTIFICATION DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 FIELD1 PIC 9(4) COMP-5 VALUE 123. 01 FIELD2 PIC 9(8) COMP-5 VALUE 123456. 01 FIELD3 PIC 9(4) COMP-5 VALUE 456. 01 FIELD4 PIC 9(8) COMP-5 VALUE 456789. PROCEDURE DIVISION. CALL “F_FPROG” USING FIELD1, FIELD2, BY VALUE FIELD3, BY VALUE FIELD4. DISPLAY “Returned PIC 9(4):” FIELD1. DISPLAY “Returned PIC 9(8):” FIELD2. STOP RUN. The following program is FOR.FOR, which assigns the items passed by value to the items passed by reference: SUBROUTINE FPROG(I, J, K, L) INTEGER2 I [FAR] INTEGER4 J [FAR] INTEGER2 K [VALUE] INTEGER4 L [VALUE] I = K J = L END COB.EXE produces the following output: Returned PIC 9(4): 00456 Returned PIC 9(8): 000456789

Copyright Microsoft Corporation 1990.