SELECTED_LOGICAL_KIND (The GNU Fortran Compiler)

### 8.251 `SELECTED_LOGICAL_KIND` — Choose logical kind ¶

Synopsis:

  `RESULT = SELECTED_LOGICAL_KIND(BITS)`

Description:

  `SELECTED_LOGICAL_KIND(BITS)` return the kind value of the smallest logical type whose storage size in bits is at least BITS. If there is no such logical kind, `SELECTED_LOGICAL_KIND` returns -1.

Class:

  Transformational function

Arguments:

  BITS | Shall be a scalar and of type `INTEGER`.

Example:

      program logical_kinds
        integer, parameter :: k1 = selected_logical_kind(1)
        integer, parameter :: k40 = selected_logical_kind(40)
        logical(kind=k1) :: l1    ! At least one bit
        logical(kind=k40) :: l40  ! At least 40 bits

        ! What is their actual size?
        print *, storage_size(l1), storage_size(l40)
      end program logical_kinds

Standard:

  Fortran 2023 and later