NCEPLIBS-g2  3.4.7
gf_unpack7.F90
Go to the documentation of this file.
1 
6 
40 subroutine gf_unpack7(cgrib, lcgrib, iofst, igdsnum, igdstmpl, &
41  idrsnum, idrstmpl, ndpts, fld, ierr)
42  implicit none
43 
44  character(len = 1), intent(in) :: cgrib(lcgrib)
45  integer, intent(in) :: lcgrib, ndpts, igdsnum, idrsnum
46  integer, intent(inout) :: iofst
47  integer, pointer, dimension(:) :: igdstmpl, idrstmpl
48  integer, intent(out) :: ierr
49  real, pointer, dimension(:) :: fld
50  integer :: ier, ipos, istat, lensec, ieee
51 
52  ierr = 0
53  nullify(fld)
54 
55  call g2_gbytec(cgrib, lensec, iofst, 32) ! Get Length of Section
56  iofst = iofst + 32
57  iofst = iofst + 8 ! skip section number
58 
59  ipos = (iofst/8) + 1
60  istat = 0
61  allocate(fld(ndpts), stat = istat)
62  if (istat.ne.0) then
63  ierr = 6
64  return
65  endif
66 
67  if (idrsnum .eq. 0) then
68  call simunpack(cgrib(ipos), lensec-5, idrstmpl, ndpts, fld)
69  elseif (idrsnum.eq.2.or.idrsnum.eq.3) then
70  call comunpack(cgrib(ipos), lensec-5, lensec, idrsnum, idrstmpl, ndpts, fld, ier)
71  if (ier .ne. 0) then
72  ierr = 7
73  return
74  endif
75  elseif (idrsnum .eq. 50) then ! Spectral simple
76  call simunpack(cgrib(ipos), lensec-5, idrstmpl, ndpts-1, fld(2))
77  ieee = idrstmpl(5)
78  call rdieee(ieee, fld(1), 1)
79  elseif (idrsnum .eq. 51) then ! Spectral complex
80  if (igdsnum.ge.50.AND.igdsnum.le.53) then
81  call specunpack(cgrib(ipos), lensec-5, idrstmpl, ndpts, &
82  igdstmpl(1), igdstmpl(2), igdstmpl(3), fld)
83  else
84  print *, 'gf_unpack7: Cannot use GDT 3.', igdsnum, ' to unpack Data Section 5.51.'
85  ierr = 5
86  nullify(fld)
87  return
88  endif
89  elseif (idrsnum .eq. 40 .OR. idrsnum .eq. 40000) then
90  call jpcunpack(cgrib(ipos), lensec-5, idrstmpl, ndpts, fld)
91  elseif (idrsnum .eq. 41 .OR. idrsnum .eq. 40010) then
92  call pngunpack(cgrib(ipos), lensec-5, idrstmpl, ndpts, fld)
93  else
94  print *, 'gf_unpack7: Data Representation Template ', idrsnum, ' not yet implemented.'
95  ierr = 4
96  nullify(fld)
97  return
98  endif
99 
100  iofst = iofst + (8 * lensec)
101 
102 end subroutine gf_unpack7
subroutine comunpack(cpack, len, lensec, idrsnum, idrstmpl, ndpts, fld, ier)
Unpack a data field that was packed using a complex packing algorithm as defined in the GRIB2 documen...
Definition: comunpack.f:33
subroutine g2_gbytec(in, iout, iskip, nbits)
Extract arbitrary size values from a packed bit string, right justifying each value in the unpacked a...
Definition: g2_gbytesc.F90:20
subroutine gf_unpack7(cgrib, lcgrib, iofst, igdsnum, igdstmpl, idrsnum, idrstmpl, ndpts, fld, ierr)
Unpack Section 7 (Data Section) of a GRIB2 message.
Definition: gf_unpack7.F90:42
subroutine jpcunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field from a JPEG2000 code stream.
Definition: jpcunpack.F90:20
subroutine pngunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field packed into a PNG image format.
Definition: pngunpack.F90:20
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
subroutine specunpack(cpack, len, idrstmpl, ndpts, JJ, KK, MM, fld)
This subroutine unpacks a spectral data field that was packed using the complex packing algorithm for...
Definition: specunpack.F90:23