NCEPLIBS-g2  3.4.7
simunpack.F90
Go to the documentation of this file.
1 
5 
18 subroutine simunpack(cpack, len, idrstmpl, ndpts, fld)
19  implicit none
20 
21  character(len=1), intent(in) :: cpack(len)
22  integer, intent(in) :: ndpts, len
23  integer, intent(in) :: idrstmpl(*)
24  real, intent(out) :: fld(ndpts)
25 
26  integer :: ifld(ndpts)
27  integer(4) :: ieee
28  real :: ref, bscale, dscale
29  integer :: itype, j, nbits
30 
31  ieee = idrstmpl(1)
32  call rdieee(ieee, ref, 1)
33  bscale = 2.0**real(idrstmpl(2))
34  dscale = 10.0**real(-idrstmpl(3))
35  nbits = idrstmpl(4)
36  itype = idrstmpl(5)
37 
38  ! If nbits equals 0, we have a constant field where the reference value
39  ! is the data value at each gridpoint.
40  if (nbits .ne. 0) then
41  call g2_gbytesc(cpack, ifld, 0, nbits, 0, ndpts)
42  do j=1, ndpts
43  fld(j) = ((real(ifld(j)) * bscale) + ref) * dscale
44  enddo
45  else
46  !print *, 'unpack ref ', ref
47  !print *, 'unpack ndpts ', ndpts
48  do j=1, ndpts
49  fld(j) = ref
50  enddo
51  endif
52 end subroutine simunpack
subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked a...
Definition: g2_gbytesc.F90:63
subroutine rdieee(rieee, a, num)
Copy array of 32-bit IEEE floating point values to local floating point representation.
Definition: rdieee.F90:16
subroutine simunpack(cpack, len, idrstmpl, ndpts, fld)
This subroutine unpacks a data field that was packed using a simple packing algorithm as defined in t...
Definition: simunpack.F90:19