 |
» |
|
|
 |
Some
extensions to FORTRAN 77 are included in Fortran 90
and other completely new features have been added. The following
list summarizes features of Fortran 90 that are not in
standard FORTRAN 77 and indicates where they are described
in the manual. Source format The fixed source form of FORTRAN 77 is extended by
the addition of the ";" statement separator, and
the "!"
trailing comment, and also a free source form is provided. The
format used in a source program file is normally indicated by the
file suffix, but the default format can be overridden by the use
of the +source compile-line option, as described in Chapter 13. Data types Intrinsic data types
are now parameterized: each can have one or more kinds, identified
by a kind type parameter. This is an integer value that determines
the range and/or precision of values that entities of that type
may hold. Several kind types for each intrinsic data type may be implemented,
and intrinsic inquiry functions are provided to establish what is
available making "precision portability" possible. In HP Fortran 90, the kind type parameter
value is the number of bytes used to represent an entity of that
type, except for COMPLEX
entities, where the number of bytes required is double the kind
type value. In principle, multibyte character data for languages with
large character sets could be implemented in Fortran 90 by means
of a kind type parameter for the CHARACTER
data type. In HP Fortran 90, however, such facilities
are instead provided through a language extension, using the Extended
UNIX Code (EUC) characters in file names, comments, and string literals. Derived data types are available: they are defined
by the user and can be composed of components that are of the intrinsic
types (INTEGER,
REAL, COMPLEX,
LOGICAL, and
CHARACTER) or
of previously defined derived data types. Scalar and array entities
of derived data types may be declared.
Data types are discussed further in Chapter 3. Operators Intrinsic operators can be extended and new operations defined,
for use with operands of intrinsic or derived data types. The intrinsic
assignment operator can be extended similarly. Defined — that is, "user-defined"—
operations and defined assignment are implemented by means of user-written
procedures; see Chapter 7 for details. Control
constructs The CASE
construct enables one of a set of statement blocks to be executed
on the basis of a case selector value (that can be INTEGER, CHARACTER
or LOGICAL). Additional forms of the DO
statement are provided, as well as the CYCLE
and EXIT statements,
to branch to the end of a DO
loop and out of a DO
loop respectively.
These facilities are described in Chapter 6. Arrays Array facilities are greatly extended in Fortran 90
and now include the following: Array sections that permit
selection of a subset of array elements have been introduced. Operations
for processing whole arrays and array sections are included, and
expressions, functions, and assignments can be array-valued. The
WHERE construct
and statement provide for masked-array assignment. Array constructors are provided. An array constructor
is an unnamed, rank-one array value, the elements of which may be
constant or variable in value. The RESHAPE
intrinsic function can be used to produce an array value of higher
rank from an array constructor. Several new sorts of array (extensions in HP FORTRAN
77) are provided in Fortran 90: Assumed-shape ("assumed"
meaning "taking on the characteristics of") Deferred-shape (an allocatable array or array pointer) Automatic, which is a new sort of explicit-shape
array
Many intrinsic array functions are provided in Fortran 90,
classed as elemental, transformational, or inquiry.
Arrays are discussed in Chapter 4. Intrinsic functions
are discussed in Chapter 11. Procedures A large number of new
intrinsic procedures are provided in the language. Many of them
are "elemental", taking either scalar or array
arguments. In the latter case, the result is as if the procedure
were applied separately to each element of the array. Other additions are transformational functions that
operate on their arguments in a nonelemental fashion and inquiry
functions that return properties of the arguments rather than values
computed from them. Fortran 90 includes a feature called the procedure
interface block, that is the basis of a number of new
facilities. For example, it enables procedure interfaces to be specified
explicitly, so that the names and properties of the dummy arguments
of such a procedure are known in the scoping unit invoking the procedure.
This makes it possible for the compiler to ensure that the dummy
and actual arguments match. Optional
arguments and keyword-identified arguments are also available when
the procedure interface is explicit. In addition, the procedure interface block enables user-defined
generic procedures to be written, and is the mechanism used to specify
defined operators and defined assignment. Dummy arguments to procedures can now be given an
INTENT attribute
(IN, OUT
or INOUT). Internal subprograms can be
defined within a module subprogram, an external subprogram, or a
main program unit. They are local to the scoping unit in which they
are declared. Recursive procedures that can invoke themselves,
directly or indirectly (an extension in HP FORTRAN 77),
are available as a standard feature in Fortran 90.
These facilities are discussed in Chapter 7. Pointers Arrays
and scalar variables can be given the POINTER
attribute in Fortran 90. A pointer is an alias,
and the variable (or allocated space) for which it is an alias is
its target. Pointer facilities enable data
to be accessed and handled dynamically. Allocatable arrays (noted
in the array discussion earlier) are similar to array pointers,
but are slightly simpler, more limited, and more efficient. Pointers are discussed in Chapter 3. Modules A module is a new type of program unit that allows the specification
of data objects, PARAMETERs, derived types, procedures, operators,
and NAMELIST groups. Partial or complete access to these module
entities is provided by the USE statement. An entity may be declared
PRIVATE to limit visibility to the module itself. Typical applications of modules are the specification of global
data (in preference to the less safe common block mechanism) or
the specification of a derived type and its associated operations. Modules are discussed in Chapter 7. Nonadvancing
I/O In FORTRAN 77, after a record-based I/O operation,
the file pointer is moved to the start of the next record. In Fortran 90, use of the I/O specifier ADVANCE=NO,
causes the file pointer to be positioned after the characters just
read or written, but not automatically at the start of the next
record. This makes character I/O operations much easier to handle.
It is also possible to read a variable length record and determine
its length. I/O facilities are discussed in Chapters 8 and 9. Namelist-directed
I/O Namelist-directed I/O, similar to that provided in HP FORTRAN 77,
is available in Fortran 90. The READ/WRITE
specifier NML=namelist-group-name
has been added together with the NAMELIST
statement that allows specification of the variables belonging to
a NAMELIST group.
|