Compaq Fortran
User Manual for
OpenVMS Alpha
Systems
Chapter 1
Getting Started
Compaq Fortran (formerly DEC Fortran 90 and DIGITAL Fortran 90)
conforms to:
- The American National Standard Fortran 90 (ANSI X3.198-1992), which
is the same as the International Standards Organization standard
(ISO/IEC 1539:1991 (E)).
- The Fortran 95 standard (ISO/IEC 1539:1998 (E)).
Compaq Fortran supports all of the deleted features of the Fortran 95
standard.
Compaq Fortran also includes partial support for the High Performance
Fortran Language Specification.
Compaq Fortran also includes support for programs that conform to the
previous Fortran standards (ANSI X3.9-1978 and ANSI X3.0-1966), the
International Standards Organization standard ISO 1539-1980 (E), the
Federal Information Processing Institute standard FIPS 69-1, and the
Military Standard 1753 Language Specification.
The ANSI committee X3J3 is currently answering questions of
interpretation of Fortran 90 ands 95 language features. Any answers
given by the ANSI committee that are related to features implemented in
Compaq Fortran may result in changes in future releases of the Compaq
Fortran compiler, even if the changes produce incompatibilities with
earlier releases of Compaq Fortran.
Compaq Fortran provides a number of extensions to the Fortran 90 and 95
standards. Compaq Fortran extensions to the latest Fortran standard are
generally provided for compatibility with Compaq Fortran 77 extensions
to the ANSI FORTRAN-77 standard.
When creating new programs that need to be standard-conforming for
portability reasons, you should avoid or minimize the use of extensions
to the latest Fortran standard. Extensions to the appropriate Fortran
standard are identified visually in the Compaq Fortran Language Reference Manual, which defines the
Compaq Fortran language.
This chapter provides information on the following topics:
- A summary of aspects of the Fortran 90/95 language related to the
Compaq Fortran program development environment on OpenVMS Alpha systems
( Section 1.1)
- The commands used to create, compile, link, and run a small program
( Section 1.2)
- The commands used to create, compile, link, and run a sample main
program that has separate files for a module and a function declaration
( Section 1.3)
- A summary of the important program development stages and tools
( Section 1.4)
1.1 The Compaq Fortran Programming Environment
The following aspects of Fortran 90/95 are relevant to the compilation
environment and should be considered before extensive coding begins:
- To install Compaq Fortran on your system, first obtain the
appropriate OpenVMS Alpha Software Product Library (media) CD-ROM. Then
perform the installation using the POLYCENTER Software Installation
(PCSI) utility (PRODUCT INSTALL command), as described in Compaq Fortran Installation Guide for OpenVMS Alpha Systems.
- Once Compaq Fortran is installed, you can:
- Use the FORTRAN command to compile source files. Use the LINK
command to link object files into executable programs.
- Use the online HELP FORTRAN command and this manual to provide
information about the FORTRAN command.
- Make sure you have adequate process memory space, especially if
your programs use large arrays as data. Your system manager (or
designated privileged user) may be able to overcome this problem by
checking and possibly increasing the following:
- Your process memory (working set)
Your system manager can use
the Authorize Utility to adjust your process working set quotas, page
file quota, and limits.
- System-wide virtual memory limits
Your system manager can use
SYSGEN to change parameters (such as WSMAX and VIRTUALPAGECNT), which
take effect after the system is rebooted.
- Page file space on your system
Your system manager can use
SYSGEN or AUTOGEN to increase page file sizes or create new page files.
Your system manager needs to INSTALL any new page files available to
the system by modifying system startup command procedures and rebooting
the system.
- System hardware resources, such as physical memory and disk space
You can check the current memory limits using the SHOW WORKING_SET
command. To view peak memory use after compiling or running a program,
use the SHOW PROCESS/ACCOUNTING command. Your system manager can use
these commands (or SHOW PROCESS/CONTINUOUS) for a currently running
process and the system-side MONITOR command.
For example, the
following DCL (shell) commands check the current limits and show the
current use of some of these limits:
$ SHOW WORKING_SET
...
$ SHOW PROCESS/ACCOUNTING
...
|
- Make sure you have an adequate process open file limit,
especially if your programs use a large number of module files.
During compilation, your application may attempt to use more module
files than your open file limit allows. In this case, the Compaq Fortran
compiler will close a previously opened module file before it opens
another to stay within your open file limit. This results in slower
compilation time. Increasing the open file limit may improve
compilation time in such cases.
You can view the per-process limit
on the number of open files (Open file quota or FILLM) by using the
SHOW PROCESS/QUOTA command:
Your system manager needs to determine the maximum per-process
limit for your system by checking the value of the CHANNELCNT SYSGEN
parameter and (if necessary) increasing its value.
- You can define the
FORT$LIBRARY logical name to specify a user-defined text library that
contains source text library modules referenced by INCLUDE statements.
The compiler searches first for libraries specified on the command line
and also in the system-supplied default library (see Section 2.4).
If you need to set these logical names frequently, consider setting
them in your LOGIN.COM file, or ask your system manager to set them as
system-wide logical names in a system startup command procedure.
For more information on using FORT$LIBRARY, see Section 2.2.4.
- You can define the FORT$INCLUDE logical name to specify a directory
to be searched for the following files:
- Module files specified by a USE statement (module name is used as a
file name)
- Source files specified by an INCLUDE statement, where a file name
is specified without a directory name
- Text library files specified by an INCLUDE statement, where a file
name is specified without a library name
You can also use the FORTRAN command line to specify:
- Additional directories to be searched
- The name of a library to be searched
- Whether to search in the process default directory or the directory
where the source file resides that references the include source file
or text library
For more information on the FORT$INCLUDE logical name and related
FORTRAN command qualifiers, see Section 2.2.3 and Section 2.2.4.
If
you need to set logical names frequently, consider setting them in your
LOGIN.COM file, or ask your system manager to set them as system-wide
logical names in a system startup command procedure.
Several other
logical names can similarly be used during program execution (see
Appendix C).
- Your Compaq Fortran source files can be in free or fixed form. You
can indicate the source form used in your source files by using certain
file types or a command-line qualifier:
- For files using fixed form, specify a file type of FOR or F.
- For files using free form, specify a file type of F90.
- You can also specify the /SOURCE_FORM qualifier on the FORTRAN
command line to specify the source form for all files on that command
line.
For example, if you specify a file as PROJ_BL1.F90 on a FORTRAN
command line (and omit the /SOURCE_FORM=FIXED qualifier), the FORTRAN
command assumes the file PROJ_BL1.F90 contains free form source code.
A special type of fixed source form is tab form (a Compaq extension
described in the Compaq Fortran Language Reference Manual).
- Each source file to be compiled must contain at
least one program unit (main program, subroutine, function, module,
block data). Consider the following aspects of program development:
- Modularity and Efficiency
For a large application, using a set
of relatively small source files promotes incremental application
development.
When application run-time performance is important,
compile related source files together (or the entire application). When
compiling multiple source files, separate file names with plus signs
(+) to concatenate source files and create a single object file. This
allows certain interprocedure optimizations to minimize run-time
execution time (unless you specify certain qualifiers).
- Code reuse
Modules, external subprograms, and included files
allow reuse of common code.
Code used in multiple places in a program should be placed in a module,
external subprogram (function or subroutine), or included file.
When using modules and external subprograms, there is one copy of
the code for a program. When using INCLUDE statements, the code in the
specified source file is repeated once for each INCLUDE statement.
In most cases, using modules or external subprograms makes programs
easier to maintain and minimizes program size.
For More Information:
- On modules, see Section 2.2.3.
- On include files, see Section 2.2.4.
- On Compaq Fortran source forms, see the Compaq Fortran Language Reference Manual.
- On recognized file types, see Section 2.2.1.
- On the types of subprograms and using an explicit interface to a
subprogram, see Chapter 10.
- On performance considerations, including compiling source programs
for optimal run-time performance, see Chapter 5.
- On logical names, see the OpenVMS User's Manual.
1.2 Commands to Create and Run an Executable Program
Example 1-1 shows a short Fortran 90/95 main program using free form
source.
Example 1-1 Sample Main Program |
! File hello.f90
PROGRAM HELLO_TEST
PRINT *, 'hello world'
PRINT *, ' '
END PROGRAM HELLO_TEST
|
To create and revise your source files, use a text editor, such as the
Extensible Versatile Editor (EVE). For instance, to use EVE to edit the
file HELLO.F90, type:
The following FORTRAN command compiles the program named HELLO.F90. The
LINK command links the compiled object file into an executable program
file named HELLO.EXE:
$ FORTRAN HELLO.F90
$ LINK HELLO
|
In this example, because all external routines used by this program
reside in standard OpenVMS libraries searched by the LINK command,
additional libraries or object files are not specified on the LINK
command line.
To run the program, type the RUN command and the program name:
If the executable program is not in your current default directory,
specify the directory before the file name. Similarly, if the
executable program resides on a different device than your current
default device, specify the device name and directory name before the
file name.
For More Information:
- On the OpenVMS programming environment, see the operating system
documents listed in Preface of this manual.
- On specifying files on an OpenVMS system, see OpenVMS User's Manual.
1.3 Creating and Running a Program Using a Module and Separate Function
Example 1-2 shows a sample Compaq Fortran main program using free-form
source that uses a module and an external subprogram.
The function CALC_AVERAGE is contained in a separately created file and
depends on the module ARRAY_CALCULATOR for its interface block.
Example 1-2 Sample Main Program That Uses a
Module and Separate Function |
! File: main.f90
! This program calculates the average of five numbers
PROGRAM MAIN
USE ARRAY_CALCULATOR (1)
REAL, DIMENSION(5) :: A = 0
REAL :: AVERAGE
PRINT *, 'Type five numbers: '
READ (*,'(BN,F10.3)') A
AVERAGE = CALC_AVERAGE(A) (2)
PRINT *, 'Average of the five numbers is: ', AVERAGE
END PROGRAM MAIN
|
- The USE statement accesses the module
ARRAY_CALCULATOR. This module contains the function declaration for
CALC_AVERAGE (use association).
- The 5-element array is passed to the function
CALC_AVERAGE, which returns the value to the variable AVERAGE for
printing.
Example 1-3 shows the module referenced by the main program. This
example program shows more Fortran 90 features, including an interface
block and an assumed-shape array.
Example 1-3 Sample Module |
! File: array_calc.f90.
! Module containing various calculations on arrays.
MODULE ARRAY_CALCULATOR
INTERFACE
FUNCTION CALC_AVERAGE(D)
REAL :: CALC_AVERAGE
REAL, INTENT(IN) :: D(:)
END FUNCTION CALC_AVERAGE
END INTERFACE
! Other subprogram interfaces...
END MODULE ARRAY_CALCULATOR
|
Example 1-4 shows the function declaration CALC_AVERAGE referenced by
the main program.
Example 1-4 Sample Separate Function
Declaration |
! File: calc_aver.f90.
! External function returning average of array.
FUNCTION CALC_AVERAGE(D)
REAL :: CALC_AVERAGE
REAL, INTENT(IN) :: D(:)
CALC_AVERAGE = SUM(D) / UBOUND(D, DIM = 1)
END FUNCTION CALC_AVERAGE
|
1.3.1 Commands to Create the Executable Program
During the early stages of program development, the three files might
be compiled separately and then linked together, using the following
commands:
$ FORTRAN ARRAY_CALC.F90
$ FORTRAN CALC_AVER.F90
$ FORTRAN MAIN.F90
$ LINK/EXECUTABLE=CALC.EXE MAIN, ARRAY_CALC, CALC_AVER
|
In this sequence of FORTRAN commands:
- Each of the FORTRAN commands creates one object file (OBJ file
type).
- The first FORTRAN command creates the object file ARRAY_CALC.OBJ
and the module file ARRAY_CALCULATOR.F90$MOD. The name in the MODULE
statement (ARRAY_CALCULATOR) in Example 1-3 determines the file name
of the module file. The FORTRAN command creates module files in the
process default device and directory with a F90$MOD file type.
- The second FORTRAN command creates the file CALC_AVER.OBJ
(Example 1-4).
- The third FORTRAN command creates the file MAIN.OBJ (Example 1-2)
and uses the module file ARRAY_CALCULATOR.F90$MOD.
- The LINK command links all object files (OBJ file type) into the
executable program named CALC.EXE.
To allow more optimizations to occur (such as the inline expansion of
called subprograms), compile the entire set of three source files
together using a single FORTRAN command:
$ FORTRAN/OBJECT=CALC.OBJ ARRAY_CALC.F90 + CALC_AVER.F90 + MAIN.F90
|
The order in which the file names are specified is significant. This
FORTRAN command:
- Compiles the file ARRAY_CALC.F90, which contains the module
definition (shown in Example 1-3), and creates its object file and the
file ARRAY_CALCULATOR.F90$MOD in the process default device and
directory.
- Compiles the file CALC_AVER.F90, which contains the external
function CALC_AVERAGE (shown in Example 1-4).
- Compiles the file MAIN.F90 (shown in Example 1-2). The USE
statement references the module file ARRAY_CALCULATOR.F90$MOD.
- Creates a single object file named CALC.OBJ.
When you omit the file type on the FORTRAN command line, the FORTRAN
command searches for a file with the F90 file type before a file with
the FOR or F file type, so you can type the previous command (without
file types) as follows:
$ FORTRAN/OBJECT=CALC.OBJ ARRAY_CALC + CALC_AVER + MAIN
|
Use a LINK command to link the single object file into an executable
program:
When you omit the file type on the LINK command line, the Linker
searches for a file with a file type of OBJ. Unless you will specify a
library on the LINK command line, you can omit the OBJ file type.
1.3.2 Running the Sample Program
If the current default directory contains the file named CALC you can
run the program by typing the RUN command followed by its name:
When you omit the file type on the RUN command line, the image
activator searches for a file with a file type of EXE (you can omit the
EXE file type).
When running the sample program, the PRINT and READ statements in the
main program result in the following dialogue between user and program:
Type five numbers:
55.5
4.5
3.9
9.0
5.6
Average of the five numbers is: 15.70000
|
1.3.3 Debugging the Sample Program
To debug a program using the OpenVMS Debugger, compile and link with
the /DEBUG qualifier to request additional symbol table information for
source line debugging in the object and executable program files. The
following FORTRAN command names the object file CALC_DEBUG.OBJ. The
LINK command then creates the program file CALC_DEBUG.EXE with full
debugging information:
$ FORTRAN/DEBUG/OBJECT=CALC_DEBUG.OBJ/NOOPTIMIZE ARRAY_CALC + CALC_AVER + MAIN
$ LINK/DEBUG CALC_DEBUG
|
The OpenVMS debugger has a character-cell interface and a windowing
interface (available with the DECwindows Motif product). To debug an
executable program named CALC_DEBUG.EXE, type the following command:
For more information on running the program within the debugger and the
windowing interface, see Chapter 4.
1.4 Program Development Stages and Tools
This manual primarily addresses the program development activities
associated with implementation and testing phases. For information
about topics usually considered during application design,
specification, and maintenance, see your operating system documentation
or appropriate commercially published documentation.
Compaq Fortran provides the standard features of a compiler and the
OpenVMS operating system provides a linker.
Use a LINK command to link the object file into an executable program.
Table 1-1 lists and describes some of the software tools you can
use when developing (implementing) and testing a program:
Table 1-1 Main Tools for Program Development and Testing
Task or Activity |
Tool and Description |
Manage source files
|
Use the Compaq Code Management System (CMS).
|
Create and modify source files
|
Use a text editor, such as the EDIT command to use the EVE editor. You
can also use the optional Language-Sensitive Editor (LSE). For more
information using OpenVMS text editors, see the OpenVMS User's Manual.
|
Analyze source code
|
Use DCL commands such as SEARCH and DIFFERENCES.
|
Build program (compile and link)
|
You can use the
FORTRAN and LINK commands to create small programs, perhaps using
command procedures, or use the Compaq Module Management System (MMS) to
build your application in an automated fashion.
For more information on the FORTRAN and LINK commands, see
Chapter 2 and Chapter 3 respectively.
|
Debug and Test program
|
Use the OpenVMS Debugger to debug your program or run it for general
testing. For more information on the OpenVMS Debugger, see
Chapter 4 in this manual.
|
Analyze performance
|
To perform program timings and profiling of code, use the LIB$
xxxx_TIMER routines, a command procedure, or the Performance
Coverage Analyzer (PCA).
For more information on timing and profiling Compaq Fortran code,
see Chapter 5.
|
To perform other program development functions at various stages of
program development, use the following DCL commands:
- Use the LIBRARIAN command to create an
object or text library, add or delete library modules in a library,
list the library modules in a library, and perform other functions. For
more information, type HELP LIBRARIAN or see the OpenVMS Librarian
Utility Manual.
- Use the LINK/NODEBUG command to remove symbolic and other debugging
information to minimize image size. For more information, see
Chapter 3.
- The LINK/MAP command creates a link map, which shows information
about the program sections, symbols, image section, and other
information.
- The ANALYZE/OBJECT command shows whether the object file was
compiled by Compaq Fortran 77 or Compaq Fortran as well as the version
number used. It also shows other information and does a partial error
analysis.
- The ANALYZE/IMAGE command checks information about an executable
program file. It also shows the date it was linked and the version of
the operating system used to link it.
For More Information:
- On the OpenVMS programming environment, see the Preface of this
manual.
- On DCL commands, use DCL HELP or see the OpenVMS DCL Dictionary.