Notes on COBOL Verbs

The following notes describe special considerations for COBOL verbs when you are calling the ACUCOBOL-GT runtime from a C main program.


The CALL and CALL RUN verbs work normally. You return from a CALL with EXIT PROGRAM and from a CALL RUN with STOP RUN.


The EXIT PROGRAM verb works normally. Use EXIT PROGRAM to return from a COBOL subroutine to the C function that called it.


A STOP RUN causes the runtime to shut down (except when a STOP RUN returns to a CALL RUN statement). If you need to control the shutdown in C (to perform clean-up for example), do not code any STOP RUN statements. Alternatively, you can place any clean-up code you need in the acu_shutdown() routine found in "sub.c". This routine is automatically executed during runtime shutdown.

Refer to the no_stop element of the ACUCOBOLINFO structure for more information.


Both the CHAIN and CALL PROGRAM verbs halt the current run unit and initiate a new run unit. Use these verbs with care as they prevent you from returning to your C main program. The chained-to COBOL program is now treated as the start of a new run unit, essentially meaning that it acts like a main program. Because it is treated like a main program, the EXIT PROGRAM verb in it is ignored. The only way to halt the program is with a STOP RUN (which halts the entire runtime) or with another CHAIN.

If you do execute a CHAIN or CALL PROGRAM, any C routines that are part of the call stack leading to the first COBOL subroutine will be left in place. Although you cannot access these routines, their stack memory remains allocated. On the other hand, any C routines that are on the call stack after the first COBOL subroutine will be removed from the stack.

There is one case where you can still return to your C routine after executing a CHAIN. This case occurs when you use the CALL RUN verb to initiate a new run unit without halting the original. The new run unit can use CHAIN. When the new run unit finally executes a STOP RUN, control returns to the original run unit, which may still return to your C routine via an EXIT PROGRAM.

However, we suggest avoiding these verbs.