4 IDENTIFICATION DIVISION

IDENTIFICATION DIVISION Syntax

[{ IDENTIFICATION } DIVISION. ]
 { ~~~~~~~~~~~~~~ } ~~~~~~~~
 { ID             }
   ~~
 { PROGRAM-ID.  } { program name } .
 { ~~~~~~~~~~   } { literal-1    } [ AS { literal-2 } ] [ Type-clause ] .
 { FUNCTION-ID. } { literal-3 } [ AS literal-4 ] .
   ~~~~~~~~~~~    { function-name } .
 { OPTIONS. }
   ~~~~~~~
 [ DEFAULT ROUNDED MODE IS {AWAY-FROM-ZERO         }
   ~~~~~~~ ~~~~~~~         {NEAREST-AWAY-FROM-ZERO }
                           {NEAREST-EVEN           }
                           {NEAREST-TOWARDS-ZERO   }
                           {PROHIBITED             }
                           {TOWARDS-GREATER        }
                           {TOWARDS-LESSER         }
                           {TRUNCATION             }]
 [ ENTRY-CONVENTION IS {COBOL   }
   ~~~~~~~~~~~~~~~~    {EXTERN  }
                       {STDCALL }]
 [ AUTHOR.        comment-1. ]
   ~~~~~~
 [ DATE-COMPILED. comment-2. ]
   ~~~~~~~~~~~~~
 [ DATE-MODIFIED. comment-3. ]
   ~~~~~~~~~~~~~
 [ DATE-WRITTEN.  comment-4. ]
   ~~~~~~~~~~~~
 [ INSTALLATION.  comment-5. ]
   ~~~~~~~~~~~~
 [ REMARKS.       comment-6. ]
   ~~~~~~~
 [ SECURITY.      comment-7. ]
   ~~~~~~~~

The AUTHOR, DATE-COMPILED, DATE-MODIFIED, DATE-WRITTEN, INSTALLATION, REMARKS and SECURITYparagraphs are supported by GnuCOBOL only to provide compatibility with programs written for the ANS1974 (or earlier) standards. As of the ANS1985 standard, these clauses have become obsolete and should not be used in new programs. PROGRAM-ID Type Clause Syntax

IS [ COMMON ] [ INITIAL|RECURSIVE PROGRAM ]
     ~~~~~~     ~~~~~~~ ~~~~~~~~~

The identification division provides basic identification of the program by giving it a name and optionally defining some high-level characteristics via the eight pre-defined paragraphs that may be specified.

  1. The paragraphs shown above may be coded in any sequence.

  2. The reserved words AS, IS and PROGRAM are optional and may be included, or not, at the discretion of the programmer. The presence or absence of these words has no effect upon the program.

  3. A Type Clause may be coded only when PROGRAM-ID is specified. If one is coded, either COMMON, COMMON INITIAL or COMMON RECURSIVE must be specified.

  4. While the actual IDENTIFICATION DIVISION or ID DIVISION header is optional, the PROGRAM-ID / FUNCTION-ID paragraphs are not; only one or the other, however, may be coded.

  5. The compiler’s -Wobsolete switch will cause the GnuCOBOL compiler to issue warnings messages if these (or any other obsolete syntax) is used in a program.

  6. If specified, <literal-1> must be an actual alphanumeric literal and may not be a figurative constant.

  7. The PROGRAM-ID and FUNCTION-ID paragraphs serve to identify the program to the external (i.e. operating system) environment. If there is no AS clause present, the <program-id> will serve as that external identification. If there is an AS clause specified, that specified literal will serve as the external identification. For the remainder of this document, that “external identification” will be referred to as the primary entry-point name.

  8. The INITIAL, COMMON and RECURSIVE words are used only within subprograms serving as subroutines. Their purposes are as follows:

    1. COMMON should be used only within subprograms that are nested subprograms. A nested subprogram declared as COMMON may be called from any nested program in the source file being compiled, not just those “above” it in the nesting structure.

    2. The RECURSIVE clause, if any, will cause the compiler to generate different object code for the subprogram that will enable it to invoke itself and to properly return back to the program that invoked it.

      User-defined functions (i.e. FUNCTION-ID) are always recursive.

    3. The INITIAL clause, if specified, guarantees the subprogram will be in its initial (i.e. compiled) state each and every time it is executed, not just the first time.