[2701] | 1 | module condensation_generic_mod |
---|
[2690] | 2 | implicit none |
---|
| 3 | |
---|
| 4 | contains |
---|
| 5 | |
---|
[2701] | 6 | subroutine condensation_generic(ngrid,nlayer,nq,ptimestep, pplev, pplay, & |
---|
[2724] | 7 | pt, pq, pdt, pdq, pdtlsc, pdqvaplsc, pdqliqlsc, rneb) |
---|
[2690] | 8 | use ioipsl_getin_p_mod, only: getin_p !-> to get the metallicity |
---|
[2711] | 9 | use generic_cloud_common_h |
---|
[2690] | 10 | USE tracer_h |
---|
[2717] | 11 | USE mod_phys_lmdz_para, only: is_master |
---|
[2720] | 12 | use generic_tracer_index_mod, only: generic_tracer_index |
---|
[2690] | 13 | IMPLICIT none |
---|
| 14 | |
---|
| 15 | !======================================================================= |
---|
| 16 | ! |
---|
| 17 | ! Purpose |
---|
| 18 | ! ------- |
---|
| 19 | ! Calculates large-scale condensation of generic tracer "tname". |
---|
| 20 | ! By convention, tname ends with the suffix "_vap", as it represents the |
---|
| 21 | ! gas phase of the generic tracer |
---|
| 22 | ! |
---|
| 23 | ! Authors |
---|
| 24 | ! ------- |
---|
[2714] | 25 | ! Adapted from largescale.F90 by Lucas Teinturier & Noé Clément (2022) |
---|
[2690] | 26 | ! largescale.F90 adapted from the LMDTERRE code by R. Wordsworth (2009) |
---|
| 27 | ! Original author Z. X. Li (1993) |
---|
| 28 | ! |
---|
| 29 | !========================================================================= |
---|
| 30 | |
---|
| 31 | INTEGER, intent(in) :: ngrid,nlayer,nq |
---|
| 32 | |
---|
| 33 | ! Arguments |
---|
| 34 | REAL, intent(in) :: ptimestep ! intervalle du temps (s) |
---|
| 35 | REAL, intent(in) :: pplev(ngrid,nlayer+1) ! pression a inter-couche |
---|
| 36 | REAL, intent(in) :: pplay(ngrid,nlayer) ! pression au milieu de couche |
---|
| 37 | REAL, intent(in) :: pt(ngrid,nlayer) ! temperature (K) |
---|
| 38 | REAL, intent(in) :: pq(ngrid,nlayer,nq) ! tracer mixing ratio (kg/kg) |
---|
| 39 | REAL, intent(in) :: pdt(ngrid,nlayer) ! physical temperature tendency (K/s) |
---|
| 40 | REAL, intent(in) :: pdq(ngrid,nlayer,nq) ! physical tracer tendency (K/s) |
---|
[2700] | 41 | ! CHARACTER(*), intent(in) :: tname_vap ! name of the tracer we consider. BY convention, it ends with _vap !!! |
---|
[2690] | 42 | REAL, intent(out) :: pdtlsc(ngrid,nlayer) ! incrementation de la temperature (K) |
---|
[2700] | 43 | REAL, intent(out) :: pdqvaplsc(ngrid,nlayer,nq) ! incrementation de la vapeur du traceur |
---|
| 44 | REAL, intent(out) :: pdqliqlsc(ngrid,nlayer,nq) ! incrementation du traceur liquide |
---|
[2724] | 45 | REAL, intent(out) :: rneb(ngrid,nlayer,nq) ! fraction nuageuse |
---|
[2690] | 46 | |
---|
| 47 | ! Options : |
---|
| 48 | real, save :: metallicity !metallicity of planet |
---|
[3044] | 49 | REAL, SAVE :: qvap_deep ! deep mixing ratio of vapor when simulating bottom less planets |
---|
| 50 | REAL, SAVE :: qvap_top ! top mixing ratio of vapor when simulating bottom less planets |
---|
[3280] | 51 | logical, save :: align_strato_cold_trap |
---|
| 52 | !$OMP THREADPRIVATE(metallicity, qvap_deep, qvap_top, align_strato_cold_trap) |
---|
[2690] | 53 | |
---|
| 54 | ! Local variables |
---|
[2720] | 55 | |
---|
| 56 | ! to call only one time the ice/vap pair of a tracer |
---|
[2722] | 57 | logical call_ice_vap_generic |
---|
[2720] | 58 | |
---|
[2690] | 59 | INTEGER i, k , nn, iq |
---|
| 60 | INTEGER,PARAMETER :: nitermax=5000 |
---|
[3044] | 61 | REAL tau ! tau is in seconds and must not be lower than the physical step time. |
---|
| 62 | integer k_cold_trap |
---|
[2690] | 63 | DOUBLE PRECISION,PARAMETER :: alpha=.1,qthreshold=1.d-8 |
---|
| 64 | ! JL13: if "careful, T<Tmin in psat water" appears often, you may want to stabilise the model by |
---|
| 65 | ! decreasing alpha and increasing nitermax accordingly |
---|
| 66 | DOUBLE PRECISION zq(ngrid) |
---|
| 67 | DOUBLE PRECISION zcond(ngrid),zcond_iter |
---|
| 68 | DOUBLE PRECISION zqs(ngrid) |
---|
| 69 | real zt(ngrid),local_p,psat_tmp,dlnpsat_tmp,Lcp,zqs_temp,zdqs |
---|
[3280] | 70 | real zqs_temp_1, zqs_temp_2 |
---|
| 71 | integer igcm_generic_vap, igcm_generic_ice ! index of the vap and ice of generic_tracer |
---|
[2690] | 72 | ! evaporation calculations |
---|
| 73 | REAL dqevap(ngrid,nlayer),dtevap(ngrid,nlayer) |
---|
| 74 | REAL qevap(ngrid,nlayer,nq) |
---|
| 75 | REAL tevap(ngrid,nlayer) |
---|
| 76 | |
---|
| 77 | DOUBLE PRECISION zx_q(ngrid) |
---|
[2890] | 78 | DOUBLE PRECISION zy_q(ngrid) |
---|
[2690] | 79 | LOGICAL,SAVE :: firstcall=.true. |
---|
| 80 | !$OMP THREADPRIVATE(firstcall) |
---|
| 81 | IF (firstcall) THEN |
---|
| 82 | write(*,*) "value for metallicity? " |
---|
| 83 | metallicity=0.0 ! default value |
---|
| 84 | call getin_p("metallicity",metallicity) |
---|
| 85 | write(*,*) " metallicity = ",metallicity |
---|
[2720] | 86 | |
---|
[3044] | 87 | write(*,*) "Deep generic tracer vapor mixing ratio ? (no effect if negative) " |
---|
[2720] | 88 | qvap_deep=-1. ! default value |
---|
| 89 | call getin_p("qvap_deep",qvap_deep) |
---|
| 90 | write(*,*) " qvap_deep = ",qvap_deep |
---|
| 91 | |
---|
[3044] | 92 | write(*,*) "top generic tracer vapor mixing ratio ? (no effect if negative) " |
---|
| 93 | qvap_top=-1. ! default value |
---|
| 94 | call getin_p("qvap_top",qvap_top) |
---|
| 95 | write(*,*) " qvap_top = ",qvap_top |
---|
| 96 | |
---|
[3280] | 97 | write(*,*) " align_strato_cold_trap ? " |
---|
| 98 | align_strato_cold_trap=.false. ! default value |
---|
| 99 | call getin_p("align_strato_cold_trap",align_strato_cold_trap) |
---|
| 100 | write(*,*) " align_strato_cold_trap = ",align_strato_cold_trap |
---|
| 101 | |
---|
[2690] | 102 | firstcall = .false. |
---|
| 103 | ENDIF |
---|
[2700] | 104 | ! Initialisation of outputs and local variables |
---|
[2690] | 105 | pdtlsc(1:ngrid,1:nlayer) = 0.0 |
---|
[2700] | 106 | pdqvaplsc(1:ngrid,1:nlayer,1:nq) = 0.0 |
---|
| 107 | pdqliqlsc(1:ngrid,1:nlayer,1:nq) = 0.0 |
---|
| 108 | dqevap(1:ngrid,1:nlayer)=0.0 |
---|
| 109 | dtevap(1:ngrid,1:nlayer)=0.0 |
---|
| 110 | qevap(1:ngrid,1:nlayer,1:nq)=0.0 |
---|
| 111 | tevap(1:ngrid,1:nlayer)=0.0 |
---|
[2724] | 112 | rneb(1:ngrid,1:nlayer,1:nq) = 0.0 |
---|
[2700] | 113 | ! Let's loop on tracers |
---|
[2690] | 114 | do iq=1,nq |
---|
[2706] | 115 | |
---|
[2722] | 116 | call generic_tracer_index(nq,iq,igcm_generic_vap,igcm_generic_ice,call_ice_vap_generic) |
---|
[2706] | 117 | |
---|
[2722] | 118 | if(call_ice_vap_generic) then ! to call only one time the ice/vap pair of a tracer |
---|
[2711] | 119 | m=constants_mass(iq) |
---|
| 120 | delta_vapH=constants_delta_vapH(iq) |
---|
| 121 | Tref=constants_Tref(iq) |
---|
| 122 | Pref=constants_Pref(iq) |
---|
[2725] | 123 | epsi_generic=constants_epsi_generic(iq) |
---|
| 124 | RLVTT_generic=constants_RLVTT_generic(iq) |
---|
[2711] | 125 | metallicity_coeff=constants_metallicity_coeff(iq) |
---|
| 126 | |
---|
[2725] | 127 | Lcp=RLVTT_generic/cpp ! need to be init here |
---|
[2690] | 128 | |
---|
[2700] | 129 | ! Vertical loop (from top to bottom) |
---|
| 130 | DO k = nlayer, 1, -1 |
---|
[2704] | 131 | zt(1:ngrid)=pt(1:ngrid,k)+pdt(1:ngrid,k)*ptimestep |
---|
[2690] | 132 | |
---|
[2700] | 133 | ! Computes Psat and the partial condensation |
---|
| 134 | DO i = 1, ngrid |
---|
| 135 | local_p=pplay(i,k) |
---|
| 136 | if(zt(i).le.15.) then |
---|
| 137 | print*,'in lsc',i,k,zt(i) |
---|
| 138 | ! zt(i)=15. ! check too low temperatures |
---|
| 139 | endif |
---|
| 140 | zx_q(i) = pq(i,k,igcm_generic_vap)+pdq(i,k,igcm_generic_vap)*ptimestep |
---|
[2724] | 141 | |
---|
[2890] | 142 | call Psat_generic(zt(i),local_p,metallicity,psat_tmp,zqs_temp) |
---|
| 143 | zy_q(i) = pq(i,k,igcm_generic_ice)+pdq(i,k,igcm_generic_ice)*ptimestep |
---|
| 144 | |
---|
| 145 | if ((zx_q(i) .le. zqs_temp) .and. (zy_q(i) .eq. 0.)) then |
---|
| 146 | ! if we are are not saturated and if there is no ice |
---|
| 147 | ! then no change |
---|
| 148 | |
---|
| 149 | zcond(i) = 0.0d0 |
---|
| 150 | |
---|
| 151 | else ! if we are saturated : we must evaporate |
---|
| 152 | ! if there is ice : we must check if we can condensate |
---|
| 153 | |
---|
| 154 | ! iterative process to stabilize the scheme when large water amounts JL12 |
---|
| 155 | zcond(i) = 0.0d0 |
---|
| 156 | Do nn=1,nitermax |
---|
| 157 | call Psat_generic(zt(i),local_p,metallicity,psat_tmp,zqs_temp) |
---|
| 158 | zqs(i)=zqs_temp |
---|
| 159 | call Lcpdqsat_generic(zt(i),local_p,psat_tmp,zqs_temp,zdqs,dlnpsat_tmp) |
---|
| 160 | zcond_iter = alpha*(zx_q(i)-zqs(i))/(1.d0+zdqs) |
---|
| 161 | !zcond can be negative here |
---|
| 162 | zx_q(i) = zx_q(i) - zcond_iter |
---|
| 163 | zcond(i) = zcond(i) + zcond_iter |
---|
| 164 | zt(i) = zt(i) + zcond_iter*Lcp |
---|
| 165 | if (ABS(zcond_iter/alpha/zqs(i)).lt.qthreshold) exit |
---|
| 166 | if (nn.eq.nitermax) print*,'itermax in largescale' |
---|
| 167 | End do ! niter |
---|
| 168 | |
---|
| 169 | ! if zcond(i) > 0, zcond(i) is the amount of vapor that we can condensate |
---|
| 170 | ! because we are saturated. zcond(i) will not change below |
---|
| 171 | ! if zcond(i) < 0, zcond(i) is the amount of ice that we can evaporate. |
---|
| 172 | ! We can not evaporate more than the existing ice, |
---|
| 173 | ! so the line below is to check how much we can evaporate. |
---|
| 174 | ! If there is no ice available, zcond(i) will be 0. (first condidition of "if") |
---|
| 175 | |
---|
| 176 | zcond(i)=MAX(zcond(i),-(pq(i,k,igcm_generic_ice)+pdq(i,k,igcm_generic_ice)*ptimestep)) |
---|
| 177 | |
---|
| 178 | endif |
---|
| 179 | |
---|
[2724] | 180 | if (zcond(i) .gt. 0.) then |
---|
| 181 | rneb(i,k,iq)=1 |
---|
| 182 | else |
---|
| 183 | rneb(i,k,iq)=0. |
---|
| 184 | endif |
---|
| 185 | |
---|
[2700] | 186 | zcond(i) = zcond(i)/ptimestep |
---|
| 187 | ENDDO ! i=1,ngrid |
---|
[2690] | 188 | |
---|
[2700] | 189 | !Tendances de t et q |
---|
[2704] | 190 | pdqvaplsc(1:ngrid,k,igcm_generic_vap) = - zcond(1:ngrid) |
---|
[2700] | 191 | pdqliqlsc(1:ngrid,k,igcm_generic_ice) = - pdqvaplsc(1:ngrid,k,igcm_generic_vap) |
---|
| 192 | pdtlsc(1:ngrid,k) = pdtlsc(1:ngrid,k) + pdqliqlsc(1:ngrid,k,igcm_generic_ice)*Lcp |
---|
[2690] | 193 | |
---|
[2700] | 194 | Enddo ! k= nlayer, 1, -1 |
---|
[2720] | 195 | |
---|
[3280] | 196 | if (align_strato_cold_trap .and. (ngrid.eq.1)) then |
---|
| 197 | ! aligns GCS vapor in the stratosphere to the quantity fixed by the cold trap |
---|
| 198 | ! works only in 1D |
---|
| 199 | tau = 10. * ptimestep |
---|
| 200 | ! tau is in seconds and must not be lower than the physical step time. |
---|
[3044] | 201 | |
---|
[3280] | 202 | ! Look for the cold trap |
---|
| 203 | k_cold_trap = 1 ! initialization of cold trap layer |
---|
| 204 | zqs_temp_2 = 1 ! initialization of minimum of saturation |
---|
[3044] | 205 | do k=2,nlayer-1 |
---|
[3280] | 206 | zt(1) = pt(1,k)+pdt(1,k)*ptimestep |
---|
| 207 | call Psat_generic(zt(1),pplay(1,k),metallicity,psat_tmp,zqs_temp_1) |
---|
| 208 | if (zqs_temp_1 .lt. zqs_temp_2) then |
---|
[3044] | 209 | k_cold_trap = k |
---|
[3280] | 210 | zqs_temp_2 = zqs_temp_1 |
---|
[3044] | 211 | endif |
---|
| 212 | enddo |
---|
| 213 | |
---|
[3280] | 214 | ! aligning |
---|
| 215 | do k=k_cold_trap,nlayer |
---|
| 216 | pdqvaplsc(1,k,igcm_generic_vap) = (zqs_temp_2 - pq(1,k,igcm_generic_vap))/tau - pdq(1,k,igcm_generic_vap) |
---|
| 217 | pdtlsc(1,k) = 0. |
---|
[3044] | 218 | enddo |
---|
| 219 | endif |
---|
[3280] | 220 | |
---|
[2720] | 221 | if (qvap_deep >= 0.) then |
---|
[3280] | 222 | tau = 10. * ptimestep |
---|
[3103] | 223 | ! brings lower generic vapor ratio to a fixed value. |
---|
[2890] | 224 | ! tau is in seconds and must not be lower than the physical step time. |
---|
[2720] | 225 | pdqvaplsc(1:ngrid,1,igcm_generic_vap) = (qvap_deep - pq(1:ngrid,1,igcm_generic_vap))/tau - pdq(1:ngrid,1,igcm_generic_vap) |
---|
| 226 | endif |
---|
[3280] | 227 | |
---|
[3044] | 228 | if (qvap_top >= 0.) then |
---|
[3280] | 229 | tau = 10. * ptimestep |
---|
[3103] | 230 | ! brings lower generic vapor ratio to a fixed value. |
---|
[3044] | 231 | ! tau is in seconds and must not be lower than the physical step time. |
---|
| 232 | pdqvaplsc(1:ngrid,nlayer,igcm_generic_vap) = (qvap_top - pq(1:ngrid,nlayer,igcm_generic_vap))/tau - pdq(1:ngrid,nlayer,igcm_generic_vap) |
---|
| 233 | endif |
---|
[3280] | 234 | |
---|
[2722] | 235 | endif !if(call_ice_vap_generic) |
---|
[2700] | 236 | enddo ! iq=1,nq |
---|
[2701] | 237 | |
---|
| 238 | end subroutine condensation_generic |
---|
| 239 | end module condensation_generic_mod |
---|