check_endian Subroutine

public subroutine check_endian()

Arguments

None

Description

Check the type of bit ordering (big or little endian) of the running architecture.

Calls

proc~~check_endian~~CallsGraph proc~check_endian check_endian none~is_little_endian is_little_endian proc~check_endian->none~is_little_endian
Help

Called By

proc~~check_endian~~CalledByGraph proc~check_endian check_endian proc~penf_init penf_init proc~penf_init->proc~check_endian
Help

Functions

pure function is_little_endian() result(is_little)

Arguments

None

Return Value logical

Logical output: true is the running architecture uses little endian ordering, false otherwise.

Description

Check if the type of the bit ordering of the running architecture is little endian.


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.
  !---------------------------------------------------------------------------------------------------------------------------------

  !---------------------------------------------------------------------------------------------------------------------------------
  if (is_little_endian()) then
    endian = endianL
  else
    endian = endianB
  endif
  return
  !---------------------------------------------------------------------------------------------------------------------------------
  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)
    return
    !-------------------------------------------------------------------------------------------------------------------------------
    endfunction is_little_endian
  endsubroutine check_endian