bswap_int32 Function

private pure function bswap_int32(x) result(y)

Reverse the four bytes of an int32.

Written with ibits/ishft using only non-negative shift counts. ishft with a negative count is avoided because the compilers this project targets have historically disagreed about it, and shiftr is Fortran 2008 which is more than this needs to assume.

Arguments

Type IntentOptional Attributes Name
integer(kind=int32), intent(in) :: x

Return Value integer(kind=int32)


Called by

proc~~bswap_int32~~CalledByGraph proc~bswap_int32 bswap_int32 proc~read_header read_header proc~read_header->proc~bswap_int32 proc~read_int32_array read_int32_array proc~read_int32_array->proc~bswap_int32 proc~read_record_header read_record_header proc~read_int32_array->proc~read_record_header proc~read_real_sp_array read_real_sp_array proc~read_real_sp_array->proc~bswap_int32 proc~read_real_sp_array->proc~read_record_header proc~read_record_header->proc~bswap_int32 interface~read_array read_array interface~read_array->proc~read_int32_array interface~read_array->proc~read_real_sp_array proc~read_char_record read_char_record interface~read_array->proc~read_char_record proc~read_int64_array read_int64_array interface~read_array->proc~read_int64_array proc~read_real_dp_array read_real_dp_array interface~read_array->proc~read_real_dp_array proc~read_char_record->proc~read_record_header proc~read_int64_array->proc~read_record_header proc~read_real_dp_array->proc~read_record_header proc~soa_read_prologue soa_read_prologue proc~soa_read_prologue->proc~read_header proc~soa_read_prologue->interface~read_array proc~particle_soa_deserialize particle_soa_t%particle_soa_deserialize proc~particle_soa_deserialize->proc~soa_read_prologue interface~soa_read_field soa_read_field proc~particle_soa_deserialize->interface~soa_read_field proc~soa_read_int32_field soa_read_int32_field proc~soa_read_int32_field->interface~read_array proc~soa_read_int64_field soa_read_int64_field proc~soa_read_int64_field->interface~read_array proc~soa_read_logical_field soa_read_logical_field proc~soa_read_logical_field->interface~read_array proc~soa_read_real_dp_field soa_read_real_dp_field proc~soa_read_real_dp_field->interface~read_array proc~soa_read_real_sp_field soa_read_real_sp_field proc~soa_read_real_sp_field->interface~read_array interface~soa_read_field->proc~soa_read_int32_field interface~soa_read_field->proc~soa_read_int64_field interface~soa_read_field->proc~soa_read_logical_field interface~soa_read_field->proc~soa_read_real_dp_field interface~soa_read_field->proc~soa_read_real_sp_field

Source Code

   pure function bswap_int32(x) result(y)
      !! Reverse the four bytes of an `int32`.
      !!
      !! Written with `ibits`/`ishft` using only non-negative shift counts.
      !! `ishft` with a negative count is avoided because the compilers this
      !! project targets have historically disagreed about it, and `shiftr` is
      !! Fortran 2008 which is more than this needs to assume.
      integer(int32), intent(in) :: x
      integer(int32) :: y

      y = ior(ior(ishft(ibits(x, 0, BITS_PER_BYTE), 24), ishft(ibits(x, 8, BITS_PER_BYTE), 16)), &
              ior(ishft(ibits(x, 16, BITS_PER_BYTE), 8), ibits(x, 24, BITS_PER_BYTE)))
   end function bswap_int32