52subroutine gb_info(cgrib, lcgrib, listsec0, listsec1, &
53 numfields, numlocal, maxlocal, ierr)
57 character(len = 1),
intent(in) :: cgrib(lcgrib)
58 integer,
intent(in) :: lcgrib
59 integer,
intent(out) :: listsec0(3), listsec1(13)
60 integer,
intent(out) :: numlocal, numfields, maxlocal, ierr
62 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
63 character(len = 4) :: ctemp
64 integer,
parameter :: zero = 0, one = 1
65 integer,
parameter :: mapsec1len = 13
66 integer,
parameter :: mapsec1(mapsec1len) = (/ 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1 /)
67 integer :: iofst, istart
68 integer :: nbits, lensec1, lensec0, lensec, lenposs, lengrib, j
69 integer (kind = 8) :: lengrib8
70 integer :: i, ipos, isecnum
73 subroutine g2_gbytec(in, iout, iskip, nbits)
74 character*1,
intent(in) :: in(*)
75 integer,
intent(inout) :: iout(*)
76 integer,
intent(in) :: iskip, nbits
79 character*1,
intent(in) :: in(*)
80 integer,
intent(inout) :: siout
81 integer,
intent(in) :: iskip, nbits
84 character*1,
intent(in) :: in(*)
85 integer (kind = 8),
intent(inout) :: siout
86 integer,
intent(in) :: iskip, nbits
87 integer (kind = 8) :: iout(1)
92 write(
g2_log_msg, *)
'gb_info: lcgrib ', lcgrib
104 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j+3)
105 if (ctemp .eq. grib )
then
110 if (istart .eq. 0)
then
111 print *,
'gb_info: Beginning characters GRIB not found.'
117 iofst = 8 * (istart + 5)
118 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
120 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
125 write(
g2_log_msg, *)
'before getting len: iofst/8 ', iofst/8
132 lengrib = int(lengrib8, kind(4))
135 listsec0(3) = lengrib
137 ipos = istart + lensec0
140 if (listsec0(2) .ne. 2)
then
141 print *,
'gb_info: can only decode GRIB edition 2.'
151 if (isecnum .ne. 1)
then
152 print *,
'gb_info: Could not find section 1.'
161 nbits = mapsec1(i) * 8
162 call g2_gbytec(cgrib, listsec1(i), iofst, nbits)
163 iofst = iofst + nbits
165 ipos = ipos + lensec1
170 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // cgrib(ipos + 3)
171 if (ctemp .eq. c7777 )
then
173 if (ipos .ne. (istart + lengrib))
then
174 print *,
'gb_info: "7777" found, but not where expected.'
180 iofst = (ipos - 1) * 8
186 if (ipos .gt. (istart + lengrib))
then
187 print *,
'gb_info: "7777" not found at end of GRIB message.'
191 if (isecnum .ge. 2 .AND. isecnum .le. 7)
then
192 if (isecnum .eq. 2)
then
194 numlocal = numlocal + 1
196 if (lenposs .gt. maxlocal) maxlocal = lenposs
197 elseif (isecnum .eq. 4)
then
199 numfields = numfields + 1
202 print *,
'gb_info: Invalid section number found in GRIB message: ', isecnum
282subroutine gribinfo(cgrib, lcgrib, listsec0, listsec1, &
283 numlocal, numfields, maxvals, ierr)
286 character(len = 1),
intent(in) :: cgrib(lcgrib)
287 integer,
intent(in) :: lcgrib
288 integer,
intent(out) :: listsec0(3), listsec1(13), maxvals(7)
289 integer,
intent(out) :: numlocal, numfields, ierr
291 integer :: i, ipos, isecnum, j, lengrib, lenposs, lensec, lensec0, lensec1
292 integer :: maxcoordlist, maxdeflist, maxdrstmpl, maxgridpts, maxpdstmpl, maxgdstmpl
293 integer :: maxsec2len, nbits, nbyte, ngdpts, numcoord
294 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
295 character(len = 4) :: ctemp
296 integer,
parameter :: zero = 0, one = 1
297 integer,
parameter :: mapsec1len = 13
298 integer,
parameter :: mapsec1(mapsec1len) = (/ 2, 2, 1, 1, 1, 2, 1, 1, &
300 integer iofst, istart
301 integer (kind = 8) :: lengrib8
317 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j + 3)
318 if (ctemp .eq. grib)
then
323 if (istart .eq. 0)
then
324 print *,
'gribinfo: Beginning characters GRIB not found.'
330 iofst = 8 * (istart + 5)
331 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
333 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
339 lengrib = int(lengrib8, kind(4))
342 listsec0(3) = lengrib
344 ipos = istart + lensec0
347 if (listsec0(2) .ne. 2)
then
348 print *,
'gribinfo: can only decode GRIB edition 2.'
358 if (isecnum .ne. 1)
then
359 print *,
'gribinfo: Could not find section 1.'
368 nbits = mapsec1(i) * 8
369 call g2_gbytec(cgrib, listsec1(i), iofst, nbits)
370 iofst = iofst + nbits
372 ipos = ipos + lensec1
378 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // &
380 if (ctemp .eq. c7777)
then
382 if (ipos .ne. (istart + lengrib))
then
383 print *,
'gribinfo: "7777" found, but not where expected.'
389 iofst = (ipos - 1) * 8
395 if (ipos .gt. (istart + lengrib))
then
396 print *,
'gribinfo: "7777" not found at end of GRIB message.'
400 if (isecnum .eq. 2)
then
403 numlocal = numlocal + 1
405 if (lenposs .gt. maxsec2len) maxsec2len = lenposs
406 elseif (isecnum .eq. 3)
then
412 if (ngdpts .gt. maxgridpts) maxgridpts = ngdpts
413 lenposs = lensec - 14
414 if (lenposs .gt. maxgdstmpl) maxgdstmpl = lenposs
415 if (nbyte .ne. 0)
then
416 lenposs = lenposs / nbyte
417 if (lenposs .gt. maxdeflist) maxdeflist = lenposs
419 elseif (isecnum .eq. 4)
then
420 numfields = numfields + 1
423 if (numcoord .ne. 0)
then
424 if (numcoord .gt. maxcoordlist) maxcoordlist = numcoord
427 if (lenposs.gt.maxpdstmpl) maxpdstmpl = lenposs
428 elseif (isecnum .eq. 5)
then
430 if (lenposs .gt. maxdrstmpl) maxdrstmpl = lenposs
434 maxvals(1) = maxsec2len
435 maxvals(2) = maxgdstmpl
436 maxvals(3) = maxdeflist
437 maxvals(4) = maxpdstmpl
438 maxvals(5) = maxcoordlist
439 maxvals(6) = maxdrstmpl
440 maxvals(7) = maxgridpts
543subroutine getfield(cgrib, lcgrib, ifldnum, igds, igdstmpl, &
544 igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, &
545 coordlist, numcoord, ndpts, idrsnum, idrstmpl, idrslen, &
546 ibmap, bmap, fld, ierr)
549 character(len = 1),
intent(in) :: cgrib(lcgrib)
550 integer,
intent(in) :: lcgrib, ifldnum
551 integer,
intent(out) :: igds(*), igdstmpl(*), ideflist(*)
552 integer,
intent(out) :: ipdsnum, ipdstmpl(*)
553 integer,
intent(out) :: idrsnum, idrstmpl(*)
554 integer,
intent(out) :: ndpts, ibmap, idefnum, numcoord
555 integer,
intent(out) :: igdslen, ipdslen, idrslen
556 real,
intent(out) :: fld(*), coordlist(*)
557 logical*1,
intent(out) :: bmap(*)
558 integer,
intent(out) :: ierr
560 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
561 character(len = 4) :: ctemp
562 integer :: listsec0(2)
563 integer :: iofst, istart
564 real (kind = 4) :: ieee(1)
565 logical :: have3, have4, have5, have6, have7
566 integer (kind = 8) :: lengrib8
567 integer :: numfld, j, lengrib, lensec0, ipos
568 integer :: lensec, isecnum, jerr, ier, numlocal
580 if (ifldnum .le. 0)
then
581 print *,
'getfield: Request for field number ' &
590 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j + 3)
591 if (ctemp .eq. grib)
then
596 if (istart .eq. 0)
then
597 print *,
'getfield: Beginning characters GRIB not found.'
603 iofst = 8 * (istart + 5)
604 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
606 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
612 lengrib = int(lengrib8, kind(4))
616 ipos = istart + lensec0
619 if (listsec0(2) .ne. 2)
then
620 print *,
'getfield: can only decode GRIB edition 2.'
630 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // &
632 if (ctemp .eq. c7777)
then
635 if (ipos.ne.(istart + lengrib))
then
636 print *,
'getfield: "7777" found, but not ' &
644 iofst = (ipos - 1) * 8
653 if (isecnum .eq. 3)
then
655 call unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
656 igdslen, ideflist, idefnum, jerr)
657 if (jerr .eq. 0)
then
667 if (isecnum .eq. 4)
then
669 if (numfld .eq. ifldnum)
then
671 call unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, &
672 ipdslen, coordlist, numcoord, jerr)
673 if (jerr .eq. 0)
then
684 if ((isecnum .eq. 5) .and. (numfld .eq. ifldnum))
then
686 call unpack5(cgrib, lcgrib, iofst, ndpts, idrsnum, &
687 idrstmpl, idrslen, jerr)
688 if (jerr .eq. 0)
then
698 if (isecnum .eq. 6)
then
700 call unpack6(cgrib, lcgrib, iofst, igds(2), ibmap, bmap, &
702 if (jerr .eq. 0)
then
712 if ((isecnum .eq. 7) .and. (numfld .eq. ifldnum))
then
713 if (idrsnum .eq. 0)
then
714 call simunpack(cgrib(ipos + 5), lensec - 6, idrstmpl, &
717 elseif (idrsnum .eq. 2 .or. idrsnum .eq. 3)
then
718 call comunpack(cgrib(ipos + 5), lensec - 6, lensec, &
719 idrsnum,idrstmpl, ndpts, fld, ier)
725 elseif (idrsnum .eq. 50)
then
726 call simunpack(cgrib(ipos + 5), lensec - 6, idrstmpl, &
728 ieee = transfer(idrstmpl(5), ieee, 1)
729 call rdieee(ieee, fld(1), 1)
731 elseif (idrsnum .eq. 40 .or. idrsnum .eq. 40000)
then
732 call jpcunpack(cgrib(ipos + 5), lensec - 5, idrstmpl, &
735 elseif (idrsnum .eq. 41 .or. idrsnum .eq. 40010)
then
736 call pngunpack(cgrib(ipos + 5), lensec - 5, idrstmpl, &
740 elseif (idrsnum .eq. 42)
then
741 call aecunpack(cgrib(ipos + 5), lensec - 5, idrstmpl, &
746 print *,
'getfield: Data Representation Template ', &
747 idrsnum,
' not yet implemented.'
756 if (ipos .gt. (istart + lengrib))
then
757 print *,
'getfield: "7777" not found at end' &
763 if (have3 .and. have4 .and. have5 .and. have6 .and. have7) &
770 print *,
'getfield: GRIB message contained ', numlocal, &
772 print *,
'getfield: The request was for the ', ifldnum, &
817subroutine unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
818 mapgridlen, ideflist, idefnum, ierr)
822 character(len = 1),
intent(in) :: cgrib(lcgrib)
823 integer,
intent(in) :: lcgrib
824 integer,
intent(inout) :: iofst
825 integer,
intent(out) :: igds(*), igdstmpl(*), ideflist(*)
826 integer,
intent(out) :: ierr, idefnum
828 integer,
allocatable :: mapgrid(:)
829 integer :: mapgridlen, ibyttem
831 integer :: lensec, iret, i, nbits, isign, newmapgridlen
849 if (igds(1) .eq. 0)
then
850 allocate(mapgrid(lensec))
854 if (iret .ne. 0)
then
868 nbits = iabs(mapgrid(i)) * 8
869 if (mapgrid(i) .ge. 0)
then
870 call g2_gbytec1(cgrib, igdstmpl(i), iofst, nbits)
873 call g2_gbytec1(cgrib, igdstmpl(i), iofst + 1, nbits-1)
874 if (isign .eq. 1) igdstmpl(i) = -igdstmpl(i)
876 iofst = iofst + nbits
877 ibyttem = ibyttem + iabs(mapgrid(i))
887 do i = mapgridlen + 1, newmapgridlen
888 nbits = iabs(mapgrid(i)) * 8
889 if (mapgrid(i) .ge. 0)
then
890 call g2_gbytec1(cgrib, igdstmpl(i), iofst, nbits)
893 call g2_gbytec1(cgrib, igdstmpl(i), iofst + 1, nbits - &
895 if (isign .eq. 1) igdstmpl(i) = -igdstmpl(i)
897 iofst = iofst + nbits
898 ibyttem = ibyttem + iabs(mapgrid(i))
900 mapgridlen = newmapgridlen
905 if (igds(3) .ne. 0)
then
907 idefnum = (lensec - 14 - ibyttem) / igds(3)
908 call g2_gbytesc(cgrib, ideflist, iofst, nbits, 0, idefnum)
909 iofst = iofst + (nbits * idefnum)
913 if (
allocated(mapgrid))
deallocate(mapgrid)
942subroutine unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, &
943 mappdslen, coordlist, numcoord, ierr)
947 character(len = 1),
intent(in) :: cgrib(lcgrib)
948 integer,
intent(in) :: lcgrib
949 integer,
intent(inout) :: iofst
950 real,
intent(out) :: coordlist(*)
951 integer,
intent(out) :: ipdsnum, ipdstmpl(*)
952 integer,
intent(out) :: ierr, numcoord
954 real(4),
allocatable :: coordieee(:)
955 integer,
allocatable :: mappds(:)
958 integer :: lensec, iret, i, nbits, isign, newmappdslen
965 allocate(mappds(lensec))
983 nbits = iabs(mappds(i)) * 8
984 if (mappds(i) .ge. 0)
then
985 call g2_gbytec1(cgrib, ipdstmpl(i), iofst, nbits)
988 call g2_gbytec1(cgrib, ipdstmpl(i), iofst + 1, nbits-1)
989 if (isign .eq. 1) ipdstmpl(i) = -ipdstmpl(i)
991 iofst = iofst + nbits
1001 do i = mappdslen + 1, newmappdslen
1002 nbits = iabs(mappds(i)) * 8
1003 if (mappds(i) .ge. 0)
then
1004 call g2_gbytec1(cgrib, ipdstmpl(i), iofst, nbits)
1007 call g2_gbytec1(cgrib, ipdstmpl(i), iofst + 1, nbits-1)
1008 if (isign .eq. 1) ipdstmpl(i) = -ipdstmpl(i)
1010 iofst = iofst + nbits
1012 mappdslen = newmappdslen
1017 if (numcoord .ne. 0)
then
1018 allocate (coordieee(numcoord))
1019 call g2_gbytescr(cgrib, coordieee, iofst, 32, 0, numcoord)
1020 call rdieee(coordieee, coordlist, numcoord)
1021 deallocate (coordieee)
1022 iofst = iofst + (32*numcoord)
1024 if (
allocated(mappds))
deallocate(mappds)
1049subroutine unpack5(cgrib, lcgrib, iofst, ndpts, idrsnum, &
1050 idrstmpl, mapdrslen, ierr)
1054 character(len = 1),
intent(in) :: cgrib(lcgrib)
1055 integer,
intent(in) :: lcgrib
1056 integer,
intent(inout) :: iofst
1057 integer,
intent(out) :: ndpts, idrsnum, idrstmpl(*)
1058 integer,
intent(out) :: ierr
1061 integer,
allocatable :: mapdrs(:)
1062 integer :: mapdrslen
1064 integer :: lensec, i, nbits, isign, newmapdrslen, iret
1071 allocate(mapdrs(lensec))
1089 nbits = iabs(mapdrs(i))*8
1090 if (mapdrs(i).ge.0)
then
1091 call g2_gbytec1(cgrib, idrstmpl(i), iofst, nbits)
1094 call g2_gbytec1(cgrib, idrstmpl(i), iofst + 1, nbits-1)
1095 if (isign.eq.1) idrstmpl(i) = -idrstmpl(i)
1097 iofst = iofst + nbits
1106 do i = mapdrslen + 1, newmapdrslen
1107 nbits = iabs(mapdrs(i)) * 8
1108 if (mapdrs(i) .ge. 0)
then
1109 call g2_gbytec1(cgrib, idrstmpl(i), iofst, nbits)
1112 call g2_gbytec1(cgrib, idrstmpl(i), iofst + 1, nbits - 1)
1113 if (isign .eq. 1) idrstmpl(i) = -idrstmpl(i)
1115 iofst = iofst + nbits
1117 mapdrslen = newmapdrslen
1119 if (
allocated(mapdrs))
deallocate(mapdrs)
1143subroutine unpack6(cgrib, lcgrib, iofst, ngpts, ibmap, bmap, ierr)
1146 character(len = 1),
intent(in) :: cgrib(lcgrib)
1147 integer,
intent(in) :: lcgrib, ngpts
1148 integer,
intent(inout) :: iofst
1149 integer,
intent(out) :: ibmap
1150 integer,
intent(out) :: ierr
1151 logical*1,
intent(out) :: bmap(ngpts)
1153 integer :: intbmap(ngpts)
1164 if (ibmap.eq.0)
then
1165 call g2_gbytesc(cgrib, intbmap, iofst, 1, 0, ngpts)
1166 iofst = iofst + ngpts
1169 if (intbmap(j).eq.0) bmap(j) = .false.
1171 elseif (ibmap.eq.254)
then
1173 elseif (ibmap.eq.255)
then
1174 bmap(1:ngpts) = .true.
1176 print *,
'unpack6: Predefined bitmap ', ibmap, &
1197subroutine getdim(csec3, lcsec3, width, height, iscan)
1200 character(len=1),
intent(in) :: csec3(*)
1201 integer,
intent(in) :: lcsec3
1202 integer,
intent(out) :: width,height,iscan
1204 integer,
pointer,
dimension(:) :: igdstmpl,list_opt
1206 integer iofst, igdtlen, num_opt, jerr
1209 subroutine gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
1210 mapgridlen, ideflist, idefnum, ierr)
1211 character(len = 1),
intent(in) :: cgrib(lcgrib)
1212 integer,
intent(in) :: lcgrib
1213 integer,
intent(inout) :: iofst
1214 integer,
pointer,
dimension(:) :: igdstmpl, ideflist
1215 integer,
intent(out) :: igds(5)
1216 integer,
intent(out) :: ierr, idefnum
1220 nullify(igdstmpl, list_opt)
1223 call gf_unpack3(csec3, lcsec3, iofst, igds, igdstmpl, &
1224 igdtlen, list_opt, num_opt, jerr)
1226 selectcase( igds(5) )
1229 height = igdstmpl(9)
1230 iscan = igdstmpl(19)
1233 height = igdstmpl(9)
1234 iscan = igdstmpl(16)
1237 height = igdstmpl(9)
1238 iscan = igdstmpl(18)
1241 height = igdstmpl(9)
1242 iscan = igdstmpl(18)
1245 height = igdstmpl(9)
1246 iscan = igdstmpl(19)
1249 height = igdstmpl(9)
1250 iscan = igdstmpl(17)
1253 height = igdstmpl(9)
1254 iscan = igdstmpl(16)
1265 if (
associated(igdstmpl))
deallocate(igdstmpl)
1266 if (
associated(list_opt))
deallocate(list_opt)
1298subroutine getlocal(cgrib, lcgrib, localnum, csec2, lcsec2, ierr)
1301 character(len = 1),
intent(in) :: cgrib(lcgrib)
1302 integer,
intent(in) :: lcgrib, localnum
1303 character(len = 1),
intent(out) :: csec2(*)
1304 integer,
intent(out) :: lcsec2, ierr
1306 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
1307 character(len = 4) :: ctemp
1308 integer :: listsec0(2)
1309 integer iofst, istart, numlocal
1310 integer :: lengrib, lensec, lensec0, j, ipos, isecnum
1316 if (localnum .le. 0)
then
1317 print *,
'getlocal: Request for local section must be positive.'
1325 ctemp = cgrib(j)//cgrib(j+1)//cgrib(j+2)//cgrib(j+3)
1326 if (ctemp .eq. grib)
then
1331 if (istart .eq. 0)
then
1332 print *,
'getlocal: Beginning characters GRIB not found.'
1338 iofst = 8 * (istart + 5)
1339 call g2_gbytec(cgrib, listsec0(1), iofst, 8)
1341 call g2_gbytec(cgrib, listsec0(2), iofst, 8)
1347 ipos = istart + lensec0
1350 if (listsec0(2) .ne. 2)
then
1351 print *,
'getlocal: can only decode GRIB edition 2.'
1361 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // cgrib(ipos + 3)
1362 if (ctemp .eq. c7777)
then
1366 if (ipos .ne. (istart + lengrib))
then
1367 print *,
'getlocal: "7777" found, but not where expected.'
1375 iofst = (ipos - 1) * 8
1383 if (isecnum .eq. 2)
then
1384 numlocal = numlocal + 1
1385 if (numlocal.eq.localnum)
then
1387 csec2(1:lcsec2) = cgrib(ipos + 5:ipos + lensec - 1)
1394 ipos = ipos + lensec
1395 if (ipos .gt. (istart + lengrib))
then
1396 print *,
'getlocal: "7777" not found at end of GRIB message.'
1404 print *,
'getlocal: GRIB message contained ', numlocal,
' local sections.'
1405 print *,
'getlocal: The request was for the ', localnum,
' occurrence.'
1427 character(len = 1),
intent(in) :: csec3(*)
1428 integer,
intent(in) :: lcsec3
1429 integer,
intent(out) :: jj, kk, mm
1431 integer,
pointer,
dimension(:) :: igdstmpl, list_opt
1433 integer iofst, igdtlen, num_opt, jerr
1436 subroutine gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, &
1437 mapgridlen, ideflist, idefnum, ierr)
1438 character(len = 1),
intent(in) :: cgrib(lcgrib)
1439 integer,
intent(in) :: lcgrib
1440 integer,
intent(inout) :: iofst
1441 integer,
pointer,
dimension(:) :: igdstmpl, ideflist
1442 integer,
intent(out) :: igds(5)
1443 integer,
intent(out) :: ierr, idefnum
1447 nullify(igdstmpl, list_opt)
1450 call gf_unpack3(csec3, lcsec3, iofst, igds, igdstmpl, &
1451 igdtlen, list_opt, num_opt, jerr)
1453 selectcase( igds(5) )
1469 if (
associated(igdstmpl))
deallocate(igdstmpl)
1470 if (
associated(list_opt))
deallocate(list_opt)
1535 igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, ierr)
1538 character(len = 1),
intent(in) :: cgrib(lcgrib)
1539 integer,
intent(in) :: lcgrib, ifldnum
1540 integer,
intent(out) :: igds(*), igdstmpl(*), ideflist(*)
1541 integer,
intent(out) :: ipdsnum, ipdstmpl(*)
1542 integer,
intent(out) :: idefnum, numcoord
1543 integer,
intent(out) :: ierr
1544 real,
intent(out) :: coordlist(*)
1546 character(len = 4),
parameter :: grib =
'GRIB', c7777 =
'7777'
1547 character(len = 4) :: ctemp
1548 integer:: listsec0(2)
1549 integer iofst, istart
1550 logical have3, have4
1551 integer :: igdslen, ipdslen, ipos, isecnum, j, jerr, lengrib, lensec, lensec0, numfld
1554 subroutine g2_gbytec1(in, siout, iskip, nbits)
1555 character*1,
intent(in) :: in(*)
1556 integer,
intent(inout) :: siout
1557 integer,
intent(in) :: iskip, nbits
1567 if (ifldnum .le. 0)
then
1568 print *,
'gettemplates: Request for field number must be positive.'
1576 ctemp = cgrib(j) // cgrib(j + 1) // cgrib(j + 2) // cgrib(j + 3)
1577 if (ctemp .eq. grib )
then
1582 if (istart .eq. 0)
then
1583 print *,
'gettemplates: Beginning characters GRIB not found.'
1589 iofst = 8 * (istart + 5)
1590 call g2_gbytec1(cgrib, listsec0(1), iofst, 8)
1592 call g2_gbytec1(cgrib, listsec0(2), iofst, 8)
1598 ipos = istart + lensec0
1601 if (listsec0(2) .ne. 2)
then
1602 print *,
'gettemplates: can only decode GRIB edition 2.'
1612 ctemp = cgrib(ipos) // cgrib(ipos + 1) // cgrib(ipos + 2) // cgrib(ipos + 3)
1613 if (ctemp .eq. c7777 )
then
1616 if (ipos .ne. (istart + lengrib))
then
1617 print *,
'gettemplates: "7777" found, but not where expected.'
1624 iofst = (ipos - 1) * 8
1634 if (isecnum .eq. 3)
then
1636 call unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, igdslen, ideflist, idefnum, jerr)
1637 if (jerr .eq. 0)
then
1647 if (isecnum .eq. 4)
then
1649 if (numfld .eq. ifldnum)
then
1651 call unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, jerr)
1652 if (jerr .eq. 0)
then
1663 ipos = ipos + lensec
1664 if (ipos .gt. (istart + lengrib))
then
1665 print *,
'gettemplates: "7777" not found at end of GRIB message.'
1670 if (have3 .and. have4)
return
1675 print *,
'gettemplates: GRIB message contained ', numfld,
' different fields.'
1676 print *,
'gettemplates: The request was for the ', ifldnum,
' field.'
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...
subroutine aecunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field from a AEC code stream as defined in Data Representation Template 5....
subroutine g2_gbytesc(in, iout, iskip, nbits, nskip, n)
Extract arbitrary size big-endian integer values (up to 32 bits each) from a packed bit string.
subroutine rdieee(rieee, a, num)
Copy array of 32-bit IEEE floating point values to local floating point representation.
subroutine g2_gbytec(in, iout, iskip, nbits)
Extract one arbitrary size big-endian value (up to 32 bits) from a packed bit string into one element...
subroutine g2_gbytec81(in, siout, iskip, nbits)
Extract one arbitrary size big-endian integer value (up to 64 bits) from a packed bit string into a s...
subroutine g2_gbytescr(in, rout, iskip, nbits, nskip, n)
Extract big-endian floating-point values (32 bits each) from a packed bit string.
subroutine g2_gbytec1(in, siout, iskip, nbits)
Extract one arbitrary size big-endian integer value (up to 32 bits) from a packed bit string into a s...
subroutine getfield(cgrib, lcgrib, ifldnum, igds, igdstmpl, igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, ndpts, idrsnum, idrstmpl, idrslen, ibmap, bmap, fld, ierr)
Return the Grid Definition, Product Definition, Bit-map (if applicable), and the unpacked data for a ...
subroutine gb_info(cgrib, lcgrib, listsec0, listsec1, numfields, numlocal, maxlocal, ierr)
Find the number of gridded fields and Local Use Sections in a GRIB2 message.
subroutine gettemplates(cgrib, lcgrib, ifldnum, igds, igdstmpl, igdslen, ideflist, idefnum, ipdsnum, ipdstmpl, ipdslen, coordlist, numcoord, ierr)
Return the Grid Definition and Product Definition for a data field.
subroutine unpack6(cgrib, lcgrib, iofst, ngpts, ibmap, bmap, ierr)
This subroutine unpacks Section 6 (Bit-Map Section) starting at octet 6 of that Section.
subroutine unpack4(cgrib, lcgrib, iofst, ipdsnum, ipdstmpl, mappdslen, coordlist, numcoord, ierr)
This subroutine unpacks Section 4 (Product Definition Section) starting at octet 6 of that Section.
subroutine getlocal(cgrib, lcgrib, localnum, csec2, lcsec2, ierr)
Return the contents of Section 2 (Local Use) from a GRIB2 message.
subroutine unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, mapgridlen, ideflist, idefnum, ierr)
This subroutine unpacks Section 3 (Grid Definition Section) starting at octet 6 of that Section.
subroutine getdim(csec3, lcsec3, width, height, iscan)
Return the dimensions and scanning mode of a grid definition packed in the Grid Definition Section.
subroutine getpoly(csec3, lcsec3, jj, kk, mm)
Return the J, K, and M pentagonal resolution parameters specified in a GRIB2 Grid Definition Section ...
subroutine unpack5(cgrib, lcgrib, iofst, ndpts, idrsnum, idrstmpl, mapdrslen, ierr)
This subroutine unpacks Section 5 (Data Representation Section) starting at octet 6 of that Section.
subroutine gribinfo(cgrib, lcgrib, listsec0, listsec1, numlocal, numfields, maxvals, ierr)
Find the number of Local Use Sections and gridded fields in a GRIB2 message, and the maximum sizes of...
subroutine jpcunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field from a JPEG2000 code stream as defined in Data Representation Template 5....
subroutine pngunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field with PNG, defined in [Data Representation Template 5.40](https://www....
subroutine simunpack(cpack, len, idrstmpl, ndpts, fld)
Unpack a data field that was packed using a simple packing, [Data Representation Template 5....
subroutine gf_unpack3(cgrib, lcgrib, iofst, igds, igdstmpl, mapgridlen, ideflist, idefnum, ierr)
Unpack Section 3 ([Grid Definition Section] (https://www.nco.ncep.noaa.gov/pmb/docs/grib2/grib2_doc/g...
Handles Data Representation Templates used in Section 5.
subroutine getdrstemplate(number, nummap, map, needext, iret)
Return DRS template information for a specified Data Representation Template.
subroutine extdrstemplate(number, list, nummap, map)
Generate the remaining octet map for a given Data Representation Template, if required.
Logging for the g2 library.
character *120 g2_log_msg
Fill this with the logging message.
subroutine g2_log(level)
Print a debug message for the g2 library.
This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Secti...
subroutine getgridtemplate(number, nummap, map, needext, iret)
Get the grid template information for a specified Grid Definition Template.
subroutine extgridtemplate(number, list, nummap, map)
Generate the remaining octet map for a given Grid Definition Template, if required.
Information on all GRIB2 Product Definition Templates used in Section 4 - the Product Definition Sect...
subroutine extpdstemplate(number, list, nummap, map)
This subroutine generates the remaining octet map for a given Product Definition Template,...
subroutine getpdstemplate(number, nummap, map, needext, iret)
This subroutine returns PDS template information for a specified Product Definition Template.