/[MITgcm]/MITgcm/pkg/fizhi/fizhi_turb.F
ViewVC logotype

Diff of /MITgcm/pkg/fizhi/fizhi_turb.F

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.2 by molod, Tue Jun 15 16:06:03 2004 UTC revision 1.33 by molod, Fri Feb 25 01:48:31 2005 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4  #include "CPP_OPTIONS.h"  #include "FIZHI_OPTIONS.h"
5        subroutine turbio (im,jm,nlay,maxtypes,istrip,nymd,nhms        subroutine turbio (im,jm,nlay,istrip,nymd,nhms,bi,bj
6       1 ,ndturb,ptop, pz, uz, vz, tz, qz, ntracers,ptracers,       1 ,ndturb,ptop, pz, uz, vz, tz, qz, ntracers,ptracers
7       2 ,plz,plze,dpres,pkht,pkz,ctmt,xxmt,yymt,zetamt,xlmt,khmt,tke       2 ,plz,plze,dpres,pkht,pkz,ctmt,xxmt,yymt,zetamt,xlmt,khmt,tke
8       3 ,tgz,gwet,snow,fracland,landtype       3 ,tgz,fracland,landtype
9       4 ,tcanopy,ecanopy,tdeep,swetshal,swetroot,swetdeep,snodep,capac       4 ,tcanopy,ecanopy,tdeep,swetshal,swetroot,swetdeep,snodep,capac
10       5 ,nchp,nchplnd,chfr,chlt,chlon,igrd,ityp,alai,agrn       5 ,nchp,nchptot,nchplnd,chfr,chlt,chlon,igrd,ityp,alai,agrn,thkz
11       6 ,surftype,tilefrac,thkz,tprof       6 ,tprof
12       8 ,duturb, dvturb, dtturb,dqturb,radlwg,st4,dst4,radswg,radswt       8 ,duturb, dvturb, dtturb,dqturb,radlwg,st4,dst4,radswg,radswt
13       9 ,fdifpar,fdirpar,rainlsp,rainconv,snowfall,tempref       9 ,fdifpar,fdirpar,rainlsp,rainconv,snowfall,tempref
14       1 ,imstturblw,imstturbsw,qliqavelw,qliqavesw,fccavelw,fccavesw       1 ,imstturblw,imstturbsw,qliqavelw,qliqavesw,fccavelw,fccavesw
15       2 ,qqgrid,u2m,v2m,t2m,q2m,u10m,v10m,t10m,q10m,myid,comm)       2 ,qqgrid,myid)
16  c-----------------------------------------------------------------------  c-----------------------------------------------------------------------
17  c subroutine turbio - model interface routine to trbflx, the turbulence  c subroutine turbio - model interface routine to trbflx, the turbulence
18  c        parameterization, and tile, the land surface parameterization  c        parameterization, and tile, the land surface parameterization
# Line 21  c  input: Line 21  c  input:
21  c      im      - number of points in the longitude direction  c      im      - number of points in the longitude direction
22  c      jm      - number of points in the latitude direction  c      jm      - number of points in the latitude direction
23  c      nlay    - number of vertical levels  c      nlay    - number of vertical levels
 c      maxtypes- maximum number of different surface types in any one grid cell  
24  c      istrip  - number of horizontal points to be handled at a time on  c      istrip  - number of horizontal points to be handled at a time on
25  c      nymd    - year and date integer in YYMMDD format (ie, 790212)  c      nymd    - year and date integer in YYMMDD format (ie, 790212)
26  c      nhms    - date and time integer in HHMMSS format (ie, 123000)  c      nhms    - date and time integer in HHMMSS format (ie, 123000)
# Line 46  c      igrd    - tile space grid number Line 45  c      igrd    - tile space grid number
45  c      ityp    - tile space vegetation type - integer[nchp]  c      ityp    - tile space vegetation type - integer[nchp]
46  c      alai    - leaf area index - real[nchp]  c      alai    - leaf area index - real[nchp]
47  c      agrn    - greenness fraction - real[nchp]  c      agrn    - greenness fraction - real[nchp]
 c      surftype- surface type designation - integer[lon,lat,maxtype]  
 c                where maxtype is the maximum number of tiles in a grid cell  
 c      tilefrac- fraction of grid box covered by the corresponding surface type  
 c                designation - real[lon,lat,maxtype]  
48  c      thkz    - sea ice thickness in m (0. for no ice) - real[lon,lat]  c      thkz    - sea ice thickness in m (0. for no ice) - real[lon,lat]
49  c      tprof   - logical flag for point by point diagnostic output  c      tprof   - logical flag for point by point diagnostic output
50  c      ndiagsiz- number of diagnostic 2-D arrays allocated  c      ndiagsiz- number of diagnostic 2-D arrays allocated
# Line 70  c      snowfall- total snowfall rate in Line 65  c      snowfall- total snowfall rate in
65  c updated:  c updated:
66  c      tke     - turbulent k.e. in m**2/s**2 - real[tiles,levels]  c      tke     - turbulent k.e. in m**2/s**2 - real[tiles,levels]
67  c      tgz     - surface skin temperature in deg K - real[lon,lat]  c      tgz     - surface skin temperature in deg K - real[lon,lat]
 c      gwet    - surface ground wetness fraction - real[lon,lat]  
 c      snow    - depth of snow pack in cm liquid water equiv real[lon,lat]  
68  c      tcanopy - canopy temperature in deg K real[tiles]  c      tcanopy - canopy temperature in deg K real[tiles]
69  c                 (sea surface temp over the ocean tiles)  c                 (sea surface temp over the ocean tiles)
70  c      ecanopy - canopy vapor pressure in mb real[tiles]  c      ecanopy - canopy vapor pressure in mb real[tiles]
# Line 96  c      qliqavesw - Moist   Turbulence Li Line 89  c      qliqavesw - Moist   Turbulence Li
89  c      fccavelw  - Moist   Turbulence Cloud Fraction for Longwave  - real[lon,lat,levels]  c      fccavelw  - Moist   Turbulence Cloud Fraction for Longwave  - real[lon,lat,levels]
90  c      fccavesw  - Moist   Turbulence Cloud Fraction for Shortwave - real[lon,lat,levels]  c      fccavesw  - Moist   Turbulence Cloud Fraction for Shortwave - real[lon,lat,levels]
91  c      qqgrid    - Gridded Turbulent Kinetic Energy                - real[lon,lat,levels]  c      qqgrid    - Gridded Turbulent Kinetic Energy                - real[lon,lat,levels]
 c      u2m       - Gridded U-Wind      real[lon,lat] at  2 meters  
 c      v2m       - Gridded V-Wind      real[lon,lat] at  2 meters  
 c      t2m       - Gridded Temperature real[lon,lat] at  2 meters  
 c      q2m       - Gridded Spec.Humd.  real[lon,lat] at  2 meters  
 c      u10m      - Gridded U-Wind      real[lon,lat] at 10 meters  
 c      v10m      - Gridded V-Wind      real[lon,lat] at 10 meters  
 c      t10m      - Gridded Temperature real[lon,lat] at 10 meters  
 c      q10m      - Gridded Spec.Humd.  real[lon,lat] at 10 meters  
 c  
92  c-----------------------------------------------------------------------  c-----------------------------------------------------------------------
93        implicit none        implicit none
94    
95    #ifdef ALLOW_USE_MPI
96  #include "mpif.h"  #include "mpif.h"
97    #endif
98    
99  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
100  #include "diagnostics.h"  #include "SIZE.h"
101    #include "DIAGNOSTICS_SIZE.h"
102    #include "DIAGNOSTICS.h"
103  #endif  #endif
104    
105        integer n,im,jm,nlay,maxtypes,istrip,nymd,nhms,ndturb        integer im,jm,nlay,istrip,nymd,nhms,bi,bj,ndturb
       real   ptop  
       integer nchp,nchplnd,landtype(im,jm),igrd(nchp)  
       integer ityp(nchp)  
       real fracland(im,jm),chfr(nchp),chlt(nchp)  
       real chlon(nchp)  
       real alai(nchp),agrn(nchp)  
         
       real pz(im,jm)  
       real uz(im,jm,nlay)  
       real vz(im,jm,nlay)  
       real tz(im,jm,nlay)  
106        integer ntracers, ptracers        integer ntracers, ptracers
107        real qz(im,jm,nlay,ntracers)        integer nchp,nchptot,nchplnd
108        real pkht(im,jm,nlay)        _RL ptop
109        real tke(nchp,nlay)        _RL pz(im,jm),uz(im,jm,nlay),vz(im,jm,nlay),tz(im,jm,nlay)
110        integer imstturblw, imstturbsw        _RL qz(im,jm,nlay,ntracers)
111        real ctmt(nchp),xxmt(nchp),yymt(nchp),zetamt(nchp)        _RL plz(im,jm,nlay),plze(im,jm,nlay+1),dpres(im,jm,nlay)
112        real xlmt(nchp,nlay),khmt(nchp,nlay)        _RL pkht(im,jm,nlay+1),pkz(im,jm,nlay)
113          _RL ctmt(nchp),xxmt(nchp),yymt(nchp),zetamt(nchp)
114        real tgz(im, jm),gwet(im,jm),snow(im,jm)        _RL xlmt(nchp,nlay),khmt(nchp,nlay),tke(nchp,nlay)
115        real  tcanopy(nchp)        _RL tgz(im, jm),fracland(im,jm)
116        real    tdeep(nchp)        integer landtype(im,jm)
117        real  ecanopy(nchp)        _RL tcanopy(nchp),tdeep(nchp),ecanopy(nchp),swetshal(nchp)
118        real swetshal(nchp)        _RL swetroot(nchp),swetdeep(nchp),snodep(nchp),capac(nchp)
119        real swetroot(nchp)        _RL chfr(nchp),chlt(nchp),chlon(nchp)
120        real swetdeep(nchp)        integer igrd(nchp),ityp(nchp)
121        real   snodep(nchp)        _RL alai(nchp),agrn(nchp),thkz(im,jm)
       real    capac(nchp)  
   
       integer surftype(im,jm,maxtypes)  
       real    tilefrac(im,jm,maxtypes)  
       real thkz(im,jm)  
   
122        logical tprof        logical tprof
123          _RL duturb(im,jm,nlay),dvturb(im,jm,nlay)
124          _RL dtturb(im,jm,nlay),dqturb(im,jm,nlay,ntracers)
125          _RL st4(im,jm),dst4(im,jm)
126          _RL radswg(im,jm),radswt(im,jm),radlwg(im,jm)
127          _RL fdifpar(im,jm),fdirpar(im,jm)
128          _RL rainlsp(im,jm),rainconv(im,jm),snowfall(im,jm)
129          _RL tempref (im,jm)
130          integer imstturblw, imstturbsw
131          _RL qliqavesw(im,jm,nlay),qliqavelw(im,jm,nlay)
132          _RL fccavelw (im,jm,nlay),fccavesw (im,jm,nlay)
133          _RL qqgrid   (im,jm,nlay)
134          integer myid
135    
136        real duturb(im,jm,nlay),dvturb(im,jm,nlay)  C Local Variables
       real dtturb(im,jm,nlay),dqturb(im,jm,nlay,ntracers)  
   
       real st4(im,jm),dst4(im,jm)  
       real radswg(im,jm),radswt(im,jm),radlwg(im,jm)  
       real fdifpar(im,jm),fdirpar(im,jm)  
       real rainlsp(im,jm),rainconv(im,jm),snowfall(im,jm)  
       real tempref (im,jm)  
   
       real qliqavesw(im,jm,nlay),qliqavelw(im,jm,nlay)  
       real fccavelw (im,jm,nlay),fccavesw (im,jm,nlay)  
       real qqgrid   (im,jm,nlay)  
   
 C Couplings for Output Purposes, Not Reproduceable  
       real u2m(im,jm), u10m(im,jm)    
       real v2m(im,jm), v10m(im,jm)    
       real t2m(im,jm), t10m(im,jm)    
       real q2m(im,jm), q10m(im,jm)    
137    
138        integer numstrips        integer numstrips
139        integer ijall        integer ijall
140        real fmu,hice,tref,pref,cti,ed        _RL fmu,hice,tref,pref,cti,ed
141  C Set fmu and ed to zero for no background diffusion  C Set fmu and ed to zero for no background diffusion
142        parameter ( fmu    = 0.00000    )        parameter ( fmu    = 0.00000    )
143        parameter ( hice   =   300.     )        parameter ( hice   =   300.     )
# Line 179  C Set fmu and ed to zero for no backgrou Line 146  C Set fmu and ed to zero for no backgrou
146        parameter ( cti    =   0.0052   )        parameter ( cti    =   0.0052   )
147        parameter ( ed     =   0.0      )        parameter ( ed     =   0.0      )
148    
149        real     pkz(im,jm,nlay)        _RL qliqtmp(im,jm,nlay)
150        real     plz(im,jm,nlay)        _RL  fcctmp(im,jm,nlay)
151        real qliqtmp(im,jm,nlay)        _RL tmpdiag(im,jm)
152        real  fcctmp(im,jm,nlay)        _RL   thtgz(im*jm)
153        real tmpdiag(im,jm)        logical  diagnostics_is_on
154        real   thtgz(im*jm)        external diagnostics_is_on
155    
156        integer nland        integer nland
157        real alwcoeff(nchp),blwcoeff(nchp)        _RL alwcoeff(nchp),blwcoeff(nchp)
158        real netsw(nchp)        _RL netsw(nchp)
159        real cnvprec(nchp),lsprec(nchp)        _RL cnvprec(nchp),lsprec(nchp)
160        real snowprec(nchp)        _RL snowprec(nchp)
161        real pardiff(nchp),pardirct(nchp)        _RL pardiff(nchp),pardirct(nchp)
162        real pmsc(nchp),radmsc(nchp)        _RL pmsc(nchp)
163        real netlw(nchp)        _RL netlw(nchp)
164        real sqscat(nchp), rsoil1(nchp)        _RL sqscat(nchp), rsoil1(nchp)
165        real rsoil2(nchp)        _RL rsoil2(nchp)
166        real rdc(nchp),u2fac(nchp)        _RL rdc(nchp),u2fac(nchp)
167        real z2ch(nchp)        _RL z2ch(nchp)
168        real zoch(nchp),cdrc(nchp)        _RL zoch(nchp),cdrc(nchp)
169        real cdsc(nchp)        _RL cdsc(nchp)
170        real dqsdt(nchp)        _RL dqsdt(nchp)
171        real tground(nchp),qground(nchp)        _RL tground(nchp),qground(nchp)
172        real utility(nchp)        _RL utility(nchp)
173        real    qice(nchp)        _RL    qice(nchp)
174        real   dqice(nchp)        _RL   dqice(nchp)
175    
176        real dumsc(nchp,nlay),dvmsc(nchp,nlay)        _RL dumsc(nchp,nlay),dvmsc(nchp,nlay)
177        real dtmsc(nchp,nlay),dqmsc(nchp,nlay,ntracers)        _RL dtmsc(nchp,nlay),dqmsc(nchp,nlay,ntracers)
178    
179        real shg(nchp),z0(nchp),icethk(nchp)        _RL shg(nchp),z0(nchp),icethk(nchp)
180        integer water(nchp)        integer water(nchp)
181    
182        real lats(istrip),lons(istrip),cosz(istrip),icest(istrip)        _RL lats(istrip),lons(istrip),cosz(istrip),icest(istrip)
183        real rainls(istrip),raincon(istrip),newsnow(istrip)        _RL rainls(istrip),raincon(istrip),newsnow(istrip)
184        real lwnet(istrip),pardf(istrip),pardr(istrip),swnet(istrip)        _RL pardf(istrip),pardr(istrip),swnet(istrip)
185        real hlwdwn(istrip),alwrad(istrip),blwrad(istrip),tmpnlay(istrip)        _RL hlwdwn(istrip),alwrad(istrip),blwrad(istrip)
186        real laistrip(istrip),grnstrip(istrip),z2str(istrip),cd(istrip)        _RL tmpnlay(istrip)
187        real scatstr(istrip), rs1str(istrip), rs2str(istrip)        _RL laistrip(istrip),grnstrip(istrip),z2str(istrip),cd(istrip)
188        real rdcstr(istrip),u2fstr(istrip),dqsdtstr(istrip)        _RL scatstr(istrip), rs1str(istrip), rs2str(istrip)
189        real eturb(istrip),dedqa(istrip),dedtc(istrip)        _RL rdcstr(istrip),u2fstr(istrip),dqsdtstr(istrip)
190        real hsturb(istrip),dhsdqa(istrip),dhsdtc(istrip)        _RL eturb(istrip),dedqa(istrip),dedtc(istrip)
191        real savetc(istrip),saveqa(istrip),lwstrip(istrip)        _RL hsturb(istrip),dhsdqa(istrip),dhsdtc(istrip)
192        real chfrstr(istrip),psurf(istrip),shgstr(istrip)        _RL savetc(istrip),saveqa(istrip),lwstrip(istrip)
193          _RL chfrstr(istrip),psurf(istrip),shgstr(istrip)
194        integer types(istrip),igrdstr(istrip)        integer types(istrip),igrdstr(istrip)
195        real evap(istrip),shflux(istrip),runoff(istrip),bomb(istrip)        _RL evap(istrip),shflux(istrip),runoff(istrip),bomb(istrip)
196        real eint(istrip),esoi(istrip),eveg(istrip),esno(istrip)        _RL eint(istrip),esoi(istrip),eveg(istrip),esno(istrip)
197        real smelt(istrip),hlatn(istrip),hlwup(istrip),gdrain(istrip)        _RL smelt(istrip),hlatn(istrip),hlwup(istrip),gdrain(istrip)
198        real runsrf(istrip),fwsoil(istrip),evpot(istrip)        _RL runsrf(istrip),fwsoil(istrip),evpot(istrip)
199        real strdg1(istrip),strdg2(istrip),strdg3(istrip),strdg4(istrip)        _RL strdg1(istrip),strdg2(istrip),strdg3(istrip),strdg4(istrip)
200        real strdg5(istrip),strdg6(istrip),strdg7(istrip),strdg8(istrip)        _RL strdg5(istrip),strdg6(istrip),strdg7(istrip),strdg8(istrip)
201        real strdg9(istrip),tmpstrip(istrip),qicestr(istrip)        _RL strdg9(istrip),tmpstrip(istrip),qicestr(istrip)
202        real dqicestr(istrip)        _RL dqicestr(istrip)
203    
204        real u(istrip,nlay+1), v(istrip,nlay+1), th(istrip,nlay+1)        _RL u(istrip,nlay+1), v(istrip,nlay+1), th(istrip,nlay+1)
205        real sh(istrip,nlay+1), thv(istrip,nlay+1), pe(istrip,nlay+1)        _RL sh(istrip,nlay+1), thv(istrip,nlay+1), pe(istrip,nlay+1)
206        real tracers(istrip,nlay+1,ntracers)        _RL tracers(istrip,nlay+1,ntracers)
207        real pke(istrip,nlay+1)        _RL dpstr(istrip,nlay),pke(istrip,nlay+1)
208        real pk(istrip,nlay), qq(istrip,nlay),   p(istrip,nlay)        _RL pk(istrip,nlay), qq(istrip,nlay),   p(istrip,nlay)
209        real sri(istrip,nlay), skh(istrip,nlay), skm(istrip,nlay)        _RL sri(istrip,nlay), skh(istrip,nlay), skm(istrip,nlay)
210        real stuflux(istrip,nlay), stvflux(istrip,nlay)        _RL stuflux(istrip,nlay), stvflux(istrip,nlay)
211        real sttflux(istrip,nlay), stqflux(istrip,nlay)        _RL sttflux(istrip,nlay), stqflux(istrip,nlay)
212        real frqtrb(istrip,nlay-1)        _RL frqtrb(istrip,nlay-1)
213        real dshdthg(istrip,nlay),dthdthg(istrip,nlay)        _RL dshdthg(istrip,nlay),dthdthg(istrip,nlay)
214        real dshdshg(istrip,nlay),dthdshg(istrip,nlay)        _RL dshdshg(istrip,nlay),dthdshg(istrip,nlay)
215        real transth(istrip,nlay), transsh(istrip,nlay)        _RL transth(istrip,nlay), transsh(istrip,nlay)
216        real checktrb(istrip,nlay)  
217          _RL tc(istrip),td(istrip),qa(istrip)
218        real tc(istrip),td(istrip),qa(istrip)        _RL swet1(istrip),swet2(istrip),swet3(istrip)
219        real swet1(istrip),swet2(istrip),swet3(istrip)        _RL capacity(istrip),snowdepth(istrip)
220        real capacity(istrip),snowdepth(istrip)        _RL stz0(istrip)
221        real strflx(istrip), stz0(istrip)        _RL stdiag(istrip)
222        real stcndi(istrip), stdiag(istrip)        _RL tends(istrip),sustar(istrip), sz0(istrip),pbldpth(istrip)
223        real tends(istrip),sustar(istrip), sz0(istrip),pbldpth(istrip)        _RL sct(istrip), scu(istrip), swinds(istrip)
224        real sdtsrf(istrip), stg(istrip), sqs(istrip)        _RL stu2m(istrip),stv2m(istrip),stt2m(istrip),stq2m(istrip)
225        real sct(istrip), scu(istrip), swinds(istrip), sdtg(istrip)        _RL stu10m(istrip),stv10m(istrip),stt10m(istrip),stq10m(istrip)
       real sts(istrip), sqg(istrip)  
       real stu2m(istrip),stv2m(istrip),stt2m(istrip),stq2m(istrip)  
       real stu10m(istrip),stv10m(istrip),stt10m(istrip),stq10m(istrip)  
226        integer  stwatr(istrip)        integer  stwatr(istrip)
227        real  wspeed(istrip)        _RL  wspeed(istrip)
228    
229        real ctsave(istrip),xxsave(istrip),yysave(istrip),zetasave(istrip)        _RL ctsave(istrip),xxsave(istrip),yysave(istrip)
230        real xlsave(istrip,nlay),khsave(istrip,nlay)        _RL zetasave(istrip)
231        real qliq(istrip,nlay),turbfcc(istrip,nlay)        _RL xlsave(istrip,nlay),khsave(istrip,nlay)
232        real qliqmsc(nchp,nlay),fccmsc(nchp,nlay)        _RL qliq(istrip,nlay),turbfcc(istrip,nlay)
233          _RL qliqmsc(nchp,nlay),fccmsc(nchp,nlay)
234    
235        integer ndlsm        integer ndlsm
236        parameter ( ndlsm = 1 )        parameter ( ndlsm = 1)
237        real qdiaglsm(nchp,ndlsm)        _RL qdiaglsm(nchp,ndlsm)
238    
239        integer nsecf,nmonf,ndayf        _RL pi,secday,sdayopi2,rgas,akap,cp,alhl
240        nsecf(n) = n/10000*3600 + mod(n,10000)/100* 60 + mod(n,100)        _RL faceps,grav,caltoj,virtcon,getcon
241        nmonf(n) = mod(n,10000)/100        _RL heatw,undef,timstp,delttrb,dttrb,ra
242        ndayf(n) = mod(n,100)        _RL edle,rmu,cltj10,atimstp,tice,const
243          integer istnp1,istnlay,itrtrb,i,j,L,nn,nt
       real pi,secday,sdayopi2,rgas,akap,cp,alhl  
       real faceps,grav,caltoj,virtcon,getcon  
       real heatw,undef,timstp,delttrb,dttrb,ra  
       real edle,rmu,cltj10,atimstp,tice,const  
       integer istnp1,istnlay,itrtrb,i,j,L,k,nn,nt  
244        integer nocean, nice        integer nocean, nice
245        integer ndmoist,time_left,ndum        integer ndmoist,time_left,ndum
246        integer ntracedim        integer ntracedim
247        real    dtfac,timstp2,sum        _RL    dtfac,timstp2,sum0
248  C logical begin flag - set to true to indicate a cold start  C logical begin flag - set to true to indicate a cold start
249        logical qbeg            logical qbeg    
250    
251  #if CRAY        integer n,nsecf,nmonf,ndayf
252  #if f77        nsecf(n) = n/10000*3600 + mod(n,10000)/100* 60 + mod(n,100)
253          nmonf(n) = mod(n,10000)/100
254          ndayf(n) = mod(n,100)
255    
256    #ifdef CRAY
257    #ifdef f77
258  cfpp$ expand (qsat)  cfpp$ expand (qsat)
259  #endif  #endif
260  #endif  #endif
261    
262  c   compute variables that do not change  c   compute variables that do not change
263  c  c
264    
265         pi = 4.*atan(1.)         pi = 4.*atan(1.)
266         secday   = getcon('SDAY')         secday   = getcon('SDAY')
267         sdayopi2 = getcon('SDAY') / (pi*2.)         sdayopi2 = getcon('SDAY') / (pi*2.)
# Line 339  c ************************************** Line 306  c **************************************
306                
307        qbeg = .false.        qbeg = .false.
308    
309        sum = 0.0        sum0 = 0.0
310        do L=1,nlay        do L=1,nlay
311        do n=1,nchp        do n=1,nchptot
312        sum = sum + tke(n,L)        sum0 = sum0 + tke(n,L)
313        enddo        enddo
314        enddo        enddo
315        call mpi_allreduce(sum,const,1,mpi_double_precision,mpi_sum,  
316       .                                                           comm,n)  #ifdef ALLOW_USE_MPI
317          call mpi_allreduce(sum0,const,1,mpi_double_precision,mpi_sum,
318         .                                                mpi_comm_world,n)
319    #else
320          const = sum0
321    #endif
322    
323        if( const.eq.0.0 ) then        if( const.eq.0.0 ) then
324        qbeg = .true.        qbeg = .true.
325            if( myid.eq.0 ) then            if( myid.eq.1 .and. bi.eq.1 ) then
326            print *            print *
327            print *, 'Warning!'            print *, 'Warning!'
328            print *, 'Turbulent Kinetic Energy has not been initialized.'            print *, 'Turbulent Kinetic Energy has not been initialized.'
# Line 363  c ************************************** Line 335  c **************************************
335  c                            Initialization  c                            Initialization
336  c **********************************************************************  c **********************************************************************
337                
 c Zero-out 2m and 10m Couplings  
 c -----------------------------  
       do j = 1,jm  
       do i = 1,im  
        u2m(i,j) = 0.0  
        v2m(i,j) = 0.0  
        t2m(i,j) = 0.0  
        q2m(i,j) = 0.0  
       u10m(i,j) = 0.0  
       v10m(i,j) = 0.0  
       t10m(i,j) = 0.0  
       q10m(i,j) = 0.0  
       enddo  
       enddo  
   
338  c Initialize diagnostic for ground temperature change  c Initialize diagnostic for ground temperature change
339  c ---------------------------------------------------  c ---------------------------------------------------
340        if(idtg.gt.0) then        if(idtg.gt.0) then
341        do i =1,ijall         do j =1,jm
342        qdiag(i,1,idtg) = qdiag(i,1,idtg) - tgz(i,1)         do i =1,im
343        enddo          qdiag(i,j,idtg,bi,bj) = qdiag(i,j,idtg,bi,bj) - tgz(i,j)
344           enddo
345           enddo
346        endif        endif
347    
348  c **********************************************************************  c **********************************************************************
# Line 392  c       do conversion of model state var Line 351  c       do conversion of model state var
351  c        (ocean points appended to tile space land point arrays)  c        (ocean points appended to tile space land point arrays)
352  c **********************************************************************  c **********************************************************************
353    
354        numstrips   = ((nchp-1)/istrip) + 1        numstrips   = ((nchptot-1)/istrip) + 1
355    
356        call grd2msc(pz(1,1),im,jm,igrd,pmsc,nchp,nchp)        call grd2msc(pz(1,1),im,jm,igrd,pmsc,nchp,nchptot)
357        call grd2msc(tgz,im,jm,igrd,tground,nchp,nchp)  
358          call grd2msc(tgz,im,jm,igrd,tground,nchp,nchptot)
359        do i = 1,ijall        do i = 1,ijall
360         tmpdiag(i,1) = st4(i,1) + dst4(i,1)*(tgz(i,1)-tempref(i,1))         tmpdiag(i,1) = st4(i,1) + dst4(i,1)*(tgz(i,1)-tempref(i,1))
361       1                         - dst4(i,1)* tgz(i,1)       1                         - dst4(i,1)* tgz(i,1)
362        enddo        enddo
363        call grd2msc(tmpdiag,im,jm,igrd,alwcoeff,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,alwcoeff,nchp,nchptot)
364        do i = 1,ijall        do i = 1,ijall
365         tmpdiag(i,1) = dst4(i,1)         tmpdiag(i,1) = dst4(i,1)
366        enddo        enddo
367        call grd2msc(tmpdiag,im,jm,igrd,blwcoeff,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,blwcoeff,nchp,nchptot)
368        do i = 1,ijall        do i = 1,ijall
369         tmpdiag(i,1) = fdifpar(i,1) * radswt(i,1)         tmpdiag(i,1) = fdifpar(i,1) * radswt(i,1)
370        enddo        enddo
371        call grd2msc(tmpdiag,im,jm,igrd,pardiff,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,pardiff,nchp,nchptot)
372        do i = 1,ijall        do i = 1,ijall
373         tmpdiag(i,1) = fdirpar(i,1) * radswt(i,1)         tmpdiag(i,1) = fdirpar(i,1) * radswt(i,1)
374        enddo        enddo
375        call grd2msc(tmpdiag,im,jm,igrd,pardirct,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,pardirct,nchp,nchptot)
376        do i = 1,ijall        do i = 1,ijall
377         tmpdiag(i,1) = radswg(i,1) * radswt(i,1)         tmpdiag(i,1) = radswg(i,1) * radswt(i,1)
378        enddo        enddo
379        call grd2msc(tmpdiag,im,jm,igrd,netsw,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,netsw,nchp,nchptot)
380        do i = 1,ijall        do i = 1,ijall
381         tmpdiag(i,1) = radlwg(i,1) + dst4(i,1)*(tgz(i,1)-tempref(i,1))         tmpdiag(i,1) = radlwg(i,1) + dst4(i,1)*(tgz(i,1)-tempref(i,1))
382        enddo        enddo
383        call grd2msc(tmpdiag,im,jm,igrd,netlw,nchp,nchp)        call grd2msc(tmpdiag,im,jm,igrd,netlw,nchp,nchptot)
384        call grd2msc(thkz,im,jm,igrd,icethk,nchp,nchp)        call grd2msc(thkz,im,jm,igrd,icethk,nchp,nchptot)
385        call grd2msc(rainlsp,im,jm,igrd,lsprec,nchp,nchp)        call grd2msc(rainlsp,im,jm,igrd,lsprec,nchp,nchptot)
386        call grd2msc(rainconv,im,jm,igrd,cnvprec,nchp,nchp)        call grd2msc(rainconv,im,jm,igrd,cnvprec,nchp,nchptot)
387        call grd2msc(snowfall,im,jm,igrd,snowprec,nchp,nchp)        call grd2msc(snowfall,im,jm,igrd,snowprec,nchp,nchptot)
388    
389  C Call chpprm to get non-varying vegetation and soil characteristics  C Call chpprm to get non-varying vegetation and soil characteristics
390    
# Line 437  c ************************************** Line 397  c **************************************
397    
398  c   set water  c   set water
399    
400        do i = 1,nchp        do i = 1,nchptot
401         water(i) = 0         water(i) = 0
402         if((ityp(i).eq.100).and.(icethk(i).eq.0. ))water(i) = 1         if((ityp(i).eq.100).and.(icethk(i).eq.0. ))water(i) = 1
403        enddo        enddo
404    
405  c   roughness length z0  c   roughness length z0
406  c  c
407        do i =1,nchp        do i =1,nchptot
408         if (icethk(i).gt.0.) then         if (icethk(i).gt.0.) then
409          z0(i) = 1.e-4          z0(i) = 1.e-4
410         else if (ityp(i).eq.100) then         else if (ityp(i).eq.100) then
# Line 463  c  (it has sst from the tgz array over t Line 423  c  (it has sst from the tgz array over t
423    
424  C value of sh at ground  C value of sh at ground
425  C ---------------------  C ---------------------
426        do I =1,nchp        do I =1,nchptot
427        utility(I) = pmsc(i) + ptop        utility(I) = pmsc(i) + ptop
428        call qsat ( tground(i),utility(i),shg(i),dqsdt(i),.true. )        call qsat ( tground(i),utility(i),shg(i),dqsdt(i),.true. )
429        enddo        enddo
# Line 474  c  (it has qstar at tground over the sea Line 434  c  (it has qstar at tground over the sea
434        do i = 1,nchplnd        do i = 1,nchplnd
435         qground(i) = ecanopy(i)         qground(i) = ecanopy(i)
436        enddo        enddo
437        do i = nchplnd+1,nchp        do i = nchplnd+1,nchptot
438         qground(i) = shg(i)         qground(i) = shg(i)
439        enddo        enddo
440    
441  c Fill Array Swetshal with Value 1. over oceans and sea ice  c Fill Array Swetshal with Value 1. over oceans and sea ice
442        do i = nchplnd+1,nchp        do i = nchplnd+1,nchptot
443         swetshal(i) = 1.         swetshal(i) = 1.
444        enddo        enddo
445    
446  c compute heat conduction through ice  c compute heat conduction through ice
447  c -----------------------------------  c -----------------------------------
448        const = ( cti / hice ) * cltj10        const = ( cti / hice ) * cltj10
449        do i =1,nchp        do i =1,nchptot
450               qice(i) =  0.0               qice(i) =  0.0
451              dqice(i) =  0.0              dqice(i) =  0.0
452         if( icethk(i).gt.0.0 ) then         if( icethk(i).gt.0.0 ) then
# Line 495  c ----------------------------------- Line 455  c -----------------------------------
455         endif         endif
456        enddo        enddo
457    
458        if( iqice.gt.0 ) then        if(diagnostics_is_on('QICE    ',myid) ) then
459        tmpdiag(:,:) = 0.0         do i =1,ijall
460        call msc2grd (igrd,chfr,qice,nchp,nchp,fracland,tmpdiag,im,jm)          tmpdiag(i,1) = 0.0
461        qdiag(:,:,iqice) = qdiag(:,:,iqice) + tmpdiag(:,:)         enddo
462        nqice = nqice + 1         call msc2grd (igrd,chfr,qice,nchp,nchptot,fracland,tmpdiag,im,jm)
463           call diagnostics_fill(tmpdiag,'QICE    ',0,1,3,bi,bj,myid)
464        endif        endif
465    
466  c**********************************************************************  c***********************************************************************
467  c                        loop over regions  c                        loop over regions
468  c**********************************************************************  c***********************************************************************
469    
470        do 2000 nn = 1, numstrips        do 2000 nn = 1, numstrips
471    
# Line 517  c*************************************** Line 478  c***************************************
478         call strip2tile(plze,igrd,pe,nchp,ijall,istrip,nlay+1,nn)         call strip2tile(plze,igrd,pe,nchp,ijall,istrip,nlay+1,nn)
479         call strip2tile(pkz,igrd,pk,nchp,ijall,istrip,nlay,nn)         call strip2tile(pkz,igrd,pk,nchp,ijall,istrip,nlay,nn)
480         call strip2tile(pkht,igrd,pke,nchp,ijall,istrip,nlay+1,nn)         call strip2tile(pkht,igrd,pke,nchp,ijall,istrip,nlay+1,nn)
481         do nt = 1,ntracers-ptracers  c      do nt = 1,ntracers-ptracers
482         call strip2tile(qz(1,1,1,ptracers+nt),igrd,tracers(1,1,nt),nchp,  c      call strip2tile(qz(1,1,1,ptracers+nt),igrd,tracers(1,1,nt),nchp,
483       1                                             ijall,istrip,nlay,nn)  c    1                                             ijall,istrip,nlay,nn)
484         enddo  c      enddo
485    
486         call stripit  (z0,stz0,nchp,nchp,istrip,1,nn)         call stripit  (z0,stz0,nchptot,nchp,istrip,1,nn)
487         call stripit  (tground,th(1,nlay+1),nchp,nchp,istrip,1,nn)         call stripit  (tground,th(1,nlay+1),nchptot,nchp,istrip,1,nn)
488         call stripit  (pmsc,pe(1,nlay+1),nchp,nchp,istrip,1,nn)         call stripit  (pmsc,pe(1,nlay+1),nchptot,nchp,istrip,1,nn)
489         call stripit  (tke,qq,nchp,nchp,istrip,nlay-1,nn)         call stripit  (tke,qq,nchptot,nchp,istrip,nlay-1,nn)
490         call stripit  (ctmt,ctsave,nchp,nchp,istrip,1,nn)         call stripit  (ctmt,ctsave,nchptot,nchp,istrip,1,nn)
491         call stripit  (xxmt,xxsave,nchp,nchp,istrip,1,nn)         call stripit  (xxmt,xxsave,nchptot,nchp,istrip,1,nn)
492         call stripit  (yymt,yysave,nchp,nchp,istrip,1,nn)         call stripit  (yymt,yysave,nchptot,nchp,istrip,1,nn)
493         call stripit  (zetamt,zetasave,nchp,nchp,istrip,1,nn)         call stripit  (zetamt,zetasave,nchptot,nchp,istrip,1,nn)
494         call stripit  (xlmt,xlsave,nchp,nchp,istrip,nlay,nn)         call stripit  (xlmt,xlsave,nchptot,nchp,istrip,nlay,nn)
495         call stripit  (khmt,khsave,nchp,nchp,istrip,nlay,nn)         call stripit  (khmt,khsave,nchptot,nchp,istrip,nlay,nn)
496         call stripitint (water,stwatr,nchp,nchp,istrip,1,nn)         call stripitint (water,stwatr,nchptot,nchp,istrip,1,nn)
497    
498         call stripitint (igrd,igrdstr,nchp,nchp,istrip,1,nn)         call stripitint (igrd,igrdstr,nchptot,nchp,istrip,1,nn)
499         call stripit  (chfr,chfrstr,nchp,nchp,istrip,1,nn)         call stripit  (chfr,chfrstr,nchptot,nchp,istrip,1,nn)
500         call stripit  (icethk,icest,nchp,nchp,istrip,1,nn)         call stripit  (icethk,icest,nchptot,nchp,istrip,1,nn)
501         call stripit  (pardiff,pardf,nchp,nchp,istrip,1,nn)         call stripit  (pardiff,pardf,nchptot,nchp,istrip,1,nn)
502         call stripit  (pardirct,pardr,nchp,nchp,istrip,1,nn)         call stripit  (pardirct,pardr,nchptot,nchp,istrip,1,nn)
503         call stripit  (chlt,lats,nchp,nchp,istrip,1,nn)         call stripit  (chlt,lats,nchptot,nchp,istrip,1,nn)
504         call stripit  (chlon,lons,nchp,nchp,istrip,1,nn)         call stripit  (chlon,lons,nchptot,nchp,istrip,1,nn)
505         call stripit  (lsprec,rainls,nchp,nchp,istrip,1,nn)         call stripit  (lsprec,rainls,nchptot,nchp,istrip,1,nn)
506         call stripit  (cnvprec,raincon,nchp,nchp,istrip,1,nn)         call stripit  (cnvprec,raincon,nchptot,nchp,istrip,1,nn)
507         call stripit  (snowprec,newsnow,nchp,nchp,istrip,1,nn)         call stripit  (snowprec,newsnow,nchptot,nchp,istrip,1,nn)
508         call stripit  (netsw,swnet,nchp,nchp,istrip,1,nn)         call stripit  (netsw,swnet,nchptot,nchp,istrip,1,nn)
509         call stripit  (netlw,lwstrip,nchp,nchp,istrip,1,nn)         call stripit  (netlw,lwstrip,nchptot,nchp,istrip,1,nn)
510         call stripit  (alwcoeff,alwrad,nchp,nchp,istrip,1,nn)         call stripit  (alwcoeff,alwrad,nchptot,nchp,istrip,1,nn)
511         call stripit  (blwcoeff,blwrad,nchp,nchp,istrip,1,nn)         call stripit  (blwcoeff,blwrad,nchptot,nchp,istrip,1,nn)
512         call stripit  (alai,laistrip,nchp,nchp,istrip,1,nn)         call stripit  (alai,laistrip,nchptot,nchp,istrip,1,nn)
513         call stripit  (agrn,grnstrip,nchp,nchp,istrip,1,nn)         call stripit  (agrn,grnstrip,nchptot,nchp,istrip,1,nn)
514         call stripit  (z2ch,z2str,nchp,nchp,istrip,1,nn)         call stripit  (z2ch,z2str,nchptot,nchp,istrip,1,nn)
515         call stripit  (sqscat,scatstr,nchp,nchp,istrip,1,nn)         call stripit  (sqscat,scatstr,nchptot,nchp,istrip,1,nn)
516         call stripit  (rsoil1,rs1str,nchp,nchp,istrip,1,nn)         call stripit  (rsoil1,rs1str,nchptot,nchp,istrip,1,nn)
517         call stripit  (rsoil2,rs2str,nchp,nchp,istrip,1,nn)         call stripit  (rsoil2,rs2str,nchptot,nchp,istrip,1,nn)
518         call stripit  (rdc,rdcstr,nchp,nchp,istrip,1,nn)         call stripit  (rdc,rdcstr,nchptot,nchp,istrip,1,nn)
519         call stripit  (u2fac,u2fstr,nchp,nchp,istrip,1,nn)         call stripit  (u2fac,u2fstr,nchptot,nchp,istrip,1,nn)
520         call stripit  (shg,shgstr,nchp,nchp,istrip,1,nn)         call stripit  (shg,shgstr,nchptot,nchp,istrip,1,nn)
521         call stripit  (dqsdt,dqsdtstr,nchp,nchp,istrip,1,nn)         call stripit  (dqsdt,dqsdtstr,nchptot,nchp,istrip,1,nn)
522         call stripit  ( qice, qicestr,nchp,nchp,istrip,1,nn)         call stripit  ( qice, qicestr,nchptot,nchp,istrip,1,nn)
523         call stripit  (dqice,dqicestr,nchp,nchp,istrip,1,nn)         call stripit  (dqice,dqicestr,nchptot,nchp,istrip,1,nn)
524         call stripitint (ityp,types,nchp,nchp,istrip,1,nn)         call stripitint (ityp,types,nchptot,nchp,istrip,1,nn)
525    
526         call stripit  (tground,tc,nchp,nchp,istrip,1,nn)         call stripit  (tground,tc,nchptot,nchp,istrip,1,nn)
527         call stripit  (tdeep,td,nchp,nchp,istrip,1,nn)         call stripit  (tdeep,td,nchptot,nchp,istrip,1,nn)
528         call stripit  (qground,qa,nchp,nchp,istrip,1,nn)         call stripit  (qground,qa,nchptot,nchp,istrip,1,nn)
529         call stripit  (swetshal,swet1,nchp,nchp,istrip,1,nn)         call stripit  (swetshal,swet1,nchptot,nchp,istrip,1,nn)
530         call stripit  (swetroot,swet2,nchp,nchp,istrip,1,nn)         call stripit  (swetroot,swet2,nchptot,nchp,istrip,1,nn)
531         call stripit  (swetdeep,swet3,nchp,nchp,istrip,1,nn)         call stripit  (swetdeep,swet3,nchptot,nchp,istrip,1,nn)
532         call stripit  (snodep,snowdepth,nchp,nchp,istrip,1,nn)         call stripit  (snodep,snowdepth,nchptot,nchp,istrip,1,nn)
533         call stripit  (capac,capacity,nchp,nchp,istrip,1,nn)         call stripit  (capac,capacity,nchptot,nchp,istrip,1,nn)
534    
535         call astro ( nymd,nhms,lats,lons,istrip,cosz,ra )         call astro ( nymd,nhms,lats,lons,istrip,cosz,ra )
536    
# Line 593  c     print * Line 554  c     print *
554  c     stop  c     stop
555  c     endif  c     endif
556    
557    c Zero out velocities at the bottom edge of the model
558    c ---------------------------------------------------
559          do i =1,istrip
560           u(i,nlay+1) = 0.
561           v(i,nlay+1) = 0.
562          enddo
563    
564  c convert temperature of level nlay+1 to theta & value of sh at ground  c convert temperature of level nlay+1 to theta & value of sh at ground
565  c --------------------------------------------------------------------  c --------------------------------------------------------------------
566        do i =1,istrip        do i =1,istrip
# Line 600  c -------------------------------------- Line 568  c --------------------------------------
568        sh(i,nlay+1) = qa(i)        sh(i,nlay+1) = qa(i)
569        enddo        enddo
570    
571        if(iqg.gt.0) then        if(diagnostics_is_on('QG      ',myid) ) then
572        do i=1,istrip        do i=1,istrip
573        tmpstrip(i) = sh(i,nlay+1)*1000        tmpstrip(i) = sh(i,nlay+1)*1000
574        enddo        enddo
575        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
576       1                        qdiag(1,1,iqg),ijall,1,nn,.false.)       . .false., 'QG      ', 1, 1, bi, bj, myid)
577        endif        endif
578    
579  c value of tracers at the ground  c value of tracers at the ground
580  c ------------------------------  c ------------------------------
581        do nt = 1,ntracers-ptracers  c     do nt = 1,ntracers-ptracers
582         do i = 1,istrip  C      do i = 1,istrip
583          tracers(i,nlay+1,nt) = 0.  C       tracers(i,nlay+1,nt) = 0.
584         enddo  C      enddo
585        enddo  C     enddo
586    
587  c compute virtual potential temperatures  c compute virtual potential temperatures
588  c --------------------------------------  c --------------------------------------
# Line 650  c ------------------------------- Line 618  c -------------------------------
618    
619  c increment diagnostic arrays for quantities calculated before trbfl  c increment diagnostic arrays for quantities calculated before trbfl
620  c ------------------------------------------------------------------  c ------------------------------------------------------------------
621        do i =1,istrip        if(diagnostics_is_on('DTSRF   ',myid) ) then
622        stdiag(i) = ( thv(i,nlay+1)-thv(i,nlay) ) / pke(i,nlay+1)         do i=1,istrip
623        enddo          stdiag(i) = ( thv(i,nlay+1)-thv(i,nlay) ) / pke(i,nlay+1)
624        if(idtsrf.gt.0) then         enddo
625        call paste2grd(stdiag,igrd,chfrstr,istrip,nchp,         call diag_vegtile_fill (stdiag,igrd,chfrstr,istrip,nchp,nn,
626       1                      qdiag(1,1,idtsrf),ijall,1,nn,.false.)       . .false., 'DTSRF   ', 1, 1, bi, bj, myid)
627          endif
628    
629          if(2.eq.1)then
630          print *,' In turb before trbflx - strip ',nn,' out of ',numstrips
631          print *,' bi = ',bi
632          print *,' ntracers ',ntracers,' ptracers ',ptracers
633          print *,'dttrb,itrtrb,rmu,edle ',dttrb,' ',itrtrb,' ',rmu,' ',edle
634          print *,' nchp ',nchp,' nchptot ',nchptot,' nchplnd ',nchplnd
635          print *,' qbeg, tprof ',qbeg,' ',tprof
636          print *,'istrip,nlay,nymd,nhms ',istrip,' ',nlay,' ',nymd,' ',nhms
637          print *,' grav,cp,rgas,faceps,virtcon,undef ',
638         .     grav,' ',cp,' ',rgas,' ',faceps,' ',virtcon,' ',undef
639          print *,' field: th ',th
640    c     print *,' field: thv ',thv
641    c     print *,' field: sh ',sh
642    c     print *,' field: u ',u
643    c     print *,' field: v ',v
644          print *,' field: p ',p
645    c     print *,' field: pe ',pe
646    c     print *,' field: pk ',pk
647    c     print *,' field: pke ',pke
648    c     print *,' field: dpstr ',dpstr
649    c     print *,' field: stwatr ',stwatr
650    c     print *,' field: stz0 ',stz0
651        endif        endif
652    
653  c call trbflx  c call trbflx
# Line 667  c ----------- Line 659  c -----------
659       4 stq10m,istrip,nlay,nymd,nhms,grav,cp,rgas,faceps,virtcon,undef,       4 stq10m,istrip,nlay,nymd,nhms,grav,cp,rgas,faceps,virtcon,undef,
660       5 dshdthg,dshdshg,dthdthg,dthdshg,eturb,dedqa,dedtc,       5 dshdthg,dshdshg,dthdthg,dthdshg,eturb,dedqa,dedtc,
661       6 hsturb,dhsdqa,dhsdtc,transth,transsh,       6 hsturb,dhsdqa,dhsdtc,transth,transsh,
662       7 ctsave,xxsave,yysave,zetasave,xlsave,khsave,qliq,turbfcc,       7 ctsave,xxsave,yysave,zetasave,xlsave,khsave,qliq,turbfcc)
      8 checktrb)  
663    
664        call pastit (qq,tke,istrip,nchp,nchp,nlay,nn)        call pastit (qq,tke,istrip,nchp,nchptot,nlay,nn)
665        call pastit (ctsave,ctmt,istrip,nchp,nchp,1,nn)        call pastit (ctsave,ctmt,istrip,nchp,nchptot,1,nn)
666        call pastit (xxsave,xxmt,istrip,nchp,nchp,1,nn)        call pastit (xxsave,xxmt,istrip,nchp,nchptot,1,nn)
667        call pastit (yysave,yymt,istrip,nchp,nchp,1,nn)        call pastit (yysave,yymt,istrip,nchp,nchptot,1,nn)
668        call pastit (zetasave,zetamt,istrip,nchp,nchp,1,nn)        call pastit (zetasave,zetamt,istrip,nchp,nchptot,1,nn)
669        call pastit (xlsave,xlmt,istrip,nchp,nchp,nlay,nn)        call pastit (xlsave,xlmt,istrip,nchp,nchptot,nlay,nn)
670        call pastit (khsave,khmt,istrip,nchp,nchp,nlay,nn)        call pastit (khsave,khmt,istrip,nchp,nchptot,nlay,nn)
671    
672        call pastit (qliq  ,qliqmsc,istrip,nchp,nchp,nlay,nn)        call pastit (qliq  ,qliqmsc,istrip,nchp,nchptot,nlay,nn)
673        call pastit (turbfcc,fccmsc,istrip,nchp,nchp,nlay,nn)        call pastit (turbfcc,fccmsc,istrip,nchp,nchptot,nlay,nn)
674    
675  c  New diagnostic: potential evapotranspiration  c  New diagnostic: potential evapotranspiration
676        do i = 1,istrip        do i = 1,istrip
# Line 701  C*************************************** Line 692  C***************************************
692         hlwdwn(i) = alwrad(i)+blwrad(i)*tc(i)-lwstrip(i)         hlwdwn(i) = alwrad(i)+blwrad(i)*tc(i)-lwstrip(i)
693         psurf(i) = pe(i,nlay+1)         psurf(i) = pe(i,nlay+1)
694         wspeed(i) = sqrt(u(i,nlay)*u(i,nlay) + v(i,nlay)*v(i,nlay))         wspeed(i) = sqrt(u(i,nlay)*u(i,nlay) + v(i,nlay)*v(i,nlay))
695           if(wspeed(i) .lt. 1.e-20) wspeed(i) = 1.e-20
696  C Note: This LSM precip bug needs to be cleaned up  C Note: This LSM precip bug needs to be cleaned up
697  ccc   newsnow(i) = newsnow(i)*dtfac    ccc   newsnow(i) = newsnow(i)*dtfac  
698  ccc   raincon(i) = raincon(i)*dtfac    ccc   raincon(i) = raincon(i)*dtfac  
# Line 740  ccc   rainls (i) = rainls (i)*dtfac Line 732  ccc   rainls (i) = rainls (i)*dtfac
732  c**********************************************************************  c**********************************************************************
733  c   diagnostics: fill arrays for lsm input fields  c   diagnostics: fill arrays for lsm input fields
734  c**********************************************************************  c**********************************************************************
735        if(isnowfall.gt.0) then        if(diagnostics_is_on('SNOWFALL',myid) ) then
736        do i = 1,istrip        do i = 1,istrip
737        tmpstrip(i) = newsnow(i)*86400          tmpstrip(i) = newsnow(i)*86400  
738        enddo        enddo
739        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
740       1                       qdiag(1,1,isnowfall),ijall,1,nn,.false.)       . .false., 'SNOWFALL', 1, 1, bi, bj, myid)
741        endif        endif
742        if(iraincon.gt.0) then        if(diagnostics_is_on('RAINCON ',myid) ) then
743        do i = 1,istrip        do i = 1,istrip
744        tmpstrip(i) = raincon(i)*86400          tmpstrip(i) = raincon(i)*86400  
745        enddo        enddo
746        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
747       1                       qdiag(1,1,iraincon),ijall,1,nn,.false.)       . .false., 'RAINCON ', 1, 1, bi, bj, myid)
748        endif        endif
749        if(irainlsp.gt.0) then        if(diagnostics_is_on('RAINLSP ',myid) ) then
750        do i = 1,istrip        do i = 1,istrip
751        tmpstrip(i) = rainls(i)*86400          tmpstrip(i) = rainls(i)*86400  
752        enddo        enddo
753        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
754       1                      qdiag(1,1,irainlsp),ijall,1,nn,.false.)       . .false., 'RAINLSP ', 1, 1, bi, bj, myid)
755        endif        endif
756        if(igreen.gt.0) then        if(diagnostics_is_on('GREEN   ',myid) ) then
757        call paste2grd(grnstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (grnstrip,igrd,chfrstr,istrip,nchp,nn,
758       1                        qdiag(1,1,igreen),ijall,1,nn,.false.)       . .false., 'GREEN   ', 1, 1, bi, bj, myid)
759        endif        endif
760        if(ilai.gt.0) then        if(diagnostics_is_on('LAI     ',myid) ) then
761        call paste2grd(laistrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (laistrip,igrd,chfrstr,istrip,nchp,nn,
762       1                        qdiag(1,1,ilai),ijall,1,nn,.false.)       . .false., 'LAI     ', 1, 1, bi, bj, myid)
763        endif        endif
764        if(ipardr.gt.0) then        if(diagnostics_is_on('PARDR   ',myid) ) then
765        call paste2grd(pardr,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (pardr,igrd,chfrstr,istrip,nchp,nn,
766       1                     qdiag(1,1,ipardr),ijall,1,nn,.false.)       . .false., 'PARDR   ', 1, 1, bi, bj, myid)
767        endif        endif
768        if(ipardf.gt.0) then        if(diagnostics_is_on('PARDF   ',myid) ) then
769        call paste2grd(pardf,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (pardf,igrd,chfrstr,istrip,nchp,nn,
770       1                     qdiag(1,1,ipardf),ijall,1,nn,.false.)       . .false., 'PARDF   ', 1, 1, bi, bj, myid)
771        endif        endif
772        if(idlwdtc.gt.0) then        if(diagnostics_is_on('DLWDTC  ',myid) ) then
773        call paste2grd(blwrad,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (blwrad,igrd,chfrstr,istrip,nchp,nn,
774       1                      qdiag(1,1,idlwdtc),ijall,1,nn,.false.)       . .false., 'DLWDTC  ', 1, 1, bi, bj, myid)
775        endif        endif
776        if(idhdtc.gt.0) then        if(diagnostics_is_on('DHDTC   ',myid) ) then
777        call paste2grd(dhsdtc,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (dhsdtc,igrd,chfrstr,istrip,nchp,nn,
778       1                      qdiag(1,1,idhdtc),ijall,1,nn,.false.)       . .false., 'DHDTC   ', 1, 1, bi, bj, myid)
779        endif        endif
780        if(idedtc.gt.0) then        if(diagnostics_is_on('DEDTC   ',myid) ) then
781        call paste2grd(dedtc,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (dedtc,igrd,chfrstr,istrip,nchp,nn,
782       1                     qdiag(1,1,idedtc),ijall,1,nn,.false.)       . .false., 'DEDTC   ', 1, 1, bi, bj, myid)
783        endif        endif
784        if(idhdqa.gt.0) then        if(diagnostics_is_on('DHDQA   ',myid) ) then
785        call paste2grd(dhsdqa,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (dhsdqa,igrd,chfrstr,istrip,nchp,nn,
786       1                      qdiag(1,1,idhdqa),ijall,1,nn,.false.)       . .false., 'DHDQA   ', 1, 1, bi, bj, myid)
787        endif        endif
788        if(idedqa.gt.0) then        if(diagnostics_is_on('DEDQA   ',myid) ) then
789        call paste2grd(dedqa,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (dedqa,igrd,chfrstr,istrip,nchp,nn,
790       1                     qdiag(1,1,idedqa),ijall,1,nn,.false.)       . .false., 'DEDQA   ', 1, 1, bi, bj, myid)
791        endif        endif
792        if(ilwgdown.gt.0) then        if(diagnostics_is_on('LWGDOWN ',myid) ) then
793        call paste2grd(hlwdwn,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (hlwdwn,igrd,chfrstr,istrip,nchp,nn,
794       1                      qdiag(1,1,ilwgdown),ijall,1,nn,.false.)       . .false., 'LWGDOWN ', 1, 1, bi, bj, myid)
795        endif        endif
796  c**********************************************************************  c**********************************************************************
797    
798        if(nland.gt.0)then        if(nland.gt.0)then
799    
800         call tile (         call tile (
801       I   nland, timstp, types, rainls, raincon,  newsnow,  wspeed,       I   nland, timstp, types, rainls, raincon,  newsnow,  wspeed,
802       I   eturb,  dedqa,  dedtc,  hsturb, dhsdqa, dhsdtc,       I   eturb,  dedqa,  dedtc,  hsturb, dhsdqa, dhsdtc,
# Line 833  c*************************************** Line 826  c***************************************
826  c   diagnostics: fill arrays for lsm output fields  c   diagnostics: fill arrays for lsm output fields
827  c***********************************************************************  c***********************************************************************
828    
829        if(irunoff.gt.0) then        if(diagnostics_is_on('RUNOFF  ',myid) ) then
830        call paste2grd(runoff,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (runoff,igrd,chfrstr,istrip,nchp,nn,
831       1                      qdiag(1,1,irunoff),ijall,1,nn,.false.)       . .false., 'RUNOFF  ', 1, 1, bi, bj, myid)
832        endif        endif
833        if(ifwsoil.gt.0) then        if(diagnostics_is_on('FWSOIL  ',myid) ) then
834        call paste2grd(fwsoil,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (fwsoil,igrd,chfrstr,istrip,nchp,nn,
835       1                      qdiag(1,1,ifwsoil),ijall,1,nn,.false.)       . .false., 'FWSOIL  ', 1, 1, bi, bj, myid)
836        endif        endif
837        if(igdrain.gt.0) then        if(diagnostics_is_on('GDRAIN  ',myid) ) then
838        call paste2grd(gdrain,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (gdrain,igrd,chfrstr,istrip,nchp,nn,
839       1                      qdiag(1,1,igdrain),ijall,1,nn,.false.)       . .false., 'GDRAIN  ', 1, 1, bi, bj, myid)
840        endif        endif
841        if(isnowmelt.gt.0) then        if(diagnostics_is_on('SNOWMELT',myid) ) then
842        call paste2grd(smelt,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (smelt,igrd,chfrstr,istrip,nchp,nn,
843       1                     qdiag(1,1,isnowmelt),ijall,1,nn,.false.)       . .false., 'SNOWMELT', 1, 1, bi, bj, myid)
844        endif        endif
845        if(ieveg.gt.0) then        if(diagnostics_is_on('EVEG    ',myid) ) then
846        call paste2grd(eveg,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (eveg,igrd,chfrstr,istrip,nchp,nn,
847       1                    qdiag(1,1,ieveg),ijall,1,nn,.false.)       . .false., 'EVEG    ', 1, 1, bi, bj, myid)
848        endif        endif
849        if(iesnow.gt.0) then        if(diagnostics_is_on('ESNOW   ',myid) ) then
850        call paste2grd(esno,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (esno,igrd,chfrstr,istrip,nchp,nn,
851       1                    qdiag(1,1,iesnow),ijall,1,nn,.false.)       . .false., 'ESNOW   ', 1, 1, bi, bj, myid)
852        endif        endif
853        if(iesoil.gt.0) then        if(diagnostics_is_on('ESOIL   ',myid) ) then
854        call paste2grd(esoi,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (esoi,igrd,chfrstr,istrip,nchp,nn,
855       1                    qdiag(1,1,iesoil),ijall,1,nn,.false.)       . .false., 'ESOIL   ', 1, 1, bi, bj, myid)
856        endif        endif
857        if(ieresv.gt.0) then        if(diagnostics_is_on('ERESV   ',myid) ) then
858        call paste2grd(eint,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (eint,igrd,chfrstr,istrip,nchp,nn,
859       1                    qdiag(1,1,ieresv),ijall,1,nn,.false.)       . .false., 'ERESV   ', 1, 1, bi, bj, myid)
860        endif        endif
861        if(ievpot.gt.0) then        if(diagnostics_is_on('EVPOT   ',myid) ) then
862        call paste2grd(evpot,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (evpot,igrd,chfrstr,istrip,nchp,nn,
863       1                     qdiag(1,1,ievpot),ijall,1,nn,.false.)       . .false., 'EVPOT   ', 1, 1, bi, bj, myid)
864        endif        endif
865        if(idtc.gt.0) then        if(diagnostics_is_on('DTC     ',myid) ) then
866        call paste2grd(strdg1,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg1,igrd,chfrstr,istrip,nchp,nn,
867       1                      qdiag(1,1,idtc),ijall,1,nn,.false.)       . .false., 'DTC     ', 1, 1, bi, bj, myid)
868        endif        endif
869        if(idqc.gt.0) then        if(diagnostics_is_on('DQC     ',myid) ) then
870        call paste2grd(strdg2,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg2,igrd,chfrstr,istrip,nchp,nn,
871       1                      qdiag(1,1,idqc),ijall,1,nn,.false.)       . .false., 'DQC     ', 1, 1, bi, bj, myid)
872        endif        endif
873        if(itcdtc.gt.0) then        if(diagnostics_is_on('TCDTC   ',myid) ) then
874        call paste2grd(strdg3,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg3,igrd,chfrstr,istrip,nchp,nn,
875       1                      qdiag(1,1,itcdtc),ijall,1,nn,.false.)       . .false., 'TCDTC   ', 1, 1, bi, bj, myid)
876        endif        endif
877        if(iraddtc.gt.0) then        if(diagnostics_is_on('RADDTC  ',myid) ) then
878        call paste2grd(strdg4,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg4,igrd,chfrstr,istrip,nchp,nn,
879       1                      qdiag(1,1,iraddtc),ijall,1,nn,.false.)       . .false., 'RADDTC  ', 1, 1, bi, bj, myid)
880        endif        endif
881        if(isensdtc.gt.0) then        if(diagnostics_is_on('SENSDTC ',myid) ) then
882        call paste2grd(strdg5,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg5,igrd,chfrstr,istrip,nchp,nn,
883       1                      qdiag(1,1,isensdtc),ijall,1,nn,.false.)       . .false., 'SENSDTC ', 1, 1, bi, bj, myid)
884        endif        endif
885        if(ilatdtc.gt.0) then        if(diagnostics_is_on('LATDTC  ',myid) ) then
886        call paste2grd(strdg6,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg6,igrd,chfrstr,istrip,nchp,nn,
887       1                      qdiag(1,1,ilatdtc),ijall,1,nn,.false.)       . .false., 'LATDTC  ', 1, 1, bi, bj, myid)
888        endif        endif
889        if(itddtc.gt.0) then        if(diagnostics_is_on('TDDTC   ',myid) ) then
890        call paste2grd(strdg7,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg7,igrd,chfrstr,istrip,nchp,nn,
891       1                      qdiag(1,1,itddtc),ijall,1,nn,.false.)       . .false., 'TDDTC   ', 1, 1, bi, bj, myid)
892        endif        endif
893        if(iqcdtc.gt.0) then        if(diagnostics_is_on('QCDTC   ',myid) ) then
894        call paste2grd(strdg8,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (strdg8,igrd,chfrstr,istrip,nchp,nn,
895       1                      qdiag(1,1,iqcdtc),ijall,1,nn,.false.)       . .false., 'QCDTC   ', 1, 1, bi, bj, myid)
896        endif        endif
897  c**********************************************************************  c***********************************************************************
898    
899        if( ndlsm.gt.1 ) then        if( ndlsm.gt.1 ) then
900        call pstbitint(types,qdiaglsm(1,1),istrip,nchp,nchp,1,nn)        call pstbitint(types,qdiaglsm(1,1),istrip,nchp,nchptot,1,nn)
901        call pstbmpit(chfrstr,qdiaglsm(1,2),istrip,nchp,nchp,1,nn)        call pstbmpit(chfrstr,qdiaglsm(1,2),istrip,nchp,nchptot,1,nn)
902        call pstbmpit(lats,qdiaglsm(1,3),istrip,nchp,nchp,1,nn)        call pstbmpit(lats,qdiaglsm(1,3),istrip,nchp,nchptot,1,nn)
903        call pstbmpit(lons,qdiaglsm(1,4),istrip,nchp,nchp,1,nn)        call pstbmpit(lons,qdiaglsm(1,4),istrip,nchp,nchptot,1,nn)
904        call pstbmpit(igrdstr,qdiaglsm(1,5),istrip,nchp,nchp,1,nn)  c     call pstbmpit(igrdstr,qdiaglsm(1,5),istrip,nchp,nchptot,1,nn)
905        call pstbmpit(tc,qdiaglsm(1,6),istrip,nchp,nchp,1,nn)        call pstbmpit(tc,qdiaglsm(1,6),istrip,nchp,nchptot,1,nn)
906        call pstbmpit(td,qdiaglsm(1,7),istrip,nchp,nchp,1,nn)        call pstbmpit(td,qdiaglsm(1,7),istrip,nchp,nchptot,1,nn)
907        call pstbmpit(qa,qdiaglsm(1,8),istrip,nchp,nchp,1,nn)        call pstbmpit(qa,qdiaglsm(1,8),istrip,nchp,nchptot,1,nn)
908        call pstbmpit(swet1,qdiaglsm(1,9),istrip,nchp,nchp,1,nn)        call pstbmpit(swet1,qdiaglsm(1,9),istrip,nchp,nchptot,1,nn)
909        call pstbmpit(swet2,qdiaglsm(1,10),istrip,nchp,nchp,1,nn)        call pstbmpit(swet2,qdiaglsm(1,10),istrip,nchp,nchptot,1,nn)
910        call pstbmpit(swet3,qdiaglsm(1,11),istrip,nchp,nchp,1,nn)        call pstbmpit(swet3,qdiaglsm(1,11),istrip,nchp,nchptot,1,nn)
911        call pstbmpit(capacity,qdiaglsm(1,12),istrip,nchp,nchp,1,nn)        call pstbmpit(capacity,qdiaglsm(1,12),istrip,nchp,nchptot,1,nn)
912        call pstbmpit(snowdepth,qdiaglsm(1,13),istrip,nchp,nchp,1,nn)        call pstbmpit(snowdepth,qdiaglsm(1,13),istrip,nchp,nchptot,1,nn)
913        call pstbmpit(eturb,qdiaglsm(1,14),istrip,nchp,nchp,1,nn)        call pstbmpit(eturb,qdiaglsm(1,14),istrip,nchp,nchptot,1,nn)
914        call pstbmpit(hsturb,qdiaglsm(1,15),istrip,nchp,nchp,1,nn)        call pstbmpit(hsturb,qdiaglsm(1,15),istrip,nchp,nchptot,1,nn)
915        call pstbmpit(cd,qdiaglsm(1,16),istrip,nchp,nchp,1,nn)        call pstbmpit(cd,qdiaglsm(1,16),istrip,nchp,nchptot,1,nn)
916        call pstbmpit(laistrip,qdiaglsm(1,17),istrip,nchp,nchp,1,nn)        call pstbmpit(laistrip,qdiaglsm(1,17),istrip,nchp,nchptot,1,nn)
917        call pstbmpit(grnstrip,qdiaglsm(1,18),istrip,nchp,nchp,1,nn)        call pstbmpit(grnstrip,qdiaglsm(1,18),istrip,nchp,nchptot,1,nn)
918        call pstbmpit(eint,qdiaglsm(1,19),istrip,nchp,nchp,1,nn)        call pstbmpit(eint,qdiaglsm(1,19),istrip,nchp,nchptot,1,nn)
919        call pstbmpit(esoi,qdiaglsm(1,20),istrip,nchp,nchp,1,nn)        call pstbmpit(esoi,qdiaglsm(1,20),istrip,nchp,nchptot,1,nn)
920        call pstbmpit(eveg,qdiaglsm(1,21),istrip,nchp,nchp,1,nn)        call pstbmpit(eveg,qdiaglsm(1,21),istrip,nchp,nchptot,1,nn)
921        call pstbmpit(esno,qdiaglsm(1,22),istrip,nchp,nchp,1,nn)        call pstbmpit(esno,qdiaglsm(1,22),istrip,nchp,nchptot,1,nn)
922        call pstbmpit(strdg1,qdiaglsm(1,23),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg1,qdiaglsm(1,23),istrip,nchp,nchptot,1,nn)
923        call pstbmpit(strdg2,qdiaglsm(1,24),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg2,qdiaglsm(1,24),istrip,nchp,nchptot,1,nn)
924        call pstbmpit(strdg3,qdiaglsm(1,25),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg3,qdiaglsm(1,25),istrip,nchp,nchptot,1,nn)
925        call pstbmpit(strdg4,qdiaglsm(1,26),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg4,qdiaglsm(1,26),istrip,nchp,nchptot,1,nn)
926        call pstbmpit(strdg5,qdiaglsm(1,27),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg5,qdiaglsm(1,27),istrip,nchp,nchptot,1,nn)
927        call pstbmpit(strdg6,qdiaglsm(1,28),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg6,qdiaglsm(1,28),istrip,nchp,nchptot,1,nn)
928        call pstbmpit(strdg7,qdiaglsm(1,29),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg7,qdiaglsm(1,29),istrip,nchp,nchptot,1,nn)
929        call pstbmpit(strdg8,qdiaglsm(1,30),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg8,qdiaglsm(1,30),istrip,nchp,nchptot,1,nn)
930        call pstbmpit(strdg9,qdiaglsm(1,31),istrip,nchp,nchp,1,nn)        call pstbmpit(strdg9,qdiaglsm(1,31),istrip,nchp,nchptot,1,nn)
931        call pstbmpit(smelt,qdiaglsm(1,32),istrip,nchp,nchp,1,nn)        call pstbmpit(smelt,qdiaglsm(1,32),istrip,nchp,nchptot,1,nn)
932        call pstbmpit(gdrain,qdiaglsm(1,33),istrip,nchp,nchp,1,nn)        call pstbmpit(gdrain,qdiaglsm(1,33),istrip,nchp,nchptot,1,nn)
933        call pstbmpit(runsrf,qdiaglsm(1,34),istrip,nchp,nchp,1,nn)        call pstbmpit(runsrf,qdiaglsm(1,34),istrip,nchp,nchptot,1,nn)
934        call pstbmpit(fwsoil,qdiaglsm(1,35),istrip,nchp,nchp,1,nn)        call pstbmpit(fwsoil,qdiaglsm(1,35),istrip,nchp,nchptot,1,nn)
935        call pstbmpit(evpot,qdiaglsm(1,36),istrip,nchp,nchp,1,nn)        call pstbmpit(evpot,qdiaglsm(1,36),istrip,nchp,nchptot,1,nn)
936        call pstbmpit(stt2m,qdiaglsm(1,37),istrip,nchp,nchp,1,nn)        call pstbmpit(stt2m,qdiaglsm(1,37),istrip,nchp,nchptot,1,nn)
937        call pstbmpit(stq2m,qdiaglsm(1,38),istrip,nchp,nchp,1,nn)        call pstbmpit(stq2m,qdiaglsm(1,38),istrip,nchp,nchptot,1,nn)
938        endif        endif
939    
940        call pastit (tc,tground,istrip,nchp,nchp,1,nn)        call pastit (tc,tground,istrip,nchp,nchptot,1,nn)
941        call pastit (td,tdeep,istrip,nchp,nchp,1,nn)        call pastit (td,tdeep,istrip,nchp,nchptot,1,nn)
942        call pastit (qa,qground,istrip,nchp,nchp,1,nn)        call pastit (qa,qground,istrip,nchp,nchptot,1,nn)
943        call pastit (swet1,swetshal,istrip,nchp,nchp,1,nn)        call pastit (swet1,swetshal,istrip,nchp,nchptot,1,nn)
944        call pastit (swet2,swetroot,istrip,nchp,nchp,1,nn)        call pastit (swet2,swetroot,istrip,nchp,nchptot,1,nn)
945        call pastit (swet3,swetdeep,istrip,nchp,nchp,1,nn)        call pastit (swet3,swetdeep,istrip,nchp,nchptot,1,nn)
946        call pastit (capacity,capac,istrip,nchp,nchp,1,nn)        call pastit (capacity,capac,istrip,nchp,nchptot,1,nn)
947        call pastit (snowdepth,snodep,istrip,nchp,nchp,1,nn)        call pastit (snowdepth,snodep,istrip,nchp,nchptot,1,nn)
948    
949  c**********************************************************************  c**********************************************************************
950  c  Now update the theta and sh profiles with the new ground temperature  c  Now update the theta and sh profiles with the new ground temperature
# Line 982  c*************************************** Line 975  c***************************************
975        enddo        enddo
976        enddo        enddo
977    
978        if(tprof)then        if(2.eq.1)then
979         CALL PNTPRF (1,IJALL,nlay,NYMD,NHMS,transth,'TRB T FLUX      ')        print *,' In turbio, just after updating th and sh - strip ',nn
980         CALL PNTPRF (1,IJALL,nlay,NYMD,NHMS,transsh,'TRB Q FLUX      ')        print *,' field: th ',th
981          print *,' field: sh ',sh
982        endif        endif
983    
984  c tendency updates  c tendency updates
# Line 995  c ---------------- Line 989  c ----------------
989        do i =1,istrip        do i =1,istrip
990        tends(i) = ( u(i,l)-tmpstrip(i) )        tends(i) = ( u(i,l)-tmpstrip(i) )
991        enddo        enddo
992        call pastit (tends,dumsc(1,l),istrip,nchp,nchp,1,nn)        call pastit (tends,dumsc(1,l),istrip,nchp,nchptot,1,nn)
993    
994        call strip2tile(vz(1,1,l),igrd,tmpstrip,nchp,ijall,        call strip2tile(vz(1,1,l),igrd,tmpstrip,nchp,ijall,
995       1                                                 istrip,1,nn)       1                                                 istrip,1,nn)
996        do i =1,istrip        do i =1,istrip
997        tends(i) = ( v(i,l)-tmpstrip(i) )        tends(i) = ( v(i,l)-tmpstrip(i) )
998        enddo        enddo
999        call pastit (tends,dvmsc(1,l),istrip,nchp,nchp,1,nn)        call pastit (tends,dvmsc(1,l),istrip,nchp,nchptot,1,nn)
1000    
1001        call strip2tile(tz(1,1,l),igrd,tmpstrip,nchp,ijall,        call strip2tile(tz(1,1,l),igrd,tmpstrip,nchp,ijall,
1002       1                                                 istrip,1,nn)       1                                                 istrip,1,nn)
1003        do i =1,istrip        do i =1,istrip
1004        tends(i) = ( th(i,l)-tmpstrip(i) )        tends(i) = ( th(i,l)-tmpstrip(i) )
1005        enddo        enddo
1006        call pastit (tends,dtmsc(1,l),istrip,nchp,nchp,1,nn)  
1007          if(2.eq.1)then
1008          print *,' In turbio, tendencies for strip ',nn,' level ',l
1009          print *,' field: th ',tends
1010          endif
1011    
1012          call pastit (tends,dtmsc(1,l),istrip,nchp,nchptot,1,nn)
1013    
1014        call strip2tile(qz(1,1,l,1),igrd,tmpstrip,nchp,ijall,        call strip2tile(qz(1,1,l,1),igrd,tmpstrip,nchp,ijall,
1015       1                                                 istrip,1,nn)       1                                                 istrip,1,nn)
1016        do i =1,istrip        do i =1,istrip
1017        tends(i) = ( sh(i,l)-tmpstrip(i) )        tends(i) = ( sh(i,l)-tmpstrip(i) )
1018        enddo        enddo
       call pastit (tends,dqmsc(1,l,1),istrip,nchp,nchp,1,nn)  
1019    
1020        do nt = 1,ntracers-ptracers        if(2.eq.1)then
1021         call strip2tile(qz(1,1,L,ptracers+nt),igrd,tmpstrip,nchp,        print *,' In turbio, tendencies for strip ',nn,' level ',l
1022       1                                             ijall,istrip,1,nn)        print *,' field: sh ',tends
1023         do i =1,istrip        endif
1024          tends(i) = ( tracers(i,L,nt)-tmpstrip(i) )  
1025         enddo        call pastit (tends,dqmsc(1,l,1),istrip,nchp,nchptot,1,nn)
1026         call pastit (tends,dqmsc(1,L,ptracers+nt),istrip,nchp,nchp,1,nn)  
1027        enddo  c     do nt = 1,ntracers-ptracers
1028    c      call strip2tile(qz(1,1,L,ptracers+nt),igrd,tmpstrip,nchp,
1029    c    1                                             ijall,istrip,1,nn)
1030    c      do i =1,istrip
1031    c       tends(i) = ( tracers(i,L,nt)-tmpstrip(i) )
1032    c      enddo
1033    c      call pastit(tends,dqmsc(1,L,ptracers+nt),istrip,nchp,
1034    c    .                                     nchptot,1,nn)
1035    c     enddo
1036    
1037        enddo        enddo
1038    
# Line 1037  c note: the order, logic, and scaling of Line 1044  c note: the order, logic, and scaling of
1044  c       diagnostics is critical!  c       diagnostics is critical!
1045  c ------------------------------  c ------------------------------
1046    
1047        if(ievap.gt.0) then        if(diagnostics_is_on('EVAP    ',myid) ) then
1048        do i=1,istrip        do i=1,istrip
1049        tmpstrip(i) = stqflux(i,nlay) * 86400        tmpstrip(i) = stqflux(i,nlay) * 86400
1050        enddo        enddo
1051        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
1052       1                        qdiag(1,1,ievap),ijall,1,nn,.false.)       . .false., 'EVAP    ', 1, 1, bi, bj, myid)
1053        endif        endif
1054        if(ieflux.gt.0) then        if(diagnostics_is_on('EFLUX   ',myid) ) then
1055        do i=1,istrip        do i=1,istrip
1056        tmpstrip(i) = stqflux(i,nlay) * alhl        tmpstrip(i) = stqflux(i,nlay) * alhl
1057        enddo        enddo
1058        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
1059       1                        qdiag(1,1,ieflux),ijall,1,nn,.false.)       . .false., 'EFLUX   ', 1, 1, bi, bj, myid)
1060        endif        endif
1061        if(ihflux.gt.0) then        if(diagnostics_is_on('HFLUX   ',myid) ) then
1062        do i=1,istrip        do i=1,istrip
1063        tmpstrip(i) = sttflux(i,nlay) * cp        tmpstrip(i) = sttflux(i,nlay) * cp
1064        enddo        enddo
1065        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
1066       1                        qdiag(1,1,ihflux),ijall,1,nn,.false.)       . .false., 'HFLUX   ', 1, 1, bi, bj, myid)
1067        endif        endif
1068        if(ituflux.gt.0) then        if(diagnostics_is_on('TUFLUX  ',myid) ) then
1069        call paste2grd(stuflux,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stuflux,igrd,chfrstr,istrip,nchp,nn,
1070       1                       qdiag(1,1,ituflux),ijall,nlay,nn,.false.)       . .false., 'TUFLUX  ', 0, nlay, bi, bj, myid)
1071        endif        endif
1072        if(itvflux.gt.0) then        if(diagnostics_is_on('TVFLUX  ',myid) ) then
1073        call paste2grd(stvflux,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stvflux,igrd,chfrstr,istrip,nchp,nn,
1074       1                       qdiag(1,1,itvflux),ijall,nlay,nn,.false.)       . .false., 'TVFLUX  ', 0, nlay, bi, bj, myid)
1075        endif        endif
1076        if(ittflux.gt.0) then        if(diagnostics_is_on('TTFLUX  ',myid) ) then
1077        do l=1,nlay        do l=1,nlay
1078        do i=1,istrip        do i=1,istrip
1079        sttflux(i,l) = sttflux(i,l) * cp        sttflux(i,l) = sttflux(i,l) * cp
1080        enddo        enddo
1081        enddo        enddo
1082        call paste2grd(sttflux,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (sttflux,igrd,chfrstr,istrip,nchp,nn,
1083       1                       qdiag(1,1,ittflux),ijall,nlay,nn,.false.)       . .false., 'TTFLUX  ', 0, nlay, bi, bj, myid)
1084        endif        endif
1085        if(itqflux.gt.0) then        if(diagnostics_is_on('TQFLUX  ',myid) ) then
1086        do l=1,nlay        do l=1,nlay
1087        do i=1,istrip        do i=1,istrip
1088        stqflux(i,l) = stqflux(i,l) * alhl        stqflux(i,l) = stqflux(i,l) * alhl
1089        enddo        enddo
1090        enddo        enddo
1091        call paste2grd(stqflux,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stqflux,igrd,chfrstr,istrip,nchp,nn,
1092       1                       qdiag(1,1,itqflux),ijall,nlay,nn,.false.)       . .false., 'TQFLUX  ', 0, nlay, bi, bj, myid)
1093        endif        endif
1094        if(iri.gt.0) call paste2grd(sri,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('RI      ',myid) ) then
1095       1                           qdiag(1,1,iri),ijall,nlay,nn,.false.)        call diag_vegtile_fill (sri,igrd,chfrstr,istrip,nchp,nn,
1096        if(ikh.gt.0) call paste2grd(skh,igrd,chfrstr,istrip,nchp,       . .false., 'RI      ', 0, nlay, bi, bj, myid)
1097       1                           qdiag(1,1,ikh),ijall,nlay,nn,.false.)        endif
1098        if(ikm.gt.0) call paste2grd(skm,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('KH      ',myid) ) then
1099       1                           qdiag(1,1,ikm),ijall,nlay,nn,.false.)        call diag_vegtile_fill (skh,igrd,chfrstr,istrip,nchp,nn,
1100        if(ict.gt.0) then       . .false., 'KH      ', 0, nlay, bi, bj, myid)
1101        call paste2grd(sct,igrd,chfrstr,istrip,nchp,        endif
1102       1                   qdiag(1,1,ict),ijall,1,nn,.false.)        if(diagnostics_is_on('KM      ',myid) ) then
1103        endif        call diag_vegtile_fill (skm,igrd,chfrstr,istrip,nchp,nn,
1104        if(icu.gt.0) then       . .false., 'KM      ', 0, nlay, bi, bj, myid)
1105        call paste2grd(scu,igrd,chfrstr,istrip,nchp,        endif
1106       1                   qdiag(1,1,icu),ijall,1,nn,.false.)        if(diagnostics_is_on('CT      ',myid) ) then
1107        endif        call diag_vegtile_fill (sct,igrd,chfrstr,istrip,nchp,nn,
1108        if(iwinds.gt.0) then       . .false., 'CT      ', 1, 1, bi, bj, myid)
1109        call paste2grd(swinds,igrd,chfrstr,istrip,nchp,        endif
1110       1                      qdiag(1,1,iwinds),ijall,1,nn,.false.)        if(diagnostics_is_on('CU      ',myid) ) then
1111        endif        call diag_vegtile_fill (scu,igrd,chfrstr,istrip,nchp,nn,
1112        if(iuflux.gt.0) then       . .false., 'CU      ', 1, 1, bi, bj, myid)
1113        call paste2grd(stuflux(1,nlay),igrd,chfrstr,istrip,nchp,        endif
1114       1                       qdiag(1,1,iuflux),ijall,1,nn,.false.)        if(diagnostics_is_on('WINDS   ',myid) ) then
1115        endif        call diag_vegtile_fill (swinds,igrd,chfrstr,istrip,nchp,nn,
1116        if(ivflux.gt.0) then       . .false., 'WINDS   ', 1, 1, bi, bj, myid)
1117        call paste2grd(stvflux(1,nlay),igrd,chfrstr,istrip,nchp,        endif
1118       1                       qdiag(1,1,ivflux),ijall,1,nn,.false.)        if(diagnostics_is_on('UFLUX   ',myid) ) then
1119        endif        call diag_vegtile_fill (stuflux(1,nlay),igrd,chfrstr,istrip,nchp,
1120        if(iustar.gt.0) then       . nn,.false., 'UFLUX   ', 1, 1, bi, bj, myid)
1121        call paste2grd(sustar,igrd,chfrstr,istrip,nchp,        endif
1122       1                      qdiag(1,1,iustar),ijall,1,nn,.false.)        if(diagnostics_is_on('VFLUX   ',myid) ) then
1123        endif        call diag_vegtile_fill (stvflux(1,nlay),igrd,chfrstr,istrip,nchp,
1124        if(iz0.gt.0) then       . nn,.false., 'VFLUX   ', 1, 1, bi, bj, myid)
1125        call paste2grd(sz0,igrd,chfrstr,istrip,nchp,        endif
1126       1                   qdiag(1,1,iz0),ijall,1,nn,.false.)        if(diagnostics_is_on('USTAR   ',myid) ) then
1127        endif        call diag_vegtile_fill (sustar,igrd,chfrstr,istrip,nchp,nn,
1128        if(ifrqtrb.gt.0) then       . .false., 'USTAR   ', 1, 1, bi, bj, myid)
1129        call paste2grd(frqtrb,igrd,chfrstr,istrip,nchp,        endif
1130       1                      qdiag(1,1,ifrqtrb),ijall,1,nn,.false.)        if(diagnostics_is_on('Z0      ',myid) ) then
1131        endif        call diag_vegtile_fill (sz0,igrd,chfrstr,istrip,nchp,nn,
1132        if(ipbl.gt.0) then       . .false., 'Z0      ', 1, 1, bi, bj, myid)
1133        call paste2grd(pbldpth,igrd,chfrstr,istrip,nchp,        endif
1134       1                       qdiag(1,1,ipbl),ijall,1,nn,.false.)        if(diagnostics_is_on('FRQTRB  ',myid) ) then
1135        endif        call diag_vegtile_fill (frqtrb,igrd,chfrstr,istrip,nchp,nn,
1136        if(iu2m.gt.0) then       . .false., 'FRQTRB  ', 0, nlay-1, bi, bj, myid)
1137        call paste2grd(stu2m,igrd,chfrstr,istrip,nchp,        endif
1138       1                     qdiag(1,1,iu2m),ijall,1,nn,.true.)        if(diagnostics_is_on('PBL     ',myid) ) then
1139        endif        call diag_vegtile_fill (pbldpth,igrd,chfrstr,istrip,nchp,nn,
1140        if(iv2m.gt.0) then       . .false., 'PBL     ', 1, 1, bi, bj, myid)
1141        call paste2grd(stv2m,igrd,chfrstr,istrip,nchp,        endif
1142       1                     qdiag(1,1,iv2m),ijall,1,nn,.true.)        if(diagnostics_is_on('U2M     ',myid) ) then
1143        endif        call diag_vegtile_fill (stu2m,igrd,chfrstr,istrip,nchp,nn,
1144        if(it2m.gt.0) then       . .false., 'U2M     ', 1, 1, bi, bj, myid)
1145        call paste2grd(stt2m,igrd,chfrstr,istrip,nchp,        endif
1146       1                     qdiag(1,1,it2m),ijall,1,nn,.true.)        if(diagnostics_is_on('V2M     ',myid) ) then
1147          call diag_vegtile_fill (stv2m,igrd,chfrstr,istrip,nchp,nn,
1148         . .false., 'V2M     ', 1, 1, bi, bj, myid)
1149          endif
1150          if(diagnostics_is_on('T2M     ',myid) ) then
1151          call diag_vegtile_fill (stt2m,igrd,chfrstr,istrip,nchp,nn,
1152         . .false., 'T2M     ', 1, 1, bi, bj, myid)
1153        endif        endif
1154        if(iq2m.gt.0) then        if(diagnostics_is_on('Q2M     ',myid) ) then
1155        do i=1,istrip        do i=1,istrip
1156           if( stq2m(i).ne.undef ) then           if( stq2m(i).ne.undef ) then
1157               tmpstrip(i) = stq2m(i) * 1000               tmpstrip(i) = stq2m(i) * 1000
# Line 1146  c ------------------------------ Line 1159  c ------------------------------
1159               tmpstrip(i) = undef               tmpstrip(i) = undef
1160           endif           endif
1161        enddo        enddo
1162        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
1163       1                     qdiag(1,1,iq2m),ijall,1,nn,.true.)       . .false., 'Q2M     ', 1, 1, bi, bj, myid)
1164        endif        endif
1165        if(iu10m.gt.0) then        if(diagnostics_is_on('U10M    ',myid) ) then
1166        call paste2grd(stu10m,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stu10m,igrd,chfrstr,istrip,nchp,nn,
1167       1                      qdiag(1,1,iu10m),ijall,1,nn,.false.)       . .false., 'U10M    ', 1, 1, bi, bj, myid)
1168        endif        endif
1169        if(iv10m.gt.0) then        if(diagnostics_is_on('V10M    ',myid) ) then
1170        call paste2grd(stv10m,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stv10m,igrd,chfrstr,istrip,nchp,nn,
1171       1                      qdiag(1,1,iv10m),ijall,1,nn,.false.)       . .false., 'V10M    ', 1, 1, bi, bj, myid)
1172        endif        endif
1173        if(it10m.gt.0) then        if(diagnostics_is_on('T10M    ',myid) ) then
1174        call paste2grd(stt10m,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (stt10m,igrd,chfrstr,istrip,nchp,nn,
1175       1                      qdiag(1,1,it10m),ijall,1,nn,.false.)       . .false., 'T10M    ', 1, 1, bi, bj, myid)
1176        endif        endif
1177        if(iq10m.gt.0) then        if(diagnostics_is_on('Q10M    ',myid) ) then
1178        do i=1,istrip        do i=1,istrip
1179           if( stq10m(i).ne.undef ) then           if( stq10m(i).ne.undef ) then
1180               tmpstrip(i) = stq10m(i) * 1000               tmpstrip(i) = stq10m(i) * 1000
# Line 1169  c ------------------------------ Line 1182  c ------------------------------
1182               tmpstrip(i) = undef               tmpstrip(i) = undef
1183           endif           endif
1184        enddo        enddo
1185        call paste2grd(tmpstrip,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (tmpstrip,igrd,chfrstr,istrip,nchp,nn,
1186       1                      qdiag(1,1,iq10m),ijall,1,nn,.false.)       . .false., 'Q10M    ', 1, 1, bi, bj, myid)
1187        endif        endif
1188    
 c Fill 2m and 10m Couplings (Not Re-producible)  
 c ---------------------------------------------  
       call paste2grd (  stu2m,igrd,chfrstr,istrip,nchp, u2m,ijall,1,  
      .                                                      nn,.true. )  
       call paste2grd (  stv2m,igrd,chfrstr,istrip,nchp, v2m,ijall,1,  
      .                                                      nn,.true. )  
       call paste2grd (  stt2m,igrd,chfrstr,istrip,nchp, t2m,ijall,1,  
      .                                                      nn,.true. )  
       call paste2grd (  stq2m,igrd,chfrstr,istrip,nchp, q2m,ijall,1,  
      .                                                      nn,.true. )  
       call paste2grd ( stu10m,igrd,chfrstr,istrip,nchp,u10m,ijall,1,  
      .                                                      nn,.false.)  
       call paste2grd ( stv10m,igrd,chfrstr,istrip,nchp,v10m,ijall,1,  
      .                                                      nn,.false.)  
       call paste2grd ( stt10m,igrd,chfrstr,istrip,nchp,t10m,ijall,1,  
      .                                                      nn,.false.)  
       call paste2grd ( stq10m,igrd,chfrstr,istrip,nchp,q10m,ijall,1,  
      .                                                      nn,.false.)  
   
1189  c**********************************************************************  c**********************************************************************
1190  c   more diagnostics: land surface model parameters  c   more diagnostics: land surface model parameters
1191  c**********************************************************************  c**********************************************************************
1192    
1193        if(itdeep.gt.0)call paste2grd(td,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('TDEEP   ',myid) ) then
1194       .                         qdiag(1,1,itdeep),ijall,1,nn,.false.)        call diag_vegtile_fill (td,igrd,chfrstr,istrip,nchp,nn,
1195        if(iqcanopy .gt.0)call paste2grd(qa,igrd,chfrstr,istrip,nchp,       . .false., 'TDEEP   ', 1, 1, bi, bj, myid)
1196       .                      qdiag(1,1,iqcanopy) ,ijall,1,nn,.false.)        endif
1197        if(ismshal  .gt.0)call paste2grd(swet1,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('QCANOPY ',myid) ) then
1198       .                      qdiag(1,1,ismshal)  ,ijall,1,nn,.false.)        call diag_vegtile_fill (qa,igrd,chfrstr,istrip,nchp,nn,
1199        if(ismroot  .gt.0)call paste2grd(swet2,igrd,chfrstr,istrip,nchp,       . .false., 'QCANOPY ', 1, 1, bi, bj, myid)
1200       .                      qdiag(1,1,ismroot)  ,ijall,1,nn,.false.)        endif
1201        if(ismdeep  .gt.0)call paste2grd(swet3,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('SMSHAL  ',myid) ) then
1202       .                      qdiag(1,1,ismdeep)  ,ijall,1,nn,.false.)        call diag_vegtile_fill (swet1,igrd,chfrstr,istrip,nchp,nn,
1203        if(icapacity.gt.0)call paste2grd(capacity,igrd,chfrstr,istrip,       . .false., 'SMSHAL  ', 1, 1, bi, bj, myid)
1204       .                 nchp,qdiag(1,1,icapacity),ijall,1,nn,.false.)        endif
1205        if(isnow.gt.0)call paste2grd(snowdepth,igrd,chfrstr,istrip,nchp,        if(diagnostics_is_on('SMROOT  ',myid) ) then
1206       .                      qdiag(1,1,isnow)    ,ijall,1,nn,.false.)        call diag_vegtile_fill (swet2,igrd,chfrstr,istrip,nchp,nn,
1207         . .false., 'SMROOT  ', 1, 1, bi, bj, myid)
1208  c**********************************************************************        endif
1209        IF(Iudiag1.GT.0) then        if(diagnostics_is_on('SMDEEP  ',myid) ) then
1210        call paste2grd(checktrb,igrd,chfrstr,istrip,nchp,        call diag_vegtile_fill (swet3,igrd,chfrstr,istrip,nchp,nn,
1211       1                       qdiag(1,1,iudiag1),ijall,nlay,nn,.false.)       . .false., 'SMDEEP  ', 1, 1, bi, bj, myid)
1212          endif
1213          if(diagnostics_is_on('CAPACITY',myid) ) then
1214          call diag_vegtile_fill (capacity,igrd,chfrstr,istrip,nchp,nn,
1215         . .false., 'CAPACITY', 1, 1, bi, bj, myid)
1216          endif
1217          if(diagnostics_is_on('SNOW    ',myid) ) then
1218          call diag_vegtile_fill (snowdepth,igrd,chfrstr,istrip,nchp,nn,
1219         . .false., 'SNOW    ', 1, 1, bi, bj, myid)
1220        endif        endif
   
1221  c**********************************************************************  c**********************************************************************
1222  c end regions loop  c end regions loop
1223    
# Line 1231  c -------------------------------------- Line 1232  c --------------------------------------
1232    
1233  c prevent ice or snow from melting  c prevent ice or snow from melting
1234  c ---------------------------------------------------------------------  c ---------------------------------------------------------------------
1235        do i =1,nchp        do i =1,nchptot
1236        if( (icethk(i).gt.0.).and.(tground(i).gt.tice) ) tground(i)=tice        if( (icethk(i).gt.0.).and.(tground(i).gt.tice) ) tground(i)=tice
1237        enddo        enddo
1238    
# Line 1264  c ----------------------------------- Line 1265  c -----------------------------------
1265  C Return Tendencies and Couplings to Grid Space  C Return Tendencies and Couplings to Grid Space
1266  c ---------------------------------------------  c ---------------------------------------------
1267        do l = 1,nlay        do l = 1,nlay
1268        call msc2grd(igrd,chfr,dumsc(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr,dumsc(1,L),nchp,nchptot,fracland,
1269       .                                              duturb(1,1,L),im,jm)       .                                              duturb(1,1,L),im,jm)
1270        call msc2grd(igrd,chfr,dvmsc(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr,dvmsc(1,L),nchp,nchptot,fracland,
1271       .                                              dvturb(1,1,L),im,jm)       .                                              dvturb(1,1,L),im,jm)
1272        call msc2grd(igrd,chfr,dtmsc(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr,dtmsc(1,L),nchp,nchptot,fracland,
1273       .                                              dtturb(1,1,L),im,jm)       .                                              dtturb(1,1,L),im,jm)
1274        do nt = 1,ntracers        do nt = 1,ntracers
1275        call msc2grd(igrd,chfr,dqmsc(1,L,nt),nchp,nchp,fracland,        call msc2grd(igrd,chfr,dqmsc(1,L,nt),nchp,nchptot,fracland,
1276       .                                           dqturb(1,1,L,nt),im,jm)       .                                           dqturb(1,1,L,nt),im,jm)
1277        enddo        enddo
1278        call msc2grd(igrd,chfr,  tke(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr,  tke(1,L),nchp,nchptot,fracland,
1279       .                                              qqgrid(1,1,L),im,jm)       .                                              qqgrid(1,1,L),im,jm)
1280    
1281        call msc2grd(igrd,chfr, fccmsc(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr, fccmsc(1,L),nchp,nchptot,fracland,
1282       .                                              fcctmp(1,1,L),im,jm)       .                                              fcctmp(1,1,L),im,jm)
1283        call msc2grd(igrd,chfr,qliqmsc(1,L),nchp,nchp,fracland,        call msc2grd(igrd,chfr,qliqmsc(1,L),nchp,nchptot,fracland,
1284       .                                             qliqtmp(1,1,L),im,jm)       .                                             qliqtmp(1,1,L),im,jm)
1285        enddo        enddo
1286    
# Line 1299  c -------------------------------------- Line 1300  c --------------------------------------
1300         enddo         enddo
1301         enddo         enddo
1302    
1303         if (itrbfcc.gt.0) then         if(diagnostics_is_on('TRBFCC  ',myid) ) then
1304         do j=1,jm          call diagnostics_fill(fcctmp(i,j,L),'TRBFCC  ',L,1,3,bi,bj,myid)
        do i=1,im  
        qdiag(i,j,itrbfcc+L-1) =  qdiag(i,j,itrbfcc+L-1) + fcctmp(i,j,L)  
        enddo  
        enddo  
1305         endif         endif
1306           if(diagnostics_is_on('TRBQLIQ ',myid) ) then
1307         if (itrbqliq.gt.0) then          do j = 1,jm
1308         do j=1,jm          do i = 1,im
1309         do i=1,im           tmpdiag(i,j) = qliqtmp(i,j,L)*1.e6
1310         qdiag(i,j,itrbqliq+L-1)=qdiag(i,j,itrbqliq+L-1)+          enddo
1311       .                                             qliqtmp(i,j,L)*1.e6          enddo
1312         enddo          call diagnostics_fill(tmpdiag,'TRBQLIQ ',L,1,3,bi,bj,myid)
        enddo  
1313         endif         endif
1314        enddo        enddo
   
1315  C**********************************************************************  C**********************************************************************
1316  C And some other variables to be transformed back to grid space:  C And some other variables to be transformed back to grid space:
1317  C Ground Temperature, snow depth and shallow layer ground wetness  C Ground Temperature, snow depth and shallow layer ground wetness
1318        do j = 1,jm        do j = 1,jm
1319         do i = 1,im         do i = 1,im
1320           tgz(i,j) = 0.           tgz(i,j) = 0.
         snow(i,j) = 0.  
         gwet(i,j) = 0.  
1321         enddo         enddo
1322        enddo        enddo
1323        call msc2grd(igrd,chfr,tground ,nchp,nchp,fracland,tgz ,im,jm)        call msc2grd(igrd,chfr,tground ,nchp,nchptot,fracland,tgz ,im,jm)
       call msc2grd(igrd,chfr,snodep  ,nchp,nchp,fracland,snow,im,jm)  
       call msc2grd(igrd,chfr,swetshal,nchp,nchp,fracland,gwet,im,jm)  
1324    
1325  c *********************************************************************  c *********************************************************************
1326  c **** increment diagnostic array for ground and surface temperatures,  c **** increment diagnostic array for ground and surface temperatures,
1327  c ***       ground temp tendency, and ground humidity  c ***       ground temp tendency, and ground humidity
1328  c *********************************************************************  c *********************************************************************
1329    
1330        if(itground.gt.0) then        if(diagnostics_is_on('TGROUND ',myid) ) then
1331        do i =1,ijall         call diagnostics_fill(tgz,'TGROUND ',0,1,3,bi,bj,myid)
       qdiag(i,1,itground) = qdiag(i,1,itground) + tgz(i,1)  
       enddo  
1332        endif        endif
1333          if(diagnostics_is_on('TCANOPY ',myid) ) then
1334        if(itcanopy.gt.0) then         call diagnostics_fill(tgz,'TCANOPY ',0,1,3,bi,bj,myid)
       do i =1,ijall  
       qdiag(i,1,itcanopy) = qdiag(i,1,itcanopy) + tgz(i,1)  
       enddo  
1335        endif        endif
1336    
1337        if(its.gt.0) then        if(diagnostics_is_on('TS      ',myid) ) then
1338        do i =1,ijall         do j =1,jm
1339        tmpstrip(i) = tz(i,1,nlay) * pkht(i,1,nlay)         do i =1,im
1340        enddo          tmpdiag(i,j) = tz(i,j,nlay) * pkht(i,j,nlay)
1341        do i =1,ijall         enddo
1342        qdiag(i,1,its) = qdiag(i,1,its) + tmpstrip(i)         enddo
1343        enddo         call diagnostics_fill(tmpdiag,'TS      ',0,1,3,bi,bj,myid)
1344        endif        endif
1345    
1346        if(idtg.gt.0) then        if(idtg.gt.0) then
1347        do i =1,ijall        do j =1,jm
1348        qdiag(i,1,idtg) = qdiag(i,1,idtg) + tgz(i,1)        do i =1,im
1349          qdiag(i,j,idtg,bi,bj) = qdiag(i,j,idtg,bi,bj) + tgz(i,j)
1350          enddo
1351        enddo        enddo
1352        endif        endif
1353    
# Line 1368  c ****           increment diagnostic ar Line 1356  c ****           increment diagnostic ar
1356  c *********************************************************************  c *********************************************************************
1357        do L = 1,nlay        do L = 1,nlay
1358    
1359         if(iturbu.gt.0) then         if(diagnostics_is_on('TURBV   ',myid) ) then
1360         do i =1,ijall          do j = 1,jm
1361          qdiag(i,1,iturbu+l-1) =  qdiag(i,1,iturbu+l-1)          do i = 1,im
1362       .                      + duturb(i,1,l) * atimstp * secday           tmpdiag(i,j) = dvturb(i,j,l) * atimstp * secday
1363         enddo          enddo
1364            enddo
1365            call diagnostics_fill(tmpdiag,'TURBV   ',L,1,3,bi,bj,myid)
1366         endif         endif
1367    
1368         if(iturbv.gt.0) then         if(diagnostics_is_on('TURBU   ',myid) ) then
1369         do i =1,ijall          do j = 1,jm
1370          qdiag(i,1,iturbv+l-1) =  qdiag(i,1,iturbv+l-1)          do i = 1,im
1371       .                      + dvturb(i,1,l) * atimstp * secday           tmpdiag(i,j) = duturb(i,j,l) * atimstp * secday
1372         enddo          enddo
1373            enddo
1374            call diagnostics_fill(tmpdiag,'TURBU   ',L,1,3,bi,bj,myid)
1375         endif         endif
1376    
1377         if(iturbq.gt.0) then         if(diagnostics_is_on('TURBQ   ',myid) ) then
1378         do i =1,ijall          do j = 1,jm
1379          qdiag(i,1,iturbq+l-1) =  qdiag(i,1,iturbq+l-1)          do i = 1,im
1380       .                      + dqturb(i,1,l,1) * atimstp * secday * 1000           tmpdiag(i,j) = dqturb(i,j,l,1) * atimstp * secday * 1000.
1381         enddo          enddo
1382            enddo
1383            call diagnostics_fill(tmpdiag,'TURBQ   ',L,1,3,bi,bj,myid)
1384         endif         endif
1385    
1386         if(iturbt.gt.0) then         if(diagnostics_is_on('TURBT   ',myid) ) then
1387         do i =1,ijall          do j = 1,jm
1388          qdiag(i,1,iturbt+l-1) =  qdiag(i,1,iturbt+l-1)          do i = 1,im
1389       .                   + dtturb(i,1,l) * pkz(i,1,l)*atimstp*secday           tmpdiag(i,j) = dtturb(i,j,l) * pkz(i,j,l)*atimstp*secday
1390         enddo          enddo
1391            enddo
1392            call diagnostics_fill(tmpdiag,'TURBT   ',L,1,3,bi,bj,myid)
1393         endif         endif
1394    
1395        enddo        enddo
# Line 1434  c ************************************** Line 1430  c **************************************
1430  c ****                bump diagnostic counters                      ***  c ****                bump diagnostic counters                      ***
1431  c *********************************************************************  c *********************************************************************
1432    
1433    #ifdef ALLOW_DIAGNOSTICS
1434          if( (bi.eq.1) .and. (bj.eq.1) ) then
1435        nturbt    = nturbt    + 1        nturbt    = nturbt    + 1
1436        nturbq    = nturbq    + 1        nturbq    = nturbq    + 1
1437        nturbu    = nturbu    + 1        nturbu    = nturbu    + 1
1438        nturbv    = nturbv    + 1        nturbv    = nturbv    + 1
       ntuflux   = ntuflux   + 1  
       ntvflux   = ntvflux   + 1  
       nttflux   = nttflux   + 1  
       ntqflux   = ntqflux   + 1  
       nwinds    = nwinds    + 1  
       nkm       = nkm       + 1  
       nkh       = nkh       + 1  
       nri       = nri       + 1  
       nct       = nct       + 1  
       ncu       = ncu       + 1  
       ntground  = ntground  + 1  
       nts       = nts       + 1  
1439        ndtg      = ndtg      + 1        ndtg      = ndtg      + 1
1440        nqg       = nqg       + 1        endif
1441        nqs       = nqs       + 1  #endif
       nhflux    = nhflux    + 1  
       neflux    = neflux    + 1  
       nevap     = nevap     + 1  
       nuflux    = nuflux    + 1  
       nvflux    = nvflux    + 1  
       ndtsrf    = ndtsrf    + 1  
       nustar    = nustar    + 1  
       nz0       = nz0       + 1  
       nfrqtrb   = nfrqtrb   + 1  
       npbl      = npbl      + 1  
       nu2m      = nu2m      + 1  
       nv2m      = nv2m      + 1  
       nt2m      = nt2m      + 1  
       nq2m      = nq2m      + 1  
       nu10m     = nu10m     + 1  
       nv10m     = nv10m     + 1  
       nt10m     = nt10m     + 1  
       nq10m     = nq10m     + 1  
       ntcanopy  = ntcanopy  + 1  
       ntdeep    = ntdeep    + 1  
       nqcanopy  = nqcanopy  + 1  
       nsmshal   = nsmshal   + 1  
       nsmroot   = nsmroot   + 1  
       nsmdeep   = nsmdeep   + 1  
       nsnow     = nsnow     + 1  
       ncapacity = ncapacity + 1  
       nraincon  = nraincon  + 1  
       nrainlsp  = nrainlsp  + 1  
       nsnowfall = nsnowfall + 1  
       nrunoff   = nrunoff   + 1  
       nfwsoil   = nfwsoil   + 1  
       ngdrain   = ngdrain   + 1  
       nsnowmelt = nsnowmelt + 1  
       neresv    = neresv    + 1  
       nesoil    = nesoil    + 1  
       neveg     = neveg     + 1  
       nesnow    = nesnow    + 1  
       npardf    = npardf    + 1  
       npardr    = npardr    + 1  
       nlai      = nlai      + 1  
       ngreen    = ngreen    + 1  
       ndlwdtc   = ndlwdtc   + 1  
       ndhdtc    = ndhdtc    + 1  
       ndedtc    = ndedtc    + 1  
       nevpot    = nevpot    + 1  
       nlwgdown  = nlwgdown  + 1  
       ndhdqa    = ndhdqa    + 1  
       ndedqa    = ndedqa    + 1  
       ndtc      = ndtc      + 1  
       ndqc      = ndqc      + 1  
       ntcdtc    = ntcdtc    + 1  
       nraddtc   = nraddtc   + 1  
       nsensdtc  = nsensdtc  + 1  
       nlatdtc   = nlatdtc   + 1  
       ntddtc    = ntddtc    + 1  
       nqcdtc    = nqcdtc    + 1  
       ntrbqliq  = ntrbqliq  + 1  
       ntrbfcc   = ntrbfcc   + 1  
1442    
1443        return        return
1444        end        end
# Line 1547  C    Z0            -         SURFACE ROU Line 1475  C    Z0            -         SURFACE ROU
1475  C    tracers       -         array of passive tracers  C    tracers       -         array of passive tracers
1476  C    ntrace        -         number of tracers to be diffused  C    ntrace        -         number of tracers to be diffused
1477  C    ntracedim     -         outer dimension of tracers array  C    ntracedim     -         outer dimension of tracers array
1478  C    DTAU          -         TIME CHANGE PER ITERATION OF TRBLFX  C    DTAU          -         TIME CHANGE PER ITERATION OF TRBFLX
1479  C    ITRTRB        -         NUMBER OF ITERATIONS OF TRBLFX  C    ITRTRB        -         NUMBER OF ITERATIONS OF TRBFLX
1480  C    KMBG          -         BACKGROUND VALUE OF MOMENTUM TRANSFER COEF  C    KMBG          -         BACKGROUND VALUE OF MOMENTUM TRANSFER COEF
1481  C    KHBG          -         BACKGROUND VALUE OF HEAT TRANSFER COEF  C    KHBG          -         BACKGROUND VALUE OF HEAT TRANSFER COEF
1482  C    NLEV          -         NUMBER OF ATMOSPHERIC LEVELS TO CALCULATE  C    NLEV          -         NUMBER OF ATMOSPHERIC LEVELS TO CALCULATE
# Line 1560  C     ------- Line 1488  C     -------
1488  C    PROFILES RETURNED WITH UPDATED VALUES  C    PROFILES RETURNED WITH UPDATED VALUES
1489  C  C
1490  C**********************************************************************  C**********************************************************************
1491  C        implicit none
1492  C  
1493    C Argument list declarations
1494          integer nn,irun,nlev,ntrace,ntracedim,itrtrb,nhms,nymd
1495          _RL TH(irun,NLEV+1),THV(irun,NLEV+1),SH(irun,NLEV+1)
1496          _RL U(irun,NLEV+1),V(irun,NLEV+1),QQ(irun,NLEV)
1497          _RL PL(irun,NLEV),PLE(irun,NLEV+1),PLK(irun,NLEV)
1498          _RL PLKE(irun,NLEV+1),DPSTR(irun,NLEV)
1499          integer IWATER(irun)
1500          _RL Z0(irun)
1501          _RL tracers(irun,nlev+1,ntracedim)
1502          _RL dtau,KMBG,KHBG
1503          LOGICAL QBEG,TPROF
1504          _RL SWINDS(irun)
1505          _RL SRI(irun,nlev), ET(irun,nlev)
1506          _RL EU (irun,nlev)
1507          _RL WU(irun,nlev)
1508          _RL WV (irun,nlev), pbldpth(irun)
1509          _RL sustar(irun), sz0(irun)
1510          _RL freqdg(irun,nlev-1)
1511          _RL sct(irun), scu(irun)
1512          _RL stu2m(irun),stv2m(irun),stt2m(irun),stq2m(irun)
1513          _RL stu10m(irun),stv10m(irun),stt10m(irun),stq10m(irun)
1514          _RL grav,cp,rgas,faceps,virtcon,undef
1515          _RL eturb(irun),dedqa(irun),dedtc(irun)
1516          _RL hsturb(irun),dhsdqa(irun),dhsdtc(irun)
1517          _RL dshdthg(irun,nlev),dthdthg(irun,nlev)
1518          _RL dshdshg(irun,nlev),dthdshg(irun,nlev)
1519          _RL transth(irun,nlev),transsh(irun,nlev)
1520          _RL ctsave(irun),xxsave(irun),yysave(irun)
1521          _RL zetasave(irun),xlsave(irun,nlev),khsave(irun,nlev)
1522          _RL qliq(irun,nlev),turbfcc(irun,nlev)
1523    
1524    C Local Variables
1525          _RL b1,b3,alpha,halpha,qqmin,qbustr
1526        PARAMETER ( B1      =   16.6    )          PARAMETER ( B1      =   16.6    )  
1527        PARAMETER ( B3      = 1. / B1  )          PARAMETER ( B3      = 1. / B1  )  
1528        PARAMETER ( ALPHA   = 0.1       )        PARAMETER ( ALPHA   = 0.1       )
1529        PARAMETER ( HALPHA = ALPHA * 0.5 )        PARAMETER ( HALPHA = ALPHA * 0.5 )
1530        PARAMETER ( QQMIN  = 0.005      )        PARAMETER ( QQMIN  = 0.005      )
1531        PARAMETER ( QBUSTR = 2.550952   )        PARAMETER ( QBUSTR = 2.550952   )
1532        real    argmax, onethrd, z1pem25, b2        _RL    argmax, onethrd, z1pem25, b2, two
1533        PARAMETER (ARGMAX = 30.)        PARAMETER (ARGMAX = 30.)
1534        PARAMETER (ONETHRD = 1./3. )        PARAMETER (ONETHRD = 1./3. )
1535        PARAMETER (Z1PEM25 = 1.E-25)        PARAMETER (Z1PEM25 = 1.E-25)
1536        PARAMETER ( B2    =  10.1 )        PARAMETER ( B2    =  10.1 )
1537        PARAMETER ( two   =   2.0 )        PARAMETER ( two   =   2.0 )
1538    
1539        DIMENSION TH(irun,NLEV+1),THV(irun,NLEV+1),SH(irun,NLEV+1)        _RL AHS (irun), HS(irun)
1540        DIMENSION U(irun,NLEV+1),V(irun,NLEV+1),QQ(irun,NLEV)        _RL XX  (irun), YY(irun), CU(irun)
1541        DIMENSION PL(irun,NLEV),PLE(irun,NLEV+1),PLK(irun,NLEV)        _RL CT(irun),  USTAR(irun)
1542        DIMENSION PLKE(irun,NLEV+1),DPSTR(irun,NLEV)        _RL RIB(irun),   ZETA(irun), WS(irun)
1543        DIMENSION IWATER(irun),Z0(irun)        _RL DTHS(irun), DELTHS(irun)
1544        real tracers(irun,nlev+1,ntracedim)        _RL DTHL(irun), DELTHL(irun)
1545        real KMBG,KHBG        _RL RIBIN(irun),CUIN(irun)
1546        LOGICAL QBEG,TPROF        _RL CTIN(irun),ZETAIN(irun)
1547        real eturb(irun),dedqa(irun),dedtc(irun)        _RL USTARIN(irun),RHOSIN(irun),Z0IN(irun)
1548        real hsturb(irun),dhsdqa(irun),dhsdtc(irun)        _RL qqcolmin(irun),qqcolmax(irun),levpbl(irun)
1549        real dshdthg(irun,nlev),dthdthg(irun,nlev)  
1550        real dshdshg(irun,nlev),dthdshg(irun,nlev)        _RL ADZ1(irun,nlev), DZ1TMP(irun,nlev)
1551        real transth(irun,nlev),transsh(irun,nlev)        _RL DZ3(irun,nlev), TEMP(irun,nlev)
1552        real ctsave(irun),xxsave(irun),yysave(irun)        _RL DV(irun,nlev), DTHV(irun,nlev)
1553        real zetasave(irun),xlsave(irun,nlev),khsave(irun,nlev)        _RL DPK(irun,nlev), STRT(irun,nlev)
1554        real qliq(irun,nlev),turbfcc(irun,nlev)        _RL DW2(irun,nlev), RI(irun,nlev)
1555          _RL RHOZPK(irun,nlev), Q(irun,nlev)
1556  C Diagnostic Variables        _RL RIINIT(irun,nlev), DU(irun,nlev)
1557  C --------------------        _RL QQINIT(irun,nlev), RHOKDZ(irun,nlev)
1558        DIMENSION SWINDS(irun)        _RL RHODZ2(irun,nlev)
1559        DIMENSION    SRI(irun,nlev), ET(irun,nlev)        _RL KM(irun,nlev), KH(irun,nlev)
1560        DIMENSION    EU (irun,nlev)  
1561        DIMENSION    WU(irun,nlev)        _RL DELTH  (irun,nlev+1), DELSH (irun,nlev+1)
1562        DIMENSION    WV (irun,nlev), pbldpth(irun)        _RL FLXFAC (irun,nlev+1)
1563        DIMENSION sustar(irun),          sz0(irun)        _RL FLXFPK (irun,nlev+1)
1564        DIMENSION    sct(irun),          scu(irun)  
1565        dimension stu2m(irun),stv2m(irun),stt2m(irun),stq2m(irun)        _RL ADZ2   (irun,nlev-1), RHODZ1(irun,nlev-1)
1566        dimension stu10m(irun),stv10m(irun),        _RL VKZE   (irun,nlev-1), VKZM  (irun,nlev-1)
1567       1                              stt10m(irun),stq10m(irun)        _RL XL     (irun,nlev-1), QXLM  (irun,nlev-1)
1568        DIMENSION freqdg(irun,nlev-1)        _RL QQE    (irun,nlev-1), QE    (irun,nlev-1)
1569          _RL P3     (irun,nlev-1), XQ    (irun,nlev-1)
1570  C Dynamic Variables        _RL XLDIAG (irun,nlev-1), FLXFCE(irun,nlev-1)
 C -----------------  
       DIMENSION AHS (irun), HS(irun)  
       DIMENSION XX  (irun), YY(irun), CU(irun)  
       DIMENSION CT     (irun),  USTAR(irun)  
       DIMENSION RIB    (irun),   ZETA(irun), WS(irun)  
       DIMENSION DTHS   (irun), DELTHS(irun)  
       DIMENSION DTHL   (irun), DELTHL(irun)  
       DIMENSION TG     (irun)  
       DIMENSION RIBIN  (irun),   CUIN(irun)  
       DIMENSION CTIN   (irun), ZETAIN(irun)  
       DIMENSION USTARIN(irun), RHOSIN(irun), Z0IN(irun)  
       DIMENSION    TMP1(irun),   TMP2(irun)  
       DIMENSION    TMP3(irun),  ITMP1(irun)  
       DIMENSION   ITMP2(irun)  
       dimension qqcolmin(irun),qqcolmax(irun),levpbl(irun)  
   
 C Dynamic Variables  
 C -----------------  
       DIMENSION ADZ1   (irun,nlev  ), DZ1TMP(irun,nlev)  
       DIMENSION DZ3    (irun,nlev  ), TEMP  (irun,nlev)  
       DIMENSION DV     (irun,nlev  ), DTHV  (irun,nlev)  
       DIMENSION DPK    (irun,nlev  ), STRT  (irun,nlev)  
       DIMENSION DW2    (irun,nlev  ), RI    (irun,nlev)  
       DIMENSION RHOZPK (irun,nlev  ), Q     (irun,nlev)  
       DIMENSION RIINIT (irun,nlev  ), DU    (irun,nlev)  
       DIMENSION QQINIT (irun,nlev  ), RHOKDZ(irun,nlev)  
       DIMENSION RHODZ2 (irun,nlev  )  
       REAL      KM     (irun,nlev  ),     KH(irun,nlev)  
   
 C Dynamic Variables  
 C -----------------  
       DIMENSION DELTH  (irun,nlev+1), DELSH (irun,nlev+1)  
       DIMENSION FLXFAC (irun,nlev+1), DTHG  (irun,nlev+1)  
       DIMENSION FLXFPK (irun,nlev+1)  
   
 C Dynamic Variables  
 C -----------------  
       DIMENSION ADZ2   (irun,nlev-1), RHODZ1(irun,nlev-1)  
       DIMENSION VKZE   (irun,nlev-1), VKZM  (irun,nlev-1)  
       DIMENSION XL     (irun,nlev-1), QXLM  (irun,nlev-1)  
       DIMENSION QQE    (irun,nlev-1), QE    (irun,nlev-1)  
       DIMENSION P3     (irun,nlev-1), XQ    (irun,nlev-1)  
       DIMENSION XLDIAG (irun,nlev-1), FLXFCE(irun,nlev-1)  
1571    
1572        LOGICAL FIRST,LAST        LOGICAL FIRST,LAST
1573        DIMENSION IBITSTB(irun,nlev),IBITSTR(irun),INTQ(irun,nlev)        integer IBITSTB(irun,nlev),INTQ(irun,nlev)
1574    
1575  C arrays for use by moist bouyancy calculation  C arrays for use by moist bouyancy calculation
1576  C -----------------  C -----------------
1577        real TL(irun,NLEV),DTH(irun,NLEV)        _RL TL(irun,NLEV),DTH(irun,NLEV)
1578        real DSH(irun,NLEV)        _RL DSH(irun,NLEV)
1579        real SHL(irun,NLEV)        _RL SHL(irun,NLEV)
1580        real AA(irun,NLEV),BB(irun,NLEV),SSDEV(irun,NLEV)        _RL AA(irun,NLEV),BB(irun,NLEV),SSDEV(irun,NLEV)
1581        real ARG(irun,NLEV),XXZETA(irun),QBYU(irun)        _RL ARG(irun,NLEV),XXZETA(irun),QBYU(irun)
1582        real SVAR(irun,NLEV),Q1M(irun,NLEV)        _RL SVAR(irun,NLEV),Q1M(irun,NLEV)
1583        real FCC(irun,NLEV)        _RL FCC(irun,NLEV)
1584        real BETAT(irun,NLEV),BETAW(irun,NLEV)        _RL BETAT(irun,NLEV),BETAW(irun,NLEV)
1585        real BETAL(irun,NLEV),BETAT1(irun,NLEV)        _RL BETAL(irun,NLEV),BETAT1(irun,NLEV)
1586        real BETAW1(irun,NLEV),SBAR(irun,NLEV)        _RL BETAW1(irun,NLEV),SBAR(irun,NLEV)
1587        real SHSAT(irun,NLEV)        _RL SHSAT(irun,NLEV)
       real TEMPOR(irun,NLEV)  
1588    
1589  C Some space for variables to be used in called routines  C Some space for variables to be used in called routines
1590        logical LWATER        logical LWATER
1591        integer IVBITRIB(irun)        integer IVBITRIB(irun)
1592        DIMENSION VHZ(irun)        _RL VHZ(irun)
1593        DIMENSION VH0(irun)        _RL VH0(irun)
1594        DIMENSION VPSIM(irun),VAPSIM(irun)        _RL VPSIM(irun),VAPSIM(irun)
1595        DIMENSION VPSIG(irun),VPSIHG(irun)        _RL VPSIG(irun),VPSIHG(irun)
1596        DIMENSION VTEMP(irun),VDZETA(irun)        _RL VTEMP(irun),VDZETA(irun)
1597        DIMENSION VDZ0(irun),VDPSIM(irun)        _RL VDZ0(irun),VDPSIM(irun)
1598        DIMENSION VDPSIH(irun),VZH(irun)        _RL VDPSIH(irun),VZH(irun)
1599        DIMENSION VXX0(irun),VYY0(irun)        _RL VXX0(irun),VYY0(irun)
1600        DIMENSION VAPSIHG(irun),VRIB1(irun),VWS1(irun)        _RL VAPSIHG(irun),VRIB1(irun),VWS1(irun)
1601        DIMENSION VPSIH(irun),VZETAL(irun)        _RL VPSIH(irun),VZETAL(irun)
1602        DIMENSION VZ0L(irun),VPSIH2(irun)        _RL VZ0L(irun),VPSIH2(irun)
1603        DIMENSION VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)        _RL VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)
1604        DIMENSION VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)        _RL VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)
1605        DIMENSION VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)        _RL VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)
1606        DIMENSION VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)        _RL VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)
1607        DIMENSION VXNUM(irun),VDZETA1(irun),VDZETA2(irun)        _RL VXNUM(irun),VDZETA1(irun),VDZETA2(irun)
1608        DIMENSION VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)        _RL VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)
1609        DIMENSION VDPSIMC(irun),VDPSIHC(irun)        _RL VDPSIMC(irun),VDPSIHC(irun)
1610        integer types(irun)  
1611        character*40 name        _RL DZITRP(irun,nlev-1),STBFCN(irun,nlev)
1612          _RL XL0(irun,nlev),Q1(irun,nlev-1)
1613        DIMENSION DZITRP(irun,nlev-1), STBFCN(irun,nlev)        _RL WRKIT1(irun,nlev-1)
1614        DIMENSION    XL0(irun,nlev),       Q1(irun,nlev-1)        _RL WRKIT2(irun,nlev-1)
1615        DIMENSION WRKIT1(irun,nlev-1)        _RL WRKIT3(irun,nlev-1)
1616        DIMENSION WRKIT2(irun,nlev-1)        _RL WRKIT4(irun,nlev-1)
       DIMENSION WRKIT3(irun,nlev-1)  
       DIMENSION WRKIT4(irun,nlev-1)  
1617        INTEGER INT1(irun,nlev), INT2(irun,nlev-1)        INTEGER INT1(irun,nlev), INT2(irun,nlev-1)
1618    
1619        real vrt1con,pi,rsq2pi,p5sr,clh        _RL vrt1con,pi,rsq2pi,p5sr,clh,vk,rvk,aitr,gbycp,fac1,fac2
1620        integer nt        _RL getcon,dum,errf
1621          integer istnlv,nlevm1,nlevm2,nlevml,nlevp1,istnm1,istnm2,istnp1
1622          integer istnml,istnmq,istlmq,nlevmq
1623          integer i,iter,init,n,nt,LL,L,Lp,Lp1,lmin,lminq,lminq1,ibit
1624    
1625        vk = getcon('VON KARMAN')        vk = getcon('VON KARMAN')
1626        rvk = 1./vk        rvk = 1./vk
# Line 1722  C Some space for variables to be used in Line 1640  C Some space for variables to be used in
1640        P5SR = 0.5**0.5        P5SR = 0.5**0.5
1641        CLH = GETCON('LATENT HEAT COND') / CP        CLH = GETCON('LATENT HEAT COND') / CP
1642    
 C CALL POINT BY POINT DIAGNOSTIC ROUTINE FOR 'BEFORE' VALUES  
 C ----------------------------------------------------------  
       IF(TPROF) THEN  
       do i = 1,irun  
        types(i) = 1  
       enddo  
       name = 'mid pressure'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,pl)  
       name = 'edge pressure'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,ple)  
       name = 'mid p ** kappa'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,plke)  
       name = 'edge p ** kappa'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,plke)  
       name = 'theta before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,th)  
       name = 'theta virtual before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,thv)  
       name = 'q before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,sh)  
       name = 'u wind before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,u)  
       name = 'v wind before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,V)  
       name = 'heat cap ground'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,hcapg)  
       name = 'latent heat at ground'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,clhg)  
       name = 'net surface rad'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,radflx)  
       name = 'background heat transfer'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,khbg)  
       ENDIF  
1643  C SET INITIAL NUMBER OF ITERATIONS OF SFCFLX  C SET INITIAL NUMBER OF ITERATIONS OF SFCFLX
1644  C ------------------------------------------  C ------------------------------------------
1645        N = 6        N = 6
# Line 2314  C ---------------------------------- Line 2199  C ----------------------------------
2199       1      * QXLM(I,LMINQ1)       1      * QXLM(I,LMINQ1)
2200  9306  CONTINUE  9306  CONTINUE
2201         CALL TRBDIF(QQ(1,LMINQ1),P3(1,LMINQ1),RHOKDZ(1,LMINQ1),         CALL TRBDIF(QQ(1,LMINQ1),P3(1,LMINQ1),RHOKDZ(1,LMINQ1),
2202       1       FLXFCE(1,LMINQ1),DTHS,DELTHS,NLEVMQ,1,1.0E-20,irun)       1       FLXFCE(1,LMINQ1),DTHS,DELTHS,NLEVMQ,1,1.0 _d -20,irun)
2203  C  C
2204  C SAVE KH BEFORE ADDING DIMENSIONS FOR USE BY MOIST BOUYANCY CALCULATION  C SAVE KH BEFORE ADDING DIMENSIONS FOR USE BY MOIST BOUYANCY CALCULATION
2205  C  C
# Line 2355  C Line 2240  C
2240        DO 9132 I =1,irun        DO 9132 I =1,irun
2241        DELTH(I,NLEVP1) = 1.        DELTH(I,NLEVP1) = 1.
2242  9132  CONTINUE  9132  CONTINUE
2243         CALL TRBDIF(TH,DELTH,TEMP,FLXFPK,DTHS,DELTHS,NLEV,2,0.,irun)         CALL TRBDIF(TH,DELTH,TEMP,FLXFPK,DTHS,DELTHS,NLEV,2,0. _d 0,irun)
2244        do i = 1,irun        do i = 1,irun
2245         hsturb(i) = -1.* dths(i)         hsturb(i) = -1.* dths(i)
2246         dhsdtc(i) = -1.* delths(i)         dhsdtc(i) = -1.* delths(i)
# Line 2381  C Line 2266  C
2266        DELSH(I,NLEVP1) = 1.        DELSH(I,NLEVP1) = 1.
2267  9140  CONTINUE  9140  CONTINUE
2268    
2269         CALL TRBDIF(SH,DELSH,RHOKDZ,FLXFAC,DTHL,DELTHL,NLEV,2,0.,irun)         CALL TRBDIF(SH,DELSH,RHOKDZ,FLXFAC,DTHL,DELTHL,NLEV,
2270         .                                     2,0. _d 0,irun)
2271        do i = 1,irun        do i = 1,irun
2272         eturb(i) = -1.* dthl(i)         eturb(i) = -1.* dthl(i)
2273         dedqa(i) = -1.* delthl(i)         dedqa(i) = -1.* delthl(i)
# Line 2404  C Line 2290  C
2290        rhokdz(i,nlev) = 0.0              rhokdz(i,nlev) = 0.0      
2291        enddo        enddo
2292    
2293        do nt = 1,ntrace  c     do nt = 1,ntrace
2294        do  i = 1,irun  c     do  i = 1,irun
2295        tracers(i,nlev+1,nt) = tracers(i,nlev,nt)  c     tracers(i,nlev+1,nt) = tracers(i,nlev,nt)
2296        enddo  c     enddo
2297        CALL TRBDIF(tracers(1,1,nt),DELSH,RHOKDZ,FLXFAC,DTHL,DELTHL,  c     CALL TRBDIF(tracers(1,1,nt),DELSH,RHOKDZ,FLXFAC,DTHL,DELTHL,
2298       .                                                  NLEV,4,0.,irun)  c    .                                         NLEV,4,0. _d 0,irun)
2299        enddo  c     enddo
2300  C  C
2301  C   CALCULATE INTERNAL FLUXES AND UPDATE PROGNOSTIC VARIABLES: U AND V  C   CALCULATE INTERNAL FLUXES AND UPDATE PROGNOSTIC VARIABLES: U AND V
2302  C  C
2303        DO 9172 I =1,ISTNLV        DO 9172 I =1,ISTNLV
2304        RHOKDZ(I,1) = RHODZ2(I,1) * KM(I,1)        RHOKDZ(I,1) = RHODZ2(I,1) * KM(I,1)
2305  9172  CONTINUE  9172  CONTINUE
2306         CALL TRBDIF(U,V,RHOKDZ,FLXFAC,DTHS,DELTHS,NLEV,3,0.,irun)         CALL TRBDIF(U,V,RHOKDZ,FLXFAC,DTHS,DELTHS,NLEV,3,0. _d 0,irun)
2307  C ( FILL DIAGNOSTIC ARRAYS IF REQUIRED )  C ( FILL DIAGNOSTIC ARRAYS IF REQUIRED )
2308        DO 9174 I =1,ISTNLV        DO 9174 I =1,ISTNLV
2309        WU(I,1) = WU(I,1) + RHOKDZ(I,1) * ( U(I,2) - U(I,1) )        WU(I,1) = WU(I,1) + RHOKDZ(I,1) * ( U(I,2) - U(I,1) )
# Line 2514  C Line 2400  C
2400         WV(I,1) =  WV(I,1) * AITR         WV(I,1) =  WV(I,1) * AITR
2401  9194  CONTINUE  9194  CONTINUE
2402  C  C
 C  IF TPROF, CALL POINT BY POINT DIAGNOSTIC ROUTINE FOR 'AFTER' VALUES  
 C  
        IF(TPROF)THEN  
       name = 'tke before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,qqinit)  
       name = 'richardson number before'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,riinit)  
       name = 'theta after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,th)  
       name = 'theta virtual after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,thv)  
       name = 'q after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev+1,name,sh)  
       name = 'u wind after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,u)  
       name = 'v wind after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,V)  
       name = 'tke after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,qq)  
       name = 'richardson number after'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,ri)  
       name = 'trb u flux'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,wu)  
       name = 'trb v flux'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,wv)  
       name = 'trb t flux'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,wt)  
       name = 'trb q flux'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,wsh)  
       name = 'eddy coef mom'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,eu)  
       name = 'eddy coef heat'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,et)  
       name = 'length scale'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,xldiag)  
       name = 'layer heights'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,nlev,name,dz1tmp)  
       name = 'q ground'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,shg)  
       name = 'rib initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,ribin)  
       name = 'cu initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,cuin)  
       name = 'ct initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,ctin)  
       name = 'ustar initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,ustarin)  
       name = 'rho sfc initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,rhosin)  
       name = 'z0 initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,z0in)  
       name = 'zeta initial'  
       call pntprf(irun,irun,lons,lats,types,nymd,nhms,1,name,zetain)  
        ENDIF  
2403        RETURN        RETURN
2404        END        END
2405         SUBROUTINE SFCFLX(NN,VUS,VVS,VTHV1,VTHV2,VTH1,VTH2,VSH1,         SUBROUTINE SFCFLX(NN,VUS,VVS,VTHV1,VTHV2,VTH1,VTH2,VSH1,
# Line 2622  C    CU            -         MOMENTUM TR Line 2454  C    CU            -         MOMENTUM TR
2454  C    CT            -         HEAT TRANSPORT COEFFICIENT  C    CT            -         HEAT TRANSPORT COEFFICIENT
2455  C  C
2456  C**********************************************************************  C**********************************************************************
2457  C        implicit none
2458    
2459    C Argument List Declarations
2460          integer nn,n,irun
2461          _RL aitr,cp,rgas,undef
2462          _RL VUS(IRUN),VVS(IRUN),VTHV1(IRUN),VTHV2(IRUN)
2463          _RL VTH1(IRUN),VTH2(IRUN),VSH1(IRUN),VSH2(IRUN)
2464          _RL VPK(IRUN),VPKE(IRUN),VPE(IRUN)
2465          _RL VZ0(IRUN),VHS(IRUN),VAHS(IRUN)
2466          integer IVWATER(IRUN)
2467          LOGICAL FIRST,LAST
2468          _RL VRHO(IRUN),VRHOZPK(IRUN)
2469          _RL VKM(IRUN),VKH(IRUN),VUSTAR(IRUN),VXX(IRUN)
2470          _RL VYY(IRUN),VCU(IRUN),VCT(IRUN),VRIB(IRUN)
2471          _RL VZETA(IRUN),VWS(IRUN)
2472          _RL stu2m(irun),stv2m(irun),stt2m(irun),stq2m(irun)
2473          _RL stu10m(irun),stv10m(irun),stt10m(irun),stq10m(irun)
2474          LOGICAL LWATER
2475          integer IVBITRIB(irun)
2476          _RL VHZ(irun),VPSIM(irun),VAPSIM(irun),VPSIG(irun),VPSIHG(irun)
2477          _RL VTEMP(irun),VDZETA(irun),VDZ0(irun),VDPSIM(irun)
2478          _RL VDPSIH(irun),VZH(irun),VXX0(irun),VYY0(irun)
2479          _RL VAPSIHG(irun),VRIB1(irun),VWS1(irun)
2480          _RL VPSIH(irun),VZETAL(irun),VZ0L(irun),VPSIH2(irun),VH0(irun)
2481          _RL VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)
2482          _RL VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)
2483          _RL VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)
2484          _RL VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)
2485          _RL VXNUM(irun),VDZETA1(irun),VDZETA2(irun)
2486          _RL VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)
2487          _RL VDPSIMC(irun),VDPSIHC(irun)
2488    
2489    C Local Variables
2490          _RL USTMX3,USTZ0S,Z0MIN,H0BYZ0,USTH0S,H0VEG,Z0VEGM,PRFAC
2491          _RL XPFAC,DIFSQT
2492        PARAMETER ( USTMX3 =   0.0632456)        PARAMETER ( USTMX3 =   0.0632456)
2493        PARAMETER ( USTZ0S =   0.2030325E-5)        PARAMETER ( USTZ0S =   0.2030325E-5)
2494        PARAMETER ( Z0MIN  =  USTZ0S/USTMX3)        PARAMETER ( Z0MIN  =  USTZ0S/USTMX3)
# Line 2635  C Line 2500  C
2500        PARAMETER ( XPFAC  = .55        )          PARAMETER ( XPFAC  = .55        )  
2501        PARAMETER ( DIFSQT  = 3.872983E-3)        PARAMETER ( DIFSQT  = 3.872983E-3)
2502    
2503         DIMENSION VUS(IRUN),VVS(IRUN),VTHV1(IRUN),VTHV2(IRUN)        _RL psihdiag(irun),psimdiag(irun)
2504         DIMENSION VTH1(IRUN),VTH2(IRUN),VSH1(IRUN),VSH2(IRUN)        _RL getcon,vk,rvk,vk2,bmdl
2505         DIMENSION VPK(IRUN),VPKE(IRUN),VPE(IRUN)        integer iwater,itype
2506         DIMENSION VZ0(IRUN),IVWATER(IRUN),VHS(IRUN),VAHS(IRUN)        integer i,iter
        DIMENSION VRHO(IRUN),VRHOZPK(IRUN)  
        DIMENSION VKM(IRUN),VKH(IRUN),VUSTAR(IRUN),VXX(IRUN)  
        DIMENSION VYY(IRUN),VCU(IRUN),VCT(IRUN),VRIB(IRUN)  
        DIMENSION VZETA(IRUN),VWS(IRUN)  
        dimension stu2m(irun),stv2m(irun),stt2m(irun),stq2m(irun)  
        dimension stu10m(irun),stv10m(irun),stt10m(irun),stq10m(irun)  
        LOGICAL FIRST,LAST  
        LOGICAL LWATER  
        integer IVBITRIB(irun)  
 C  
        DIMENSION VHZ(irun)  
        DIMENSION VH0(irun)  
        DIMENSION VPSIM(irun),VAPSIM(irun)  
        DIMENSION VPSIG(irun),VPSIHG(irun)  
        DIMENSION VTEMP(irun),VDZETA(irun)  
        DIMENSION VDZ0(irun),VDPSIM(irun)  
        DIMENSION VDPSIH(irun),VZH(irun)  
        DIMENSION VXX0(irun),VYY0(irun)  
        DIMENSION VAPSIHG(irun),VRIB1(irun),VWS1(irun)  
        DIMENSION VPSIH(irun),VZETAL(irun)  
        DIMENSION VZ0L(irun),VPSIH2(irun)  
        DIMENSION VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)  
        DIMENSION VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)  
        DIMENSION VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)  
        DIMENSION VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)  
        DIMENSION VXNUM(irun),VDZETA1(irun),VDZETA2(irun)  
        DIMENSION VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)  
        DIMENSION VDPSIMC(irun),VDPSIHC(irun)  
   
        dimension psihdiag(irun),psimdiag(irun)  
2507  C  C
2508        vk = getcon('VON KARMAN')        vk = getcon('VON KARMAN')
2509        rvk = 1./vk        rvk = 1./vk
# Line 3005  C                  (IFLAG=3), OR BOTH (I Line 2840  C                  (IFLAG=3), OR BOTH (I
2840  C     N     -  LENGTH OF VECTOR TO BE SOLVED  C     N     -  LENGTH OF VECTOR TO BE SOLVED
2841  C  C
2842  C**********************************************************************  C**********************************************************************
2843  C        implicit none
2844        DIMENSION PHIM(N),PHIH(N),Z(N)  
2845        DIMENSION INT72(N), INTMAX(N)  C Argument List Declarations
2846        DIMENSION ZSTAR(N),I1(N),I2(N)        integer n,iflag
2847        DIMENSION E1(N),E2(N),TEMP1(N)        _RL PHIM(N),PHIH(N),Z(N)
2848  C  
2849        DIMENSION PHIM0(385),ZLINM1(75),ZLINM2(75),ZLINM3(36)  C Local Variables
2850        DIMENSION ZLOGM1(74),ZLOGM2(75),ZLOGM3(50)        integer I1(N),I2(N)
2851        DIMENSION PHIH0(385),ZLINH1(75),ZLINH2(75),ZLINH3(36)        _RL ZSTAR(N),E1(N),E2(N),TEMP1(N)
2852        DIMENSION ZLOGH1(74),ZLOGH2(75),ZLOGH3(50)  C
2853          _RL PHIM0(385),ZLINM1(75),ZLINM2(75),ZLINM3(36)
2854          _RL ZLOGM1(74),ZLOGM2(75),ZLOGM3(50)
2855          _RL PHIH0(385),ZLINH1(75),ZLINH2(75),ZLINH3(36)
2856          _RL ZLOGH1(74),ZLOGH2(75),ZLOGH3(50)
2857        EQUIVALENCE (PHIM0(1),ZLINM1(1)),(PHIM0(76),ZLINM2(1))        EQUIVALENCE (PHIM0(1),ZLINM1(1)),(PHIM0(76),ZLINM2(1))
2858        EQUIVALENCE (PHIM0(151),ZLINM3(1))        EQUIVALENCE (PHIM0(151),ZLINM3(1))
2859        EQUIVALENCE (PHIM0(187),ZLOGM1(1)),(PHIM0(261),ZLOGM2(1))        EQUIVALENCE (PHIM0(187),ZLOGM1(1)),(PHIM0(261),ZLOGM2(1))
# Line 3193  C Line 3032  C
3032       &  0.664746,0.663985,0.663227,0.662473,0.661723,       &  0.664746,0.663985,0.663227,0.662473,0.661723,
3033       &  0.660977,0.660234,0.659495,0.658759,0.658027,       &  0.660977,0.660234,0.659495,0.658759,0.658027,
3034       &  0.657298/       &  0.657298/
3035    
3036          integer ibit1,ibit2,i
3037  C  C
3038        IBIT1 = 0        IBIT1 = 0
3039        IBIT2 = 0        IBIT2 = 0
# Line 3299  C  SUBPROGRAMS NEEDED Line 3140  C  SUBPROGRAMS NEEDED
3140  C     PHI  -  COMPUTES SIMILARITY FUNCTION FOR MOMENTUM AND SCALARS  C     PHI  -  COMPUTES SIMILARITY FUNCTION FOR MOMENTUM AND SCALARS
3141  C  C
3142  C**********************************************************************  C**********************************************************************
3143  C        implicit none
3144  C  
3145    C Argument List Declarations
3146          integer irun,iflag
3147          _RL VZZ(IRUN),VZH(IRUN),VPSIM(IRUN),VPSIH(IRUN),
3148         1     VX(IRUN),VXS(IRUN),VY(IRUN),VYS(IRUN)
3149    
3150    C Local Variables
3151          _RL ZWM,RZWM,Z0M,ZCM,RZCM,CM1,CM2,CM6,CM7,CM8ARG,YCM
3152        PARAMETER ( ZWM     =    1.    )        PARAMETER ( ZWM     =    1.    )
3153        PARAMETER ( RZWM    =  1./ZWM  )        PARAMETER ( RZWM    =  1./ZWM  )
3154        PARAMETER ( Z0M     =    0.2    )        PARAMETER ( Z0M     =    0.2    )
# Line 3313  C Line 3161  C
3161        PARAMETER ( CM8ARG  =  CM7*ZCM*RZWM / (CM2+ZCM)  )        PARAMETER ( CM8ARG  =  CM7*ZCM*RZWM / (CM2+ZCM)  )
3162        PARAMETER ( YCM     =  6. / ( 1. + 6.*CM1*ZCM )  )        PARAMETER ( YCM     =  6. / ( 1. + 6.*CM1*ZCM )  )
3163    
3164        DIMENSION VZZ(IRUN),VZH(IRUN),VPSIM(IRUN),VPSIH(IRUN),        integer INTSTB(irun),INTZ0(irun)
3165       1     VX(IRUN),VXS(IRUN),VY(IRUN),VYS(IRUN)        _RL ZZ0(irun),Z(irun),Z2(irun),Z1(irun),Z0(irun)
3166          _RL X0(irun),X1(irun),Y0(irun),Y1(irun)
3167        DIMENSION INTSTB(irun),INT72(irun),INTZ0(irun)        _RL PSI2(irun),TEMP(irun)
3168        DIMENSION  ZZ0(irun),Z(irun),Z2(irun),Z1(irun),Z0(irun)        _RL HZ(irun),ARG0(irun),ARG1(irun),DX(irun)
3169        DIMENSION  X0(irun),X1(irun),Y0(irun),Y1(irun)        _RL X0NUM(irun),X1NUM(irun),X0DEN(irun)
3170        DIMENSION  XX(irun),XXS(irun),YY(irun),YYS(irun)        _RL X1DEN(irun),Y1DEN(irun),Z2ZWM(irun)
3171        DIMENSION  PSIMM(irun),PSIHH(irun)        _RL cm3,cm4,cm5,cm8
3172        DIMENSION  PSI2(irun),TEMP(irun)        integer ibit,indx
3173        DIMENSION  HZ(irun),ARG0(irun),ARG1(irun),DX(irun)        integer i
       DIMENSION  X0NUM(irun),X1NUM(irun),X0DEN(irun)  
       DIMENSION  X1DEN(irun),Y1DEN(irun),Z2ZWM(irun)  
3174  C  C
3175        CM3 =   sqrt( 0.2/CM1-0.01 )        CM3 =   sqrt( 0.2/CM1-0.01 )
3176        CM4 =   1./CM3        CM4 =   1./CM3
# Line 3358  C ************************************** Line 3204  C **************************************
3204  C  C
3205        IF(IBIT.LE.0)  GO TO 100        IF(IBIT.LE.0)  GO TO 100
3206  C  C
3207        INDEX = 0        indx = 0
3208        DO 9002 I = 1,IRUN        DO 9002 I = 1,IRUN
3209         IF (INTSTB(I).EQ.1)THEN         IF (INTSTB(I).EQ.1)THEN
3210          INDEX = INDEX + 1          indx = indx + 1
3211          Z(INDEX) = VZZ(I)          Z(indx) = VZZ(I)
3212          Z0(INDEX) = ZZ0(I)          Z0(indx) = ZZ0(I)
3213         ENDIF         ENDIF
3214   9002 CONTINUE   9002 CONTINUE
3215  C  C
# Line 3401  C Line 3247  C
3247         PSI2(I) = PSI2(I) + DX(I)         PSI2(I) = PSI2(I) + DX(I)
3248   9006 CONTINUE   9006 CONTINUE
3249  C  C
3250        INDEX = 0        indx = 0
3251        DO 9008 I = 1,IRUN        DO 9008 I = 1,IRUN
3252         IF( INTSTB(I).EQ.1 ) THEN         IF( INTSTB(I).EQ.1 ) THEN
3253          INDEX = INDEX + 1          indx = indx + 1
3254          VPSIM(I) = PSI2(INDEX)          VPSIM(I) = PSI2(indx)
3255          VX(I) = X1(INDEX)          VX(I) = X1(indx)
3256          VXS(I) = X0(INDEX)          VXS(I) = X0(indx)
3257         ENDIF         ENDIF
3258   9008 CONTINUE   9008 CONTINUE
3259  C  C
# Line 3434  C Line 3280  C
3280         PSI2(I) = PSI2(I) - Y1(I) + Y0(I)         PSI2(I) = PSI2(I) - Y1(I) + Y0(I)
3281   9010 CONTINUE   9010 CONTINUE
3282  C  C
3283        INDEX = 0        indx = 0
3284        DO 9012 I = 1,IRUN        DO 9012 I = 1,IRUN
3285         IF( INTSTB(I).EQ.1 ) THEN         IF( INTSTB(I).EQ.1 ) THEN
3286         INDEX = INDEX + 1         indx = indx + 1
3287         VPSIH(I) = PSI2(INDEX)         VPSIH(I) = PSI2(indx)
3288         VY(I) = Y1(INDEX)         VY(I) = Y1(indx)
3289         VYS(I) = Y0(INDEX)         VYS(I) = Y0(indx)
3290         ENDIF         ENDIF
3291   9012 CONTINUE   9012 CONTINUE
3292  C  C
# Line 3463  C Line 3309  C
3309         ENDIF         ENDIF
3310   9014 CONTINUE   9014 CONTINUE
3311        IF(IBIT.LE.0)  GO TO 300        IF(IBIT.LE.0)  GO TO 300
3312        INDEX = 0        indx = 0
3313  #if CRAY  #ifdef CRAY
3314  CDIR$ NOVECTOR  CDIR$ NOVECTOR
3315  #endif  #endif
3316        DO 9016 I = 1,IRUN        DO 9016 I = 1,IRUN
3317         IF (INTSTB(I).EQ.1)THEN         IF (INTSTB(I).EQ.1)THEN
3318          INDEX = INDEX + 1          indx = indx + 1
3319          Z(INDEX) = VZZ(I)          Z(indx) = VZZ(I)
3320          Z0(INDEX) = ZZ0(I)          Z0(indx) = ZZ0(I)
3321          ARG1(INDEX) = VZH(I)          ARG1(indx) = VZH(I)
3322         ENDIF         ENDIF
3323   9016 CONTINUE   9016 CONTINUE
3324  #if CRAY  #ifdef CRAY
3325  CDIR$ VECTOR  CDIR$ VECTOR
3326  #endif  #endif
3327    
# Line 3529  C Line 3375  C
3375         PSI2(I) = TEMP(I) + CM6 * ARG1(I)         PSI2(I) = TEMP(I) + CM6 * ARG1(I)
3376   9020 CONTINUE   9020 CONTINUE
3377  C  C
3378        INDEX = 0        indx = 0
3379        DO 9030 I = 1,IRUN        DO 9030 I = 1,IRUN
3380         IF( INTSTB(I).EQ.1 ) THEN         IF( INTSTB(I).EQ.1 ) THEN
3381         INDEX = INDEX + 1         indx = indx + 1
3382         VPSIM(I) = PSI2(INDEX)         VPSIM(I) = PSI2(indx)
3383         VX(I) = X1(INDEX)         VX(I) = X1(indx)
3384         VXS(I) = X0(INDEX)         VXS(I) = X0(indx)
3385         ENDIF         ENDIF
3386   9030 CONTINUE   9030 CONTINUE
3387  C  C
# Line 3561  C Line 3407  C
3407         PSI2(I) = TEMP(I) + ARG0(I) * ARG1(I)         PSI2(I) = TEMP(I) + ARG0(I) * ARG1(I)
3408   9024 CONTINUE   9024 CONTINUE
3409  C  C
3410        INDEX = 0        indx = 0
3411        DO 9026 I = 1,IRUN        DO 9026 I = 1,IRUN
3412         IF( INTSTB(I).EQ.1 ) THEN         IF( INTSTB(I).EQ.1 ) THEN
3413         INDEX = INDEX + 1         indx = indx + 1
3414         VPSIH(I) = PSI2(INDEX)         VPSIH(I) = PSI2(indx)
3415         VY(I) = Y1(INDEX)         VY(I) = Y1(indx)
3416         VYS(I) = X0(INDEX)         VYS(I) = X0(indx)
3417         ENDIF         ENDIF
3418   9026 CONTINUE   9026 CONTINUE
3419  C  C
# Line 3613  C Line 3459  C
3459  C     TRBITP -  INTERPOLATES TO HEIGHT WHERE RI = RICR  C     TRBITP -  INTERPOLATES TO HEIGHT WHERE RI = RICR
3460  C  C
3461  C**********************************************************************  C**********************************************************************
3462  C        implicit none
3463  C  
3464    C Argument List Declarations
3465          integer irun,nlev,init,lmin,lminq,lminq1
3466          _RL cp
3467          _RL STRT(irun,NLEV),DW2(irun,NLEV),DZ3(irun,NLEV)
3468          _RL Q(irun,NLEV),VKZM(irun,NLEV-1),VKZE(irun,NLEV-1)
3469          _RL DTHV(irun,NLEV),DPK(irun,NLEV),DU(irun,NLEV)
3470          _RL DV(irun,NLEV)
3471          _RL QXLM(irun,NLEV-1),XL(irun,NLEV-1)
3472          _RL DZITRP(irun,nlev-1),STBFCN(irun,nlev)
3473          _RL XL0(irun,nlev),Q1(irun,nlev-1)
3474          _RL WRKIT1(irun,nlev-1),WRKIT2(irun,nlev-1)
3475          _RL WRKIT3(irun,nlev-1)
3476          _RL WRKIT4(irun,nlev-1)
3477          INTEGER INT1(irun,nlev), INT2(irun,nlev-1)
3478    
3479    C Local Variables
3480          _RL rf1,rf2,e5,d4,d1,rfc,ricr,alpha,dzcnv,xl0cnv,xl0min
3481          _RL clmt,clmt53
3482        PARAMETER ( RF1     = 0.2340678 )        PARAMETER ( RF1     = 0.2340678 )
3483        PARAMETER ( RF2     = 0.2231172 )        PARAMETER ( RF2     = 0.2231172 )
3484        PARAMETER ( E5      = 49.66     )          PARAMETER ( E5      = 49.66     )  
# Line 3628  C Line 3492  C
3492        PARAMETER ( XL0MIN  = 1.        )        PARAMETER ( XL0MIN  = 1.        )
3493        PARAMETER ( CLMT    = 0.23      )          PARAMETER ( CLMT    = 0.23      )  
3494        PARAMETER ( CLMT53  = 5. * CLMT / 3. )        PARAMETER ( CLMT53  = 5. * CLMT / 3. )
3495    
3496          integer ibit,nlevm1,nlevp1,istnlv,istnm1,nlevml,istnml,Lp1
3497        DIMENSION STRT(irun,NLEV),   DW2(irun,NLEV), DZ3(irun,NLEV)        integer istnmq,istlmq,lminp,lm1,lmin1
3498        DIMENSION DTHV(irun,NLEV),   DPK(irun,NLEV),  DU(irun,NLEV)        integer i,L,LL
       DIMENSION   DV(irun,NLEV),     Q(irun,NLEV)  
       DIMENSION VKZM(irun,NLEV-1),VKZE(irun,NLEV-1)  
       DIMENSION QXLM(irun,NLEV-1),  XL(irun,NLEV-1)  
       DIMENSION DZITRP(irun,nlev-1), STBFCN(irun,nlev)  
       DIMENSION    XL0(irun,nlev),       Q1(irun,nlev-1)  
       DIMENSION WRKIT1(irun,nlev-1)  
       DIMENSION WRKIT2(irun,nlev-1)  
       DIMENSION WRKIT3(irun,nlev-1)  
       DIMENSION WRKIT4(irun,nlev-1)  
 C  
       INTEGER INT1(irun,nlev), INT2(irun,nlev-1)  
3499  C  C
3500        NLEVM1 = NLEV - 1        NLEVM1 = NLEV - 1
3501        NLEVP1 = NLEV + 1        NLEVP1 = NLEV + 1
# Line 3846  C     ------- Line 3699  C     -------
3699  C    DZITRP        -         INTERPOLATION COEFFICIENT  C    DZITRP        -         INTERPOLATION COEFFICIENT
3700  C  C
3701  C**********************************************************************  C**********************************************************************
3702  C        implicit none
3703  C  
3704    C Argument List Declarations
3705          integer irun,nlev
3706          _RL cp
3707          _RL STBFCN(irun,NLEV+1)
3708          integer INTCHG(irun,NLEV)
3709          _RL DTHV(irun,NLEV+1),DPK(irun,NLEV+1)
3710          _RL DU(irun,NLEV+1),DV(irun,NLEV+1)
3711          _RL DZITRP(irun,NLEV+1)
3712          _RL AAA(irun,NLEV),BBB(irun,NLEV)
3713          _RL CCC(irun,NLEV),DDD(irun,NLEV)
3714    
3715    C Local Variables
3716          _RL rf1,rf2,e5,d4,d1,rfc,ricr
3717        PARAMETER ( RF1     = 0.2340678 )        PARAMETER ( RF1     = 0.2340678 )
3718        PARAMETER ( RF2     = 0.2231172 )        PARAMETER ( RF2     = 0.2231172 )
3719        PARAMETER ( E5      = 49.66     )          PARAMETER ( E5      = 49.66     )  
# Line 3856  C Line 3722  C
3722        PARAMETER ( RFC     = 0.1912323 )        PARAMETER ( RFC     = 0.1912323 )
3723        PARAMETER ( RICR    = ( (RF1-RFC)*RFC ) / ( (RF2-RFC)*D1 )  )        PARAMETER ( RICR    = ( (RF1-RFC)*RFC ) / ( (RF2-RFC)*D1 )  )
3724    
3725        DIMENSION STBFCN(irun,NLEV+1), INTCHG(irun,NLEV)        integer istnlv
3726        DIMENSION DTHV  (irun,NLEV+1), DPK   (irun,NLEV+1)        integer i
       DIMENSION DU    (irun,NLEV+1), DV    (irun,NLEV+1)  
       DIMENSION DZITRP(irun,NLEV+1)  
       DIMENSION AAA   (irun,NLEV), BBB   (irun,NLEV)  
       DIMENSION CCC   (irun,NLEV), DDD   (irun,NLEV)  
3727  C  C
3728  C *********************************************************************  C *********************************************************************
3729  C ****           QUADRATIC INTERPOLATION OF RI TO RICR VIA          ***  C ****           QUADRATIC INTERPOLATION OF RI TO RICR VIA          ***
# Line 3924  C    QQE           -         EQUILIBRIUM Line 3786  C    QQE           -         EQUILIBRIUM
3786  C    BITSTB        -         BIT '1' WHERE QE GREATER THAN ZERO  C    BITSTB        -         BIT '1' WHERE QE GREATER THAN ZERO
3787  C  C
3788  C**********************************************************************  C**********************************************************************
3789  C        implicit none
3790  C  
3791    C Argument List Declarations
3792          integer nlev,nlay,irun
3793          _RL RI(irun,NLEV),STRT(irun,NLEV),DW2(irun,NLEV)
3794          _RL XL(irun,NLEV),ZKM(irun,NLEV),ZKH(irun,NLEV)
3795          _RL QE(irun,NLEV),QQE(irun,NLEV)
3796          INTEGER INTSTB(irun,nlev)
3797          _RL EE(irun,nlay-1),RF(irun,nlay-1)
3798    
3799    C Local Variables
3800          _RL b1,b2,d3,rf1,rf2,d3b2,d2,e5,d4,d1,d1half,d2half
3801          _RL rfc,ricr,ch,cm
3802        PARAMETER ( B1      =   16.6    )          PARAMETER ( B1      =   16.6    )  
3803        PARAMETER ( B2      =   10.1    )        PARAMETER ( B2      =   10.1    )
3804        PARAMETER ( D3      = 0.29397643 )        PARAMETER ( D3      = 0.29397643 )
# Line 3944  C Line 3816  C
3816        PARAMETER ( CH      = 2.5828674 )        PARAMETER ( CH      = 2.5828674 )
3817        PARAMETER ( CM      = CH / D1   )        PARAMETER ( CM      = CH / D1   )
3818    
3819          integer istnlv
3820        DIMENSION RI(irun,NLEV), STRT(irun,NLEV), DW2(irun,NLEV)        integer i
3821        DIMENSION XL(irun,NLEV),  ZKM(irun,NLEV), ZKH(irun,NLEV)  
       DIMENSION QE(irun,NLEV),  QQE(irun,NLEV)  
       INTEGER INTSTB(irun,nlev)  
       DIMENSION     EE(irun,nlay-1),  RF(irun,nlay-1)  
 C  
3822        ISTNLV = irun * NLEV        ISTNLV = irun * NLEV
3823  C  C
3824  C *********************************************************************  C *********************************************************************
# Line 4021  C    ZKH           -         HEAT TRANSP Line 3889  C    ZKH           -         HEAT TRANSP
3889  C    P3            -         PRODUCTION RATE OF TURBULENT KINETIC ENERG  C    P3            -         PRODUCTION RATE OF TURBULENT KINETIC ENERG
3890  C  C
3891  C**********************************************************************  C**********************************************************************
3892  C        implicit none
3893  C  
3894    C Argument list Declarations
3895          integer nlev,nlay,irun
3896          _RL Q(irun,NLEV),XL(irun,NLEV),STRT(irun,NLEV)
3897          _RL DW2(irun,NLEV)
3898          INTEGER INTSTB(irun,nlay), INTQ(irun,nlay)
3899          _RL ZKM(irun,NLEV),ZKH(irun,NLEV),P3(irun,NLEV)
3900    
3901    C Local Variables
3902          _RL a1,a2,a4,c1,a5,a3,b1,b2,b3,ff2,ff3,ff4
3903        PARAMETER ( A1      =   0.92    )        PARAMETER ( A1      =   0.92    )
3904        PARAMETER ( A2      =   0.74    )        PARAMETER ( A2      =   0.74    )
3905        PARAMETER ( A4      = 6. * A1 * A1)        PARAMETER ( A4      = 6. * A1 * A1)
# Line 4037  C Line 3913  C
3913        PARAMETER ( FF3     = (3.*A2*B2) - (9.*A2*A2 )  )        PARAMETER ( FF3     = (3.*A2*B2) - (9.*A2*A2 )  )
3914        PARAMETER ( FF4     = (3.*A2*B2) + (12.*A1*A2 )  )        PARAMETER ( FF4     = (3.*A2*B2) + (12.*A1*A2 )  )
3915    
3916          _RL F2(irun,nlay-1),F3(irun,nlay-1)
3917        DIMENSION   Q(irun,NLEV),  XL(irun,NLEV), STRT(irun,NLEV)        _RL F4(irun,nlay-1),XQ(irun,nlay-1)
3918        DIMENSION DW2(irun,NLEV)  
3919        DIMENSION ZKM(irun,NLEV), ZKH(irun,NLEV),   P3(irun,NLEV)        integer istnlv
3920  C        integer i
       DIMENSION F2(irun,nlay-1),  F3(irun,nlay-1)  
       DIMENSION F4(irun,nlay-1),  XQ(irun,nlay-1)  
       INTEGER INTSTB(irun,nlay), INTQ(irun,nlay)  
3921  C  C
3922        ISTNLV = irun * NLEV        ISTNLV = irun * NLEV
3923  C  C
# Line 4115  C    DXX1G         -         SOURCE TERM Line 3988  C    DXX1G         -         SOURCE TERM
3988  C    DXX1G         -         SOURCE TERM FOR XX2 AT GROUND  C    DXX1G         -         SOURCE TERM FOR XX2 AT GROUND
3989  C  C
3990  C**********************************************************************  C**********************************************************************
3991          implicit none
3992    
3993    C Argument List Declarations
3994          integer nlev,itype,irun
3995          _RL XX1(irun,NLEV+1),XX2(irun,NLEV+1)
3996          _RL RHOKDZ(irun,NLEV),FLXFAC(irun,NLEV+1)
3997          _RL DXX1G(irun),DXX2G(irun)
3998          _RL epsl
3999  C  C
4000  C        _RL AA(irun,nlev), BB(irun,nlev), CC(irun,nlev+1)
4001          integer istnlv,istnm1,nlevp1,istnlx
4002          integer i
       DIMENSION    XX1(irun,NLEV+1),    XX2(irun,NLEV+1)  
       DIMENSION RHOKDZ(irun,NLEV)  , FLXFAC(irun,NLEV+1)  
       DIMENSION  DXX1G(irun)    ,     DXX2G(irun)  
 C  
       DIMENSION AA(irun,nlev), BB(irun,nlev), CC(irun,nlev+1)  
4003  C  C
4004        ISTNLV = irun * NLEV        ISTNLV = irun * NLEV
4005        ISTNM1 = ISTNLV - irun        ISTNM1 = ISTNLV - irun
# Line 4182  C Line 4058  C
4058        RETURN        RETURN
4059        END        END
4060        SUBROUTINE VTRI0 ( A,B,C,F,Y,K,irun)        SUBROUTINE VTRI0 ( A,B,C,F,Y,K,irun)
4061        DIMENSION A(irun,K),B(irun,K),C(irun,K),Y(irun,K+1)        implicit none
4062        DIMENSION F(irun,K)  
4063          integer k,irun
4064          _RL A(irun,K),B(irun,K),C(irun,K),Y(irun,K+1)
4065          _RL F(irun,K)
4066    
4067          integer i,L,Lm1
4068  C  C
4069        DO 9000 I = 1,irun        DO 9000 I = 1,irun
4070         A(I,1) = 1. / A(I,1)         A(I,1) = 1. / A(I,1)
# Line 4208  C Line 4089  C
4089        END        END
4090  C  C
4091        SUBROUTINE VTRI1 ( A,B,Y,K,irun)        SUBROUTINE VTRI1 ( A,B,Y,K,irun)
4092        DIMENSION A(irun,K),B(irun,K),Y(irun,K+1)        implicit none
4093    
4094          integer k,irun
4095          _RL A(irun,K),B(irun,K),Y(irun,K+1)
4096    
4097          integer i,L
4098  C  C
4099        DO 200 L = K,1,-1        DO 200 L = K,1,-1
4100         DO 9000 I = 1,irun         DO 9000 I = 1,irun
# Line 4220  C Line 4106  C
4106        END        END
4107  C  C
4108        SUBROUTINE VTRI2 ( A,B,C,F,Y,K,irun)        SUBROUTINE VTRI2 ( A,B,C,F,Y,K,irun)
4109        DIMENSION A(irun,K),B(irun,K),C(irun,K),F(irun,K)        implicit none
4110        DIMENSION Y(irun,K+1)  
4111          integer k,irun
4112          _RL A(irun,K),B(irun,K),C(irun,K),F(irun,K)
4113          _RL Y(irun,K+1)
4114    
4115          integer i,L
4116  C  C
4117        DO 100 L = 2,K        DO 100 L = 2,K
4118         DO 9000 I = 1,irun         DO 9000 I = 1,irun
# Line 4282  C    DPSIH         -         D PSIH Line 4173  C    DPSIH         -         D PSIH
4173  C    BITRIB        -         BIT ARRAY - '1' WHERE RIB1 = 0  C    BITRIB        -         BIT ARRAY - '1' WHERE RIB1 = 0
4174  C  C
4175  C**********************************************************************  C**********************************************************************
4176  C        implicit none
4177  C  
4178    C Argument List Declarations
4179          integer nn,irun,itype
4180          _RL VRIB1(IRUN),VRIB2(IRUN)
4181          _RL VWS1(IRUN),VWS2(IRUN),VZ1(IRUN),VUSTAR(IRUN)
4182          integer IWATER(IRUN)
4183          _RL VAPSIM(IRUN),VAPSIHG(IRUN)
4184          _RL VPSIH(IRUN),VPSIG(IRUN),VX(IRUN)
4185          _RL VX0(IRUN),VY(IRUN),VY0(IRUN)
4186          LOGICAL LWATER
4187          _RL VDZETA(IRUN),VDZ0(IRUN),VDPSIM(IRUN)
4188          _RL VDPSIH(IRUN)
4189          integer INTRIB(IRUN)
4190          _RL VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)
4191          _RL VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)
4192          _RL VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)
4193          _RL VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)
4194          _RL VXNUM(irun),VDZETA1(irun),VDZETA2(irun)
4195          _RL VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)
4196          _RL VDPSIMC(irun),VDPSIHC(irun)
4197    
4198    C Local Variables
4199          _RL xx0max,prfac,xpfac,difsqt,ustz0s,h0byz0,usth0s
4200        PARAMETER ( XX0MAX  =   1.49821 )        PARAMETER ( XX0MAX  =   1.49821 )
4201        PARAMETER ( PRFAC  = 0.595864   )        PARAMETER ( PRFAC  = 0.595864   )
4202        PARAMETER ( XPFAC  = .55        )          PARAMETER ( XPFAC  = .55        )  
# Line 4292  C Line 4205  C
4205        PARAMETER ( H0BYZ0 =    30.0    )        PARAMETER ( H0BYZ0 =    30.0    )
4206        PARAMETER ( USTH0S =  H0BYZ0*USTZ0S )        PARAMETER ( USTH0S =  H0BYZ0*USTZ0S )
4207    
4208        DIMENSION VRIB1(IRUN),VRIB2(IRUN)        integer VINT1(irun),VINT2(irun)
4209        DIMENSION VWS1(IRUN),VWS2(IRUN),VZ1(IRUN),VUSTAR(IRUN)        _RL getcon,vk,bmdl,b2uhs
4210        DIMENSION VAPSIM(IRUN),VAPSIHG(IRUN)        integer i
       DIMENSION VPSIH(IRUN),VPSIG(IRUN),VX(IRUN)  
       DIMENSION VX0(IRUN),VY(IRUN),VY0(IRUN)  
       DIMENSION VDZETA(IRUN),VDZ0(IRUN),VDPSIM(IRUN)  
       DIMENSION VDPSIH(IRUN)  
       DIMENSION IWATER(IRUN),INTRIB(IRUN)  
       LOGICAL LWATER  
       DIMENSION VX0PSIM(irun),VG(irun),VG0(irun),VR1MG0(irun)  
       DIMENSION VZ2(irun),VDZSEA(irun),VAZ0(irun),VXNUM1(irun)  
       DIMENSION VPSIGB2(irun),VDX(irun),VDXPSIM(irun),VDY(irun)  
       DIMENSION VXNUM2(irun),VDEN(irun),VAWS1(irun),VXNUM3(irun)  
       DIMENSION VXNUM(irun),VDZETA1(irun),VDZETA2(irun)  
       DIMENSION VZCOEF2(irun),VZCOEF1(irun),VTEMPLIN(irun)  
       DIMENSION VDPSIMC(irun),VDPSIHC(irun)  
 C  
   
   
       DIMENSION VINT1(irun),VINT2(irun)  
 C  
4211  C  C
4212        vk = getcon('VON KARMAN')        vk = getcon('VON KARMAN')
4213        BMDL    = VK * XPFAC * PRFAC / DIFSQT        BMDL    = VK * XPFAC * PRFAC / DIFSQT
# Line 4570  C        COMPUTE ROUGHNESS LENGTH FOR OC Line 4465  C        COMPUTE ROUGHNESS LENGTH FOR OC
4465  C          BASED ON FUNCTIONS OF LARGE AND POND  C          BASED ON FUNCTIONS OF LARGE AND POND
4466  C          AND OF KONDO --- DESIGNED FOR K = .4  C          AND OF KONDO --- DESIGNED FOR K = .4
4467  C *********************************************************************  C *********************************************************************
4468  C        implicit none
4469  C  
4470    C Argument List Delcarations
4471          integer irun
4472          _RL VZSEA(IRUN),VUSTAR(IRUN),VDZSEA(IRUN)
4473          integer IWATER(IRUN)
4474          LOGICAL LDZSEA
4475    
4476    C Local Variables
4477          _RL USTMX1,USTMX2,USTMX3
4478        PARAMETER ( USTMX1 =   1.14973  )        PARAMETER ( USTMX1 =   1.14973  )
4479        PARAMETER ( USTMX2 =   0.381844 )        PARAMETER ( USTMX2 =   0.381844 )
4480        PARAMETER ( USTMX3 =   0.0632456)        PARAMETER ( USTMX3 =   0.0632456)
4481    
4482        DIMENSION VZSEA(IRUN),VUSTAR(IRUN),VDZSEA(IRUN)        _RL AA(IRUN,5),TEMP(IRUN)
4483        DIMENSION IWATER(IRUN)        integer INT2(IRUN),INT3(IRUN),INT4(IRUN)
4484        DIMENSION AA(IRUN ,5),TEMP(IRUN)        integer i,k
4485        LOGICAL LDZSEA  
4486        DIMENSION INT2(IRUN ), INT3(IRUN ), INT4(IRUN)        _RL AA1(5),AA2(5),AA3(5),AA4(5)
 C  
       DIMENSION AA1(5),AA2(5),AA3(5),AA4(5)  
4487        DATA AA1/.2030325E-5,0.0,0.0,0.0,0.0/        DATA AA1/.2030325E-5,0.0,0.0,0.0,0.0/
4488        DATA AA2/-0.402451E-08,0.239597E-04,0.117484E-03,0.191918E-03,        DATA AA2/-0.402451E-08,0.239597E-04,0.117484E-03,0.191918E-03,
4489       1         0.395649E-04/       1         0.395649E-04/
# Line 4665  C Line 4566  C
4566  C  C
4567        RETURN        RETURN
4568        END        END
       subroutine pntquants_turb(nlaygcm)  
 C**********************************************************************  
 C  Subroutine to initialize the list of quantities for turbulence  
 C    package point by point diagnostic output  
 C**********************************************************************  
       implicit none  
       integer nlaygcm  
       character * 40 name  
       integer nlev  
   
       name = 'mid pressure'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'edge pressure'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'mid p ** kappa'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'edge p ** kappa'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'theta before'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'theta virtual before'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'q before'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'u wind before'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'v wind before'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'heat cap ground'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'latent heat at ground'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'net surface rad'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'background heat transfer'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'tke before'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'richardson number before'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'theta after'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'theta virtual after'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'q after'  
       nlev = nlaygcm+1  
       call pntquants(name,nlev)  
       name = 'u wind after'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'v wind after'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'tke after'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'richardson number after'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'trb u flux'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'trb v flux'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'trb t flux'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'trb q flux'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'eddy coef mom'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'eddy coef heat'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'length scale'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'layer heights'  
       nlev = nlaygcm  
       call pntquants(name,nlev)  
       name = 'q ground'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'rib initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'cu initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'ct initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'ustar initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'rho sfc initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'z0 initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'zeta initial'  
       nlev = 1  
       call pntquants(name,nlev)  
       name = 'beta coeff'  
       nlev = 1  
       call pntquants(name,nlev)  
       return  
       end  
4569    
4570        subroutine seaice ( nocean, timstp, hice,        subroutine seaice ( nocean, timstp, hice,
4571       .                     eturb,  dedtc,         .                     eturb,  dedtc,  
# Line 4803  C*************************************** Line 4575  C***************************************
4575       .                       pke,  seaic, tc, qa )       .                       pke,  seaic, tc, qa )
4576        implicit none        implicit none
4577        integer  nocean        integer  nocean
4578        real timstp        _RL timstp
4579        real eturb(nocean),dedtc(nocean),hsturb(nocean),dhsdtc(nocean)        _RL eturb(nocean),dedtc(nocean),hsturb(nocean),dhsdtc(nocean)
4580        real swnet(nocean),lwnet(nocean),  dst4(nocean)        _RL swnet(nocean),lwnet(nocean),  dst4(nocean)
4581        real  qice(nocean),dqice(nocean)        _RL  qice(nocean),dqice(nocean)
4582        real   pke(nocean),   tc(nocean),    qa(nocean)        _RL   pke(nocean),   tc(nocean),    qa(nocean)
4583        real seaic(nocean)        _RL seaic(nocean)
4584    
4585  C  rho*C = 1.93e6 J/(m**3 K) ; Peixoto & Oort  C  rho*C = 1.93e6 J/(m**3 K) ; Peixoto & Oort
4586        real, parameter ::  rhoC = 1.93e6          _RL rhoC
4587          parameter (rhoC = 1.93e6)
4588    
4589        real faceps,getcon,latent,codt,deltg,hice        _RL faceps,getcon,latent,codt,deltg,hice
4590        integer i        integer i
4591    
4592        faceps = getcon('EPSFAC')        faceps = getcon('EPSFAC')

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.22