8 SPECIFICATION STATEMENTS

There are nine kinds of specification statements:
  1. DIMENSION
  2. EQUIVALENCE
  3. COMMON
  4. INTEGER, REAL, DOUBLE PRECISION, COMPLEX, LOGICAL, and CHARACTER type-statements
  5. IMPLICIT
  6. PARAMETER
  7. EXTERNAL
  8. INTRINSIC
  9. SAVE

All specification statements are nonexecutable.

8.1 DIMENSION Statement

A DIMENSION statement is used to specify the symbolic names and dimension specifications of arrays.

The form of a DIMENSION statement is:

DIMENSION a(d) [,a(d)]...
where each a(d) is an array declarator ( 5.1).

Each symbolic name a appearing in a DIMENSION statement declares a to be an array in that program unit. Note that array declarators may also appear in COMMON statements and type-statements. Only one appearance of a symbolic name as an array name in an array declarator in a program unit is permitted.

8.2 EQUIVALENCE Statement

An EQUIVALENCE statement is used to specify the sharing of storage units by two or more entities in a program unit. This causes association of the entities that share the storage units.

If the equivalenced entities are of different data types, the EQUIVALENCE statement does not cause type conversion or imply mathematical equivalence. If a variable and an array are equivalenced, the variable does not have array properties and the array does not have the properties of a variable.

8.2.1 Form of an EQUIVALENCE Statement.

The form of an EQUIVALENCE statement is:
EQUIVALENCE (nlist) [,(nlist)]...
where each nlist is a list ( 2.10) of variable names, array element names, array names, and character substring names. Each list must contain at least two names. Names of dummy arguments of an external procedure in a subprogram must not appear in the list. If a variable name is also a function name ( 15.5.1), that name must not appear in the list.

Each subscript expression or substring expression in a list nlist must be an integer constant expression.

8.2.2 Equivalence Association.

An EQUIVALENCE statement specifies that the storage sequences of the entities whose names appear in a list nlist have the same first storage unit. This causes the association of the entities in the list nlist and may cause association of other entities ( 17.1).

8.2.3 Equivalence of Character Entities.

An entity of type character may be equivalenced only with other entities of type character. The lengths of the equivalenced entities are not required to be the same.

An EQUIVALENCE statement specifies that the storage sequences of the character entities whose names appear in a list nlist have the same first character storage unit. This causes the association of the entities in the list nlist and may cause association of other entities ( 17.1). Any adjacent characters in the associated entities may also have the same character storage unit and thus may also be associated. In the example:

  1. CHARACTER A*4, B*4, C(2)*3
  2. EQUIVALENCE (A,C(1)), (B,C(2))

the association of A, B, and C can be graphically illustrated as:

| 01|  02|  03|  04|  05|  06|  07|

            | --------A--------|
                             --------B--------|
            | ----C(1)----|  ----C(2)----|

8.2.4 Array Names and Array Element Names.

If an array element name appears in an EQUIVALENCE statement, the number of subscript expressions must be the same as the number of dimensions specified in the array declarator for the array name.

The use of an array name unqualified by a subscript in an EQUIVALENCE statement has the same effect as using an array element name that identifies the first element of the array.

8.2.5 Restrictions on EQUIVALENCE Statements.

An EQUIVALENCE statement must not specify that the same storage unit is to occur more than once in a storage sequence. For example,
  1. DIMENSION A(2)
  2. EQUIVALENCE (A(1),B), (A(2),B)

is prohibited, because it would specify the same storage unit for A(1) and A(2). An EQUIVALENCE statement must not specify that consecutive storage units are to be nonconsecutive. For example, the following is prohibited:

  1. REAL A(2)
  2. DOUBLE PRECISION D(2)
  3. EQUIVALENCE (A(1),D(1)), (A(2),D(2))

8.3 COMMON Statement

The COMMON statement provides a means of associating entities in different program units. This allows different program units to define and reference the same data without using arguments, and to share storage units.

8.3.1 Form of a COMMON Statement.

The form of a COMMON statement is:
COMMON [/[cb]/] nlist [/[cb]/ nlist]...

Each omitted cb specifies the blank common block. If the first cb is omitted, the first two slashes are optional.

In each COMMON statement, the entities whose names appear in an nlist following a block name cb are declared to be in common block cb . If the first cb is omitted, all entities whose names appear in the first nlist are specified to be in blank common. Alternatively, the appearance of two slashes with no block name between them declares the entities whose names appear in the list nlist that follows to be in blank common.

Any common block name cb or an omitted cb for blank common may occur more than once in one or more COMMON statements in a program unit. The list nlist following each successive appearance of the same common block name is treated as a continuation of the list for that common block name.

If a character variable or character array is in a common block, all of the entities in that common block must be of type character.

8.3.2 Common Block Storage Sequence.

For each common block, a common block storage sequence is formed as follows:
  1. A storage sequence is formed consisting of the storage sequences of all entities in the lists nlist Z for the common block. The order of the storage sequence is the same as the order of the appearance of the lists nlist in the program unit.
  2. The storage sequence formed in (1) is extended to include all storage units of any storage sequence associated with it by equivalence association. The sequence may be extended only by adding storage units beyond the last storage unit. Entities associated with an entity in a common block are considered to be in that common block.

8.3.3 Size of a Common Block.

The size of a common block is the size of its common block storage sequence, including any extensions of the sequence resulting from equivalence association.

Within an executable program, all named common blocks that have the same name must be the same size. Blank common blocks within an executable program are not required to be the same size.

8.3.4 Common Association.

Within an executable program, the common block storage sequences of all common blocks with the same name have the same first storage unit. Within an executable program, the common block storage sequences of all blank common blocks have the same first storage unit. This results in the association ( 17.1) of entities in different program units.

8.3.5 Differences between Named Common and Blank Common.

A blank common block has the same properties as a named common block, except for the following:
  1. Execution of a RETURN or END statement sometimes causes entities in named common blocks to become undefined but never causes entities in blank common to become undefined ( 15.8.4).
  2. Named common blocks of the same name must be of the same size in all program units of an executable program in which they appear, but blank common blocks may be of different sizes.
  3. Entities in named common blocks may be initially defined by means of a DATA statement in a block data subprogram, but entities in blank common must not be initially defined (Section 9).

8.3.6 Restrictions on Common and Equivalence.

An EQUIVALENCE statement must not cause the storage sequences of two different common blocks in the same program unit to be associated. Equivalence association must not cause a common block storage sequence to be extended by adding storage units preceding the first storage unit of the first entity specified in a COMMON statement for the common block. For example, the following is not permitted:
  1. COMMON /X/A
  2. REAL B(2)
  3. EQUIVALENCE (A,B(2))

8.4 Type-Statements

A type-statement is used to override or confirm implicit typing and may specify dimension information.

The appearance of the symbolic name of a constant, variable, array, external function, or statement function in a type-statement specifies the data type for that name for all appearances in the program unit. Within a program unit, a name must not have its type explicitly specified more than once.

A type-statement that confirms the type of an intrinsic function whose name appears in the Specific Name column of Table 5 is not required, but is permitted. If a generic function name appears in a type-statement, such an appearance is not sufficient by itself to remove the generic properties from that function.

The name of a main program, subroutine, or block data subprogram must not appear in a type-statement.

8.4.1 INTEGER, REAL, DOUBLE PRECISION, COMPLEX, and LOGICAL Type-Statements.

An INTEGER, REAL, DOUBLE PRECISION, COMPLEX, or LOGICAL type-statement is of the form:
typ v[,v]...

8.4.2 CHARACTER Type-Statement.

The form of a CHARACTER type-statement is:
CHARACTER [*len ] nam [,nam]...

A length len immediately following the word CHARACTER is the length specification for each entity in the statement not having its own length specification. A length specification immediately following an entity is the length specification for only that entity. Note that for an array the length specified is for each array element. If a length is not specified for an entity, its length is one.

An entity declared in a CHARACTER statement must have a length specification that is an integer constant expression, unless that entity is an external function, a dummy argument of an external procedure, or a character constant that has a symbolic name.

If a dummy argument has a len of (*) declared, the dummy argument assumes the length of the associated actual argument for each reference of the subroutine or function. If the associated actual argument is an array name, the length assumed by the dummy argument is the length of an array element in the associated actual argument array.

If an external function has a len of (*) declared in a function subprogram, the function name must appear as the name of a function in a FUNCTION or ENTRY statement in the same subprogram. When a reference to such a function is executed, the function assumes the length specified in the referencing program unit.

The length specified for a character function in the program unit that references the function must be an integer constant expression and must agree with the length specified in the subprogram that specifies the function. Note that there always is agreement of length if a len of (*) is specified in the subprogram that specifies the function.

If a character constant that has a symbolic name has a len of (*) declared, the constant assumes the length of its corresponding constant expression in a PARAMETER statement.

The length specified for a character statement function or statement function dummy argument of type character must be an integer constant expression.

8.5 IMPLICIT Statement

An IMPLICIT statement is used to change or confirm the default implied integer and real typing.

The form of an IMPLICIT statement is:

IMPLICIT typ (a [,a]...) [,typ (a [,a]...)]...

An IMPLICIT statement specifies a type for all variables, arrays, symbolic names of constants, external functions, and statement^ functions that begin with any letter that appears in the specification, either as a single letter or included in a range of letters. IMPLICIT statements do not change the type of any intrinsic functions. An IMPLICIT statement applies only to the program unit that contains it.

Type specification by an IMPLICIT statement may be overridden or confirmed for any particular variable, array, symbolic name of a constant, external function, or statement function name by the appearance of that name in a type-statement. An explicit type specification in a FUNCTION statement overrides an IMPLICIT statement for the name of that function subprogram. Note that the length is also overridden when a particular name appears in a CHARACTER or CHARACTER FUNCTION statement.

Within the specification statements of a program unit, IMPLICIT statements must precede all other specification statements except PARAMETER statements. A program unit may contain more than one IMPLICIT statement.

The same letter must not appear as a single letter, or be included in a range of letters, more than once in all of the IMPLICIT statements in a program unit.

8.6 PARAMETER Statement

The PARAMETER statement is used to give a constant a symbolic name.

The form of a PARAMETER statement is:

PARAMETER (p=e [,p=e]...)

If the symbolic name p is of type integer, real, double precision, or complex, the corresponding expression e must be an arithmetic constant expression ( 6.1.3). If the symbolic name p is of type character or logical, the corresponding expression e must be a character constant expression ( 6.2.3) or a logical constant expression ( 6.4.4), respectively.

Each p is the symbolic name of a constant that becomes defined with the value determined from the expression e that appears on the right of the equals, in accordance with the rules for assignment statements ( 10.1, 10.2, and 10.4).

Any symbolic name of a constant that appears in an expression e must have been defined previously in the same or a different PARAMETER statement in the same program unit.

A symbolic name of a constant must not become defined more than once in a program unit.

If a symbolic name of a constant is not of default implied type, its type must be specified by a type-statement or IMPLICIT statement prior to its first appearance in a PARAMETER statement. If the length specified for the symbolic name of a constant of type character is not the default length of one, its length must be specified in a type-statement or IMPLICIT statement prior to the first appearance of the symbolic name of the constant. Its length must not be changed by subsequent statements including IMPLICIT statements.

Once such a symbolic name is defined, that name may appear in that program unit in any subsequent statement as a primary in an expression or in a DATA statement ( 9.1). A symbolic name of a constant must not be part of a format specification. A symbolic name of a constant must not be used to form part of another constant, for example, any part of a complex constant.

A symbolic name in a PARAMETER statement may identify only the corresponding constant in that program unit.

8.7 EXTERNAL Statement

An EXTERNAL statement is used to identify a symbolic name as representing an external procedure or dummy procedure, and to permit such a name to be used as an actual argument.

The form of an EXTERNAL statement is:

EXTERNAL proc [,proc]...
where each proc is the name of an external procedure, dummy procedure, or block data subprogram. Appearance of a name in an EXTERNAL statement declares that name to be an external procedure name or dummy procedure name, or block data subprogram name. If an external procedure na`)me or a dummy procedure name is used as an actual argument in a program unit, it must appear in an EXTERNAL statement in that program unit. Note that a statement function name must not appear in an EXTERNAL statement.

If an intrinsic function name appears in an EXTERNAL statement in a program unit, that name becomes the name of some external procedure and an intrinsic function of the same name is not available for reference in the program unit.

Only one appearance of a symbolic name in all of the EXTERNAL statements of a program unit is permitted.

8.8 INTRINSIC Statement

An INTRINSIC statement is used to identify a symbolic name as representing an intrinsic function ( 15.3). It also permits a name that represents a specific intrinsic function to be used as an actual argument.

The form of an INTRINSIC statement is:

INTRINSIC fun [,fun]...
where each fun is an intrinsic function name.

Appearance of a name in an INTRINSIC statement declares that name to be an intrinsic function name. If 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. The names of intrinsic functions for type conversion (INT, IFIX, IDINT, FLOAT, SNGL, REAL, DBLE, CMPLX, ICHAR, CHAR), lexical relationship (LGE, LGT, LLE, LLT), and for choosing the largest or smallest value (MAX, MAX0, AMAX1, DMAX1, AMAX0, MAX1, MIN, MIN0, AMIN1, DMIN1, AMIN0, MIN1) must not be used as actual arguments.

The appearance of a generic function name in an INTRINSIC statement does not cause that name to lose its generic property.

Only one appearance of a symbolic name in all of the INTRINSIC statements of a program unit is permitted. Note that a symbolic name must not appear in both an EXTERNAL and an INTRINSIC statement in a program unit.

8.9 SAVE Statement

A SAVE statement is used to retain the definition status of an entity after the execution of a RETURN or END statement in a subprogram. Within a function or subroutine subprogram, an entity specified by a SAVE statement does not become undefined as a result of the execution of a RETURN or END statement in the subprogram. However, such an entity in a common block may become undefined or redefined in another program unit.

The form of a SAVE statement is:

SAVE [a [,a]...]
where each a is a named common block name preceded and followed by a slash, a variable name, or an array name. Redundant appearances of an item are not permitted.

Dummy argument names, procedure names, and names of entities in a common block must not appear in a SAVE statement.

A SAVE statement without a list is treated as though it contained the names of all allowable items in the program unit.

The appearance of a common block name preceded and followed by a slash in a SAVE statement has the effect of specifying all of the entities in that common block.

If a particular common block name is specified by a SAVE statement in a subprogram of an executable program, it must be specified by a SAVE statement in every subprogram in which that common block appears.

A SAVE statement is optional in a main program and has no effect.

If a named common block is specified in a SAVE statement in a subprogram, the current values of the entities in the common block storage sequence ( 8.3.3) at the time a RETURN or END statement is executed are made available to the next program unit that specifies that common block name in the execution sequence of an executable program.

If a named common block is specified in the main program unit, the current values of the common block storage sequence are made available to each subprogram that specifies that named common block; a SAVE statement in the subprogram has no effect.

The definition status of each entity in the named common block storage sequence depends on the association that has been established for the common block storage sequence ( 17.2 and 17.3).

If a local entity that is specified by a SAVE statement and is not in a common block is in a defined state at the time a RETURN or END statement is executed in a subprogram, that entity is defined with the same value at the next reference of that subprogram.

The execution of a RETURN statement or an END statement within a subprogram causes all entities within the subprogram to become undefined except for the following:

  1. Entities specified by SAVE statements
  2. Entities in blank common
  3. Initially defined entities that have neither been redefined nor become undefined
  4. Entities in a named common block that appears in the subprogram and appears in at least one other program unit that is referencing, either directly or indirectly, that subprogram

'




[Contents] [Previous] [Next] [Home]

NDP77
http://www.ndp77.net
webmaster MFA (main)
webmaster@ndp77.net