Integer Data Types

Integer data types can be specified as follows:

INTEGER
INTEGER([KIND=]n)
INTEGER*n

n
Is kind 1, 2, 4, or 8.

If a kind parameter is specified, the integer has the kind specified. If a kind parameter is not specified, integer constants are interpreted as follows:

You can change the result of a default specification by using the /integer_size:size compiler option or the INTEGER compiler directive.

The intrinsic inquiry function KIND returns the kind type parameter, if you do not know it. You can use the intrinsic function SELECTED_INT_KIND to find the kind values that provide a given range of integer values. The decimal exponent range is returned by the intrinsic function RANGE.

For more information on the integer data type, see Integer Constants.

Examples

The following examples show ways an integer variable can be declared.
An entity-oriented example is:

 INTEGER, DIMENSION(:), POINTER :: days, hours
 INTEGER(2), POINTER :: k, limit
 INTEGER(1), DIMENSION(10) :: min

An attribute-oriented example is:

 INTEGER days, hours
 INTEGER(2) k, limit
 INTEGER(1) min
 DIMENSION days(:), hours(:), min (10)
 POINTER days, hours, k, limit

An integer can be used in certain cases when a logical value is expected, such as in a logical expression evaluating a condition, as in the following:

 INTEGER I, X
 READ (*,*) I
 IF (I) THEN
   X = 1
 END IF