43 SUBROUTINE fdlvl(ITYPE,TFD,QFD,UFD,VFD,PFD,ICINGFD,AERFD)
48 use vrbls3d, only: zmid, t, q, pmid, icing_gfip, uh, vh
52 use ctlblk_mod
, only: jsta, jend, spval, jsta_2l, jend_2u, lm, jsta_m, &
53 jend_m, htfd, nfd, im, jm, nbin_du, gocart_on, &
55 use gridspec_mod
, only: gridtype
64 integer,
intent(in) :: itype(nfd)
66 real,
dimension(IM,JSTA:JEND,NFD),
intent(out) :: tfd,qfd,ufd,vfd,pfd,icingfd
67 real,
dimension(IM,JSTA:JEND,NFD,NBIN_DU),
intent(out) :: aerfd
69 INTEGER lvl(nfd),lhl(nfd)
70 INTEGER ive(jm),ivw(jm)
71 REAL dzabv(nfd), dzabh(nfd)
74 integer i,j,jvs,jvn,ie,iw,jn,js,jnt,l,llmh,ifd,n
75 integer istart,istop,jstart,jstop
76 real htt,htsfc,httuv,dz,rdz,delt,delq,delu,delv,z1,z2,htabv,htabh,htsfcv
96 icingfd(i,j,ifd) = spval
105 aerfd(i,j,ifd,n) = spval
112 IF(gridtype ==
'E')
THEN
121 IF(gridtype /=
'A')
THEN
122 CALL exch(fis(1:im,jsta_2l:jend_2u))
124 CALL exch(zmid(1:im,jsta_2l:jend_2u,l))
140 IF (itype(ifd)==1)
THEN
148 llmh = nint(lmh(i,j))
159 IF(gridtype ==
'E')
THEN
164 httuv = 0.25*(zmid(iw,j,l) &
165 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
166 ELSE IF(gridtype==
'B')
THEN
171 httuv = 0.25*(zmid(iw,j,l) &
172 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
177 IF (.NOT. doneh .AND. htt>htfd(ifd))
THEN
179 dzabh(ifd) = htt-htfd(ifd)
182 IF(htsfc > htfd(ifd))
THEN
192 IF (.NOT. donev .AND. httuv>htfd(ifd))
THEN
194 dzabv(ifd) = httuv-htfd(ifd)
197 IF(htsfc>htfd(ifd))
THEN
207 IF(doneh .AND. donev)
exit
217 dz = zmid(i,j,l)-zmid(i,j,l+1)
219 delt = t(i,j,l)-t(i,j,l+1)
220 delq = q(i,j,l)-q(i,j,l+1)
221 tfd(i,j,ifd) = t(i,j,l) - delt*rdz*dzabh(ifd)
222 qfd(i,j,ifd) = q(i,j,l) - delq*rdz*dzabh(ifd)
223 pfd(i,j,ifd) = pmid(i,j,l) - (pmid(i,j,l)-pmid(i,j,l+1))*rdz*dzabh(ifd)
224 icingfd(i,j,ifd) = icing_gfip(i,j,l) - &
225 (icing_gfip(i,j,l)-icing_gfip(i,j,l+1))*rdz*dzabh(ifd)
228 aerfd(i,j,ifd,n) = dust(i,j,l,n) - &
229 (dust(i,j,l,n)-dust(i,j,l+1,n))*rdz*dzabh(ifd)
232 ELSEIF (l == lm)
THEN
233 tfd(i,j,ifd) = t(i,j,l)
234 qfd(i,j,ifd) = q(i,j,l)
235 pfd(i,j,ifd) = pmid(i,j,l)
236 icingfd(i,j,ifd) = icing_gfip(i,j,l)
239 aerfd(i,j,ifd,n) = dust(i,j,l,n)
246 IF(gridtype ==
'E')
THEN
251 z1 = 0.25*(zmid(iw,j,l) &
252 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
253 z2 = 0.25*(zmid(iw,j,l+1) &
254 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(i,js,l+1))
257 ELSE IF(gridtype==
'B')
THEN
262 z1 = 0.25*(zmid(iw,j,l) &
263 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
264 z2 = 0.25*(zmid(iw,j,l+1) &
265 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(ie,jn,l+1))
268 dz = zmid(i,j,l)-zmid(i,j,l+1)
271 delu = uh(i,j,l) - uh(i,j,l+1)
272 delv = vh(i,j,l) - vh(i,j,l+1)
273 ufd(i,j,ifd) = uh(i,j,l) - delu*rdz*dzabv(ifd)
274 vfd(i,j,ifd) = vh(i,j,l) - delv*rdz*dzabv(ifd)
276 ufd(i,j,ifd)=uh(i,j,l)
277 vfd(i,j,ifd)=vh(i,j,l)
297 IF(gridtype ==
'E')
THEN
302 htsfcv = (fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(i,js))*(0.25/g)
303 ELSE IF(gridtype ==
'B')
THEN
308 htsfcv = (fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(ie,jn))*(0.25/g)
310 llmh = nint(lmh(i,j))
320 htabh = zmid(i,j,l)-htsfc
322 IF(gridtype==
'E')
THEN
323 htabv = 0.25*(zmid(iw,j,l) &
324 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))-htsfcv
325 ELSE IF(gridtype==
'B')
THEN
326 htabv = 0.25*(zmid(iw,j,l) &
327 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))-htsfcv
332 IF (.NOT. doneh .AND. htabh>htfd(ifd))
THEN
334 dzabh(ifd) = htabh-htfd(ifd)
340 IF (.NOT. donev .AND. htabv>htfd(ifd))
THEN
342 dzabv(ifd) = htabv-htfd(ifd)
347 IF(doneh .AND. donev)
exit
357 dz = zmid(i,j,l)-zmid(i,j,l+1)
359 delt = t(i,j,l)-t(i,j,l+1)
360 delq = q(i,j,l)-q(i,j,l+1)
361 tfd(i,j,ifd) = t(i,j,l) - delt*rdz*dzabh(ifd)
362 qfd(i,j,ifd) = q(i,j,l) - delq*rdz*dzabh(ifd)
363 pfd(i,j,ifd) = pmid(i,j,l) - (pmid(i,j,l)-pmid(i,j,l+1))*rdz*dzabh(ifd)
364 icingfd(i,j,ifd) = icing_gfip(i,j,l) - &
365 (icing_gfip(i,j,l)-icing_gfip(i,j,l+1))*rdz*dzabh(ifd)
368 aerfd(i,j,ifd,n) = dust(i,j,l,n) - &
369 (dust(i,j,l,n)-dust(i,j,l+1,n))*rdz*dzabh(ifd)
373 tfd(i,j,ifd) = t(i,j,l)
374 qfd(i,j,ifd) = q(i,j,l)
375 pfd(i,j,ifd) = pmid(i,j,l)
376 icingfd(i,j,ifd) = icing_gfip(i,j,l)
379 aerfd(i,j,ifd,n) = dust(i,j,l,n)
386 IF(gridtype ==
'E')
THEN
391 z1 = 0.25*(zmid(iw,j,l) &
392 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
393 z2 = 0.25*(zmid(iw,j,l+1) &
394 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(i,js,l+1))
396 ELSE IF(gridtype==
'B')
THEN
401 z1 = 0.25*(zmid(iw,j,l) &
402 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
403 z2 = 0.25*(zmid(iw,j,l+1) &
404 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(ie,jn,l+1))
407 dz = zmid(i,j,l)-zmid(i,j,l+1)
410 delu = uh(i,j,l)-uh(i,j,l+1)
411 delv = vh(i,j,l)-vh(i,j,l+1)
412 ufd(i,j,ifd) = uh(i,j,l) - delu*rdz*dzabv(ifd)
413 vfd(i,j,ifd) = vh(i,j,l) - delv*rdz*dzabv(ifd)
415 ufd(i,j,ifd) = uh(i,j,l)
416 vfd(i,j,ifd) = vh(i,j,l)
429 !krf: need ncar and nmm wrf cores in this check as well?
430 IF(modelname==
'RAPR' .OR. modelname==
'NCAR' .OR. modelname==
'NMM')
THEN
434 if(qfd(i,j,ifd) < 1.0e-8) qfd(i,j,ifd)=0.0
486 SUBROUTINE fdlvl_uv(ITYPE,NFD,HTFD,UFD,VFD)
489 use vrbls3d, only: zmid, pmid, uh, vh
493 use ctlblk_mod
, only: jsta, jend, spval, jsta_2l, jend_2u, lm, jsta_m, &
494 jend_m, im, jm, modelname
495 use gridspec_mod
, only: gridtype
501 integer,
intent(in) :: itype(nfd)
502 integer,
intent(in) :: nfd
503 real,
intent(in) :: htfd(nfd)
504 real,
dimension(IM,JSTA_2L:JEND_2U,NFD),
intent(out) :: ufd,vfd
507 INTEGER ive(jm),ivw(jm)
510 integer i,j,jvs,jvn,ie,iw,jn,js,l,llmh,ifd,n
511 integer istart,istop,jstart,jstop
512 real htt,htsfc,httuv,dz,rdz,delu,delv,z1,z2,htabv,htabh,htsfcv
529 IF(gridtype ==
'E')
THEN
538 IF(gridtype /=
'A')
THEN
539 CALL exch(fis(1:im,jsta_2l:jend_2u))
541 CALL exch(zmid(1:im,jsta_2l:jend_2u,l))
557 IF (itype(ifd) == 1)
THEN
565 llmh = nint(lmh(i,j))
572 IF(gridtype ==
'E')
THEN
577 httuv = 0.25*(zmid(iw,j,l) &
578 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
579 ELSE IF(gridtype==
'B')
THEN
584 httuv = 0.25*(zmid(iw,j,l) &
585 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
590 IF (httuv > htfd(ifd))
THEN
592 dzabv(ifd) = httuv-htfd(ifd)
594 IF(htsfc > htfd(ifd))
THEN
609 IF(gridtype ==
'E')
THEN
614 z1 = 0.25*(zmid(iw,j,l) &
615 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
616 z2 = 0.25*(zmid(iw,j,l+1) &
617 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(i,js,l+1))
620 ELSE IF(gridtype==
'B')
THEN
625 z1 = 0.25*(zmid(iw,j,l) &
626 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
627 z2 = 0.25*(zmid(iw,j,l+1) &
628 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(ie,jn,l+1))
631 dz = zmid(i,j,l)-zmid(i,j,l+1)
634 delu = uh(i,j,l) - uh(i,j,l+1)
635 delv = vh(i,j,l) - vh(i,j,l+1)
636 ufd(i,j,ifd) = uh(i,j,l) - delu*rdz*dzabv(ifd)
637 vfd(i,j,ifd) = vh(i,j,l) - delv*rdz*dzabv(ifd)
638 ELSEIF (l == lm)
THEN
639 ufd(i,j,ifd)=uh(i,j,l)
640 vfd(i,j,ifd)=vh(i,j,l)
642 ufd(i,j,ifd)=uh(i,j,lm)
643 vfd(i,j,ifd)=vh(i,j,lm)
660 IF(gridtype ==
'E')
THEN
665 htsfcv = (fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(i,js))*(0.25/g)
666 ELSE IF(gridtype ==
'B')
THEN
671 htsfcv = (fis(iw,j)+fis(ie,j)+fis(i,jn)+fis(ie,jn))*(0.25/g)
673 llmh = nint(lmh(i,j))
679 htabh = zmid(i,j,l)-htsfc
680 IF(gridtype==
'E')
THEN
681 htabv = 0.25*(zmid(iw,j,l) &
682 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))-htsfcv
683 ELSE IF(gridtype==
'B')
THEN
684 htabv = 0.25*(zmid(iw,j,l) &
685 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))-htsfcv
690 IF (htabv > htfd(ifd))
THEN
692 dzabv(ifd) = htabv-htfd(ifd)
702 IF(gridtype ==
'E')
THEN
707 z1 = 0.25*(zmid(iw,j,l) &
708 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(i,js,l))
709 z2 = 0.25*(zmid(iw,j,l+1) &
710 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(i,js,l+1))
712 ELSE IF(gridtype==
'B')
THEN
717 z1 = 0.25*(zmid(iw,j,l) &
718 + zmid(ie,j,l)+zmid(i,jn,l)+zmid(ie,jn,l))
719 z2 = 0.25*(zmid(iw,j,l+1) &
720 + zmid(ie,j,l+1)+zmid(i,jn,l+1)+zmid(ie,jn,l+1))
723 dz = zmid(i,j,l)-zmid(i,j,l+1)
726 delu = uh(i,j,l)-uh(i,j,l+1)
727 delv = vh(i,j,l)-vh(i,j,l+1)
728 ufd(i,j,ifd) = uh(i,j,l) - delu*rdz*dzabv(ifd)
729 vfd(i,j,ifd) = vh(i,j,l) - delv*rdz*dzabv(ifd)
731 ufd(i,j,ifd) = uh(i,j,l)
732 vfd(i,j,ifd) = vh(i,j,l)
815 SUBROUTINE fdlvl_mass(ITYPE,NFD,PTFD,HTFD,NIN,QIN,QTYPE,QFD)
816 use vrbls3d, only: t,q,zmid,pmid,pint,zint
819 use params_mod, only: gi, g, gamma,pq0, a2, a3, a4, rhmin,rgamog
820 use ctlblk_mod
, only: jsta, jend, spval, jsta_2l, jend_2u, lm, jsta_m, &
821 jend_m, im, jm,global,modelname
822 use gridspec_mod
, only: gridtype
823 use physcons_post,only: con_fvirt, con_rog, con_eps, con_epsm1
832 real,
parameter:: zshul=75.,tvshul=290.66
834 integer,
intent(in) :: itype(nfd)
835 integer,
intent(in) :: nfd
836 real,
intent(in) :: ptfd(nfd)
837 real,
intent(in) :: htfd(nfd)
838 integer,
intent(in) :: nin
839 real,
intent(in) :: qin(im,jsta:jend,lm,nin)
840 character,
intent(in) :: qtype(nin)
841 real,
intent(out) :: qfd(im,jsta:jend,nfd,nin)
847 integer i,j,l,llmh,ifd,n
848 integer istart,istop,jstart,jstop
849 real htt,htsfc,dz,rdz,delq,htabh
851 real :: tvu,tvd,gammas,part,es,qsat,rhl,pl,zl,tl,ql
852 real :: tvrl,tvrblo,tblo,qblo
864 qfd(i,j,ifd,n) = spval
870 IF(gridtype /=
'A')
THEN
887 IF (itype(ifd) == 1)
THEN
895 llmh = nint(lmh(i,j))
903 IF (htt > htfd(ifd))
THEN
905 dzabh(ifd) = htt-htfd(ifd)
907 IF(htsfc > htfd(ifd))
THEN
923 dz = zmid(i,j,l)-zmid(i,j,l+1)
926 if(qin(i,j,l,n)<spval)
then
927 qfd(i,j,ifd,n)=qin(i,j,l+1,n)
928 elseif(qin(i,j,l+1,n)<spval)
then
929 qfd(i,j,ifd,n)=qin(i,j,l,n)
931 qfd(i,j,ifd,n) = qin(i,j,l,n) - &
932 (qin(i,j,l,n)-qin(i,j,l+1,n))*rdz*dzabh(ifd)
935 ELSEIF (l == lm)
THEN
937 qfd(i,j,ifd,n) = qin(i,j,l,n)
942 IF(modelname ==
'GFS')
THEN
943 if(qtype(n) ==
"T" .or. qtype(n) ==
"Q")
then
944 tvu = t(i,j,lm) * (1.+con_fvirt*q(i,j,lm))
945 if(zmid(i,j,lm) > zshul)
then
946 tvd = tvu + gamma*zmid(i,j,lm)
947 if(tvd > tvshul)
then
948 if(tvu > tvshul)
then
949 tvd = tvshul - 5.e-3*(tvu-tvshul)*(tvu-tvshul)
954 gammas = (tvu-tvd)/zmid(i,j,lm)
958 part = con_rog*(log(ptfd(ifd))-log(pmid(i,j,lm)))
959 part = zmid(i,j,lm) - tvu*part/(1.+0.5*gammas*part)
960 part = t(i,j,lm) - gamma*(part-zmid(i,j,lm))
962 if(qtype(n) ==
"T") qfd(i,j,ifd,n) = part
964 if(qtype(n) ==
"Q")
then
968 es = min(
fpvsnew(t(i,j,lm)), pmid(i,j,lm))
969 qsat = con_eps*es/(pmid(i,j,lm)+con_epsm1*es)
972 es = min(
fpvsnew(part), ptfd(ifd))
973 qsat = con_eps*es/(ptfd(ifd)+con_epsm1*es)
975 qfd(i,j,ifd,n) = rhl*qsat
980 if(qtype(n) ==
"T" .or. qtype(n) ==
"Q")
then
983 tl = 0.5*(t(i,j,lm-2)+t(i,j,lm-1))
984 ql = 0.5*(q(i,j,lm-2)+q(i,j,lm-1))
986 qsat = pq0/pl*exp(a2*(tl-a3)/(tl-a4))
999 tvrl = tl*(1.+0.608*ql)
1000 tvrblo = tvrl*(ptfd(ifd)/pl)**rgamog
1001 tblo = tvrblo/(1.+0.608*ql)
1003 qsat = pq0/ptfd(ifd)*exp(a2*(tblo-a3)/(tblo-a4))
1004 if(qtype(n) ==
"T") qfd(i,j,ifd,n) = tblo
1006 if(qtype(n) ==
"Q") qfd(i,j,ifd,n) = max(1.e-12,qblo)
1010 if(qtype(n) ==
"W") qfd(i,j,ifd,n)=qin(i,j,lm,n)
1011 if(qtype(n) ==
"K") qfd(i,j,ifd,n)= max(0.0,0.5*(qin(i,j,lm,n)+qin(i,j,lm-1,n)))
1012 if(qtype(n) ==
"C") qfd(i,j,ifd,n)=0.0
1034 llmh = nint(lmh(i,j))
1040 htabh = zmid(i,j,l)-htsfc
1042 IF ( htabh > htfd(ifd))
THEN
1044 dzabh(ifd) = htabh-htfd(ifd)
1054 dz = zmid(i,j,l)-zmid(i,j,l+1)
1057 if(qin(i,j,l,n)<spval)
then
1058 qfd(i,j,ifd,n)=qin(i,j,l+1,n)
1059 elseif(qin(i,j,l+1,n)<spval)
then
1060 qfd(i,j,ifd,n)=qin(i,j,l,n)
1062 qfd(i,j,ifd,n) = qin(i,j,l,n) - &
1063 (qin(i,j,l,n)-qin(i,j,l+1,n))*rdz*dzabh(ifd)
1068 qfd(i,j,ifd,n) = qin(i,j,l,n)
elemental real function, public fpvsnew(t)
calcape() computes CAPE/CINS and other storm related variables.