| United States-English |
|
|
|
![]() |
HP Fortran Compiler for HP-UX: HP Fortran Programmer's Reference > Chapter 10 HP
Fortran statementsPARAMETER (statement and attribute) |
|
SyntaxA type declaration statement with the PARAMETER attribute is:
The syntax of the PARAMETER statement is:
DescriptionThe PARAMETER statement associates a symbolic name with a constant. A symbolic name defined in a PARAMETER statement is known as a named constant. A named constant must not become defined more than once in a program unit. Once defined, it can be used only as a named constant. This means that a named constant cannot be assigned a value like a variable. When the PARAMETER attribute is used, the value of the named constant must be provided by the initialization part of the statement in which the PARAMETER attribute appears. The type of a named constant is determined by the implicit typing rules, unless its type is specified by a type declaration statement prior to its first appearance in a PARAMETER statement or by a type declaration statement that includes PARAMETER as one of its attributes. If a PARAMETER statement declares and implicitly types a named constant, the named constant may appear in a subsequent type declaration or IMPLICIT statement, but only to confirm the type of the named constant. When the type of the symbolic name and the constant do not agree, the value of the named constant is assigned in accordance with assignment statement type-conversion rules, as given in Table 4-5 “Conversion of variable=expression”. The following rules apply to type agreement between the constant and the symbolic name:
Any symbolic name of a constant that appears in cexpr must have been defined previously in the same or a different PARAMETER statement in the same program unit. For example, the expression in the second PARAMETER statement below is built from the expression in the first PARAMETER statement, and is legal:
The logical operators (.EQ., .NE., .LT., .LE., .GT., and .GE.), as well as the following intrinsic functions, can appear in the PARAMETER statement: Table 10-43 Title not available (PARAMETER (statement and attribute))
If these intrinsic functions are used in a PARAMETER statement, their arguments must be constants. If the named constant is of type character and its length is not specified, the length must be specified in a type declaration statement or IMPLICIT statement prior to the first appearance of the named constant. Its type and/or length must not be changed by subsequent statements, including IMPLICIT statements. If a symbolic name of type CHARACTER*(*) is defined in a PARAMETER statement, its length becomes the length of the expression assigned to it. If the named constant is an array, the bounds must be explicit and determined by an initialization expression. Once such a symbolic name is defined, that name can appear in any subsequent statement of the defining program unit as a constant in an expression or DATA statement. Examples
Related conceptsFor information about the type declaration statement, see “Type declaration for intrinsic types”. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||