source: trunk/LMDZ.GENERIC/libf/phystd/thermcell_env.F90 @ 3566

Last change on this file since 3566 was 3435, checked in by alesaux, 5 months ago

Generic PCM:
Bug fix in the Thermal Plumes Model for generic tracers.
Error in computation of potential temperature.
ALS

File size: 5.9 KB
RevLine 
[2060]1!
2!
3!
[2127]4SUBROUTINE thermcell_env(ngrid,nlay,nq,pq,pt,pu,pv,pplay,pplev,               &
5                         zqt,zql,zt,ztv,zhl,zu,zv,zpopsk,zqs)
6     
7     
8!===============================================================================
9!  Purpose: calcul des caracteristiques de l'environnement necessaires au calcul
10!           des proprietes dans le thermique.
11
12!  Modif 2019/04 (AB alexandre.boissinot@lmd.jussieu.fr)
13
14!  Nota Bene
15!     ql   means "non-gaseous water mass mixing ratio" (liquid and solid)
16!     qv   means "vapor mass mixing ratio"
17!     qt   means "total water mass mixing ratio"
18!     TP   means "potential temperature"
19!     TRPV means "virtual potential temperature with latent heat release" 
20!     TPV  means "virtual potential temperature"
21!     TR   means "temperature with latent heat release"
22!===============================================================================
23     
[2060]24      USE print_control_mod, ONLY: prt_level
25      USE thermcell_mod, ONLY: RKAPPA
[2071]26      USE watercommon_h, ONLY: RLvCp, RETV, Psat_water
[2127]27      USE tracer_h, ONLY: igcm_h2o_vap, igcm_h2o_ice
[3342]28      USE callkeys_mod, ONLY: water, generic_condensation
29      USE comcstfi_mod, ONLY: r, cpp, mugaz
30      USE generic_cloud_common_h, ONLY: Psat_generic, epsi_generic, RLVTT_generic
31      USE generic_tracer_index_mod, ONLY: generic_tracer_index
32           
[2127]33      IMPLICIT NONE
[2060]34     
[2127]35     
36!===============================================================================
[2060]37! Declaration
[2127]38!===============================================================================
[2060]39     
[2127]40!     Inputs:
41!     -------
[2060]42     
[2177]43      INTEGER, INTENT(in) :: ngrid
44      INTEGER, INTENT(in) :: nlay
45      INTEGER, INTENT(in) :: nq
[2060]46     
[2177]47      REAL, INTENT(in) :: pq(ngrid,nlay,nq)           ! Large scale water
48      REAL, INTENT(in) :: pt(ngrid,nlay)              ! Large scale temperature
49      REAL, INTENT(in) :: pu(ngrid,nlay)              ! Large scale zonal wind
50      REAL, INTENT(in) :: pv(ngrid,nlay)              ! Large scale meridional wind
51      REAL, INTENT(in) :: pplay(ngrid,nlay)           ! Layers pressure
52      REAL, INTENT(in) :: pplev(ngrid,nlay+1)         ! Levels pressure
53      REAL, INTENT(in) :: zpopsk(ngrid,nlay)          ! Exner function
[2060]54     
[2127]55!     Outputs:
56!     --------
[2060]57     
[2177]58      REAL, INTENT(out) :: zt(ngrid,nlay)             ! T    environment
59      REAL, INTENT(out) :: ztv(ngrid,nlay)            ! TRPV environment
60      REAL, INTENT(out) :: zhl(ngrid,nlay)            ! TP   environment
61      REAL, INTENT(out) :: zu(ngrid,nlay)             ! u    environment
62      REAL, INTENT(out) :: zv(ngrid,nlay)             ! v    environment
63      REAL, INTENT(out) :: zqt(ngrid,nlay)            ! qt   environment
64      REAL, INTENT(out) :: zql(ngrid,nlay)            ! ql   environment
65      REAL, INTENT(out) :: zqs(ngrid,nlay)            ! qsat environment
[2060]66     
[2127]67!     Local:
68!     ------
[2060]69     
[3342]70      INTEGER ig, k, iq
[2060]71     
[2177]72      REAL psat                                       ! Dummy argument for Psat_water()
[2060]73     
[3342]74      !ALS24 declaration for generic tracer
75      INTEGER :: igcm_generic_vap, igcm_generic_ice! index of the vap and ice of generic_tracer
76      LOGICAL :: call_ice_vap_generic ! to call only one time the ice/vap pair of a tracer
77      REAL, SAVE :: metallicity ! metallicity of planet --- is not used here, but necessary to call function Psat_generic
78      !$OMP THREADPRIVATE(metallicity)
79      REAL :: RETV_generic, RV_generic, RLvCp_generic
80
[2127]81!===============================================================================
[2060]82! Initialization
[2127]83!===============================================================================
[2060]84     
[2127]85      zu(:,:) = pu(:,:)
86      zv(:,:) = pv(:,:)
[2060]87     
[2127]88      zhl(:,:) = pt(:,:) / zpopsk(:,:)
[2060]89     
[2230]90      zqt(:,:) = 0.
[2143]91      zql(:,:) = 0.
92     
[3342]93      metallicity=0.0 ! default value --- is not used here but necessary to call function Psat_generic
94       
[2127]95!===============================================================================
96! Condensation and latent heat release
97!===============================================================================
98     
99      IF (water) THEN
100         
[2230]101         zqt(:,:) = pq(:,:,igcm_h2o_vap)
102         
[2177]103         DO k=1,nlay
[2127]104            DO ig=1,ngrid
[2177]105               CALL Psat_water(pt(ig,k), pplev(ig,k), psat, zqs(ig,k))
[2127]106            ENDDO
[2060]107         ENDDO
[2127]108         
[2177]109         DO k=1,nlay
[2127]110            DO ig=1,ngrid
[2177]111               zql(ig,k) = max(0.,pq(ig,k,igcm_h2o_vap) - zqs(ig,k))
112               zt(ig,k) = pt(ig,k) + RLvCp * zql(ig,k)
113               ztv(ig,k) = zt(ig,k) / zpopsk(ig,k)                            &
114               &         * (1. + RETV * (zqt(ig,k)-zql(ig,k)) - zql(ig,k))
[2127]115            ENDDO
116         ENDDO
[3342]117     
118      ELSEIF (generic_condensation .AND. .NOT. water ) THEN
119
120         DO iq=1,nq
121
122            CALL generic_tracer_index(nq,iq,igcm_generic_vap,igcm_generic_ice,call_ice_vap_generic)
123
124            IF (call_ice_vap_generic) THEN ! to call only one time the ice/vap pair of a tracer
125
126               zqt(:,:) = pq(:,:,igcm_generic_vap)
127
128               DO k = 1,nlay
129                  DO ig=1,ngrid
130                     CALL Psat_generic(pt(ig,k),pplev(ig,k),metallicity,psat,zqs(ig,k))
131                  ENDDO
132               ENDDO
133
134               RV_generic = (8.314511*1000.)/(epsi_generic*mugaz)
[3435]135               RETV_generic = RV_generic/r-1.
[3342]136               RLvCp_generic = RLVTT_generic/cpp
137
138               DO k = 1,nlay
139                  DO ig=1,ngrid
140                     zql(ig,k) = max(0.,pq(ig,k,igcm_generic_vap) - zqs(ig,k))
141                     zt(ig,k)  = pt(ig,k) + RLvCp_generic * zql(ig,k)
142                     ztv(ig,k) = zt(ig,k) / zpopsk(ig,k)                      &
143                     &        * (1. + RETV_generic * (zqt(ig,k)-zql(ig,k)) - zql(ig,k))
144                  ENDDO
145               ENDDO
146
147            ENDIF !call_ice_vap_generic
148
149         ENDDO!nq
150   
[2127]151      ELSE
152         
153         zt(:,:) = pt(:,:)
[2143]154         ztv(:,:) = pt(:,:) / zpopsk(:,:)
[2127]155         
156      ENDIF
[2060]157     
158     
159RETURN
160END
Note: See TracBrowser for help on using the repository browser.