61 use vrbls3d,
only: pmid, uh, vh, t, zmid, zint, pint, alpint, q, omga
62 use vrbls3d,
only: catedr,mwt,gtg, cit
63 use vrbls2d,
only: pblh, cprate, fis, t500, t700, z500, z700,&
66 use params_mod,
only: d00, d50, h99999, h100, h1, h1m12, pq0, a2, a3, a4, &
67 rhmin, rgamog, tfrz, small, g
68 use ctlblk_mod,
only: grib, cfld, fld_info, datapd, im, jsta, jend, jm, jsta_m, jend_m, &
69 nbnd, nbin_du, lm, htfd, spval, pthresh, nfd, petabnd, me,&
70 jsta_2l, jend_2u, modelname, submodelname, &
71 ista, iend, ista_m, iend_m, ista_2l, iend_2u, &
72 ifi_flight_levels, gtg_on
73 use rqstfld_mod,
only: iget, lvls, id, iavblfld, lvlsxml
74 use grib2_module,
only: pset
75 use upp_physics,
only: fpvsnew,calrh_pw,calcape,calcape2,tvirtual
76 use gridspec_mod,
only: gridtype
83 real,
PARAMETER :: C2K=273.15
84 real,
parameter :: con_rd =2.8705e+2
85 real,
parameter :: con_rv =4.6150e+2
86 real,
parameter :: con_eps =con_rd/con_rv
87 real,
parameter :: con_epsm1 =con_rd/con_rv-1
88 real,
parameter :: cpthresh =0.000004
89 real,
PARAMETER :: D1000=1000
90 real,
PARAMETER :: D1500=1500
91 real,
PARAMETER :: D2000=2000
92 real,
PARAMETER :: HCONST=42000000.
93 real,
PARAMETER :: K2C=273.16
94 REAL,
PARAMETER :: DM9999=-9999.0
99 LOGICAL NORTH, FIELD1,FIELD2, NEED_IFI
100 LOGICAL,
dimension(ISTA:IEND,JSTA:JEND) :: DONE, DONE1
102 INTEGER,
allocatable :: LVLBND(:,:,:),LB2(:,:)
105 real,
dimension(im,jm) :: GRID1, GRID2
106 real,
dimension(ista:iend,jsta:jend) :: P1D, T1D, Q1D, U1D, V1D, SHR1D, Z1D, &
107 rh1d, egrid1, egrid2, egrid3, egrid4, &
108 egrid5, egrid6, egrid7, egrid8, &
109 mlcape,mlcin,mllcl,mucape,mucin, &
110 freezelvl,muq1d,slcl,the,maxthe
111 integer,
dimension(ista:iend,jsta:jend) :: MAXTHEPOS
112 real,
dimension(:,:,:),
allocatable :: OMGBND, PWTBND, QCNVBND, &
119 real,
dimension(:,:),
allocatable :: QM8510, RH4710, RH8498, &
120 rh4796, rh1847, ust, vst, &
121 rh3310, rh6610, rh3366, &
122 pw3310, rh4410, rh7294, &
124 t78483, t89671, p78483, p89671
126 REAL,
dimension(:,:,:),
allocatable :: HELI
127 real,
dimension(:,:),
allocatable :: USHR1, VSHR1, USHR6, VSHR6, &
128 maxwp, maxwz, maxwu, maxwv, &
130 INTEGER,
dimension(:,:),
allocatable :: LLOW,LUPP,LLOW_ZINT,IEQL_ZINT, &
132 REAL,
dimension(:,:),
allocatable :: CANGLE,ESHR,UVECT,VVECT,&
133 effust,effvst,fshr,htsfc,&
136 integer I,J,ii,jj,L,ITYPE,ISVALUE,LBND,ILVL,IFD,ITYPEFDLVL(NFD), &
137 iget1, iget2, iget3, llmh,imax,jmax,lmax
138 real DPBND,PKL1,PKU1,FAC1,FAC2,PL,TL,QL,QSAT,RHL,TVRL,TVRBLO, &
139 es1,es2,qs1,qs2,rh1,rh2,zsf,depth(2),work1,work2,work3, &
140 scintmp,mucapetmp,mucintmp,mllcltmp,eshrtmp,mlcapetmp,stp,&
141 fshrtmp,mlcintmp,slcltmp,lapse,ship
143 integer IE,IW,JN,JS,IVE(JM),IVW(JM),JVN,JVS
144 integer ISTART,ISTOP,JSTART,JSTOP
145 real dummy(ista:iend,jsta:jend)
146 integer idummy(ista:iend,jsta:jend)
148 INTEGER,
dimension(:,:),
allocatable :: EL_BASE, EL_TOPS
149 LOGICAL,
dimension(:,:),
allocatable :: FOUND_BASE, FOUND_TOPS
150 INTEGER,
dimension(:,:),
allocatable :: L_THETAE_MAX
151 INTEGER,
dimension(:,:),
allocatable :: CAPE9, CINS9
152 CHARACTER(LEN=5) :: IM_CH, JSTA_CH, JEND_CH, ME_CH
153 CHARACTER(LEN=60) :: EFFL_FNAME
154 CHARACTER(LEN=60) :: EFFL_FNAME2
155 INTEGER :: IREC, IUNIT
156 INTEGER :: IREC2, IUNIT2
157 LOGICAL :: debugprint
159 INTEGER :: LLCL_PAR, LEQL_PAR
160 REAL :: LMASK, PSFC, CAPE_PAR, CINS_PAR, LPAR0
161 REAL,
DIMENSION(4) :: PARCEL0
162 REAL,
DIMENSION(:),
ALLOCATABLE :: TPAR_B, TPAR_T
163 REAL,
DIMENSION(:),
ALLOCATABLE :: TPAR_TMP
164 REAL,
DIMENSION(:),
ALLOCATABLE :: P_AMB, T_AMB, Q_AMB, ZINT_AMB
165 REAL,
DIMENSION(:,:,:),
ALLOCATABLE :: TPAR_BASE, TPAR_TOPS
169 REAL,
allocatable :: HTFDCTL(:)
170 integer,
allocatable :: ITYPEFDLVLCTL(:)
171 real,
allocatable :: QIN(:,:,:,:), QFD(:,:,:,:)
172 character,
allocatable :: QTYPE(:)
174 integer,
parameter :: NFDMAX=10
175 integer :: IDS(NFDMAX)
184 need_ifi = iget(1007)>0 .or. iget(1008)>0 .or. iget(1009)>0 .or. iget(1010)>0
186 allocate(ushr1(ista_2l:iend_2u,jsta_2l:jend_2u),vshr1(ista_2l:iend_2u,jsta_2l:jend_2u), &
187 ushr6(ista_2l:iend_2u,jsta_2l:jend_2u),vshr6(ista_2l:iend_2u,jsta_2l:jend_2u))
188 allocate(ust(ista_2l:iend_2u,jsta_2l:jend_2u),vst(ista_2l:iend_2u,jsta_2l:jend_2u), &
189 heli(ista_2l:iend_2u,jsta_2l:jend_2u,2),fshr(ista_2l:iend_2u,jsta_2l:jend_2u))
196 iget2 = lvls(1,iget1)
197 iget3 = lvls(2,iget1)
199 IF (iget1 > 0 .OR. iget(163) > 0 .OR. iget(164) > 0)
THEN
202 CALL calhel(depth,ust,vst,heli,ushr1,vshr1,ushr6,vshr6)
207 grid1(i,j) = heli(i,j,1)
210 if(grib==
'grib2')
then
212 fld_info(cfld)%ifld=iavblfld(iget1)
213 fld_info(cfld)%lvl=lvlsxml(1,iget1)
219 datapd(i,j,cfld) = grid1(ii,jj)
229 grid1(i,j) = heli(i,j,2)
232 if(grib==
'grib2')
then
234 fld_info(cfld)%ifld=iavblfld(iget1)
235 fld_info(cfld)%lvl=lvlsxml(2,iget1)
241 datapd(i,j,cfld) = grid1(ii,jj)
247 IF (iget(163) > 0)
THEN
251 grid1(i,j) = ust(i,j)
254 if(grib==
'grib2')
then
256 fld_info(cfld)%ifld=iavblfld(iget(163))
262 datapd(i,j,cfld) = grid1(ii,jj)
267 IF (iget(164) > 0)
THEN
271 grid1(i,j) = vst(i,j)
274 if(grib==
'grib2')
then
276 fld_info(cfld)%ifld=iavblfld(iget(164))
282 datapd(i,j,cfld) = grid1(ii,jj)
291 if (iget(427) > 0)
THEN
292 CALL calupdhel(grid1(ista_2l:iend_2u,jsta_2l:jend_2u))
293 if(grib==
'grib2')
then
295 fld_info(cfld)%ifld=iavblfld(iget(427))
301 datapd(i,j,cfld) = grid1(ii,jj)
310 IF(iget(430) > 0 .OR. iget(431) > 0 .OR. iget(432) > 0 &
311 .OR. iget(433) > 0)
THEN
314 CALL calhel(depth,ust,vst,heli,ushr1,vshr1,ushr6,vshr6)
319 fshr(i,j) = sqrt(ushr6(i,j)**2+vshr6(i,j)**2)
322 IF(iget(430) > 0)
THEN
326 grid1(i,j) = ushr1(i,j)
329 if(grib==
'grib2')
then
331 fld_info(cfld)%ifld=iavblfld(iget(430))
337 datapd(i,j,cfld) = grid1(ii,jj)
342 IF(iget(431) > 0)
THEN
346 grid1(i,j) = vshr1(i,j)
349 if(grib==
'grib2')
then
351 fld_info(cfld)%ifld=iavblfld(iget(431))
357 datapd(i,j,cfld) = grid1(ii,jj)
362 IF(iget(432) > 0)
THEN
366 grid1(i,j) = ushr6(i,j)
369 if(grib==
'grib2')
then
371 fld_info(cfld)%ifld=iavblfld(iget(432))
377 datapd(i,j,cfld) = grid1(ii,jj)
382 IF(iget(433) > 0)
THEN
386 grid1(i,j) = vshr6(i,j)
389 if(grib==
'grib2')
then
391 fld_info(cfld)%ifld=iavblfld(iget(433))
397 datapd(i,j,cfld) = grid1(ii,jj)
404 if (
allocated(ushr1))
deallocate(ushr1)
405 if (
allocated(vshr1))
deallocate(vshr1)
406 if (
allocated(ushr6))
deallocate(ushr6)
407 if (
allocated(vshr6))
deallocate(vshr6)
408 if (
allocated(ust))
deallocate(ust)
409 if (
allocated(vst))
deallocate(vst)
410 if (
allocated(heli))
deallocate(heli)
416 IF ((iget(054)>0).OR.(iget(055)>0).OR. &
417 (iget(056)>0).OR.(iget(057)>0).OR. &
419 (iget(058)>0).OR.(iget(108)>0) )
THEN
425 if(pmid(i,j,1)<spval)
then
427 CALL tpause(lm,pmid(i,j,1:lm),uh(i,j,1:lm) &
429 ,vh(i,j,1:lm),t(i,j,1:lm),zmid(i,j,1:lm) &
431 ,p1d(i,j),u1d(i,j),v1d(i,j),t1d(i,j) &
433 ,z1d(i,j),shr1d(i,j))
447 IF (iget(054) > 0)
THEN
451 grid1(i,j) = p1d(i,j)
454 if(grib==
'grib2')
then
456 fld_info(cfld)%ifld=iavblfld(iget(054))
462 datapd(i,j,cfld) = grid1(ii,jj)
469 IF (iget(399)>0)
THEN
470 CALL icaoheight(p1d, grid1(ista:iend,jsta:jend))
472 if(grib==
'grib2')
then
474 fld_info(cfld)%ifld=iavblfld(iget(399))
480 datapd(i,j,cfld) = grid1(ii,jj)
487 IF (iget(177) > 0)
THEN
491 grid1(i,j) = z1d(i,j)
494 if(grib==
'grib2')
then
496 fld_info(cfld)%ifld=iavblfld(iget(177))
502 datapd(i,j,cfld) = grid1(ii,jj)
509 IF (iget(055) > 0)
THEN
513 grid1(i,j) = t1d(i,j)
516 if(grib==
'grib2')
then
518 fld_info(cfld)%ifld=iavblfld(iget(055))
524 datapd(i,j,cfld) = grid1(ii,jj)
531 IF (iget(108) > 0)
THEN
532 CALL calpot(p1d,t1d,grid1(ista:iend,jsta:jend))
533 if(grib==
'grib2')
then
535 fld_info(cfld)%ifld=iavblfld(iget(108))
541 datapd(i,j,cfld) = grid1(ii,jj)
548 IF ((iget(056) > 0).OR.(iget(057) > 0))
THEN
556 if(grib==
'grib2')
then
559 fld_info(cfld)%ifld=iavblfld(iget(056))
565 datapd(i,j,cfld) = grid1(ii,jj)
571 fld_info(cfld)%ifld=iavblfld(iget(057))
577 datapd(i,j,cfld) = grid2(ii,jj)
585 IF (iget(058) > 0)
THEN
589 grid1(i,j) = shr1d(i,j)
592 if(grib==
'grib2')
then
594 fld_info(cfld)%ifld=iavblfld(iget(058))
600 datapd(i,j,cfld) = grid1(ii,jj)
611 IF ((iget(173)>0) .OR. (iget(174)>0) .OR. &
612 (iget(175)>0) .OR. (iget(176)>0))
THEN
614 allocate(maxwp(ista:iend,jsta:jend), maxwz(ista:iend,jsta:jend), &
615 maxwu(ista:iend,jsta:jend), maxwv(ista:iend,jsta:jend),maxwt(ista:iend,jsta:jend))
632 IF (abs(pmid(i,j,l)-spval)<=small .OR. &
633 abs(uh(i,j,l)-spval)<=small .OR. &
634 abs(uh(i,j,l)-spval)<=small .OR. &
635 abs(vh(i,j,l)-spval)<=small .OR. &
636 abs(t(i,j,l)-spval)<=small .OR. &
637 abs(zmid(i,j,l)-spval)<=small) cycle loopi
640 CALL mxwind(lm,pmid(i,j,1:lm),uh(i,j,1:lm) &
642 ,vh(i,j,1:lm),t(i,j,1:lm),zmid(i,j,1:lm) &
644 ,maxwp(i,j),maxwu(i,j),maxwv(i,j) &
646 ,maxwt(i,j),maxwz(i,j))
650 IF (iget(173) > 0)
THEN
654 grid1(i,j) = maxwp(i,j)
657 if(grib==
'grib2')
then
659 fld_info(cfld)%ifld=iavblfld(iget(173))
665 datapd(i,j,cfld) = grid1(ii,jj)
671 IF (iget(398)>0)
THEN
672 CALL icaoheight(maxwp, grid1(ista:iend,jsta:jend))
674 if(grib==
'grib2')
then
676 fld_info(cfld)%ifld=iavblfld(iget(398))
682 datapd(i,j,cfld) = grid1(ii,jj)
688 IF (iget(174) > 0)
THEN
692 grid1(i,j) = maxwz(i,j)
695 if(grib==
'grib2')
then
697 fld_info(cfld)%ifld=iavblfld(iget(174))
703 datapd(i,j,cfld) = grid1(ii,jj)
710 IF ((iget(175) > 0).OR.(iget(176) > 0))
THEN
714 grid1(i,j) = maxwu(i,j)
715 grid2(i,j) = maxwv(i,j)
718 if(grib==
'grib2')
then
720 fld_info(cfld)%ifld=iavblfld(iget(175))
726 datapd(i,j,cfld) = grid1(ii,jj)
730 fld_info(cfld)%ifld=iavblfld(iget(176))
736 datapd(i,j,cfld) = grid2(ii,jj)
742 IF (iget(314) > 0)
THEN
746 grid1(i,j)=maxwt(i,j)
749 if(grib==
'grib2')
then
751 fld_info(cfld)%ifld=iavblfld(iget(314))
757 datapd(i,j,cfld) = grid1(ii,jj)
762 deallocate(maxwp,maxwz,maxwu,maxwv,maxwt)
768 IF ( (iget(059)>0.or.iget(586)>0).OR.iget(911)>0.OR. &
769 (iget(060)>0.or.iget(576)>0).OR. &
770 (iget(061)>0.or.iget(577)>0).OR. &
771 (iget(451)>0.or.iget(578)>0).OR.iget(580)>0 )
THEN
773 ALLOCATE(t7d(ista:iend,jsta:jend,nfd), q7d(ista:iend,jsta:jend,nfd), &
774 u7d(ista:iend,jsta:jend,nfd), v6d(ista:iend,jsta:jend,nfd), &
775 p7d(ista:iend,jsta:jend,nfd), icingfd(ista:iend,jsta:jend,nfd))
782 IF (iget(059)>0)
THEN
783 IF (lvls(ifd,iget(059))>1) itypefdlvl(ifd)=2
785 IF (iget(911)>0)
THEN
786 IF (lvls(ifd,iget(911))>1) itypefdlvl(ifd)=2
789 IF (iget(586)>0)
THEN
790 IF(lvls(ifd,iget(586))>0) itypefdlvl(ifd)=2
792 IF (iget(060)>0)
THEN
793 IF (lvls(ifd,iget(060))>1) itypefdlvl(ifd)=2
795 IF (iget(576)>0)
THEN
796 IF(lvls(ifd,iget(576))>0) itypefdlvl(ifd)=2
798 IF (iget(061)>0)
THEN
799 IF (lvls(ifd,iget(061))>1) itypefdlvl(ifd)=2
801 IF (iget(577)>0)
then
802 if(lvls(ifd,iget(577))>0) itypefdlvl(ifd)=2
804 IF (iget(451)>0)
THEN
805 IF (lvls(ifd,iget(451))>1) itypefdlvl(ifd)=2
807 IF (iget(578)>0)
then
808 if(lvls(ifd,iget(578))>0) itypefdlvl(ifd)=2
811 IF (iget(580)>0)
then
812 if(lvls(ifd,iget(580))>1) itypefdlvl(ifd)=2
814 IF (iget(587)>0)
then
815 if(lvls(ifd,iget(587))>0) itypefdlvl(ifd)=2
822 CALL fdlvl(itypefdlvl,t7d,q7d,u7d,v6d,p7d,icingfd)
824 loop_10:
DO ifd = 1,nfd
830 work1 = lvls(ifd,iget1)
835 work2 = lvls(ifd,iget2)
839 IF (iget1 > 0 .or. iget2 > 0)
THEN
840 IF (work1 > 0 .or. work2 > 0)
THEN
845 grid1(i,j) = t7d(i,j,ifd)
849 if(grib ==
'grib2')
then
851 fld_info(cfld)%ifld = iavblfld(iget1)
852 fld_info(cfld)%lvl = lvlsxml(ifd,iget1)
858 datapd(i,j,cfld) = grid1(ii,jj)
864 if(grib ==
'grib2')
then
866 fld_info(cfld)%ifld = iavblfld(iget2)
867 fld_info(cfld)%lvl = lvlsxml(ifd,iget2)
873 datapd(i,j,cfld) = grid1(ii,jj)
882 IF (iget(911)>0)
THEN
883 IF (lvls(ifd,iget(911))>0)
THEN
886 if ( t7d(i,j,ifd) > 600 )
then
889 grid1(i,j)=t7d(i,j,ifd)*(1.+0.608*q7d(i,j,ifd))
894 IF(lvls(ifd,iget(911))>0)
then
895 if(grib==
'grib2')
then
897 fld_info(cfld)%ifld=iavblfld(iget(911))
898 fld_info(cfld)%lvl=lvlsxml(ifd,iget(911))
899 datapd(1:iend-ista+1,1:jend-jsta+1,cfld)=grid1(ista:iend,jsta:jend)
910 work1 = lvls(ifd,iget1)
915 work2 = lvls(ifd,iget2)
919 IF (iget1 > 0 .or. iget2 > 0)
THEN
920 IF (work1 > 0 .or. work2 > 0)
THEN
924 grid1(i,j) = q7d(i,j,ifd)
928 if(grib ==
'grib2')
then
930 fld_info(cfld)%ifld = iavblfld(iget1)
931 fld_info(cfld)%lvl = lvlsxml(ifd,iget1)
937 datapd(i,j,cfld) = grid1(ii,jj)
943 if(grib ==
'grib2')
then
945 fld_info(cfld)%ifld = iavblfld(iget2)
946 fld_info(cfld)%lvl = lvlsxml(ifd,iget2)
952 datapd(i,j,cfld) = grid1(ii,jj)
964 work1 = lvls(ifd,iget1)
969 work2 = lvls(ifd,iget2)
973 IF (iget1 > 0 .or. iget2 > 0)
THEN
974 IF (work1 > 0 .or. work2 > 0)
THEN
978 grid1(i,j) = p7d(i,j,ifd)
982 if(grib ==
'grib2')
then
984 fld_info(cfld)%ifld = iavblfld(iget1)
985 fld_info(cfld)%lvl = lvlsxml(ifd,iget1)
991 datapd(i,j,cfld) = grid1(ii,jj)
997 if(grib ==
'grib2')
then
999 fld_info(cfld)%ifld = iavblfld(iget2)
1000 fld_info(cfld)%lvl = lvlsxml(ifd,iget2)
1006 datapd(i,j,cfld) = grid1(ii,jj)
1018 work1 = lvls(ifd,iget1)
1023 work2 = lvls(ifd,iget2)
1027 IF (iget1 > 0 .or. iget2 > 0)
THEN
1028 IF (work1 > 0 .or. work2 > 0)
THEN
1032 grid1(i,j) = icingfd(i,j,ifd)
1036 if(grib ==
'grib2')
then
1038 fld_info(cfld)%ifld = iavblfld(iget1)
1039 fld_info(cfld)%lvl = lvlsxml(ifd,iget1)
1045 datapd(i,j,cfld) = grid1(ii,jj)
1051 if(grib ==
'grib2')
then
1053 fld_info(cfld)%ifld = iavblfld(iget2)
1054 fld_info(cfld)%lvl = lvlsxml(ifd,iget2)
1060 datapd(i,j,cfld) = grid1(ii,jj)
1073 IF ((iget(060)>0).OR.(iget(061)>0))
THEN
1077 grid1(i,j)=u7d(i,j,ifd)
1078 grid2(i,j)=v6d(i,j,ifd)
1081 IF (iget(060)>0)
THEN
1082 IF (lvls(ifd,iget(060))>0)
then
1083 if(grib==
'grib2')
then
1085 fld_info(cfld)%ifld=iavblfld(iget(060))
1086 fld_info(cfld)%lvl=lvlsxml(ifd,iget(060))
1092 datapd(i,j,cfld) = grid1(ii,jj)
1098 IF (iget(061)>0)
THEN
1099 IF (lvls(ifd,iget(061))>0)
THEN
1100 if(grib==
'grib2')
then
1102 fld_info(cfld)%ifld=iavblfld(iget(061))
1103 fld_info(cfld)%lvl=lvlsxml(ifd,iget(061))
1109 datapd(i,j,cfld) = grid2(ii,jj)
1118 IF ((iget(576)>0).OR.(iget(577)>0))
THEN
1122 grid1(i,j) = u7d(i,j,ifd)
1123 grid2(i,j) = v6d(i,j,ifd)
1126 IF (iget(576)>0)
THEN
1127 IF (lvls(ifd,iget(576))>0)
then
1128 if(grib==
'grib2')
then
1130 fld_info(cfld)%ifld=iavblfld(iget(576))
1131 fld_info(cfld)%lvl=lvlsxml(ifd,iget(576))
1137 datapd(i,j,cfld) = grid1(ii,jj)
1143 IF (iget(577)>0)
THEN
1144 IF (lvls(ifd,iget(577))>0)
THEN
1145 if(grib==
'grib2')
then
1147 fld_info(cfld)%ifld=iavblfld(iget(577))
1148 fld_info(cfld)%lvl=lvlsxml(ifd,iget(577))
1154 datapd(i,j,cfld) = grid2(ii,jj)
1163 DEALLOCATE(t7d,q7d,u7d,v6d,p7d,icingfd)
1169 IF(gtg_on .and. (iget(467)>0.or.iget(468)>0.or.iget(469)>0.or.iget(477)>0))
THEN
1171 if(
allocated(qin))
deallocate(qin)
1172 if(
allocated(qtype))
deallocate(qtype)
1173 ALLOCATE(qin(ista:iend,jsta:jend,lm,nfdmax))
1174 ALLOCATE(qtype(nfdmax))
1178 IF(iget(467) > 0)
THEN
1181 qin(ista:iend,jsta:jend,1:lm,nfds)=gtg(ista:iend,jsta:jend,1:lm)
1184 IF(iget(468) > 0)
THEN
1187 qin(ista:iend,jsta:jend,1:lm,nfds)=catedr(ista:iend,jsta:jend,1:lm)
1190 IF(iget(469) > 0)
THEN
1193 qin(ista:iend,jsta:jend,1:lm,nfds)=mwt(ista:iend,jsta:jend,1:lm)
1197 IF(iget(477) > 0)
THEN
1200 qin(ista:iend,jsta:jend,1:lm,nfds)=cit(ista:iend,jsta:jend,1:lm)
1207 n = iavblfld(iget(iid))
1208 nfdctl=
size(pset%param(n)%level)
1209 if(
allocated(itypefdlvlctl))
deallocate(itypefdlvlctl)
1210 allocate(itypefdlvlctl(nfdctl))
1212 itypefdlvlctl(ifd)=lvls(ifd,iget(iid))
1214 if(
allocated(htfdctl))
deallocate(htfdctl)
1215 allocate(htfdctl(nfdctl))
1216 htfdctl=pset%param(n)%level
1218 if(
allocated(qfd))
deallocate(qfd)
1219 ALLOCATE(qfd(ista:iend,jsta:jend,nfdctl,nfds))
1223 call fdlvl_mass(itypefdlvlctl,nfdctl,pset%param(n)%level,htfdctl,nfds,qin,qtype,qfd)
1228 if(iid==467 .or. iid==468 .or. iid==469 .or. iid==477)
then
1232 if(qfd(i,j,ifd,n) < spval)
then
1233 qfd(i,j,ifd,n)=max(0.0,qfd(i,j,ifd,n))
1234 qfd(i,j,ifd,n)=min(1.0,qfd(i,j,ifd,n))
1248 if (iid == 467 .and. iget(476) > 0)
then
1253 work1=qfd(i,j,ifd,n)
1254 if(egrid1(i,j)>=spval)
then
1256 elseif(work1<spval)
then
1257 if(egrid1(i,j)<work1) egrid1(i,j)=work1
1264 grid1(i,j)=egrid1(i,j)
1267 if(grib==
'grib2')
then
1269 fld_info(cfld)%ifld=iavblfld(iget(476))
1275 datapd(i,j,cfld) = grid1(ii,jj)
1282 IF (lvls(ifd,iget(iid)) > 0)
THEN
1286 grid1(i,j)=qfd(i,j,ifd,n)
1289 if(grib==
'grib2')
then
1291 fld_info(cfld)%ifld=iavblfld(iget(iid))
1292 fld_info(cfld)%lvl=lvlsxml(ifd,iget(iid))
1298 datapd(i,j,cfld) = grid1(ii,jj)
1308 if(
allocated(itypefdlvlctl))
deallocate(itypefdlvlctl)
1309 if(
allocated(htfdctl))
deallocate(htfdctl)
1316 IF ( (iget(062)>0).OR.(iget(063)>0) )
THEN
1317 CALL frzlvl(z1d,rh1d,p1d)
1320 IF (iget(062)>0)
THEN
1325 IF (submodelname ==
'RTMA')
THEN
1326 freezelvl(i,j)=grid1(i,j)
1330 CALL bound (grid1,d00,h99999)
1331 if(grib==
'grib2')
then
1333 fld_info(cfld)%ifld=iavblfld(iget(062))
1339 datapd(i,j,cfld) = grid1(ii,jj)
1346 IF (iget(063)>0)
THEN
1350 grid1(i,j) = rh1d(i,j)
1353 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
1354 CALL bound(grid1,h1,h100)
1355 if(grib==
'grib2')
then
1357 fld_info(cfld)%ifld=iavblfld(iget(063))
1363 datapd(i,j,cfld) = grid1(ii,jj)
1370 IF (iget(753)>0)
THEN
1374 grid1(i,j) = p1d(i,j)
1377 if(grib==
'grib2')
then
1379 fld_info(cfld)%ifld=iavblfld(iget(753))
1385 datapd(i,j,cfld) = grid1(ii,jj)
1393 IF (iget(165)>0 .OR. iget(350)>0.OR. iget(756)>0)
THEN
1394 CALL frzlvl2(tfrz,z1d,rh1d,p1d)
1397 IF (iget(165)>0)
THEN
1404 CALL bound (grid1,d00,h99999)
1405 if(grib==
'grib2')
then
1407 fld_info(cfld)%ifld=iavblfld(iget(165))
1413 datapd(i,j,cfld) = grid1(ii,jj)
1420 IF (iget(350)>0)
THEN
1425 IF(rh1d(i,j) < spval) grid1(i,j)=rh1d(i,j)*100.
1428 CALL bound (grid1,h1,h100)
1429 if(grib==
'grib2')
then
1431 fld_info(cfld)%ifld=iavblfld(iget(350))
1437 datapd(i,j,cfld) = grid1(ii,jj)
1444 IF (iget(756)>0)
THEN
1448 grid1(i,j) = p1d(i,j)
1451 if(grib==
'grib2')
then
1453 fld_info(cfld)%ifld=iavblfld(iget(756))
1459 datapd(i,j,cfld) = grid1(ii,jj)
1469 IF (iget(776)>0 .OR. iget(777)>0.OR. iget(778)>0)
THEN
1470 CALL frzlvl2(263.15,z1d,rh1d,p1d)
1473 IF (iget(776)>0)
THEN
1480 CALL bound (grid1,d00,h99999)
1481 if(grib==
'grib2')
then
1483 fld_info(cfld)%ifld=iavblfld(iget(776))
1489 datapd(i,j,cfld) = grid1(ii,jj)
1496 IF (iget(777)>0)
THEN
1501 IF(rh1d(i,j) < spval) grid1(i,j)=rh1d(i,j)*100.
1504 CALL bound (grid1,h1,h100)
1505 if(grib==
'grib2')
then
1507 fld_info(cfld)%ifld=iavblfld(iget(777))
1513 datapd(i,j,cfld) = grid1(ii,jj)
1520 IF (iget(778)>0)
THEN
1527 if(grib==
'grib2')
then
1529 fld_info(cfld)%ifld=iavblfld(iget(778))
1535 datapd(i,j,cfld) = grid1(ii,jj)
1545 IF (iget(779)>0 .OR. iget(780)>0.OR. iget(781)>0)
THEN
1546 CALL frzlvl2(253.15,z1d,rh1d,p1d)
1549 IF (iget(779)>0)
THEN
1556 CALL bound (grid1,d00,h99999)
1557 if(grib==
'grib2')
then
1559 fld_info(cfld)%ifld=iavblfld(iget(779))
1565 datapd(i,j,cfld) = grid1(ii,jj)
1572 IF (iget(780)>0)
THEN
1577 IF(rh1d(i,j) < spval) grid1(i,j)=rh1d(i,j)*100.
1580 CALL bound (grid1,h1,h100)
1581 if(grib==
'grib2')
then
1583 fld_info(cfld)%ifld=iavblfld(iget(780))
1589 datapd(i,j,cfld) = grid1(ii,jj)
1596 IF (iget(781)>0)
THEN
1603 if(grib==
'grib2')
then
1605 fld_info(cfld)%ifld=iavblfld(iget(781))
1611 datapd(i,j,cfld) = grid1(ii,jj)
1619 allocate(pbnd(ista:iend,jsta:jend,nbnd), tbnd(ista:iend,jsta:jend,nbnd), &
1620 qbnd(ista:iend,jsta:jend,nbnd), ubnd(ista:iend,jsta:jend,nbnd), &
1621 vbnd(ista:iend,jsta:jend,nbnd), rhbnd(ista:iend,jsta:jend,nbnd), &
1622 wbnd(ista:iend,jsta:jend,nbnd))
1627 IF ( (iget(067)>0).OR.(iget(068)>0).OR. &
1628 (iget(069)>0).OR.(iget(070)>0).OR. &
1629 (iget(071)>0).OR.(iget(072)>0).OR. &
1630 (iget(073)>0).OR.(iget(074)>0).OR. &
1631 (iget(088)>0).OR.(iget(089)>0).OR. &
1632 (iget(090)>0).OR.(iget(075)>0).OR. &
1633 (iget(109)>0).OR.(iget(110)>0).OR. &
1634 (iget(031)>0).OR.(iget(032)>0).OR. &
1635 (iget(573)>0).OR. need_ifi .OR. &
1636 (iget(107)>0).OR.(iget(091)>0).OR. &
1637 (iget(092)>0).OR.(iget(093)>0).OR. &
1638 (iget(094)>0).OR.(iget(095)>0).OR. &
1639 (iget(096)>0).OR.(iget(097)>0).OR. &
1640 (iget(098)>0).OR.(iget(221)>0) )
THEN
1642 call allocate_cape_arrays
1644 CALL bndlyr(pbnd,tbnd,qbnd,rhbnd,ubnd,vbnd, &
1645 wbnd,omgbnd,pwtbnd,qcnvbnd,lvlbnd)
1656 boundary_layer_loop:
DO lbnd = 1,nbnd
1659 IF (iget(067)>0)
THEN
1660 IF (lvls(lbnd,iget(067))>0)
THEN
1664 grid1(i,j) = pbnd(i,j,lbnd)
1667 if(grib==
'grib2')
then
1669 fld_info(cfld)%ifld=iavblfld(iget(067))
1670 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(067))
1676 datapd(i,j,cfld) = grid1(ii,jj)
1684 IF (iget(068)>0)
THEN
1685 IF (lvls(lbnd,iget(068))>0)
THEN
1689 grid1(i,j)=tbnd(i,j,lbnd)
1692 if(grib==
'grib2')
then
1694 fld_info(cfld)%ifld=iavblfld(iget(068))
1695 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(068))
1701 datapd(i,j,cfld) = grid1(ii,jj)
1709 IF (iget(069)>0)
THEN
1710 IF (lvls(lbnd,iget(069))>0)
THEN
1711 CALL calpot(pbnd(ista,jsta,lbnd),tbnd(ista,jsta,lbnd),grid1(ista:iend,jsta:jend))
1712 if(grib==
'grib2')
then
1714 fld_info(cfld)%ifld=iavblfld(iget(069))
1715 fld_info(cfld)%lvl=lvlsxml(ifd,iget(069))
1721 datapd(i,j,cfld) = grid1(ii,jj)
1729 IF (iget(072)>0)
THEN
1730 IF (lvls(lbnd,iget(072))>0)
THEN
1734 grid1(i,j)=rhbnd(i,j,lbnd)
1737 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
1738 CALL bound(grid1,h1,h100)
1739 if(grib==
'grib2')
then
1741 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(072))
1742 fld_info(cfld)%ifld=iavblfld(iget(072))
1748 datapd(i,j,cfld) = grid1(ii,jj)
1756 IF (iget(070)>0)
THEN
1757 IF (lvls(lbnd,iget(070))>0)
THEN
1758 CALL caldwp(pbnd(ista:iend,jsta:jend,lbnd), qbnd(ista:iend,jsta:jend,lbnd), &
1759 grid1(ista:iend,jsta:jend), tbnd(ista:iend,jsta:jend,lbnd))
1760 if(grib==
'grib2')
then
1762 fld_info(cfld)%ifld=iavblfld(iget(070))
1763 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(070))
1769 datapd(i,j,cfld) = grid1(ii,jj)
1777 IF (iget(071)>0)
THEN
1778 IF (lvls(lbnd,iget(071))>0)
THEN
1782 grid1(i,j)=qbnd(i,j,lbnd)
1785 CALL bound(grid1,h1m12,h99999)
1786 if(grib==
'grib2')
then
1788 fld_info(cfld)%ifld=iavblfld(iget(071))
1789 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(071))
1795 datapd(i,j,cfld) = grid1(ii,jj)
1803 IF (iget(088)>0)
THEN
1804 IF (lvls(lbnd,iget(088))>0)
THEN
1808 grid1(i,j) = qcnvbnd(i,j,lbnd)
1811 if(grib==
'grib2')
then
1813 fld_info(cfld)%ifld=iavblfld(iget(088))
1814 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(088))
1820 datapd(i,j,cfld) = grid1(ii,jj)
1833 IF(lvls(lbnd,iget(073))>0)field1=.true.
1836 IF(lvls(lbnd,iget(074))>0)field2=.true.
1839 IF(field1.OR.field2)
THEN
1843 grid1(i,j) = ubnd(i,j,lbnd)
1844 grid2(i,j) = vbnd(i,j,lbnd)
1848 IF (iget(073)>0)
THEN
1849 IF (lvls(lbnd,iget(073))>0)
then
1850 if(grib==
'grib2')
then
1852 fld_info(cfld)%ifld=iavblfld(iget(073))
1853 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(073))
1859 datapd(i,j,cfld) = grid1(ii,jj)
1865 IF (iget(074)>0)
THEN
1866 IF (lvls(lbnd,iget(074))>0)
THEN
1867 if(grib==
'grib2')
then
1869 fld_info(cfld)%ifld=iavblfld(iget(074))
1870 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(074))
1876 datapd(i,j,cfld) = grid2(ii,jj)
1885 IF (iget(090)>0)
THEN
1886 IF (lvls(lbnd,iget(090))>0)
THEN
1890 grid1(i,j) = omgbnd(i,j,lbnd)
1893 if(grib==
'grib2')
then
1895 fld_info(cfld)%ifld=iavblfld(iget(090))
1896 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(090))
1902 datapd(i,j,cfld) = grid1(ii,jj)
1910 IF (iget(089)>0)
THEN
1911 IF (lvls(lbnd,iget(089))>0)
THEN
1915 grid1(i,j) = pwtbnd(i,j,lbnd)
1918 CALL bound(grid1,d00,h99999)
1919 if(grib==
'grib2')
then
1921 fld_info(cfld)%ifld=iavblfld(iget(089))
1922 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(089))
1928 datapd(i,j,cfld) = grid1(ii,jj)
1936 IF (iget(075)>0 .OR. iget(031)>0 .OR. iget(573)>0)
THEN
1937 CALL otlft(pbnd(ista,jsta,lbnd),tbnd(ista,jsta,lbnd), &
1938 qbnd(ista,jsta,lbnd),grid1(ista:iend,jsta:jend))
1940 IF (lvls(lbnd,iget(075))>0)
THEN
1941 if(grib==
'grib2')
then
1943 fld_info(cfld)%ifld=iavblfld(iget(075))
1944 fld_info(cfld)%lvl=lvlsxml(lbnd,iget(075))
1950 datapd(i,j,cfld) = grid1(ii,jj)
1956 IF(iget(031)>0 .or. iget(573)>0)
THEN
1960 egrid2(i,j) = min(egrid2(i,j),grid1(i,j))
1967 END DO boundary_layer_loop
1968 deallocate(omgbnd,pwtbnd,qcnvbnd)
1972 IF (iget(031)>0 .OR. iget(573)>0 )
THEN
1992 grid1(i,j)=egrid2(i,j)
1997 if (iget(031)>0)
then
1998 if(grib==
'grib2')
then
2000 fld_info(cfld)%ifld=iavblfld(iget(031))
2001 datapd(1:iend-ista+1,1:jend-jsta+1,cfld)=grid1(ista:iend,jsta:jend)
2005 if(iget(573)> 0 )
THEN
2006 if(grib==
'grib2')
then
2008 fld_info(cfld)%ifld=iavblfld(iget(573))
2014 datapd(i,j,cfld) = grid1(ii,jj)
2028 IF(lvls(2,iget(032))>0)field1=.true.
2031 IF(lvls(2,iget(107))>0)field2=.true.
2046 IF(field1.OR.field2.OR.need_ifi)
THEN
2048 call allocate_cape_arrays
2053 egrid1(i,j) = -h99999
2054 egrid2(i,j) = -h99999
2058 loop_80:
DO lbnd = 1,nbnd
2059 CALL calthte(pbnd(ista,jsta,lbnd),tbnd(ista,jsta,lbnd), &
2060 qbnd(ista,jsta,lbnd),egrid1)
2064 IF (egrid1(i,j) > egrid2(i,j))
THEN
2065 egrid2(i,j) = egrid1(i,j)
2066 lb2(i,j) = lvlbnd(i,j,lbnd)
2067 p1d(i,j) = pbnd(i,j,lbnd)
2068 t1d(i,j) = tbnd(i,j,lbnd)
2069 q1d(i,j) = qbnd(i,j,lbnd)
2076 CALL calcape(itype,dpbnd,p1d,t1d,q1d,lb2,egrid1, &
2077 egrid2,egrid3,egrid4,egrid5)
2080 IF(iget(566)>0 .or. need_ifi)
THEN
2085 IF(t1d(i,j) < spval) grid1(i,j) = egrid1(i,j)
2088 CALL bound(grid1,d00,h99999)
2092 cape(i,j) = grid1(i,j)
2097 IF (iget(566)>0)
THEN
2098 if(grib==
'grib2')
then
2100 fld_info(cfld)%ifld=iavblfld(iget(566))
2101 fld_info(cfld)%lvl=lvlsxml(1,iget(566))
2107 datapd(i,j,cfld) = cape(ii,jj)
2113 IF (iget(567) > 0 .or. need_ifi)
THEN
2119 IF(t1d(i,j) < spval) grid1(i,j) = - egrid2(i,j)
2123 CALL bound(grid1,d00,h99999)
2128 IF(t1d(i,j) < spval) grid1(i,j) = - grid1(i,j)
2129 cin(i,j) = grid1(i,j)
2134 IF(iget(567) > 0)
THEN
2135 if(grib==
'grib2')
then
2137 fld_info(cfld)%ifld=iavblfld(iget(567))
2138 fld_info(cfld)%lvl=lvlsxml(1,iget(567))
2144 datapd(i,j,cfld) = cin(ii,jj)
2153 IF(iget(221) > 0)
THEN
2157 grid1(i,j) = pblh(i,j)
2160 if(grib==
'grib2')
then
2162 fld_info(cfld)%ifld=iavblfld(iget(221))
2168 datapd(i,j,cfld) = grid1(ii,jj)
2176 IF ( (iget(109)>0).OR.(iget(110)>0) )
THEN
2177 CALL callcl(pbnd(ista,jsta,1),tbnd(ista,jsta,1), &
2178 qbnd(ista,jsta,1),egrid1,egrid2)
2179 IF (iget(109)>0)
THEN
2184 IF(tbnd(i,j,1) < spval) grid1(i,j) = egrid2(i,j)
2187 if(grib==
'grib2')
then
2189 fld_info(cfld)%ifld=iavblfld(iget(109))
2195 datapd(i,j,cfld) = grid1(ii,jj)
2200 IF (iget(110)>0)
THEN
2205 IF(tbnd(i,j,1) < spval) grid1(i,j) = egrid1(i,j)
2208 if(grib==
'grib2')
then
2210 fld_info(cfld)%ifld=iavblfld(iget(110))
2216 datapd(i,j,cfld) = grid1(ii,jj)
2225 IF ( (iget(091)>0).OR.(iget(092)>0).OR. &
2226 (iget(093)>0).OR.(iget(094)>0).OR. &
2227 (iget(095)>0).OR.(iget(095)>0).OR. &
2228 (iget(096)>0).OR.(iget(097)>0).OR. &
2229 (iget(098)>0) )
THEN
2231 allocate(t78483(ista:iend,jsta:jend), t89671(ista:iend,jsta:jend), &
2232 p78483(ista:iend,jsta:jend), p89671(ista:iend,jsta:jend))
2236 IF (iget(097)>0.OR.iget(098)>0)
THEN
2240 p78483(i,j) = log(pint(i,j,nint(lmh(i,j)))*0.78483)
2241 p89671(i,j) = log(pint(i,j,nint(lmh(i,j)))*0.89671)
2250 pkl1=0.5*(alpint(i,j,l)+alpint(i,j,l+1))
2251 pku1=0.5*(alpint(i,j,l)+alpint(i,j,l-1))
2254 IF(p78483(i,j) < pkl1.AND.p78483(i,j) > pku1)
THEN
2255 fac1 = (pkl1-p78483(i,j))/(pkl1-pku1)
2256 fac2 = (p78483(i,j)-pku1)/(pkl1-pku1)
2257 t78483(i,j) = t(i,j,l)*fac2 + t(i,j,l-1)*fac1
2260 IF(p89671(i,j) < pkl1.AND.p89671(i,j) > pku1)
THEN
2261 fac1 = (pkl1-p89671(i,j))/(pkl1-pku1)
2262 fac2 = (p89671(i,j)-pku1)/(pkl1-pku1)
2263 t89671(i,j) = t(i,j,l)*fac2 + t(i,j,l-1)*fac1
2274 IF(.NOT. done(i,j))
THEN
2276 tl = 0.5*(t(i,j,lm-2)+t(i,j,lm-1))
2277 ql = 0.5*(q(i,j,lm-2)+q(i,j,lm-1))
2278 qsat = pq0/pl *exp(a2*(tl-a3)/(tl-a4))
2296 t89671(i,j) = tl * (p89671(i,j)/pl)**rgamog
2309 IF(.NOT. done1(i,j))
THEN
2311 tl = 0.5*(t(i,j,lm-2)+t(i,j,lm-1))
2312 ql = 0.5*(q(i,j,lm-2)+q(i,j,lm-1))
2313 qsat = pq0/pl *exp(a2*(tl-a3)/(tl-a4))
2331 t78483(i,j) = tl * (p78483(i,j)/pl)**rgamog
2339 IF (iget(097) > 0)
THEN
2344 IF(t(i,j,lm) < spval) grid1(i,j) = t89671(i,j)
2349 if(grib==
'grib2')
then
2351 fld_info(cfld)%ifld=iavblfld(iget(097))
2352 fld_info(cfld)%lvl=lvlsxml(1,iget(097))
2358 datapd(i,j,cfld) = grid1(ii,jj)
2365 IF (iget(098)>0)
THEN
2370 IF(t(i,j,lm) < spval) grid1(i,j) = t78483(i,j)
2373 if(grib==
'grib2')
then
2375 fld_info(cfld)%ifld=iavblfld(iget(098))
2376 fld_info(cfld)%lvl=lvlsxml(1,iget(098))
2382 datapd(i,j,cfld) = grid1(ii,jj)
2387 deallocate(t78483, t89671, p78483, p89671)
2394 IF ( (iget(091)>0).OR.(iget(092)>0).OR. &
2395 (iget(093)>0).OR.(iget(094)>0).OR. &
2396 (iget(095)>0).OR.(iget(095)>0).OR. &
2397 (iget(096)>0) )
THEN
2401 IF (iget(091)>0)
THEN
2405 grid1(i,j) = pbnd(i,j,1)
2408 if(grib==
'grib2')
then
2410 fld_info(cfld)%ifld=iavblfld(iget(091))
2416 datapd(i,j,cfld) = grid1(ii,jj)
2423 IF (iget(092)>0)
THEN
2427 grid1(i,j) = tbnd(i,j,1)
2430 if(grib==
'grib2')
then
2432 fld_info(cfld)%ifld=iavblfld(iget(092))
2433 fld_info(cfld)%lvl=lvlsxml(1,iget(092))
2439 datapd(i,j,cfld) = grid1(ii,jj)
2446 IF (iget(093)>0)
THEN
2450 grid1(i,j) = qbnd(i,j,1)
2453 CALL bound(grid1,h1m12,h99999)
2454 if(grib==
'grib2')
then
2456 fld_info(cfld)%ifld=iavblfld(iget(093))
2457 fld_info(cfld)%lvl=lvlsxml(1,iget(093))
2463 datapd(i,j,cfld) = grid1(ii,jj)
2470 IF (iget(094)>0)
THEN
2474 grid1(i,j) = rhbnd(i,j,1)
2477 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2478 CALL bound(grid1,h1,h100)
2479 if(grib==
'grib2')
then
2481 fld_info(cfld)%ifld=iavblfld(iget(094))
2482 fld_info(cfld)%lvl=lvlsxml(1,iget(094))
2488 datapd(i,j,cfld) = grid1(ii,jj)
2495 IF ((iget(095)>0).OR.(iget(096)>0))
THEN
2499 grid1(i,j) = ubnd(i,j,1)
2500 grid2(i,j) = vbnd(i,j,1)
2503 IF (iget(095)>0)
then
2504 if(grib==
'grib2')
then
2506 fld_info(cfld)%ifld=iavblfld(iget(095))
2507 fld_info(cfld)%lvl=lvlsxml(1,iget(095))
2513 datapd(i,j,cfld) = grid1(ii,jj)
2518 IF (iget(096)>0)
then
2519 if(grib==
'grib2')
then
2521 fld_info(cfld)%ifld=iavblfld(iget(096))
2522 fld_info(cfld)%lvl=lvlsxml(1,iget(096))
2528 datapd(i,j,cfld) = grid2(ii,jj)
2544 IF ( (iget(066)>0).OR.(iget(081)>0).OR. &
2545 (iget(082)>0).OR.(iget(104)>0).OR. &
2546 (iget(099)>0).OR.(iget(100)>0).OR. &
2547 (iget(101)>0).OR.(iget(102)>0).OR. &
2548 (iget(103)>0) )
THEN
2552 IF ( (iget(066)>0).OR.(iget(081)>0).OR. &
2553 (iget(082)>0).OR.(iget(104)>0) )
THEN
2554 allocate(rh3310(ista:iend,jsta:jend),rh6610(ista:iend,jsta:jend), &
2555 rh3366(ista:iend,jsta:jend),pw3310(ista:iend,jsta:jend))
2556 CALL lfmfld(rh3310,rh6610,rh3366,pw3310)
2559 IF (iget(066)>0)
THEN
2563 grid1(i,j) = rh3310(i,j)
2566 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2567 CALL bound(grid1,h1,h100)
2568 if(grib==
'grib2')
then
2570 fld_info(cfld)%ifld=iavblfld(iget(066))
2571 fld_info(cfld)%lvl=lvlsxml(1,iget(066))
2577 datapd(i,j,cfld) = grid1(ii,jj)
2586 IF (iget(081)>0)
THEN
2590 grid1(i,j) = rh6610(i,j)
2593 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2594 CALL bound(grid1,h1,h100)
2595 if(grib==
'grib2')
then
2597 fld_info(cfld)%ifld=iavblfld(iget(081))
2598 fld_info(cfld)%lvl=lvlsxml(1,iget(081))
2604 datapd(i,j,cfld) = grid1(ii,jj)
2611 IF (iget(082)>0)
THEN
2615 grid1(i,j) = rh3366(i,j)
2618 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2619 CALL bound(grid1,h1,h100)
2620 if(grib==
'grib2')
then
2622 fld_info(cfld)%ifld=iavblfld(iget(082))
2623 fld_info(cfld)%lvl=lvlsxml(1,iget(082))
2629 datapd(i,j,cfld) = grid1(ii,jj)
2636 IF (iget(104)>0)
THEN
2640 grid1(i,j) = pw3310(i,j)
2643 CALL bound(grid1,d00,h99999)
2644 if(grib==
'grib2')
then
2646 fld_info(cfld)%ifld=iavblfld(iget(104))
2647 fld_info(cfld)%lvl=lvlsxml(1,iget(104))
2653 datapd(i,j,cfld) = grid1(ii,jj)
2658 deallocate(rh3310,rh6610,rh3366,pw3310)
2663 IF ( (iget(099)>0).OR.(iget(100)>0).OR. &
2664 (iget(101)>0).OR.(iget(102)>0).OR. &
2665 (iget(103)>0) )
THEN
2666 allocate(rh4710(ista_2l:iend_2u,jsta_2l:jend_2u),rh4796(ista_2l:iend_2u,jsta_2l:jend_2u), &
2667 rh1847(ista_2l:iend_2u,jsta_2l:jend_2u))
2668 allocate(rh8498(ista_2l:iend_2u,jsta_2l:jend_2u),qm8510(ista_2l:iend_2u,jsta_2l:jend_2u))
2670 CALL ngmfld(rh4710,rh4796,rh1847,rh8498,qm8510)
2673 IF (iget(099)>0)
THEN
2677 grid1(i,j) = rh4710(i,j)
2680 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2681 CALL bound(grid1,h1,h100)
2682 if(grib==
'grib2')
then
2684 fld_info(cfld)%ifld=iavblfld(iget(099))
2685 fld_info(cfld)%lvl=lvlsxml(1,iget(099))
2691 datapd(i,j,cfld) = grid1(ii,jj)
2698 IF (iget(100)>0)
THEN
2702 grid1(i,j) = rh4796(i,j)
2705 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2706 CALL bound(grid1,h1,h100)
2707 if(grib==
'grib2')
then
2709 fld_info(cfld)%ifld=iavblfld(iget(100))
2710 fld_info(cfld)%lvl=lvlsxml(1,iget(100))
2716 datapd(i,j,cfld) = grid1(ii,jj)
2723 IF (iget(101)>0)
THEN
2727 grid1(i,j) = rh1847(i,j)
2730 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2731 CALL bound(grid1,h1,h100)
2732 if(grib==
'grib2')
then
2734 fld_info(cfld)%ifld=iavblfld(iget(101))
2735 fld_info(cfld)%lvl=lvlsxml(1,iget(101))
2741 datapd(i,j,cfld) = grid1(ii,jj)
2748 IF (iget(102)>0)
THEN
2752 grid1(i,j) = rh8498(i,j)
2755 CALL sclfld(grid1(ista:iend,jsta:jend),h100,im,jm)
2756 CALL bound(grid1,h1,h100)
2757 if(grib==
'grib2')
then
2759 fld_info(cfld)%ifld=iavblfld(iget(102))
2760 fld_info(cfld)%lvl=lvlsxml(1,iget(102))
2766 datapd(i,j,cfld) = grid1(ii,jj)
2773 IF (iget(103)>0)
THEN
2779 IF(qm8510(i,j) < spval) grid1(i,j) = -1.0*qm8510(i,j)
2782 if(grib==
'grib2')
then
2784 fld_info(cfld)%ifld=iavblfld(iget(103))
2785 fld_info(cfld)%lvl=lvlsxml(1,iget(103))
2791 datapd(i,j,cfld) = grid1(ii,jj)
2796 deallocate(rh4710,rh4796,rh1847)
2797 deallocate(rh8498,qm8510)
2801 IF ( (iget(318)>0).OR.(iget(319)>0).OR. &
2803 allocate(rh4410(ista:iend,jsta:jend),rh7294(ista:iend,jsta:jend), &
2804 rh4472(ista:iend,jsta:jend),rh3310(ista:iend,jsta:jend))
2808 IF (iget(318)>0)
THEN
2813 IF(rh4410(i,j) < spval) grid1(i,j) = rh4410(i,j)*100.
2816 CALL bound(grid1,d00,h100)
2817 if(grib==
'grib2')
then
2819 fld_info(cfld)%ifld=iavblfld(iget(318))
2820 fld_info(cfld)%lvl=lvlsxml(1,iget(318))
2826 datapd(i,j,cfld) = grid1(ii,jj)
2833 IF (iget(319)>0)
THEN
2838 IF(rh7294(i,j) < spval) grid1(i,j) = rh7294(i,j)*100.
2841 CALL bound(grid1,d00,h100)
2842 if(grib==
'grib2')
then
2844 fld_info(cfld)%ifld=iavblfld(iget(319))
2845 fld_info(cfld)%lvl=lvlsxml(1,iget(319))
2851 datapd(i,j,cfld) = grid1(ii,jj)
2858 IF (iget(320)>0)
THEN
2863 IF(rh4472(i,j) < spval) grid1(i,j)=rh4472(i,j)*100.
2866 CALL bound(grid1,d00,h100)
2867 if(grib==
'grib2')
then
2869 fld_info(cfld)%ifld=iavblfld(iget(320))
2870 fld_info(cfld)%lvl=lvlsxml(1,iget(320))
2876 datapd(i,j,cfld) = grid1(ii,jj)
2881 deallocate(rh4410,rh7294,rh4472,rh3310)
2885 IF ( (iget(321)>0).OR.(iget(322)>0).OR. &
2886 (iget(323)>0).OR.(iget(324)>0).OR. &
2887 (iget(325)>0).OR.(iget(326)>0))
THEN
2891 egrid2(i,j) = 0.995*pint(i,j,lm+1)
2892 egrid1(i,j) = log(pmid(i,j,lm)/egrid2(i,j)) &
2893 / log(pmid(i,j,lm)/pmid(i,j,lm-1))
2895 IF (modelname ==
'GFS' .OR. modelname ==
'FV3R')
THEN
2896 egrid1(i,j) = log(pmid(i,j,lm)/egrid2(i,j)) &
2897 / max(1.e-6,log(pmid(i,j,lm)/pmid(i,j,lm-1)))
2898 egrid1(i,j) =max(-10.0,min(egrid1(i,j), 10.0))
2899 IF ( abs(pmid(i,j,lm)-pmid(i,j,lm-1)) < 0.5 )
THEN
2907 IF (iget(321)>0)
THEN
2912 IF(t(i,j,lm)<spval.and.t(i,j,lm-1)<spval.and.egrid1(i,j)<spval)&
2913 grid1(i,j) = t(i,j,lm)+(t(i,j,lm-1)-t(i,j,lm)) &
2917 if(grib==
'grib2')
then
2919 fld_info(cfld)%ifld=iavblfld(iget(321))
2920 fld_info(cfld)%lvl=lvlsxml(1,iget(321))
2926 datapd(i,j,cfld) = grid1(ii,jj)
2934 IF (iget(322)>0)
THEN
2939 IF(t(i,j,lm)<spval.and.t(i,j,lm-1)<spval.and.egrid1(i,j)<spval)&
2940 grid2(i,j) = t(i,j,lm)+(t(i,j,lm-1)-t(i,j,lm)) &
2944 CALL calpot(egrid2,grid2(ista:iend,jsta:jend),grid1(ista:iend,jsta:jend))
2945 if(grib==
'grib2')
then
2947 fld_info(cfld)%ifld=iavblfld(iget(322))
2948 fld_info(cfld)%lvl=lvlsxml(1,iget(322))
2954 datapd(i,j,cfld) = grid1(ii,jj)
2960 IF (iget(323)>0)
THEN
2965 IF(pmid(i,j,lm)<spval.and.pmid(i,j,lm-1)<spval.and.&
2966 q(i,j,lm)<spval.and.q(i,j,lm-1)<spval)
THEN
2967 es1 = min(pmid(i,j,lm),fpvsnew(t(i,j,lm)))
2968 qs1 = con_eps*es1/(pmid(i,j,lm)+con_epsm1*es1)
2970 es2 = min(pmid(i,j,lm-1),fpvsnew(t(i,j,lm-1)))
2971 qs2 = con_eps*es2/(pmid(i,j,lm-1)+con_epsm1*es2)
2972 rh2 = q(i,j,lm-1)/qs2
2973 grid1(i,j) = (rh1+(rh2-rh1)*egrid1(i,j))*100.
2977 CALL bound(grid1,d00,h100)
2978 if(grib==
'grib2')
then
2980 fld_info(cfld)%ifld=iavblfld(iget(323))
2981 fld_info(cfld)%lvl=lvlsxml(1,iget(323))
2987 datapd(i,j,cfld) = grid1(ii,jj)
2993 IF (iget(324)>0)
THEN
2998 IF(uh(i,j,lm)<spval.and.uh(i,j,lm-1)<spval.and.egrid1(i,j)<spval)&
2999 grid1(i,j) = uh(i,j,lm)+(uh(i,j,lm-1)-uh(i,j,lm)) &
3003 if(grib==
'grib2')
then
3005 fld_info(cfld)%ifld=iavblfld(iget(324))
3006 fld_info(cfld)%lvl=lvlsxml(1,iget(324))
3012 datapd(i,j,cfld) = grid1(ii,jj)
3018 IF (iget(325)>0)
THEN
3023 IF(vh(i,j,lm)<spval.and.vh(i,j,lm-1)<spval.and.egrid1(i,j)<spval)&
3024 grid1(i,j) = vh(i,j,lm)+(vh(i,j,lm-1)-vh(i,j,lm)) &
3028 if(grib==
'grib2')
then
3030 fld_info(cfld)%ifld=iavblfld(iget(325))
3031 fld_info(cfld)%lvl=lvlsxml(1,iget(325))
3037 datapd(i,j,cfld) = grid1(ii,jj)
3043 IF (iget(326)>0)
THEN
3048 IF(omga(i,j,lm)<spval.and.omga(i,j,lm-1)<spval.and.egrid1(i,j)<spval)&
3049 grid1(i,j) = omga(i,j,lm)+(omga(i,j,lm-1)-omga(i,j,lm))&
3053 if(grib==
'grib2')
then
3055 fld_info(cfld)%ifld=iavblfld(iget(326))
3056 fld_info(cfld)%lvl=lvlsxml(1,iget(326))
3062 datapd(i,j,cfld) = grid1(ii,jj)
3075 IF(lvls(3,iget(032))>0)field1=.true.
3078 IF(lvls(3,iget(107))>0)field2=.true.
3088 IF(field1.OR.field2)
THEN
3094 egrid1(i,j) = -h99999
3095 egrid2(i,j) = -h99999
3096 lb2(i,j) = (lvlbnd(i,j,1) + lvlbnd(i,j,2) + &
3098 p1d(i,j) = (pbnd(i,j,1) + pbnd(i,j,2) + pbnd(i,j,3))/3
3099 t1d(i,j) = (tbnd(i,j,1) + tbnd(i,j,2) + tbnd(i,j,3))/3
3100 q1d(i,j) = (qbnd(i,j,1) + qbnd(i,j,2) + qbnd(i,j,3))/3
3105 CALL calcape(itype,dpbnd,p1d,t1d,q1d,lb2,egrid1, &
3106 egrid2,egrid3,egrid4,egrid5)
3108 IF (iget(582)>0)
THEN
3114 IF(t1d(i,j) < spval)
THEN
3115 grid1(i,j) = egrid1(i,j)
3116 IF (submodelname ==
'RTMA')mlcape(i,j)=grid1(i,j)
3120 CALL bound(grid1,d00,h99999)
3121 if(grib==
'grib2')
then
3123 fld_info(cfld)%ifld=iavblfld(iget(582))
3124 fld_info(cfld)%lvl=lvlsxml(1,iget(582))
3130 datapd(i,j,cfld) = grid1(ii,jj)
3135 IF (iget(583)>0)
THEN
3141 IF(t1d(i,j) < spval) grid1(i,j) = - egrid2(i,j)
3145 CALL bound(grid1,d00,h99999)
3150 IF(t1d(i,j) < spval)
THEN
3151 grid1(i,j) = - grid1(i,j)
3152 IF (submodelname ==
'RTMA') mlcin(i,j)=grid1(i,j)
3157 if(grib==
'grib2')
then
3159 fld_info(cfld)%ifld=iavblfld(iget(583))
3160 fld_info(cfld)%lvl=lvlsxml(1,iget(583))
3166 datapd(i,j,cfld) = grid1(ii,jj)
3176 IF ( (iget(109)>0).OR.(iget(110)>0) )
THEN
3177 CALL callcl(p1d,t1d,q1d,egrid1,egrid2)
3178 IF (iget(109)>0)
THEN
3182 IF(t1d(i,j) < spval) grid1(i,j)=egrid2(i,j)
3183 IF (submodelname ==
'RTMA') mllcl(i,j) = grid1(i,j)
3213 IF(lvls(4,iget(032))>0)field1=.true.
3217 IF(lvls(4,iget(107))>0)field2=.true.
3227 IF(field1.OR.field2.OR.need_ifi)
THEN
3229 call allocate_cape_arrays
3234 egrid1(i,j) = -h99999
3235 egrid2(i,j) = -h99999
3240 CALL calcape(itype,dpbnd,p1d,t1d,q1d,lb2,egrid1, &
3241 egrid2,egrid3,egrid4,egrid5)
3242 IF (iget(584)>0 .or. need_ifi)
THEN
3248 IF(t1d(i,j) < spval)
THEN
3249 grid1(i,j) = egrid1(i,j)
3250 IF (submodelname ==
'RTMA') mucape(i,j)=grid1(i,j)
3254 CALL bound(grid1,d00,h99999)
3261 cape(i,j) = grid1(i,j)
3264 if(iget(584)>0 .and. grib==
'grib2')
then
3266 fld_info(cfld)%ifld=iavblfld(iget(584))
3267 fld_info(cfld)%lvl=lvlsxml(1,iget(584))
3273 datapd(i,j,cfld) = grid1(ii,jj)
3280 IF (iget(585)>0 .or. need_ifi)
THEN
3286 IF(t1d(i,j) < spval) grid1(i,j) = - egrid2(i,j)
3289 CALL bound(grid1,d00,h99999)
3292 IF(t1d(i,j) < spval)
THEN
3293 grid1(i,j) = - grid1(i,j)
3294 IF (submodelname ==
'RTMA')
THEN
3295 mucape(i,j) = grid1(i,j)
3296 muq1d(i,j) = q1d(i,j)
3305 cin(i,j) = grid1(i,j)
3309 if(iget(585)>0 .and. grib==
'grib2')
then
3311 fld_info(cfld)%ifld=iavblfld(iget(585))
3312 fld_info(cfld)%lvl=lvlsxml(1,iget(585))
3318 datapd(i,j,cfld) = grid1(ii,jj)
3326 IF (iget(443)>0)
THEN
3331 IF(t1d(i,j) < spval) grid1(i,j) = egrid4(i,j)
3334 if(grib==
'grib2')
then
3336 fld_info(cfld)%ifld=iavblfld(iget(443))
3337 fld_info(cfld)%lvl=lvlsxml(1,iget(443))
3343 datapd(i,j,cfld) = grid1(ii,jj)
3349 IF (iget(982)>0)
THEN
3352 grid1(i,j) = teql(i,j)
3355 if(grib==
'grib2')
then
3357 fld_info(cfld)%ifld=iavblfld(iget(982))
3358 fld_info(cfld)%lvl=lvlsxml(1,iget(982))
3364 datapd(i,j,cfld) = grid1(ii,jj)
3373 IF (iget(246)>0)
THEN
3378 IF(t1d(i,j) < spval) grid1(i,j) = egrid3(i,j)
3381 CALL bound(grid1,d00,h99999)
3384 if(grib==
'grib2')
then
3386 fld_info(cfld)%ifld=iavblfld(iget(246))
3387 fld_info(cfld)%lvl=lvlsxml(1,iget(246))
3393 datapd(i,j,cfld) = grid1(ii,jj)
3400 IF (iget(444)>0)
THEN
3405 IF(cprate(i,j) < spval)
THEN
3406 IF (cprate(i,j) > pthresh)
THEN
3407 grid1(i,j) = egrid5(i,j)
3414 CALL bound(grid1,d00,h99999)
3415 if(grib==
'grib2')
then
3417 fld_info(cfld)%ifld=iavblfld(iget(444))
3418 fld_info(cfld)%lvl=lvlsxml(1,iget(444))
3424 datapd(i,j,cfld) = grid1(ii,jj)
3432 IF (submodelname ==
'RTMA')
THEN
3438 ALLOCATE(el_base(ista_2l:iend_2u,jsta_2l:jend_2u))
3439 ALLOCATE(el_tops(ista_2l:iend_2u,jsta_2l:jend_2u))
3440 ALLOCATE(found_base(ista_2l:iend_2u,jsta_2l:jend_2u))
3441 ALLOCATE(found_tops(ista_2l:iend_2u,jsta_2l:jend_2u))
3447 found_base(i,j) = .false.
3448 found_tops(i,j) = .false.
3463 egrid1(i,j) = -h99999
3464 egrid2(i,j) = -h99999
3466 p1d(i,j) = pmid(i,j,l)
3473 IF (debugprint)
WRITE(1000+me,
'(A,I3)') &
3474 ' CALCULATING CAPE/CINS ON LEVEL:',l
3475 CALL calcape(itype,dpbnd,p1d,t1d,q1d,idummy,egrid1, &
3476 egrid2,egrid3,egrid4,egrid5)
3482 IF ( .NOT. found_base(i,j) )
THEN
3483 IF ( egrid1(i,j) >= 100. .AND. egrid2(i,j) >= -250. )
THEN
3485 found_base(i,j) = .true.
3488 found_base(i,j) = .false.
3491 IF ( .NOT. found_tops(i,j) )
THEN
3492 IF ( egrid1(i,j) < 100. .OR. egrid2(i,j) < -250. )
THEN
3493 el_tops(i,j) = l + 1
3494 found_tops(i,j) = .true.
3497 found_tops(i,j) = .false.
3507 IF (
ALLOCATED(found_base))
DEALLOCATE(found_base)
3508 IF (
ALLOCATED(found_tops))
DEALLOCATE(found_tops)
3510 IF (debugprint)
THEN
3511 WRITE(im_ch,
'(I5.5)') im
3512 WRITE(jsta_ch,
'(I5.5)') jsta
3513 WRITE(jend_ch,
'(I5.5)') jend
3514 effl_fname=
"EFFL_NEW_"//im_ch//
"_"//jsta_ch//
"_"//jend_ch &
3516 effl_fname2=
"EFFL_NEW_LVLS_"//im_ch//
"_"//jsta_ch//
"_"//jend_ch &
3522 OPEN(iunit,file=trim(adjustl(effl_fname)),form=
'FORMATTED')
3529 WRITE(iunit,
'(1x,I6,2x,I6,2(2x,I6,2x,F12.3))') i, j, &
3530 el_base(i,j),pmid(i,j,el_base(i,j)), &
3531 el_tops(i,j),pmid(i,j,el_tops(i,j))
3537 IF(
ALLOCATED(tpar_base))
DEALLOCATE(tpar_base)
3538 IF(
ALLOCATED(tpar_tops))
DEALLOCATE(tpar_tops)
3550 IF(lvls(3,iget(032))>0)field1=.true.
3553 IF(lvls(3,iget(107))>0)field2=.true.
3562 IF(modelname ==
"FV3R" .and. submodelname ==
"RTMA")
THEN
3570 IF(field1.OR.field2)
THEN
3573 call allocate_cape_arrays
3579 egrid1(i,j) = -h99999
3580 egrid2(i,j) = -h99999
3581 egrid3(i,j) = -h99999
3582 egrid4(i,j) = -h99999
3583 egrid5(i,j) = -h99999
3584 egrid6(i,j) = -h99999
3585 egrid7(i,j) = -h99999
3586 egrid8(i,j) = -h99999
3591 lb2(i,j) = (lvlbnd(i,j,1) + lvlbnd(i,j,2) + &
3593 p1d(i,j) = (pbnd(i,j,1) + pbnd(i,j,2) + pbnd(i,j,3))/3
3594 t1d(i,j) = (tbnd(i,j,1) + tbnd(i,j,2) + tbnd(i,j,3))/3
3595 q1d(i,j) = (qbnd(i,j,1) + qbnd(i,j,2) + qbnd(i,j,3))/3
3600 CALL calcape2(itype,dpbnd,p1d,t1d,q1d,lb2, &
3601 egrid1,egrid2,egrid3,egrid4,egrid5, &
3602 egrid6,egrid7,egrid8)
3607 IF (iget(950)>0)
THEN
3613 IF(t1d(i,j) < spval) grid1(i,j) = egrid1(i,j)
3616 CALL bound(grid1,d00,h99999)
3617 if(grib==
'grib2')
then
3619 fld_info(cfld)%ifld=iavblfld(iget(950))
3620 fld_info(cfld)%lvl=lvlsxml(1,iget(950))
3626 datapd(i,j,cfld) = grid1(ii,jj)
3632 IF (iget(951)>0)
THEN
3638 IF(t1d(i,j) < spval) grid1(i,j) = - egrid2(i,j)
3642 CALL bound(grid1,d00,h99999)
3647 IF(t1d(i,j) < spval) grid1(i,j) = - grid1(i,j)
3651 if(grib==
'grib2')
then
3653 fld_info(cfld)%ifld=iavblfld(iget(951))
3654 fld_info(cfld)%lvl=lvlsxml(1,iget(951))
3660 datapd(i,j,cfld) = grid1(ii,jj)
3668 IF (iget(952)>0)
THEN
3673 IF(t1d(i,j) < spval) grid1(i,j) = egrid3(i,j)
3676 CALL bound(grid1,d00,h99999)
3677 if(grib==
'grib2')
then
3679 fld_info(cfld)%ifld=iavblfld(iget(952))
3680 fld_info(cfld)%lvl=lvlsxml(1,iget(952))
3686 datapd(i,j,cfld) = grid1(ii,jj)
3695 allocate(ust(ista_2l:iend_2u,jsta_2l:jend_2u),vst(ista_2l:iend_2u,jsta_2l:jend_2u), &
3696 heli(ista_2l:iend_2u,jsta_2l:jend_2u,2))
3697 allocate(llow(ista_2l:iend_2u,jsta_2l:jend_2u),lupp(ista_2l:iend_2u,jsta_2l:jend_2u), &
3698 cangle(ista_2l:iend_2u,jsta_2l:jend_2u))
3699 allocate(llow_zint(ista_2l:iend_2u,jsta_2l:jend_2u), &
3700 ieql_zint(ista_2l:iend_2u,jsta_2l:jend_2u),z_temp(ista_2l:iend_2u,jsta_2l:jend_2u))
3701 allocate(midcal(ista_2l:iend_2u,jsta_2l:jend_2u,1:lm))
3702 allocate(z_midcal(ista_2l:iend_2u,jsta_2l:jend_2u))
3707 iget2 = lvls(1,iget1)
3708 iget3 = lvls(2,iget1)
3710 if(me==0)
write(*,*)
'953 ',iget1,iget2,iget3
3711 IF (iget1 > 0 .OR. iget(162) > 0 .OR. iget(953) > 0)
THEN
3714 IF (submodelname ==
'RTMA')
THEN
3720 llow(i,j) = el_base(i,j)
3721 lupp(i,j) = el_tops(i,j)
3728 llow(i,j) = int(egrid4(i,j))
3729 lupp(i,j) = int(egrid5(i,j))
3734 IF (debugprint)
THEN
3735 WRITE(im_ch,
'(I5.5)') im
3736 WRITE(jsta_ch,
'(I5.5)') jsta
3737 WRITE(jend_ch,
'(I5.5)') jend
3738 effl_fname=
"EFFL_OLD_"//im_ch//
"_"//jsta_ch//
"_"//jend_ch &
3742 OPEN(iunit,file=trim(adjustl(effl_fname)),form=
'FORMATTED')
3746 WRITE(iunit,
'(1x,I6,2x,I6,2(2x,I6,2x,F12.3))') i, j, &
3747 llow(i,j),pmid(i,j,llow(i,j)), &
3748 lupp(i,j),pmid(i,j,lupp(i,j))
3755 CALL calhel2(llow,lupp,depth,ust,vst,heli,cangle)
3761 grid1(i,j) = heli(i,j,1)
3764 if(grib==
'grib2')
then
3766 fld_info(cfld)%ifld=iavblfld(iget1)
3767 fld_info(cfld)%lvl=lvlsxml(1,iget1)
3773 datapd(i,j,cfld) = grid1(ii,jj)
3782 IF (submodelname ==
'RTMA')
THEN
3786 allocate(eshr(ista_2l:iend_2u,jsta_2l:jend_2u),uvect(ista_2l:iend_2u,jsta_2l:jend_2u),&
3787 vvect(ista_2l:iend_2u,jsta_2l:jend_2u),htsfc(ista_2l:iend_2u,jsta_2l:jend_2u))
3788 allocate(effust(ista_2l:iend_2u,jsta_2l:jend_2u),effvst(ista_2l:iend_2u,jsta_2l:jend_2u),&
3789 esrh(ista_2l:iend_2u,jsta_2l:jend_2u))
3804 egrid1(i,j) = -h99999
3805 p1d(i,j)=pmid(i,j,l)
3810 CALL calthte(p1d,t1d,q1d,egrid1)
3813 the(i,j)=egrid1(i,j)
3814 IF(the(i,j)>=maxthe(i,j))
THEN
3815 maxthe(i,j)=the(i,j)
3817 muq1d(i,j) = q(i,j,l)
3823 llow(i,j) = el_base(i,j)
3824 llow_zint(i,j)=zint(i,j,llow(i,j))
3825 ieql_zint(i,j)=zint(i,j,ieql(i,j))
3826 z_temp(i,j)=llow_zint(i,j)+d50*(ieql_zint(i,j)-llow_zint(i,j))
3827 midcal(i,j,l)=abs(zint(i,j,l)-z_temp(i,j))
3831 z_midcal=minloc(midcal,dim=3)
3835 IF(gridtype ==
'E')
THEN
3846 ELSE IF(gridtype ==
'B')
THEN
3870 IF(gridtype /=
'A')
CALL exch(fis(ista_2l:iend_2u,jsta_2l:jend_2u))
3877 IF (gridtype==
'B')
THEN
3878 htsfc(i,j)=(0.25/g)*(fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(ie,jn))
3880 htsfc(i,j)=(0.25/g)*(fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(i,js))
3886 IF (iget(979)>0)
THEN
3890 IF(zint(i,j,llow(i,j))<spval.and.htsfc(i,j)<spval)&
3891 grid1(i,j) = zint(i,j,llow(i,j)) - htsfc(i,j)
3894 if(grib==
'grib2')
then
3896 fld_info(cfld)%ifld=iavblfld(iget(979))
3897 fld_info(cfld)%lvl=lvlsxml(1,iget(979))
3903 datapd(i,j,cfld) = grid1(ii,jj)
3909 IF (iget(980)>0)
THEN
3913 IF(zint(i,j,lupp(i,j))<spval.and.htsfc(i,j)<spval)&
3914 grid1(i,j) = zint(i,j,lupp(i,j)) - htsfc(i,j)
3917 if(grib==
'grib2')
then
3919 fld_info(cfld)%ifld=iavblfld(iget(980))
3920 fld_info(cfld)%lvl=lvlsxml(1,iget(980))
3926 datapd(i,j,cfld) = grid1(ii,jj)
3934 IF (iget(983)>0)
THEN
3938 IF(llow(i,j)<spval.and.lupp(i,j)<spval)
THEN
3939 uvect(i,j)=uh(i,j,z_midcal(i,j))-uh(i,j,llow(i,j))
3940 grid1(i,j)=uvect(i,j)
3944 if(grib==
'grib2')
then
3946 fld_info(cfld)%ifld=iavblfld(iget(983))
3947 fld_info(cfld)%lvl=lvlsxml(1,iget(983))
3953 datapd(i,j,cfld) = grid1(ii,jj)
3960 IF (iget(984)>0)
THEN
3964 IF(llow(i,j)<spval.and.lupp(i,j)<spval)
THEN
3965 vvect(i,j)=vh(i,j,z_midcal(i,j))-vh(i,j,llow(i,j))
3966 grid1(i,j)=vvect(i,j)
3970 if(grib==
'grib2')
then
3972 fld_info(cfld)%ifld=iavblfld(iget(984))
3973 fld_info(cfld)%lvl=lvlsxml(1,iget(984))
3979 datapd(i,j,cfld) = grid1(ii,jj)
3986 IF (iget(985)>0)
THEN
3990 IF(uvect(i,j)<spval.and.vvect(i,j)<spval)
THEN
3991 eshr(i,j)=sqrt((uvect(i,j)**2)+(vvect(i,j))**2)
3994 grid1(i,j)=eshr(i,j)
3998 if(grib==
'grib2')
then
4000 fld_info(cfld)%ifld=iavblfld(iget(985))
4001 fld_info(cfld)%lvl=lvlsxml(1,iget(985))
4007 datapd(i,j,cfld) = grid1(ii,jj)
4017 llow(i,j) = el_base(i,j)
4018 lupp(i,j) = el_tops(i,j)
4022 CALL calhel3(llow,lupp,effust,effvst,esrh)
4027 IF (iget(986)>0)
THEN
4031 IF(llow(i,j)<spval.and.lupp(i,j)<spval)&
4032 grid1(i,j)=effust(i,j)
4035 if(grib==
'grib2')
then
4037 fld_info(cfld)%ifld=iavblfld(iget(986))
4038 fld_info(cfld)%lvl=lvlsxml(1,iget(986))
4044 datapd(i,j,cfld) = grid1(ii,jj)
4051 IF (iget(987)>0)
THEN
4055 IF(llow(i,j)<spval.and.lupp(i,j)<spval)&
4056 grid1(i,j)=effvst(i,j)
4059 if(grib==
'grib2')
then
4061 fld_info(cfld)%ifld=iavblfld(iget(987))
4062 fld_info(cfld)%lvl=lvlsxml(1,iget(987))
4068 datapd(i,j,cfld) = grid1(ii,jj)
4075 IF (iget(988)>0)
THEN
4079 IF(llow(i,j)<spval.and.lupp(i,j)<spval)&
4080 grid1(i,j)=esrh(i,j)
4083 if(grib==
'grib2')
then
4085 fld_info(cfld)%ifld=iavblfld(iget(988))
4086 fld_info(cfld)%lvl=lvlsxml(1,iget(988))
4092 datapd(i,j,cfld) = grid1(ii,jj)
4099 IF (iget(989)>0)
THEN
4102 IF (mllcl(i,j)>d2000)
THEN
4104 ELSEIF (mllcl(i,j)<d1000)
THEN
4107 mllcltmp=((d2000-mllcl(i,j))/d1000)
4109 IF (eshr(i,j)<12.5)
THEN
4111 ELSEIF (eshr(i,j)>30.0)
THEN
4114 eshrtmp=(eshr(i,j)/20.)
4116 IF (mlcin(i,j)>-50.)
THEN
4118 ELSEIF (mlcin(i,j)<-200.)
THEN
4121 mlcintmp=(200.+mlcin(i,j))/150.
4123 stp=(mlcape(i,j)/d1500)*mllcltmp*(esrh(i,j)/150.)*&
4126 IF(llow(i,j)<spval.and.lupp(i,j)<spval)
THEN
4135 if(grib==
'grib2')
then
4137 fld_info(cfld)%ifld=iavblfld(iget(989))
4138 fld_info(cfld)%lvl=lvlsxml(1,iget(989))
4144 datapd(i,j,cfld) = grid1(ii,jj)
4151 IF (iget(990)>0)
THEN
4154 llmh = nint(lmh(i,j))
4155 p1d(i,j) = pmid(i,j,llmh)
4156 t1d(i,j) = t(i,j,llmh)
4157 q1d(i,j) = q(i,j,llmh)
4160 CALL callcl(p1d,t1d,q1d,egrid1,egrid2)
4163 slcl(i,j)=egrid2(i,j)
4170 CALL calcape(itype,dpbnd,dummy,dummy,dummy,&
4171 idummy,egrid1,egrid2,&
4176 IF (slcl(i,j)>d2000)
THEN
4178 ELSEIF (slcl(i,j)<=d1000)
THEN
4181 slcltmp=((d2000-slcl(i,j))/d1000)
4183 IF (fshr(i,j)<12.5)
THEN
4185 ELSEIF (fshr(i,j)>30.0)
THEN
4188 fshrtmp=(fshr(i,j)/20.)
4190 IF (egrid2(i,j)>-50.)
THEN
4192 ELSEIF (egrid2(i,j)<-200.)
THEN
4195 scintmp=((200.+egrid2(i,j)/150.))
4197 stp=(egrid1(i,j)/d1500)*slcltmp*(heli(i,j,2)/150.)*&
4200 IF(t1d(i,j) < spval)
THEN
4209 if(grib==
'grib2')
then
4211 fld_info(cfld)%ifld=iavblfld(iget(990))
4212 fld_info(cfld)%lvl=lvlsxml(1,iget(990))
4218 datapd(i,j,cfld) = grid1(ii,jj)
4225 IF (iget(991)>0)
THEN
4228 IF (eshr(i,j)<10.)
THEN
4230 ELSEIF (eshr(i,j)>20.0)
THEN
4233 eshrtmp=(eshr(i,j)/20.)
4235 IF (mucin(i,j)>-40.)
THEN
4238 mucintmp=(-40./mucin(i,j))
4240 stp=(mucape(i,j)/d1000)*(esrh(i,j)/50.)*&
4243 IF(t1d(i,j) < spval)
THEN
4252 if(grib==
'grib2')
then
4254 fld_info(cfld)%ifld=iavblfld(iget(991))
4255 fld_info(cfld)%lvl=lvlsxml(1,iget(991))
4261 datapd(i,j,cfld) = grid1(ii,jj)
4269 IF (iget(992)>0)
THEN
4273 egrid1(i,j) = -h99999
4274 egrid2(i,j) = -h99999
4275 egrid3(i,j) = -h99999
4276 egrid4(i,j) = -h99999
4277 egrid5(i,j) = -h99999
4278 egrid6(i,j) = -h99999
4279 egrid7(i,j) = -h99999
4280 egrid8(i,j) = -h99999
4281 lb2(i,j) = (lvlbnd(i,j,1) + lvlbnd(i,j,2) + &
4283 p1d(i,j) = (pbnd(i,j,1) + pbnd(i,j,2) + pbnd(i,j,3))/3
4284 t1d(i,j) = (tvirtual(tbnd(i,j,1),qbnd(i,j,1)) + &
4285 tvirtual(tbnd(i,j,2),qbnd(i,j,2)) + &
4286 tvirtual(tbnd(i,j,3),qbnd(i,j,3)))/3
4287 q1d(i,j) = (qbnd(i,j,1) + qbnd(i,j,2) + qbnd(i,j,3))/3
4294 CALL calcape2(itype,dpbnd,p1d,t1d,q1d,lb2, &
4295 egrid1,egrid2,egrid3,egrid4,egrid5, &
4296 egrid6,egrid7,egrid8)
4301 IF(t1d(i,j) < spval) grid1(i,j) = egrid3(i,j)
4304 CALL bound(grid1,d00,h99999)
4305 if(grib==
'grib2')
then
4307 fld_info(cfld)%ifld=iavblfld(iget(992))
4308 fld_info(cfld)%lvl=lvlsxml(1,iget(992))
4314 datapd(i,j,cfld) = grid1(ii,jj)
4321 IF (iget(763)>0)
THEN
4326 grid1(i,j) = q1d(i,j)
4329 if(grib==
'grib2')
then
4331 fld_info(cfld)%ifld=iavblfld(iget(763))
4332 fld_info(cfld)%lvl=lvlsxml(1,iget(763))
4338 datapd(i,j,cfld) = grid1(ii,jj)
4345 IF (iget(993)>0)
THEN
4349 lapse=-((t700(i,j)-t500(i,j))/((z700(i,j)-z500(i,j))))
4350 ship=(mucape(i,j)*d1000*muq1d(i,j)*lapse*(t500(i,j)-k2c)*fshr(i,j))/hconst
4351 IF (mucape(i,j)<1300.)
THEN
4352 ship=ship*(mucape(i,j)/1300.)
4354 IF (lapse < 5.8)
THEN
4355 ship=ship*(lapse/5.8)
4357 IF (freezelvl(i,j) < 2400.)
THEN
4358 ship=ship*(freezelvl(i,j)/2400.)
4363 if(grib==
'grib2')
then
4365 fld_info(cfld)%ifld=iavblfld(iget(993))
4366 fld_info(cfld)%lvl=lvlsxml(1,iget(993))
4372 datapd(i,j,cfld) = grid1(ii,jj)
4383 IF (iget(957)>0)
THEN
4388 IF(t1d(i,j) < spval ) grid1(i,j) = cangle(i,j)
4394 if(grib==
'grib2')
then
4396 fld_info(cfld)%ifld=iavblfld(iget(957))
4397 fld_info(cfld)%lvl=lvlsxml(1,iget(957))
4403 datapd(i,j,cfld) = grid1(ii,jj)
4411 IF (iget(955)>0)
THEN
4416 IF(t1d(i,j) < spval ) grid1(i,j) = egrid7(i,j)
4419 CALL bound(grid1,d00,h99999)
4420 if(grib==
'grib2')
then
4422 fld_info(cfld)%ifld=iavblfld(iget(955))
4423 fld_info(cfld)%lvl=lvlsxml(1,iget(955))
4429 datapd(i,j,cfld) = grid1(ii,jj)
4437 IF (iget(956)>0)
THEN
4442 IF(t1d(i,j) < spval ) grid1(i,j) = egrid8(i,j)
4445 CALL bound(grid1,d00,h99999)
4446 if(grib==
'grib2')
then
4448 fld_info(cfld)%ifld=iavblfld(iget(956))
4449 fld_info(cfld)%lvl=lvlsxml(1,iget(956))
4455 datapd(i,j,cfld) = grid1(ii,jj)
4479 IF (iget(954)>0)
THEN
4484 IF(t1d(i,j) < spval) grid1(i,j) = -egrid6(i,j)
4487 CALL bound(grid1,d00,h99999)
4488 if(grib==
'grib2')
then
4490 fld_info(cfld)%ifld=iavblfld(iget(954))
4491 fld_info(cfld)%lvl=lvlsxml(1,iget(954))
4497 datapd(i,j,cfld) = grid1(ii,jj)
4504 if (
allocated(ushr1))
deallocate(ushr1)
4505 if (
allocated(vshr1))
deallocate(vshr1)
4506 if (
allocated(ushr6))
deallocate(ushr6)
4507 if (
allocated(vshr6))
deallocate(vshr6)
4508 if (
allocated(ust))
deallocate(ust)
4509 if (
allocated(vst))
deallocate(vst)
4510 if (
allocated(heli))
deallocate(heli)
4511 if (
allocated(llow))
deallocate(llow)
4512 if (
allocated(lupp))
deallocate(lupp)
4513 if (
allocated(cangle))
deallocate(cangle)
4514 if (
allocated(effust))
deallocate(effust)
4515 if (
allocated(effvst))
deallocate(effvst)
4516 if (
allocated(eshr))
deallocate(eshr)
4517 if (
allocated(uvect))
deallocate(uvect)
4518 if (
allocated(vvect))
deallocate(vvect)
4519 if (
allocated(esrh))
deallocate(esrh)
4520 if (
allocated(htsfc))
deallocate(htsfc)
4521 if (
allocated(fshr))
deallocate(fshr)
4522 if (
allocated(llow_zint))
deallocate(llow_zint)
4523 if (
allocated(ieql_zint))
deallocate(ieql_zint)
4524 if (
allocated(z_temp))
deallocate(z_temp)
4525 if (
allocated(midcal))
deallocate(midcal)
4526 if (
allocated(z_midcal))
deallocate(z_midcal)
4527 if (
allocated(el_base))
deallocate(el_base)
4528 if (
allocated(el_tops))
deallocate(el_tops)
4532 if (
allocated(pbnd))
deallocate(pbnd)
4533 if (
allocated(tbnd))
deallocate(tbnd)
4534 if (
allocated(qbnd))
deallocate(qbnd)
4535 if (
allocated(ubnd))
deallocate(ubnd)
4536 if (
allocated(vbnd))
deallocate(vbnd)
4537 if (
allocated(rhbnd))
deallocate(rhbnd)
4538 if (
allocated(wbnd))
deallocate(wbnd)
4539 if (
allocated(lvlbnd))
deallocate(lvlbnd)
4540 if (
allocated(lb2))
deallocate(lb2)
4545 IF (iget(749)>0)
THEN
4546 CALL calrh_pw(grid1(ista:iend,jsta:jend))
4547 if(grib==
'grib2')
then
4549 fld_info(cfld)%ifld=iavblfld(iget(749))
4555 datapd(i,j,cfld) = grid1(ii,jj)
4567 subroutine allocate_cape_arrays
4568 if(.not.
allocated(omgbnd))
allocate(omgbnd(ista:iend,jsta:jend,nbnd))
4569 if(.not.
allocated(pwtbnd))
allocate(pwtbnd(ista:iend,jsta:jend,nbnd))
4570 if(.not.
allocated(qcnvbnd))
allocate(qcnvbnd(ista:iend,jsta:jend,nbnd))
4571 if(.not.
allocated(lvlbnd))
allocate(lvlbnd(ista:iend,jsta:jend,nbnd))
4572 if(.not.
allocated(lb2))
allocate(lb2(ista:iend,jsta:jend))
4573 end subroutine allocate_cape_arrays