40 subroutine pvetc(km,p,px,py,t,tx,ty,h,u,v,av,hm,s,bvf2,pvn,theta,sigma,pvu)
45 integer,
intent(in):: km
46 real,
intent(in),
dimension(km):: p,px,py,t,tx,ty,h,u,v,av
47 real,
intent(out),
dimension(km):: hm,s,bvf2,pvn,theta,sigma,pvu
49 real,
parameter:: hhmin=5.,t0=2.e2,p0=1.e5
51 real cprho,sx,sy,sz,uz,vz
54 hm(k) = con_cp*t(k) + con_g*h(k)
55 s(k) = con_cp*log(t(k)/t0) - con_rd*log(p(k)/p0)
58 call
rsearch1(km,h,2,(/h(k)-hhmin,h(k)+hhmin/),k2)
66 cprho = p(k)/(con_rocp*t(k))
67 sx = con_cp*tx(k) / t(k)-con_rd*px(k)/p(k)
68 sy = con_cp*ty(k) / t(k)-con_rd*py(k)/p(k)
69 sz = (s(ku)-s(kd)) / (h(ku)-h(kd))
70 uz = (u(ku)-u(kd)) / (h(ku)-h(kd))
71 vz = (v(ku)-v(kd)) / (h(ku)-h(kd))
72 bvf2(k) = con_g/con_cp*sz
73 pvn(k) = (av(k)*sz - vz*sx + uz*sy) / cprho
74 theta(k) = t0*exp(s(k)/con_cp)
75 sigma(k) = t(k)/con_g*bvf2(k)
76 pvu(k) = 1.e6*theta(k)*pvn(k)
109 subroutine p2th(km,theta,u,v,h,t,pvu,sigma,rh,omga,kth,th &
110 ,lth,uth,vth,hth,tth,zth,sigmath,rhth,oth)
112 integer,
intent(in):: km,kth
113 real,
intent(in),
dimension(km):: theta,u,v,h,t,pvu,sigma,rh,omga
114 real,
intent(in):: th(kth)
115 logical*1,
intent(out),
dimension(kth):: lth
116 real,
intent(out),
dimension(kth):: uth,vth,hth,tth,zth &
122 call
rsearch1(km,theta(1),kth,th(1),loc(1))
125 lth(k) = l > 0 .and.l < km
127 w = log(th(k)/theta(l)) / log(theta(l+1)/theta(l))
128 uth(k) = u(l) + w*(u(l+1)-u(l))
129 vth(k) = v(l) + w*(v(l+1)-v(l))
130 hth(k) = h(l) + w*(h(l+1)-h(l))
131 tth(k) = t(l) + w*(t(l+1)-t(l))
132 zth(k) = pvu(l) + w*(pvu(l+1)-pvu(l))
133 sigmath(k) = sigma(l) + w*(sigma(l+1)-sigma(l))
134 rhth(k) = rh(l) + w*(rh(l+1)-rh(l))
136 oth(k) = omga(l) + w*(omga(l+1)-omga(l))
175 subroutine p2pv(km,pvu,h,t,p,u,v,kpv,pv,pvpt,pvpb,&
176 lpv,upv,vpv,hpv,tpv,ppv,spv)
179 integer,
intent(in):: km,kpv
180 real,
intent(in),
dimension(km):: pvu,h,t,p,u,v
181 real,
intent(in):: pv(kpv),pvpt(kpv),pvpb(kpv)
182 logical*1,
intent(out),
dimension(kpv):: lpv
183 real,
intent(out),
dimension(kpv):: upv,vpv,hpv,tpv,ppv,spv
187 real,
parameter:: pd=5000.
189 integer k,l1,l2,lu,ld,l
201 if(pv(k) >= pvu(lu+1).and.pv(k) < pvu(lu))
then
204 if(all(pv(k) >= pvu(lu+1:ld)))
then
215 if(pv(k) <= pvu(lu+1).and.pv(k) > pvu(lu))
then
218 if(all(pv(k) <= pvu(lu+1:ld)))
then
227 w = (pv(k)-pvu(l))/(pvu(l+1)-pvu(l))
228 upv(k) = u(l) + w*(u(l+1)-u(l))
229 vpv(k) = v(l) + w*(v(l+1)-v(l))
230 hpv(k) = h(l) + w*(h(l+1)-h(l))
231 tpv(k) = t(l) + w*(t(l+1)-t(l))
232 ppv(k) = p(l)*exp((h(l)-hpv(k))*(1-0.5*(tpv(k)/t(l)-1))/(con_rog*t(l)))
234 spdu = sqrt(u(l+1)*u(l+1) + v(l+1)*v(l+1))
235 spdd = sqrt(u(l)*u(l) + v(l)*v(l))
236 spv(k) = (spdu-spdd) / (h(l+1)-h(l))
271 integer,
intent(in):: km1,km2
272 real,
intent(in):: z1(km1),z2(km2)
273 integer,
intent(out):: l2(km2)
277 if(z1(1) <= z1(km1))
then
281 if (z1(1) >= z2(k2))
then
286 if(z1(k1) <= z2(k2) .and. z1(k1+1) > z2(k2))
then
297 if (z1(1) <= z2(k2))
then
302 if(z2(k2) >= z1(k1) .and. z2(k2) < z1(k1-1))
then
344 subroutine tpause(km,p,u,v,t,h,ptp,utp,vtp,ttp,htp,shrtp)
347 integer,
intent(in):: km
348 real,
intent(in),
dimension(km):: p,u,v,t,h
349 real,
intent(out):: ptp,utp,vtp,ttp,htp,shrtp
350 real,
parameter:: ptplim(2)=(/500.e+2,50.e+2/),gamtp=2.e-3,hd=2.e+3
351 real gamu,gamd,td,gami,wtp,spdu,spdd
352 integer klim(2),k,kd,ktp
355 call
rsearch1(km-2,p(2),2,ptplim,klim)
364 do k=klim(1),klim(2),-1
366 gamu=(t(k+1)-t(k-1))/(h(k-1)-h(k+1))
369 call
rsearch1(k-2,h(2),1,h(k)+hd,kd)
371 td=t(kd+2)+(h(k)+hd-h(2+kd))/(h(kd+1)-h(2+kd))*(t(kd+1)-t(2+kd))
375 wtp=(gamtp-gamu)/(max(gamd,gamtp+0.1e-3)-gamu)
383 utp=u(ktp)-wtp*(u(ktp)-u(ktp-1))
384 vtp=v(ktp)-wtp*(v(ktp)-v(ktp-1))
385 ttp=t(ktp)-wtp*(t(ktp)-t(ktp-1))
386 htp=h(ktp)-wtp*(h(ktp)-h(ktp-1))
387 ptp=p(ktp)*exp((h(ktp)-htp)*(1-0.5*(ttp/t(ktp)-1))/(con_rog*t(ktp)))
388 spdu=sqrt(u(ktp)**2+v(ktp)**2)
389 spdd=sqrt(u(ktp-1)**2+v(ktp-1)**2)
390 shrtp=(spdu-spdd)/(h(ktp)-h(ktp-1))
392 utp=u(ktp)-wtp*(u(ktp)-u(ktp+1))
393 vtp=v(ktp)-wtp*(v(ktp)-v(ktp+1))
394 ttp=t(ktp)-wtp*(t(ktp)-t(ktp+1))
395 htp=h(ktp)-wtp*(h(ktp)-h(ktp+1))
396 ptp=p(ktp)*exp((h(ktp)-htp)*(1-0.5*(ttp/t(ktp)-1))/(con_rog*t(ktp)))
397 spdu=sqrt(u(ktp)**2+v(ktp)**2)
398 spdd=sqrt(u(ktp+1)**2+v(ktp+1)**2)
399 shrtp=(spdu-spdd)/(h(ktp)-h(ktp+1))
431 subroutine mxwind(km,p,u,v,t,h,pmw,umw,vmw,tmw,hmw)
434 integer,
intent(in):: km
435 real,
intent(in),
dimension(km):: p,u,v,t,h
436 real,
intent(out):: pmw,umw,vmw,tmw,hmw
437 real,
parameter:: pmwlim(2)=(/500.e+2,100.e+2/)
438 integer klim(2),k,kmw
439 real spd(km),spdmw,wmw,dhd,dhu,shrd,shru,dhmw,ub,vb,spdb
442 call
rsearch1(km,p(1),2,pmwlim,klim)
446 spd(klim(2):klim(1))=sqrt(u(klim(2):klim(1))**2+v(klim(2):klim(1))**2)
450 do k=klim(1)-1,klim(2),-1
451 if(spd(k)>spdmw)
then
458 if(kmw==klim(1).or.kmw==klim(2))
then
468 shrd=(spd(kmw)-spd(kmw+1))/(h(kmw)-h(kmw+1))
470 shru=(spd(kmw)-spd(kmw-1))/(h(kmw-1)-h(kmw))
471 dhmw=(shrd*dhu-shru*dhd)/(2*(shrd+shru))
473 spdmw=spd(kmw)+dhmw**2*(shrd+shru)/(dhd+dhu)
477 wmw=(h(kmw)-hmw)/(h(kmw)-h(kmw+1))
482 ub=u(kmw)-wmw*(u(kmw)-u(kmw+1))
484 vb=v(kmw)-wmw*(v(kmw)-v(kmw+1))
485 spdb=max(sqrt(ub**2+vb**2),1.e-6)
489 tmw=t(kmw)-wmw*(t(kmw)-t(kmw+1))
490 pmw=p(kmw)*exp((h(kmw)-hmw)*(1-0.5*(tmw/t(kmw)-1))/(con_rog*t(kmw)))
519 subroutine mptgen(mpirank,mpisize,nd,jt1,jt2,j1,j2,jx,jm,jn)
520 use machine_post
,only:kint_mpi
522 integer(kint_mpi),
intent(in):: mpirank,mpisize,nd,jt1(nd),jt2(nd)
523 integer(kint_mpi),
intent(out):: j1(nd),j2(nd),jx(nd),jm(nd),jn(nd)
524 integer msize,mrank,msn,mrn,n
529 if(jt2(n)>=jt1(n))
then
530 jm(n)=(jt2(n)-jt1(n))/msize+1
531 msn=max(msize/(jt2(n)-jt1(n)+1),1)
535 j1(n)=min(jt1(n)+jm(n)*mrn,jt2(n)+1)
536 j2(n)=min(jt1(n)+jm(n)*mrn+jm(n)-1,jt2(n))
540 write(0,*)
' mrank=',mrank,
' j1=',j1(n),
' j2=',j2(n),
' jx=',jx(n),
' jm=',jm(n)
622 jm,jma,jmb,jda,km,kma,kmb,kdb,a,b,ta,tb)
623 use machine_post
,only:kint_mpi
626 integer(kint_mpi),
intent(in):: mpicomm,mpisize
627 integer(kint_mpi),
intent(in):: im,ida,idb
628 integer(kint_mpi),
intent(in):: jm,jma,jmb,jda
629 integer(kint_mpi),
intent(in):: km,kma,kmb,kdb
630 real(4),
dimension(ida,jda,kma),
intent(in):: a
631 real(4),
dimension(idb,kdb,jmb),
intent(out):: b
632 real(4),
dimension(im,jm,km,mpisize),
intent(inout):: ta,tb
633 integer(4) jmb1(1),jmbf(mpisize),kma1(1),kmaf(mpisize)
634 integer(kint_mpi)::i,j,k,l,ierr,ja,kb
637 call mpi_allgather(jmb1,1,mpi_integer4,jmbf,1,mpi_integer4,mpicomm,ierr)
639 call mpi_allgather(kma1,1,mpi_integer4,kmaf,1,mpi_integer4,mpicomm,ierr)
646 ja = j + sum(jmbf(1:l-1))
649 ta(i,j,k,l) = a(i,ja,k)
657 call mpi_alltoall(ta,im*jm*km,mpi_real4,tb,im*jm*km,mpi_real4,mpicomm,ierr)
663 kb = k + sum(kmaf(1:l-1))
667 b(i,kb,j) = tb(i,j,k,l)
subroutine mxwind(km, p, u, v, t, h, pmw, umw, vmw, tmw, hmw)
mxwind() computes maximum wind level fields.
subroutine mptgen(mpirank, mpisize, nd, jt1, jt2, j1, j2, jx, jm, jn)
mptgen() generates grid decomposition dimensions.
subroutine p2th(km, theta, u, v, h, t, pvu, sigma, rh, omga, kth, th, lth, uth, vth, hth, tth, zth, sigmath, rhth, oth)
p2th() interpolates to isentropic level.
subroutine mptranr4(mpicomm, mpisize, im, ida, idb, jm, jma, jmb, jda, km, kma, kmb, kdb, a, b, ta, tb)
mptranr4() transposes grid decompositions.
subroutine p2pv(km, pvu, h, t, p, u, v, kpv, pv, pvpt, pvpb, lpv, upv, vpv, hpv, tpv, ppv, spv)
p2pv() interpolates to potential vorticity level.
subroutine tpause(km, p, u, v, t, h, ptp, utp, vtp, ttp, htp, shrtp)
tpause() computes tropopause level fields.
subroutine rsearch1(km1, z1, km2, z2, l2)
rsearch1() searches for a surrounding real interval.