The type statement specifies the data type of items in the list, optionally specifies array dimensions, and initializes with values.
One of the following:
CHARACTER*n (where n is greater than 0)
COMPLEX*32 @(SPARC only)
DOUBLE COMPLEX @
REAL*16 @(SPARC only)
Variable name, array name, array declarator, symbolic name of a constant, statement function or function subprogram name
List of constants. There are more details about clist in the section on the DATA statement.
type can be preceded by either AUTOMATIC or STATIC.
A type statement can be used to:
Confirm or to override the type established by default or by the IMPLICIT statement
Specify dimension information for an array, or confirm the type of an intrinsic function
Override the length by one of the acceptable lengths for that data type
A type statement can assign initial values to variables, arrays, or record fields by specifying a list of constants (clist) as in a DATA statement. @
The general form of a type statement is:
type VariableName / constant /
type ArrayName / constant, /
type ArrayName / r*constant /
CHARACTER LABEL*12 / 'Standard' / COMPLEX STRESSPT / ( 0.0, 1.0 ) / INTEGER COUNT / 99 /, Z / 1 / REAL PRICE / 0.0 /, COST / 0.0 / REAL LIST(8) / 0.0, 6*1.0, 0.0 /
When you initialize a data type, remember the following restrictions:
For a simple variable, there must be exactly one constant.
If any element of an array is initialized, all must be initialized.
You can use an integer as a repeat factor, followed by an asterisk (*), followed by a constant. In the example above, six values of 1.0 are stored into array elements 2, 3, 4, 5, 6, and 7 of LIST.
If a variable or array is declared AUTOMATIC, then it cannot be initialized.
INTEGER Z / 4 / POINTER ( x, Z ) Warning issued, not initialized
In this case, the compiler issues a warning message, and Z is not initialized.
If a variable or array is not initialized, its values are undefined.
If such initialization statements involve variables in COMMON, and the -ansi compiler flag is set, then a warning is issued.
Compiling with any of the options -dbl, -r8, -i2, or -xtypemap can alter the default size of names typed without an explicit size. See the discussion in Chapter 2.
A symbolic name can appear only once in type statements in a program unit.
A type statement must precede all executable statements.
INTEGER*2 I, J/0/ REAL*4 PI/3.141592654/,ARRAY(10)/5*0.0,5*1.0/ CHARACTER*10 NAME CHARACTER*10 TITLE/'Heading'/
In the above example:
J is initialized to 0
PI is initialized to 3.141592654
The first five elements of ARRAY are initialized to 0.0
The second five elements of ARRAY are initialized to 1.0
TITLE is initialized to 'Heading'