Compaq COBOL

Compaq COBOL

User Manual

Order Number: AA--Q2G1F--TK


October 2000

This manual provides information to help you develop Compaq COBOL programs for the OpenVMS Alpha and Compaq Tru64 UNIX platforms.

Revision/Update Information: This manual supersedes the
DIGITAL COBOL User Manual,
Version 2.5.

Operating System and Version: OpenVMS Alpha Version 6.2 or higher;
Tru64 UNIX Version 4.0F or higher

Software Version: Compaq COBOL Version 2.7




Compaq Computer Corporation Houston, Texas


© 2000 Compaq Computer Corporation

COMPAQ, VAX, VMS, the Compaq logo, and the DIGITAL logo Registered in U.S. Patent and Trademark Office.

OpenVMS and Tru64 are trademarks of Compaq Information Technologies Group, L.P.

Microsoft, MS-DOS, Win32, Windows, and Windows NT are trademarks of Microsoft Corporation.

Motif, OSF/1, UNIX, and X/Open are trademarks of The Open Group.

All other product names mentioned herein may be trademarks of their respective companies.

Confidential computer software. Valid license from Compaq required for possession, use, or copying. Consistent with FAR 12.211 and 12.212, Commercial Computer Software, Computer Software Documentation, and Technical Data for Commercial Items are licensed to the U.S. Government under vendor's standard commercial license.

Compaq shall not be liable for technical or editorial errors or omissions contained herein. The information in this document is subject to change without notice.

THE INFORMATION IN THIS PUBLICATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK ARISING OUT OF THE USE OF THIS INFORMATION REMAINS WITH RECIPIENT. IN NO EVENT SHALL COMPAQ BE LIABLE FOR ANY DIRECT, CONSEQUENTIAL, INCIDENTAL, SPECIAL, PUNITIVE, OR OTHER DAMAGES WHATSOEVER (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION OR LOSS OF BUSINESS INFORMATION), EVEN IF COMPAQ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES AND WHETHER IN AN ACTION OF CONTRACT OR TORT, INCLUDING NEGLIGENCE.

The limited warranties for Compaq products are exclusively set forth in the documentation accompanying such products. Nothing herein should be construed as constituting a further or additional warranty.

ZK6297

Contents Index


Preface

This manual provides information to help you develop Compaq COBOL programs for the OpenVMS Alpha and Compaq Tru64 UNIX platforms.

Compaq COBOL is the new name for DEC COBOL and for DIGITAL COBOL. Compaq COBOL, unmodified, refers to the COBOL language on three platforms:

OpenVMS Alpha
Tru64 UNIX
Windows NT Alpha (described in separate documentation)

Compaq COBOL for OpenVMS VAX is the new name for VAX COBOL and DIGITAL VAX COBOL. It is the COBOL implementation for the OpenVMS VAX platform. (It is described in a separate documentation set.)

Any references to the former names in product documentation or other components should be construed as references to the Compaq COBOL names.

All references in this manual to Windows NT mean Microsoft Windows NT Alpha.

Intended Audience

This manual is intended for experienced applications programmers who have a thorough understanding of the COBOL language. Some familiarity with your operating system is also recommended. This is not a tutorial manual.

If you are a new COBOL user, you may need to read introductory COBOL textbooks or take COBOL courses. Additional prerequisites are described at the beginning of each chapter or appendix, if appropriate.

Document Structure

This manual is organized as follows:

Associated Documents

The following documents contain additional information directly related to various topics in this manual:

Compaq COBOL Reference Manual

This manual describes the concepts and rules of the Compaq COBOL programming language under the supported operating systems.

Release Notes

Consult the Compaq COBOL release notes for your installed version for late corrections and new features.

On the OpenVMS Alpha operating system, the release notes are in:

SYS$HELP:COBOLnnn.RELEASE_NOTES (ASCII text)
SYS$HELP:COBOLnnn_RELEASE_NOTES.PS
where nnn is the version and release number, for example, 027 for Version 2.7.

On the Tru64 UNIX operating system, the release notes are in:

/usr/lib/cmplrs/cobol/relnotes

Compaq COBOL for OpenVMS Alpha Systems Installation Guide

This manual provides information on how to install Compaq COBOL on the OpenVMS Alpha operating system.

Compaq COBOL for Tru64 UNIX Systems Installation Guide

This manual provides information on how to install Compaq COBOL on the Tru64 UNIX operating system.

DIGITAL COBOL DBMS Database Programming

This manual provides information on using Compaq COBOL for database programming with Oracle DBMS on the OpenVMS Alpha operating system.

The OpenVMS Documentation Set

This set contains information about using the features of the OpenVMS Alpha and OpenVMS VAX operating systems and their tools, including the OpenVMS Debugger.

The Tru64 UNIX Documentation Set

This set contains information about using the features of the Tru64 UNIX operating system and its tools.

The Compaq FUSE Documentation

This documentation contains information about using the features of Compaq FUSE.

The Alpha Architecture Reference Manual

This manual is available from Digital Press.

Related Documents

For additional information about OpenVMS products and services, access the following World Wide Web address:


http://www.compaq.com/ 

Conventions


References

The following table shows certain references and their respective meanings in this manual:
Reference Meaning
OpenVMS OpenVMS Alpha operating system
Tru64 UNIX Compaq Tru64 UNIX operating system
Windows NT Microsoft Windows NT Version 4.0, SP4, SP5 for Alpha systems

Compaq Tru64 UNIX was formerly known as DEC OSF/1 or as DIGITAL UNIX. Compaq COBOL was formerly known as DIGITAL COBOL or DEC COBOL. Compaq COBOL for OpenVMS VAX was formerly known as VAX COBOL or as DIGITAL VAX COBOL.

Acknowledgment

COBOL is an industry language and is not the property of any company or group of companies, or of any organization or group of organizations.

No warranty, expressed or implied, is made by any contributor or by the CODASYL COBOL Committee as to the accuracy and functioning of the programming system and language. Moreover, no responsibility is assumed by any contributor, or by the committee, in connection therewith.

The authors and copyright holders of the copyrighted material used herein are as follows: FLOW-MATIC (trademark of Unisys Corporation), Programming for the UNIVAC (R) I and II, Data Automation Systems, copyrighted 1958, 1959, by Unisys Corporation; IBM Commercial Translator Form No. F28-8013, copyrighted 1959 by IBM; FACT, DSI 27A5260-2760, copyrighted 1960 by Minneapolis-Honeywell.

They have specifically authorized the use of this material, in whole or in part, in the COBOL specifications. Such authorization extends to the reproduction and use of COBOL specifications in programming manuals or similar publications.

How to Order Additional Documentation

For information on pricing and where to buy documentation and other Compaq products in the United States and Canada, please call toll-free 1-800-282-6672.

Reader's Comments

Compaq appreciates your comments. If you find errors or want to comment about this manual, please send the manual title, order number, and your comments by one of the following methods:

User Programs and the Year 2000

Even subsequent to the turn of the century, there still exist potential disruptions in previously problem-free software where there are instances of a two-digit year field that should be a four-digit field. Programmers need to correct all such fields, as Compaq cannot prevent problems that originate in application code.

For more information, see Section 1.6.

New Features

Consult the Index for entries under Version 2.7 -- what's new since V2.5. They will point you to information added since Version 2.5 of Compaq COBOL.


Chapter 1
Developing Compaq COBOL Programs

Compaq COBOL is a powerful optimizing compiler produced by Compaq Computer Corporation. It operates comfortably in the Compaq common language environment; it is based on GEM, which is the highly advanced code generator and optimizer that Compaq uses in its family of languages, which includes COBOL, C, C++, FORTRAN 77, FORTRAN 90, BASIC, Ada, and PASCAL. In addition to standard COBOL features, Compaq COBOL includes extensions that make new application development efficient and effective, with features helpful in porting legacy COBOL programs to OpenVMS Alpha and Tru64 UNIX systems.

Developing software applications with Compaq COBOL will be a familiar process. You set up your development environment, create your source, compile, link, and run. A few of the specific tasks are:

1.0.1 Files Installed on Your System

You will have the following directories and files added to your system after a typical installation:

where nn shows the version and release numbers. For example, for Version 2.7 nn is 27.

1.1 Compaq COBOL and Alpha Architecture System Resources

For many user applications, the Compaq COBOL compiler requires significantly more system resources than Compaq COBOL for OpenVMS VAX. In fact, unless you have adjusted your system resource parameters accordingly, the attempt to compile may fail because of insufficient virtual memory. Also, for very large programs (greater than 10,000 lines), you might experience extremely long compile times. Knowing why Compaq COBOL requires more memory can help you take actions to avoid resource problems.

1.1.1 Compilation Performance

The Alpha architecture is a RISC (reduced instruction set computer) architecture. Many other processor architectures, including the VAX, are CISC (complex instruction set computer) architectures. The main distinguishing characteristic of a RISC machine is that it has few instructions and each instruction does a small amount of work. A CISC machine generally has many instructions, most of which perform many complicated operations in one step.

By reducing the amount of work that is done in each instruction (and by reducing the number of instructions), the complexity of the hardware is reduced. These hardware changes, plus others, result in an increase in the number of instructions per second that can be completed. The result is much faster overall system performance.

A tradeoff of RISC systems is that compilers for these architectures generally must do a great deal more work than a corresponding compiler for a CISC architecture. For example, the compiler must compute the best way to use all of the functional units of the processor, and it must determine how to make the best use of registers and on-chip data cache because reads and writes to main memory are generally slow compared to the speed of the processor.

The code generation portion of the Compaq COBOL for OpenVMS VAX compiler examines one COBOL statement at a time, determines the VAX instructions to be constructed to execute that statement, and then moves on to the next one. This tactic works well for a CISC architecture like the VAX. Compaq COBOL for OpenVMS VAX does "peephole" optimization.

The Compaq COBOL compiler, in contrast, is a globally optimizing compiler based on the Alpha RISC architecture as well as mathematical concepts. The compiler constructs an internal representation of the entire COBOL program, and repeatedly traverses this structure at compile time, so that it can produce the most efficient machine code for the program. This results in very high performance code, to the benefit of your users at run time. Although the Compaq COBOL compiler requires more resources than some other compilers to do this additional work at compile time, this cost is offset by better performance during the many run times that follow.

To reduce this impact on system resources, do the following:

Note

Large arrays (tables) can have a significant impact on compile time and resource requirements. In addition to the size of the program source, you should also examine the amount of space allocated in your Data Division, particularly for arrays. The number of array elements as well as the size of the array elements is significant. This impact can be minimized in two ways: by system tuning (as suggested in this section), which will optimize system resources for the compile, and by using INITIALIZE instead of VALUE in your data definitions, which will improve compilation performance.

1.1.2 Tuning OpenVMS Alpha for Large Compaq COBOL Compiles

The recommendations that follow were determined by compiling one set of very large Compaq COBOL modules on OpenVMS Alpha. While your results may vary, the principles are generally applicable. For more detailed information on OpenVMS Alpha tuning, see the OpenVMS System Manager's Manual, particularly the sections on Managing System Parameters and Managing System Page, Swap, and Dump Files.

Note that many tuning exercises are more beneficial if you work with a relatively quiet system, submit batch jobs, and retain the log files for later analysis.

1.1.2.1 Optimizing Virtual Memory Usage

If your system does not have enough virtual memory allocated, the compile may fail, with the "%LIB-E-INSVIRMEM, insufficient virtual memory" error reported.

OpenVMS has two parameters that control the amount of virtual memory available to a process. One is the system generation parameter VIRTUALPAGECNT, which sets an upper bound on the number of pagelets of virtual memory for any process in the system. The other control is the AUTHORIZE parameter PGFLQUOTA, which determines the number of pagelets a process can reserve in the system's page file(s).

After an "insufficient virtual memory" error, you can issue the DCL command $SHOW PROCESS/ACCOUNTING to see the "Peak virtual size" used by the process (or look at the "Peak page file size" at the end of a batch job log file). If the peak size is at the system generation parameter VIRTUALPAGECNT, you will need to raise this value. If the peak size is below VIRTUALPAGECNT, and at or above PGFLQUOTA, run AUTHORIZE to increase PGFLQUOTA for the COBOL users. (Peak size can exceed PGFLQUOTA because some virtual memory, such as read-only image code, is not allocated page file space.)

It is difficult to predict precisely how much virtual memory will be required for a compilation, but a starting point for system tuning may be computed by multiplying 250 times the size of the largest program in disk blocks (including all COPY files referenced). Alternatively, multiply 25 times the number of lines in the program (including all COPY files).

The resulting figure can then be used as a starting point for the system generation parameter VIRTUALPAGECNT. Put that figure in the parameter file SYS$SYSTEM:MODPARAMS.DAT. For example, if you estimate 370,000 pages, add the line following line in MODPARAMS, run AUTOGEN and reboot:


MIN_VIRTUALPAGECNT = 400000 

If the compilation now completes successfully, use the command $SHOW PROCESS/ACCOUNTING to determine the Peak Virtual Size; if the actual peak is significantly less than the value computed above, you can reduce VIRTUALPAGECNT.

When modifying VIRTUALPAGECNT and PGFLQUOTA, you may also need to increase the size of the page file.

1.1.2.2 Optimizing Physical Memory Usage

In any evaluation of your system's physical memory, two of the questions to consider are:

Is there enough memory on the system?
Is enough available to the process running the compilation?

More specifically:

The amount of physical memory required will vary, but it should be a large percentage of the process peak virtual size---as close to 100% as practical. The reason is that the compiler makes multiple passes over the internal representation of the program. A page that falls out of the working set in one pass is probably going to be needed again on the very next pass.

The physical memory present on the system can be determined by the DCL command $SHOW MEMORY/PHYSICAL. The physical memory used by the compilation is reported as "Peak working set size" by the command SHOW PROCESS/ACCOUNTING or at the end of a batch log file.

More physical memory can be made available to a process by minimizing the number of competing processes on the system (for example, by compiling one module at a time or by scheduling large compiles for off-peak time periods; late at night is a good time in some situations).

More physical memory can also be made available to a process (if it is present on the machine) by adjusting the system generation parameter WSMAX and the corresponding WSEXTENT (in AUTHORIZE). Approach such adjustments with great caution, as the system may hang if memory is oversubscribed and you create a situation where OpenVMS Alpha effectively has no options to reclaim memory. The following guidelines can help:

The effects of physical memory on compilation time were studied for a set of seven large modules. These modules ranged in size from approximately 1600 to 3300 disk blocks. Your results may differ, but to give a rough appreciation for the effect of physical memory on compilation time, note that:

Your results may differ from those shown in this section and will be strongly affected by the speed of the devices that are used for paging.

Note that the requirements for virtual memory and physical memory can also be reduced by breaking large modules into smaller modules.

Note

1 MB= megabytes


Next Contents Index