source: trunk/LMDZ.GENERIC/libf/phystd/largescale.F90 @ 1153

Last change on this file since 1153 was 1016, checked in by jleconte, 11 years ago

07/08/2013 == JL

  • Water cycle in double precision (largescale+moistadj)
  • Improved wate rayleigh.
  • First step for rayleigh with variable species. Now, just need to change optcv.
  • changed some interpolation indices in callcorrk to limit dependency of OLR on the number of layers
File size: 6.2 KB
RevLine 
[787]1      subroutine largescale(ngrid,nq,ptimestep, pplev, pplay, pt, pq,   &
[728]2                        pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb)
3
[1016]4
5!     to use  'getin'
6      use ioipsl_getincom
[728]7      use watercommon_h, only : RLVTT, RCPD, RVTMP2,  &
[1016]8          T_h2O_ice_clouds,T_h2O_ice_liq,Psat_waterDP,Lcpdqsat_waterDP
[787]9      USE tracer_h
[728]10      IMPLICIT none
11
12!==================================================================
13!     
14!     Purpose
15!     -------
16!     Calculates large-scale (stratiform) H2O condensation.
17!     
18!     Authors
19!     -------
20!     Adapted from the LMDTERRE code by R. Wordsworth (2009)
21!     Original author Z. X. Li (1993)
22!     
23!==================================================================
24
25#include "dimensions.h"
26#include "dimphys.h"
27#include "comcstfi.h"
28
29#include "callkeys.h"
30
[787]31      INTEGER ngrid,nq
[728]32
33!     Arguments
34      REAL ptimestep                 ! intervalle du temps (s)
[787]35      REAL pplev(ngrid,nlayermx+1) ! pression a inter-couche
36      REAL pplay(ngrid,nlayermx)   ! pression au milieu de couche
37      REAL pt(ngrid,nlayermx)      ! temperature (K)
[1016]38      REAL pq(ngrid,nlayermx,nq) ! tracer mixing ratio (kg/kg)
[787]39      REAL pdt(ngrid,nlayermx)     ! physical temperature tenedency (K/s)
40      REAL pdq(ngrid,nlayermx,nq)! physical tracer tenedency (K/s)
41      REAL pdtlsc(ngrid,nlayermx)  ! incrementation de la temperature (K)
42      REAL pdqvaplsc(ngrid,nlayermx) ! incrementation de la vapeur d'eau
43      REAL pdqliqlsc(ngrid,nlayermx) ! incrementation de l'eau liquide
44      REAL rneb(ngrid,nlayermx)    ! fraction nuageuse
[728]45
46
47!     Options du programme
[1016]48      REAL, SAVE :: ratqs   ! determine largeur de la distribution de vapeur
[728]49
50!     Variables locales
51      REAL CBRT
52      EXTERNAL CBRT
53      INTEGER i, k , nn
[1016]54      INTEGER,PARAMETER :: nitermax=5000
55      DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8
[875]56      ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by
57      !                   decreasing alpha and increasing nitermax accordingly
[1016]58      DOUBLE PRECISION zt(ngrid), zq(ngrid)
59      DOUBLE PRECISION zcond(ngrid),zcond_iter
60      DOUBLE PRECISION zdelq(ngrid)
61      DOUBLE PRECISION zqs(ngrid), zdqs(ngrid)
62      DOUBLE PRECISION local_p,psat_tmp,dlnpsat_tmp,Lcp
[728]63     
64! evaporation calculations
[787]65      REAL dqevap(ngrid,nlayermx),dtevap(ngrid,nlayermx)     
66      REAL qevap(ngrid,nlayermx,nq)
67      REAL tevap(ngrid,nlayermx)
[728]68
[1016]69      DOUBLE PRECISION zx_q(ngrid)
70      LOGICAL,SAVE :: firstcall=.true.
[728]71
[1016]72
73      IF (firstcall) THEN
74
75         write(*,*) "value for ratqs? "
76         ratqs=0.2 ! default value
77         call getin("ratqs",ratqs)
78         write(*,*) " ratqs = ",ratqs
79
80         firstcall = .false.
81      ENDIF
82
[728]83!     GCM -----> subroutine variables, initialisation of outputs
84
[787]85      pdtlsc(1:ngrid,1:nlayermx)  = 0.0
86      pdqvaplsc(1:ngrid,1:nlayermx)  = 0.0
87      pdqliqlsc(1:ngrid,1:nlayermx) = 0.0
88      rneb(1:ngrid,1:nlayermx) = 0.0
[1016]89      Lcp=RLVTT/RCPD
[728]90
91
92      ! Evaporate cloud water/ice
[787]93      call evap(ngrid,nq,ptimestep,pt,pq,pdq,pdt,dqevap,dtevap,qevap,tevap)
[728]94      ! note: we use qevap but not tevap in largescale/moistadj
95            ! otherwise is a big mess
96
97
98!  Boucle verticale (du haut vers le bas)
99   DO k = nlayermx, 1, -1
100
[787]101      zt(1:ngrid)=pt(1:ngrid,k)+(pdt(1:ngrid,k)+dtevap(1:ngrid,k))*ptimestep
102      zq(1:ngrid)=qevap(1:ngrid,k,igcm_h2o_vap) !liquid water is included in qevap
[728]103
104!     Calculer la vapeur d'eau saturante et
105!     determiner la condensation partielle
[787]106      DO i = 1, ngrid
[728]107
[1016]108         local_p=pplay(i,k)
[773]109         if(zt(i).le.15.) then
[786]110            print*,'in lsc',i,k,zt(i)
111!           zt(i)=15.   ! check too low temperatures
[773]112         endif
[1016]113         call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
[728]114 
[1016]115         zdelq(i) = MAX(MIN(ratqs * zq(i),1.-zq(i)),1.d-12)
[786]116         rneb(i,k) = (zq(i)+zdelq(i)-zqs(i)) / (2.0*zdelq(i))
117         if (rneb(i,k).lt.0.) then  !no clouds
118
119            rneb(i,k)=0.
120            zcond(i)=0.
121
[1016]122         else if ((rneb(i,k).gt.0.99).or.(ratqs.lt.1.e-6)) then    !complete cloud cover, we start without evaporating
[786]123            rneb(i,k)=1.
124            zt(i)=pt(i,k)+pdt(i,k)*ptimestep
125            zx_q(i) = pq(i,k,igcm_h2o_vap)+pdq(i,k,igcm_h2o_vap)*ptimestep
126            dqevap(i,k)=0.
127!           iterative process to stabilize the scheme when large water amounts JL12
[1016]128            zcond(i) = 0.0d0
[786]129            Do nn=1,nitermax 
[1016]130               call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
131               call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
132               zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i))         
[786]133                  !zcond can be negative here
134               zx_q(i) = zx_q(i) - zcond_iter
135               zcond(i) = zcond(i) + zcond_iter
[1016]136               zt(i) = zt(i) + zcond_iter*Lcp
137               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
138!              if (ABS(zcond_iter/alpha).lt.qthreshold) exit
139               if (nn.eq.nitermax) print*,'itermax in largescale'
[786]140            End do ! niter
141            zcond(i)=MAX(zcond(i),-(pq(i,k,igcm_h2o_ice)+pdq(i,k,igcm_h2o_ice)*ptimestep))
142
143         else   !standard case     
144
[1016]145            zx_q(i) = (zq(i)+zdelq(i)+zqs(i))/2.0d0 !water vapor in cloudy sky
[786]146!           iterative process to stabilize the scheme when large water amounts JL12
[1016]147            zcond(i) = 0.0d0
[786]148            Do nn=1,nitermax 
[1016]149               call Lcpdqsat_waterDP(zt(i),local_p,psat_tmp,zqs(i),zdqs(i),dlnpsat_tmp)
150               zcond_iter = MAX(0.0d0,alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs(i)))       
[786]151                  !zcond always postive! cannot evaporate clouds!
152                  !this is why we must reevaporate before largescale
153               zx_q(i) = zx_q(i) - zcond_iter
154               zcond(i) = zcond(i) + zcond_iter
[1016]155               if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit
156!              if (ABS(zcond_iter/alpha).lt.qthreshold) exit
157               zt(i) = zt(i) + zcond_iter*Lcp*rneb(i,k)
158               call Psat_waterDP(zt(i),local_p,psat_tmp,zqs(i))
159               if (nn.eq.nitermax) print*,'itermax in largescale'
[786]160            End do ! niter
161
[728]162         Endif
163
[786]164         zcond(i) = zcond(i)*rneb(i,k)/ptimestep ! JL12
[728]165
166      ENDDO
167
168!     Tendances de t et q
[787]169         pdqvaplsc(1:ngrid,k)  = dqevap(1:ngrid,k) - zcond(1:ngrid)
170         pdqliqlsc(1:ngrid,k) = - pdqvaplsc(1:ngrid,k)
[1016]171         pdtlsc(1:ngrid,k)  = pdqliqlsc(1:ngrid,k)*real(Lcp)
[728]172
173   Enddo ! k= nlayermx, 1, -1
[1016]174 
[728]175
176      return
177      end
Note: See TracBrowser for help on using the repository browser.