/[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.3 by molod, Thu Jun 24 19:57:02 2004 UTC revision 1.21 by molod, Thu Dec 2 19:06:17 2004 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 moistio (ndmoist,istrip,npcs,pz,tz,qz,bi,bj,        subroutine moistio (ndmoist,istrip,npcs,
6       .   ntracer,ptracer,       .   lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup,
7       .   pkht,qqz,dumoist,dvmoist,dtmoist,dqmoist,       .   pz,plz,plze,dpres,pkht,pkl,uz,vz,tz,qz,bi,bj,ntracerin,ptracer,
8       .   im,jm,lm,sige,sig,dsig,ptop,       .   qqz,dumoist,dvmoist,dtmoist,dqmoist,cumfric,
9         .   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,
12       .   nlwcld,cldtot_lw,cldras_lw,cldlsp_lw,nlwlz,lwlz,       .   nlwcld,cldtot_lw,cldras_lw,cldlsp_lw,nlwlz,lwlz,
13       .   lpnt,myid)       .   lpnt,myid)
14    
15           implicit none
16    
17  #ifdef ALLOW_DIAGNOSTICS  #ifdef ALLOW_DIAGNOSTICS
18    #include "SIZE.h"
19    #include "diagnostics_SIZE.h"
20  #include "diagnostics.h"  #include "diagnostics.h"
21  #endif  #endif
22    
23  c Input Variables  c Input Variables
24  c ---------------  c ---------------
25        integer ndmoist,istrip,npcs,myid,bi,bj        integer im,jm,lm
26          integer ndmoist,istrip,npcs
27        integer im,jm,lm                        integer bi,bj,ntracerin,ptracer        
28        real  ptop                              integer lowlevel,midlevel,nltop,nsubmin,nsubmax,Lup
29        real  sige(lm+1)                        _RL pz(im,jm),plz(im,jm,lm),plze(im,jm,lm+1),dpres(im,jm,lm)
30        real   sig(lm)                          _RL pkht(im,jm,lm+1),pkl(im,jm,lm)
31        real  dsig(lm)                          _RL tz(im,jm,lm),qz(im,jm,lm,ntracerin)      
32          _RL uz(im,jm,lm),vz(im,jm,lm)      
33        integer ntracer,ptracer                _RL qqz(im,jm,lm)
34          _RL dumoist(im,jm,lm),dvmoist(im,jm,lm)
35        real pz(im,jm)                          _RL dtmoist(im,jm,lm),dqmoist(im,jm,lm,ntracerin)
36        real tz(im,jm,lm)                      logical cumfric
37        real qz(im,jm,lm,ntracer)              _RL ptop
38          integer iras
39        real  pkht(im,jm,lm)                    _RL rainlsp(im,jm),rainconv(im,jm),snowfall(im,jm)
40          integer nswcld,nswlz
41        real   qqz(im,jm,lm)                    _RL cldlsp_sw(im,jm,lm),cldras_sw(im,jm,lm)
42          _RL cldtot_sw(im,jm,lm),swlz(im,jm,lm)
43        real dumoist(im,jm,lm)                  integer nlwcld,nlwlz
44        real dvmoist(im,jm,lm)                  _RL  cldlsp_lw(im,jm,lm),cldras_lw(im,jm,lm)
45        real dtmoist(im,jm,lm)                  _RL  cldtot_lw(im,jm,lm),lwlz(im,jm,lm)
46        real dqmoist(im,jm,lm,ntracer)          logical lpnt
47          integer myid
       integer iras                      
       real   rainlsp(im,jm)            
       real  rainconv(im,jm)            
       real  snowfall(im,jm)            
   
       integer nswcld,nswlz              
       real  cldlsp_sw(im,jm,lm)        
       real  cldras_sw(im,jm,lm)        
       real  cldtot_sw(im,jm,lm)        
       real       swlz(im,jm,lm)        
   
       integer nlwcld,nlwlz              
       real  cldlsp_lw(im,jm,lm)        
       real  cldras_lw(im,jm,lm)        
       real  cldtot_lw(im,jm,lm)        
       real       lwlz(im,jm,lm)        
   
       logical lpnt                      
48    
49  c Local Variables  c Local Variables
50  c ---------------  c ---------------
51        integer    ncrnd,nsecf,nsubmax        integer    ncrnd,nsecf
52    
53        real       fracqq, rh,temp1,temp2,dum        _RL       fracqq, dum
54        integer    snowcrit, lup        integer    snowcrit
55        parameter (fracqq = 0.1)        parameter (fracqq = 0.1)
56          _RL one
57          parameter (one=1.)
58    
59        real   cldsr(im,jm,lm)        _RL   cldsr(im,jm,lm)
60        real   srcld(istrip,lm)        _RL   srcld(istrip,lm)
61    
62        real plev        _RL plev
63        real cldnow,cldlsp_mem,cldras_mem,cldras,watnow,watmin,cldmin        _RL cldnow,cldlsp_mem,cldlsp,cldras_mem,cldras
64        real cldprs(im,jm),cldtmp(im,jm)        _RL watnow,watmin,cldmin
65        real cldhi (im,jm),cldlow(im,jm)        _RL cldprs(im,jm),cldtmp(im,jm)
66        real cldmid(im,jm),totcld(im,jm)        _RL cldhi (im,jm),cldlow(im,jm)
67        integer midlevel,lowlevel        _RL cldmid(im,jm),totcld(im,jm)
68    
69        real   CLDLS(im,jm,lm)  , CPEN(im,jm,lm)        _RL   CLDLS(im,jm,lm)  , CPEN(im,jm,lm)
70        real    tmpimjm(im,jm)        _RL    tmpimjm(im,jm)
71        real    lsp_new(im,jm)        _RL    lsp_new(im,jm)
72        real   conv_new(im,jm)        _RL   conv_new(im,jm)
73        real   snow_new(im,jm)        _RL   snow_new(im,jm)
74    
75        real  qqcolmin(im,jm)        _RL  qqcolmin(im,jm)
76        real  qqcolmax(im,jm)        _RL  qqcolmax(im,jm)
77        integer levpbl(im,jm)        integer levpbl(im,jm)
78    
79  c Gathered Arrays for Variable Cloud Base  c Gathered Arrays for Variable Cloud Base
80  c ---------------------------------------  c ---------------------------------------
81        real    raincgath(im*jm)        _RL    raincgath(im*jm)
82        real     pigather(im*jm)        _RL     pigather(im*jm)
83        real     thgather(im*jm,lm)        _RL     thgather(im*jm,lm)
84        real     shgather(im*jm,lm)        _RL     shgather(im*jm,lm)
85        real    pkzgather(im*jm,lm)        _RL    pkzgather(im*jm,lm)
86        real    pkegather(im*jm,lm)        _RL    pkegather(im*jm,lm+1)
87        real    tmpgather(im*jm,lm)        _RL    plzgather(im*jm,lm)
88        real   deltgather(im*jm,lm)        _RL    plegather(im*jm,lm+1)
89        real   delqgather(im*jm,lm)        _RL     dpgather(im*jm,lm)
90        real      ugather(im*jm,lm,ntracer)        _RL    tmpgather(im*jm,lm)
91        real   delugather(im*jm,lm,ntracer)        _RL   deltgather(im*jm,lm)
92        real     deltrnev(im*jm,lm)        _RL   delqgather(im*jm,lm)
93        real     delqrnev(im*jm,lm)        _RL      ugather(im*jm,lm,ntracerin+2-ptracer)
94          _RL   delugather(im*jm,lm,ntracerin+2-ptracer)
95          _RL     deltrnev(im*jm,lm)
96          _RL     delqrnev(im*jm,lm)
97    
98        integer  nindeces(lm)        integer  nindeces(lm)
99        integer  pblindex(im*jm)        integer  pblindex(im*jm)
# Line 109  c -------------------------------------- Line 101  c --------------------------------------
101    
102  c Stripped Arrays  c Stripped Arrays
103  c ---------------  c ---------------
104        real saveth (istrip,lm)        _RL saveth (istrip,lm)
105        real saveq  (istrip,lm)        _RL saveq  (istrip,lm)
106        real saveu  (istrip,lm,ntracer)        _RL saveu  (istrip,lm,ntracerin+2-ptracer)
107        real usubcl (istrip,   ntracer)        _RL usubcl (istrip,   ntracerin+2-ptracer)
108    
109        real     ple(istrip,lm+1), gam(istrip,lm)        _RL     ple(istrip,lm+1)
110        real      TL(ISTRIP,lm)  , SHL(ISTRIP,lm)        _RL      dp(istrip,lm)
111        real      PL(ISTRIP,lm)  , PLK(ISTRIP,lm)        _RL      TL(ISTRIP,lm)  , SHL(ISTRIP,lm)
112        real    PLKE(ISTRIP,lm+1)        _RL      PL(ISTRIP,lm)  , PLK(ISTRIP,lm)
113        real      TH(ISTRIP,lm)  ,CVTH(ISTRIP,lm)        _RL    PLKE(ISTRIP,lm+1)
114        real   SHSAT(ISTRIP,lm)  , CVQ(ISTRIP,lm)        _RL      TH(ISTRIP,lm)  ,CVTH(ISTRIP,lm)
115        real      UL(ISTRIP,lm,ntracer)        _RL   CVQ(ISTRIP,lm)
116        real     cvu(istrip,lm,ntracer)        _RL      UL(ISTRIP,lm,ntracerin+2-ptracer)
117        real  CLMAXO(ISTRIP,lm),CLBOTH(ISTRIP,lm)        _RL     cvu(istrip,lm,ntracerin+2-ptracer)
118        real  CLSBTH(ISTRIP,lm)        _RL  CLMAXO(ISTRIP,lm),CLBOTH(ISTRIP,lm)
119        real    TMP1(ISTRIP,lm),  TMP2(ISTRIP,lm)        _RL  CLSBTH(ISTRIP,lm)
120        real    TMP3(ISTRIP,lm),  TMP4(ISTRIP,lm+1)        _RL    TMP1(ISTRIP,lm),  TMP2(ISTRIP,lm)
121        real    TMP5(ISTRIP,lm+1)        _RL    TMP3(ISTRIP,lm),  TMP4(ISTRIP,lm+1)
122          _RL    TMP5(ISTRIP,lm+1)
123        integer   ITMP1(ISTRIP,lm), ITMP2(ISTRIP,lm)        integer   ITMP1(ISTRIP,lm), ITMP2(ISTRIP,lm)
       integer   ITMP3(ISTRIP,lm)  
124    
125        real   PRECIP(ISTRIP), PCMID(ISTRIP), PCNET(ISTRIP)        _RL   PRECIP(ISTRIP), PCNET(ISTRIP)
126        real   PCLOW (ISTRIP),    SP(ISTRIP),  PREP(ISTRIP)        _RL   SP(ISTRIP),  PREP(ISTRIP)
127        real   PCPEN (ISTRIP,lm)        _RL   PCPEN (ISTRIP,lm)
128        integer pbl(istrip),depths(lm)        integer pbl(istrip),depths(lm)
129    
130        real   cldlz(istrip,lm), cldwater(im,jm,lm)        _RL   cldlz(istrip,lm), cldwater(im,jm,lm)
131        real   rhfrac(istrip), rhmin, pup, ppbl, rhcrit(istrip,lm)        _RL   rhfrac(istrip), rhmin, pup, ppbl, rhcrit(istrip,lm)
132        real   offset, alpha, rasmax        _RL   offset, alpha, rasmax
133    
134        logical first        logical first
135        logical lras        logical lras
136        real    clfrac (istrip,lm)        _RL    clfrac (istrip,lm)
137        real    cldmas (istrip,lm)        _RL    cldmas (istrip,lm)
138        real    detrain(istrip,lm)        _RL    detrain(istrip,lm)
139        real    psubcld    (istrip), psubcldg (im,jm)        _RL    psubcld    (istrip), psubcldg (im,jm)
140        real    psubcld_cnt(istrip), psubcldgc(im,jm)        _RL    psubcld_cnt(istrip), psubcldgc(im,jm)
141        real rnd(lm/2)        _RL rnd(lm/2)
142        DATA      FIRST /.TRUE./        DATA      FIRST /.TRUE./
143    
144        integer imstp,nltop,nsubcl,nlras,nsubmin        integer imstp,nsubcl,nlras
145        integer i,j,iloop,index,l,nn,num,numdeps,nt        integer i,j,iloop,indx,indgath,l,nn,num,numdeps,nt
146        real tmstp,tminv,sday,grav,alhl,cp,elocp,gamfac        _RL tmstp,tminv,sday,grav,alhl,cp,elocp,gamfac
147        real rkappa,p0kappa,p0kinv,ptopkap,pcheck        _RL rkappa,p0kappa,p0kinv,ptopkap,pcheck
148        real tice,getcon,pi        _RL tice,getcon,pi
149          integer ntracer,ntracedim, ntracex
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 192  C Threshold for Cloud Liquid Water Memor Line 194  C Threshold for Cloud Liquid Water Memor
194        tice     = getcon('FREEZING-POINT')        tice     = getcon('FREEZING-POINT')
195        PI       = 4.*atan(1.)        PI       = 4.*atan(1.)
196    
197  c Determine Upper  Level for Cumulus Convection  c Determine Total number of Random Clouds to Check
 c and Total number of Random Clouds to Check  
198  c ---------------------------------------------  c ---------------------------------------------
199    C     ncrnd = (lm-nltop+1)/2
200          ncrnd = 0
201    
202        NLTOP = 1        if(first .and. myid.eq.1 .and. bi.eq.1 ) then
       DO L=1,lm  
        PCHECK = (1000.-ptop)*SIG(L) + PTOP  
        IF (PCHECK.GE.10.) THEN  
         NLTOP = L  
         GO TO 2  
        ENDIF  
       ENDDO  
  2    CONTINUE  
       ncrnd = (lm-nltop+1)/2  
   
 c Determine Minimum Number of Levels in Sub-Cloud (50 mb) Layer  
 c -------------------------------------------------------------  
       nsubmin = lm  
       nsubmax = 1  
       DO L=lm-1,1,-1  
           PCHECK = (1000.-ptop)*SIG(L) + PTOP  
       IF( PCHECK.GE.950.0 ) nsubmin = L  
       IF( PCHECK.GE.750.0 ) nsubmax = L  
       ENDDO  
   
       if(first .and. myid.eq.0) then  
203         print *         print *
204         print *,'Top Level Allowed for Convection : ',nltop,         print *,'Top Level Allowed for Convection : ',nltop
205       .                    ' (',(1000.-ptop)*SIG(nltop) + PTOP,' mb)'         print *,'          Highest Sub-Cloud Level: ',nsubmax
206         print *,'          Highest Sub-Cloud Level: ',nsubmax,         print *,'          Lowest  Sub-Cloud Level: ',nsubmin
      .                    ' (',(1000.-ptop)*SIG(nsubmax) + PTOP,' mb)'  
        print *,'          Lowest  Sub-Cloud Level: ',nsubmin,  
      .                    ' (',(1000.-ptop)*SIG(nsubmin) + PTOP,' mb)'  
207         print *,'    Total Number of Random Clouds: ',ncrnd         print *,'    Total Number of Random Clouds: ',ncrnd
208         print *         print *
209         first = .false.         first = .false.
# Line 264  c -------------------------------------- Line 243  c --------------------------------------
243    
244  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
245  c ----------------------------------------------------------------  c ----------------------------------------------------------------
246        index = 0        indx = 0
247        do L = nsubmin,nltop,-1        do L = nsubmin,nltop,-1
248         do j = 1,jm         do j = 1,jm
249         do i = 1,im         do i = 1,im
250          if(levpbl(i,j).eq.L) then          if(levpbl(i,j).eq.L) then
251           index = index + 1           indx = indx + 1
252           pblindex(index) = (j-1)*im + i           pblindex(indx) = (j-1)*im + i
253          endif          endif
254         enddo         enddo
255         enddo         enddo
256        enddo        enddo
257    
258        do index = 1,im*jm        do indx = 1,im*jm
259         levgather(index) = levpbl(pblindex(index),1)         levgather(indx) = levpbl(pblindex(indx),1)
260          pigather(index) =     pz(pblindex(index),1)          pigather(indx) =     pz(pblindex(indx),1)
261            pkegather(indx,lm+1) = pkht(pblindex(indx),1,lm+1)
262            plegather(indx,lm+1) = plze(pblindex(indx),1,lm+1)
263        enddo        enddo
264    
265        do L = 1,lm        do L = 1,lm
266         do index = 1,im*jm         do indx = 1,im*jm
267           thgather(index,L) =   tz(pblindex(index),1,L)           thgather(indx,L) = tz(pblindex(indx),1,L)
268           shgather(index,L) =   qz(pblindex(index),1,L,1)           shgather(indx,L) = qz(pblindex(indx),1,L,1)
269          pkegather(index,L) = pkht(pblindex(index),1,L)          pkegather(indx,L) = pkht(pblindex(indx),1,L)
270            pkzgather(indx,L) = pkl(pblindex(indx),1,L)
271            plegather(indx,L) = plze(pblindex(indx),1,L)
272            plzgather(indx,L) = plz(pblindex(indx),1,L)
273             dpgather(indx,L) = dpres(pblindex(indx),1,L)
274         enddo         enddo
275        enddo        enddo
276        do nt = 1,ntracer-ptracer  C General Tracers
277    C----------------
278          do nt = 1,ntracerin-ptracer
279        do L = 1,lm        do L = 1,lm
280         do index = 1,im*jm         do indx = 1,im*jm
281          ugather(index,L,nt) = qz(pblindex(index),1,L,nt+ptracer)          ugather(indx,L,nt) = qz(pblindex(indx),1,L,nt+ptracer)
282         enddo         enddo
283        enddo        enddo
284        enddo        enddo
285    
286        call pkappa(pigather,pkegather,pkzgather,ptop,sige,dsig,im,jm,lm)        if(cumfric) then
287    C Cumulus Friction - load u and v wind components into tracer array
288    C------------------------------------------------------------------
289          do L = 1,lm
290           do indx = 1,im*jm
291            ugather(indx,L,ntracerin-ptracer+1) = uz(pblindex(indx),1,L)
292            ugather(indx,L,ntracerin-ptracer+2) = vz(pblindex(indx),1,L)
293           enddo
294          enddo
295    
296          endif
297    
298  c bump the counter for number of calls to convection  c bump the counter for number of calls to convection
299  c --------------------------------------------------  c --------------------------------------------------
# Line 310  c -------------------------------------- Line 307  c --------------------------------------
307        do l=1,lm        do l=1,lm
308        do j=1,jm        do j=1,jm
309        do i=1,im        do i=1,im
310          dumoist(i,j,l) = 0.
311          dvmoist(i,j,l) = 0.
312        dtmoist(i,j,l) = 0.        dtmoist(i,j,l) = 0.
313          do nt = 1,ntracer          do nt = 1,ntracerin
314          dqmoist(i,j,l,nt) = 0.          dqmoist(i,j,l,nt) = 0.
315          enddo          enddo
316        enddo        enddo
# Line 330  C ************************************** Line 329  C **************************************
329    
330         CALL STRIP (  pigather, SP      ,im*jm,ISTRIP,1 ,NN )         CALL STRIP (  pigather, SP      ,im*jm,ISTRIP,1 ,NN )
331         CALL STRIP ( pkzgather, PLK     ,im*jm,ISTRIP,lm,NN )         CALL STRIP ( pkzgather, PLK     ,im*jm,ISTRIP,lm,NN )
332         CALL STRIP ( pkegather, PLKE    ,im*jm,ISTRIP,lm,NN )         CALL STRIP ( pkegather, PLKE    ,im*jm,ISTRIP,lm+1,NN )
333           CALL STRIP ( plzgather, PL      ,im*jm,ISTRIP,lm,NN )
334           CALL STRIP ( plegather, PLE     ,im*jm,ISTRIP,lm+1,NN )
335           CALL STRIP (  dpgather, dp      ,im*jm,ISTRIP,lm,NN )
336         CALL STRIP (  thgather, TH      ,im*jm,ISTRIP,lm,NN )         CALL STRIP (  thgather, TH      ,im*jm,ISTRIP,lm,NN )
337         CALL STRIP (  shgather, SHL     ,im*jm,ISTRIP,lm,NN )         CALL STRIP (  shgather, SHL     ,im*jm,ISTRIP,lm,NN )
338         CALL STRINT( levgather, pbl     ,im*jm,ISTRIP,1 ,NN )         CALL STRINT( levgather, pbl     ,im*jm,ISTRIP,1 ,NN )
339    
340         do nt = 1,ntracer-ptracer         do nt = 1,ntracer-ptracer
341         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 )
342         enddo         enddo
343    
       do l = 1,lm  
       do i = 1,istrip  
        PL(I,L) =  SIG(L)*SP(I) + PTOP  
       PLE(I,L) = SIGE(L)*SP(I) + PTOP  
       enddo  
       enddo  
   
       do i = 1,istrip  
       PLE(I,lm+1) = SP(I) + PTOP  
       enddo  
   
344  C **********************************************************************  C **********************************************************************
345  C ****        SETUP FOR RAS CUMULUS PARAMETERIZATION                ****  C ****        SETUP FOR RAS CUMULUS PARAMETERIZATION                ****
346  C **********************************************************************  C **********************************************************************
# Line 445  c ------------------------------- Line 436  c -------------------------------
436         ENDDO         ENDDO
437         DO L=2,lm         DO L=2,lm
438         DO I=num,num+nindeces(nsubcl)-1         DO I=num,num+nindeces(nsubcl)-1
439          TMP5(I,L) = PLKE(I,L-1)*P0KINV          TMP5(I,L) = PLKE(I,L)*P0KINV
440         ENDDO         ENDDO
441         ENDDO         ENDDO
442         DO  I=num,num+nindeces(nsubcl)-1         DO  I=num,num+nindeces(nsubcl)-1
443          TMP4(I,lm+1) = PLE (I,lm+1)          TMP4(I,lm+1) = PLE (I,lm+1)
444          TMP5(I,lm+1) = PLKE(I,lm)*P0KINV          TMP5(I,lm+1) = PLKE(I,lm+1)*P0KINV
445         ENDDO         ENDDO
446         DO 113 I=num,num+nindeces(nsubcl)-1         DO 113 I=num,num+nindeces(nsubcl)-1
447          TMP4(I,NSUBCL+1) = PLE (I,lm+1)          TMP4(I,NSUBCL+1) = PLE (I,lm+1)
448          TMP5(I,NSUBCL+1) = PLKE(I,lm)*P0KINV          TMP5(I,NSUBCL+1) = PLKE(I,lm+1)*P0KINV
449   113   CONTINUE   113   CONTINUE
450    
451        do i=num,num+nindeces(nsubcl)-1        do i=num,num+nindeces(nsubcl)-1
# Line 491  C Top level of atan func above this rh_t Line 482  C Top level of atan func above this rh_t
482           rhcrit(i,L) = 1.           rhcrit(i,L) = 1.
483         enddo         enddo
484         do L = 1, nsubcl-1         do L = 1, nsubcl-1
485          pcheck = (1000.-ptop)*sig(L) + ptop          pcheck = pl(i,L)
486          if (pcheck .le. pup) then          if (pcheck .le. pup) then
487           rhcrit(i,L) = rhmin           rhcrit(i,L) = rhmin
488          else          else
489           ppbl = (1000.-ptop)*sig(nsubcl) + ptop           ppbl = pl(i,nsubcl)
490           rhcrit(i,L) = rhmin + (1.-rhmin)/(19.) *           rhcrit(i,L) = rhmin + (1.-rhmin)/(19.) *
491       .      ((atan( (2.*(pcheck-pup)/(ppbl-pup)-1.) *       .      ((atan( (2.*(pcheck-pup)/(ppbl-pup)-1.) *
492       .       tan(20.*pi/21.-0.5*pi) )       .       tan(20.*pi/21.-0.5*pi) )
# Line 516  c -------------------------------------- Line 507  c --------------------------------------
507        enddo        enddo
508    
509        CALL RAS ( NN,istrip,nindeces(nsubcl),NLRAS,NLTOP,lm,TMSTP        CALL RAS ( NN,istrip,nindeces(nsubcl),NLRAS,NLTOP,lm,TMSTP
510       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)
511       2, TMP4(num,NLTOP), TMP5(num,NLTOP),rnd, ncrnd, PCPEN(num,NLTOP)       2, TMP4(num,NLTOP), TMP5(num,NLTOP),rnd, ncrnd, PCPEN(num,NLTOP)
512       3, CLBOTH(num,NLTOP), CLFRAC(num,NLTOP)       3, CLBOTH(num,NLTOP), CLFRAC(num,NLTOP)
513       4, cldmas(num,nltop), detrain(num,nltop)       4, cldmas(num,nltop), detrain(num,nltop)
# Line 525  c -------------------------------------- Line 516  c --------------------------------------
516  c Compute Diagnostic CLDMAS in RAS Subcloud Layers  c Compute Diagnostic CLDMAS in RAS Subcloud Layers
517  c ------------------------------------------------  c ------------------------------------------------
518         do L=nsubcl,lm         do L=nsubcl,lm
         dum = dsig(L)/(1.0-sige(nsubcl))  
519         do I=num,num+nindeces(nsubcl)-1         do I=num,num+nindeces(nsubcl)-1
520            dum = dp(i,L)/(ple(i,lm+1)-ple(i,nsubcl))
521          cldmas(i,L) = cldmas(i,L-1) - dum*cldmas(i,nsubcl-1)          cldmas(i,L) = cldmas(i,L-1) - dum*cldmas(i,nsubcl-1)
522         enddo         enddo
523         enddo         enddo
# Line 640  C ************************************** Line 631  C **************************************
631        ENDDO        ENDDO
632        ENDDO        ENDDO
633    
634         CALL RNEVP (NN,ISTRIP,lm,TL,SHL,PCPEN,PL,CLFRAC,SP,DSIG,PLKE,         CALL RNEVP (NN,ISTRIP,lm,TL,SHL,PCPEN,PL,CLFRAC,SP,DP,PLKE,
635       .  PLK,TH,TMP1,TMP2,TMP3,ITMP1,ITMP2,PCNET,PRECIP,       .  PLK,TH,TMP1,TMP2,TMP3,ITMP1,ITMP2,PCNET,PRECIP,
636       .  CLSBTH,TMSTP,1.,cp,grav,alhl,gamfac,cldlz,rhcrit,offset,alpha)       .  CLSBTH,TMSTP,one,cp,grav,alhl,gamfac,cldlz,rhcrit,offset,alpha)
637    
638  C **********************************************************************  C **********************************************************************
639  C ****                     TENDENCY UPDATES                         ****  C ****                     TENDENCY UPDATES                         ****
# Line 729  c  snow algorthm: Line 720  c  snow algorthm:
720  c  if temperature profile from the surface level to 700 mb  c  if temperature profile from the surface level to 700 mb
721  c  uniformaly c  below zero, then precipitation (total) is  c  uniformaly c  below zero, then precipitation (total) is
722  c  snowfall.  Else there is no snow.  c  snowfall.  Else there is no snow.
 c  For version of level 70, the sigma level corresponding  
 c  to 700mb (assume the surface pressure is 1000mb) is  
 c  the 13th level from the surface  
 c   Runhua Yang Aug. 24 98  
 c  added pcheck for 700mb - sharon sept 18, 1998  
723  c-------------------------------------------------------  c-------------------------------------------------------
724    
         pup = 700.  
         do L = lm, 1, -1  
           pcheck = (1000.-ptop)*sig(L) + ptop  
           if (pcheck .ge. pup) then  
             lup = L  
           endif  
         enddo  
725          do i = 1,istrip          do i = 1,istrip
726            snowcrit=0            snowcrit=0
727            do l=lup,lm            do l=lup,lm
# Line 812  c ------------ Line 791  c ------------
791       .                                              cldsr(1,1,L),im*jm)       .                                              cldsr(1,1,L),im*jm)
792        enddo        enddo
793    
794  c Tracers  c General Tracers
795  c -------  c ---------------
796        do nt = 1,ntracer-ptracer        do nt = 1,ntracerin-ptracer
797         do L = 1,lm         do L = 1,lm
798         call back2grd (delugather(1,L,nt),pblindex,         call back2grd (delugather(1,L,nt),pblindex,
799       .                                 dqmoist(1,1,L,ptracer+nt),im*jm)       .                                 dqmoist(1,1,L,ptracer+nt),im*jm)
800         enddo         enddo
801        enddo        enddo
802    
803          if(cumfric) then
804    
805  C **********************************************************************  c U and V for cumulus friction
806  C                          BUMP DIAGNOSTICS  c ----------------------------
807  C **********************************************************************        do L = 1,lm
808           call back2grd (delugather(1,L,ntracerin-ptracer+1),pblindex,
809  c Determine Level Indices for Low-Mid-High Cloud Regions       .                                 dumoist(1,1,L),im*jm)
810  c ------------------------------------------------------         call back2grd (delugather(1,L,ntracerin-ptracer+2),pblindex,
811        lowlevel = lm       .                                 dvmoist(1,1,L),im*jm)
       midlevel = lm  
       do L = lm-1,1,-1  
       pcheck = (1000.-ptop)*sig(l) + ptop  
       if (pcheck.gt.700.0) lowlevel = L  
       if (pcheck.gt.400.0) midlevel = L  
812        enddo        enddo
813    
814    C Remove pi-weighting for u and v tendencies
 c Clear-Sky (Above 400mb) Temperature  
 c -----------------------------------  
       if( itmpuclr.ne.0 .or. isphuclr.ne.0 ) then  
815        do j = 1,jm        do j = 1,jm
816        do i = 1,im        do i = 1,im
817        totcld(i,j) = 0.0         tmpimjm(i,j) = 1./pz(i,j)
818        enddo        enddo
819        enddo        enddo
820        do L = 1,midlevel        do L = 1,lm
821        do j = 1,jm        do j = 1,jm
822        do i = 1,im        do i = 1,im
823         if(cldls(i,j,L).ne.0.0.or.cpen(i,j,L).ne.0.0)totcld(i,j) = 1.0         dumoist(i,j,L) = dumoist(i,j,L) * tmpimjm(i,j)
824           dumoist(i,j,L) = dumoist(i,j,L) * tmpimjm(i,j)
825        enddo        enddo
826        enddo        enddo
827        enddo        enddo
828        do L = 1,lm  
        if( itmpuclr.ne.0 ) then  
         do i = 1,im*jm  
         if( totcld(i,1).eq.0.0 ) then  
          qdiag(i,1,itmpuclr +L-1,bi,bj) =  
      .         qdiag(i,1,itmpuclr +L-1,bi,bj) + tz(i,1,L)*pkzgather(i,L)  
          qdiag(i,1,itmpuclrc+L-1,bi,bj) =  
      .                            qdiag(i,1,itmpuclrc+L-1,bi,bj)+1.0  
         endif  
         enddo  
        endif  
   
        if( isphuclr.ne.0 ) then  
         do i = 1,im*jm  
         if( totcld(i,1).eq.0.0 ) then  
          qdiag(i,1,isphuclr +L-1,bi,bj) =  
      .              qdiag(i,1,isphuclr +L-1,bi,bj) + qz(i,1,L,1)*1000.0  
          qdiag(i,1,isphuclrc+L-1,bi,bj) =  
      .                      qdiag(i,1,isphuclrc+L-1,bi,bj) + 1.0  
         endif  
         enddo  
        endif  
       enddo  
829        endif        endif
830    
831    C **********************************************************************
832    C                          BUMP DIAGNOSTICS
833    C **********************************************************************
834    
835    
836  c Sub-Cloud Layer  c Sub-Cloud Layer
837  c -------------------------  c -------------------------
838        if( ipsubcld.ne.0 ) then        if( ipsubcld.ne.0 ) then
# Line 908  c Moist Processes Heating Rate Line 864  c Moist Processes Heating Rate
864  c ----------------------------  c ----------------------------
865        if(imoistt.gt.0) then        if(imoistt.gt.0) then
866        do L = 1,lm        do L = 1,lm
867        do i = 1,im*jm        do j = 1,jm
868        qdiag(i,1,imoistt+L-1,bi,bj) = qdiag(i,1,imoistt+L-1,bi,bj) +        do i = 1,im
869       .                      (dtmoist(i,1,L)*sday*pkzgather(i,L)/pz(i,1))         indgath = (j-1)*im + i
870          qdiag(i,j,imoistt+L-1,bi,bj) = qdiag(i,j,imoistt+L-1,bi,bj) +
871         .    (dtmoist(i,j,L)*sday*pkzgather(indgath,L)/pz(i,j))
872          enddo
873        enddo        enddo
874        enddo        enddo
875        endif        endif
# Line 928  c ------------------------------- Line 887  c -------------------------------
887        enddo        enddo
888        endif        endif
889    
890    c Moist Processes Change in U-Momentum (Cumulus Friction)
891    c ------------------------------------------------------
892          if(iudiag1.gt.0) then
893          do L = 1,lm
894          do j = 1,jm
895          do i = 1,im
896           indgath = (j-1)*im + i
897          qdiag(i,j,iudiag1+L-1,bi,bj) = qdiag(i,j,iudiag1+L-1,bi,bj) +
898         .    dumoist(i,j,L)*sday
899          enddo
900          enddo
901          enddo
902          endif
903    
904    c Moist Processes Change in V-Momentum (Cumulus Friction)
905    c ------------------------------------------------------
906          if(iudiag2.gt.0) then
907          do L = 1,lm
908          do j = 1,jm
909          do i = 1,im
910           indgath = (j-1)*im + i
911          qdiag(i,j,iudiag2+L-1,bi,bj) = qdiag(i,j,iudiag2+L-1,bi,bj) +
912         .    dvmoist(i,j,L)*sday
913          enddo
914          enddo
915          enddo
916          endif
917    
918  c Cloud Mass Flux  c Cloud Mass Flux
919  c ---------------  c ---------------
920        if(icldmas.gt.0) then        if(icldmas.gt.0) then
921        do L = 1,lm        do L = 1,lm
922        do i = 1,im*jm        do j = 1,jm
923        qdiag(i,1,icldmas+L-1,bi,bj) = qdiag(i,1,icldmas+L-1,bi,bj) +        do i = 1,im
924       .                                                  tmpgather(i,L)         indgath = (j-1)*im + i
925          qdiag(i,j,icldmas+L-1,bi,bj) = qdiag(i,j,icldmas+L-1,bi,bj) +
926         .                               tmpgather(indgath,L)
927          enddo
928        enddo        enddo
929        enddo        enddo
930        endif        endif
# Line 943  c Detrained Cloud Mass Flux Line 933  c Detrained Cloud Mass Flux
933  c -------------------------  c -------------------------
934        if(idtrain.gt.0) then        if(idtrain.gt.0) then
935        do L = 1,lm        do L = 1,lm
936        do i = 1,im*jm        do j = 1,jm
937        qdiag(i,1,idtrain+L-1,bi,bj) = qdiag(i,1,idtrain+L-1,bi,bj) +        do i = 1,im
938       .                                                  pkegather(i,L)         indgath = (j-1)*im + i
939          qdiag(i,j,idtrain+L-1,bi,bj) = qdiag(i,j,idtrain+L-1,bi,bj) +
940         .                                pkegather(indgath,L)
941          enddo
942        enddo        enddo
943        enddo        enddo
944        endif        endif
# Line 954  c Grid-Scale Condensational Heating Rate Line 947  c Grid-Scale Condensational Heating Rate
947  c --------------------------------------  c --------------------------------------
948        if(idtls.gt.0) then        if(idtls.gt.0) then
949        do L = 1,lm        do L = 1,lm
950        do i = 1,im*jm        do j = 1,jm
951        qdiag(i,1,idtls+L-1,bi,bj) = qdiag(i,1,idtls+L-1,bi,bj) +        do i = 1,im
952       .                                                  deltrnev(i,L)         indgath = (j-1)*im + i
953          qdiag(i,j,idtls+L-1,bi,bj) = qdiag(i,j,idtls+L-1,bi,bj) +
954         .                               deltrnev(indgath,L)
955          enddo
956        enddo        enddo
957        enddo        enddo
958        endif        endif
# Line 965  c Grid-Scale Condensational Moistening R Line 961  c Grid-Scale Condensational Moistening R
961  c -----------------------------------------  c -----------------------------------------
962        if(idqls.gt.0) then        if(idqls.gt.0) then
963        do L = 1,lm        do L = 1,lm
964        do i = 1,im*jm        do j = 1,jm
965        qdiag(i,1,idqls+L-1,bi,bj) = qdiag(i,1,idqls+L-1,bi,bj) +        do i = 1,im
966       .                                                  delqrnev(i,L)         indgath = (j-1)*im + i
967          qdiag(i,j,idqls+L-1,bi,bj) = qdiag(i,j,idqls+L-1,bi,bj) +
968         .                                delqrnev(indgath,L)
969          enddo
970        enddo        enddo
971        enddo        enddo
972        endif        endif
# Line 988  c ------------------- Line 987  c -------------------
987  c Convective Precipitation  c Convective Precipitation
988  c ------------------------  c ------------------------
989        if(iprecon.gt.0) then        if(iprecon.gt.0) then
990        do i = 1,im*jm        do j = 1,jm
991        qdiag(i,1,iprecon,bi,bj) = qdiag(i,1,iprecon,bi,bj) +        do i = 1,im
992       .                                         raincgath(i)*sday*tminv         indgath = (j-1)*im + i
993          qdiag(i,j,iprecon,bi,bj) = qdiag(i,j,iprecon,bi,bj) +
994         .                      raincgath(indgath)*sday*tminv
995          enddo
996        enddo        enddo
997        endif        endif
998    
# Line 1031  c ------------------------------------ Line 1033  c ------------------------------------
1033    
1034        do L = 1,lm        do L = 1,lm
1035        do i = 1,im*jm        do i = 1,im*jm
1036         plev = sig(L)*pz(i,1)+ptop         plev = pl(i,L)
1037    
1038  c Compute Time-averaged Cloud and Water Amounts for Longwave Radiation  c Compute Time-averaged Cloud and Water Amounts for Longwave Radiation
1039  c --------------------------------------------------------------------  c --------------------------------------------------------------------
# Line 1093  c -------------------------------------- Line 1095  c --------------------------------------
1095        enddo        enddo
1096        enddo        enddo
1097    
1098  c Compute Instantanious Total 2-D Cloud Fraction  c Compute Instantaneous Total 2-D Cloud Fraction
1099  c ----------------------------------------------  c ----------------------------------------------
1100        do j = 1,jm        do j = 1,jm
1101        do i = 1,im        do i = 1,im
# Line 1144  C ************************************** Line 1146  C **************************************
1146         nlwcld   = nlwcld   + 1         nlwcld   = nlwcld   + 1
1147         nswcld   = nswcld   + 1         nswcld   = nswcld   + 1
1148    
1149    #ifdef ALLOW_DIAGNOSTICS
1150           if( (bi.eq.1) .and. (bj.eq.1) ) then
1151         nmoistt  = nmoistt  + 1         nmoistt  = nmoistt  + 1
1152         nmoistq  = nmoistq  + 1         nmoistq  = nmoistq  + 1
1153         npreacc  = npreacc  + 1         npreacc  = npreacc  + 1
# Line 1154  C ************************************** Line 1158  C **************************************
1158    
1159         ndtls  = ndtls  + 1         ndtls  = ndtls  + 1
1160         ndqls  = ndqls  + 1         ndqls  = ndqls  + 1
1161           endif
1162    #endif
1163    
1164        RETURN        RETURN
1165        END        END
1166        SUBROUTINE RAS( NN, LEN, LENC, K, NLTOP, nlayr, DT        SUBROUTINE RAS( NN, LNG, LENC, K, NLTOP, nlayr, DT
1167       *,               UOI, ntracer, POI, QOI, PRS, PRJ, rnd, ncrnd       *,      UOI, ntracedim, ntracer, POI, QOI, PRS, PRJ, rnd, ncrnd
1168       *,               RAINS, CLN, CLF, cldmas, detrain       *,      RAINS, CLN, CLF, cldmas, detrain
1169       *,               cp,grav,rkappa,alhl,rhfrac,rasmax )       *,      cp,grav,rkappa,alhl,rhfrac,rasmax )
1170  C  C
1171  C*********************************************************************  C*********************************************************************
 C*********************** ARIES   MODEL *******************************  
1172  C********************* SUBROUTINE  RAS   *****************************  C********************* SUBROUTINE  RAS   *****************************
1173  C********************** 16 MARCH   1988 ******************************  C********************** 16 MARCH   1988 ******************************
1174  C*********************************************************************  C*********************************************************************
1175  C  C
1176          implicit none
1177    
1178    C Argument List
1179          integer nn,lng,lenc,k,nltop,nlayr
1180          integer ntracedim, ntracer
1181          integer ncrnd
1182          _RL dt
1183          _RL UOI(lng,nlayr,ntracedim),   POI(lng,K)
1184          _RL QOI(lng,K), PRS(lng,K+1), PRJ(lng,K+1)
1185          _RL rnd(ncrnd)
1186          _RL RAINS(lng,K), CLN(lng,K), CLF(lng,K)
1187          _RL cldmas(lng,K), detrain(lng,K)
1188          _RL cp,grav,rkappa,alhl,rhfrac(lng),rasmax
1189    
1190    C Local Variables
1191          _RL TCU(lng,K), QCU(lng,K)
1192          _RL ucu(lng,K,ntracedim)
1193          _RL ALF(lng,K), BET(lng,K), GAM(lng,K)
1194         *,         ETA(lng,K), HOI(lng,K)
1195         *,         PRH(lng,K), PRI(lng,K)
1196          _RL HST(lng,K), QOL(lng,K), GMH(lng,K)
1197    
1198          _RL TX1(lng), TX2(lng), TX3(lng), TX4(lng), TX5(lng)
1199         *,         TX6(lng), TX7(lng), TX8(lng), TX9(lng)
1200         *,         TX11(lng), TX12(lng), TX13(lng), TX14(lng,ntracedim)
1201         *,         TX15(lng)
1202         *,         WFN(lng)
1203          integer IA1(lng), IA2(lng), IA3(lng)
1204          _RL cloudn(lng), pcu(lng)
1205    
1206          integer krmin,icm
1207          _RL rknob, cmb2pa
1208        PARAMETER (KRMIN=01)        PARAMETER (KRMIN=01)
1209        PARAMETER (ICM=1000)        PARAMETER (ICM=1000)
1210        PARAMETER (CMB2PA=100.0)        PARAMETER (CMB2PA=100.0)
1211        PARAMETER (rknob = 10.)        PARAMETER (rknob = 10.)
 C  
       integer ntracer  
       integer nltop,nlayr  
       DIMENSION UOI(len,nlayr,ntracer),   POI(len,K)  
       DIMENSION QOI(len,K), PRS(len,K+1), PRJ(len,K+1)  
       dimension rnd(ncrnd)  
 C  
       DIMENSION RAINS(len,K), CLN(len,K), CLF(len,K)  
       DIMENSION cldmas(len,K), detrain(len,K)  
       DIMENSION TCU(len,K), QCU(len,K)  
       real ucu(len,K,ntracer)  
       DIMENSION ALF(len,K), BET(len,K), GAM(len,K)  
      *,         ETA(len,K), HOI(len,K)  
      *,         PRH(len,K), PRI(len,K)  
       DIMENSION HST(len,K), QOL(len,K), GMH(len,K)  
   
       DIMENSION TX1(len), TX2(len), TX3(len), TX4(len), TX5(len)  
      *,         TX6(len), TX7(len), TX8(len), TX9(len)  
      *,         TX11(len), TX12(len), TX13(len), TX14(len,ntracer)  
      *,         TX15(len), TX16(len)  
      *,         WFN(len), IA1(len), IA2(len), IA3(len)  
       DIMENSION cloudn(len), pcu(len)  
1212    
1213        real rhfrac(len),rasmax        integer IC(ICM),   IRND(icm)
1214          _RL cmass(lng,K)
       DIMENSION IC(ICM),   IRND(icm)  
       dimension cmass(len,K)  
1215        LOGICAL SETRAS        LOGICAL SETRAS
1216    
1217           do L = 1,k        integer i,L,nc,ib,nt
1218           do I = 1,LENC        integer km1,kp1,kprv,kcr,kfx,ncmx
1219           rains(i,l) = 0.        _RL p00, crtmsf, frac, rasblf
1220           enddo  
1221           enddo        do L = 1,k
1222          do I = 1,LENC
1223           rains(i,l) = 0.
1224          enddo
1225          enddo
1226    
1227        p00 = 1000.        p00 = 1000.
1228        crtmsf = 0.        crtmsf = 0.
# Line 1224  C Line 1241  C
1241         KPRV  = KM1         KPRV  = KM1
1242  C Removed KRMAX parameter  C Removed KRMAX parameter
1243         KCR   = MIN(KM1,nlayr-2)             KCR   = MIN(KM1,nlayr-2)    
1244         KFX   = KM1 - KCR  CCC    KFX   = KM1 - KCR
1245           KFX   = KM1
1246         NCMX  = KFX + NCRND         NCMX  = KFX + NCRND
1247  C  C
1248         IF (KFX .GT. 0) THEN         IF (KFX .GT. 0) THEN
# Line 1259  c ------------------------------- Line 1277  c -------------------------------
1277        cloudn(i) = 0.0        cloudn(i) = 0.0
1278        enddo        enddo
1279    
1280         CALL CLOUD(nn,LEN, LENC, K, NLTOP, nlayr, IB, RASBLF,SETRAS,FRAC         CALL CLOUD(nn,lng, LENC, K, NLTOP, nlayr, IB, RASBLF,SETRAS,FRAC
1281       *,           CP,  ALHL, RKAPPA, GRAV, P00, CRTMSF       *,           CP,  ALHL, RKAPPA, GRAV, P00, CRTMSF
1282       *,           POI, QOI, UOI, Ntracer, PRS, PRJ       *,           POI, QOI, UOI, ntracedim, Ntracer, PRS, PRJ
1283       *,           PCU, CLOUDN, TCU, QCU, UCU, CMASS       *,           PCU, CLOUDN, TCU, QCU, UCU, CMASS
1284       *,           ALF, BET, GAM, PRH, PRI, HOI, ETA       *,           ALF, BET, GAM, PRH, PRI, HOI, ETA
1285       *,           HST, QOL, GMH       *,           HST, QOL, GMH
# Line 1332  c -------------------------------------- Line 1350  c --------------------------------------
1350    
1351        RETURN        RETURN
1352        END        END
   
1353        subroutine rndcloud (iras,nrnd,rnd,myid)        subroutine rndcloud (iras,nrnd,rnd,myid)
1354        implicit none        implicit none
1355        integer n,iras,nrnd,myid        integer n,iras,nrnd,myid
1356        real random_numbx        _RL random_numbx
1357        real rnd(nrnd)        _RL rnd(nrnd)
1358        integer irm        integer irm
1359        parameter (irm = 1000)        parameter (irm = 1000)
1360        real random(irm)        _RL random(irm)
1361        integer i,mcheck,numrand,iseed,index        integer i,mcheck,numrand,iseed,indx
1362        logical first        logical first
1363        data    first /.true./        data    first /.true./
1364        integer iras0        integer iras0
# Line 1352  c -------------------------------------- Line 1369  c --------------------------------------
1369         do i = 1,nrnd         do i = 1,nrnd
1370          rnd(i) = 0          rnd(i) = 0
1371         enddo         enddo
1372         if(first .and. myid.eq.0) print *,' NO RANDOM CLOUDS IN RAS '         if(first .and. myid.eq.1) print *,' NO RANDOM CLOUDS IN RAS '
1373         go to 100         go to 100
1374        endif        endif
1375    
# Line 1361  c -------------------------------------- Line 1378  c --------------------------------------
1378  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
1379  c ----------------------------------------------------------------------------  c ----------------------------------------------------------------------------
1380        if( first.and.(iras.gt.1) .or. iras.ne.iras0+1 )then        if( first.and.(iras.gt.1) .or. iras.ne.iras0+1 )then
1381         if( myid.eq.0 ) print *, 'Recreating Rand Numb Array in RNDCLOUD'         print *,' first ',first,' iras ',iras,' iras0 ',iras0
1382         if( myid.eq.0 ) print *, 'IRAS: ',iras,'  IRAS0: ',iras0         if( myid.eq.1 ) print *, 'Recreating Rand Numb Array in RNDCLOUD'
1383           if( myid.eq.1 ) print *, 'IRAS: ',iras,'  IRAS0: ',iras0
1384         numrand = mod(iras,irm/nrnd) * nrnd         numrand = mod(iras,irm/nrnd) * nrnd
1385         iseed   = iras * nrnd - numrand         iseed   = iras * nrnd - numrand
1386         call random_seedx(iseed)         call random_seedx(iseed)
1387         do i = 1,irm         do i = 1,irm
1388          random(i) = random_numbx()          random(i) = random_numbx(iseed)
1389         enddo         enddo
1390         index = (iras-1)*nrnd         indx = (iras-1)*nrnd
1391    
1392  c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0)  c Multiple Time In But have Used Up all 1000 numbers (MCHECK.EQ.0)
1393  c ----------------------------------------------------------------  c ----------------------------------------------------------------
# Line 1377  c -------------------------------------- Line 1395  c --------------------------------------
1395            iseed = (iras-1)*nrnd            iseed = (iras-1)*nrnd
1396            call random_seedx(iseed)            call random_seedx(iseed)
1397            do i = 1,irm            do i = 1,irm
1398             random(i) = random_numbx()             random(i) = random_numbx(iseed)
1399            enddo            enddo
1400            index = iseed            indx = iseed
1401    
1402  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)
1403  c --------------------------------------------------------------------  c --------------------------------------------------------------------
1404        else        else
1405            index = (iras-1)*nrnd            indx = (iras-1)*nrnd
1406        endif        endif
1407    
1408            index = mod(index,irm)            indx = mod(indx,irm)
1409        if( index+nrnd.gt.1000 ) index=1000-nrnd        if( indx+nrnd.gt.1000 ) indx=1000-nrnd
1410    
1411        do n = 1,nrnd        do n = 1,nrnd
1412         rnd(n) = random(index+n)         rnd(n) = random(indx+n)
1413        enddo        enddo
1414    
1415   100  continue   100  continue
# Line 1399  c -------------------------------------- Line 1417  c --------------------------------------
1417        iras0 = iras        iras0 = iras
1418        return        return
1419        end        end
1420          function random_numbx(iseed)
       real function random_numbx()  
1421        implicit none        implicit none
1422  #if CRAY        integer iseed
1423        real ranf        real *8 seed,port_rand
1424          _RL random_numbx
1425          random_numbx = 0
1426    #ifdef CRAY
1427          _RL ranf
1428        random_numbx = ranf()        random_numbx = ranf()
1429  #endif  #else
1430  #if SGI  #ifdef SGI
1431        real rand        _RL rand
1432        random_numbx = rand()        random_numbx = rand()
1433  #endif  #endif
1434          random_numbx = port_rand(seed)
1435    #endif
1436        return        return
1437        end        end
1438        subroutine random_seedx (iseed)        subroutine random_seedx (iseed)
1439        implicit none        implicit none
1440        integer  iseed        integer  iseed
1441  #if CRAY  #ifdef CRAY
1442        call ranset (iseed)        call ranset (iseed)
1443  #endif  #endif
1444  #if SGI  #ifdef SGI
1445        integer*4   seed        integer*4   seed
1446                    seed = iseed                    seed = iseed
1447        call srand (seed)        call srand (seed)
1448  #endif  #endif
1449        return        return
1450        end        end
1451          SUBROUTINE CLOUD(nn,lng, LENC, K, NLTOP, nlayr, IC, RASALF
       SUBROUTINE CLOUD(nn,LEN, LENC, K, NLTOP, nlayr, IC, RASALF,  
1452       *,                 SETRAS, FRAC       *,                 SETRAS, FRAC
1453       *,                 CP,  ALHL, RKAP, GRAV, P00, CRTMSF       *,                 CP,  ALHL, RKAP, GRAV, P00, CRTMSF
1454       *,                 POI, QOI, UOI, Ntracer, PRS,  PRJ       *,                 POI, QOI, UOI, ntracedim, Ntracer, PRS,  PRJ
1455       *,                 PCU, CLN, TCU, QCU, UCU, CMASS       *,                 PCU, CLN, TCU, QCU, UCU, CMASS
1456       *,                 ALF, BET, GAM, PRH, PRI, HOL, ETA       *,                 ALF, BET, GAM, PRH, PRI, HOL, ETA
1457       *,                 HST, QOL, GMH       *,                 HST, QOL, GMH
# Line 1468  C Line 1490  C
1490  C  Input:  C  Input:
1491  C  ------  C  ------
1492  C  C
1493  C     LEN     : The inner dimension of update and input arrays.  C     lng     : The inner dimension of update and input arrays.
1494  C  C
1495  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.
1496  C               RAS works on the first LENC of the LEN soundings  C               RAS works on the first LENC of the lng soundings
1497  C               passed. This allows working on pieces of the world  C               passed. This allows working on pieces of the world
1498  C               say for multitasking, without declaring temporary arrays  C               say for multitasking, without declaring temporary arrays
1499  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
1500  C               version. An F90 version would have to allow more  C               version. An F90 version would have to allow more
1501  C               flexibility in the argument declarations.  Obviously  C               flexibility in the argument declarations.  Obviously
1502  C               (LENC<=LEN).    C               (LENC<=lng).  
1503  C  C
1504  C     K       : Number of vertical layers (increasing downwards).  C     K       : Number of vertical layers (increasing downwards).
1505  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 1508  C     CRTMSF  : Critical value of mass f Line 1530  C     CRTMSF  : Critical value of mass f
1530  C               the detrainment layer of that cloud-type is assumed.  C               the detrainment layer of that cloud-type is assumed.
1531  C               Affects only cloudiness calculation.  C               Affects only cloudiness calculation.
1532  C  C
1533  C     POI     : 2D array of dimension (LEN,K) containing potential  C     POI     : 2D array of dimension (lng,K) containing potential
1534  C               temperature. Updated but not initialized by RAS.  C               temperature. Updated but not initialized by RAS.
1535  C  C
1536  C     QOI     : 2D array of dimension (LEN,K) containing specific  C     QOI     : 2D array of dimension (lng,K) containing specific
1537  C               humidity. Updated but not initialized by RAS.  C               humidity. Updated but not initialized by RAS.
1538  C  C
1539  C     UOI     : 3D array of dimension (LEN,K,NTRACER) containing tracers  C     UOI     : 3D array of dimension (lng,K,NTRACER) containing tracers
1540  C               Updated but not initialized by RAS.  C               Updated but not initialized by RAS.
1541  C  C
1542  C     PRS     : 2D array of dimension (LEN,K+1) containing pressure  C     PRS     : 2D array of dimension (lng,K+1) containing pressure
1543  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
1544  C               atmosphere to the bottom. Not modified.  C               atmosphere to the bottom. Not modified.
1545  C  C
1546  C     PRJ     : 2D array of dimension (LEN,K+1) containing (PRS/P00) **  C     PRJ     : 2D array of dimension (lng,K+1) containing (PRS/P00) **
1547  C               RKAP.  i.e. Exner function at layer edges. Not modified.  C               RKAP.  i.e. Exner function at layer edges. Not modified.
1548  C  C
1549  C     rhfrac  : 1D array of dimension (LEN) containing a rel.hum. scaling  C     rhfrac  : 1D array of dimension (lng) containing a rel.hum. scaling
1550  C               fraction. Not modified.  C               fraction. Not modified.
1551  C  C
1552  C  Output:  C  Output:
1553  C  -------  C  -------
1554  C  C
1555  C     PCU     : 1D array of length LEN containing accumulated  C     PCU     : 1D array of length lng containing accumulated
1556  C               precipitation in mm/sec.  C               precipitation in mm/sec.
1557  C  C
1558  C     CLN     : 2D array of dimension (LEN,K) containing cloudiness  C     CLN     : 2D array of dimension (lng,K) containing cloudiness
1559  C               Note:  CLN is bumped but NOT initialized  C               Note:  CLN is bumped but NOT initialized
1560  C  C
1561  C     TCU     : 2D array of dimension (LEN,K) containing accumulated  C     TCU     : 2D array of dimension (lng,K) containing accumulated
1562  C               convective heating (K/sec).  C               convective heating (K/sec).
1563  C  C
1564  C     QCU     : 2D array of dimension (LEN,K) containing accumulated  C     QCU     : 2D array of dimension (lng,K) containing accumulated
1565  C               convective drying (kg/kg/sec).  C               convective drying (kg/kg/sec).
1566  C  C
1567  C     CMASS   : 2D array of dimension (LEN,K) containing the  C     CMASS   : 2D array of dimension (lng,K) containing the
1568  C               cloud mass flux (kg/sec). Filled from cloud top  C               cloud mass flux (kg/sec). Filled from cloud top
1569  C               to base.  C               to base.
1570  C  C
# Line 1560  C    IA, I1, and I2 are temporary intege Line 1582  C    IA, I1, and I2 are temporary intege
1582  C  C
1583  C  C
1584  C************************************************************************  C************************************************************************
1585  C        implicit none
1586  C  C Argument List declarations
1587          integer nn,lng,LENC,K,NLTOP,nlayr,ic,ntracedim, ntracer
1588          _RL rasalf
1589          LOGICAL SETRAS
1590          _RL frac, cp,  alhl, rkap, grav, p00, crtmsf
1591          _RL POI(lng,K),QOI(lng,K),PRS(lng,K+1),PRJ(lng,K+1)
1592          _RL uoi(lng,nlayr,ntracedim)
1593          _RL PCU(LENC), CLN(lng)
1594          _RL TCU(lng,K),  QCU(lng,K),  ucu(lng,k,ntracedim), CMASS(lng,K)
1595          _RL ALF(lng,K), BET(lng,K),  GAM(lng,K), PRH(lng,K), PRI(lng,K)
1596          _RL HOL(LENC,K), ETA(LENC,K), HST(LENC,K), QOL(LENC,K)
1597          _RL GMH(LENC,K)
1598          _RL TX1(LENC), TX2(LENC), TX3(LENC), TX4(LENC)
1599          _RL TX5(LENC), TX6(LENC), TX7(LENC), TX8(LENC)
1600          _RL ALM(LENC), WFN(LENC), AKM(LENC), QS1(LENC)
1601          _RL WLQ(LENC), CLF(LENC)
1602          _RL uht(lng,ntracedim)
1603          integer IA(LENC), I1(LENC),I2(LENC)
1604          _RL      rhfrac(lng)
1605    
1606    C Local Variables
1607          _RL daylen,half,one,zero,cmb2pa,rhmax
1608        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)
1609        PARAMETER (CMB2PA=100.0)        PARAMETER (CMB2PA=100.0)
1610        PARAMETER (RHMAX=0.9999)        PARAMETER (RHMAX=0.9999)
1611          _RL rkapp1,onebcp,albcp,onebg,cpbg,twobal
1612  C  C
1613        integer nltop,ntracer,nlayr        integer nt,km1,ic1,i,L,len1,len2,isav,len11,ii
1614        DIMENSION POI(LEN,K),  QOI(LEN,K),  PRS(LEN,K+1)        integer lena,lena1,lenb
1615       *,         PRJ(LEN,K+1)        _RL tem,tem1
      *,         TCU(LEN,K),  QCU(LEN,K),  CMASS(LEN,K), CLN(LEN)  
       real uoi(len,nlayr,ntracer)  
       DIMENSION ALF(LEN,K), BET(LEN,K),  GAM(LEN,K)  
      *,         PRH(LEN,K), PRI(LEN,K)  
       DIMENSION AKM(LENC),   WFN(LENC)  
       DIMENSION HOL(LENC,K), QOL(LENC,K),  ETA(LENC,K), HST(LENC,K)  
      *,         GMH(LENC,K), ALM(LENC),    WLQ(LENC),   QS1(LENC)  
      *,         TX1(LENC),   TX2(LENC), TX3(LENC),   TX4(LENC)  
      *,         TX5(LENC),   TX6(LENC), TX7(LENC),   TX8(LENC)  
      *,         CLF(LENC),   PCU(LENC)  
       DIMENSION IA(LENC),    I1(LENC),  I2(LENC)  
       real      rhfrac(len)  
       real ucu(len,k,ntracer),uht(len,ntracer)  
       LOGICAL SETRAS  
   
       integer nt  
1616    
1617  c Explicit Inline Directives  c Explicit Inline Directives
1618  c --------------------------  c --------------------------
1619  #if CRAY  #ifdef CRAY
1620  #if f77  #ifdef f77
1621  cfpp$ expand (qsat)  cfpp$ expand (qsat)
1622  #endif  #endif
1623  #endif  #endif
# Line 1601  cfpp$ expand (qsat) Line 1628  cfpp$ expand (qsat)
1628        ONEBG  = 1.0  / GRAV        ONEBG  = 1.0  / GRAV
1629        CPBG   = CP   * ONEBG        CPBG   = CP   * ONEBG
1630        TWOBAL = 2.0 / ALHL        TWOBAL = 2.0 / ALHL
1631    
1632  C  C
1633        KM1 = K  - 1        KM1 = K  - 1
1634        IC1 = IC + 1        IC1 = IC + 1
1635  C  C
1636  C      SETTIING ALF, BET, GAM, PRH, AND PRI : DONE ONLY WHEN SETRAS=.T.  C      SETTING ALF, BET, GAM, PRH, AND PRI : DONE ONLY WHEN SETRAS=.T.
1637  C  C
1638    
1639        IF (SETRAS) THEN        IF (SETRAS) THEN
# Line 1634  C Line 1662  C
1662  C  C
1663  C  C
1664        DO 10 L=1,K        DO 10 L=1,K
1665        DO 10 I=1,LEN        DO 10 I=1,lng
1666        TCU(I,L) = 0.0        TCU(I,L) = 0.0
1667        QCU(I,L) = 0.0        QCU(I,L) = 0.0
1668        CMASS(I,L) = 0.0        CMASS(I,L) = 0.0
# Line 1902  C Line 1930  C
1930        DO I=1,LENB        DO I=1,LENB
1931        II = I1(I)        II = I1(I)
1932        TEM    = ETA(I,L) - ETA(I,L+1)        TEM    = ETA(I,L) - ETA(I,L+1)
1933        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)
1934        ENDDO        ENDDO
1935        ENDDO        ENDDO
1936        ENDDO        ENDDO
# Line 2122  C Line 2150  C
2150  c Compute Tracer Tendencies  c Compute Tracer Tendencies
2151  c -------------------------  c -------------------------
2152        do nt = 1,ntracer        do nt = 1,ntracer
2153    c
2154  c Tracer Tendency at the Bottom Layer  c Tracer Tendency at the Bottom Layer
2155  c -----------------------------------  c -----------------------------------
2156        DO 995 I=1,LENB        DO 995 I=1,LENB
2157        II = I1(I)        II = I1(I)
2158        TEM    = half*TX5(I) * PRI(II,K)        TEM    = half*TX5(I) * PRI(II,K)
2159        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))
2160        ucu(II,K,nt) = TEM * TX1(I)        ucu(II,K,nt) = TEM * TX1(I)
2161    995 CONTINUE    995 CONTINUE
2162    c
2163  c Tracer Tendency at all other Levels  c Tracer Tendency at all other Levels
2164  c -----------------------------------  c -----------------------------------
2165        DO 1020 L=KM1,IC1,-1        DO 1020 L=KM1,IC1,-1
# Line 2146  c ----------------------------------- Line 2174  c -----------------------------------
2174        II = I1(I)        II = I1(I)
2175        ucu(II,L,nt) = TX3(I)        ucu(II,L,nt) = TX3(I)
2176   1020 CONTINUE   1020 CONTINUE
2177    
2178        DO 1030 I=1,LENB        DO 1030 I=1,LENB
2179        II = I1(I)        II = I1(I)
2180        IF (TX6(I) .GE. 1.0) THEN        IF (TX6(I) .GE. 1.0) THEN
# Line 2160  c ----------------------------------- Line 2188  c -----------------------------------
2188        II = I1(I)        II = I1(I)
2189        ucu(II,IC,nt) = TX1(I)        ucu(II,IC,nt) = TX1(I)
2190   1040 CONTINUE   1040 CONTINUE
2191    
2192        enddo        enddo
2193  C  C
2194  C     PENETRATIVE CONVECTION CALCULATION OVER  C     PENETRATIVE CONVECTION CALCULATION OVER
# Line 2168  C Line 2196  C
2196    
2197        RETURN        RETURN
2198        END        END
2199        SUBROUTINE RNCL(LEN, PL, RNO, CLF)        SUBROUTINE RNCL(lng, PL, RNO, CLF)
 C  
2200  C  C
2201  C*********************************************************************  C*********************************************************************
2202  C********************** Relaxed Arakawa-Schubert *********************  C********************** Relaxed Arakawa-Schubert *********************
2203  C************************   SUBROUTINE  RNCL  ************************  C************************   SUBROUTINE  RNCL  ************************
2204  C**************************** 23 July 1992 ***************************  C**************************** 23 July 1992 ***************************
2205  C*********************************************************************  C*********************************************************************
2206          implicit none
2207    C Argument List declarations
2208          integer lng
2209          _RL PL(lng),  RNO(lng), CLF(lng)
2210    
2211    C Local Variables
2212          _RL p5,p8,pt8,pt2,pfac,p4,p6,p7,p9,cucld,cfac
2213        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)
2214        PARAMETER (PFAC=PT2/(P8-P5))        PARAMETER (PFAC=PT2/(P8-P5))
 C  
2215        PARAMETER (P4=400.0,    P6=401.0)        PARAMETER (P4=400.0,    P6=401.0)
2216        PARAMETER (P7=700.0,    P9=900.0)        PARAMETER (P7=700.0,    P9=900.0)
2217        PARAMETER (CUCLD=0.5,CFAC=CUCLD/(P6-P4))        PARAMETER (CUCLD=0.5,CFAC=CUCLD/(P6-P4))
2218    
2219          integer i
2220  C  C
2221        DIMENSION PL(LEN),  RNO(LEN), CLF(LEN)        DO 10 I=1,lng
   
       DO 10 I=1,LEN  
2222                             rno(i) = 1.0                             rno(i) = 1.0
2223  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)) )
2224    
# Line 2213  CARIES Line 2245  CARIES
2245  C  C
2246        RETURN        RETURN
2247        END        END
2248        SUBROUTINE ACRITN ( LEN,PL,PLB,ACR )        SUBROUTINE ACRITN ( lng,PL,PLB,ACR )
2249    
2250  C*********************************************************************  C*********************************************************************
2251  C********************** Relaxed Arakawa-Schubert *********************  C********************** Relaxed Arakawa-Schubert *********************
# Line 2224  C****  Note:  Data obtained from January Line 2256  C****  Note:  Data obtained from January
2256  C****         from 4x5 46-layer GEOS Assimilation                *****  C****         from 4x5 46-layer GEOS Assimilation                *****
2257  C****                                                            *****  C****                                                            *****
2258  C*********************************************************************  C*********************************************************************
2259          implicit none
2260        real PL(LEN), PLB(LEN), ACR(LEN)  C Argument List declarations
2261          integer lng
2262          _RL PL(lng), PLB(lng), ACR(lng)
2263    
2264    C Local variables
2265          integer lma
2266        parameter  (lma=18)        parameter  (lma=18)
2267        real      p(lma)        _RL p(lma)
2268        real      a(lma)        _RL a(lma)
2269          integer i,L
2270          _RL temp
2271    
2272        data p  / 93.81, 111.65, 133.46, 157.80, 186.51,        data p  / 93.81, 111.65, 133.46, 157.80, 186.51,
2273       .         219.88, 257.40, 301.21, 352.49, 409.76,       .         219.88, 257.40, 301.21, 352.49, 409.76,
# Line 2243  C*************************************** Line 2281  C***************************************
2281    
2282    
2283        do L=1,lma-1        do L=1,lma-1
2284        do i=1,len        do i=1,lng
2285           if( pl(i).ge.p(L)   .and.           if( pl(i).ge.p(L)   .and.
2286       .       pl(i).le.p(L+1)) then       .       pl(i).le.p(L+1)) then
2287           temp = ( pl(i)-p(L) )/( p(L+1)-p(L) )           temp = ( pl(i)-p(L) )/( p(L+1)-p(L) )
# Line 2252  C*************************************** Line 2290  C***************************************
2290        enddo        enddo
2291        enddo        enddo
2292    
2293        do i=1,len        do i=1,lng
2294        if( pl(i).lt.p(1)   ) acr(i) = a(1)        if( pl(i).lt.p(1)   ) acr(i) = a(1)
2295        if( pl(i).gt.p(lma) ) acr(i) = a(lma)        if( pl(i).gt.p(lma) ) acr(i) = a(lma)
2296        enddo        enddo
2297    
2298        do i=1,len        do i=1,lng
2299        acr(i) = acr(i) * (plb(i)-pl(i))        acr(i) = acr(i) * (plb(i)-pl(i))
2300        enddo        enddo
2301    
2302        RETURN        RETURN
2303        END        END
2304         SUBROUTINE RNEVP(NN,IRUN,NLAY,TL,QL,RAIN,PL,CLFRAC,SP,DSIG,PLKE,         SUBROUTINE RNEVP(NN,IRUN,NLAY,TL,QL,RAIN,PL,CLFRAC,SP,DP,PLKE,
2305       1   PLK,TH,TEMP1,TEMP2,TEMP3,ITMP1,ITMP2,RCON,RLAR,CLSBTH,tmscl,       1   PLK,TH,TEMP1,TEMP2,TEMP3,ITMP1,ITMP2,RCON,RLAR,CLSBTH,tmscl,
2306       2   tmfrc,cp,gravity,alhl,gamfac,cldlz,RHCRIT,offset,alpha)       2   tmfrc,cp,gravity,alhl,gamfac,cldlz,RHCRIT,offset,alpha)
2307    
2308          implicit none
2309    C Argument List declarations
2310          integer nn,irun,nlay
2311          _RL TL(IRUN,NLAY),QL(IRUN,NLAY),RAIN(IRUN,NLAY),
2312         . PL(IRUN,NLAY),CLFRAC(IRUN,NLAY),SP(IRUN),TEMP1(IRUN,NLAY),
2313         . TEMP2(IRUN,NLAY),PLKE(IRUN,NLAY+1),
2314         . RCON(IRUN),RLAR(IRUN),DP(IRUN,NLAY),PLK(IRUN,NLAY),TH(IRUN,NLAY),
2315         . TEMP3(IRUN,NLAY)
2316          integer ITMP1(IRUN,NLAY),ITMP2(IRUN,NLAY)
2317          _RL CLSBTH(IRUN,NLAY)
2318          _RL tmscl,tmfrc,cp,gravity,alhl,gamfac,offset,alpha
2319          _RL cldlz(irun,nlay)
2320          _RL rhcrit(irun,nlay)
2321    C
2322    C Local Variables
2323          _RL zm1p04,zero,two89,zp44,zp01,half,zp578,one,thousand,z3600
2324          _RL zp1,zp001
2325        PARAMETER (ZM1P04 = -1.04E-4 )        PARAMETER (ZM1P04 = -1.04E-4 )
2326        PARAMETER (ZERO = 0.)        PARAMETER (ZERO = 0.)
2327        PARAMETER (TWO89= 2.89E-5)        PARAMETER (TWO89= 2.89E-5)
# Line 2280  C*************************************** Line 2335  C***************************************
2335        PARAMETER ( THOUSAND = 1000.)        PARAMETER ( THOUSAND = 1000.)
2336        PARAMETER ( Z3600 = 3600.)        PARAMETER ( Z3600 = 3600.)
2337  C  C
2338         DIMENSION TL(IRUN,NLAY),QL(IRUN,NLAY),RAIN(IRUN,NLAY),        _RL EVP9(IRUN,NLAY)
2339       $ PL(IRUN,NLAY),CLFRAC(IRUN,NLAY),SP(IRUN),TEMP1(IRUN,NLAY),        _RL water(irun),crystal(irun)
2340       $ TEMP2(IRUN,NLAY),PLKE(IRUN,NLAY),        _RL watevap(irun),iceevap(irun)
2341       $ RCON(IRUN),RLAR(IRUN),DSIG(NLAY),PLK(IRUN,NLAY),TH(IRUN,NLAY),        _RL fracwat,fracice, tice,rh,fact,dum
2342       $ TEMP3(IRUN,NLAY),ITMP1(IRUN,NLAY),        _RL rainmax(irun)
2343       $ ITMP2(IRUN,NLAY),CLSBTH(IRUN,NLAY)        _RL getcon,rphf,elocp,cpog,relax
2344  C        _RL exparg,arearat,rpow
2345         DIMENSION EVP9(IRUN,NLAY)  
2346         real water(irun),crystal(irun)        integer i,L,n,nlaym1,irnlay,irnlm1
        real watevap(irun),iceevap(irun)  
        real fracwat,fracice, tice,rh,fact,dum  
   
        real cldlz(irun,nlay)  
        real rhcrit(irun,nlay), rainmax(irun)  
        real offset, alpha  
2347    
2348  c Explicit Inline Directives  c Explicit Inline Directives
2349  c --------------------------  c --------------------------
2350  #if CRAY  #ifdef CRAY
2351  #if f77  #ifdef f77
2352  cfpp$ expand (qsat)  cfpp$ expand (qsat)
2353  #endif  #endif
2354  #endif  #endif
# Line 2348  C INVERSE OF MASS IN EACH LAYER Line 2397  C INVERSE OF MASS IN EACH LAYER
2397  c -----------------------------  c -----------------------------
2398        DO L = 1,NLAY        DO L = 1,NLAY
2399        DO I = 1,IRUN        DO I = 1,IRUN
2400        TEMP3(I,L) = SP(I) * DSIG(L)        TEMP3(I,L) = GRAVITY*ZP01 / DP(I,L)
       TEMP3(I,L) = GRAVITY*ZP01 / TEMP3(I,L)  
2401        ENDDO        ENDDO
2402        ENDDO        ENDDO
2403    
# Line 2497  C  ======= Line 2545  C  =======
2545  C    cloud ...... Cloud Fraction        (irun,irise)  C    cloud ...... Cloud Fraction        (irun,irise)
2546  C  C
2547  C***********************************************************************  C***********************************************************************
 C*                  GODDARD LABORATORY FOR ATMOSPHERES                 *  
 C***********************************************************************  
2548    
2549        implicit none        implicit none
2550        integer  irun,irise        integer  irun,irise
2551    
2552        real   th(irun,irise)        _RL   th(irun,irise)
2553        real    q(irun,irise)        _RL    q(irun,irise)
2554        real  plk(irun,irise)        _RL  plk(irun,irise)
2555        real   pl(irun,irise)        _RL   pl(irun,irise)
2556        real plke(irun,irise+1)        _RL plke(irun,irise+1)
2557    
2558        real tempth(irun)        _RL  cloud(irun,irise)
2559        real tempqs(irun)        _RL cldwat(irun,irise)
2560        real dhstar(irun)        _RL     qs(irun,irise)
2561        real  cloud(irun,irise)  
2562        real cldwat(irun,irise)        _RL cp, alhl, getcon, akap
2563        real     qs(irun,irise)        _RL ratio, temp, elocp
2564          _RL rhcrit,rh,dum
2565        real cp, alhl, getcon, akap, pcheck        integer i,L
2566        real ratio, temp, pke, elocp  
2567        real rhcrit,rh,dum,pbar,tbar        _RL rhc(irun,irise)
2568        integer i,L,ntradesu,ntradesl        _RL offset,alpha
   
       real factor  
       real rhc(irun,irise)  
       real offset,alpha  
2569    
2570  c Explicit Inline Directives  c Explicit Inline Directives
2571  c --------------------------  c --------------------------
2572  #if CRAY  #ifdef CRAY
2573  #if f77  #ifdef f77
2574  cfpp$ expand (qsat)  cfpp$ expand (qsat)
2575  #endif  #endif
2576  #endif  #endif
# Line 2569  c -------------------------------------- Line 2611  c --------------------------------------
2611        subroutine ctei ( th,q,cldfrc,cldwat,pl,plk,plke,im,lm )        subroutine ctei ( th,q,cldfrc,cldwat,pl,plk,plke,im,lm )
2612        implicit none        implicit none
2613        integer im,lm        integer im,lm
2614        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)
2615        real plk(im,lm),pl(im,lm),cldfrc(im,lm)        _RL plk(im,lm),pl(im,lm),cldfrc(im,lm)
2616        integer i,L        integer i,L
2617        real    getcon,cp,alhl,elocp,cpoel,t,p,s,qs,dqsdt,dq        _RL    getcon,cp,alhl,elocp,cpoel,t,p,s,qs,dqsdt,dq
2618        real    k,krd,kmm,f        _RL    k,krd,kmm,f
2619    
2620        cp     = getcon('CP')        cp     = getcon('CP')
2621        alhl   = getcon('LATENT HEAT COND')        alhl   = getcon('LATENT HEAT COND')
# Line 2610  c -------------------------------------- Line 2652  c --------------------------------------
2652        subroutine back2grd(gathered,indeces,scattered,irun)        subroutine back2grd(gathered,indeces,scattered,irun)
2653        implicit none        implicit none
2654        integer i,irun,indeces(irun)        integer i,irun,indeces(irun)
2655        real gathered(irun),scattered(irun)        _RL gathered(irun),scattered(irun)
2656        real temp(irun)        _RL temp(irun)
2657        do i = 1,irun        do i = 1,irun
2658         temp(indeces(i)) = gathered(i)         temp(indeces(i)) = gathered(i)
2659        enddo        enddo

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.22