HP Fortran Programmer's Reference (September 2007)

HP Fortran statements
STRUCTURE (extension)
Chapter 10 467
STRUCTURE /foo_bar/
REAL, DIMENSION(30, 50) :: bar
END STRUCTURE
The array’s dimensions must in any case appear in the type statement. The DIMENSION
statement (but not the DIMENSION attribute) is illegal in a structure definition. The following
code defines the structure, string, which uses a type declaration statement to define an array
field str of type CHARACTER(LEN=1), containing 254 elements:
STRUCTURE /string/
CHARACTER(LEN=1) :: str(254)! Contains string
INTEGER :: length ! string’s length
END STRUCTURE
As mentioned, the DIMENSION statement cannot be used in a structure definition. For
example, the following code would cause a compile-time error:
STRUCTURE /real_array/
REAL :: rarray
DIMENSION arr(100) ! illegal example
END STRUCTURE
A correct way to code this would be:
STRUCTURE /real_array/
REAL :: rarray(100)
END STRUCTURE
or
STRUCTURE /real_array/
REAL, DIMENSION(100) :: arr
END STRUCTURE
Assumed-size and adjustable arrays are also illegal in structure definitions. For example, the
following is illegal:
STRUCTURE /assumed_size/ ! illegal example
CHARACTER*(*) :: carray
END STRUCTURE
The following is also illegal:
STRUCTURE /adj_array/ ! illegal example
INTEGER :: size
REAL :: iarray(size)
END STRUCTURE
For alignment purposes, HP Fortran provides the %FILL field name. It enables the
programmer to pad a record to ensure proper alignment. The padding does not have a name
and is therefore not accessible. For example, the following structure, sixbytes, creates a
6-byte structure, of which 4 bytes are inaccessible filler bytes: