Syntax
INQUIRE (FILE=filename, list) INQUIRE ([UNIT=]unit,list)In addition list may contain one of each of the following specifiers in any order, following the unit number if the optional UNIT specifier keyword is not supplied.
Description
When an INQUIRE by file statement is executed the following specifiers will only be assigned values if the file name is acceptable: nmd, fn, seq, dir, fmt and unf. num is defined, and acc, fm, rcl, nr and blnk may become defined only if od is defined as .TRUE..
When an INQUIRE by unit statement is executed the specifiers num, nmd, fn, acc, seq, dir, fm, fmt, unf, rcl, nr and blnk are assigned values provided that the unit exists and a file is connected to that unit. Should an error condition occur during the execution of an INQUIRE statement all the specifiers except ios become undefined.
Syntax
The syntax for INTEGER has two forms, a standard Fortran 90 attributed form, and the PGI extended form. This section describes both syntax forms.
INTEGER [([ KIND = kind-value ) ][, attribute-list ::] entity-listINTEGER permits a KIND specification. Refer to the Fortran 90 handbook for more syntax details.
PGI Syntax Extension
INTEGER [*n] [,] name [*n] [dimensions] [/clist/]...
Description
Integer type declaration statements may be used to dimension arrays explicitly in the same way as the DIMENSION statement. INTEGER statements must not be labeled. Note: The data type of a symbol may be explicitly declared only once. It is established by type declaration statement, IMPLICIT statement or by predefined typing rules. Explicit declaration of a type overrides any implicit declaration. An IMPLICIT statement overrides predefined typing rules.
Example
INTEGER TIME, SECOND, STORE (5,5)
Syntax
INTENT (intent-spec) [ :: ] dummy-arg-list
IN OUT INOUT
Description
With intent specified as IN, the subprogram argument must not be redefined by the subprogram.
With intent specified as OUT, the subprogram should use the argument to pass information to the calling program.
With intent specified as INOUT, the subprogram may use the value passed through the argument, but should also redefine the argument to pass information to the calling program.
See Also
OPTIONAL
Example
SUBROUTINE IN_OUT(R1,I1)
REAL, INTENT (IN)::R1
INTEGER, INTENT(OUT)::I1
I1=R1
END SUBROUTINE IN_OUT
The INTERFACE statement block makes an implicit procedure an explicit procedure where the dummy parameters and procedure type are known to the calling module. This statement is also used to overload a procedure name.
Syntax
INTERFACE [generic-spec] [interface-body]... [MODULE PROCEDURE procedure-name-list]... END INTERFACEwhere a generic-spec is either:
generic-name OPERATOR (defined operator) ASSIGNMENT (=)and the interface body specified the interface for a function or a subroutine:
function-statement [specification-part] END FUNCTION [function name] subroutine-statement [specification-part] END FUNCTION [subroutine name]
See Also
END INTERFACE
Example
INTERFACE
SUBROUTINE IN_OUT(R1,I1)
REAL, INTENT (IN)::R1
INTEGER, INTENT(OUT)::I1
END SUBROUTINE IN_OUT
END INTEFACE
An INTRINSIC statement identifies a symbolic name as an intrinsic function and allows it to be used as an actual argument.
Syntax
INTRINSIC func [,func]
Description
Do not use any of the following functions in INTRINSIC statements:
INT, IFIX, IDINT, FLOAT, SNGL, REAL, DBLE, CMPLX, ICHAR, CHAR
LGE, LGT, LLE, LLT
MAX, MAX0, AMAX1, DMAX1, AMAX0, MAX1, MIN, MIN0, AMIN1, DMIN1, AMIN0, MIN1When a specific name of an intrinsic function is used as an actual argument in a program unit it must appear in an INTRINSIC statement in that program unit. If the name used in an INTRINSIC statement is also the name of a generic intrinsic function, it retains its generic properties. A symbolic name can appear only once in all the INTRINSIC statements of a program unit and cannot be used in both an EXTERNAL and INTRINSIC statement in a program unit.
The following example illustrates the use of INTRINSIC and EXTERNAL:
EXTERNAL MYOWN
INTRINSIC SIN, COS
.
.
CALL TRIG (ANGLE,SIN,SINE)
.
CALL TRIG (ANGLE,MYOWN,COTANGENT)
.
CALL TRIG (ANGLE,COS,SINE) SUBROUTINE TRIG (X,F,Y)
Y=F(X)
RETURN
END
FUNCTION MYOWNIn this example, when TRIG is called with a second argument of SIN or COS the function reference F(X) references the intrinsic functions SIN and COS; however when TRIG is called with MYOWN as the second argument F(X) references the user function MYOWN.
MYOWN=COS(X)/SIN(X)
RETURN
END
Syntax
The syntax for LOGICAL has two forms, a standard Fortran 90 attributed form, and the PGI extended form. This section describes both syntax forms.
LOGICAL [ ( [ KIND = kind-value ) ] [, attribute-list ::] entity-listLOGICAL permits a KIND specification. Refer to the Fortran 90 handbook for more syntax details.
PGI Syntax Extension
LOGICAL [*n] [,] name [*n] [dimensions] [/clist/]
[, name] [*n][dimensions] [/clist/]...
Description
Logical type declaration statements may be used to dimension arrays explicitly in the same way as the DIMENSION statement. Type declaration statements must not be labeled. Note: The data type of a symbol may be explicitly declared only once. It is established by type declaration statement, IMPLICIT statement or by predefined typing rules. Explicit declaration of a type overrides any implicit declaration. An IMPLICIT statement overrides predefined typing rules.
Example
LOGICAL TIME, SECOND, STORE (5,5)
The MODULE statement specifies the entry point for a module program unit. A module defines a host environment of scope of the module, and may contain subprograms that are in the same scoping unit.
Syntax
MODULE [name] [specification-part] [ CONTAINS [module-subprogram-part]] END [MODULE [ module-name ]]
Example
MODULE MYOWN
REAL MEAN, TOTAL
INTEGER, ALLOCATABLE, DIMENSION(:):: A
CONTAINS
RECURSIVE INTEGER FUNCTION X(Y)
.
.
.
END FUNCTION X
END MODULE MYOWN
The NAMELIST statement allows for the definition of namelist groups for namelist-directed I/O.
Syntax
NAMELIST /group-name/ namelist [[,] /group-name/ namelist ]...
Example
In the following example a named group PERS consists of a name, an account, and a value.
CHARACTER*12 NAME
INTEGER*$ ACCOUNT
REAL*4 VALUE
NAMELIST /PERS/ NAME, ACCOUNT, VALUE
The NULLIFY statement disassociates a pointer from its target.
Syntax
NULLIFY (pointer-object-list)
Example
NULLIFY PTR1
See Also
ALLOCATE, DEALLOCATE
The OPEN statement connects an existing file to a unit; creates and connects a file to a unit; creates a file that is preconnected or changes certain specifiers of a connection between a file and a unit.
Syntax
OPEN ( list )
[UNIT=] uwhere the UNIT= is optional and the external unit specifier u is an integer.
In addition list may contain one of each of the following specifiers in any order, following the unit number if the optional UNIT specifier keyword is not supplied.
Description
The record length, RECL=, must be specified if a file is connected for direct access and optionally one of each of the other specifiers may be used.
The unit specified must exist and once connected by an OPEN statement can be referenced in any program unit of the executable program. If a file is connected to a unit it cannot be connected to a different unit by the OPEN statement.
If a unit is connected to an existing file, execution of an OPEN statement for that file is allowed. Where FILE= is not specified the file to be connected is the same as the file currently connected. If the file specified for connection to the unit does not exist but is the same as a preconnected file, the properties specified by the OPEN statement become part of the connection. However, if the file specified is not the same as the preconnected file this has the same effect as the execution of a CLOSE statement without a STATUS= specifier immediately before the execution of the OPEN statement. When the file to be connected is the same as the file already connected only the BLANK= specifier may be different from the one currently defined.
Example
In the following example a new file, BOOK, is created and connected to unit 12 for direct formatted input/output with a record length of 98 characters. Numeric values will have blanks ignored and E1 will be assigned some positive value if an error condition exists when the OPEN statement is executed; execution will then continue with the statement labeled 20. If no error condition pertains, E1 is assigned the value zero (0) and execution continues with the next statement.
OPEN( 12, IOSTAT=E1, ERR=20, FILE='BOOK',
+ BLANK='NULL', ACCESS='DIRECT', RECL=98,
+ FORM='FORMATTED',STATUS='NEW')
Environment Variables
For an OPEN statement which does not contain the FILE= specifier, an environment variable may be used to specify the file to be connected to the unit. If the environment variable FORddd exists, where ddd is a 3 digit string whose value is the unit, the environment variable's value is the name of the file to be opened.
VAX/VMS Fortran @
VAX/VMS introduces a number of extensions to the OPEN statement. Many of these relate only to the VMS file system and are not supported (e.g., KEYED access for indexed files). The following keywords for the OPEN statement have been added or augmented as shown below. Refer to Programming in VAX FORTRAN for additional details on these keywords.
The OPTIONAL specification statement (attribute) specifies dummy arguments that may be omitted or that are optional.
Syntax
OPTIONAL [::] dummy-arg-list
Examples
OPTIONAL :: VAR4, VAR5 OPTIONAL VAR6, VAR7 INTEGER, OPTIONAL:: VAR8, VAR9
See Also
INTENT
The OPTIONS statement confirms or overrides certain compiler command-line options.
Syntax
OPTIONS /option [/option ...]Table 3.1 shows what options are available for the OPTIONS statement.
Table 3.1 OPTIONS Statement
Option Action Taken CHECK=ALL Enable array bounds checking CHECK=[NO]OVERFLOW None (recognized but ignored) CHECK=[NO]BOUNDS (Disable) Enable array bounds checking CHECK=[NO]UNDERFLOW None CHECK=NONE Disable array bounds checking NOCHECK Disable array bounds checking [NO]EXTEND_SOURCE (Disable) Enable the -Mextend option [NO]G_FLOATING None [NO]REENTRANT (Enable) Disable optimizations that may result in code that is not reentrant.The following restrictions apply to the OPTIONS statement:
The PARAMETER statement gives a symbolic name to a constant.
Syntax
PARAMETER (name = expression[,name = expression...] )
Examples
PARAMETER ( PI = 3.142 ) PARAMETER ( INDEX = 1024 ) PARAMETER ( INDEX3 = INDEX * 3 )
The PAUSE statement stops the program's execution. The PAUSE statement is obsolescent because a WRITE statement may send a message to any device, and a READ statement may be used to wait for a message from the same device.
Syntax
PAUSE [character-expression | digits ]The PAUSE statement stops the program's execution. The program may be restarted later and execution will then continue with the statement following the PAUSE statement.
The POINTER specification statement (attribute) declares a scalar variable to
be a pointer variable (of type INTEGER), and another variable to be its
target pointer-based variable.
Note
The POINTER statement is not implemented in version 2.0 of
pghpf.
Syntax
POINTER [::] object-name [ (deferred-shape-spec-list) ] [, object-name [ ( deferred-shape-spec-list ) ]]
Example
REAL, DIMENSION(:,:), POINTER:: X
The PRINT statement is a data transfer output statement.
Syntax
PRINT format-identifier [, iolist] or PRINT namelist-group
Description
When a PRINT statement is executed the following operations are carried out : data is transferred to the standard output device from the items specified in the output list and format specification.[*] The data are transferred between the specified destinations in the order specified by the input/output list. Every item whose value is to be transferred must be defined.
The PRIVATE statement specifies entities defined in a module are not accessible outside of the module. This statement is only valid in a module. The default specification for a module is PUBLIC.
Syntax
PRIVATE [[ :: [ access-id-list ]
Description
Example
MODULE FORMULA
PRIVATE
PUBLIC :: VARA
.
.
.
END MODULE
Type
Non-executable
See Also
PUBLIC, MODULE
The PROGRAM statement specifies the entry point for the linked Fortran program.
Syntax
PROGRAM [name]
.
.
.
END [ PROGRAM [program-name]]
Description
The program statement specifies the entry point for the linked Fortran program. An END statement terminates the program.
The END PROGRAM statement terminates a main program unit that begins with the optional PROGRAM statement. The program name found in the END PROGRAM must match that in the PROGRAM statement.
Example
PROGRAM MYOWN
REAL MEAN, TOTAL
.
CALL TRIG(A,B,C,MEAN)
.
END
The PUBLIC statement specifies entities defined in a module are accessible outside of the module. This statement is only valid in a module. The default specification for a module is PUBLIC.
Syntax
PUBLIC [[ :: [ access-id-list ]
Example
MODULE FORMULA
PRIVATE
PUBLIC :: VARA
.
.
.
END MODULE
Type
Non-excutable
See Also
PRIVATE, MODULE
The PURE attribute indicates whether a function or subroutine has side effects. This indicates if a subroutine or function can be used in a FORALL statement or construct.
Syntax
PURE [type-specification] FUNCTIONor
type-specification PURE FUNCTIONor
PURE SUBROUTINE
Type
Non-executable
See Also
FUNCTION, SUBROUTINE
The READ statement is the data transfer input statement.
Syntax
READ ([unit=] u, format-identifier [,control-information) [iolist] READ format-identifier [,iolist] READ ([unit=] u, [NML=] namelist-group [,control-information])where the UNIT= is optional and the external unit specifier u is an integer.
In addition control-information is an optional control specification which can be any of the following: may contain one of each of the following specifiers in any order, following the unit number if the optional UNIT specifier keyword is not supplied.
Description
When a READ statement is executed the following operations are carried out : data is transferred from the standard input device to the items specified in the input and format specification.[*] The data are transferred between the specified destinations in the order specified by the input/output list. Every item whose value is to be transferred must be defined.
Example
READ(2,110) I,J,K
110 FORMAT(I2, I4, I3)
Syntax
The syntax for REAL has two forms, a standard Fortran 90 attributed form, and the PGI extended form. This section describes both syntax forms.
REAL [ ( [ KIND = kind-value ) ] [, attribute-list ::] entity-listREAL permits a KIND specification. Refer to the Fortran 90 handbook for more syntax details.
PGI Syntax Extension
REAL [*n] name [*n] [dimensions] [/clist/] [, name] [*n] [dimensions][/clist/]...
Description
The REAL type declaration statements may be used to dimension arrays explicitly in the same way as the DIMENSION statement. Type declaration statements must not be labeled. Note: The data type of a symbol may be explicitly declared only once. It is established by type declaration statement, IMPLICIT statement or by predefined typing rules. Explicit declaration of a type overrides any implicit declaration. An IMPLICIT statement overrides predefined typing rules.
The RECURSIVE statement indicates whether a function or subroutine may call itself recursively.
Syntax
RECURSIVE [type-specification] FUNCTIONor
type-specification RECURSIVE FUNCTIONor
RECURSIVE SUBROUTINE
Type
Non-executable
See Also
FUNCTION, SUBROUTINE
Syntax
RETURN
RETURN expression
Example
SUBROUTINE FIX (A,B,*,*,C)
40 IF (T) 50, 60, 70
50 RETURN
60 RETURN 1
70 RETURN 2
END
PROGRAM FIXIT
CALL FIX(X, Y, *100, *200, S)
WRITE(*,5) X, S ! Come here if (T) < 0
STOP
100 WRITE(*, 10) X, Y ! Come here if (T) = 0
STOP
200 WRITE(*,20) Y, S ! Come here if (T) > 0
The REWIND statement positions the file at its beginning. The statement has no effect if the file is already positioned at the start or if the file is connected but does not exist.
Syntax
REWIND unit REWIND (unit,list)
Examples
REWIND 5 REWIND(2, ERR=30) REWIND(3, IOSTAT=IOERR)
Syntax
SAVE [v [, v ]...]
Description
Using a common-block name, preceded and followed by a slash, ensures that all entities within that COMMON block are saved. SAVE may be used without a list, in which case all the allowable entities within the program unit are saved (this has the same effect as using the -Msave command-line option). Dummy arguments, names of procedures and names of entities within a common block may not be specified in a SAVE statement. Use of the SAVE statement with local variables ensures the values of the local variables are retained for the next invocation of the SUBROUTINE or FUNCTION. Within a main program the SAVE statement is optional and has no effect.
When a RETURN or END is executed within a subroutine or function, all entities become undefined with the exception of:
Example
PROGRAM SAFE
.
CALL KEEP
.
SUBROUTINE KEEP
COMMON /LIST/ TOP, MIDDLE
INTEGER LOCAL1.
.
SAVE /LIST/, LOCAL1
The SELECT CASE statement begins a CASE construct.
Syntax
[case-name:]SELECT CASE (case-expr) [ CASE selector [name] block] ... [ CASE DEFAULT [case-name] block END SELECT [case-name]
Example
SELECT CASE (FLAG)
CASE ( 1, 2, 3 )
TYPE=1
CASE ( 4:6 )
TYPE=2
CASE DEFAULT
TYPE=0
END SELECT
Note, there is also an HPF SEQUENCE directive that specifes whether an array, common block, or equvalence is sequential or non-sequential. Refer to Chapter 4, HPF Directives for more information.
Syntax
TYPE [SEQUENCE] type-specification... END TYPE
Example
TYPE RECORD
SEQUENCE
CHARACTER NAME(25)
INTEGER CUST_NUM
REAL COST
END TYPE
The STOP statement stops the program's execution and precludes any further execution of the program.
Syntax
STOP [character-expression | digits ]
Syntax
[RECURSIVE] SUBROUTINE name & [(argument[,argument...])] & [specification-part] [exectuion-part] [internal-subspart] END [SUBROUTINE [name]]
Description
A SUBROUTINE must be terminated by an END statement. The statements and names in the subprogram only apply to the subroutine except for subroutine or function references and the names of COMMON blocks. Dummy arguments may be specified as * which indicates that the SUBROUTINE contains alternate returns.
Recursion is allowed if the -Mrecursive option is used on the command-line and the RECURSIVE prefix is included in the function definition.
Example
SUBROUTINE DAXTIM (A, X, Y, N, M, ITER, FP, TOH) INTEGER*4 N, M, ITER
REAL*8 A, X(N,M), Y(N,M), FP, TOH . . . END SUBROUTINE DAXTIM
See Also
PURE, RECURSIVE
The TARGET specification statement (attribute) specifies that a data type may
be the object of a pointer variable - that is pointed to by a pointer variable.
Likewise, types that do not have the TARGET attribute cannot be the target of a
pointer variable.
Note
The TARGET statement is not implemented in version 2.0 of
pghpf.
Syntax
TARGET [ :: ] object-name [(array-spec)] [, object-name [(array-spec)]]...
See Also
ALLOCATABLE, POINTER
The TYPE statement begins a derived type data specification or declares variables of a specified user-defined type.
Syntax Type Declaration
TYPE (type-name) [ , attribute-list :: ] entity-list
Syntax Derived Type Definition
TYPE [[ access-spec ] :: ] type-name [ private-sequence-statement ] ... component-definition-statement [ component-definition-statement ]... END TYPE [type-name]
The USE statement gives a program unit access to the public entities or to the named entities in the specified module.
Syntax
USE module-name [, rename-list ] USE module-name, ONLY: [ only-list ]
Examples
USE MOD1 USE MOD2, TEMP => VAR USE MOD3, ONLY: RESULTS, SCORES => VAR2
Type
Non-executable
See Also
MODULE
The VOLATILE statement inhibits all optimizations on the variables, arrays and common blocks that it identifies.
Syntax
VOLATILE nitem [, nitem ...]
Description
If nitem names a common block, all members of the block are volatile. The volatile attribute of a variable is inherited by any direct or indirect equivalences, as shown in the example.
Example
COMMON /COM/ C1, C2
VOLATILE /COM/, DIR ! /COM/ and DIR are volatile
EQUIVALENCE (DIR, X) ! X is volatile
EQUIVALENCE (X, Y) ! Y is volatile
The WHERE statement and the WHERE END WHERE construct permit masked assignments to the elements of an array (or to a scalar, zero dimensional array).
Syntax WHERE Statement
WHERE (logical-array-expr) array-variable = array-expr
Syntax WHERE Construct
WHERE (logical-array-expr) array-assignments [ELSE WHERE array-assignments ] END WHERE
Description
This construct allows for conditional assignment to an array based on the result of a logical array expression. The logical array expression and the array assignments must involve arrays of the same shape.
Examples
INTEGER SCORE(30)
CHARACTER GRADE(30)
WHERE ( SCORE > 60 ) GRADE = 'P'
WHERE ( SCORE > 60 )
GRADE = 'P'
ELSE WHERE
GRADE = 'F'
END WHERE
Syntax
WRITE ([unit=] u, [,control-information) [iolist] WRITE ([unit=] u, [NML=] namelist-group [,control-information])where the UNIT= is optional and the external unit specifier u is an integer. This may also be a * indicating list-directed output.
In addition to the unit specification, control-information are optional control specifications, and may be any of those listed in the following (there are some limits on the allowed specifications depending on the type of output, for example, non-advancing, direct and sequential):
Description
When a WRITE statement is executed the following operations are carried out: data is transferred to the standard output device from the items specified in the output list and format specification.[*] The data are transferred between the specified destinations in the order specified by the input/output list. Every item whose value is to be transferred must be defined.
Example
WRITE (6,90) NPAGE
90 FORMAT('1PAGE NUMBER ',I2,16X,'SALES REPORT, Cont.')