Standard Fortran Types

Fortran provides all the typical data types supported directly by most CPUs, as well as a few abstract types. Table 16.2, “Fortran 90 Data Types” outlines the standard data types available in Fortran 90.

Table 16.2. Fortran 90 Data Types

Fortran 90 TypeDescriptionRangePrecision
integer(1)8-bit signed integer-128 to +127Exact
integer(2)16-bit signed integer-32,768 to +32,767Exact
integer(4) [ integer ]32-bit signed integer-2,147,483,648 to +2,147,483,647Exact
integer(8)64-bit signed integer+/- 9.22 x 1018Exact
integer(16)128-bit signed integer+/- 9.22 x 1018 or +/- 1.70 x 1038Exact
real(4) [ real ]32-bit floating point+/- (1.1754 x 10-38 to 3.4028 x 1038)24 bits (6-7 decimal digits)
real(8) [ double precision ]64-bit floating point+/- (2.2250 x 10-308 to 1.7976 x 10308)52 bits (15-16 decimal digits)
real(16)128-bit floating point+/- 3.3621 x 10-4932 to 1.1897 x 10+4932)114 bits (64 decimal digits)
character8-bit ISO, 16-bit in non-Latin localesISO 0 (NUL) to 255 (y-umlaut in ISO-Latin1)Exact
logical.true. or .false.false to trueExact
complex(4) [ complex ]Two 32-bit floating point valuesSame as real(4)Same as real(4)
complex(8) [ double complex ]Two 64-bit floating point valuesSame as real(8)Same as real(8)
complex(16)Two 128-bit floating point valuesSame as real(16)Same as real(16)



Be sure to thoroughly review the instructions in Section 2, “Practice Problem Instructions” before doing the practice problems below.
  1. What would be the best Fortran data type to use for each of the following values? Explain your reasoning in each case. Use the C types table in the text and the adjoining explanations to make optimal choices.

    1. A single variable containing a person's age, in years.

    2. A single variable holding the temperature of a star, up to 40,000 Kelvin. The value is only approximate within 1,000 degrees.

    3. The balance of Joe Sixpack's checking account, in pennies.

    4. A huge array of people's ages in years.

    5. A single variable holding Avogadro's constant.

    6. A large array holding values like Avogadro's constant.