52 subroutine rtsig(lusig,head,k1,k2,kgds,ijo,levs,ntrac,jcap,lnt2,me, &
53 h,p,px,py,t,u,v,d,trc,iret)
55 use sigio_module
, only : sigio_intkind, sigio_head
56 use sigio_r_module
, only : sigio_dati, sigio_rrdati
60 integer(sigio_intkind),
intent(in) :: lusig
61 type(sigio_head
),
intent(in) :: head
62 integer,
intent(in) :: k1,k2,kgds(200),ijo,levs,ntrac,jcap,lnt2,me
63 real,
dimension(ijo),
intent(out) :: h,p,px,py
64 real,
dimension(ijo,k1:k2),
intent(out):: t,u,v,d
65 real,
dimension(ijo,k1:k2,ntrac),
intent(out),
target :: trc
66 integer,
intent(out) :: iret
68 integer idrt,io,jo,iidea
70 integer(sigio_intkind):: irets
77 real,
target :: trisca(lnt2,k1:k2+1), triscb(lnt2,k1:k2)
78 real,
dimension(:),
allocatable :: cpi
79 real,
dimension(:,:),
allocatable :: wrk
80 integer io3,ict,jct,n,i,k,jc,nt
87 if(kgds(1) == 0 .and. kgds(4) < 90000) idrt = 256
94 print*,
'Debug rtsig= ',lusig,k1,k2,ijo,kgds(1:20)
105 dati%f => trisca(:,k1)
106 call sigio_rrdati(lusig,head,dati,irets)
107 if(irets /= 0)
return
115 dati%f => trisca(:,k1+1)
116 call sigio_rrdati(lusig,head,dati,irets)
117 if(irets /= 0)
return
123 call sptezm(0,jcap,idrt,io,jo,2,trisca(1,k1),wrk,1)
124 if( mod(idvm,10) < 2)
then
128 p(i) = 1.e3*exp(wrk(i,2))
131 elseif(mod(idvm,10) == 2)
then
135 p(i) = 1000.*wrk(i,2)
139 if (
allocated(wrk))
deallocate(wrk)
141 call sptezd(0,jcap,idrt,io,jo,trisca(1,k1+1),pmean,px,py,1)
152 write(0,*)
' retriving T for k=',k,
' k1=',k1,
' k2=',k2
154 dati%f => trisca(:,k)
156 call sigio_rrdati(lusig,head,dati,iret)
158 call sptezm(0,jcap,idrt,io,jo,klen,trisca(1,k1),t(1,k1),1)
161 dati%i = levs + 2 + (k-1) * 2 + 1
162 dati%f => trisca(:,k)
163 call sigio_rrdati(lusig,head,dati,irets)
164 if(irets /= 0)
return
165 dati%i = levs + 2 + (k-1) * 2 + 2
166 dati%f => triscb(:,k)
167 call sigio_rrdati(lusig,head,dati,irets)
168 if(irets /= 0)
return
170 call sptezmv(0,jcap,idrt,io,jo,klen,trisca(1,k1),triscb(1,k1), &
172 call sptezm(0,jcap,idrt,io,jo,klen,trisca(1,k1),d(1,k1),1)
175 write(0,*)
' retriving d/z for k=',k,
' k1=',k1,
' k2=',k2
178 write(0,*)
' start get tracer'
181 dati%i = levs * (2+nt) + 2 + k
182 dati%f => trisca(:,k)
183 call sigio_rrdati(lusig,head,dati,irets)
185 call sptezm(0,jcap,idrt,io,jo,klen,trisca(1,k1),trc(1,k1,nt),1)
186 write(0,*)
' retriving d/z for nt=',nt,
'ntrac=',ntrac,
'k=',k,
' k1=',k1,
' k2=',k2
189 write(0,*)
' end get tracer,idvm=',idvm,
'ijo=',ijo,
'ntrac=',ntrac
192 if (mod(idvm/10,10) == 3)
then
193 allocate(cpi(0:ntrac))
195 cpi(0:ntrac) = head%cpi(1:ntrac+1)
203 if( cpi(n) /= 0.0 )
then
204 xcp = xcp + cpi(n)*trc(i,k,n)
205 sumq = sumq + trc(i,k,n)
208 xcp = (1.-sumq)*cpi(0) + xcp
209 t(i,k) = t(i,k) / xcp
212 if (
allocated(cpi))
deallocate(cpi)
217 t(i,k) = t(i,k) / (1+con_fvirt*trc(i,k,1))
255 subroutine modstuff(km,idvc,idsl,nvcoord,vcoord,ps,psx,psy,d,u,v,&
257 use sigio_module
, only: sigio_modprd
259 integer,
intent(in):: km,idvc,idsl,nvcoord
260 real,
intent(in):: vcoord(km+1,nvcoord)
261 real,
intent(in):: ps,psx,psy
262 real,
intent(in):: u(km),v(km),d(km)
264 real*8,
intent(out):: pi(km+1),pm(km)
265 real,
intent(out):: om(km)
266 real*8 ps8,pm8(km),pd8(km),vcoord8(km+1,nvcoord)
267 real*8 dpmdps(km),dpddps(km),dpidps(km+1),pi8(km+1)
268 real vgradp,pd(km),px(km),py(km),os
273 call sigio_modprd(1,1,km,nvcoord,idvc,idsl,vcoord8,iret,&
275 pm=pm8,pd=pd8,dpmdps=dpmdps,dpddps=dpddps)
283 pi8(k+1)=pi8(k)-pd8(k)
284 dpidps(k+1)=dpidps(k)-dpddps(k)
293 vgradp=u(k)*psx+v(k)*psy
294 os=os-vgradp*ps*(dpmdps(k)-dpidps(k+1))-d(k)*(pm(k)-pi(k+1))
295 om(k)=vgradp*ps*dpmdps(k)+os
296 os=os-vgradp*ps*(dpidps(k)-dpmdps(k))-d(k)*(pi(k)-pm(k))
333 subroutine modstuff2(im,ix,km,idvc,idsl,nvcoord,vcoord,ps,psx,psy,d,u,v,&
335 use sigio_module
, only : sigio_modprd
337 integer,
intent(in) :: im,ix,km,idvc,idsl,nvcoord,me
338 real,
intent(in) :: vcoord(km+1,nvcoord)
339 real,
dimension(ix),
intent(in) :: ps,psx,psy
340 real,
dimension(ix,km),
intent(in) :: u,v,d
341 real*8,
dimension(ix,km+1),
intent(out) :: pi
342 real*8,
dimension(ix,km),
intent(out) :: pm
343 real,
dimension(ix,km),
intent(out) :: om
351 real*8 ps8(ix),pm8(ix,km),pd8(ix,km),vcoord8(km+1,nvcoord)
352 real*8 dpmdps(ix,km),dpddps(ix,km),dpidps(ix,km+1),pi8(ix,km+1)
353 real vgradpps,pd(im,km),os(im)
355 integer i,k,iret,logk
360 call sigio_modprd(im,ix,km,nvcoord,idvc,idsl,vcoord8,iret, &
361 ps=ps8,pd=pd8,dpddps=dpddps,pm=pm8,dpmdps=dpmdps)
380 pi8(i,k+1) = pi8(i,k) - pd8(i,k)
381 dpidps(i,k+1) = dpidps(i,k) - dpddps(i,k)
385 pi(i,k+1) = pi8(i,k+1)
393 vgradpps = (u(i,k)*psx(i) + v(i,k)*psy(i)) * ps(i)
395 os(i) = os(i) - vgradpps*(dpmdps(i,k)-dpidps(i,k+1)) &
396 - d(i,k)*(pm(i,k)-pi(i,k+1))
398 om(i,k) = os(i) + vgradpps*dpmdps(i,k)
400 os(i) = os(i) - vgradpps*(dpidps(i,k)-dpmdps(i,k)) &
401 - d(i,k)*(pi(i,k)-pm(i,k))
444 subroutine trssc(jcap,nc,km,ntrac,idvc,idvm,idsl,nvcoord,vcoord, &
445 cpi,idrt,lonb,latb,ijl,ijn,j1,j2,jc,chgq0, &
446 szs,sps,st,sd,sz,sq,gfszs,gfsps,gfsp,gfsdp, &
447 gfst,gfsu,gfsv,gfsq,gfsw)
449 integer,
intent(in)::jcap,nc,km,ntrac,idvc,idvm,idsl,nvcoord,idrt,lonb,latb
450 integer,
intent(in)::ijl,ijn,j1,j2,jc,chgq0
451 real,
intent(in):: szs(nc),sps(nc),st(nc,km),sd(nc,km),sz(nc,km),sq(nc,km*ntrac)
452 real,
intent(in):: cpi(0:ntrac)
453 real*8,
intent(in):: vcoord(km+1,nvcoord)
454 real,
dimension(ijn),
intent(inout):: gfszs,gfsps
455 real,
dimension(ijn,km),
intent(inout):: gfsp,gfsdp,gfst,gfsu,gfsv,gfsw
456 real,
dimension(ijn,km*ntrac),
intent(inout):: gfsq
457 real zs(ijl),ps(ijl),t(ijl,km),u(ijl,km),v(ijl,km),q(ijl,km*ntrac)
458 real wi(ijl,km),pi(ijl,km),dpo(ijl,km)
460 integer thermodyn_id,jn,js,is,in
461 integer jj,jjm,k,n,j,i,ij,lonb2
464 if(j1==732)print*,
'sample input to trssc= ',jcap,nc,km,ntrac, &
465 idvc,idvm,idsl,nvcoord, &
466 idrt,lonb,latb,ijl,ijn,j1,j2,jc,chgq0
471 call sptran(0,jcap,idrt,lonb,latb,1,1,1,lonb2,lonb2,nc,ijl, &
472 j1,j2,jc,szs,zs(in),zs(is),1)
473 call sptran(0,jcap,idrt,lonb,latb,1,1,1,lonb2,lonb2,nc,ijl, &
474 j1,j2,jc,sps,ps(in),ps(is),1)
475 call sptran(0,jcap,idrt,lonb,latb,km,1,1,lonb2,lonb2,nc,ijl, &
476 j1,j2,jc,st,t(in,1),t(is,1),1)
477 call sptranv(0,jcap,idrt,lonb,latb,km,1,1,lonb2,lonb2,nc,ijl, &
478 j1,j2,jc,sd,sz,u(in,1),u(is,1),v(in,1),v(is,1),1)
479 call sptran(0,jcap,idrt,lonb,latb,km*ntrac,1,1,lonb2,lonb2,nc,ijl, &
480 j1,j2,jc,sq,q(in,1),q(is,1),1)
484 if(t(i,k)>400. .or. t(i,k)<100.)print*,
'bad T from sptran',i,k,t(i,k)
485 if(q(i,k)>1.)print*,
'bad Q from sptran',i,k,q(i,k)
486 if(q(i,2*k)>1.)print*,
'bad Q from sptran',i,k,q(i,2*k)
487 if(q(i,3*k)>1.)print*,
'bad Q from sptran',i,k,q(i,3*k)
491 select case(mod(idvm,10))
494 ps(i)=1.e3*exp(ps(i))
502 ps(i)=1.e3*exp(ps(i))
506 thermodyn_id=mod(idvm/10,10)
507 if (thermodyn_id == 3)
then
510 t(i,k) = t(i,k)/cpi(0)
516 call getomega(jcap,nc,km,idvc,idvm,idrt,idsl, &
517 nvcoord,vcoord,lonb,latb,ijl,j1,j2,1,sd,sps, &
522 if(t(i,k)>400. .or. t(i,k)<100.)print*,
'bad T after getomega',i,k,t(i,k)
523 if(q(i,k)>1. )print*,
'bad Q after getomega',i,k,q(i,k)
524 if(q(i,2*k)>1. )print*,
'bad Q after getomega',i,2*k,q(i,2*k)
528 if(thermodyn_id /= 2)
then
530 if (thermodyn_id == 3)
then
536 if( cpi(n) /= 0.0 )
then
537 xcp = xcp + cpi(n)*q(i,k+(n-1)*km)
538 sumq = sumq + q(i,k+(n-1)*km)
541 t(i,k) = t(i,k)/((1.-sumq)*cpi(0)+xcp)
546 tvcon=(461.50/287.05-1.)
547 t(:,:) = t(:,:)/(1.+tvcon*q(:,1:km))
553 if(t(i,k)>400. .or. t(i,k)<100.)print*,
'bad T after Tv to T',i,k,t(i,k)
554 if(q(i,k)>1.)print*,
'bad Q after Tv to T',i,k,q(i,k)
555 if(q(i,2*k)>1. )print*,
'bad Q after Tv to T',i,k,q(i,2*k)
561 if (chgq0 == 1) q = max(q, 0.0)
572 gfszs(i+jn) = zs(i+jjm)
573 gfsps(i+jn) = ps(i+jjm)
576 gfszs(i+js) = zs(i+jj)
577 gfsps(i+js) = ps(i+jj)
581 gfsdp(i+jn,k) = dpo(i+jjm,k)
582 gfsp(i+jn,k) = pi(i+jjm,k)
583 gfst(i+jn,k) = t(i+jjm,k)
584 gfsu(i+jn,k) = u(i+jjm,k)
585 gfsv(i+jn,k) = v(i+jjm,k)
586 gfsw(i+jn,k) = wi(i+jjm,k)
589 gfsdp(i+js,k) = dpo(i+jj,k)
590 gfsp(i+js,k) = pi(i+jj,k)
591 gfst(i+js,k) = t(i+jj,k)
592 gfsu(i+js,k) = u(i+jj,k)
593 gfsv(i+js,k) = v(i+jj,k)
594 gfsw(i+js,k) = wi(i+jj,k)
599 gfsq(i+jn,k) = q(i+jjm,k)
602 gfsq(i+js,k) = q(i+jj,k)
609 subroutine getomega(jcap,nc,km,idvc,idvm,idrt,idsl,nvcoord,vcoord, &
610 lonb,latb,ijn,j1,j2,jc,sd,sps,psi,ti,ui,vi,wi,pm,pd)
612 use sigio_module
, only : sigio_modprd
615 integer,
intent(in):: jcap,nc,km,idvc,idvm,idrt,idsl,nvcoord
616 integer,
intent(in):: lonb,latb,j1,j2,jc,ijn
617 real*8,
intent(in):: vcoord(km+1,nvcoord)
618 real,
intent(in):: sd(nc,km),sps(nc)
619 real,
intent(in):: psi(ijn),ti(ijn,km),ui(ijn,km),vi(ijn,km)
620 real,
intent(out):: wi(ijn,km),pm(ijn,km),pd(ijn,km)
623 real*8 psi8(ijn),ti8(ijn,km),pm8(ijn,km),pd8(ijn,km)
624 real*8 dpmdps(ijn,km),dpddps(ijn,km),dpidps(ijn,km+1),vgradp,psmean
625 real di(ijn,km),psx(ijn),psy(ijn)
626 integer k,i,ij,lonb2,iret,is,in
632 call sptrand(0,jcap,idrt,lonb,latb,1,1,1,lonb2,lonb2,nc,ijn, &
633 j1,j2,jc,sps,psmean,psx(in),psx(is),psy(in),psy(is),1)
635 call sptran(0,jcap,idrt,lonb,latb,km,1,1,lonb2,lonb2,nc,ijn, &
636 j1,j2,jc,sd,di(in,1),di(is,1),1)
640 call sigio_modprd(ijn,ijn,km,nvcoord,idvc,idsl,vcoord,iret, &
641 ps=psi8,t=ti8,pm=pm8,pd=pd8,dpmdps=dpmdps,dpddps=dpddps)
645 select case(mod(idvm,10))
650 psx(i)=psx(i)/(psi(i)*1.0e-3)
651 psy(i)=psy(i)/(psi(i)*1.0e-3)
667 pi(i,k+1)=pi(i,k)-pd(i,k)
668 dpidps(i,k+1)=dpidps(i,k)-dpddps(i,k)
674 vgradp=ui(i,k)*psx(i)+vi(i,k)*psy(i)
675 os=os-vgradp*psi(i)*(dpmdps(i,k)-dpidps(i,k+1))- &
676 di(i,k)*(pm(i,k)-pi(i,k+1))
677 wi(i,k)=vgradp*psi(i)*dpmdps(i,k)+os
678 os=os-vgradp*psi(i)*(dpidps(i,k)-dpmdps(i,k))- &
679 di(i,k)*(pi(i,k)-pm(i,k))
subroutine modstuff2(im, ix, km, idvc, idsl, nvcoord, vcoord, ps, psx, psy, d, u, v, pi, pm, om, me)
modstuff2() computes model coordinate dependent functions.
subroutine modstuff(km, idvc, idsl, nvcoord, vcoord, ps, psx, psy, d, u, v, pi, pm, om)
modstuff() computes model coordinate dependent functions.
subroutine trssc(jcap, nc, km, ntrac, idvc, idvm, idsl, nvcoord, vcoord, cpi, idrt, lonb, latb, ijl, ijn, j1, j2, jc, chgq0, szs, sps, st, sd, sz, sq, gfszs, gfsps, gfsp, gfsdp, gfst, gfsu, gfsv, gfsq, gfsw)
trssc() transforms sigma spectral fields to grid.