162 CHARACTER*256 carg,cg1,cx1,cgb,cxb,cgm,cxm,cg2,cnl
164 INTEGER kgdti(200),ipopt(20),jpdt(200),jpdsb(200),iuv(100)
165 DATA igdtn/-1/,kgdti/200*0/
166 DATA ip/0/,ipopt/20*-1/
167 DATA jpdtn/-1/,jpdt/200*-9999/,jpdsb/200*-1/
168 DATA iuv/514,99*0/,nuv/1/
169 DATA lwg/0/,lapp/0/,lxx/0/,lx/1/,kz1/-1/,kz2/-2/
170 DATA jb/0/,jbk/0/,lab/1/,ab/-1.e30/,lam/0/,am/0./
171 DATA cgb/
' '/,cxb/
' '/,cgm/
' '/,cxm/
' '/,cnl/
' '/
172 INTEGER ids(255),ibs(255),nbs(255)
173 NAMELIST/nlcopygb/ ids,ibs,nbs
174 DATA ids/255*-9999/,ibs/255*-9999/,nbs/255*-9999/
180 DO WHILE(iarg.LE.narg.AND.lstopt.EQ.0)
181 CALL getarg(iarg,carg)
184 IF(carg(1:1).NE.
'-')
THEN
187 ELSEIF(larg.EQ.1)
THEN
188 CALL errmsg(
'copygb2: invalid option -')
194 IF(carg(l:l).EQ.
'-')
THEN
196 ELSEIF(carg(l:l).EQ.
'a')
THEN
198 ELSEIF(carg(l:l).EQ.
'A')
THEN
201 CALL getarg(iarg,carg)
205 IF(carg(l+1:l+1).EQ.
'>')
THEN
208 ELSEIF(carg(l+1:l+1).EQ.
'<')
THEN
212 CALL errmsg(
'copygb2: invalid threshold '// &
217 CALL fparser(carg(l+1:larg),1,ab)
219 call errmsg(
'Option -A Ignored...Not yet implemented.')
222 ELSEIF(carg(l:l).EQ.
'B')
THEN
225 CALL getarg(iarg,carg)
232 call errmsg(
'Option -B Ignored...Not yet implemented.')
235 ELSEIF(carg(l:l).EQ.
'b')
THEN
238 CALL getarg(iarg,carg)
245 call errmsg(
'Option -b Ignored...Not yet implemented.')
248 ELSEIF(carg(l:l).EQ.
'g')
THEN
251 CALL getarg(iarg,carg)
257 CALL fparsei(carg(l+1:larg),100,karg)
259 IF(igdtn.GE.0.AND.igdtn.LE.65534)
THEN
260 kgdti(1:99)=karg(2:100)
262 IF(igdtn.LT.-5.OR.igdtn.EQ.-2.OR. &
263 igdtn.EQ.-3.OR.igdtn.GT.65534)
THEN
264 CALL errmsg(
'copygb2: invalid output grid '// &
269 IF ( igdtn.GE.0 )
THEN
270 mi=numpts(igdtn,kgdti)
272 CALL errmsg(
'copygb2: unsupported output grid '// &
279 ELSEIF(carg(l:l).EQ.
'i')
THEN
282 CALL getarg(iarg,carg)
288 CALL fparsei(carg(l+1:larg),21,karg)
292 ELSEIF(carg(l:l).EQ.
'K')
THEN
295 CALL getarg(iarg,carg)
300 CALL fparsei(carg(l+1:larg),100,jpdsb)
301 IF(jpdsb(5).EQ.0)
THEN
302 CALL errmsg(
'copygb2: invalid PDS parms '// &
308 call errmsg(
'Option -K Ignored...Not yet implemented.')
311 ELSEIF(carg(l:l).EQ.
'k')
THEN
314 CALL getarg(iarg,carg)
319 karg(2:100)=jpdt(1:99)
320 CALL fparsei(carg(l+1:larg),100,karg)
322 jpdt(1:99)=karg(2:100)
323 IF(jpdtn.LT.-1 .OR. jpdtn.GE.65535)
THEN
324 CALL errmsg(
'copygb2: invalid PDT parms '// &
330 ELSEIF(carg(l:l).EQ.
'M')
THEN
333 CALL getarg(iarg,carg)
337 IF(carg(l+1:l+1).EQ.
'#')
THEN
339 CALL fparser(carg(l+1:larg),1,am)
347 ELSEIF(carg(l:l).EQ.
'm')
THEN
350 CALL getarg(iarg,carg)
357 ELSEIF(carg(l:l).EQ.
'N')
THEN
360 CALL getarg(iarg,carg)
367 call errmsg(
'Option -N Ignored...Not yet implemented.')
370 ELSEIF(carg(l:l).EQ.
'v')
THEN
373 CALL getarg(iarg,carg)
377 CALL fparsei(carg(l+1:larg),100,iuv)
380 IF(iuv(juv).NE.0) nuv=juv
383 ELSEIF(carg(l:l).EQ.
'x')
THEN
385 ELSEIF(carg(l:l).EQ.
'X')
THEN
388 CALL errmsg(
'copygb2: invalid option '//carg(l:l))
399 IF(narg-iarg+1.NE.nxarg)
THEN
400 CALL errmsg(
'copygb2: incorrect number of arguments')
404 CALL getarg(iarg,cg1)
408 CALL baopenr(lg1,cg1(1:lcg1),iretba)
410 CALL errmsg(
'copygb2: error accessing file '//cg1(1:lcg1))
414 CALL getarg(iarg,cx1)
418 CALL baopenr(lx1,cx1(1:lcx1),iretba)
420 CALL errmsg(
'copygb2: error accessing file '//cx1(1:lcx1))
426 CALL getarg(iarg,cg2)
429 IF(cg2(1:lcg2).EQ.
'-')
THEN
431 CALL errmsg(
'copygb2: piping incompatible with the X option')
438 CALL baopenwt(lg2,cg2(1:lcg2),iretba)
440 CALL baopenwa(lg2,cg2(1:lcg2),iretba)
443 CALL errmsg(
'copygb2: error accessing file '//cg2(1:lcg2))
450 IF(cgb(1:2).EQ.
'-1')
THEN
451 IF(jpdsb(5).EQ.-1)
THEN
461 CALL baopenr(lgb,cgb(1:lcgb),iretba)
463 CALL errmsg(
'copygb2: error accessing file '//cgb(1:lcgb))
466 IF(cxb(1:1).NE.
' ')
THEN
468 CALL baopenr(lxb,cxb(1:lcxb),iretba)
470 CALL errmsg(
'copygb2: error accessing file '//cxb(1:lcxb))
483 CALL baopenr(lgm,cgm(1:lcgm),iretba)
485 CALL errmsg(
'copygb2: error accessing file '//cgm(1:lcgm))
488 IF(cxm(1:1).NE.
' ')
THEN
490 CALL baopenr(lxm,cxm(1:lcxm),iretba)
492 CALL errmsg(
'copygb2: error accessing file '//cxm(1:lcxm))
503 OPEN(lnl,file=cnl(1:lcnl),status=
'OLD',iostat=iret)
505 CALL errmsg(
'copygb2: error accessing file '//cnl(1:lcnl))
508 READ(lnl,nlcopygb,iostat=iret)
510 CALL errmsg(
'copygb2: error reading namelist from file '// &
518 CALL w3tagb(
'COPYGB2 ',1998,0295,0047,
'NP23 ')
520 CALL cpgb(lg1,lx1,lgb,lxb,lgm,lxm,lg2, &
521 igdtn,kgdti,ip,ipopt,jpdtn,jpdt,nuv,iuv, &
522 jpdsb,jb,jbk,lab,ab,lam,am,lxx,lwg, &
525 CALL w3tage(
'COPYGB2 ')
534 CALL errmsg(
'Usage: copygb2'// &
535 ' [-g "kgdtn [kgdt]"] [-i "ip [ipopts]"]')
537 ' [-k "kpdtn kpdt"] [-v "uparms"]')
539 ' [-B mapgrib [-b mapindex] [-A "<> mapthreshold"]'// &
542 ' [-M "mask"/mergegrib [-m mergeindex]] [-X] [-a]'// &
544 CALL errmsg(
' then either:')
546 ' grib2in index1 grib2out')
549 ' -x grib2in grib2out')
584 SUBROUTINE cpgb(LG1,LX1,LGB,LXB,LGM,LXM,LG2, &
585 IGDTN,KGDTI,IP,IPOPT,JPDTN,JPDT,NUV,IUV, &
586 JPDSB,JB,JBK,LAB,AB,LAM,AM,LXX,LWG, &
590 parameter(mbuf=256*1024)
591 CHARACTER cbufb(mbuf)
592 INTEGER jids(200),jpdt(200),jgdt(200)
594 INTEGER jpdsb(100),iuv(100)
597 INTEGER ids(255),ibs(255),nbs(255)
599 INTEGER jgds(200),jens(5)
600 INTEGER kpdsb(200),kgdsb(200),kensb(5)
608 IF(lxx.GT.0)
CALL instrument(6,kall0,ttot0,tmin0,tmax0)
615 CALL getgbemh(lgb,lxb,krb,jpdsb,jgds,jens, &
616 mbuf,cbufb,nlenb,nnumb,mnumb, &
617 kb,mb,krbx,kpdsb,kgdsb,kensb,iret)
618 IF(iret.EQ.0.AND.mb.LE.0) iret=255
621 print *,
'copygb2 map field not found'
622 ELSEIF(iret.NE.0)
THEN
623 print *,
'copygb2 map field retrieval error code ',iret
647 CALL getgb2(lg1,lx1,kr1,jdisc,jids,jpdtn,jpdt,jgdtn, &
648 jgdt,unpack,kr1x,gfld1,iret)
652 IF(iret.EQ.0.AND.gfld1%NDPTS.LE.0) iret=255
657 print *,
'copygb2 field not found'
658 ELSEIF(iret.NE.0)
THEN
659 print *,
'copygb2 header retrieval error code ',iret
669 jdisc=gfld1%DISCIPLINE
673 jjpdt(1:2)=gfld1%IPDTMPL(1:2)
674 jjpdt(10:15)=gfld1%IPDTMPL(10:15)
679 CALL getgb2(lgm,lxm,krm,jdisc,jids,jjpdtn,jjpdt, &
680 jgdtn,jgdt,unpack,krmx,gfldm,iret)
685 IF(iret.EQ.0.AND.mm.LE.0) iret=255
694 kgdti(1:gfld1%IGDTLEN) = gfld1%IGDTMPL(1:gfld1%IGDTLEN)
696 ELSEIF(igdtn.EQ.-4.AND.jb.EQ.4)
THEN
702 ELSEIF(igdtn.EQ.-5.AND.lam.EQ.5)
THEN
704 kgdti(1:gfldm%IGDTLEN) = gfldm%IGDTMPL(1:gfldm%IGDTLEN)
707 mi=numpts(igdtn,kgdti)
709 IF(lxx.GT.0)
CALL instrument(1,kall1,ttot1,tmin1,tmax1)
710 IF(igdtn.GE.0.AND.igdtn.LE.65534)
THEN
712 CALL cpgb1(lg1,lx1,m1, &
714 igdtn,kgdti,ip,ipopt,jpdtn,jpdt,nuv,iuv, &
715 jpdsb,jb,jbk,lab,ab,lam,am, &
717 lgb,lxb,mb,cbufb,nlenb,nnumb,mnumb, &
719 lg2,lxx,kr1-1,no,iret1)
740 CALL getgb2(lg1,lx1,kr1,jdisc,jids,jpdtn,jpdt,jgdtn, &
741 jgdt,unpack,kr1x,gfld1,iret)
745 IF(iret.EQ.0.AND.gfld1%NDPTS.LE.0) iret=255
749 IF(iret.NE.0.AND.iret.NE.99)
THEN
750 print *,
'copygb2 header retrieval error code ',iret
757 print *,
'copygb2 wrote ',no,
' total records'
758 CALL instrument(1,kall1,ttot1,tmin1,tmax1)
759 print *,
'Instrumentation Report'
760 print
'(F10.3," seconds spent searching headers")',ttot1
761 CALL instrument(-2,kall2,ttot2,tmin2,tmax2)
762 print
'(F10.3," seconds spent reading and unpacking")',ttot2
763 CALL instrument(-3,kall3,ttot3,tmin3,tmax3)
764 print
'(F10.3," seconds spent manipulating masks")',ttot3
765 CALL instrument(-4,kall4,ttot4,tmin4,tmax4)
766 print
'(F10.3," seconds spent interpolating or copying")',ttot4
767 CALL instrument(-5,kall5,ttot5,tmin5,tmax5)
768 print
'(F10.3," seconds spent merging")',ttot5
769 CALL instrument(-6,kall6,ttot6,tmin6,tmax6)
770 print
'(F10.3," seconds spent packing and writing")',ttot6
771 ttott=ttot1+ttot2+ttot3+ttot4+ttot5+ttot6
772 print
'(F10.3," total seconds spent in copygb2")',ttott
820 SUBROUTINE cpgb1(LG1,LX1,M1, &
822 IGDTN,KGDTI,IP,IPOPT,JPDTN,JPDT,NUV,IUV, &
823 JPDSB,JB,JBK,LAB,AB,LAM,AM, &
825 LGB,LXB,MB,CBUFB,NLENB,NNUMB,MNUMB, &
831 CHARACTER cbufb(mbuf)
832 INTEGER jpdsb(100),iuv(100)
833 INTEGER jids(200),jpdt(100),jgdt(200)
835 INTEGER,
TARGET :: kgdti(200)
837 INTEGER ids(255),ibs(255),nbs(255)
839 INTEGER jgds(200),jens(5)
842 INTEGER kpdsb(200),kgdsb(200),kensb(5)
844 INTEGER,
POINTER :: tmpptr(:)
846 LOGICAL*1,
POINTER :: l1i(:),lbi(:)
850 REAL,
POINTER :: f1i(:)
851 REAL,
ALLOCATABLE,
TARGET :: g1i(:)
852 REAL,
POINTER :: fbi(:),gbi(:)
853 TYPE(
gribfield ) :: gfld1,gfldv,gfldm,gfldmv
854 INTEGER isdummy,iadummy(200)
862 CALL getgb2(lg1,lx1,ks1,jdisc,jids,jpdtn,jpdt,jgdtn, &
863 jgdt,unpack,kr1,gfld1,iret)
872 nparm=(65536*gfld1%DISCIPLINE) + (256*gfld1%IPDTMPL(1)) + &
874 DO WHILE(juv.LE.nuv.AND.nparm.NE.iuv(juv).AND. &
878 IF(juv.LE.nuv.AND.nparm.EQ.iuv(juv))
THEN
880 gfld1%IPDTMPL(2)=gfld1%IPDTMPL(2)+1
881 CALL getgb2(lg1,lx1,krv,gfld1%DISCIPLINE,gfld1%IDSECT, &
882 gfld1%IPDTNUM,gfld1%IPDTMPL,gfld1%IGDTNUM, &
883 gfld1%IGDTMPL,unpack,krvx,gfldv,iret)
888 gfld1%IPDTMPL(2)=gfld1%IPDTMPL(2)-1
889 ELSEIF(juv.LE.nuv.AND.nparm.EQ.iuv(juv)+1)
THEN
895 print *,
'copygb2 skipping 2nd vector component field'
896 ELSEIF(iret.NE.0)
THEN
897 print *,
'copygb2 data retrieval error code ',iret
898 ELSEIF(krv.EQ.0)
THEN
899 print *,
'copygb2 read scalar field from record ',kr1
900 print *,
' ...PDT 4.',gfld1%IPDTNUM,
'=', &
901 (gfld1%IPDTMPL(i),i=1,gfld1%IPDTLEN)
903 print *,
'copygb2 read vector field from records ',kr1,krv
904 print *,
' ...PDT 4.',gfld1%IPDTNUM,
'=', &
905 (gfld1%IPDTMPL(i),i=1,gfld1%IPDTLEN)
906 print *,
' ...PDT 4.',gfldv%IPDTNUM,
'=', &
907 (gfldv%IPDTMPL(i),i=1,gfldv%IPDTLEN)
909 CALL instrument(2,kall2,ttot2,tmin2,tmax2)
913 IF(iret.EQ.0.AND.jbk.EQ.1.AND.jb.EQ.1)
THEN
916 IF((lab.EQ.1.AND.fr(i).LE.ab).OR. &
917 (lab.EQ.-1.AND.fr(i).GE.ab))
THEN
924 print *,
' applied pre-interpolation map mask'
925 CALL instrument(3,kall3,ttot3,tmin3,tmax3)
934 IF ( gfld1%IBMAP.EQ.0 .OR. gfld1%IBMAP.EQ.254 )
THEN
938 ALLOCATE( gfld1%BMAP(k1) )
940 IF ( .NOT.
ASSOCIATED(gfld1%LIST_OPT)) &
941 ALLOCATE(gfld1%LIST_OPT(1))
942 IF ( .NOT.
ASSOCIATED(gfldv%FLD) )
ALLOCATE(gfldv%FLD(k1))
943 CALL intgrib2(iv,ip,ipopt,gfld1%IGDTNUM,gfld1%IGDTMPL, &
944 gfld1%NUM_OPT,gfld1%LIST_OPT, &
946 gfld1%FLD,gfldv%FLD,igdtn,kgdti,mi, &
947 ib1i,l1i,f1i,g1i,iret)
950 print *,
' interpolated to grid GDT 3.',igdtn,
'=', &
952 ELSEIF(iret.GT.0)
THEN
953 print *,
' interpolation error code ',iret
955 CALL instrument(4,kall4,ttot4,tmin4,tmax4)
957 IF(iret.EQ.-1) iret=0
961 IF(iret.EQ.0.AND.jb.EQ.4)
THEN
965 CALL getgbem(lgb,lxb,mb,krb,jpdsb,jgds,jens, &
966 mbuf,cbufb,nlenb,nnumb,mnumb, &
967 kb,krbx,kpdsb,kgdsb,kensb,lr,fr,iret)
970 print *,
' map field retrieved'
971 print *,
' ...KPDS(1:24)=',(kpdsb(i),i=1,24)
972 ELSEIF(iret.EQ.99)
THEN
973 print *,
' map field not found'
975 print *,
' map field retrieval error code ',iret
981 ibb=mod(kpdsb(4)/64,2)
982 CALL intgrib2(0,ip,ipopt,isdummy,iadummy,
SIZE(kgdsb),kgdsb, &
983 kb,ibb,lr,fr,gr,isdummy,kgdti,mi, &
984 ibbi,lbi,fbi,gbi,iret)
987 print *,
' interpolated to grid template 3.',igdtn
988 ELSEIF(iret.GT.0)
THEN
989 print *,
' interpolation error code ',iret
992 IF(iret.EQ.-1) iret=0
998 IF(jbk.EQ.0.AND.jb.EQ.1)
THEN
1001 IF((lab.EQ.1.AND.f1i(i).LE.ab).OR. &
1002 (lab.EQ.-1.AND.f1i(i).GE.ab))
THEN
1009 print *,
' applied post-interpolation map mask'
1011 ELSEIF(jb.EQ.4)
THEN
1014 IF((lab.EQ.1.AND.fbi(i).LE.ab).OR. &
1015 (lab.EQ.-1.AND.fbi(i).GE.ab))
THEN
1025 print *,
' applied fixed map mask'
1030 IF(lam.EQ.1.AND.ib1i.EQ.1)
THEN
1033 IF(.NOT.l1i(i))
THEN
1036 IF(krv.GT.0) g1i(i)=am
1040 print *,
' substituted mask fill value ',am
1043 IF(lxx.GT.0)
CALL instrument(3,kall3,ttot3,tmin3,tmax3)
1046 IF(lam.EQ.5.AND.ib1i.EQ.1)
THEN
1047 jdisc=gfld1%DISCIPLINE
1049 jjpdtn=gfld1%IPDTNUM
1051 jjpdt(1:2)=gfld1%IPDTMPL(1:2)
1052 jjpdt(10:15)=gfld1%IPDTMPL(10:15)
1057 CALL getgb2(lgm,lxm,krm,jdisc,jids,jjpdtn,jjpdt, &
1058 jgdtn,jgdt,unpack,krmx,gfldm,iret)
1063 IF(iret.EQ.0.AND.krv.GT.0)
THEN
1064 gfldm%IPDTMPL(2)=gfldm%IPDTMPL(2)+1
1065 CALL getgb2(lgm,lxm,krm,gfldm%DISCIPLINE,gfldm%IDSECT, &
1066 gfldm%IPDTNUM,gfldm%IPDTMPL,gfldm%IGDTNUM, &
1067 gfldm%IGDTMPL,unpack,krmx,gfldmv,iret)
1071 gfldm%IPDTMPL(2)=gfldm%IPDTMPL(2)-1
1075 print *,
' merge field retrieved'
1076 print *,
' ...PDT 4.',gfldm%IPDTNUM,
'=', &
1077 (gfldm%IPDTMPL(i),i=1,gfldm%IPDTLEN)
1079 print *,
' ...PDT 4.',gfldmv%IPDTNUM,
'=', &
1080 (gfldmv%IPDTMPL(i),i=1,gfldmv%IPDTLEN)
1081 ELSEIF(iret.EQ.99)
THEN
1082 print *,
' merge field not found'
1084 print *,
' merge field retrieval error code ',iret
1088 ALLOCATE(lbi(mi),fbi(mi),gbi(mi))
1089 IF ( gfldm%IBMAP.EQ.0 .OR. gfldm%IBMAP.EQ.254 )
THEN
1093 ALLOCATE( gfld1%BMAP(km) )
1095 IF ( .NOT.
ASSOCIATED(gfldm%LIST_OPT)) &
1096 ALLOCATE(gfldm%LIST_OPT(1))
1097 IF ( .NOT.
ASSOCIATED(gfldmv%FLD))
ALLOCATE(gfldmv%FLD(km))
1098 CALL intgrib2(iv,ip,ipopt,gfldm%IGDTNUM,gfldm%IGDTMPL, &
1099 gfldm%NUM_OPT,gfldm%LIST_OPT, &
1100 km,ibm,gfldm%BMAP,gfldm%FLD,gfldmv%FLD, &
1102 ibbi,lbi,fbi,gbi,iret)
1105 print *,
' interpolated to grid template 3.',igdtn
1106 ELSEIF(iret.GT.0)
THEN
1107 print *,
' interpolation error code ',iret
1110 IF(iret.EQ.-1) iret=0
1114 IF(.NOT.l1i(i).AND.lbi(i))
THEN
1117 IF(krv.GT.0) g1i(i)=gbi(i)
1121 print *,
' merged output field with merge field'
1125 IF (
ASSOCIATED(lbi))
DEALLOCATE(lbi)
1126 IF (
ASSOCIATED(fbi))
DEALLOCATE(fbi)
1127 IF (
ASSOCIATED(gbi))
DEALLOCATE(gbi)
1129 IF(lxx.GT.0)
CALL instrument(5,kall5,ttot5,tmin5,tmax5)
1135 IF ( ib1i .EQ. 1 ) gfld1%IBMAP=0
1149 DEALLOCATE(gfld1%IGDTMPL)
1150 gfld1%IGDTMPL => kgdti
1154 IF (
ASSOCIATED(gfld1%BMAP) )
DEALLOCATE(gfld1%BMAP)
1156 IF (
ASSOCIATED(gfld1%FLD) )
DEALLOCATE(gfld1%FLD)
1158 CALL putgb2(lg2,gfld1,iret)
1160 IF(iret.EQ.0) no=no+1
1161 IF(iret.EQ.0.AND.krv.GT.0)
THEN
1162 IF (
ASSOCIATED(gfld1%FLD) )
DEALLOCATE(gfld1%FLD)
1166 tmpptr => gfld1%IPDTMPL
1167 gfld1%IPDTMPL => gfldv%IPDTMPL
1169 CALL putgb2(lg2,gfld1,iret)
1171 IF(iret.EQ.0) no=no+1
1172 gfld1%IPDTMPL => tmpptr
1176 print *,
' packing error code ',iret
1177 ELSEIF(krv.EQ.0)
THEN
1178 print *,
' wrote scalar field to record ',no
1179 print *,
' ...PDT 4.',gfld1%IPDTNUM,
'=', &
1180 (gfld1%IPDTMPL(i),i=1,gfld1%IPDTLEN)
1182 print *,
' wrote vector field to records ',no-1,no
1183 print *,
' ...PDT 4.',gfld1%IPDTNUM,
'=', &
1184 (gfld1%IPDTMPL(i),i=1,gfld1%IPDTLEN)
1185 print *,
' ...PDT 4.',gfldv%IPDTNUM,
'=', &
1186 (gfldv%IPDTMPL(i),i=1,gfldv%IPDTLEN)
1188 CALL instrument(6,kall6,ttot6,tmin6,tmax6)
1193 IF (iret.EQ.0)
NULLIFY(gfld1%IGDTMPL)
1194 IF (
ASSOCIATED(gfld1%FLD,g1i))
then
1197 elseif (
ALLOCATED(g1i))
then
1208 END SUBROUTINE cpgb1
1234 SUBROUTINE intgrib2(IV,IP,IPOPT,NGDT1,KGDT1,IDEFN1,IDEF1, &
1236 NGDT2,KGDT2,K2,IB2,L2,F2,G2,IRET)
1240 INTEGER kgdt1(*),kgdt2(*),igds(5)
1241 INTEGER idef1(idefn1)
1244 INTEGER kgds1(200),kgds2(200)
1245 LOGICAL*1 l1(k1),l2(k2)
1248 INTEGER kgds1f(200),kgds2f(200)
1255 IF ( ngdt1 .EQ. ngdt2 )
THEN
1257 int=max(int,abs(kgdt1(i)-kgdt2(i)))
1271 IF(iv.NE.0) g2(i)=g1(i)
1282 CALL gdt2gds(igds,kgdt1,idefn1,idef1,kgds1,igi,iret)
1285 CALL gdt2gds(igds,kgdt2,idefn,idef,kgds2,igi,iret)
1296 IF(k1f.GT.0.AND.k2f.GT.0)
THEN
1297 CALL intgrib1(k1f,kgds1f,k2f,kgds2f,mrl,mro, &
1298 iv,ip,ipopt,kgds1,k1,ib1,l1,f1,g1,kgds2,k2, &
1305 END SUBROUTINE intgrib2
1333 SUBROUTINE intgrib1(K1F,KGDS1F,K2F,KGDS2F,MRL,MRO, &
1334 IV,IP,IPOPT,KGDS1,K1,IB1,L1,F1,G1,KGDS2,K2, &
1340 INTEGER kgds1(200),kgds2(200)
1341 LOGICAL*1 l1(k1),l2(k2)
1342 REAL f1(k1),f2(k2),g1(k1),g2(k2)
1343 INTEGER kgds1f(200),kgds2f(200)
1344 LOGICAL*1 l1f(k1f),l2f(k2f)
1345 REAL f1f(k1f),f2f(k2f),g1f(k1f),g2f(k2f)
1346 REAL rlat(mrl),rlon(mrl),crot(mro),srot(mro)
1349 IF(k1f.EQ.1.AND.k2f.EQ.1.AND.iv.EQ.0)
THEN
1350 CALL ipolates(ip,ipopt,kgds1,kgds2,k1,k2,1,ib1,l1,f1, &
1351 ki,rlat,rlon,ib2,l2,f2,iret)
1354 ELSEIF(k1f.NE.1.AND.k2f.EQ.1.AND.iv.EQ.0)
THEN
1355 CALL ipxwafs2(1,k1,k1f,1, &
1356 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1358 CALL ipolates(ip,ipopt,kgds1f,kgds2,k1f,k2,1,ib1f,l1f,f1f, &
1359 ki,rlat,rlon,ib2,l2,f2,iret)
1363 ELSEIF(k1f.EQ.1.AND.k2f.NE.1.AND.iv.EQ.0)
THEN
1364 CALL ipolates(ip,ipopt,kgds1,kgds2f,k1,k2f,1,ib1,l1,f1, &
1365 ki,rlat,rlon,ib2f,l2f,f2f,iret)
1367 CALL ipxwafs2(-1,k2,k2f,1, &
1368 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1372 ELSEIF(k1f.NE.1.AND.k2f.NE.1.AND.iv.EQ.0)
THEN
1373 CALL ipxwafs2(1,k1,k1f,1, &
1374 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1376 CALL ipolates(ip,ipopt,kgds1f,kgds2f,k1f,k2f,1,ib1f,l1f,f1f, &
1377 ki,rlat,rlon,ib2f,l2f,f2f,iret)
1379 CALL ipxwafs2(-1,k2,k2f,1, &
1380 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1385 ELSEIF(k1f.EQ.1.AND.k2f.EQ.1.AND.iv.NE.0)
THEN
1386 CALL ipolatev(ip,ipopt,kgds1,kgds2,k1,k2,1,ib1,l1,f1,g1, &
1387 ki,rlat,rlon,crot,srot,ib2,l2,f2,g2,iret)
1388 IF(iret.EQ.0.AND.ki.EQ.k2-1)
THEN
1394 ELSEIF(k1f.NE.1.AND.k2f.EQ.1.AND.iv.NE.0)
THEN
1395 CALL ipxwafs2(1,k1,k1f,1, &
1396 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1397 CALL ipxwafs2(1,k1,k1f,1, &
1398 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1400 CALL ipolatev(ip,ipopt,kgds1f,kgds2,k1f,k2,1, &
1402 ki,rlat,rlon,crot,srot,ib2,l2,f2,g2,iret)
1403 IF(iret.EQ.0.AND.ki.EQ.k2-1)
THEN
1410 ELSEIF(k1f.EQ.1.AND.k2f.NE.1.AND.iv.NE.0)
THEN
1411 CALL ipolatev(ip,ipopt,kgds1,kgds2f,k1,k2f,1,ib1,l1,f1,g1, &
1412 ki,rlat,rlon,crot,srot,ib2f,l2f,f2f,g2f,iret)
1414 CALL ipxwafs2(-1,k2,k2f,1, &
1415 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1416 CALL ipxwafs2(-1,k2,k2f,1, &
1417 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
1421 ELSEIF(k1f.NE.1.AND.k2f.NE.1.AND.iv.NE.0)
THEN
1422 CALL ipxwafs2(1,k1,k1f,1, &
1423 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1424 CALL ipxwafs2(1,k1,k1f,1, &
1425 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1427 CALL ipolatev(ip,ipopt,kgds1f,kgds2f,k1f,k2f,1, &
1429 ki,rlat,rlon,crot,srot,ib2f,l2f,f2f,g2f,iret)
1431 CALL ipxwafs2(-1,k2,k2f,1, &
1432 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1433 CALL ipxwafs2(-1,k2,k2f,1, &
1434 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
1457 INTEGER kgds(200),kgdsf(200)
1459 IF(kgds(1).EQ.201)
THEN
1461 lengdsf=kgds(7)*kgds(8)-kgds(8)/2
1462 ELSEIF(kgds(1).EQ.202)
THEN
1465 ELSEIF(kgds(19).EQ.0.AND.kgds(20).NE.255)
THEN
1466 CALL ipxwafs(1,1,1,0,kgds,dum,kgdsf,dumf,iret)
1492 FUNCTION numpts(IGDTN,KGDT)
1493 INTEGER,
INTENT(IN) :: igdtn,kgdt(*)
1498 allones=ibset(allones,j)
1501 SELECT CASE( igdtn )
1503 IF ( kgdt(8).NE.allones .AND. kgdt(9).NE.allones )
THEN
1504 numpts = kgdt(8) * kgdt(9)
1509 IF ( kgdt(8).NE.allones .AND. kgdt(9).NE.allones )
THEN
1510 numpts = kgdt(8) * kgdt(9)
1515 IF ( kgdt(8).NE.allones .AND. kgdt(9).NE.allones )
THEN
1516 numpts = kgdt(8) * kgdt(9)
1521 IF ( kgdt(8).NE.allones .AND. kgdt(9).NE.allones )
THEN
1522 numpts = kgdt(8) * kgdt(9)
1527 IF ( kgdt(8).NE.allones .AND. kgdt(9).NE.allones )
THEN
1528 numpts = kgdt(8) * kgdt(9)
subroutine gdt2gds(igds, igdstmpl, idefnum, ideflist, kgds, igrid, iret)
This routine converts grid information from a GRIB2 Grid Description Section as well as its Grid Defi...
program copygb2
The command copygb2 copies all or part of one GRIB2 file to another GRIB2 file, interpolating if nece...
subroutine cpgb(lg1, lx1, lgb, lxb, lgm, lxm, lg2, igi, kgdsi, ip, ipopt, jpds1, nuv, iuv, jpdsb, jb, jbk, lab, ab, lam, am, lxx, lwg, ids, ibs, nbs)
Copy grib files.
subroutine eusage
Print proper usage to stderr.
subroutine cpgb1(lg1, lx1, m1, cbuf1, nlen1, nnum1, mnum1, mbuf, mf, mi, igi, kgdsi, ip, ipopt, jpds1, nuv, iuv, jpdsb, jb, jbk, lab, ab, lam, am, ids, ibs, nbs, lgb, lxb, mb, cbufb, nlenb, nnumb, mnumb, lgm, lxm, mm, cbufm, nlenm, nnumm, mnumm, lg2, lxx, ks1, no, iret)
Copy one grib field.
function lengdsf(kgds, kgdsf)
Return the length of a filled grid.
subroutine intgrib1(k1f, kgds1f, k2f, kgds2f, mrl, mro, iv, ip, ipopt, kgds1, k1, ib1, l1, f1, g1, kgds2, k2, ib2, l2, f2, g2, iret)
Interpolate field.
subroutine getgb2(lugb, lugi, j, jdisc, jids, jpdtn, jpdt, jgdtn, jgdt, unpack, k, gfld, iret)
This is a legacy version of getgb2i2().
subroutine gf_free(gfld)
Free memory that was used to store array values in derived type grib_mod::gribfield.
subroutine putgb2(lugb, gfld, iret)
Pack a field into a grib2 message and write that message to a file.
This Fortran module contains the declaration of derived type gribfield.
This Fortran module contains info on all the available GRIB2 Grid Definition Templates used in [Secti...
integer function getgdtlen(number)
This function returns the initial length (number of entries) in the static part of specified Grid Def...