HP Fortran for OpenVMS
HP Fortran for OpenVMS
Language Reference Manual
Order Number:
BA368-90004
January 2005
This manual contains the complete description of the HP Fortran
programming language, which includes Fortran 95 and Fortran 90 features.
Note
HP Fortran provides a number of extensions to the Fortran 95 Standard.
In this online HTML version of the manual, these extensions are colored
in
teal.
|
Revision/Update Information:
This is a new manual.
Software Version:
HP Fortran for OpenVMS Systems Version 8.0
Operating System:
OpenVMS Industry Standard 64 Systems Version 8.2
OpenVMS Alpha Systems Version 8.2
Hewlett-Packard Company Palo Alto, California
© Copyright 2005 Hewlett-Packard Development Company, L.P.
Confidential computer software. Valid license from HP 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.
The information contained herein is subject to change without notice.
The only warranties for HP products and services are set forth in the
express warranty statements accompanying such products and services.
Nothing herein should be construed as constituting an additional
warranty. HP shall not be liable for technical or editorial errors or
omissions contained herein.
Intel and Itanium are trademarks or registered trademarks of Intel
Corporation or its subsidiaries in the United States and other
countries.
Printed in the US
ZK6324
This manual is available on CD-ROM.
Preface
This manual contains the complete description of the HP Fortran
programming language, which includes Fortran 95 and Fortran 90
features. It contains information about language syntax and semantics,
adherence to various Fortran standards, and extensions to those
standards.
Note
In this manual, the term OpenVMS refers to both OpenVMS I64 and OpenVMS
Alpha systems. If there are differences in the behavior of the
HP Fortran compiler on the two operating systems, those differences
are noted in the text.
|
Intended Audience
This manual is intended for experienced applications programmers who
have a basic understanding of Fortran concepts and the Fortran 95/90
language, and are using HP Fortran in either a single-platform or
multiplatform environment.
Some familiarity with parallel programming concepts and OpenVMS is
helpful. This manual is not a Fortran or programming tutorial.
Document Structure
This manual consists of the following chapters and appendixes:
- Chapter 1 describes language standards, language compatibility,
and some features of Fortran 95 and Fortran 90.
- Chapter 2 describes program structure, the Fortran 95/90
character set, and source forms.
- Chapter 3 describes intrinsic and derived data types,
constants, variables (scalars and arrays), and substrings.
- Chapter 4 describes expressions and assignment.
- Chapter 5 describes specification statements, which declare the
attributes of data objects.
- Chapter 6 describes dynamic allocation.
- Chapter 7 describes constructs and statements that can transfer
control within a program.
- Chapter 8 describes program units (including modules),
subroutines and functions, and procedure interfaces.
- Chapter 9 summarizes all intrinsic procedures.
- Chapter 10 describes data transfer input/output (I/O) statements.
- Chapter 11 describes the rules for I/O formatting.
- Chapter 12 describes auxiliary I/O statements you can use to
perform file operations.
- Chapter 13 describes compilation control statements.
- Chapter 14 describes compiler directives.
- Chapter 15 describes scope and association.
- Appendix A describes obsolescent language features in Fortran 95
and Fortran 90.
- Appendix B describes some statements and language features
supported for programs written in older versions of Fortran.
- Appendix C describes the HP Fortran character sets.
- Appendix D describes data representation models for numeric
intrinsic functions.
- Appendix E summarizes HP Fortran extensions to the Fortran 95
Standard.
- The Glossary contains abbreviated definitions of some commonly
used terms in this manual.
Note
If you are reading the printed version of this manual, be aware that
the version at the HP Fortran Web site and the version on the
Documentation CD-ROM from HP may contain updated and/or corrected
information.
|
Related Documents
The following documents are also useful:
- HP Fortran for OpenVMS User Manual
This manual provides information about
HP Fortran program development and the run-time environment. It
describes compiling, linking, running, and debugging HP Fortran
programs, run-time error-handling and I/O, performance guidelines, data
types, numeric data conversion, calling other procedures and library
routines, and compatibility with Compaq Fortran 77.
- HP Fortran Installation Guide for OpenVMS I64 Systems or HP Fortran Installation Guide for OpenVMS Alpha Systems
These guides provide information
on how to install HP Fortran.
- OpenVMS documentation set
This set provides detailed
information about components and features of the OpenVMS operating
system, such as commands, tools, libraries, and other aspects of the
programming environment.
- Standards and Specifications
The following copyrighted standard
and specification documents contain precise descriptions of many of the
features found in HP Fortran:
- American National Standard Programming Language FORTRAN, ANSI
X3.9-1978
- American National Standard Programming Language Fortran 90, ANSI
X3.198-1992
This Standard is equivalent to: International Standards
Organization Programming Language Fortran, ISO/IEC 1539:1991 (E).
- American National Standard Programming Language Fortran 95, ANSI
X3J3/96-007
This Standard is equivalent to: International Standards
Organization Programming Language Fortran, ISO/IEC 1539-1:1997 (E).
Other Sources of Information
This section alphabetically lists some commercially published documents
that provide reference or tutorial information on Fortran 95 and
Fortran 90:
- Fortran 90/95 for Scientists and Engineers by S. Chapman;
published by McGraw-Hill, ISBN 0-07-011938-4.
- Fortran 90 Handbook by J. Adams, W. Brainerd, J. Martin,
B. Smith, and J. Wagener; published by Intertext Publications
(McGraw--Hill), ISBN 0-07-000406-4.
- Fortran 90 Programming by T. Ellis, I. Philips, and T.
Lahey; published by Addison--Wesley, ISBN 0201-54446-6.
- Introduction to Fortran 90/95 by S. Chapman; published by
WCB McGraw--Hill, ISBN 0-07-011969-4.
- Programmer's Guide to Fortran 90, Second Edition by W.
Brainerd, C. Goldberg, and J. Adams; published by Unicomp, ISBN
0-07-000248-7.
HP does not endorse these books or recommend them over other books on
the same subjects.
Reader's Comments
HP welcomes your comments on this or any other HP Fortran manual. You
can send comments by email to:
HP Fortran Web Page
The HP Fortran home page is at:
http://www.hp.com/go/fortran
|
This Web site contains information about software patch kits, example
programs, and additional product information.
Conventions
The following product names may appear in this manual:
- HP OpenVMS Industry Standard 64 for Integrity Servers
- OpenVMS I64
- I64
All three names---the longer form and the two abbreviated forms---refer
to the version of the OpenVMS operating system that runs on the
Intel® Itanium® architecture.
The following conventions might be used in this manual:
Ctrl/
x
|
A sequence such as Ctrl/
x indicates that you must hold down the key labeled Ctrl while
you press another key or a pointing device button.
|
PF1
x
|
A sequence such as PF1
x indicates that you must first press and release the key
labeled PF1 and then press and release another key or a pointing device
button.
|
[Return]
|
In examples, a key name enclosed in a box indicates that you press a
key on the keyboard. (In text, a key name is not enclosed in a box.)
In the HTML version of this document, this convention appears as
brackets, rather than a box.
|
...
|
A horizontal ellipsis in examples indicates one of the following
possibilities:
- Additional optional arguments in a statement have been omitted.
- The preceding item or items can be repeated one or more times.
- Additional parameters, values, or other information can be entered.
|
.
.
.
|
A vertical ellipsis indicates the omission of items from a code example
or command format; the items are omitted because they are not important
to the topic being discussed.
|
( )
|
In command format descriptions, parentheses indicate that you must
enclose choices in parentheses if you specify more than one.
|
[ ]
|
In command format descriptions, brackets indicate optional choices. You
can choose one or more items or no items. Do not type the brackets on
the command line. However, you must include the brackets in the syntax
for OpenVMS directory specifications and for a substring specification
in an assignment statement.
|
|
|
In command format descriptions, vertical bars separate choices within
brackets or braces. Within brackets, the choices are optional; within
braces, at least one choice is required. Do not type the vertical bars
on the command line.
|
{ }
|
In command format descriptions, braces indicate required choices; you
must choose at least one of the items listed. Do not type the braces on
the command line.
|
bold type
|
Bold type represents the introduction of a new term. It also represents
the name of an argument, an attribute, or a reason.
|
italic type
|
Italic type indicates important information, complete titles of
manuals, or variables. Variables include information that varies in
system output (Internal error
number), in command lines (/PRODUCER=
name), and in command parameters in text (where
dd represents the predefined code for the device type).
|
UPPERCASE TYPE
|
Uppercase type indicates a command, the name of a routine, the name of
a file, or the abbreviation for a system privilege.
|
-
|
A hyphen at the end of a command format description, command line, or
code line indicates that the command or statement continues on the
following line.
|
numbers
|
All numbers in text are assumed to be decimal unless otherwise noted.
Nondecimal radixes---binary, octal, or hexadecimal---are explicitly
indicated.
|
real
|
This term refers to all floating-point intrinsic data types as a group.
|
complex
|
This term refers to all complex floating-point intrinsic data types as
a group.
|
logical
|
This term refers to logical intrinsic data types as a group.
|
integer
|
This term refers to integer intrinsic data types as a group.
|
Fortran
|
This term refers to language information that is common to ANSI
FORTRAN-77, ANSI/ISO Fortran 90, ANSI/ISO Fortran 95, and HP Fortran
90.
|
Fortran 90
|
This term refers to language information that is common to ANSI/ISO
Fortran 90 and HP Fortran. For example, a new language feature
introduced in the Fortran 90 standard.
|
Fortran 95
|
This term refers to language information that is common to ISO Fortran
95 and HP Fortran. For example, a new language feature introduced in
the Fortran 95 standard.
|
HP Fortran
|
Unless otherwise specified, this term (formerly Compaq Fortran) refers
to language information that is common to the Fortran 90 and 95
standards, and any HP Fortran extensions, running on the OpenVMS
operating system. Since the Fortran 90 standard is a superset of the
FORTRAN-77 standard, HP Fortran also supports the FORTRAN-77
standard. HP Fortran supports all of the deleted features of the
Fortran 95 standard.
|
Chapter 1
Overview
This chapter describes:
1.1 Language Standards Conformance
Fortran 95 includes Fortran 90 and most features of FORTRAN 77. Fortran
90 is a superset that includes FORTRAN 77. HP Fortran fully supports
the Fortran 95, Fortran 90, and FORTRAN 77 Standards.
HP Fortran conforms to the American National Standard Fortran 95
(ANSI X3J3/96-007)1 and the American National Standard
Fortran 90 (ANSI X3.198-1992)2.
The ANSI committee X3J3 answers questions of interpretation of Fortran
95 and Fortran 90 language features. Any answers given by the ANSI
committee that are related to features implemented in HP Fortran may
result in changes in future releases of the HP Fortran compiler, even
if the changes produce incompatibilities with earlier releases of
HP Fortran.
HP Fortran provides a number of extensions to the Fortran 95
Standard. In the online HTML version of this manual, these extensions
are colored in teal.
HP 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.
For More Information:
On HP Fortran language extensions, see Appendix E.
Note
1 This is the same as International
Standards Organization standard ISO/IEC 1539-1:1997 (E).
2 This is the same as International
Standards Organization standard ISO/IEC 1539:1991 (E).
|
1.2 Language Compatibility
HP Fortran is highly compatible with Compaq Fortran 77 on supported
platforms, and it is substantially compatible with PDP-11 and VAX
FORTRAN 77.
For More Information:
On language compatibility, compiler options, and program conversion
considerations, see the HP Fortran for OpenVMS User Manual.
1.3 Fortran 95 Features
Following are some of the Fortran 95 features implemented in
HP Fortran:
- FORALL statement and construct
In Fortran 90, you could build
array values element-by-element by using array constructors and the
RESHAPE and SPREAD intrinsics. The Fortran 95 FORALL statement and
construct offer an alternative method.
FORALL allows array
elements, array sections, character substrings, or pointer targets to
be explicitly specified as a function of the element subscripts. A
FORALL construct allows several array assignments to share the same
element subscript control.
FORALL is a generalization of WHERE.
They both allow masked array assignment, but FORALL uses element
subscripts, while WHERE uses the whole array.
For more information,
see Section 4.2.5.
- PURE user-defined procedures
Pure user-defined procedures do
not have side effects, such as changing the value of a variable in a
common block. To specify a pure procedure, use the PURE prefix in the
function or subroutine statement. Pure functions are allowed in
specification statements.
For more information, see Section 8.5.1.2.
- ELEMENTAL user-defined procedures
An elemental user-defined
procedure is a restricted form of pure procedure. An elemental
procedure can be passed an array, which is acted upon one element at a
time. To specify an elemental procedure, use the ELEMENTAL prefix in
the function or subroutine statement.
For more information, see
Sections 8.5.2 and 8.5.3.
- CPU_TIME intrinsic subroutine
This intrinsic subroutine returns
a processor-dependent approximation of processor time.
For more
information, see Section 9.4.33.
- NULL intrinsic function
In Fortran 90, there was no way to
assign a null value to the pointer by using a pointer assignment
operation. A Fortran 90 pointer had to be explicitly allocated,
nullified, or associated with a target during execution before
association status could be determined.
Fortran 95 provides the
NULL intrinsic function that can be used to nullify a pointer.
For
more information, see Section 9.4.111.
- Obsolescent features
Fortran 95 deletes several language
features that were obsolescent in Fortran 90, and identifies new
obsolescent features.
HP Fortran fully supports features deleted
in Fortran 95.
For more information, see Appendix A.
- Derived-type structure default initialization
In derived-type
definitions, you can now specify default initial values for
derived-type components.
For more information, see Section 3.3.2.
- Pointer initialization
In Fortran 90, there was no way to
define the initial value of a pointer. You can now specify default
initialization for a pointer.
For more information, see Sections
3.3.1 and 3.3.2.
- Automatic deallocation of allocatable arrays
Allocatable arrays
whose status is allocated upon routine exit are now automatically
deallocated.
For more information, see Section 6.2.1.
- Enhanced CEILING and FLOOR intrinsic functions
KIND can now be
specified for these intrinsic functions.
For more information, see
Sections 9.4.23 and 9.4.52.
- Enhanced MAXLOC and MINLOC intrinsic functions
DIM can now be
specified for these intrinsic functions.
For more information, see
Sections 9.4.96 and 9.4.101.
- Enhanced SIGN intrinsic function
When a specific compiler
option is specified, the SIGN function can now distinguish between
positive and negative zero if the processor is capable of doing so.
For more information, see Section 9.4.142.
- Printing of --0.0
When a specific compiler option is specified,
a floating-point value of minus zero (--0.0) can now be printed if the
processor can represent it.
- Enhanced WHERE construct
The WHERE construct has been improved
to allow nested WHERE constructs and a masked ELSEWHERE statement.
WHERE constructs can now be named.
For more information, see
Section 4.2.4.
- Generic identifier allowed in END INTERFACE statement
The END
INTERFACE statement of an interface block defining a generic routine
can now specify a generic identifier.
For more information, see
Section 8.9.2.
- Zero-length formats
On output, when using I, B, O, Z, and F
edit descriptors, the specified value of the field width can be zero.
In such cases, the compiler selects the smallest possible positive
actual field width that does not result in the field being filled with
asterisks (*).
- Comments allowed in namelist input
Fortran 95 allows comments
(beginning with !) in namelist input data.
1.4 Fortran 90 Features
Following are some of the Fortran 90 features implemented in
HP Fortran:
- Free source form
Fortran 90 provides a free-source form where
line positions have no special meaning. There are no reserved columns,
trailing comments can appear, and blanks have significance under
certain circumstances (for example,
P R O G R A M
is not allowed as an alternative for
PROGRAM
).
For more information, see Section 2.3.1.
- Modules
Fortran 90 provides a form of program unit called a
module, which is more powerful than (and overcomes limitations of)
FORTRAN 77 block data program units.
A module is a set of
declarations that are grouped together under a single, global name.
Modules let you encapsulate a set of related items such as data,
procedures, and procedure interfaces, and make them available to
another program unit.
Module items can be made private to limit
accessibility, provide data abstraction, and to create more secure and
portable programs.
For more information, see Section 8.3.
- User-defined (derived) data types and operators
Fortran 90 lets
you define data types derived from any combination of the intrinsic
data types and derived types. The derived-type object can be accessed
as a whole, or its individual components can be accessed directly.
You can extend the intrinsic operators (such as + and *) to
user-defined data types, and also define new operators for operands of
any type.
For more information, see Sections 3.3 and
8.9.4.
- Array operations and features
In Fortran 90, intrinsic
operators and intrinsic functions can operate on array-valued operands
(whole arrays or array sections).
Features for arrays include
whole, partial, and masked array assignment (including the WHERE
statement for selective assignment), and array-valued constants and
expressions. You can create user-defined array-valued functions, use
array constructors to specify values of a one-dimensional array, and
allocate arrays dynamically (using ALLOCATABLE and POINTER attributes).
Intrinsic procedures create multidimensional arrays, manipulate
arrays, perform operations on arrays, and support computations
involving arrays (for example, SUM sums the elements of an array).
For more information, see Section 3.5.2 and Chapter
9.
- Generic user-defined procedures
In Fortran 90, user-defined
procedures can be placed in generic interface blocks. This allows the
procedures to be referenced using the generic name of the block.
Selection of a specific procedure within the block is based on the
properties of the argument, the same way as specific intrinsic
functions are selected based on the properties of the argument when
generic intrinsic function names are used.
For more information,
see Section 8.9.3.
- Pointers
Fortran 90 pointers are mechanisms that allow dynamic
access and processing of data. They allow arrays to be sized
dynamically and they allow structures to be linked together.
A
pointer can be of any intrinsic or derived type. When a pointer is
associated with a target, it can appear in most expressions and
assignments.
For more information, see Sections 5.15 and
4.2.3.
- Recursion
Fortran 90 procedures can be recursive if the keyword
RECURSIVE is specified on the FUNCTION or SUBROUTINE statement line.
For more information, see Chapter 8.
- Interface blocks
A Fortran 90 procedure can contain an
interface block. Interface blocks can be used to do the following:
- Describe the characteristics of an external or dummy procedure
- Define a generic name for a procedure
- Define a new operator (or extend an intrinsic operator)
- Define a new form of assignment
For more information, see Section 8.9.
- Extensibility and redundancy
By using user-defined data types,
operators, and meanings, you can extend Fortran to suit your needs.
These new data types and their operations can be packaged in modules,
which can be used by one or more program units to provide data
abstraction.
With the addition of new features and
capabilities, some old features become redundant and may eventually be
removed from the language. For example, the functionality of the ASSIGN
and assigned GO TO statements can be replaced more effectively by
internal procedures. The use of certain old features of Fortran can
result in less than optimal performance on newer hardware
architectures.
For more information, see the HP Fortran for OpenVMS User Manual. For a
list of obsolescent features, see Appendix A.
- Additional features for source text
Lowercase characters are
now allowed in source text. A semicolon can be used to separate
multiple statements on a single source line. Additional characters have
been added to the Fortran character set, and names can have up to 31
characters (including underscores).
For more information, see
Chapter 2.
- Improved facilities for numerical computation
Intrinsic data
types can be specified in a portable way by using a kind type parameter
indicating the precision or accuracy required. There are also intrinsic
functions that allow you to specify numeric precision and inquire about
precision characteristics available on a processor.
For more
information, see Chapters 3 and 9.
- Optional procedure arguments
Procedure arguments can be made
optional and keywords can be used when calling procedures, allowing
arguments to be listed in any order.
For more information, see
Chapter 8.
- Additional input/output features
Fortran 90 provides additional
keywords for the OPEN and INQUIRE statements. It also permits namelist
formatting, and nonadvancing (stream) character-oriented input and
output.
For more information on formatting, see Chapter 10; on
OPEN and INQUIRE, see Chapter 12.
- Additional control constructs
Fortran 90 provides a control
construct (CASE) and improves the DO construct. The DO construct can
now use CYCLE and EXIT statements, and can have additional (or no)
control clauses (for example, WHILE). All control constructs (CASE, DO,
and IF) can now be named.
For more information, see Chapter 7.
- Additional intrinsic procedures
Fortran 90 provides many more
intrinsic procedures than existed in FORTRAN 77. Many of these
intrinsics support mathematical operations on arrays, including the
construction and transformation of arrays. Bit manipulation and
numerical accuracy intrinsics have been added.
For more
information, see Chapter 9.
- Additional specification statements
The following specification
statements are in Fortran 90:
- Additional way to specify attributes
Fortran 90 lets you
specify attributes (such as PARAMETER, SAVE, and INTRINSIC) in type
declaration statements, as well as in specification statements.
For
more information, see Section 5.1.
- Scope and association
These concepts were implicit in FORTRAN
77, but they are explicitly defined in Fortran 90. In FORTRAN 77, the
term scoping unit applies to a program unit, but Fortran 90 expands the
term to include internal procedures, interface blocks, and derived-type
definitions.
For more information, see Chapter 15.