NCEPLIBS-g2  3.4.5
pngunpack.f
Go to the documentation of this file.
1 
6 
20 
21  subroutine pngunpack(cpack,len,idrstmpl,ndpts,fld)
22 
23  character(len=1),intent(in) :: cpack(len)
24  integer,intent(in) :: ndpts,len
25  integer,intent(in) :: idrstmpl(*)
26  real,intent(out) :: fld(ndpts)
27 
28  integer :: ifld(ndpts)
29  character(len=1),allocatable :: ctemp(:)
30  integer(4) :: ieee
31  real :: ref,bscale,dscale
32  integer :: dec_png,width,height
33 
34  ieee = idrstmpl(1)
35  call rdieee(ieee,ref,1)
36  bscale = 2.0**real(idrstmpl(2))
37  dscale = 10.0**real(-idrstmpl(3))
38  nbits = idrstmpl(4)
39  itype = idrstmpl(5)
40 !
41 ! if nbits equals 0, we have a constant field where the reference value
42 ! is the data value at each gridpoint
43 !
44  if (nbits.ne.0) then
45  allocate(ctemp(ndpts*4))
46  iret=dec_png(cpack,width,height,ctemp)
47  call g2_gbytesc(ctemp,ifld,0,nbits,0,ndpts)
48  deallocate(ctemp)
49  do j=1,ndpts
50  fld(j)=((real(ifld(j))*bscale)+ref)*dscale
51  enddo
52  else
53  do j=1,ndpts
54  fld(j)=ref
55  enddo
56  endif
57 
58 
59  return
60  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
pngunpack
subroutine pngunpack(cpack, len, idrstmpl, ndpts, fld)
This subroutine unpacks a data field that was packed into a PNG image format using info from the GRIB...
Definition: pngunpack.f:22
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