NCEPLIBS-g2  3.4.5
simunpack.f
Go to the documentation of this file.
1 
5 
19 
20  subroutine simunpack(cpack,len,idrstmpl,ndpts,fld)
21 
22  character(len=1),intent(in) :: cpack(len)
23  integer,intent(in) :: ndpts,len
24  integer,intent(in) :: idrstmpl(*)
25  real,intent(out) :: fld(ndpts)
26 
27  integer :: ifld(ndpts)
28  integer(4) :: ieee
29  real :: ref,bscale,dscale
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 !
41  if (nbits.ne.0) then
42  call g2_gbytesc(cpack,ifld,0,nbits,0,ndpts)
43  do j=1,ndpts
44  fld(j)=((real(ifld(j))*bscale)+ref)*dscale
45  enddo
46  else
47  !print *,'unpack ref ',ref
48  !print *,'unpack ndpts ',ndpts
49  do j=1,ndpts
50  fld(j)=ref
51  enddo
52  endif
53 
54 
55  return
56  end
rdieee
subroutine rdieee(rieee, a, num)
This subroutine reads a list of real values in 32-bit IEEE floating point format.
Definition: rdieee.f:16
g2_gbytesc
subroutine g2_gbytesc(IN, IOUT, ISKIP, NBYTE, NSKIP, N)
This subrountine is to extract arbitrary size values from a packed bit string, right justifying each ...
Definition: g2_gbytesc.f:60
simunpack
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.f:21