Microsoft KB Archive/57744

Passing Common Numeric Types from FORTRAN to COBOL

PSS ID Number: Q57744 Article last modified on 12-05-1990

3.00 3.00a MS-DOS

Summary: The two programs shown below demonstrate how a Microsoft FORTRAN program can pass common numeric data types to COBOL. 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, search in this Knowledge Base for 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 FOR COB,,,LLIBFE LCOBOL ; Please note that the above FORTRAN library LLIBFE.LIB may be called LLIBFER.LIB, depending on how you installed FORTRAN. The following COBOL program is COB.CBL, which is passed an integer and a long integer from the calling FORTRAN program. The passed values are then displayed. $SET LITLINK IDENTIFICATION DIVISION. PROGRAM-ID. &quot;_CobProg“. DATA DIVISION. WORKING-STORAGE SECTION. LINKAGE SECTION. 01 INTNUM PIC 9(4) COMP-5. 01 LONGNUM PIC 9(8) COMP-5. PROCEDURE DIVISION USING INTNUM, LONGNUM. DISPLAY”Passed INTNUM : &quot; INTNUM. DISPLAY “Passed LONGNUM :” LONGNUM. STOP RUN. The following program is FOR.FOR, which assigns values to the two data items, which are then passed to the COBOL program: INTERFACE TO SUBROUTINE COBPROG [C] (I, J) INTEGER2 I [FAR, REFERENCE] INTEGER4 J [FAR, REFERENCE] END INTEGER2 I INTEGER4 J I = 5 J = 7 CALL COBPROG(I, J) END FOR.EXE produces the following output: Passed INTNUM : 00005 Passed LONGNUM : 000000007

Copyright Microsoft Corporation 1990.