check_endian Subroutine

public subroutine check_endian()

Arguments

None

Called by

proc~~check_endian~~CalledByGraph proc~check_endian check_endian proc~penf_init penf_init proc~penf_init->proc~check_endian program~volatile_doctest~680 volatile_doctest program~volatile_doctest~680->proc~check_endian program~volatile_doctest~326 volatile_doctest program~volatile_doctest~326->proc~check_endian program~volatile_doctest~1078 volatile_doctest program~volatile_doctest~1078->proc~check_endian program~volatile_doctest~105 volatile_doctest program~volatile_doctest~105->proc~check_endian program~volatile_doctest~503 volatile_doctest program~volatile_doctest~503->proc~check_endian program~volatile_doctest~901 volatile_doctest program~volatile_doctest~901->proc~check_endian program~volatile_doctest~1255 volatile_doctest program~volatile_doctest~1255->proc~check_endian proc~initialize initialize proc~initialize->proc~penf_init proc~b64_init b64_init proc~initialize->proc~b64_init proc~initialize~6 initialize proc~initialize~6->proc~penf_init proc~initialize~6->proc~b64_init proc~penf_print penf_print proc~penf_print->proc~penf_init proc~b64_init~3 b64_init proc~b64_init~3->proc~penf_init proc~initialize~2 initialize proc~initialize~2->proc~penf_init proc~initialize~2->proc~b64_init proc~b64_init~4 b64_init proc~b64_init~4->proc~penf_init program~volatile_doctest~108 volatile_doctest program~volatile_doctest~108->proc~penf_init program~volatile_doctest~506 volatile_doctest program~volatile_doctest~506->proc~penf_init program~volatile_doctest~904 volatile_doctest program~volatile_doctest~904->proc~penf_init program~volatile_doctest~1258 volatile_doctest program~volatile_doctest~1258->proc~penf_init proc~b64_init->proc~penf_init proc~b64_init~2 b64_init proc~b64_init~2->proc~penf_init program~volatile_doctest~329 volatile_doctest program~volatile_doctest~329->proc~penf_init program~volatile_doctest~683 volatile_doctest program~volatile_doctest~683->proc~penf_init program~volatile_doctest~1081 volatile_doctest program~volatile_doctest~1081->proc~penf_init program~volatile_doctest~110 volatile_doctest program~volatile_doctest~110->proc~penf_print program~volatile_doctest~1260 volatile_doctest program~volatile_doctest~1260->proc~penf_print program~volatile_doctest~508 volatile_doctest program~volatile_doctest~508->proc~penf_print program~volatile_doctest~906 volatile_doctest program~volatile_doctest~906->proc~penf_print program~volatile_doctest~354 volatile_doctest program~volatile_doctest~354->proc~b64_init program~volatile_doctest~1106 volatile_doctest program~volatile_doctest~1106->proc~b64_init program~volatile_doctest~685 volatile_doctest program~volatile_doctest~685->proc~penf_print program~volatile_doctest~331 volatile_doctest program~volatile_doctest~331->proc~penf_print program~volatile_doctest~1083 volatile_doctest program~volatile_doctest~1083->proc~penf_print program~volatile_doctest~531 volatile_doctest program~volatile_doctest~531->proc~b64_init program~volatile_doctest~929 volatile_doctest program~volatile_doctest~929->proc~b64_init

Contents

Source Code


Source Code

   subroutine check_endian()
   !< Check the type of bit ordering (big or little endian) of the running architecture.
   !<
   !> @note The result is stored into the *endian* global variable.
   !<
   !<```fortran
   !< use penf
   !< call check_endian
   !< print *, endian
   !<```
   !=> 1 <<<
   if (is_little_endian()) then
      endian = endianL
   else
      endian = endianB
   endif
   contains
      pure function is_little_endian() result(is_little)
      !< Check if the type of the bit ordering of the running architecture is little endian.
      logical      :: is_little !< Logical output: true is the running architecture uses little endian ordering, false otherwise.
      integer(I1P) :: int1(1:4) !< One byte integer array for casting 4 bytes integer.

      int1 = transfer(1_I4P, int1)
      is_little = (int1(1)==1_I1P)
      endfunction is_little_endian
   endsubroutine check_endian