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

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

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

revision 1.11 by molod, Fri Jul 16 20:11:04 2004 UTC revision 1.32 by molod, Sat May 21 23:50:13 2005 UTC
# Line 1  Line 1 
1  C $Header$  C $Header$
2  C $Name$  C $Name$
3    
4  #include "PACKAGES_CONFIG.h"  #include "FIZHI_OPTIONS.h"
 #include "CPP_OPTIONS.h"  
5        subroutine moistio (ndmoist,istrip,npcs,        subroutine moistio (ndmoist,istrip,npcs,
6       .   lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup,       .   lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup,
7       .   pz,plz,plze,dpres,pkht,pkl,tz,qz,bi,bj,ntracer,ptracer,       .   pz,plz,plze,dpres,pkht,pkl,uz,vz,tz,qz,bi,bj,ntracerin,ptracer,
8       .   qqz,dumoist,dvmoist,dtmoist,dqmoist,       .   qqz,dumoist,dvmoist,dtmoist,dqmoist,cumfric,
9       .   im,jm,lm,ptop,       .   im,jm,lm,ptop,
10       .   iras,rainlsp,rainconv,snowfall,       .   iras,rainlsp,rainconv,snowfall,
11       .   nswcld,cldtot_sw,cldras_sw,cldlsp_sw,nswlz,swlz,       .   nswcld,cldtot_sw,cldras_sw,cldlsp_sw,nswlz,swlz,
# Line 15  C $Name$ Line 14  C $Name$
14    
15         implicit none         implicit none
16    
 #ifdef ALLOW_DIAGNOSTICS  
 #include "SIZE.h"  
 #include "diagnostics_SIZE.h"  
 #include "diagnostics.h"  
 #endif  
   
17  c Input Variables  c Input Variables
18  c ---------------  c ---------------
19        integer im,jm,lm        integer im,jm,lm
20        integer ndmoist,istrip,npcs        integer ndmoist,istrip,npcs
21        integer bi,bj,ntracer,ptracer                integer bi,bj,ntracerin,ptracer        
22        integer lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup        integer lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup
23        real pz(im,jm),plz(im,jm,lm),plze(im,jm,lm+1),dpres(im,jm,lm)        _RL pz(im,jm),plz(im,jm,lm),plze(im,jm,lm+1),dpres(im,jm,lm)
24        real pkht(im,jm,lm+1),pkl(im,jm,lm)        _RL pkht(im,jm,lm+1),pkl(im,jm,lm)
25        real tz(im,jm,lm),qz(im,jm,lm,ntracer)              _RL tz(im,jm,lm),qz(im,jm,lm,ntracerin)      
26        real qqz(im,jm,lm)        _RL uz(im,jm,lm),vz(im,jm,lm)      
27        real dumoist(im,jm,lm),dvmoist(im,jm,lm)        _RL qqz(im,jm,lm)
28        real dtmoist(im,jm,lm),dqmoist(im,jm,lm,ntracer)        _RL dumoist(im,jm,lm),dvmoist(im,jm,lm)
29        real ptop        _RL dtmoist(im,jm,lm),dqmoist(im,jm,lm,ntracerin)
30          logical cumfric
31          _RL ptop
32        integer iras        integer iras
33        real rainlsp(im,jm),rainconv(im,jm),snowfall(im,jm)        _RL rainlsp(im,jm),rainconv(im,jm),snowfall(im,jm)
34        integer nswcld,nswlz        integer nswcld,nswlz
35        real cldlsp_sw(im,jm,lm),cldras_sw(im,jm,lm)        _RL cldlsp_sw(im,jm,lm),cldras_sw(im,jm,lm)
36        real cldtot_sw(im,jm,lm),swlz(im,jm,lm)        _RL cldtot_sw(im,jm,lm),swlz(im,jm,lm)
37        integer nlwcld,nlwlz        integer nlwcld,nlwlz
38        real  cldlsp_lw(im,jm,lm),cldras_lw(im,jm,lm)        _RL  cldlsp_lw(im,jm,lm),cldras_lw(im,jm,lm)
39        real  cldtot_lw(im,jm,lm),lwlz(im,jm,lm)        _RL  cldtot_lw(im,jm,lm),lwlz(im,jm,lm)
40        logical lpnt        logical lpnt
41        integer myid        integer myid
42    
# Line 49  c Local Variables Line 44  c Local Variables
44  c ---------------  c ---------------
45        integer    ncrnd,nsecf        integer    ncrnd,nsecf
46    
47        real       fracqq, dum        _RL       fracqq, dum
48        integer    snowcrit        integer    snowcrit
49        parameter (fracqq = 0.1)        parameter (fracqq = 0.1)
50          _RL one
51          parameter (one=1.)
52    
53        real   cldsr(im,jm,lm)        _RL   cldsr(im,jm,lm)
54        real   srcld(istrip,lm)        _RL   srcld(istrip,lm)
55    
56        real plev        _RL plev
57        real cldnow,cldlsp_mem,cldlsp,cldras_mem,cldras        _RL cldnow,cldlsp_mem,cldlsp,cldras_mem,cldras
58        real watnow,watmin,cldmin        _RL watnow,watmin,cldmin
59        real cldprs(im,jm),cldtmp(im,jm)        _RL cldprs(im,jm),cldtmp(im,jm)
60        real cldhi (im,jm),cldlow(im,jm)        _RL cldhi (im,jm),cldlow(im,jm)
61        real cldmid(im,jm),totcld(im,jm)        _RL cldmid(im,jm),totcld(im,jm)
62    
63        real   CLDLS(im,jm,lm)  , CPEN(im,jm,lm)        _RL   CLDLS(im,jm,lm)  , CPEN(im,jm,lm)
64        real    tmpimjm(im,jm)        _RL    tmpimjm(im,jm)
65        real    lsp_new(im,jm)        _RL    lsp_new(im,jm)
66        real   conv_new(im,jm)        _RL   conv_new(im,jm)
67        real   snow_new(im,jm)        _RL   snow_new(im,jm)
68    
69        real  qqcolmin(im,jm)        _RL  qqcolmin(im,jm)
70        real  qqcolmax(im,jm)        _RL  qqcolmax(im,jm)
71        integer levpbl(im,jm)        integer levpbl(im,jm)
72    
73  c Gathered Arrays for Variable Cloud Base  c Gathered Arrays for Variable Cloud Base
74  c ---------------------------------------  c ---------------------------------------
75        real    raincgath(im*jm)        _RL    raincgath(im*jm)
76        real     pigather(im*jm)        _RL     pigather(im*jm)
77        real     thgather(im*jm,lm)        _RL     thgather(im*jm,lm)
78        real     shgather(im*jm,lm)        _RL     shgather(im*jm,lm)
79        real    pkzgather(im*jm,lm)        _RL    pkzgather(im*jm,lm)
80        real    pkegather(im*jm,lm+1)        _RL    pkegather(im*jm,lm+1)
81        real    plzgather(im*jm,lm)        _RL    plzgather(im*jm,lm)
82        real    plegather(im*jm,lm+1)        _RL    plegather(im*jm,lm+1)
83        real     dpgather(im*jm,lm)        _RL     dpgather(im*jm,lm)
84        real    tmpgather(im*jm,lm)        _RL    tmpgather(im*jm,lm)
85        real   deltgather(im*jm,lm)        _RL   deltgather(im*jm,lm)
86        real   delqgather(im*jm,lm)        _RL   delqgather(im*jm,lm)
87        real      ugather(im*jm,lm,ntracer)        _RL      ugather(im*jm,lm,ntracerin+2-ptracer)
88        real   delugather(im*jm,lm,ntracer)        _RL   delugather(im*jm,lm,ntracerin+2-ptracer)
89        real     deltrnev(im*jm,lm)        _RL     deltrnev(im*jm,lm)
90        real     delqrnev(im*jm,lm)        _RL     delqrnev(im*jm,lm)
91    
92        integer  nindeces(lm)        integer  nindeces(lm)
93        integer  pblindex(im*jm)        integer  pblindex(im*jm)
# Line 98  c -------------------------------------- Line 95  c --------------------------------------
95    
96  c Stripped Arrays  c Stripped Arrays
97  c ---------------  c ---------------
98        real saveth (istrip,lm)        _RL saveth (istrip,lm)
99        real saveq  (istrip,lm)        _RL saveq  (istrip,lm)
100        real saveu  (istrip,lm,ntracer)        _RL saveu  (istrip,lm,ntracerin+2-ptracer)
101        real usubcl (istrip,   ntracer)        _RL usubcl (istrip,   ntracerin+2-ptracer)
102    
103        real     ple(istrip,lm+1)        _RL     ple(istrip,lm+1)
104        real      dp(istrip,lm)        _RL      dp(istrip,lm)
105        real      TL(ISTRIP,lm)  , SHL(ISTRIP,lm)        _RL      TL(ISTRIP,lm)  , SHL(ISTRIP,lm)
106        real      PL(ISTRIP,lm)  , PLK(ISTRIP,lm)        _RL      PL(ISTRIP,lm)  , PLK(ISTRIP,lm)
107        real    PLKE(ISTRIP,lm+1)        _RL    PLKE(ISTRIP,lm+1)
108        real      TH(ISTRIP,lm)  ,CVTH(ISTRIP,lm)        _RL      TH(ISTRIP,lm)  ,CVTH(ISTRIP,lm)
109        real   CVQ(ISTRIP,lm)        _RL   CVQ(ISTRIP,lm)
110        real      UL(ISTRIP,lm,ntracer)        _RL      UL(ISTRIP,lm,ntracerin+2-ptracer)
111        real     cvu(istrip,lm,ntracer)        _RL     cvu(istrip,lm,ntracerin+2-ptracer)
112        real  CLMAXO(ISTRIP,lm),CLBOTH(ISTRIP,lm)        _RL  CLMAXO(ISTRIP,lm),CLBOTH(ISTRIP,lm)
113        real  CLSBTH(ISTRIP,lm)        _RL  CLSBTH(ISTRIP,lm)
114        real    TMP1(ISTRIP,lm),  TMP2(ISTRIP,lm)        _RL    TMP1(ISTRIP,lm),  TMP2(ISTRIP,lm)
115        real    TMP3(ISTRIP,lm),  TMP4(ISTRIP,lm+1)        _RL    TMP3(ISTRIP,lm),  TMP4(ISTRIP,lm+1)
116        real    TMP5(ISTRIP,lm+1)        _RL    TMP5(ISTRIP,lm+1)
117        integer   ITMP1(ISTRIP,lm), ITMP2(ISTRIP,lm)        integer   ITMP1(ISTRIP,lm), ITMP2(ISTRIP,lm)
118    
119        real   PRECIP(ISTRIP), PCNET(ISTRIP)        _RL   PRECIP(ISTRIP), PCNET(ISTRIP)
120        real   SP(ISTRIP),  PREP(ISTRIP)        _RL   SP(ISTRIP),  PREP(ISTRIP)
121        real   PCPEN (ISTRIP,lm)        _RL   PCPEN (ISTRIP,lm)
122        integer pbl(istrip),depths(lm)        integer pbl(istrip),depths(lm)
123    
124        real   cldlz(istrip,lm), cldwater(im,jm,lm)        _RL   cldlz(istrip,lm), cldwater(im,jm,lm)
125        real   rhfrac(istrip), rhmin, pup, ppbl, rhcrit(istrip,lm)        _RL   rhfrac(istrip), rhmin, pup, ppbl, rhcrit(istrip,lm)
126        real   offset, alpha, rasmax        _RL   offset, alpha, rasmax
127    
128        logical first        logical first
129        logical lras        logical lras
130        real    clfrac (istrip,lm)        _RL    clfrac (istrip,lm)
131        real    cldmas (istrip,lm)        _RL    cldmas (istrip,lm)
132        real    detrain(istrip,lm)        _RL    detrain(istrip,lm)
133        real    psubcld    (istrip), psubcldg (im,jm)        _RL    psubcld    (istrip), psubcldg (im,jm)
134        real    psubcld_cnt(istrip), psubcldgc(im,jm)        _RL    psubcld_cnt(istrip), psubcldgc(im,jm)
135        real rnd(lm/2)        _RL rnd(lm/2)
136        DATA      FIRST /.TRUE./        DATA      FIRST /.TRUE./
137    
138        integer imstp,nsubcl,nlras        integer imstp,nsubcl,nlras
139        integer i,j,iloop,index,l,nn,num,numdeps,nt        integer i,j,iloop,indx,indgath,l,nn,num,numdeps,nt
140        real tmstp,tminv,sday,grav,alhl,cp,elocp,gamfac        _RL tmstp,tminv,sday,grav,alhl,cp,elocp,gamfac
141        real rkappa,p0kappa,p0kinv,ptopkap,pcheck        _RL rkappa,p0kappa,p0kinv,ptopkap,pcheck
142        real tice,getcon,pi        _RL tice,getcon,pi
143          integer ntracer,ntracedim, ntracex
144    
145    #ifdef ALLOW_DIAGNOSTICS
146          logical  diagnostics_is_on
147          external diagnostics_is_on
148          _RL tmpdiag(im,jm),tmpdiag2(im,jm)
149    #endif
150    
151  C **********************************************************************  C **********************************************************************
152  C ****                     INITIALIZATION                           ****  C ****                     INITIALIZATION                           ****
153  C **********************************************************************  C **********************************************************************
154    
155    C Add U and V components to tracer array for cumulus friction
156    
157          if(cumfric) then
158           ntracer = ntracerin + 2
159          else
160           ntracer = ntracerin
161          endif
162          ntracedim= max(ntracer-ptracer,1)
163          ntracex= ntracer-ptracer
164        IMSTP  = nsecf(NDMOIST)        IMSTP  = nsecf(NDMOIST)
165        TMSTP  = FLOAT(IMSTP)        TMSTP  = FLOAT(IMSTP)
166        TMINV  = 1. /  TMSTP        TMINV  = 1. /  TMSTP
# Line 185  c Determine Total number of Random Cloud Line 198  c Determine Total number of Random Cloud
198  c ---------------------------------------------  c ---------------------------------------------
199        ncrnd = (lm-nltop+1)/2        ncrnd = (lm-nltop+1)/2
200    
201        if(first .and. myid.eq.0) then        if(first .and. myid.eq.1 .and. bi.eq.1 ) then
202         print *         print *
203         print *,'Top Level Allowed for Convection : ',nltop         print *,'Top Level Allowed for Convection : ',nltop
204         print *,'          Highest Sub-Cloud Level: ',nsubmax         print *,'          Highest Sub-Cloud Level: ',nsubmax
# Line 229  c -------------------------------------- Line 242  c --------------------------------------
242    
243  c Set up the array of indeces of subcloud levels for the gathering  c Set up the array of indeces of subcloud levels for the gathering
244  c ----------------------------------------------------------------  c ----------------------------------------------------------------
245        index = 0        indx = 0
246        do L = nsubmin,nltop,-1        do L = nsubmin,nltop,-1
247         do j = 1,jm         do j = 1,jm
248         do i = 1,im         do i = 1,im
249          if(levpbl(i,j).eq.L) then          if(levpbl(i,j).eq.L) then
250           index = index + 1           indx = indx + 1
251           pblindex(index) = (j-1)*im + i           pblindex(indx) = (j-1)*im + i
252          endif          endif
253         enddo         enddo
254         enddo         enddo
255        enddo        enddo
256    
257        do index = 1,im*jm        do indx = 1,im*jm
258         levgather(index) = levpbl(pblindex(index),1)         levgather(indx) = levpbl(pblindex(indx),1)
259          pigather(index) =     pz(pblindex(index),1)          pigather(indx) =     pz(pblindex(indx),1)
260          pkegather(index,lm+1) = pkht(pblindex(index),1,lm+1)          pkegather(indx,lm+1) = pkht(pblindex(indx),1,lm+1)
261          plegather(index,lm+1) = plze(pblindex(index),1,lm+1)          plegather(indx,lm+1) = plze(pblindex(indx),1,lm+1)
262        enddo        enddo
263    
264        do L = 1,lm        do L = 1,lm
265         do index = 1,im*jm         do indx = 1,im*jm
266           thgather(index,L) = tz(pblindex(index),1,L)           thgather(indx,L) = tz(pblindex(indx),1,L)
267           shgather(index,L) = qz(pblindex(index),1,L,1)           shgather(indx,L) = qz(pblindex(indx),1,L,1)
268          pkegather(index,L) = pkht(pblindex(index),1,L)          pkegather(indx,L) = pkht(pblindex(indx),1,L)
269          pkzgather(index,L) = pkl(pblindex(index),1,L)          pkzgather(indx,L) = pkl(pblindex(indx),1,L)
270          plegather(index,L) = plze(pblindex(index),1,L)          plegather(indx,L) = plze(pblindex(indx),1,L)
271          plzgather(index,L) = plz(pblindex(index),1,L)          plzgather(indx,L) = plz(pblindex(indx),1,L)
272           dpgather(index,L) = dpres(pblindex(index),1,L)           dpgather(indx,L) = dpres(pblindex(indx),1,L)
273         enddo         enddo
274        enddo        enddo
275        do nt = 1,ntracer-ptracer  C General Tracers
276    C----------------
277          do nt = 1,ntracerin-ptracer
278        do L = 1,lm        do L = 1,lm
279         do index = 1,im*jm         do indx = 1,im*jm
280          ugather(index,L,nt) = qz(pblindex(index),1,L,nt+ptracer)          ugather(indx,L,nt) = qz(pblindex(indx),1,L,nt+ptracer)
281         enddo         enddo
282        enddo        enddo
283        enddo        enddo
284    
285          if(cumfric) then
286    C Cumulus Friction - load u and v wind components into tracer array
287    C------------------------------------------------------------------
288          do L = 1,lm
289           do indx = 1,im*jm
290            ugather(indx,L,ntracerin-ptracer+1) = uz(pblindex(indx),1,L)
291            ugather(indx,L,ntracerin-ptracer+2) = vz(pblindex(indx),1,L)
292           enddo
293          enddo
294    
295          endif
296    
297  c bump the counter for number of calls to convection  c bump the counter for number of calls to convection
298  c --------------------------------------------------  c --------------------------------------------------
299                          iras = iras + 1                          iras = iras + 1
# Line 279  c -------------------------------------- Line 306  c --------------------------------------
306        do l=1,lm        do l=1,lm
307        do j=1,jm        do j=1,jm
308        do i=1,im        do i=1,im
309          dumoist(i,j,l) = 0.
310          dvmoist(i,j,l) = 0.
311        dtmoist(i,j,l) = 0.        dtmoist(i,j,l) = 0.
312          do nt = 1,ntracer          do nt = 1,ntracerin
313          dqmoist(i,j,l,nt) = 0.          dqmoist(i,j,l,nt) = 0.
314          enddo          enddo
315        enddo        enddo
# Line 308  C ************************************** Line 337  C **************************************
337         CALL STRINT( levgather, pbl     ,im*jm,ISTRIP,1 ,NN )         CALL STRINT( levgather, pbl     ,im*jm,ISTRIP,1 ,NN )
338    
339         do nt = 1,ntracer-ptracer         do nt = 1,ntracer-ptracer
340         call strip ( ugather(1,1,nt), ul(1,1,nt),im*jm,istrip,lm,nn )          call strip ( ugather(1,1,nt), ul(1,1,nt),im*jm,istrip,lm,nn )
341         enddo         enddo
342    
343  C **********************************************************************  C **********************************************************************
# Line 341  C ************************************** Line 370  C **************************************
370         endif         endif
371        enddo        enddo
372    
   
373  C Initiate a do-loop around RAS for the number of different  C Initiate a do-loop around RAS for the number of different
374  C    sub-cloud layer depths in this strip  C    sub-cloud layer depths in this strip
375  C --If all subcloud depths are the same, execute loop once  C --If all subcloud depths are the same, execute loop once
# Line 477  c -------------------------------------- Line 505  c --------------------------------------
505        enddo        enddo
506    
507        CALL RAS ( NN,istrip,nindeces(nsubcl),NLRAS,NLTOP,lm,TMSTP        CALL RAS ( NN,istrip,nindeces(nsubcl),NLRAS,NLTOP,lm,TMSTP
508       1, UL(num,1,1),ntracer-ptracer,TH(num,NLTOP),SHL(num,NLTOP)       1, UL(num,1,1),ntracedim,ntracex,TH(num,NLTOP),SHL(num,NLTOP)
509       2, TMP4(num,NLTOP), TMP5(num,NLTOP),rnd, ncrnd, PCPEN(num,NLTOP)       2, TMP4(num,NLTOP), TMP5(num,NLTOP),rnd, ncrnd, PCPEN(num,NLTOP)
510       3, CLBOTH(num,NLTOP), CLFRAC(num,NLTOP)       3, CLBOTH(num,NLTOP), CLFRAC(num,NLTOP)
511       4, cldmas(num,nltop), detrain(num,nltop)       4, cldmas(num,nltop), detrain(num,nltop)
# Line 578  C     And now paste some arrays for fill Line 606  C     And now paste some arrays for fill
606  C (use pkegather to hold detrainment and tmpgather for cloud mass flux)  C (use pkegather to hold detrainment and tmpgather for cloud mass flux)
607  C **********************************************************************  C **********************************************************************
608    
609        if(icldmas .gt.0) call paste( cldmas,tmpgather,istrip,im*jm,lm,NN)        call paste( cldmas,tmpgather,istrip,im*jm,lm,NN)
610        if(idtrain .gt.0) call paste(detrain,pkegather,istrip,im*jm,lm,NN)        call paste(detrain,pkegather,istrip,im*jm,lm,NN)
       if(ipsubcld.gt.0) then  
611        call paste(psubcld    ,psubcldg ,istrip,im*jm,1,NN)        call paste(psubcld    ,psubcldg ,istrip,im*jm,1,NN)
612        call paste(psubcld_cnt,psubcldgc,istrip,im*jm,1,NN)        call paste(psubcld_cnt,psubcldgc,istrip,im*jm,1,NN)
       endif  
613    
614  C *********************************************************************  C *********************************************************************
615  C ****         RE-EVAPORATION OF PENETRATING CONVECTIVE RAIN       ****  C ****         RE-EVAPORATION OF PENETRATING CONVECTIVE RAIN       ****
# Line 603  C ************************************** Line 629  C **************************************
629    
630         CALL RNEVP (NN,ISTRIP,lm,TL,SHL,PCPEN,PL,CLFRAC,SP,DP,PLKE,         CALL RNEVP (NN,ISTRIP,lm,TL,SHL,PCPEN,PL,CLFRAC,SP,DP,PLKE,
631       .  PLK,TH,TMP1,TMP2,TMP3,ITMP1,ITMP2,PCNET,PRECIP,       .  PLK,TH,TMP1,TMP2,TMP3,ITMP1,ITMP2,PCNET,PRECIP,
632       .  CLSBTH,TMSTP,1.,cp,grav,alhl,gamfac,cldlz,rhcrit,offset,alpha)       .  CLSBTH,TMSTP,one,cp,grav,alhl,gamfac,cldlz,rhcrit,offset,alpha)
633    
634  C **********************************************************************  C **********************************************************************
635  C ****                     TENDENCY UPDATES                         ****  C ****                     TENDENCY UPDATES                         ****
# Line 623  C ************************************** Line 649  C **************************************
649    
650  C Paste rain evap tendencies into arrays for diagnostic output  C Paste rain evap tendencies into arrays for diagnostic output
651  c ------------------------------------------------------------  c ------------------------------------------------------------
        if(idtls.gt.0)then  
652         DO I =1,ISTRIP         DO I =1,ISTRIP
653          TMP1(I,L) = ((TL(I,L)/PLK(I,L))-saveth(i,l))*plk(i,l)*sday*tminv          TMP1(I,L) = ((TL(I,L)/PLK(I,L))-saveth(i,l))*plk(i,l)*sday*tminv
654         ENDDO         ENDDO
655         call paste(tmp1(1,L),deltrnev(1,L),istrip,im*jm,1,NN)         call paste(tmp1(1,L),deltrnev(1,L),istrip,im*jm,1,NN)
        endif  
656    
        if(idqls.gt.0)then  
657         DO I =1,ISTRIP         DO I =1,ISTRIP
658          TMP1(I,L) = (SHL(I,L)-saveq(I,L)) * 1000. * sday * tminv          TMP1(I,L) = (SHL(I,L)-saveq(I,L)) * 1000. * sday * tminv
659         ENDDO         ENDDO
660         call paste(tmp1(1,L),delqrnev(1,L),istrip,im*jm,1,NN)         call paste(tmp1(1,L),delqrnev(1,L),istrip,im*jm,1,NN)
        endif  
661    
662        ENDDO        ENDDO
663    
# Line 709  c--------------------------------------- Line 731  c---------------------------------------
731        CALL paste (tmp1(1,1), lsp_new,ISTRIP,im*jm,1,NN)        CALL paste (tmp1(1,1), lsp_new,ISTRIP,im*jm,1,NN)
732        CALL paste (tmp1(1,2),conv_new,ISTRIP,im*jm,1,NN)        CALL paste (tmp1(1,2),conv_new,ISTRIP,im*jm,1,NN)
733        CALL paste (tmp1(1,3),snow_new,ISTRIP,im*jm,1,NN)        CALL paste (tmp1(1,3),snow_new,ISTRIP,im*jm,1,NN)
   
       if(iprecon.gt.0) then  
734        CALL paste (pcnet,raincgath,ISTRIP,im*jm,1,NN)        CALL paste (pcnet,raincgath,ISTRIP,im*jm,1,NN)
       endif  
735    
736  C *********************************************************************  C *********************************************************************
737  C ****               End Major Stripped Region                     ****  C ****               End Major Stripped Region                     ****
# Line 725  c -------------------------------------- Line 744  c --------------------------------------
744        call back2grd ( lsp_new,pblindex, lsp_new,im*jm)        call back2grd ( lsp_new,pblindex, lsp_new,im*jm)
745        call back2grd (conv_new,pblindex,conv_new,im*jm)        call back2grd (conv_new,pblindex,conv_new,im*jm)
746        call back2grd (snow_new,pblindex,snow_new,im*jm)        call back2grd (snow_new,pblindex,snow_new,im*jm)
   
       if(iprecon.gt.0) then  
747        call back2grd (raincgath,pblindex,raincgath,im*jm)        call back2grd (raincgath,pblindex,raincgath,im*jm)
       endif  
748    
749  c Subcloud Layer Pressure  c Subcloud Layer Pressure
750  c -----------------------  c -----------------------
       if(ipsubcld.gt.0) then  
751        call back2grd (psubcldg ,pblindex,psubcldg ,im*jm)        call back2grd (psubcldg ,pblindex,psubcldg ,im*jm)
752        call back2grd (psubcldgc,pblindex,psubcldgc,im*jm)        call back2grd (psubcldgc,pblindex,psubcldgc,im*jm)
       endif  
753    
754        do L = 1,lm        do L = 1,lm
755  C Delta theta,q, convective, max and ls clouds  C Delta theta,q, convective, max and ls clouds
# Line 749  c -------------------------------------- Line 763  c --------------------------------------
763    
764  C Diagnostics:  C Diagnostics:
765  c ------------  c ------------
766         if(icldmas.gt.0)call back2grd(tmpgather(1,L),pblindex,         call back2grd(tmpgather(1,L),pblindex,
767       .                                            tmpgather(1,L),im*jm)       .                                            tmpgather(1,L),im*jm)
768         if(idtrain.gt.0)call back2grd(pkegather(1,L),pblindex,         call back2grd(pkegather(1,L),pblindex,
769       .                                            pkegather(1,L),im*jm)       .                                            pkegather(1,L),im*jm)
770         if(idtls.gt.0)call back2grd(deltrnev(1,L),pblindex,         call back2grd(deltrnev(1,L),pblindex,
771       .                                             deltrnev(1,L),im*jm)       .                                             deltrnev(1,L),im*jm)
772         if(idqls.gt.0)call back2grd(delqrnev(1,L),pblindex,         call back2grd(delqrnev(1,L),pblindex,
773       .                                             delqrnev(1,L),im*jm)       .                                             delqrnev(1,L),im*jm)
774         if(icldnp.gt.0)call back2grd(cldsr(1,1,L),pblindex,         call back2grd(cldsr(1,1,L),pblindex,
775       .                                              cldsr(1,1,L),im*jm)       .                                              cldsr(1,1,L),im*jm)
776        enddo        enddo
777    
778  c Tracers  c General Tracers
779  c -------  c ---------------
780        do nt = 1,ntracer-ptracer        do nt = 1,ntracerin-ptracer
781         do L = 1,lm         do L = 1,lm
782         call back2grd (delugather(1,L,nt),pblindex,         call back2grd (delugather(1,L,nt),pblindex,
783       .                                 dqmoist(1,1,L,ptracer+nt),im*jm)       .                                 dqmoist(1,1,L,ptracer+nt),im*jm)
784         enddo         enddo
785        enddo        enddo
786    
787          if(cumfric) then
788    
789  C **********************************************************************  c U and V for cumulus friction
790  C                          BUMP DIAGNOSTICS  c ----------------------------
791  C **********************************************************************        do L = 1,lm
792           call back2grd (delugather(1,L,ntracerin-ptracer+1),pblindex,
793         .                                 dumoist(1,1,L),im*jm)
794           call back2grd (delugather(1,L,ntracerin-ptracer+2),pblindex,
795         .                                 dvmoist(1,1,L),im*jm)
796          enddo
797    
798  c Sub-Cloud Layer  C Remove pi-weighting for u and v tendencies
 c -------------------------  
       if( ipsubcld.ne.0 ) then  
799        do j = 1,jm        do j = 1,jm
800        do i = 1,im        do i = 1,im
801        qdiag(i,j,ipsubcld,bi,bj) = qdiag(i,j,ipsubcld,bi,bj) +         tmpimjm(i,j) = 1./pz(i,j)
      .                                           psubcldg (i,j)  
       qdiag(i,j,ipsubcldc,bi,bj) = qdiag(i,j,ipsubcldc,bi,bj) +  
      .                                           psubcldgc(i,j)  
802        enddo        enddo
803        enddo        enddo
       endif  
   
 c Non-Precipitating Cloud Fraction  
 c --------------------------------  
       if( icldnp.ne.0 ) then  
804        do L = 1,lm        do L = 1,lm
805        do j = 1,jm        do j = 1,jm
806        do i = 1,im        do i = 1,im
807        qdiag(i,j,icldnp+L-1,bi,bj) = qdiag(i,j,icldnp+L-1,bi,bj) +         dumoist(i,j,L) = dumoist(i,j,L) * tmpimjm(i,j)
808       .                                                  cldsr(i,j,L)         dvmoist(i,j,L) = dvmoist(i,j,L) * tmpimjm(i,j)
809        enddo        enddo
810        enddo        enddo
811        enddo        enddo
812        ncldnp = ncldnp + 1  
813    
814          endif
815    
816    C **********************************************************************
817    C                          BUMP DIAGNOSTICS
818    C **********************************************************************
819    
820    #ifdef ALLOW_DIAGNOSTICS
821    
822    c Sub-Cloud Layer
823    c -------------------------
824          if(diagnostics_is_on('PSUBCLD ',myid) .and.
825         .                 diagnostics_is_on('PSUBCLDC',myid) ) then
826           call diagnostics_fill(psubcldg,'PSUBCLD ',0,1,3,bi,bj,myid)
827           call diagnostics_fill(psubcldgc,'PSUBCLDC',0,1,3,bi,bj,myid)
828          endif
829    
830    c Non-Precipitating Cloud Fraction
831    c --------------------------------
832          if(diagnostics_is_on('CLDNP   ',myid) ) then
833           do L=1,lm
834           do j=1,jm
835           do i=1,im
836            tmpdiag(i,j) = cldsr(i,j,L)
837           enddo
838           enddo
839           call diagnostics_fill(tmpdiag,'CLDNP   ',L,1,3,bi,bj,myid)
840          enddo
841        endif        endif
842    
843  c Moist Processes Heating Rate  c Moist Processes Heating Rate
844  c ----------------------------  c ----------------------------
845        if(imoistt.gt.0) then        if(diagnostics_is_on('MOISTT  ',myid) ) then
846        do L = 1,lm         do L=1,lm
847        do i = 1,im*jm         do j=1,jm
848        qdiag(i,1,imoistt+L-1,bi,bj) = qdiag(i,1,imoistt+L-1,bi,bj) +         do i=1,im
849       .                      (dtmoist(i,1,L)*sday*pkzgather(i,L)/pz(i,1))          indgath = (j-1)*im + i
850        enddo          tmpdiag(i,j)=(dtmoist(i,j,L)*sday*pkzgather(indgath,L)/pz(i,j))
851           enddo
852           enddo
853           call diagnostics_fill(tmpdiag,'MOISTT  ',L,1,3,bi,bj,myid)
854        enddo        enddo
855        endif        endif
856    
857  c Moist Processes Moistening Rate  c Moist Processes Moistening Rate
858  c -------------------------------  c -------------------------------
859        if(imoistq.gt.0) then        if(diagnostics_is_on('MOISTQ  ',myid) ) then
860        do L = 1,lm         do L=1,lm
861        do j = 1,jm         do j=1,jm
862        do i = 1,im         do i=1,im
863        qdiag(i,j,imoistq+L-1,bi,bj) = qdiag(i,j,imoistq+L-1,bi,bj) +          tmpdiag(i,j)=(dqmoist(i,j,L,1)*sday*1000./pz(i,j))
864       .                           (dqmoist(i,j,L,1)*sday*1000.0/pz(i,j))         enddo
865        enddo         enddo
866        enddo         call diagnostics_fill(tmpdiag,'MOISTQ  ',L,1,3,bi,bj,myid)
867        enddo        enddo
868        endif        endif
869    
870  c Cloud Mass Flux  c Cloud Mass Flux
871  c ---------------  c ---------------
872        if(icldmas.gt.0) then        if(diagnostics_is_on('CLDMAS  ',myid) ) then
873        do L = 1,lm         do L=1,lm
874        do i = 1,im*jm         do j=1,jm
875        qdiag(i,1,icldmas+L-1,bi,bj) = qdiag(i,1,icldmas+L-1,bi,bj) +         do i=1,im
876       .                                                  tmpgather(i,L)          indgath = (j-1)*im + i
877        enddo          tmpdiag(i,j)=tmpgather(indgath,L)
878        enddo         enddo
879           enddo
880           call diagnostics_fill(tmpdiag,'CLDMAS  ',L,1,3,bi,bj,myid)
881           enddo
882        endif        endif
883    
884  c Detrained Cloud Mass Flux  c Detrained Cloud Mass Flux
885  c -------------------------  c -------------------------
886        if(idtrain.gt.0) then        if(diagnostics_is_on('DTRAIN  ',myid) ) then
887        do L = 1,lm         do L=1,lm
888        do i = 1,im*jm         do j=1,jm
889        qdiag(i,1,idtrain+L-1,bi,bj) = qdiag(i,1,idtrain+L-1,bi,bj) +         do i=1,im
890       .                                                  pkegather(i,L)          indgath = (j-1)*im + i
891        enddo          tmpdiag(i,j)=pkegather(indgath,L)
892        enddo         enddo
893           enddo
894           call diagnostics_fill(tmpdiag,'DTRAIN  ',L,1,3,bi,bj,myid)
895           enddo
896        endif        endif
897    
898  c Grid-Scale Condensational Heating Rate  c Grid-Scale Condensational Heating Rate
899  c --------------------------------------  c --------------------------------------
900        if(idtls.gt.0) then        if(diagnostics_is_on('DTLS    ',myid) ) then
901        do L = 1,lm         do L=1,lm
902        do i = 1,im*jm         do j=1,jm
903        qdiag(i,1,idtls+L-1,bi,bj) = qdiag(i,1,idtls+L-1,bi,bj) +         do i=1,im
904       .                                                  deltrnev(i,L)          indgath = (j-1)*im + i
905        enddo          tmpdiag(i,j)=deltrnev(indgath,L)
906        enddo         enddo
907           enddo
908           call diagnostics_fill(tmpdiag,'DTLS    ',L,1,3,bi,bj,myid)
909           enddo
910        endif        endif
911    
912  c Grid-Scale Condensational Moistening Rate  c Grid-Scale Condensational Moistening Rate
913  c -----------------------------------------  c -----------------------------------------
914        if(idqls.gt.0) then        if(diagnostics_is_on('DQLS    ',myid) ) then
915        do L = 1,lm         do L=1,lm
916        do i = 1,im*jm         do j=1,jm
917        qdiag(i,1,idqls+L-1,bi,bj) = qdiag(i,1,idqls+L-1,bi,bj) +         do i=1,im
918       .                                                  delqrnev(i,L)          indgath = (j-1)*im + i
919        enddo          tmpdiag(i,j)=delqrnev(indgath,L)
920        enddo         enddo
921           enddo
922           call diagnostics_fill(tmpdiag,'DQLS    ',L,1,3,bi,bj,myid)
923           enddo
924        endif        endif
925    
926  c Total Precipitation  c Total Precipitation
927  c -------------------  c -------------------
928        if(ipreacc.gt.0) then        if(diagnostics_is_on('PREACC  ',myid) ) then
929        do j = 1,jm         do j=1,jm
930        do i = 1,im         do i=1,im
931        qdiag(i,j,ipreacc,bi,bj) = qdiag(i,j,ipreacc,bi,bj)          tmpdiag(i,j) = (lsp_new(I,j) + snow_new(I,j) + conv_new(i,j))
932       .                   +  (  lsp_new(I,j)       .                                                    *sday*tminv
933       .                      + snow_new(I,j)         enddo
934       .                      + conv_new(i,j) ) *sday*tminv         enddo
935        enddo         call diagnostics_fill(tmpdiag,'PREACC  ',L,1,3,bi,bj,myid)
       enddo  
936        endif        endif
937    
938  c Convective Precipitation  c Convective Precipitation
939  c ------------------------  c ------------------------
940        if(iprecon.gt.0) then        if(diagnostics_is_on('PRECON  ',myid) ) then
941        do i = 1,im*jm         do j=1,jm
942        qdiag(i,1,iprecon,bi,bj) = qdiag(i,1,iprecon,bi,bj) +         do i=1,im
943       .                                         raincgath(i)*sday*tminv          indgath = (j-1)*im + i
944        enddo          tmpdiag(i,j) = raincgath(indgath)*sday*tminv
945           enddo
946           enddo
947           call diagnostics_fill(tmpdiag,'PRECON  ',L,1,3,bi,bj,myid)
948        endif        endif
949    
950    #endif
951    
952  C **********************************************************************  C **********************************************************************
953  C ****   Fill Rainfall and Snowfall Arrays for Land Surface Model   ****  C ****   Fill Rainfall and Snowfall Arrays for Land Surface Model   ****
954  C ****        Note:  Precip Rates work when DT(turb)<DT(moist)      ****  C ****        Note:  Precip Rates work when DT(turb)<DT(moist)      ****
# Line 991  c -------------------------------------- Line 1048  c --------------------------------------
1048        enddo        enddo
1049        enddo        enddo
1050    
1051  c Compute Instantanious Total 2-D Cloud Fraction  c Compute Instantaneous Total 2-D Cloud Fraction
1052  c ----------------------------------------------  c ----------------------------------------------
1053        do j = 1,jm        do j = 1,jm
1054        do i = 1,im        do i = 1,im
# Line 1006  C ************************************** Line 1063  C **************************************
1063  C ***       Fill Cloud Top Pressure and Temperature Diagnostic       ***  C ***       Fill Cloud Top Pressure and Temperature Diagnostic       ***
1064  C **********************************************************************  C **********************************************************************
1065    
1066        if(icldtmp.gt.0) then  #ifdef ALLOW_DIAGNOSTICS
1067        do j = 1,jm        if(diagnostics_is_on('CLDTMP  ',myid) .and.
1068        do i = 1,im       .                 diagnostics_is_on('CTTCNT  ',myid) ) then
1069           if( cldtmp(i,j).gt.0.0 ) then         do j=1,jm
1070           qdiag(i,j,icldtmp,bi,bj) = qdiag(i,j,icldtmp,bi,bj) +         do i=1,im
1071       .                       cldtmp(i,j)*totcld(i,j)/tmpimjm(i,j)          if( cldtmp(i,j).gt.0. ) then              
1072           qdiag(i,j,icttcnt,bi,bj) = qdiag(i,j,icttcnt,bi,bj) +           tmpdiag(i,j) = cldtmp(i,j)*totcld(i,j)/tmpimjm(i,j)
1073       .                                                totcld(i,j)           tmpdiag2(i,j) = totcld(i,j)
1074           endif          else
1075        enddo           tmpdiag(i,j) = 0.
1076        enddo           tmpdiag2(i,j) = 0.
1077            endif
1078           enddo
1079           enddo
1080           call diagnostics_fill(tmpdiag,'CLDTMP  ',0,1,3,bi,bj,myid)
1081           call diagnostics_fill(tmpdiag2,'CTTCNT  ',0,1,3,bi,bj,myid)
1082        endif        endif
1083    
1084        if(icldprs.gt.0) then        if(diagnostics_is_on('CLDPRS  ',myid) .and.
1085        do j = 1,jm       .                 diagnostics_is_on('CTPCNTC ',myid) ) then
1086        do i = 1,im         do j=1,jm
1087           if( cldprs(i,j).gt.0.0 ) then         do i=1,im
1088           qdiag(i,j,icldprs,bi,bj) = qdiag(i,j,icldprs,bi,bj) +          if( cldprs(i,j).gt.0. ) then              
1089       .                       cldprs(i,j)*totcld(i,j)/tmpimjm(i,j)           tmpdiag(i,j) = cldprs(i,j)*totcld(i,j)/tmpimjm(i,j)
1090           qdiag(i,j,ictpcnt,bi,bj) = qdiag(i,j,ictpcnt,bi,bj) +           tmpdiag2(i,j) = totcld(i,j)
1091       .                                                totcld(i,j)          else
1092           endif           tmpdiag(i,j) = 0.
1093        enddo           tmpdiag2(i,j) = 0.
1094        enddo          endif
1095           enddo
1096           enddo
1097           call diagnostics_fill(tmpdiag,'CLDPRS  ',0,1,3,bi,bj,myid)
1098           call diagnostics_fill(tmpdiag2,'CTPCNT  ',0,1,3,bi,bj,myid)
1099        endif        endif
1100    
1101    #endif
1102        
1103  C **********************************************************************  C **********************************************************************
1104  C ****                      INCREMENT COUNTERS                      ****  C ****                      INCREMENT COUNTERS                      ****
# Line 1042  C ************************************** Line 1110  C **************************************
1110         nlwcld   = nlwcld   + 1         nlwcld   = nlwcld   + 1
1111         nswcld   = nswcld   + 1         nswcld   = nswcld   + 1
1112    
        nmoistt  = nmoistt  + 1  
        nmoistq  = nmoistq  + 1  
        npreacc  = npreacc  + 1  
        nprecon  = nprecon  + 1  
   
        ncldmas  = ncldmas  + 1  
        ndtrain  = ndtrain  + 1  
   
        ndtls  = ndtls  + 1  
        ndqls  = ndqls  + 1  
   
1113        RETURN        RETURN
1114        END        END
1115        SUBROUTINE RAS( NN, LEN, LENC, K, NLTOP, nlayr, DT        SUBROUTINE RAS( NN, LNG, LENC, K, NLTOP, nlayr, DT
1116       *,               UOI, ntracer, POI, QOI, PRS, PRJ, rnd, ncrnd       *,      UOI, ntracedim, ntracer, POI, QOI, PRS, PRJ, rnd, ncrnd
1117       *,               RAINS, CLN, CLF, cldmas, detrain       *,      RAINS, CLN, CLF, cldmas, detrain
1118       *,               cp,grav,rkappa,alhl,rhfrac,rasmax )       *,      cp,grav,rkappa,alhl,rhfrac,rasmax )
1119  C  C
1120  C*********************************************************************  C*********************************************************************
1121  C********************* SUBROUTINE  RAS   *****************************  C********************* SUBROUTINE  RAS   *****************************
# Line 1068  C Line 1125  C
1125        implicit none        implicit none
1126    
1127  C Argument List  C Argument List
1128        integer nn,len,lenc,k,nltop,nlayr        integer nn,lng,lenc,k,nltop,nlayr
1129        integer ntracer        integer ntracedim, ntracer
1130        integer ncrnd        integer ncrnd
1131        real dt        _RL dt
1132        real UOI(len,nlayr,ntracer),   POI(len,K)        _RL UOI(lng,nlayr,ntracedim),   POI(lng,K)
1133        real QOI(len,K), PRS(len,K+1), PRJ(len,K+1)        _RL QOI(lng,K), PRS(lng,K+1), PRJ(lng,K+1)
1134        real rnd(ncrnd)        _RL rnd(ncrnd)
1135        real RAINS(len,K), CLN(len,K), CLF(len,K)        _RL RAINS(lng,K), CLN(lng,K), CLF(lng,K)
1136        real cldmas(len,K), detrain(len,K)        _RL cldmas(lng,K), detrain(lng,K)
1137        real cp,grav,rkappa,alhl,rhfrac(len),rasmax        _RL cp,grav,rkappa,alhl,rhfrac(lng),rasmax
1138    
1139  C Local Variables  C Local Variables
1140        real TCU(len,K), QCU(len,K)        _RL TCU(lng,K), QCU(lng,K)
1141        real ucu(len,K,ntracer)        _RL ucu(lng,K,ntracedim)
1142        real ALF(len,K), BET(len,K), GAM(len,K)        _RL ALF(lng,K), BET(lng,K), GAM(lng,K)
1143       *,         ETA(len,K), HOI(len,K)       *,         ETA(lng,K), HOI(lng,K)
1144       *,         PRH(len,K), PRI(len,K)       *,         PRH(lng,K), PRI(lng,K)
1145        real HST(len,K), QOL(len,K), GMH(len,K)        _RL HST(lng,K), QOL(lng,K), GMH(lng,K)
1146    
1147        real TX1(len), TX2(len), TX3(len), TX4(len), TX5(len)        _RL TX1(lng), TX2(lng), TX3(lng), TX4(lng), TX5(lng)
1148       *,         TX6(len), TX7(len), TX8(len), TX9(len)       *,         TX6(lng), TX7(lng), TX8(lng), TX9(lng)
1149       *,         TX11(len), TX12(len), TX13(len), TX14(len,ntracer)       *,         TX11(lng), TX12(lng), TX13(lng), TX14(lng,ntracedim)
1150       *,         TX15(len)       *,         TX15(lng)
1151       *,         WFN(len)       *,         WFN(lng)
1152        integer IA1(len), IA2(len), IA3(len)        integer IA1(lng), IA2(lng), IA3(lng)
1153        real cloudn(len), pcu(len)        _RL cloudn(lng), pcu(lng)
1154    
1155        integer krmin,icm        integer krmin,icm
1156        real rknob, cmb2pa        _RL rknob, cmb2pa
1157        PARAMETER (KRMIN=01)        PARAMETER (KRMIN=01)
1158        PARAMETER (ICM=1000)        PARAMETER (ICM=1000)
1159        PARAMETER (CMB2PA=100.0)        PARAMETER (CMB2PA=100.0)
1160        PARAMETER (rknob = 10.)        PARAMETER (rknob = 10.)
1161    
1162        integer IC(ICM),   IRND(icm)        integer IC(ICM),   IRND(icm)
1163        real cmass(len,K)        _RL cmass(lng,K)
1164        LOGICAL SETRAS        LOGICAL SETRAS
1165          integer ifound
1166          _RL temp
1167          _RL thbef(lng,K)
1168    
1169        integer i,L,nc,ib,nt        integer i,L,nc,ib,nt
1170        integer km1,kp1,kprv,kcr,kfx,ncmx        integer km1,kp1,kprv,kcr,kfx,ncmx
1171        real p00, crtmsf, frac, rasblf        _RL p00, crtmsf, frac, rasblf
1172    
1173        do L = 1,k        do L = 1,k
1174        do I = 1,LENC        do I = 1,LENC
# Line 1123  C The numerator here is the fraction of Line 1183  C The numerator here is the fraction of
1183  C      allowed to entrain into the cloud  C      allowed to entrain into the cloud
1184    
1185  CCC   FRAC = 1./dt  CCC   FRAC = 1./dt
1186    CCC   FRAC = 0.5/dt
1187        FRAC = 0.5/dt        FRAC = 0.5/dt
1188    
1189        KM1    = K  - 1        KM1    = K  - 1
# Line 1168  c ------------------------------- Line 1229  c -------------------------------
1229        cloudn(i) = 0.0        cloudn(i) = 0.0
1230        enddo        enddo
1231    
1232         CALL CLOUD(nn,LEN, LENC, K, NLTOP, nlayr, IB, RASBLF,SETRAS,FRAC         CALL CLOUD(nn,lng, LENC, K, NLTOP, nlayr, IB, RASBLF,SETRAS,FRAC
1233       *,           CP,  ALHL, RKAPPA, GRAV, P00, CRTMSF       *,           CP,  ALHL, RKAPPA, GRAV, P00, CRTMSF
1234       *,           POI, QOI, UOI, Ntracer, PRS, PRJ       *,           POI, QOI, UOI, ntracedim, Ntracer, PRS, PRJ
1235       *,           PCU, CLOUDN, TCU, QCU, UCU, CMASS       *,           PCU, CLOUDN, TCU, QCU, UCU, CMASS
1236       *,           ALF, BET, GAM, PRH, PRI, HOI, ETA       *,           ALF, BET, GAM, PRH, PRI, HOI, ETA
1237       *,           HST, QOL, GMH       *,           HST, QOL, GMH
# Line 1213  c ***************************** Line 1274  c *****************************
1274    
1275        DO L=IB,K        DO L=IB,K
1276         DO I=1,LENC         DO I=1,LENC
1277            thbef(I,L) = POI(I,L)
1278          POI(I,L) = POI(I,L) + TCU(I,L) * DT * rhfrac(i)          POI(I,L) = POI(I,L) + TCU(I,L) * DT * rhfrac(i)
1279          QOI(I,L) = QOI(I,L) + QCU(I,L) * DT * rhfrac(i)          QOI(I,L) = QOI(I,L) + QCU(I,L) * DT * rhfrac(i)
1280         ENDDO         ENDDO
# Line 1228  c ***************************** Line 1290  c *****************************
1290         rains(I,ib) = rains(I,ib) + PCU(I)*dt * rhfrac(i)         rains(I,ib) = rains(I,ib) + PCU(I)*dt * rhfrac(i)
1291        ENDDO        ENDDO
1292    
1293          do i = 1,lenc
1294           ifound = 0
1295           do L = 1,k
1296            if(tcu(i,L).ne.0.)ifound = ifound + 1
1297           enddo
1298           if(ifound.ne.0) then
1299    c       print *,i,' made a cloud detraining at ',ib
1300            do L = 1,k
1301             temp = TCU(I,L) * DT * rhfrac(i)
1302    c        write(6,122)L,thbef(i,L),poi(i,L),temp
1303            enddo
1304           endif
1305          enddo
1306    
1307    100 CONTINUE    100 CONTINUE
1308    
1309     122  format(' ',i3,' TH B ',e10.3,' TH A ',e10.3,' DTH ',e10.3)
1310    
1311  c Fill Convective Cloud Fractions based on 3-D Rain Amounts  c Fill Convective Cloud Fractions based on 3-D Rain Amounts
1312  c ---------------------------------------------------------  c ---------------------------------------------------------
# Line 1244  c -------------------------------------- Line 1322  c --------------------------------------
1322        subroutine rndcloud (iras,nrnd,rnd,myid)        subroutine rndcloud (iras,nrnd,rnd,myid)
1323        implicit none        implicit none
1324        integer n,iras,nrnd,myid        integer n,iras,nrnd,myid
1325        real random_numbx        _RL random_numbx
1326        real rnd(nrnd)  c     _RL rnd(nrnd)
1327          _RL rnd(*)
1328        integer irm        integer irm
1329        parameter (irm = 1000)        parameter (irm = 1000)
1330        real random(irm)        _RL random(irm)
1331        integer i,mcheck,numrand,iseed,index        integer i,mcheck,iseed,indx
1332        logical first        logical first
1333        data    first /.true./        data    first /.true./
1334        integer iras0        integer iras0
1335        data    iras0 /0/        data    iras0 /0/
1336        save random, iras0        save random, iras0
1337    
1338        if(nrnd.eq.0.)then        if(nrnd.eq.0)then
1339         do i = 1,nrnd         do i = 1,nrnd
1340          rnd(i) = 0          rnd(i) = 0
1341         enddo         enddo
1342         if(first .and. myid.eq.0) print *,' NO RANDOM CLOUDS IN RAS '         if(first .and. myid.eq.1) print *,' NO RANDOM CLOUDS IN RAS '
1343         go to 100         go to 100
1344        endif        endif
1345    
1346        mcheck = mod(iras-1,irm/nrnd)        mcheck = mod(iras-1,irm/nrnd)
1347    
1348    c     print *,' RNDCLOUD: first ',first,' iras ',iras,' iras0 ',iras0
1349    c     print *,' RNDCLOUD: irm,nrnd,mcheck=',irm,nrnd,mcheck
1350    
1351          if ( iras.eq.iras0 ) then
1352    C-    Not the 1rst tile: we are all set (already done for the 1rst tile):
1353    c -----------------------------------------------------------------------
1354              indx = (iras-1)*nrnd
1355    
1356  c First Time In From a Continuing RESTART (IRAS.GT.1) or Reading a New RESTART  c First Time In From a Continuing RESTART (IRAS.GT.1) or Reading a New RESTART
1357    c   -- or --
1358    c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0)
1359  c ----------------------------------------------------------------------------  c ----------------------------------------------------------------------------
1360        if( first.and.(iras.gt.1) .or. iras.ne.iras0+1 )then        elseif ( first.and.(iras.gt.1) .or. mcheck.eq.0 ) then
1361         if( myid.eq.0 ) print *, 'Recreating Rand Numb Array in RNDCLOUD'         iseed = (iras-1-mcheck)*nrnd
        if( myid.eq.0 ) print *, 'IRAS: ',iras,'  IRAS0: ',iras0  
        numrand = mod(iras,irm/nrnd) * nrnd  
        iseed   = iras * nrnd - numrand  
1362         call random_seedx(iseed)         call random_seedx(iseed)
1363         do i = 1,irm         do i = 1,irm
1364          random(i) = random_numbx()          random(i) = random_numbx(iseed)
1365         enddo         enddo
1366         index = (iras-1)*nrnd         indx = (iras-1)*nrnd
1367    
1368  c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0)         if( myid.eq.1 ) print *, 'Creating Rand Numb Array in RNDCLOUD'
1369  c ----------------------------------------------------------------       &                        ,', iseed=', iseed
1370        else if (mcheck.eq.0) then         if( myid.eq.1 ) print *, 'IRAS: ',iras,'  IRAS0: ',iras0,
1371            iseed = (iras-1)*nrnd       &    ' indx: ', mod(indx,irm)
           call random_seedx(iseed)  
           do i = 1,irm  
            random(i) = random_numbx()  
           enddo  
           index = iseed  
1372    
1373  c Multiple Time In But have NOT Used Up all 1000 numbers (MCHECK.NE.0)  c Multiple Time In But have NOT Used Up all 1000 numbers (MCHECK.NE.0)
1374  c --------------------------------------------------------------------  c --------------------------------------------------------------------
1375        else        else
1376            index = (iras-1)*nrnd            indx = (iras-1)*nrnd
1377          endif
1378    
1379              indx = mod(indx,irm)
1380          if( indx+nrnd.gt.irm ) then
1381    c       if( myid.eq.1 .AND. iras.ne.iras0 ) print *,
1382    c    &   'reach end of Rand Numb Array in RNDCLOUD',indx,irm-nrnd
1383            indx=irm-nrnd
1384        endif        endif
1385    
           index = mod(index,irm)  
       if( index+nrnd.gt.1000 ) index=1000-nrnd  
   
1386        do n = 1,nrnd        do n = 1,nrnd
1387         rnd(n) = random(index+n)         rnd(n) = random(indx+n)
1388        enddo        enddo
1389    
1390   100  continue   100  continue
1391        first = .false.        first = .false.
1392        iras0 = iras        iras0 = iras
1393    
1394        return        return
1395        end        end
1396        function random_numbx()        function random_numbx(iseed)
1397        implicit none        implicit none
1398        real random_numbx        integer iseed
1399        random_numbx = 0        real *8 seed,port_rand
1400          _RL random_numbx
1401  #ifdef CRAY  #ifdef CRAY
1402        real ranf        _RL ranf
1403        random_numbx = ranf()        random_numbx = ranf()
1404  #endif  #else
1405  #ifdef SGI  #ifdef SGI
1406        real rand        _RL rand
1407        random_numbx = rand()        random_numbx = rand()
1408    #else
1409          seed = -1.d0
1410          random_numbx = port_rand(seed)
1411    #endif
1412  #endif  #endif
1413        return        return
1414        end        end
1415        subroutine random_seedx (iseed)        subroutine random_seedx (iseed)
1416        implicit none        implicit none
1417        integer  iseed        integer  iseed
1418          real *8 port_rand
1419  #ifdef CRAY  #ifdef CRAY
1420        call ranset (iseed)        call ranset (iseed)
1421  #endif  #else
1422  #ifdef SGI  #ifdef SGI
1423        integer*4   seed        integer*4   seed
1424                    seed = iseed                    seed = iseed
1425        call srand (seed)        call srand (seed)
1426    #else
1427          real*8 tmpRdN
1428          real*8 seed
1429          seed = iseed
1430          tmpRdN = port_rand(seed)
1431    #endif
1432  #endif  #endif
1433        return        return
1434        end        end
1435        SUBROUTINE CLOUD(nn,LEN, LENC, K, NLTOP, nlayr, IC, RASALF        SUBROUTINE CLOUD(nn,lng, LENC, K, NLTOP, nlayr, IC, RASALF
1436       *,                 SETRAS, FRAC       *,                 SETRAS, FRAC
1437       *,                 CP,  ALHL, RKAP, GRAV, P00, CRTMSF       *,                 CP,  ALHL, RKAP, GRAV, P00, CRTMSF
1438       *,                 POI, QOI, UOI, Ntracer, PRS,  PRJ       *,                 POI, QOI, UOI, ntracedim, Ntracer, PRS,  PRJ
1439       *,                 PCU, CLN, TCU, QCU, UCU, CMASS       *,                 PCU, CLN, TCU, QCU, UCU, CMASS
1440       *,                 ALF, BET, GAM, PRH, PRI, HOL, ETA       *,                 ALF, BET, GAM, PRH, PRI, HOL, ETA
1441       *,                 HST, QOL, GMH       *,                 HST, QOL, GMH
# Line 1376  C Line 1474  C
1474  C  Input:  C  Input:
1475  C  ------  C  ------
1476  C  C
1477  C     LEN     : The inner dimension of update and input arrays.  C     lng     : The inner dimension of update and input arrays.
1478  C  C
1479  C     LENC    : The run: the number of soundings processes in a single call.  C     LENC    : The run: the number of soundings processes in a single call.
1480  C               RAS works on the first LENC of the LEN soundings  C               RAS works on the first LENC of the lng soundings
1481  C               passed. This allows working on pieces of the world  C               passed. This allows working on pieces of the world
1482  C               say for multitasking, without declaring temporary arrays  C               say for multitasking, without declaring temporary arrays
1483  C               and copying the data to and from them.  This is an f77  C               and copying the data to and from them.  This is an f77
1484  C               version. An F90 version would have to allow more  C               version. An F90 version would have to allow more
1485  C               flexibility in the argument declarations.  Obviously  C               flexibility in the argument declarations.  Obviously
1486  C               (LENC<=LEN).    C               (LENC<=lng).  
1487  C  C
1488  C     K       : Number of vertical layers (increasing downwards).  C     K       : Number of vertical layers (increasing downwards).
1489  C               Need not be the same as the number of layers in the  C               Need not be the same as the number of layers in the
# Line 1416  C     CRTMSF  : Critical value of mass f Line 1514  C     CRTMSF  : Critical value of mass f
1514  C               the detrainment layer of that cloud-type is assumed.  C               the detrainment layer of that cloud-type is assumed.
1515  C               Affects only cloudiness calculation.  C               Affects only cloudiness calculation.
1516  C  C
1517  C     POI     : 2D array of dimension (LEN,K) containing potential  C     POI     : 2D array of dimension (lng,K) containing potential
1518  C               temperature. Updated but not initialized by RAS.  C               temperature. Updated but not initialized by RAS.
1519  C  C
1520  C     QOI     : 2D array of dimension (LEN,K) containing specific  C     QOI     : 2D array of dimension (lng,K) containing specific
1521  C               humidity. Updated but not initialized by RAS.  C               humidity. Updated but not initialized by RAS.
1522  C  C
1523  C     UOI     : 3D array of dimension (LEN,K,NTRACER) containing tracers  C     UOI     : 3D array of dimension (lng,K,NTRACER) containing tracers
1524  C               Updated but not initialized by RAS.  C               Updated but not initialized by RAS.
1525  C  C
1526  C     PRS     : 2D array of dimension (LEN,K+1) containing pressure  C     PRS     : 2D array of dimension (lng,K+1) containing pressure
1527  C               in hPa at the interfaces of K-layers from top of the  C               in hPa at the interfaces of K-layers from top of the
1528  C               atmosphere to the bottom. Not modified.  C               atmosphere to the bottom. Not modified.
1529  C  C
1530  C     PRJ     : 2D array of dimension (LEN,K+1) containing (PRS/P00) **  C     PRJ     : 2D array of dimension (lng,K+1) containing (PRS/P00) **
1531  C               RKAP.  i.e. Exner function at layer edges. Not modified.  C               RKAP.  i.e. Exner function at layer edges. Not modified.
1532  C  C
1533  C     rhfrac  : 1D array of dimension (LEN) containing a rel.hum. scaling  C     rhfrac  : 1D array of dimension (lng) containing a rel.hum. scaling
1534  C               fraction. Not modified.  C               fraction. Not modified.
1535  C  C
1536  C  Output:  C  Output:
1537  C  -------  C  -------
1538  C  C
1539  C     PCU     : 1D array of length LEN containing accumulated  C     PCU     : 1D array of length lng containing accumulated
1540  C               precipitation in mm/sec.  C               precipitation in mm/sec.
1541  C  C
1542  C     CLN     : 2D array of dimension (LEN,K) containing cloudiness  C     CLN     : 2D array of dimension (lng,K) containing cloudiness
1543  C               Note:  CLN is bumped but NOT initialized  C               Note:  CLN is bumped but NOT initialized
1544  C  C
1545  C     TCU     : 2D array of dimension (LEN,K) containing accumulated  C     TCU     : 2D array of dimension (lng,K) containing accumulated
1546  C               convective heating (K/sec).  C               convective heating (K/sec).
1547  C  C
1548  C     QCU     : 2D array of dimension (LEN,K) containing accumulated  C     QCU     : 2D array of dimension (lng,K) containing accumulated
1549  C               convective drying (kg/kg/sec).  C               convective drying (kg/kg/sec).
1550  C  C
1551  C     CMASS   : 2D array of dimension (LEN,K) containing the  C     CMASS   : 2D array of dimension (lng,K) containing the
1552  C               cloud mass flux (kg/sec). Filled from cloud top  C               cloud mass flux (kg/sec). Filled from cloud top
1553  C               to base.  C               to base.
1554  C  C
# Line 1470  C Line 1568  C
1568  C************************************************************************  C************************************************************************
1569        implicit none        implicit none
1570  C Argument List declarations  C Argument List declarations
1571        integer nn,LEN,LENC,K,NLTOP,nlayr,ic,ntracer        integer nn,lng,LENC,K,NLTOP,nlayr,ic,ntracedim, ntracer
1572        real rasalf        _RL rasalf
1573        LOGICAL SETRAS        LOGICAL SETRAS
1574        real frac, cp,  alhl, rkap, grav, p00, crtmsf        _RL frac, cp,  alhl, rkap, grav, p00, crtmsf
1575        real POI(LEN,K),QOI(LEN,K),PRS(LEN,K+1),PRJ(LEN,K+1)        _RL POI(lng,K),QOI(lng,K),PRS(lng,K+1),PRJ(lng,K+1)
1576        real uoi(len,nlayr,ntracer)        _RL uoi(lng,nlayr,ntracedim)
1577        real PCU(LENC), CLN(LEN)        _RL PCU(LENC), CLN(lng)
1578        real TCU(LEN,K),  QCU(LEN,K),  ucu(len,k,ntracer), CMASS(LEN,K)        _RL TCU(lng,K),QCU(lng,K),ucu(lng,k,ntracedim),CMASS(lng,K)
1579        real ALF(LEN,K), BET(LEN,K),  GAM(LEN,K), PRH(LEN,K), PRI(LEN,K)        _RL ALF(lng,K), BET(lng,K),  GAM(lng,K), PRH(lng,K), PRI(lng,K)
1580        real HOL(LENC,K), ETA(LENC,K), HST(LENC,K), QOL(LENC,K)        _RL HOL(LENC,K), ETA(LENC,K), HST(LENC,K), QOL(LENC,K)
1581        real GMH(LENC,K)        _RL GMH(LENC,K)
1582        real TX1(LENC), TX2(LENC), TX3(LENC), TX4(LENC)        _RL TX1(LENC), TX2(LENC), TX3(LENC), TX4(LENC)
1583        real TX5(LENC), TX6(LENC), TX7(LENC), TX8(LENC)        _RL TX5(LENC), TX6(LENC), TX7(LENC), TX8(LENC)
1584        real ALM(LENC), WFN(LENC), AKM(LENC), QS1(LENC)        _RL ALM(LENC), WFN(LENC), AKM(LENC), QS1(LENC)
1585        real WLQ(LENC), CLF(LENC)        _RL WLQ(LENC), CLF(LENC)
1586        real uht(len,ntracer)        _RL uht(lng,ntracedim)
1587        integer IA(LENC), I1(LENC),I2(LENC)        integer IA(LENC), I1(LENC),I2(LENC)
1588        real      rhfrac(len)        _RL      rhfrac(lng)
1589    
1590  C Local Variables  C Local Variables
1591        real daylen,half,one,zero,cmb2pa,rhmax        _RL daylen,half,one,zero,cmb2pa,rhmax
1592        PARAMETER (DAYLEN=86400.0,  HALF=0.5,  ONE=1.0, ZERO=0.0)        PARAMETER (DAYLEN=86400.0,  HALF=0.5,  ONE=1.0, ZERO=0.0)
1593        PARAMETER (CMB2PA=100.0)        PARAMETER (CMB2PA=100.0)
1594        PARAMETER (RHMAX=0.9999)        PARAMETER (RHMAX=0.9999)
1595        real rkapp1,onebcp,albcp,onebg,cpbg,twobal        _RL rkapp1,onebcp,albcp,onebg,cpbg,twobal
1596  C  C
1597        integer nt,km1,ic1,i,L,len1,len2,isav,len11,ii        integer nt,km1,ic1,i,L,len1,len2,isav,len11,ii
1598        integer lena,lena1,lenb,tem,tem1        integer lena,lena1,lenb
1599          _RL tem,tem1
1600    
1601  c Explicit Inline Directives  c Explicit Inline Directives
1602  c --------------------------  c --------------------------
# Line 1513  cfpp$ expand (qsat) Line 1612  cfpp$ expand (qsat)
1612        ONEBG  = 1.0  / GRAV        ONEBG  = 1.0  / GRAV
1613        CPBG   = CP   * ONEBG        CPBG   = CP   * ONEBG
1614        TWOBAL = 2.0 / ALHL        TWOBAL = 2.0 / ALHL
1615    
1616  C  C
1617        KM1 = K  - 1        KM1 = K  - 1
1618        IC1 = IC + 1        IC1 = IC + 1
# Line 1546  C Line 1646  C
1646  C  C
1647  C  C
1648        DO 10 L=1,K        DO 10 L=1,K
1649        DO 10 I=1,LEN        DO 10 I=1,lng
1650        TCU(I,L) = 0.0        TCU(I,L) = 0.0
1651        QCU(I,L) = 0.0        QCU(I,L) = 0.0
1652        CMASS(I,L) = 0.0        CMASS(I,L) = 0.0
# Line 1814  C Line 1914  C
1914        DO I=1,LENB        DO I=1,LENB
1915        II = I1(I)        II = I1(I)
1916        TEM    = ETA(I,L) - ETA(I,L+1)        TEM    = ETA(I,L) - ETA(I,L+1)
1917        UHT(I,NT) = UHT(I,NT) + TEM * UOI(II,L+nltop-1,NT)        UHT(I,NT) = UHT(I,NT) + TEM *  UOI(II,L+nltop-1,NT)
1918        ENDDO        ENDDO
1919        ENDDO        ENDDO
1920        ENDDO        ENDDO
# Line 2034  C Line 2134  C
2134  c Compute Tracer Tendencies  c Compute Tracer Tendencies
2135  c -------------------------  c -------------------------
2136        do nt = 1,ntracer        do nt = 1,ntracer
2137    c
2138  c Tracer Tendency at the Bottom Layer  c Tracer Tendency at the Bottom Layer
2139  c -----------------------------------  c -----------------------------------
2140        DO 995 I=1,LENB        DO 995 I=1,LENB
2141        II = I1(I)        II = I1(I)
2142        TEM    = half*TX5(I) * PRI(II,K)        TEM    = half*TX5(I) * PRI(II,K)
2143        TX1(I) = (UOI(II,KM1+nltop-1,nt) - UOI(II,K+nltop-1,nt))        TX1(I) = ( UOI(II,KM1+nltop-1,nt) - UOI(II,K+nltop-1,nt))
2144        ucu(II,K,nt) = TEM * TX1(I)        ucu(II,K,nt) = TEM * TX1(I)
2145    995 CONTINUE    995 CONTINUE
2146    c
2147  c Tracer Tendency at all other Levels  c Tracer Tendency at all other Levels
2148  c -----------------------------------  c -----------------------------------
2149        DO 1020 L=KM1,IC1,-1        DO 1020 L=KM1,IC1,-1
# Line 2072  c ----------------------------------- Line 2172  c -----------------------------------
2172        II = I1(I)        II = I1(I)
2173        ucu(II,IC,nt) = TX1(I)        ucu(II,IC,nt) = TX1(I)
2174   1040 CONTINUE   1040 CONTINUE
2175    
2176        enddo        enddo
2177  C  C
2178  C     PENETRATIVE CONVECTION CALCULATION OVER  C     PENETRATIVE CONVECTION CALCULATION OVER
# Line 2080  C Line 2180  C
2180    
2181        RETURN        RETURN
2182        END        END
2183        SUBROUTINE RNCL(LEN, PL, RNO, CLF)        SUBROUTINE RNCL(lng, PL, RNO, CLF)
2184  C  C
2185  C*********************************************************************  C*********************************************************************
2186  C********************** Relaxed Arakawa-Schubert *********************  C********************** Relaxed Arakawa-Schubert *********************
# Line 2089  C**************************** 23 July 19 Line 2189  C**************************** 23 July 19
2189  C*********************************************************************  C*********************************************************************
2190        implicit none        implicit none
2191  C Argument List declarations  C Argument List declarations
2192        integer len        integer lng
2193        real PL(LEN),  RNO(LEN), CLF(LEN)        _RL PL(lng),  RNO(lng), CLF(lng)
2194    
2195  C Local Variables  C Local Variables
2196        real p5,p8,pt8,pt2,pfac,p4,p6,p7,p9,cucld,cfac        _RL p5,p8,pt8,pt2,pfac,p4,p6,p7,p9,cucld,cfac
2197        PARAMETER (P5=500.0,  P8=800.0, PT8=0.8, PT2=0.2)        PARAMETER (P5=500.0,  P8=800.0, PT8=0.8, PT2=0.2)
2198        PARAMETER (PFAC=PT2/(P8-P5))        PARAMETER (PFAC=PT2/(P8-P5))
2199        PARAMETER (P4=400.0,    P6=401.0)        PARAMETER (P4=400.0,    P6=401.0)
# Line 2102  C Local Variables Line 2202  C Local Variables
2202    
2203        integer i        integer i
2204  C  C
2205        DO 10 I=1,LEN        DO 10 I=1,lng
2206                             rno(i) = 1.0                             rno(i) = 1.0
2207  ccc   if( pl(i).le.400.0 ) rno(i) = max( 0.75, 1.0-0.0025*(400.0-pl(i)) )  ccc   if( pl(i).le.400.0 ) rno(i) = max( 0.75, 1.0-0.0025*(400.0-pl(i)) )
2208    
# Line 2129  CARIES Line 2229  CARIES
2229  C  C
2230        RETURN        RETURN
2231        END        END
2232        SUBROUTINE ACRITN ( LEN,PL,PLB,ACR )        SUBROUTINE ACRITN ( lng,PL,PLB,ACR )
2233    
2234  C*********************************************************************  C*********************************************************************
2235  C********************** Relaxed Arakawa-Schubert *********************  C********************** Relaxed Arakawa-Schubert *********************
# Line 2142  C**** Line 2242  C****
2242  C*********************************************************************  C*********************************************************************
2243        implicit none        implicit none
2244  C Argument List declarations  C Argument List declarations
2245        integer len        integer lng
2246        real PL(LEN), PLB(LEN), ACR(LEN)        _RL PL(lng), PLB(lng), ACR(lng)
2247    
2248  C Local variables  C Local variables
2249        integer lma        integer lma
2250        parameter  (lma=18)        parameter  (lma=18)
2251        real p(lma)        _RL p(lma)
2252        real a(lma)        _RL a(lma)
2253        integer i,L        integer i,L
2254        real temp        _RL temp
2255    
2256        data p  / 93.81, 111.65, 133.46, 157.80, 186.51,        data p  / 93.81, 111.65, 133.46, 157.80, 186.51,
2257       .         219.88, 257.40, 301.21, 352.49, 409.76,       .         219.88, 257.40, 301.21, 352.49, 409.76,
# Line 2165  C Local variables Line 2265  C Local variables
2265    
2266    
2267        do L=1,lma-1        do L=1,lma-1
2268        do i=1,len        do i=1,lng
2269           if( pl(i).ge.p(L)   .and.           if( pl(i).ge.p(L)   .and.
2270       .       pl(i).le.p(L+1)) then       .       pl(i).le.p(L+1)) then
2271           temp = ( pl(i)-p(L) )/( p(L+1)-p(L) )           temp = ( pl(i)-p(L) )/( p(L+1)-p(L) )
# Line 2174  C Local variables Line 2274  C Local variables
2274        enddo        enddo
2275        enddo        enddo
2276    
2277        do i=1,len        do i=1,lng
2278        if( pl(i).lt.p(1)   ) acr(i) = a(1)        if( pl(i).lt.p(1)   ) acr(i) = a(1)
2279        if( pl(i).gt.p(lma) ) acr(i) = a(lma)        if( pl(i).gt.p(lma) ) acr(i) = a(lma)
2280        enddo        enddo
2281    
2282        do i=1,len        do i=1,lng
2283        acr(i) = acr(i) * (plb(i)-pl(i))        acr(i) = acr(i) * (plb(i)-pl(i))
2284        enddo        enddo
2285    
# Line 2192  C Local variables Line 2292  C Local variables
2292        implicit none        implicit none
2293  C Argument List declarations  C Argument List declarations
2294        integer nn,irun,nlay        integer nn,irun,nlay
2295        real TL(IRUN,NLAY),QL(IRUN,NLAY),RAIN(IRUN,NLAY),        _RL TL(IRUN,NLAY),QL(IRUN,NLAY),RAIN(IRUN,NLAY),
2296       . PL(IRUN,NLAY),CLFRAC(IRUN,NLAY),SP(IRUN),TEMP1(IRUN,NLAY),       . PL(IRUN,NLAY),CLFRAC(IRUN,NLAY),SP(IRUN),TEMP1(IRUN,NLAY),
2297       . TEMP2(IRUN,NLAY),PLKE(IRUN,NLAY+1),       . TEMP2(IRUN,NLAY),PLKE(IRUN,NLAY+1),
2298       . RCON(IRUN),RLAR(IRUN),DP(IRUN,NLAY),PLK(IRUN,NLAY),TH(IRUN,NLAY),       . RCON(IRUN),RLAR(IRUN),DP(IRUN,NLAY),PLK(IRUN,NLAY),TH(IRUN,NLAY),
2299       . TEMP3(IRUN,NLAY)       . TEMP3(IRUN,NLAY)
2300        integer ITMP1(IRUN,NLAY),ITMP2(IRUN,NLAY)        integer ITMP1(IRUN,NLAY),ITMP2(IRUN,NLAY)
2301        real CLSBTH(IRUN,NLAY)        _RL CLSBTH(IRUN,NLAY)
2302        real tmscl,tmfrc,cp,gravity,alhl,gamfac,offset,alpha        _RL tmscl,tmfrc,cp,gravity,alhl,gamfac,offset,alpha
2303        real cldlz(irun,nlay)        _RL cldlz(irun,nlay)
2304        real rhcrit(irun,nlay)        _RL rhcrit(irun,nlay)
2305  C  C
2306  C Local Variables  C Local Variables
2307        real zm1p04,zero,two89,zp44,zp01,half,zp578,one,thousand,z3600        _RL zm1p04,zero,two89,zp44,zp01,half,zp578,one,thousand,z3600
2308        real zp1,zp001        _RL zp1,zp001
2309        PARAMETER (ZM1P04 = -1.04E-4 )        PARAMETER (ZM1P04 = -1.04E-4 )
2310        PARAMETER (ZERO = 0.)        PARAMETER (ZERO = 0.)
2311        PARAMETER (TWO89= 2.89E-5)        PARAMETER (TWO89= 2.89E-5)
# Line 2219  C Local Variables Line 2319  C Local Variables
2319        PARAMETER ( THOUSAND = 1000.)        PARAMETER ( THOUSAND = 1000.)
2320        PARAMETER ( Z3600 = 3600.)        PARAMETER ( Z3600 = 3600.)
2321  C  C
2322        real EVP9(IRUN,NLAY)        _RL EVP9(IRUN,NLAY)
2323        real water(irun),crystal(irun)        _RL water(irun),crystal(irun)
2324        real watevap(irun),iceevap(irun)        _RL watevap(irun),iceevap(irun)
2325        real fracwat,fracice, tice,rh,fact,dum        _RL fracwat,fracice, tice,rh,fact,dum
2326        real rainmax(irun)        _RL rainmax(irun)
2327        real getcon,rphf,elocp,cpog,relax        _RL getcon,rphf,elocp,cpog,relax
2328        real exparg,arearat,rpow        _RL exparg,arearat,rpow
2329    
2330        integer i,L,n,nlaym1,irnlay,irnlm1        integer i,L,n,nlaym1,irnlay,irnlm1
2331    
# Line 2433  C*************************************** Line 2533  C***************************************
2533        implicit none        implicit none
2534        integer  irun,irise        integer  irun,irise
2535    
2536        real   th(irun,irise)        _RL   th(irun,irise)
2537        real    q(irun,irise)        _RL    q(irun,irise)
2538        real  plk(irun,irise)        _RL  plk(irun,irise)
2539        real   pl(irun,irise)        _RL   pl(irun,irise)
2540        real plke(irun,irise+1)        _RL plke(irun,irise+1)
2541    
2542        real  cloud(irun,irise)        _RL  cloud(irun,irise)
2543        real cldwat(irun,irise)        _RL cldwat(irun,irise)
2544        real     qs(irun,irise)        _RL     qs(irun,irise)
2545    
2546        real cp, alhl, getcon, akap        _RL cp, alhl, getcon, akap
2547        real ratio, temp, elocp        _RL ratio, temp, elocp
2548        real rhcrit,rh,dum        _RL rhcrit,rh,dum
2549        integer i,L        integer i,L
2550    
2551        real rhc(irun,irise)        _RL rhc(irun,irise)
2552        real offset,alpha        _RL offset,alpha
2553    
2554  c Explicit Inline Directives  c Explicit Inline Directives
2555  c --------------------------  c --------------------------
# Line 2495  c -------------------------------------- Line 2595  c --------------------------------------
2595        subroutine ctei ( th,q,cldfrc,cldwat,pl,plk,plke,im,lm )        subroutine ctei ( th,q,cldfrc,cldwat,pl,plk,plke,im,lm )
2596        implicit none        implicit none
2597        integer im,lm        integer im,lm
2598        real  th(im,lm),q(im,lm),plke(im,lm+1),cldwat(im,lm)        _RL  th(im,lm),q(im,lm),plke(im,lm+1),cldwat(im,lm)
2599        real plk(im,lm),pl(im,lm),cldfrc(im,lm)        _RL plk(im,lm),pl(im,lm),cldfrc(im,lm)
2600        integer i,L        integer i,L
2601        real    getcon,cp,alhl,elocp,cpoel,t,p,s,qs,dqsdt,dq        _RL    getcon,cp,alhl,elocp,cpoel,t,p,s,qs,dqsdt,dq
2602        real    k,krd,kmm,f        _RL    k,krd,kmm,f
2603    
2604        cp     = getcon('CP')        cp     = getcon('CP')
2605        alhl   = getcon('LATENT HEAT COND')        alhl   = getcon('LATENT HEAT COND')
# Line 2536  c -------------------------------------- Line 2636  c --------------------------------------
2636        subroutine back2grd(gathered,indeces,scattered,irun)        subroutine back2grd(gathered,indeces,scattered,irun)
2637        implicit none        implicit none
2638        integer i,irun,indeces(irun)        integer i,irun,indeces(irun)
2639        real gathered(irun),scattered(irun)        _RL gathered(irun),scattered(irun)
2640        real temp(irun)        _RL temp(irun)
2641        do i = 1,irun        do i = 1,irun
2642         temp(indeces(i)) = gathered(i)         temp(indeces(i)) = gathered(i)
2643        enddo        enddo

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.32

  ViewVC Help
Powered by ViewVC 1.1.22