This section describes the data types in Sun FORTRAN 77.
Default data declarations, those that do not explicitly declare a data size can have their meanings changed by certain compiler options. The next section, "Size and Alignment of Data Types " summarizes data sizes and alignments and the effects of these options.
The BYTE data type provides a data type that uses only one byte of storage. It is a logical data type, and has the synonym, LOGICAL*1.
A variable of type BYTE can hold any of the following:
One character
An integer between -128 and 127
The logical values, .TRUE. or .FALSE.
If it is interpreted as a logical value, a value of 0 represents .FALSE., and any other value is interpreted as .TRUE.
f77 allows the BYTE type as an array index, just as it allows the REAL type, but it does not allow BYTE as a DO loop index (where it allows only INTEGER, REAL, and DOUBLE PRECISION). Wherever the compiler expects INTEGER explicitly, it will not allow BYTE.
BYTE Bit3 / 8 /, C1 / 'W' /, & Counter / 0 /, Switch / .FALSE. /
A BYTE item occupies 1 byte (8 bits) of storage, and is aligned on 1-byte boundaries.
The character data type, CHARACTER, which has the synonym, CHARACTER*1, holds one character.
The character is enclosed in apostrophes (') or quotes ("). @ Allowing quotes (") is nonstandard; if you compile with the -xl option, quotes mean something else, and you must use apostrophes to enclose a string.
The data of type CHARACTER is always unsigned. A CHARACTER item occupies 1 byte (8 bits) of storage and is aligned on 1-byte boundaries.
The character string data type, CHARACTER*n, where n > 0, holds a string of n characters.
A CHARACTER*n data type occupies n bytes of storage and is aligned on 1-byte boundaries.
Every character string constant is aligned on 2-byte boundaries. If it does not appear in a DATA statement, it is followed by a null character to ease communication with C routines.
A complex datum is an approximation of a complex number. The complex data type, COMPLEX, which defaults to a synonym for COMPLEX*8, is a pair of REAL*4 values that represent a complex number. The first element represents the real part and the second represents the imaginary part.
The default size for a COMPLEX item (no size specified) is 8 bytes. The default alignment is on 4-byte boundaries. However, these defaults can be changed by compiling with certain special options (see "Size and Alignment of Data Types ").
The complex data type COMPLEX*8 is a synonym for COMPLEX, except that it always has a size of 8 bytes, independent of any compiler options.
The complex data type COMPLEX*16 is a synonym for DOUBLE COMPLEX, except that it always has a size of 16 bytes, independent of any compiler options.
(SPARC only) The complex data type COMPLEX*32 is a quadruple-precision complex. It is a pair of REAL*16 elements, where each has a sign bit, a 15-bit exponent, and a 112-bit fraction. These REAL*16 elements in f77 conform to the IEEE standard.
The size for COMPLEX*32 is 32 bytes.
The complex data type, DOUBLE COMPLEX, which usually has the synonym, COMPLEX*16, is a pair of DOUBLE PRECISION (REAL*8) values that represents a complex number. The first element represents the real part; the second represents the imaginary part.
The default size for DOUBLE COMPLEX with no size specified is 16.
A double-precision datum is an approximation of a real number. The double-precision data type, DOUBLE PRECISION, which has the synonym, REAL*8, holds one double-precision datum.
The default size for DOUBLE PRECISION with no size specified is 8 bytes.
A DOUBLE PRECISION element has a sign bit, an 11-bit exponent, and a 52-bit fraction. These DOUBLE PRECISION elements in f77 conform to the IEEE standard for double-precision floating-point data. The layout is shown in Appendix C, Data Representations .
The integer data type, INTEGER, holds a signed integer.
The default size for INTEGER with no size specified is 4, and is aligned on 4-byte boundaries. However, these defaults can be changed by compiling with certain special options (see "Size and Alignment of Data Types ").
The short integer data type, INTEGER*2, holds a signed integer. An expression involving only objects of type INTEGER*2 is of that type. Using this feature may have adverse performance implications, and we do not recommend it.
Generic functions return short or long integers depending on the default integer type. If a procedure is compiled with the -i2 flag, all integer constants that fit and all variables of type INTEGER (no explicit size) are of type INTEGER*2. If the precision of an integer-valued intrinsic function is not determined by the generic function rules, one is chosen that returns the prevailing length (INTEGER*2) when the -i2 compilation option is in effect. With -i2, the default length of LOGICAL quantities is 2 bytes.
Ordinary integers follow the FORTRAN rules about occupying the same space as a REAL variable. They are assumed to be equivalent to the C type long int, and 2-byte integers are of C type short int. These short integer and logical quantities do not obey the standard rules for storage association.
An INTEGER*2 occupies 2 bytes.
INTEGER*2 is aligned on 2-byte boundaries.
The integer data type, INTEGER*4, holds a signed integer.
An INTEGER*4 occupies 4 bytes.
INTEGER*4 is aligned on 4-byte boundaries.
The integer data type, INTEGER*8, holds a signed 64-bit integer.
An INTEGER*8 occupies 8 bytes.
INTEGER*8 is aligned on 8-byte boundaries.
The logical data type, LOGICAL, holds a logical value .TRUE. or .FALSE. The value 0 represents .FALSE.; any other value represents .TRUE.
The usual default size for an LOGICAL item with no size specified is 4, and is aligned on 4-byte boundaries. However, these defaults can be changed by compiling with certain special options.
The one-byte logical data type, LOGICAL*1, which has the synonym, BYTE, can hold any of the following:
One character
An integer between -128 and 127
The logical values .TRUE. or .FALSE.
The value is as defined for LOGICAL, but it can hold a character or small integer. An example:
LOGICAL*1 Bit3 / 8 /, C1 / 'W' /, & Counter / 0 /, Switch / .FALSE. /
A LOGICAL*1 item occupies one byte of storage.
LOGICAL*1 is aligned on one-byte boundaries.
The data type, LOGICAL*2, holds logical value .TRUE. or .FALSE. The value is defined as for LOGICAL.
A LOGICAL*2 occupies 2 bytes.
LOGICAL*2 is aligned on 2-byte boundaries.
The logical data type, LOGICAL*4 holds a logical value .TRUE. or .FALSE. The value is defined as for LOGICAL.
A LOGICAL*4 occupies 4 bytes.
LOGICAL*4 is aligned on 4-byte boundaries.
The logical data type, LOGICAL*8, holds the logical value .TRUE. or .FALSE. The value is defined the same way as for the LOGICAL data type.
A LOGICAL*8 occupies 8 bytes.
LOGICAL*8 is aligned on 8-byte boundaries.
A real datum is an approximation of a real number. The real data type, REAL, which usually has the synonym, REAL*4, holds one real datum.
The usual default size for a REAL item with no size specified is 4 bytes, and is aligned on 4-byte boundaries. However, these defaults can be changed by compiling with certain special options.
A REAL element has a sign bit, an 8-bit exponent, and a 23-bit fraction. These REAL elements in f77 conform to the IEEE standard.
The REAL*4 data type is a synonym for REAL, except that it always has a size of 4 bytes, independent of any compiler options.
The REAL*8, data type is a synonym for DOUBLE PRECISION, except that it always has a size of 8 bytes, independent of any compiler options.
(SPARC only) The REAL*16 data type is a quadruple-precision real. The size for a REAL*16 item is 16 bytes. A REAL*16 element has a sign bit, a 15-bit exponent, and a 112-bit fraction. These REAL*16 elements in f77 conform to the IEEE standard for extended precision.