Manual Reference Pages  - selected_int_kind (3fortran)

NAME

SELECTED_INT_KIND(3) - [KIND] Choose integer kind

SYNOPSIS

result = selected_int_kind(r)

integer function selected_int_kind(r)

         integer(kind=KIND),intent(in) :: r

CHARACTERISTICS

o R is an integer scalar.
o the result is an default integer scalar.

DESCRIPTION

SELECTED_INT_KIND(3) return the kind value of the smallest integer type that can represent all values ranging from -10**R (exclusive) to 10**R (exclusive). If there is no integer kind that accommodates this range, selected_int_kind returns -1.

OPTIONS

o R : The value specifies the required range of powers of ten that need supported by the kind type being returned.

RESULT

The result has a value equal to the value of the kind type parameter of an integer type that represents all values in the requested range.

if no such kind type parameter is available on the processor, the result is -1.

If more than one kind type parameter meets the criterion, the value returned is the one with the smallest decimal exponent range, unless there are several such values, in which case the smallest of these kind values is returned.

EXAMPLES

Sample program:

    program demo_selected_int_kind
    implicit none
    integer,parameter :: k5 = selected_int_kind(5)
    integer,parameter :: k15 = selected_int_kind(15)
    integer(kind=k5) :: i5
    integer(kind=k15) :: i15

print *, huge(i5), huge(i15)

! the following inequalities are always true print *, huge(i5) >= 10_k5**5-1 print *, huge(i15) >= 10_k15**15-1 end program demo_selected_int_kind

Results:

      >   2147483647  9223372036854775807
      >  T
      >  T

STANDARD

Fortran 95

SEE ALSO

AINT(3), ANINT(3), INT(3), NINT(3), CEILING(3), FLOOR(3)

Fortran intrinsic descriptions (license: MIT) @urbanjost


Nemo Release 3.1 selected_int_kind (3fortran) November 02, 2024
Generated by manServer 1.08 from 1747ed44-49bf-4ffe-90fa-b0b454969523 using man macros.