Previous | Contents | Index |
The REFORMAT Utility converts source programs between terminal format and conventional ANSI format. Consider the two formats and their characteristics:
The Compaq COBOL Reference Manual describes both formats in detail.
On OpenVMS, REFORMAT is installed by the Compaq COBOL installation procedure (if you answered "yes" to the query during installation), and is placed in the following location:
SYS$SYSTEM:REFORMAT.EXE <> |
On OpenVMS, you may define REFORMAT as a foreign command as follows:
$ REFORMAT :== "$SYS$SYSTEM:REFORMAT.EXE" <> |
To run the REFORMAT Utility, type the following command:
On OpenVMS
$ reformat <> |
On Tru64 UNIX
% reformat <> |
REFORMAT - REFORMAT - Enter Y for ANSI-to-terminal conversion, or REFORMAT - Enter N (default) for terminal-to-ANSI conversion. REFORMAT - Enter ^Z to exit. REFORMAT - ANSI-to-terminal format conversion mode [ Y / [N] ]? n REFORMAT - Terminal-to-ANSI format selected REFORMAT - Terminal-format input file spec : myprog.cob REFORMAT - ANSI-format output file spec: myprog2.cob REFORMAT - Columns 73 to 80: REFORMAT - 42 Terminal source code records converted to ANSI format REFORMAT - REFORMAT - Enter Y for ANSI-to-terminal conversion, or REFORMAT - Enter N (default) for terminal-to-ANSI conversion. REFORMAT - Enter ^Z to exit. REFORMAT - ANSI-to-terminal format conversion mode [ Y / [N] ]? ^Z REFORMAT - |
In the preceding example, the following events took place:
The Ctrl/Z ends this reformatting session.
14.2 ANSI-to-Terminal Format Conversion
REFORMAT converts each ANSI format source line to terminal format by:
When you convert programs that contain continued nonnumeric literals you should examine those literals to see if they require any changes. (This should occur only when going from ANSI format to terminal format.) |
REFORMAT converts each terminal format source line to ANSI format by:
Note that it is possible to construct a terminal format line that converts to an invalid ANSI formatted line. Consider the case of a conditional compilation line with a long nonnumeric literal:
\A 01 ART PIC X(80) VALUE "A ... A". |
This statement cannot be reformatted to a valid ANSI statement. The
literal is 80 characters long, which indicates that the literal must be
continued on the next line by placing a continuation symbol (-) in the
indicator area. The line is also a conditional compilation line, which
indicates that the A is to be placed in the indicator area. Clearly
both characters cannot be placed in the indicator area. Compaq COBOL
continues the conditional compilation line by placing the A in the
indicator area. This means the program remains valid if conditionals
are not used in the compilation because the lines become comment lines.
If conditionals are used, you must locate and correct these invalid
lines. The reformat program is a text processor and does not perform
the level of checking required by lines such as these. You detect this
error during a compile operation.
14.4 REFORMAT Error Messages
If any of your responses to the prompts are incorrect, REFORMAT displays error messages. It replaces the parentheses and the parenthetical text with the appropriate format type you specified.
REFORMAT - Error in opening (ANSI or terminal) format input file: REFORMAT - (ANSI or terminal) format input file spec: |
The system could not open the input file; either the file is not on the specified device or you typed the file name incorrectly.
The default device is SYS$DISK on OpenVMS systems; it is stdin on Tru64 UNIX systems.
To continue processing, examine the input file specification and type a corrected version. To process another file, type a new input file specification. To end execution, type Ctrl/Z (on OpenVMS and Windows NT systems) or CTRL/D (on Tru64 UNIX systems).
REFORMAT - Error in opening (ANSI or terminal) format output file: REFORMAT - (ANSI or terminal) format output file spec: |
The system could not open the output file. An incorrectly typed file specification usually causes this error.
The default device is SYS$DISK on OpenVMS systems; it is ./ on Tru64 UNIX systems.
To continue, examine the output file specification and type a corrected version. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).
REFORMAT - (ANSI or terminal) format input file is empty REFORMAT - (ANSI or terminal) format input file spec: |
The system opened an empty input file. To continue, type a new input file specification. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).
REFORMAT - Error in reading (ANSI or terminal) format input file REFORMAT - Reformating aborted REFORMAT - n (ANSI or terminal) COBOL source records converted to (ANSI or terminal) format REFORMAT - ANSI-to-terminal format conversion mode [ Y or N ]? |
REFORMAT failed to read a record from the input file. This error ends the conversion process. REFORMAT closes both files and displays the number of converted input records.
You can convert another file, or you can end the session by typing Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).
REFORMAT - Error in writing (ANSI or terminal) format output file REFORMAT - Reformatting aborted REFORMAT - n (ANSI or terminal) COBOL source records converted to (ANSI or terminal) format REFORMAT - ANSI-to-terminal format conversion mode [ Y or N ]? |
REFORMAT failed in an attempt to write an output record. It ends execution and closes both files.
To process another file, type a new input file specification and continue the prompting message sequence. To end execution, type Ctrl/Z (on OpenVMS systems) or CTRL/D (on Tru64 UNIX systems).
You can specify optimization and data alignment on the COBOL compiler command line to improve run-time performance. You can also decrease processing time and save storage space by writing programs that take advantage of compiler optimizations.
The information that you find here contains guidelines only, not rules. Follow those suggestions that fit your needs.
This chapter provides the following information about optimizing your Compaq COBOL programs on one or more of the OpenVMS Alpha,Tru64 UNIX, and Windows NT operating systems:
The Compaq COBOL compiler is a highly optimizing compiler. Full optimization is the default with the COBOL compiler command and usually results in improved run-time performance. You can specify the desired level of optimization by adding a value to the optimize option. The various formats are provided here to illustrate the similarity in processes across the supported platforms.
On OpenVMS Alpha systems, the /OPTIMIZE qualifier has the following forms:
/OPTIMIZE[=LEVEL=n] |
/OPTIMIZE=TUNE=keyword |
or
/NOOPTIMIZE <> |
On Tru64 UNIX systems, the -O flag and the -tune flag specify optimization. The -O flag has the following form:
-On |
The -tune flag has the following form:
-tune keyword <> |
The -tune flag is the equivalent of the /OPTIMIZE=TUNE qualifier.
On Windows NT systems, /OPTIMIZE and /TUNE specify optimization. The /OPTIMIZE option has the following form:
/OPTIMIZE[=n] <> |
The /TUNE option has the following form:
/TUNE[=keyword] |
On all systems, n is a number ranging from 0 to 4, specifying the level of optimization. In brief, these levels mean the following:
/OPTIMIZE=TUNE=keyword (or -tune keyword or /TUNE=keyword) specifies the kind of optimized code to be generated, allowing you to tune optimization to the hardware. The keyword can be any of the following:
The /ARCHITECTURE= option qualifier (or -arch option on Tru64 UNIX) determines the type of Alpha chip code that will be generated for a particular program.
The /ARCHITECTURE qualifier uses the same options (keywords) as the /OPTIMIZE=TUNE qualifier, and their definitions are similar. However, their effects are not identical. The /OPTIMIZE=TUNE qualifier is primarily used by certain higher-level optimizations for instruction scheduling purposes, while the /ARCHITECTURE qualifier determines the type of code instructions generated for the program unit being compiled.
OpenVMS Version 7.1 and subsequent releases provide an operating system kernel that includes an instruction emulator. This emulator allows new instructions, not implemented on the host processor chip, to execute and produce correct results. All Alpha processors implement a core set of instructions. Certain Alpha processor versions include additional instruction extensions. Applications using emulated instructions will run correctly, but might incur significant software emulation overhead at run time.
The following /ARCHITECTURE options are supported:
If a program contains declarations of non-EXTERNAL variables that are not referenced in the program, the Compaq COBOL compiler does not allocate those variables. These variables are not affected by /OPTIMIZE; they simply are not allocated. This feature improves both resource usage and run-time performance, and allows the use of site "copybooks" that have numerous standardized variables. Only those copybook variables that are referenced will be allocated within a given program. |
You should disable optimization when you compile a program for debugging. Optimizations can cause unexpected and confusing behavior in a debugging session by changing the order of machine code. When you turn optimization off, a debugging session is expedited and simplified because the machine code is put in the same order as the lines in your source program.
On the Tru64 UNIX operating system, full optimization, corresponding to the -O4 or -O flag, is the default unless you specify the -g flag on the command line for debugging. The -g flag disables optimization entirely, and displays this message:
cobol: Warning:...File not optimized; use -g3 if both optimization and debugging wanted <> |
On OpenVMS Alpha systems, in general, specify /NOOPTIMIZE if you specify /DEBUG when you compile a program. If you specify /DEBUG but omit any form of the /OPTIMIZE qualifier on the command line, the compiler issues the following informational message:
%COBOL-I-DEBUGOPT, /NOOPTIMIZE is recommended with /DEBUG |
Unlike other informational messages, which are turned off by default, this message is issued even if /WARNINGS=NOINFORMATION is in effect. You can turn it off by specifying any form of the /OPTIMIZE qualifier.
If you need to debug optimized code, see the OpenVMS Debugger Manual. <>
An effect of optimization is larger object modules and longer compile times. These potential disadvantages are typically outweighed by faster run times.
To speed compilations during program development, you may want to compile with the noobject option when you want to check syntax.
When checking for correct execution, you may want to compile initially with no optimization, and later with optimization when the program is executing correctly.
If your program is not executing correctly and you suspect an optimization-related problem, try compiling it with no optimization or with level 2 optimization. The latter is a compromise that can often help, because it turns off some of the more aggressive optimizations, such as decimal shadowing.
Previous | Next | Contents | Index |