Documentation
14. Main program
14. Main program
The main program is where execution begins. Every executable program has exactly one (§14).
PROGRAM PAYROLL
...
END
- The
PROGRAMstatement, if present, is the first statement and names the program. The name is documentation; it has no other use. ThePROGRAMline is optional — a unit with no header that isn't aFUNCTION/SUBROUTINE/BLOCK DATAis the main program. - A main program may contain any statements except
FUNCTION,SUBROUTINE,BLOCK DATA,ENTRY, orRETURN— it is not a procedure and is never called. - Reaching the main program's
END(or executing aSTOP) terminates the program.
That is the whole of it; the substance of a program lives in its statements (earlier chapters) and its subprograms (Chapter 15).
forterp notes.
PROGRAMis optional and, when present, named, exactly as specified; execution starts at the main program's first executable statement regardless of where the unit appears in the source.