562SUBROUTINE cpgb(LG1,LX1,LGB,LXB,LGM,LXM,LG2, &
563 IGI,KGDSI,IP,IPOPT,JPDS1,NUV,IUV, &
564 JPDSB,JB,JBK,LAB,AB,LAM,AM,LXX,LWG, &
566 parameter(mbuf=256*1024)
567 CHARACTER CBUF1(MBUF),CBUFB(MBUF),CBUFM(MBUF)
568 INTEGER JPDS1(100),JPDSB(100),IUV(100)
571 INTEGER IDS(255),IBS(255),NBS(255)
572 INTEGER JPDS(200),JGDS(200),JENS(5)
573 INTEGER KPDS1(200),KGDS1(200),KENS1(5)
574 INTEGER KPDSB(200),KGDSB(200),KENSB(5)
575 INTEGER KPDSM(200),KGDSM(200),KENSM(5)
579 IF(lxx.GT.0)
CALL instrument(6,kall0,ttot0,tmin0,tmax0)
586 CALL getgbemh(lgb,lxb,krb,jpdsb,jgds,jens, &
587 mbuf,cbufb,nlenb,nnumb,mnumb, &
588 kb,mb,krbx,kpdsb,kgdsb,kensb,iret)
589 IF(iret.EQ.0.AND.mb.LE.0) iret=255
592 print *,
'copygb map field not found'
593 ELSEIF(iret.NE.0)
THEN
594 print *,
'copygb map field retrieval error code ',iret
604 READ (*,*,iostat=iret) cin
607 IF(ndel.GT.0) cin=cin(:ndel-1)
617 CALL getgbemh(lg1,lx1,kr1,jpds1,jgds,jens, &
618 mbuf,cbuf1,nlen1,nnum1,mnum1, &
619 k1,m1,kr1x,kpds1,kgds1,kens1,iret)
620 IF(iret.EQ.0.AND.m1.LE.0) iret=255
624 print *,
'copygb field not found'
625 ELSEIF(iret.NE.0)
THEN
626 print *,
'copygb header retrieval error code ',iret
643 CALL getgbemh(lgm,lxm,krm,jpds,jgds,jens, &
644 mbuf,cbufm,nlenm,nnumm,mnumm, &
645 km,mm,krmx,kpdsm,kgdsm,kensm,iret)
646 IF(iret.EQ.0.AND.mm.LE.0) iret=255
658 ELSEIF(igi.EQ.-4.AND.jb.EQ.4)
THEN
662 ELSEIF(igi.EQ.-5.AND.lam.EQ.5)
THEN
669 IF(lxx.GT.0)
CALL instrument(1,kall1,ttot1,tmin1,tmax1)
670 IF(igi.GT.0.AND.igi.LE.255)
THEN
672 CALL cpgb1(lg1,lx1,m1,cbuf1,nlen1,nnum1,mnum1, &
674 igi,kgdsi,ip,ipopt,jpds1,nuv,iuv, &
675 jpdsb,jb,jbk,lab,ab,lam,am, &
677 lgb,lxb,mb,cbufb,nlenb,nnumb,mnumb, &
678 lgm,lxm,mm,cbufm,nlenm,nnumm,mnumm, &
679 lg2,lxx,kr1-1,no,iret1)
682 READ (*,*,iostat=iret) cin
685 IF(ndel.GT.0) cin=cin(:ndel-1)
695 CALL getgbemh(lg1,lx1,kr1,jpds1,jgds,jens, &
696 mbuf,cbuf1,nlen1,nnum1,mnum1, &
697 k1,m1,kr1x,kpds1,kgds1,kens1,iret)
698 IF(iret.EQ.0.AND.m1.LE.0) iret=255
701 IF(iret.NE.0.AND.iret.NE.99)
THEN
702 print *,
'copygb header retrieval error code ',iret
709 print *,
'copygb wrote ',no,
' total records'
710 CALL instrument(1,kall1,ttot1,tmin1,tmax1)
711 print *,
'Instrumentation Report'
712 print
'(F10.3," seconds spent searching headers")',ttot1
713 CALL instrument(-2,kall2,ttot2,tmin2,tmax2)
714 print
'(F10.3," seconds spent reading and unpacking")',ttot2
715 CALL instrument(-3,kall3,ttot3,tmin3,tmax3)
716 print
'(F10.3," seconds spent manipulating masks")',ttot3
717 CALL instrument(-4,kall4,ttot4,tmin4,tmax4)
718 print
'(F10.3," seconds spent interpolating or copying")',ttot4
719 CALL instrument(-5,kall5,ttot5,tmin5,tmax5)
720 print
'(F10.3," seconds spent merging")',ttot5
721 CALL instrument(-6,kall6,ttot6,tmin6,tmax6)
722 print
'(F10.3," seconds spent packing and writing")',ttot6
723 ttott=ttot1+ttot2+ttot3+ttot4+ttot5+ttot6
724 print
'(F10.3," total seconds spent in copygb")',ttott
779SUBROUTINE cpgb1(LG1,LX1,M1,CBUF1,NLEN1,NNUM1,MNUM1, &
781 IGI,KGDSI,IP,IPOPT,JPDS1,NUV,IUV, &
782 JPDSB,JB,JBK,LAB,AB,LAM,AM, &
784 LGB,LXB,MB,CBUFB,NLENB,NNUMB,MNUMB, &
785 LGM,LXM,MM,CBUFM,NLENM,NNUMM,MNUMM, &
787 CHARACTER CBUF1(MBUF),CBUFB(MBUF),CBUFM(MBUF)
788 INTEGER JPDS1(100),JPDSB(100),IUV(100)
791 INTEGER IDS(255),IBS(255),NBS(255)
792 INTEGER JPDS(200),JGDS(200),JENS(5)
793 INTEGER KPDS1(200),KGDS1(200),KENS1(5)
794 INTEGER KPDSB(200),KGDSB(200),KENSB(5)
795 INTEGER KPDSM(200),KGDSM(200),KENSM(5)
796 LOGICAL*1 LR(MF),L1I(MI),LBI(MI)
797 REAL FR(MF),F1I(MI),FBI(MI)
798 REAL GR(MF),G1I(MI),GBI(MI)
804 CALL getgbem(lg1,lx1,m1,ks1,jpds1,jgds,jens, &
805 mbuf,cbuf1,nlen1,nnum1,mnum1, &
806 k1,kr1,kpds1,kgds1,kens1,lr,fr,iret)
808 ib1=mod(kpds1(4)/64,2)
813 DO WHILE(juv.LE.nuv.AND.kpds1(5).NE.iuv(juv).AND. &
814 kpds1(5).NE.iuv(juv)+1)
817 IF(juv.LE.nuv.AND.kpds1(5).EQ.iuv(juv))
THEN
820 jpds(1:24)=kpds1(1:24)
825 CALL getgbem(lg1,lx1,m1,krv,jpds,jgds,jens, &
826 mbuf,cbuf1,nlen1,nnum1,mnum1, &
827 k1,krvx,kpds1,kgds1,kens1,lr,gr,iret)
830 kpds1(22)=max(ids2,kpds1(22))
831 ELSEIF(juv.LE.nuv.AND.kpds1(5).EQ.iuv(juv)+1)
THEN
837 print *,
'copygb skipping 2nd vector component field'
838 ELSEIF(iret.NE.0)
THEN
839 print *,
'copygb data retrieval error code ',iret
840 ELSEIF(krv.EQ.0)
THEN
841 print *,
'copygb read scalar field from record ',kr1
842 print *,
' ...KPDS(1:24)=',(kpds1(i),i=1,24)
844 print *,
'copygb read vector field from records ',kr1,krv
845 print *,
' ...KPDS(1:24)=',(kpds1(i),i=1,24)
846 print *,
' ...KPDS(1:24)=',(kpds1(i),i=1,4), &
847 kpds1(5)+1,(kpds1(i),i=6,24)
849 CALL instrument(2,kall2,ttot2,tmin2,tmax2)
853 IF(iret.EQ.0.AND.jbk.EQ.1.AND.jb.EQ.1)
THEN
856 IF((lab.EQ.1.AND.fr(i).LE.ab).OR. &
857 (lab.EQ.-1.AND.fr(i).GE.ab))
THEN
864 print *,
' applied pre-interpolation map mask'
865 CALL instrument(3,kall3,ttot3,tmin3,tmax3)
871 CALL intgrib(iv,ip,ipopt,kgds1,k1,ib1,lr,fr,gr,kgdsi,mi, &
872 ib1i,l1i,f1i,g1i,iret)
875 print *,
' interpolated to grid ',igi
876 ELSEIF(iret.GT.0)
THEN
877 print *,
' interpolation error code ',iret
879 CALL instrument(4,kall4,ttot4,tmin4,tmax4)
881 IF(iret.EQ.-1) iret=0
885 IF(iret.EQ.0.AND.jb.EQ.4)
THEN
889 CALL getgbem(lgb,lxb,mb,krb,jpdsb,jgds,jens, &
890 mbuf,cbufb,nlenb,nnumb,mnumb, &
891 kb,krbx,kpdsb,kgdsb,kensb,lr,fr,iret)
894 print *,
' map field retrieved'
895 print *,
' ...KPDS(1:24)=',(kpdsb(i),i=1,24)
896 ELSEIF(iret.EQ.99)
THEN
897 print *,
' map field not found'
899 print *,
' map field retrieval error code ',iret
905 ibb=mod(kpdsb(4)/64,2)
906 CALL intgrib(0,ip,ipopt,kgdsb,kb,ibb,lr,fr,gr,kgdsi,mi, &
907 ibbi,lbi,fbi,gbi,iret)
910 print *,
' interpolated to grid ',igi
911 ELSEIF(iret.GT.0)
THEN
912 print *,
' interpolation error code ',iret
915 IF(iret.EQ.-1) iret=0
921 IF(jbk.EQ.0.AND.jb.EQ.1)
THEN
924 IF((lab.EQ.1.AND.f1i(i).LE.ab).OR. &
925 (lab.EQ.-1.AND.f1i(i).GE.ab))
THEN
932 print *,
' applied post-interpolation map mask'
937 IF((lab.EQ.1.AND.fbi(i).LE.ab).OR. &
938 (lab.EQ.-1.AND.fbi(i).GE.ab))
THEN
948 print *,
' applied fixed map mask'
953 IF(lam.EQ.1.AND.ib1i.EQ.1)
THEN
959 IF(krv.GT.0) g1i(i)=am
963 print *,
' substituted mask fill value'
966 IF(lxx.GT.0)
CALL instrument(3,kall3,ttot3,tmin3,tmax3)
969 IF(lam.EQ.5.AND.ib1i.EQ.1)
THEN
975 CALL getgbem(lgm,lxm,mm,krm,jpds,jgds,jens, &
976 mbuf,cbufm,nlenm,nnumm,mnumm, &
977 km,krmx,kpdsm,kgdsm,kensm,lr,fr,iret)
978 IF(iret.EQ.0.AND.krv.GT.0)
THEN
980 jpds(1:24)=kpdsm(1:24)
984 CALL getgbem(lgm,lxm,mm,krm,jpds,jgds,jens, &
985 mbuf,cbufm,nlenm,nnumm,mnumm, &
986 km,krmx,kpdsm,kgdsm,kensm,lr,gr,iret)
991 print *,
' merge field retrieved'
992 print *,
' ...KPDS(1:24)=',(kpdsm(i),i=1,24)
994 print *,
' ...KPDS(1:24)=',(kpdsm(i),i=1,4), &
995 kpdsm(5)+1,(kpdsm(i),i=6,24)
996 ELSEIF(iret.EQ.99)
THEN
997 print *,
' merge field not found'
999 print *,
' merge field retrieval error code ',iret
1003 ibm=mod(kpdsm(4)/64,2)
1004 CALL intgrib(iv,ip,ipopt,kgdsm,km,ibm,lr,fr,gr,kgdsi,mi, &
1005 ibbi,lbi,fbi,gbi,iret)
1008 print *,
' interpolated to grid ',igi
1009 ELSEIF(iret.GT.0)
THEN
1010 print *,
' interpolation error code ',iret
1013 IF(iret.EQ.-1) iret=0
1017 IF(.NOT.l1i(i).AND.lbi(i))
THEN
1020 IF(krv.GT.0) g1i(i)=gbi(i)
1024 print *,
' merged output field with merge field'
1029 IF(lxx.GT.0)
CALL instrument(5,kall5,ttot5,tmin5,tmax5)
1035 kpds1(4)=128+64*ib1i
1040 IF(k5.GT.0.AND.k5.LT.256)
THEN
1041 IF(ids(k5).GE.-128.AND.ids(k5).LT.128) ids1=ids(k5)
1042 IF(ibs(k5).GE.-128.AND.ibs(k5).LT.128) ibs1=ibs(k5)
1043 IF(nbs(k5).GE.0.AND.nbs(k5).LT.256) nbs1=nbs(k5)
1046 CALL putgben(lg2,mi,kpds1,kgdsi,kens1,ibs1,nbs1,l1i,f1i,iret)
1047 IF(iret.EQ.0) no=no+1
1048 IF(iret.EQ.0.AND.krv.GT.0)
THEN
1050 CALL putgben(lg2,mi,kpds1,kgdsi,kens1,ibs1,nbs1,l1i,g1i,iret)
1051 IF(iret.EQ.0) no=no+1
1056 print *,
' packing error code ',iret
1057 ELSEIF(krv.EQ.0)
THEN
1058 print *,
' wrote scalar field to record ',no
1059 print *,
' ...KPDS(1:24),IDS,IBS,NBS=', &
1060 (kpds1(i),i=1,24),ids1,ibs1,nbs1
1062 print *,
' wrote vector field to records ',no-1,no
1063 print *,
' ...KPDS(1:24)=',(kpds1(i),i=1,24)
1064 print *,
' ...KPDS(1:24)=',(kpds1(i),i=1,4), &
1065 kpds1(5)+1,(kpds1(i),i=6,24)
1067 CALL instrument(6,kall6,ttot6,tmin6,tmax6)
1173 IV,IP,IPOPT,KGDS1,K1,IB1,L1,F1,G1,KGDS2,K2, &
1179 INTEGER KGDS1(200),KGDS2(200)
1180 LOGICAL*1 L1(K1),L2(K2)
1181 REAL F1(K1),F2(K2),G1(K1),G2(K2)
1182 INTEGER KGDS1F(200),KGDS2F(200)
1183 LOGICAL*1 L1F(K1F),L2F(K2F)
1184 REAL F1F(K1F),F2F(K2F),G1F(K1F),G2F(K2F)
1185 REAL RLAT(MRL),RLON(MRL),CROT(MRO),SROT(MRO)
1188 IF(k1f.EQ.1.AND.k2f.EQ.1.AND.iv.EQ.0)
THEN
1189 CALL ipolates(ip,ipopt,kgds1,kgds2,k1,k2,1,ib1,l1,f1, &
1190 ki,rlat,rlon,ib2,l2,f2,iret)
1193 ELSEIF(k1f.NE.1.AND.k2f.EQ.1.AND.iv.EQ.0)
THEN
1195 CALL ipxwafs3(1,k1,k1f,1, &
1196 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1198 CALL ipxwafs2(1,k1,k1f,1, &
1199 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1202 CALL ipolates(ip,ipopt,kgds1f,kgds2,k1f,k2,1,ib1f,l1f,f1f, &
1203 ki,rlat,rlon,ib2,l2,f2,iret)
1207 ELSEIF(k1f.EQ.1.AND.k2f.NE.1.AND.iv.EQ.0)
THEN
1208 CALL ipolates(ip,ipopt,kgds1,kgds2f,k1,k2f,1,ib1,l1,f1, &
1209 ki,rlat,rlon,ib2f,l2f,f2f,iret)
1212 CALL ipxwafs3(-1,k2,k2f,1, &
1213 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1215 CALL ipxwafs2(-1,k2,k2f,1, &
1216 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1221 ELSEIF(k1f.NE.1.AND.k2f.NE.1.AND.iv.EQ.0)
THEN
1223 CALL ipxwafs3(1,k1,k1f,1, &
1224 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1226 CALL ipxwafs2(1,k1,k1f,1, &
1227 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1230 CALL ipolates(ip,ipopt,kgds1f,kgds2f,k1f,k2f,1,ib1f,l1f,f1f, &
1231 ki,rlat,rlon,ib2f,l2f,f2f,iret)
1234 CALL ipxwafs3(-1,k2,k2f,1, &
1235 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1237 CALL ipxwafs2(-1,k2,k2f,1, &
1238 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1244 ELSEIF(k1f.EQ.1.AND.k2f.EQ.1.AND.iv.NE.0)
THEN
1245 CALL ipolatev(ip,ipopt,kgds1,kgds2,k1,k2,1,ib1,l1,f1,g1, &
1246 ki,rlat,rlon,crot,srot,ib2,l2,f2,g2,iret)
1247 IF(iret.EQ.0.AND.ki.EQ.k2-1)
THEN
1253 ELSEIF(k1f.NE.1.AND.k2f.EQ.1.AND.iv.NE.0)
THEN
1255 CALL ipxwafs3(1,k1,k1f,1, &
1256 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1257 CALL ipxwafs3(1,k1,k1f,1, &
1258 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1260 CALL ipxwafs2(1,k1,k1f,1, &
1261 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1262 CALL ipxwafs2(1,k1,k1f,1, &
1263 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1266 CALL ipolatev(ip,ipopt,kgds1f,kgds2,k1f,k2,1, &
1268 ki,rlat,rlon,crot,srot,ib2,l2,f2,g2,iret)
1269 IF(iret.EQ.0.AND.ki.EQ.k2-1)
THEN
1276 ELSEIF(k1f.EQ.1.AND.k2f.NE.1.AND.iv.NE.0)
THEN
1277 CALL ipolatev(ip,ipopt,kgds1,kgds2f,k1,k2f,1,ib1,l1,f1,g1, &
1278 ki,rlat,rlon,crot,srot,ib2f,l2f,f2f,g2f,iret)
1281 CALL ipxwafs3(-1,k2,k2f,1, &
1282 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1283 CALL ipxwafs3(-1,k2,k2f,1, &
1284 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
1286 CALL ipxwafs2(-1,k2,k2f,1, &
1287 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1288 CALL ipxwafs2(-1,k2,k2f,1, &
1289 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
1294 ELSEIF(k1f.NE.1.AND.k2f.NE.1.AND.iv.NE.0)
THEN
1296 CALL ipxwafs3(1,k1,k1f,1, &
1297 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1298 CALL ipxwafs3(1,k1,k1f,1, &
1299 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1301 CALL ipxwafs2(1,k1,k1f,1, &
1302 kgds1,ib1,l1,f1,kgds1f,ib1f,l1f,f1f,iret)
1303 CALL ipxwafs2(1,k1,k1f,1, &
1304 kgds1,ib1,l1,g1,kgds1f,ib1f,l1f,g1f,iret)
1307 CALL ipolatev(ip,ipopt,kgds1f,kgds2f,k1f,k2f,1, &
1309 ki,rlat,rlon,crot,srot,ib2f,l2f,f2f,g2f,iret)
1312 CALL ipxwafs3(-1,k2,k2f,1, &
1313 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1314 CALL ipxwafs3(-1,k2,k2f,1, &
1315 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
1317 CALL ipxwafs2(-1,k2,k2f,1, &
1318 kgds2,ib2,l2,f2,kgds2f,ib2f,l2f,f2f,iret)
1319 CALL ipxwafs2(-1,k2,k2f,1, &
1320 kgds2,ib2,l2,g2,kgds2f,ib2f,l2f,g2f,iret)
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.