COBOL - Group home

How to tone down optimization for complex or large programs?

  

In COBOL for z/OS, V5,1, when compiling your source files that are too complex or in a relatively large size, and if you have specified the OPTIMIZE level, it may take excessive amount of time or storage. Thus a new compiler option, MAXPCF, is introduced to allow you to control the amount of time and storage used when optimizing a program. You can specify the maximum program complexity factor with this option. The new term, Program Complexity Factor (PCF), is a value calculated by the compiler, and represents the complexity of the program being compiled.

 

PCF is documented in the listing file, and the following aspects affect PCF:

  • The number of COBOL statements in the PROCEDURE DIVISION, including generated statements from the SQL or CICS options and the expansion of COPY statements

  • Initialization operations for WORKING-STORAGE or LOCAL-STORAGE data items with value clauses

  • Operations for variable-length groups or subgroups in the DATA DIVISION, which compute their size at run time


Here's a fragment taken from the short listing example of the COBOL program IGYTCARA, where shows the PCF is 486.

...
...
...
* Statistics for COBOL program IGYTCARA:
* Source records = 1755
* Data Division statements = 295
* Procedure Division statements = 479
* Generated COBOL statements = 0
* Program complexity factor = 486
End of compilation 1, program IGYTCARA, highest severity 12.
Return code 12

See the syntax of the MAXPCF option below:


n
must be an integer of 0 – 999999, and the default value is MAXPCF(60000).

 

If you specify MAXPCF(0), no limit will be enforced on the complexity of the program.

If you specify the MAXPCF(n) option and n is not zero, when PCF exceeds n, even if you've specified OPTIMIZE(1) or OPTIMIZE(2), it will be reset to OPTIMIZE(0), and a warning message is generated.

In all, specifying MAXPCF value can avoid excessive compilation time or storage requirements when compiling a suite of programs, and you don't need to specify individual OPTIMIZE(n) option values for each program. However, please note that specifying MAXPCF will limit the optimization effects, and reduce the performance of the generated code, too.