16 SUBROUTINE mdl2std_p()
19 use vrbls3d, only: pint, pmid, zmid
20 use vrbls3d, only: t, q, uh, vh, omga, cwm, qqw, qqi, qqr, qqs, qqg
22 use vrbls3d, only: icing_gfip, icing_gfis, catedr, mwt, gtg
23 use ctlblk_mod
, only: grib, cfld, fld_info, datapd, im, jsta, jend, jm, &
24 lm, htfd, spval, nfd, me,&
25 jsta_2l, jend_2u, modelname
26 use rqstfld_mod
, only: iget, lvls, iavblfld, lvlsxml
34 real,
external :: p2h, relabel
36 real,
dimension(im,jsta_2l:jend_2u) :: grid1
37 real,
dimension(im,jsta_2l:jend_2u) :: egrid1,egrid2,egrid3,egrid4
40 integer i,j,jj,l,itype,ifd,itypefdlvl(nfd)
44 REAL,
allocatable :: htfdctl(:)
45 integer,
allocatable :: itypefdlvlctl(:)
46 real,
allocatable :: qin(:,:,:,:), qfd(:,:,:,:)
47 character,
allocatable :: qtype(:)
48 real,
allocatable :: var3d1(:,:,:), var3d2(:,:,:)
50 integer,
parameter :: nfdmax=50
51 integer :: ids(nfdmax)
75 IF(iget(450)>0 .or. iget(480)>0 .or. &
76 iget(464)>0 .or. iget(465)>0 .or. iget(466)>0 .or. &
77 iget(518)>0 .or. iget(519)>0 .or. iget(520)>0 .or. &
78 iget(521)>0 .or. iget(522)>0 .or. iget(523)>0 .or. &
79 iget(524)>0 .or. iget(525)>0)
then
82 IF(iget(520)>0 .or. iget(521)>0 .or. iget(524) > 0 )
THEN
85 n = iavblfld(iget(iid))
86 nfdctl=
size(pset%param(n)%level)
87 if(
allocated(itypefdlvlctl))
deallocate(itypefdlvlctl)
88 allocate(itypefdlvlctl(nfdctl))
90 itypefdlvlctl(ifd)=lvls(ifd,iget(iid))
92 if(
allocated(htfdctl))
deallocate(htfdctl)
93 allocate(htfdctl(nfdctl))
94 htfdctl=pset%param(n)%level
96 htfdctl(i)=p2h(htfdctl(i)/100.)
98 if(
allocated(var3d1))
deallocate(var3d1)
99 if(
allocated(var3d2))
deallocate(var3d2)
100 allocate(var3d1(im,jsta_2l:jend_2u,nfdctl))
101 allocate(var3d2(im,jsta_2l:jend_2u,nfdctl))
105 call fdlvl_uv(itypefdlvlctl,nfdctl,htfdctl,var3d1,var3d2)
109 IF (lvls(ifd,iget(520)) > 0)
THEN
113 grid1(i,j)=var3d1(i,j,ifd)
116 if(grib==
'grib2')
then
118 fld_info(cfld)%ifld=iavblfld(iget(520))
119 fld_info(cfld)%lvl=lvlsxml(ifd,iget(520))
124 datapd(i,j,cfld) = grid1(i,jj)
130 IF (lvls(ifd,iget(521)) > 0)
THEN
134 grid1(i,j)=var3d2(i,j,ifd)
137 if(grib==
'grib2')
then
139 fld_info(cfld)%ifld=iavblfld(iget(521))
140 fld_info(cfld)%lvl=lvlsxml(ifd,iget(521))
145 datapd(i,j,cfld) = grid1(i,jj)
151 IF (lvls(ifd,iget(524)) > 0)
THEN
152 egrid1=var3d1(1:im,jsta_2l:jend_2u,ifd)
153 egrid2=var3d2(1:im,jsta_2l:jend_2u,ifd)
154 call calvor(egrid1,egrid2,egrid3)
158 grid1(i,j)=egrid3(i,j)
161 if(grib==
'grib2')
then
163 fld_info(cfld)%ifld=iavblfld(iget(524))
164 fld_info(cfld)%lvl=lvlsxml(ifd,iget(524))
169 datapd(i,j,cfld) = grid1(i,jj)
185 if(
allocated(qin))
deallocate(qin)
186 if(
allocated(qtype))
deallocate(qtype)
187 ALLOCATE(qin(im,jsta:jend,lm,nfdmax))
188 ALLOCATE(qtype(nfdmax))
192 IF(iget(450) > 0)
THEN
195 qin(1:im,jsta:jend,1:lm,nfds)=icing_gfip(1:im,jsta:jend,1:lm)
198 IF(iget(480) > 0)
THEN
201 qin(1:im,jsta:jend,1:lm,nfds)=icing_gfis(1:im,jsta:jend,1:lm)
204 IF(iget(464) > 0)
THEN
207 qin(1:im,jsta:jend,1:lm,nfds)=gtg(1:im,jsta:jend,1:lm)
210 IF(iget(465) > 0)
THEN
213 qin(1:im,jsta:jend,1:lm,nfds)=catedr(1:im,jsta:jend,1:lm)
216 IF(iget(466) > 0)
THEN
219 qin(1:im,jsta:jend,1:lm,nfds)=mwt(1:im,jsta:jend,1:lm)
222 IF(iget(519) > 0)
THEN
225 qin(1:im,jsta:jend,1:lm,nfds)=t(1:im,jsta:jend,1:lm)
228 IF(iget(523) > 0)
THEN
231 qin(1:im,jsta:jend,1:lm,nfds)=omga(1:im,jsta:jend,1:lm)
234 IF(iget(525) > 0)
THEN
237 qin(1:im,jsta:jend,1:lm,nfds)=qqw(1:im,jsta:jend,1:lm)+ &
238 qqr(1:im,jsta:jend,1:lm)+ &
239 qqs(1:im,jsta:jend,1:lm)+ &
240 qqg(1:im,jsta:jend,1:lm)+ &
241 qqi(1:im,jsta:jend,1:lm)
247 n = iavblfld(iget(iid))
248 nfdctl=
size(pset%param(n)%level)
249 if(
allocated(itypefdlvlctl))
deallocate(itypefdlvlctl)
250 allocate(itypefdlvlctl(nfdctl))
252 itypefdlvlctl(ifd)=lvls(ifd,iget(iid))
254 if(
allocated(htfdctl))
deallocate(htfdctl)
255 allocate(htfdctl(nfdctl))
256 htfdctl=pset%param(n)%level
258 htfdctl(i)=p2h(htfdctl(i)/100.)
261 if(
allocated(qfd))
deallocate(qfd)
262 ALLOCATE(qfd(im,jsta:jend,nfdctl,nfds))
265 call fdlvl_mass(itypefdlvlctl,nfdctl,pset%param(n)%level,htfdctl,nfds,qin,qtype,qfd)
278 if(qfd(i,j,ifd,n) < spval)
then
279 qfd(i,j,ifd,n)=max(0.0,qfd(i,j,ifd,n))
280 qfd(i,j,ifd,n)=min(1.0,qfd(i,j,ifd,n))
293 if(qfd(i,j,ifd,n) < spval)
then
294 qfd(i,j,ifd,n)=max(0.0,qfd(i,j,ifd,n))
314 if(qfd(i,j,ifd,n1) < 0.001) qfd(i,j,ifd,n)=0.
316 if(qfd(i,j,ifd,n) == spval) cycle
317 if (qfd(i,j,ifd,n) < 0.08)
then
319 elseif (qfd(i,j,ifd,n) <= 0.21)
then
321 else if(qfd(i,j,ifd,n) <= 0.37)
then
323 else if(qfd(i,j,ifd,n) <= 0.67)
then
334 if(iid==464 .or. iid==465 .or. iid==466)
then
338 if(qfd(i,j,ifd,n) < spval)
then
339 qfd(i,j,ifd,n)=max(0.0,qfd(i,j,ifd,n))
340 qfd(i,j,ifd,n)=min(1.0,qfd(i,j,ifd,n))
353 IF (lvls(ifd,iget(iid)) > 0)
THEN
357 grid1(i,j)=qfd(i,j,ifd,n)
360 if(grib==
'grib2')
then
362 fld_info(cfld)%ifld=iavblfld(iget(iid))
363 fld_info(cfld)%lvl=lvlsxml(ifd,iget(iid))
368 datapd(i,j,cfld) = grid1(i,jj)
383 IF(iget(518) > 0)
THEN
385 n = iavblfld(iget(iid))
386 nfdctl=
size(pset%param(n)%level)
387 if(
allocated(htfdctl))
deallocate(htfdctl)
388 allocate(htfdctl(nfdctl))
389 htfdctl=pset%param(n)%level
391 htfdctl(i)=p2h(htfdctl(i)/100.)
395 IF (lvls(ifd,iget(iid)) > 0)
THEN
399 grid1(i,j)=htfdctl(ifd)
402 if(grib==
'grib2')
then
404 fld_info(cfld)%ifld=iavblfld(iget(iid))
405 fld_info(cfld)%lvl=lvlsxml(ifd,iget(iid))
410 datapd(i,j,cfld) = grid1(i,jj)
419 IF(iget(522) > 0)
THEN
421 n = iavblfld(iget(iid))
422 nfdctl=
size(pset%param(n)%level)
423 if(
allocated(itypefdlvlctl))
deallocate(itypefdlvlctl)
424 allocate(itypefdlvlctl(nfdctl))
426 itypefdlvlctl(ifd)=lvls(ifd,iget(iid))
428 if(
allocated(htfdctl))
deallocate(htfdctl)
429 allocate(htfdctl(nfdctl))
430 htfdctl=pset%param(n)%level
432 htfdctl(i)=p2h(htfdctl(i)/100.)
435 if(
allocated(qin))
deallocate(qin)
436 if(
allocated(qtype))
deallocate(qtype)
437 ALLOCATE(qin(im,jsta:jend,lm,2))
439 qin(1:im,jsta:jend,1:lm,1)=t(1:im,jsta:jend,1:lm)
440 qin(1:im,jsta:jend,1:lm,2)=q(1:im,jsta:jend,1:lm)
444 if(
allocated(qfd))
deallocate(qfd)
445 ALLOCATE(qfd(im,jsta:jend,nfdctl,2))
448 print *,
"wafs levels",pset%param(n)%level
449 call fdlvl_mass(itypefdlvlctl,nfdctl,pset%param(n)%level,htfdctl,2,qin,qtype,qfd)
451 htfdctl=pset%param(n)%level
454 IF (lvls(ifd,iget(iid)) > 0)
THEN
458 egrid2(i,j) = htfdctl(ifd)
462 egrid3(1:im,jsta:jend)=qfd(1:im,jsta:jend,ifd,1)
463 egrid4(1:im,jsta:jend)=qfd(1:im,jsta:jend,ifd,2)
466 CALL calrh(egrid2(1,jsta),egrid3(1,jsta),egrid4(1,jsta),egrid1(1,jsta))
471 IF(egrid1(i,j) < spval)
THEN
472 grid1(i,j) = egrid1(i,j)*100.
474 grid1(i,j) = egrid1(i,j)
479 if(grib==
'grib2')
then
481 fld_info(cfld)%ifld=iavblfld(iget(iid))
482 fld_info(cfld)%lvl=lvlsxml(ifd,iget(iid))
487 datapd(i,j,cfld) = grid1(i,jj)
500 ids = (/ 450,480,464,465,466,518,519,520,521,522,523,524,525,(0,i=14,50) /)
504 n = iavblfld(iget(iid))
505 nfdctl=
size(pset%param(n)%level)
507 pset%param(n)%level(j) = relabel(pset%param(n)%level(j))
521 real,
intent(in) :: p
526 real,
parameter :: lapse = 0.0065
527 real,
parameter :: surf_temp = 288.15
528 real,
parameter :: gravity = 9.80665
529 real,
parameter :: moles_dry_air = 0.02896442
530 real,
parameter :: gas_const = 8.31432
531 real,
parameter :: surf_pres = 1013.25
532 real,
parameter :: power_const = (gravity * moles_dry_air) &
533 / (gas_const * lapse)
535 p2h = (surf_temp/lapse)*(1-(p/surf_pres)**(1/power_const))
540 real,
intent(in) :: p
543 if(p == 10040.) relabel=10000
544 if(p == 12770.) relabel=12500
545 if(p == 14750.) relabel=15000
546 if(p == 17870.) relabel=17500
547 if(p == 19680.) relabel=20000
548 if(p == 22730.) relabel=22500
549 if(p == 27450.) relabel=27500
550 if(p == 30090.) relabel=30000
551 if(p == 34430.) relabel=35000
552 if(p == 39270.) relabel=40000
553 if(p == 44650.) relabel=45000
554 if(p == 50600.) relabel=50000
555 if(p == 59520.) relabel=60000
556 if(p == 69680.) relabel=70000
557 if(p == 75260.) relabel=75000
558 if(p == 81200.) relabel=80000
559 if(p == 84310.) relabel=85000
calcape() computes CAPE/CINS and other storm related variables.