[5099] | 1 | |
---|
[1279] | 2 | ! $Id: diagedyn.f90 5159 2024-08-02 19:58:25Z abarral $ |
---|
[524] | 3 | |
---|
[5105] | 4 | !====================================================================== |
---|
| 5 | SUBROUTINE diagedyn(tit,iprt,idiag,idiag2,dtime & |
---|
| 6 | , ucov , vcov , ps, p ,pk , teta , q, ql) |
---|
| 7 | !====================================================================== |
---|
[5159] | 8 | |
---|
[5105] | 9 | ! Purpose: |
---|
| 10 | ! Calcul la difference d'enthalpie et de masse d'eau entre 2 appels, |
---|
| 11 | ! et calcul le flux de chaleur et le flux d'eau necessaire a ces |
---|
| 12 | ! changements. Ces valeurs sont moyennees sur la surface de tout |
---|
| 13 | ! le globe et sont exprime en W/2 et kg/s/m2 |
---|
| 14 | ! Outil pour diagnostiquer la conservation de l'energie |
---|
| 15 | ! et de la masse dans la dynamique. |
---|
[5159] | 16 | |
---|
| 17 | |
---|
[5105] | 18 | !====================================================================== |
---|
| 19 | ! Arguments: |
---|
| 20 | ! tit-----imput-A15- Comment added in PRINT (CHARACTER*15) |
---|
| 21 | ! iprt----input-I- PRINT level ( <=1 : no PRINT) |
---|
| 22 | ! idiag---input-I- indice dans lequel sera range les nouveaux |
---|
| 23 | ! bilans d' entalpie et de masse |
---|
| 24 | ! idiag2--input-I-les nouveaux bilans d'entalpie et de masse |
---|
| 25 | ! sont compare au bilan de d'enthalpie de masse de |
---|
| 26 | ! l'indice numero idiag2 |
---|
| 27 | ! Cas parriculier : si idiag2=0, pas de comparaison, on |
---|
| 28 | ! sort directement les bilans d'enthalpie et de masse |
---|
| 29 | ! dtime----input-R- time step (s) |
---|
| 30 | ! uconv, vconv-input-R- vents covariants (m/s) |
---|
| 31 | ! ps-------input-R- Surface pressure (Pa) |
---|
| 32 | ! p--------input-R- pressure at the interfaces |
---|
| 33 | ! pk-------input-R- pk= (p/Pref)**kappa |
---|
| 34 | ! teta-----input-R- potential temperature (K) |
---|
| 35 | ! q--------input-R- vapeur d'eau (kg/kg) |
---|
| 36 | ! ql-------input-R- liquid watter (kg/kg) |
---|
| 37 | ! aire-----input-R- mesh surafce (m2) |
---|
[5159] | 38 | |
---|
[5105] | 39 | ! the following total value are computed by UNIT of earth surface |
---|
[5159] | 40 | |
---|
[5105] | 41 | ! d_h_vcol--output-R- Heat flux (W/m2) define as the Enthalpy |
---|
| 42 | ! change (J/m2) during one time step (dtime) for the whole |
---|
| 43 | ! atmosphere (air, watter vapour, liquid and solid) |
---|
| 44 | ! d_qt------output-R- total water mass flux (kg/m2/s) defined as the |
---|
| 45 | ! total watter (kg/m2) change during one time step (dtime), |
---|
| 46 | ! d_qw------output-R- same, for the watter vapour only (kg/m2/s) |
---|
| 47 | ! d_ql------output-R- same, for the liquid watter only (kg/m2/s) |
---|
| 48 | ! d_ec------output-R- Cinetic Energy Budget (W/m2) for vertical air column |
---|
[5159] | 49 | |
---|
| 50 | |
---|
[5105] | 51 | ! J.L. Dufresne, July 2002 |
---|
| 52 | !====================================================================== |
---|
[524] | 53 | |
---|
[5105] | 54 | USE control_mod, ONLY: planet_type |
---|
[5118] | 55 | USE lmdz_iniprint, ONLY: lunout, prt_level |
---|
[5136] | 56 | USE lmdz_comgeom |
---|
[5099] | 57 | |
---|
[5159] | 58 | USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm |
---|
| 59 | USE lmdz_paramet |
---|
[5105] | 60 | IMPLICIT NONE |
---|
| 61 | ! |
---|
[524] | 62 | |
---|
[5159] | 63 | |
---|
| 64 | |
---|
[5105] | 65 | ! Ehouarn: for now set these parameters to what is in Earth physics... |
---|
| 66 | ! (cf ../phylmd/suphel.h) |
---|
| 67 | ! this should be generalized... |
---|
| 68 | REAL,PARAMETER :: RCPD= & |
---|
| 69 | 3.5*(1000.*(6.0221367E+23*1.380658E-23)/28.9644) |
---|
| 70 | REAL,PARAMETER :: RCPV= & |
---|
| 71 | 4.*(1000.*(6.0221367E+23*1.380658E-23)/18.0153) |
---|
| 72 | REAL,PARAMETER :: RCS=RCPV |
---|
| 73 | REAL,PARAMETER :: RCW=RCPV |
---|
| 74 | REAL,PARAMETER :: RLSTT=2.8345E+6 |
---|
| 75 | REAL,PARAMETER :: RLVTT=2.5008E+6 |
---|
[524] | 76 | |
---|
[5159] | 77 | |
---|
[5105] | 78 | INTEGER :: imjmp1 |
---|
| 79 | PARAMETER( imjmp1=iim*jjp1) |
---|
| 80 | ! Input variables |
---|
| 81 | CHARACTER(len=15) :: tit |
---|
| 82 | INTEGER :: iprt,idiag, idiag2 |
---|
| 83 | REAL :: dtime |
---|
| 84 | REAL :: vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants |
---|
| 85 | REAL :: ps(ip1jmp1) ! pression au sol |
---|
| 86 | REAL :: p (ip1jmp1,llmp1 ) ! pression aux interfac.des couches |
---|
| 87 | REAL :: pk (ip1jmp1,llm ) ! = (p/Pref)**kappa |
---|
| 88 | REAL :: teta(ip1jmp1,llm) ! temperature potentielle |
---|
| 89 | REAL :: q(ip1jmp1,llm) ! champs eau vapeur |
---|
| 90 | REAL :: ql(ip1jmp1,llm) ! champs eau liquide |
---|
[524] | 91 | |
---|
| 92 | |
---|
[5105] | 93 | ! Output variables |
---|
| 94 | REAL :: d_h_vcol, d_qt, d_qw, d_ql, d_qs, d_ec |
---|
[5159] | 95 | |
---|
[5105] | 96 | ! Local variables |
---|
[5159] | 97 | |
---|
[5105] | 98 | REAL :: h_vcol_tot, h_dair_tot, h_qw_tot, h_ql_tot & |
---|
| 99 | , h_qs_tot, qw_tot, ql_tot, qs_tot , ec_tot |
---|
| 100 | ! h_vcol_tot-- total enthalpy of vertical air column |
---|
| 101 | ! (air with watter vapour, liquid and solid) (J/m2) |
---|
| 102 | ! h_dair_tot-- total enthalpy of dry air (J/m2) |
---|
| 103 | ! h_qw_tot---- total enthalpy of watter vapour (J/m2) |
---|
| 104 | ! h_ql_tot---- total enthalpy of liquid watter (J/m2) |
---|
| 105 | ! h_qs_tot---- total enthalpy of solid watter (J/m2) |
---|
| 106 | ! qw_tot------ total mass of watter vapour (kg/m2) |
---|
| 107 | ! ql_tot------ total mass of liquid watter (kg/m2) |
---|
| 108 | ! qs_tot------ total mass of solid watter (kg/m2) |
---|
| 109 | ! ec_tot------ total cinetic energy (kg/m2) |
---|
[5159] | 110 | |
---|
[5105] | 111 | REAL :: masse(ip1jmp1,llm) ! masse d'air |
---|
| 112 | REAL :: vcont(ip1jm,llm),ucont(ip1jmp1,llm) |
---|
| 113 | REAL :: ecin(ip1jmp1,llm) |
---|
[524] | 114 | |
---|
[5105] | 115 | REAL :: zaire(imjmp1) |
---|
| 116 | REAL :: zps(imjmp1) |
---|
| 117 | REAL :: zairm(imjmp1,llm) |
---|
| 118 | REAL :: zecin(imjmp1,llm) |
---|
| 119 | REAL :: zpaprs(imjmp1,llm) |
---|
| 120 | REAL :: zpk(imjmp1,llm) |
---|
| 121 | REAL :: zt(imjmp1,llm) |
---|
| 122 | REAL :: zh(imjmp1,llm) |
---|
| 123 | REAL :: zqw(imjmp1,llm) |
---|
| 124 | REAL :: zql(imjmp1,llm) |
---|
| 125 | REAL :: zqs(imjmp1,llm) |
---|
[524] | 126 | |
---|
[5105] | 127 | REAL :: zqw_col(imjmp1) |
---|
| 128 | REAL :: zql_col(imjmp1) |
---|
| 129 | REAL :: zqs_col(imjmp1) |
---|
| 130 | REAL :: zec_col(imjmp1) |
---|
| 131 | REAL :: zh_dair_col(imjmp1) |
---|
| 132 | REAL :: zh_qw_col(imjmp1), zh_ql_col(imjmp1), zh_qs_col(imjmp1) |
---|
[5159] | 133 | |
---|
[5105] | 134 | REAL :: d_h_dair, d_h_qw, d_h_ql, d_h_qs |
---|
[5159] | 135 | |
---|
[5105] | 136 | REAL :: airetot, zcpvap, zcwat, zcice |
---|
[5159] | 137 | |
---|
[5105] | 138 | INTEGER :: i, k, jj, ij , l ,ip1jjm1 |
---|
[5159] | 139 | |
---|
[5105] | 140 | INTEGER :: ndiag ! max number of diagnostic in parallel |
---|
| 141 | PARAMETER (ndiag=10) |
---|
[5116] | 142 | INTEGER :: pas(ndiag) |
---|
[5105] | 143 | save pas |
---|
| 144 | data pas/ndiag*0/ |
---|
[5159] | 145 | |
---|
[5105] | 146 | REAL :: h_vcol_pre(ndiag), h_dair_pre(ndiag), h_qw_pre(ndiag) & |
---|
| 147 | , h_ql_pre(ndiag), h_qs_pre(ndiag), qw_pre(ndiag) & |
---|
| 148 | , ql_pre(ndiag), qs_pre(ndiag) , ec_pre(ndiag) |
---|
| 149 | SAVE h_vcol_pre, h_dair_pre, h_qw_pre, h_ql_pre & |
---|
| 150 | , h_qs_pre, qw_pre, ql_pre, qs_pre , ec_pre |
---|
| 151 | |
---|
| 152 | |
---|
| 153 | IF (planet_type=="earth") THEN |
---|
| 154 | |
---|
| 155 | !====================================================================== |
---|
| 156 | ! Compute Kinetic enrgy |
---|
| 157 | CALL covcont ( llm , ucov , vcov , ucont, vcont ) |
---|
| 158 | CALL enercin ( vcov , ucov , vcont , ucont , ecin ) |
---|
| 159 | CALL massdair( p, masse ) |
---|
| 160 | !====================================================================== |
---|
[5159] | 161 | |
---|
| 162 | |
---|
[5105] | 163 | PRINT*,'MAIS POURQUOI DONC DIAGEDYN NE MARCHE PAS ?' |
---|
[5116] | 164 | RETURN |
---|
[5105] | 165 | ! On ne garde les donnees que dans les colonnes i=1,iim |
---|
| 166 | DO jj = 1,jjp1 |
---|
| 167 | ip1jjm1=iip1*(jj-1) |
---|
| 168 | DO ij = 1,iim |
---|
| 169 | i=iim*(jj-1)+ij |
---|
| 170 | zaire(i)=aire(ij+ip1jjm1) |
---|
| 171 | zps(i)=ps(ij+ip1jjm1) |
---|
| 172 | ENDDO |
---|
| 173 | ENDDO |
---|
| 174 | ! 3D arrays |
---|
| 175 | DO l = 1, llm |
---|
| 176 | DO jj = 1,jjp1 |
---|
| 177 | ip1jjm1=iip1*(jj-1) |
---|
| 178 | DO ij = 1,iim |
---|
| 179 | i=iim*(jj-1)+ij |
---|
| 180 | zairm(i,l) = masse(ij+ip1jjm1,l) |
---|
| 181 | zecin(i,l) = ecin(ij+ip1jjm1,l) |
---|
| 182 | zpaprs(i,l) = p(ij+ip1jjm1,l) |
---|
| 183 | zpk(i,l) = pk(ij+ip1jjm1,l) |
---|
| 184 | zh(i,l) = teta(ij+ip1jjm1,l) |
---|
| 185 | zqw(i,l) = q(ij+ip1jjm1,l) |
---|
| 186 | zql(i,l) = ql(ij+ip1jjm1,l) |
---|
| 187 | zqs(i,l) = 0. |
---|
[524] | 188 | ENDDO |
---|
[5105] | 189 | ENDDO |
---|
| 190 | ENDDO |
---|
[5159] | 191 | |
---|
[5105] | 192 | ! Reset variables |
---|
| 193 | DO i = 1, imjmp1 |
---|
| 194 | zqw_col(i)=0. |
---|
| 195 | zql_col(i)=0. |
---|
| 196 | zqs_col(i)=0. |
---|
| 197 | zec_col(i) = 0. |
---|
| 198 | zh_dair_col(i) = 0. |
---|
| 199 | zh_qw_col(i) = 0. |
---|
| 200 | zh_ql_col(i) = 0. |
---|
| 201 | zh_qs_col(i) = 0. |
---|
| 202 | ENDDO |
---|
[5159] | 203 | |
---|
[5105] | 204 | zcpvap=RCPV |
---|
| 205 | zcwat=RCW |
---|
| 206 | zcice=RCS |
---|
[5159] | 207 | |
---|
[5105] | 208 | ! Compute vertical sum for each atmospheric column |
---|
| 209 | ! ================================================ |
---|
| 210 | DO k = 1, llm |
---|
| 211 | DO i = 1, imjmp1 |
---|
| 212 | ! Watter mass |
---|
| 213 | zqw_col(i) = zqw_col(i) + zqw(i,k)*zairm(i,k) |
---|
| 214 | zql_col(i) = zql_col(i) + zql(i,k)*zairm(i,k) |
---|
| 215 | zqs_col(i) = zqs_col(i) + zqs(i,k)*zairm(i,k) |
---|
| 216 | ! Cinetic Energy |
---|
| 217 | zec_col(i) = zec_col(i) & |
---|
| 218 | +zecin(i,k)*zairm(i,k) |
---|
| 219 | ! Air enthalpy |
---|
| 220 | zt(i,k)= zh(i,k) * zpk(i,k) / RCPD |
---|
| 221 | zh_dair_col(i) = zh_dair_col(i) & |
---|
| 222 | + RCPD*(1.-zqw(i,k)-zql(i,k)-zqs(i,k))*zairm(i,k)*zt(i,k) |
---|
| 223 | zh_qw_col(i) = zh_qw_col(i) & |
---|
| 224 | + zcpvap*zqw(i,k)*zairm(i,k)*zt(i,k) |
---|
| 225 | zh_ql_col(i) = zh_ql_col(i) & |
---|
| 226 | + zcwat*zql(i,k)*zairm(i,k)*zt(i,k) & |
---|
| 227 | - RLVTT*zql(i,k)*zairm(i,k) |
---|
| 228 | zh_qs_col(i) = zh_qs_col(i) & |
---|
| 229 | + zcice*zqs(i,k)*zairm(i,k)*zt(i,k) & |
---|
| 230 | - RLSTT*zqs(i,k)*zairm(i,k) |
---|
[524] | 231 | |
---|
[5105] | 232 | END DO |
---|
| 233 | ENDDO |
---|
[5159] | 234 | |
---|
[5105] | 235 | ! Mean over the planete surface |
---|
| 236 | ! ============================= |
---|
| 237 | qw_tot = 0. |
---|
| 238 | ql_tot = 0. |
---|
| 239 | qs_tot = 0. |
---|
| 240 | ec_tot = 0. |
---|
| 241 | h_vcol_tot = 0. |
---|
| 242 | h_dair_tot = 0. |
---|
| 243 | h_qw_tot = 0. |
---|
| 244 | h_ql_tot = 0. |
---|
| 245 | h_qs_tot = 0. |
---|
| 246 | airetot=0. |
---|
[5159] | 247 | |
---|
[5158] | 248 | DO i=1,imjmp1 |
---|
[5105] | 249 | qw_tot = qw_tot + zqw_col(i) |
---|
| 250 | ql_tot = ql_tot + zql_col(i) |
---|
| 251 | qs_tot = qs_tot + zqs_col(i) |
---|
| 252 | ec_tot = ec_tot + zec_col(i) |
---|
| 253 | h_dair_tot = h_dair_tot + zh_dair_col(i) |
---|
| 254 | h_qw_tot = h_qw_tot + zh_qw_col(i) |
---|
| 255 | h_ql_tot = h_ql_tot + zh_ql_col(i) |
---|
| 256 | h_qs_tot = h_qs_tot + zh_qs_col(i) |
---|
| 257 | airetot=airetot+zaire(i) |
---|
| 258 | END DO |
---|
[5159] | 259 | |
---|
[5105] | 260 | qw_tot = qw_tot/airetot |
---|
| 261 | ql_tot = ql_tot/airetot |
---|
| 262 | qs_tot = qs_tot/airetot |
---|
| 263 | ec_tot = ec_tot/airetot |
---|
| 264 | h_dair_tot = h_dair_tot/airetot |
---|
| 265 | h_qw_tot = h_qw_tot/airetot |
---|
| 266 | h_ql_tot = h_ql_tot/airetot |
---|
| 267 | h_qs_tot = h_qs_tot/airetot |
---|
[5159] | 268 | |
---|
[5105] | 269 | h_vcol_tot = h_dair_tot+h_qw_tot+h_ql_tot+h_qs_tot |
---|
[5159] | 270 | |
---|
[5105] | 271 | ! Compute the change of the atmospheric state compare to the one |
---|
| 272 | ! stored in "idiag2", and convert it in flux. THis computation |
---|
| 273 | ! is performed IF idiag2 /= 0 and IF it is not the first CALL |
---|
| 274 | ! for "idiag" |
---|
| 275 | ! =================================== |
---|
[5159] | 276 | |
---|
[5117] | 277 | IF ( (idiag2>0) .AND. (pas(idiag2) /= 0) ) THEN |
---|
[5105] | 278 | d_h_vcol = (h_vcol_tot - h_vcol_pre(idiag2) )/dtime |
---|
| 279 | d_h_dair = (h_dair_tot- h_dair_pre(idiag2))/dtime |
---|
| 280 | d_h_qw = (h_qw_tot - h_qw_pre(idiag2) )/dtime |
---|
| 281 | d_h_ql = (h_ql_tot - h_ql_pre(idiag2) )/dtime |
---|
| 282 | d_h_qs = (h_qs_tot - h_qs_pre(idiag2) )/dtime |
---|
| 283 | d_qw = (qw_tot - qw_pre(idiag2) )/dtime |
---|
| 284 | d_ql = (ql_tot - ql_pre(idiag2) )/dtime |
---|
| 285 | d_qs = (qs_tot - qs_pre(idiag2) )/dtime |
---|
| 286 | d_ec = (ec_tot - ec_pre(idiag2) )/dtime |
---|
| 287 | d_qt = d_qw + d_ql + d_qs |
---|
| 288 | ELSE |
---|
| 289 | d_h_vcol = 0. |
---|
| 290 | d_h_dair = 0. |
---|
| 291 | d_h_qw = 0. |
---|
| 292 | d_h_ql = 0. |
---|
| 293 | d_h_qs = 0. |
---|
| 294 | d_qw = 0. |
---|
| 295 | d_ql = 0. |
---|
| 296 | d_qs = 0. |
---|
| 297 | d_ec = 0. |
---|
| 298 | d_qt = 0. |
---|
| 299 | ENDIF |
---|
[5159] | 300 | |
---|
[5105] | 301 | IF (iprt>=2) THEN |
---|
| 302 | WRITE(6,9000) tit,pas(idiag),d_qt,d_qw,d_ql,d_qs |
---|
| 303 | 9000 format('Dyn3d. Watter Mass Budget (kg/m2/s)',A15 & |
---|
| 304 | ,1i6,10(1pE14.6)) |
---|
| 305 | WRITE(6,9001) tit,pas(idiag), d_h_vcol |
---|
[524] | 306 | 9001 format('Dyn3d. Enthalpy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
[5105] | 307 | WRITE(6,9002) tit,pas(idiag), d_ec |
---|
[524] | 308 | 9002 format('Dyn3d. Cinetic Energy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
[5105] | 309 | ! WRITE(6,9003) tit,pas(idiag), ec_tot |
---|
[524] | 310 | 9003 format('Dyn3d. Cinetic Energy (W/m2) ',A15,1i6,10(E15.6)) |
---|
[5105] | 311 | WRITE(6,9004) tit,pas(idiag), d_h_vcol+d_ec |
---|
[524] | 312 | 9004 format('Dyn3d. Total Energy Budget (W/m2) ',A15,1i6,10(F8.2)) |
---|
[5105] | 313 | END IF |
---|
[5159] | 314 | |
---|
[5105] | 315 | ! Store the new atmospheric state in "idiag" |
---|
[5159] | 316 | |
---|
[5105] | 317 | pas(idiag)=pas(idiag)+1 |
---|
| 318 | h_vcol_pre(idiag) = h_vcol_tot |
---|
| 319 | h_dair_pre(idiag) = h_dair_tot |
---|
| 320 | h_qw_pre(idiag) = h_qw_tot |
---|
| 321 | h_ql_pre(idiag) = h_ql_tot |
---|
| 322 | h_qs_pre(idiag) = h_qs_tot |
---|
| 323 | qw_pre(idiag) = qw_tot |
---|
| 324 | ql_pre(idiag) = ql_tot |
---|
| 325 | qs_pre(idiag) = qs_tot |
---|
| 326 | ec_pre (idiag) = ec_tot |
---|
[5159] | 327 | |
---|
[5105] | 328 | ELSE |
---|
[5116] | 329 | WRITE(lunout,*)'diagedyn: set to function with Earth parameters' |
---|
[5105] | 330 | ENDIF ! of if (planet_type=="earth") |
---|
| 331 | RETURN |
---|
| 332 | END SUBROUTINE diagedyn |
---|