Microsoft KB Archive/39383

COBOL Prog May Hang at STOP RUN After CALLing FORTRAN Function

PSS ID Number: Q39383 Article last modified on 04-20-1993

3.00 3.00a 4.00 | 3.00 3.00a 4.00 MS-DOS | OS/2

Summary: When a Microsoft COBOL version 3.0 or 3.0a program CALLs a Microsoft FORTRAN function, the COBOL program may hang after it has returned from the FORTRAN function and it reaches the STOP RUN or EXIT PROGRAM statement. Microsoft has confirmed this to be a problem in versions 3.0 and 3.0a and Microsoft COBOL Professional Development System version 4.0 for MS-DOS and MS OS/2. We are researching this problem and will post new information here as it becomes available.

More Information: The example program below, after compilation and LINKing, will hang at the STOP RUN statement. The COBOL program should be compiled with the following command line: COBOL cobprog /LITLINK /VSC2; The FORTRAN function should be compiled with the following command line: FL /c /FPi fortfn The two should be LINKed with the following command line: LINK /noe /nod cobprog+minitf+fortfn,,,lcobol+llibfore; The following is COBPROG.COB: WORKING-STORAGE SECTION. 01 TEMP-ITEMS. 05 MARK1 PIC 9(4) COMP-5 VALUE 10. 05 MARK2 PIC 9(4) COMP-5 VALUE 20. 05 MARK3 PIC 9(4) COMP-5 VALUE 30. 05 LOOP-VAR PIC 9(4) COMP VALUE ZERO. PROCEDURE DIVISION. A1000-INIT. CALL “F_FORTFN” USING MARK1, MARK2, MARK3. DISPLAY ‘RETURNED FROM FORTRAN OKAY AVG:’, RETURN-CODE. MOVE 1 TO LOOP-VAR. PERFORM A2000-TEST-LOOP UNTIL LOOP-VAR = 20. STOP RUN. A2000-TEST-LOOP. DISPLAY ‘TEST-LOOP-NUMBER ->’, LOOP-VAR. ADD 1 TO LOOP-VAR. The following is FORPROG.FOR: C This is a FORTRAN function to find the average of 3 marks: integer2 function fortfn(mark1, mark2, mark3) integer2 mark1, mark2, mark3 [FAR] real avg, sum write (,) ‘Mark #1 ->’, mark1 write (,) ‘Mark #2 ->’, mark2 write (,) ‘Mark #3 ->’, mark3 fortfn = (mark1 + mark2 + mark3) / 3 write (,) ‘SUM:’, mark1 + mark2 + mark3, ‘AVERAGE:’, fortfn return end

Additional reference words: 3.00 3.00a 4.00 Copyright Microsoft Corporation 1993.