1 SUBROUTINE memslp_nmm(TPRES,QPRES,FIPRES)
44 use vrbls3d, only: pint, zint, t, q
47 use params_mod, only: overrc, ad05, cft0, g, rd, d608, h1, kslpd
48 use ctlblk_mod
, only: jsta, jend, spl, num_procs, mpi_comm_comp, lsmp1, jsta_m2, jend_m2,&
49 lm, jsta_m, jend_m, im, jsta_2l, jend_2u, im_jm, lsm, jm
55 integer,
PARAMETER :: nfill=0,nrlx1=500,nrlx2=100
57 real,
dimension(IM,JSTA_2L:JEND_2U,LSM),
intent(in) :: qpres
58 real,
dimension(IM,JSTA_2L:JEND_2U,LSM),
intent(inout) :: tpres,fipres
59 REAL :: ttv(im,jsta_2l:jend_2u),tnew(im,jsta_2l:jend_2u) &
60 ,slpx(im,jsta_2l:jend_2u) &
61 ,p1(im,jsta_2l:jend_2u),htm2d(im,jsta_2l:jend_2u)
62 REAL :: htmo(im,jsta_2l:jend_2u,lsm)
63 real p2,gz1,gz2,tlyr,spll,pchk,psfc,slope,tvrt,dis,tinit
66 INTEGER :: kmntm(lsm),imnt(im_jm,lsm),jmnt(im_jm,lsm) &
67 ,lmho(im,jsta_2l:jend_2u)
68 INTEGER :: ihe(jm),ihw(jm),ive(jm),ivw(jm),ihs(jm),ihn(jm)
69 integer ii,jj,i,j,l,n,km,ks,kp,kmn,kmm,kount,lp,llmh,lhmnt &
70 ,lmhij,lmap1,lxxx,ierr,nrlx,ihh2
72 LOGICAL :: done(im,jsta_2l:jend_2u)
73 logical,
parameter :: debugprint = .false.
95 pslp(i,j)=pint(i,j,llmh+1)
96 if(debugprint .and. i==ii .and. j==jj)print*,
'Debug: FIS,IC for PSLP=' &
121 pchk=pint(i,j,nint(lmh(i,j))+1-nfill)
124 IF(fis(i,j)<1.)pchk=pslp(i,j)
131 IF(l>1.AND.htmo(i,j,l-1)>0.5)lmho(i,j)=l-1
134 IF(l==lsm.AND.htmo(i,j,l)>0.5)lmho(i,j)=lsm
135 if(debugprint .and. i==ii .and. j==jj)print*,
'Debug: HTMO= ',htmo(i,j,l)
148 loop210:
DO l=lsm,1,-1
152 IF(htmo(i,j,l)<0.5) cycle loop210
160 if(debugprint)print*,
'Debug in SLP: LHMNT=',lhmnt
161 if ( num_procs > 1 )
then
163 (lhmnt,lxxx,1,mpi_integer,mpi_min,mpi_comm_comp,ierr)
170 if(debugprint)print*,
'Debug in SLP: LHMNT A ALLREDUCE=',lhmnt
179 DO 240 j=jsta_m2,jend_m2
185 IF(htmo(i,j,l)>0.5) cycle
208 ttv(i,j)=tpres(i,j,l)
209 IF(ttv(i,j)<150. .and. ttv(i,j)>325.0)print* &
210 ,
'abnormal IC for T relaxation',i,j,ttv(i,j)
211 htm2d(i,j)=htmo(i,j,l)
217 CALL exch2(htm2d(1,jsta_2l))
220 IF(htm2d(i,j)>0.5.AND.htm2d(i+ihw(j),j-1)*htm2d(i+ihe(j),j-1) &
221 *htm2d(i+ihw(j),j+1)*htm2d(i+ihe(j),j+1) &
222 *htm2d(i-1 ,j )*htm2d(i+1 ,j ) &
223 *htm2d(i ,j-2)*htm2d(i ,j+2)<0.5)
THEN
231 ttv(i,j)=tpres(i,j,l)*(1.+0.608*qpres(i,j,l))
240 CALL exch2(ttv(1,jsta_2l))
246 tnew(i,j)=ad05*(4.*(ttv(i+ihw(j),j-1)+ttv(i+ihe(j),j-1) &
247 +ttv(i+ihw(j),j+1)+ttv(i+ihe(j),j+1)) &
248 +ttv(i-1,j) +ttv(i+1,j) &
249 +ttv(i,j-2) +ttv(i,j+2)) &
274 tpres(i,j,l)=ttv(i,j)
294 IF(abs(fis(i,j))<1.)
THEN
295 pslp(i,j)=pint(i,j,nint(lmh(i,j))+1)
298 if(i==ii.and.j==jj)print*,
'Debug:DONE,PSLP A S1=' &
300 ELSE IF(fis(i,j)<-1.0)
THEN
302 IF(zint(i,j,l)>0.)
THEN
303 pslp(i,j)=pint(i,j,l)/exp(-zint(i,j,l)*g &
304 /(rd*t(i,j,l)*(q(i,j,l)*d608+1.0)))
306 if(debugprint .and. i==ii.and.j==jj)print* &
307 ,
'Debug:DONE,PINT,PSLP A S1=' &
308 ,done(i,j),pint(i,j,l),pslp(i,j)
324 gz1=fipres(i,j,lmhij)
330 tlyr=0.5*(tpres(i,j,l)+tpres(i,j,l-1))
331 gz2=gz1+rd*tlyr*alog(p1(i,j)/p2)
335 pslp(i,j)=p1(i,j)/exp(-gz1/(rd*tpres(i,j,l-1)))
347 tlyr=tpres(i,j,lp)-0.5*fipres(i,j,lp)*slope
348 pslp(i,j)=spl(lp)/exp(-fipres(i,j,lp)/(rd*tlyr))
373 if(debugprint .and. i==ii.and.j==jj)print*,
'Debug: with 330 loop'
375 if(debugprint .and. i==ii.and.j==jj)print*,
'Debug: still within 330 loop'
389 IF(pint(i,j,nint(lmh(i,j))+1)>spl(lp))
THEN
391 tvrt=t(i,j,llmh)*(h1+d608*q(i,j,llmh))
392 dis=zint(i,j,llmh+1)-zint(i,j,llmh)+0.5*zint(i,j,llmh+1)
393 tlyr=tvrt-dis*g*slope
394 pslp(i,j)=pint(i,j,llmh+1)*exp(zint(i,j,llmh+1)*g/(rd*tlyr))
398 tlyr=tpres(i,j,lp)-0.5*fipres(i,j,lp)*slope
399 pslp(i,j)=spl(lp)/exp(-fipres(i,j,lp)/(rd*tlyr))
400 if(debugprint .and. i==ii.and.j==jj)print*,
'Debug:spl,FI,TLYR,PSLPA3=' &
401 ,spl(lp),fipres(i,j,lp),tlyr,pslp(i,j)