Read a real(dp) array record. See read_real_sp_array for the way
the foreign endian path is kept away from the native one.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer(kind=default_int), | intent(in) | :: | unit | |||
| real(kind=dp), | intent(out), | allocatable | :: | values(:) | ||
| logical, | intent(in) | :: | swapped | |||
| type(error_t), | intent(inout) | :: | err |
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| integer(kind=int64), | private, | allocatable | :: | bits(:) | |||
| integer(kind=default_int), | private | :: | code | ||||
| integer(kind=int64), | private | :: | count | ||||
| integer(kind=int64), | private | :: | i | ||||
| integer(kind=default_int), | private | :: | ios | ||||
| logical, | private | :: | ok |
subroutine read_real_dp_array(unit, values, swapped, err) !! Read a `real(dp)` array record. See `read_real_sp_array` for the way !! the foreign endian path is kept away from the native one. integer(default_int), intent(in) :: unit real(dp), allocatable, intent(out) :: values(:) logical, intent(in) :: swapped type(error_t), intent(inout) :: err integer(default_int) :: ios, code logical :: ok integer(int64) :: count, i integer(int64), allocatable :: bits(:) call read_record_header(unit, PIC_TAG_REAL_DP, swapped, count, ok, err) if (.not. ok) then code = err%get_code() call err%wrap(code, "failed to read real(dp) record") allocate (values(0)) return end if allocate (values(count)) if (count > 0_int64) then if (swapped) then allocate (bits(count)) read (unit, iostat=ios) bits else read (unit, iostat=ios) values end if call check_io(ios, "short read on real(dp) payload", err) if (swapped .and. ios == 0) then do i = 1_int64, count values(i) = bits_to_real_dp(bswap_int64(bits(i))) end do end if end if end subroutine read_real_dp_array