The KIND Number

Integers

Suppose a processor supports three different range values for integers, -128--127, -65536--65535 and a 32-bit representation (-4.29*10^9--4.29*10^9):

    INTEGER(KIND=1) :: a, b
    INTEGER(2)      :: c, d
    INTEGER(4)      :: e
or more portably:
    INTEGER, PARAMETER :: short = 1, medium = 2, long = 4

    INTEGER(short)  :: a, b
    INTEGER(medium) :: c, d
    INTEGER(long)   :: e

SELECTED_INT_KIND

    SELECTED_INT_KIND(r)
returns the KIND value of the integer representation with the smallest range that can represent values n such that
    -10^r < n < 10^r
Therefore we have:
    INTEGER, PARAMETER :: short  = SELECTED_INT_KIND(2), & 
                          medium = SELECTED_INT_KIND(4), & 
                          long   = SELECTED_INT_KIND(10)

    INTEGER(short)  :: a, b
    INTEGER(medium) :: c, d
    INTEGER(long)   :: e

Reals

    REAL, PARAMETER :: single = 4, double = 8, extended = 16;

    REAL(single)   :: x, y
    REAL(double)   :: xx, yy
    REAL(extended) :: eee

SELECTED_REAL_KIND

    SELECTED_REAL_KIND(p,r)
where p is the required precision and r is as before. Therefore we have:
    REAL, PARAMETER :: single   = SELECTED_REAL_KIND(5,20), & 
                       double   = SELECTED_REAL_KIND(10,40), & 
                       extended = SELECTED_REAL_KIND(20,100)

    REAL(single)   :: a, b
    REAL(double)   :: c, d
    REAL(extended) :: e

COMPLEX

Is analogous to that for REAL --- same KIND values.

CHARACTER

Skipped!

LOGICAL

Skipped!


...previousup (conts)next...



About this document:

Produced from the SGML: /home/isd/public_html/_course_fortran_90/_reml_grp/index.reml
On: 10/2/2003 at 10:33:52
Options: reml2 -i noindex -l long -o html -p multiple