Determining the main routine

In Language Environment, only one routine can be the main routine; no other routine in the enclave can use syntax that indicates it is main.

A COBOL program is designated as main if it is the first program to run in an enclave. A Fortran routine is designated as a main routine with a PROGRAM statement, which indicates the name of the main routine. A main routine can also be designated when there are no PROGRAM, SUBROUTINE, or FUNCTION statements, in which case the name of the main routine is the default value of MAIN (or MAIN# for VS FORTRAN Version 2 Releases 5 and 6). The name of the main routine is the entry point into the load module.

Table 1 describes how COBOL and Fortran identify the main routine.

Table 1. How COBOL and Fortran main routines are determined
Language When determined Explanation
COBOL Run time Determined dynamically. If it is the first program to run, it is a main program.
Fortran Compilation Determined in the Fortran source by the name on the PROGRAM statement.

An entry point is defined for each supported HLL. Table 2 identifies the main and fetched entry point for each language. The table assumes that your code has been compiled using the Language Environment-conforming compilers.

Table 2. Determining the entry point
HLL Main entry point Fetched entry point
COBOL Name of the first object program to get control in the object module Program name
Fortran Name on the PROGRAM statement, or MAIN (or MAIN# for VS FORTRAN Version 2 Releases 5 and 6), if no PROGRAM, SUBROUTINE, or FUNCTION statements are used Subprogram name