[3800] | 1 | ! |
---|
| 2 | ! $Id: qminimum_loc.F 5199 2024-09-18 21:22:37Z fairhead $ |
---|
| 3 | ! |
---|
[2270] | 4 | SUBROUTINE qminimum_loc( q,nqtot,deltap ) |
---|
[1823] | 5 | USE parallel_lmdz |
---|
[5199] | 6 | USE infotrac, ONLY: niso, ntiso, iqIsoPha, tracers, addPhase, |
---|
[4143] | 7 | & isoCheck, min_qParent |
---|
| 8 | USE strings_mod, ONLY: strIdx |
---|
[1632] | 9 | IMPLICIT none |
---|
| 10 | c |
---|
| 11 | c -- Objet : Traiter les valeurs trop petites (meme negatives) |
---|
| 12 | c pour l'eau vapeur et l'eau liquide |
---|
| 13 | c |
---|
[2600] | 14 | include "dimensions.h" |
---|
| 15 | include "paramet.h" |
---|
[3801] | 16 | include "iniprint.h" |
---|
[1632] | 17 | c |
---|
[2270] | 18 | INTEGER nqtot ! CRisi: on remplace nq par nqtot |
---|
| 19 | REAL q(ijb_u:ije_u,llm,nqtot), deltap(ijb_u:ije_u,llm) |
---|
[1632] | 20 | c |
---|
[4143] | 21 | LOGICAL, SAVE :: first=.TRUE. |
---|
| 22 | INTEGER, SAVE :: iq_vap, iq_liq ! indices pour l'eau vapeur/liquide |
---|
| 23 | c$OMP THREADPRIVATE(iq_vap, iq_liq, first) |
---|
| 24 | REAL, PARAMETER :: seuil_vap = 1.0e-10 ! seuil pour l'eau vapeur |
---|
| 25 | REAL, PARAMETER :: seuil_liq = 1.0e-11 ! seuil pour l'eau liquide |
---|
[1632] | 26 | c |
---|
| 27 | c NB. ....( Il est souhaitable mais non obligatoire que les valeurs des |
---|
| 28 | c parametres seuil_vap, seuil_liq soient pareilles a celles |
---|
| 29 | c qui sont utilisees dans la routine ADDFI ) |
---|
| 30 | c ................................................................. |
---|
| 31 | c |
---|
[5001] | 32 | cDC iq_val and iq_liq are usable for q only, NOT for q_follow |
---|
| 33 | c and zx_defau_diag (crash if iq_val/liq==3) => vapor/liquid |
---|
| 34 | c water at hardcoded indices 1/2 in these variables |
---|
[1632] | 35 | INTEGER i, k, iq |
---|
| 36 | REAL zx_defau, zx_abc, zx_pump(ijb_u:ije_u), pompe |
---|
[2270] | 37 | |
---|
| 38 | real zx_defau_diag(ijb_u:ije_u,llm,2) |
---|
| 39 | real q_follow(ijb_u:ije_u,llm,2) |
---|
[1632] | 40 | c |
---|
| 41 | REAL SSUM |
---|
| 42 | EXTERNAL SSUM |
---|
| 43 | c |
---|
| 44 | INTEGER imprim |
---|
| 45 | SAVE imprim |
---|
| 46 | DATA imprim /0/ |
---|
| 47 | c$OMP THREADPRIVATE(imprim) |
---|
| 48 | INTEGER ijb,ije |
---|
| 49 | INTEGER Index_pump(ij_end-ij_begin+1) |
---|
| 50 | INTEGER nb_pump |
---|
[2270] | 51 | INTEGER ixt |
---|
| 52 | INTEGER iso_verif_noNaN_nostop |
---|
[1632] | 53 | |
---|
[4384] | 54 | c$OMP BARRIER |
---|
| 55 | |
---|
[4143] | 56 | !write(lunout,*) 'qminimum 52: entree' |
---|
| 57 | IF(first) THEN |
---|
| 58 | iq_vap = strIdx(tracers(:)%name, addPhase('H2O', 'g')) |
---|
| 59 | iq_liq = strIdx(tracers(:)%name, addPhase('H2O', 'l')) |
---|
| 60 | first = .FALSE. |
---|
| 61 | END IF |
---|
[5001] | 62 | c |
---|
| 63 | c Quand l'eau liquide est trop petite (ou negative), on prend |
---|
| 64 | c l'eau vapeur de la meme couche et la convertit en eau liquide |
---|
| 65 | c (sans changer la temperature !) |
---|
| 66 | c |
---|
| 67 | |
---|
[4143] | 68 | call check_isotopes(q,ij_begin,ij_end,'qminimum 52') |
---|
[2270] | 69 | |
---|
[1632] | 70 | ijb=ij_begin |
---|
| 71 | ije=ij_end |
---|
| 72 | |
---|
[4384] | 73 | DO k = 1, llm |
---|
| 74 | c$OMP DO SCHEDULE(STATIC) |
---|
| 75 | DO i = ijb, ije |
---|
| 76 | zx_defau_diag(i,k,1)=0.0 |
---|
| 77 | zx_defau_diag(i,k,2)=0.0 |
---|
[5001] | 78 | q_follow(i,k,1)=q(i,k,iq_vap) |
---|
| 79 | q_follow(i,k,2)=q(i,k,iq_liq) |
---|
[4384] | 80 | ENDDO |
---|
| 81 | c$OMP END DO NOWAIT |
---|
| 82 | ENDDO |
---|
[2270] | 83 | |
---|
[3800] | 84 | !write(lunout,*) 'qminimum 57' |
---|
[5001] | 85 | DO k = 1, llm |
---|
[4384] | 86 | c$OMP DO SCHEDULE(STATIC) |
---|
[5001] | 87 | DO i = ijb, ije |
---|
| 88 | if (seuil_liq - q(i,k,iq_liq) .gt. 0.d0 ) then |
---|
[2270] | 89 | |
---|
[5001] | 90 | if (niso > 0) zx_defau_diag(i,k,2)=AMAX1 |
---|
[2270] | 91 | : ( seuil_liq - q(i,k,iq_liq), 0.0 ) |
---|
| 92 | |
---|
[5001] | 93 | q(i,k,iq_vap) = q(i,k,iq_vap) + q(i,k,iq_liq) - seuil_liq |
---|
| 94 | q(i,k,iq_liq) = seuil_liq |
---|
| 95 | endif |
---|
| 96 | END DO |
---|
[4384] | 97 | c$OMP END DO NOWAIT |
---|
[5001] | 98 | END DO |
---|
[1632] | 99 | |
---|
| 100 | c |
---|
| 101 | c Quand l'eau vapeur est trop faible (ou negative), on complete |
---|
| 102 | c le defaut en prennant de l'eau vapeur de la couche au-dessous. |
---|
| 103 | c |
---|
[3800] | 104 | !write(lunout,*) 'qminimum 81' |
---|
[1632] | 105 | DO k = llm, 2, -1 |
---|
| 106 | ccc zx_abc = dpres(k) / dpres(k-1) |
---|
| 107 | c$OMP DO SCHEDULE(STATIC) |
---|
[5001] | 108 | DO i = ijb, ije |
---|
[2270] | 109 | |
---|
[5001] | 110 | if ( seuil_vap - q(i,k,iq_vap) .gt. 0.d0 ) then |
---|
[2270] | 111 | |
---|
[5001] | 112 | if (niso > 0) zx_defau_diag(i,k,1) |
---|
| 113 | & = AMAX1( seuil_vap - q(i,k,iq_vap), 0.0 ) |
---|
[2270] | 114 | |
---|
[5001] | 115 | q(i,k-1,iq_vap) = q(i,k-1,iq_vap) - (seuil_vap |
---|
| 116 | & -q(i,k,iq_vap)) * deltap(i,k)/deltap(i,k-1) |
---|
| 117 | q(i,k,iq_vap) = seuil_vap |
---|
[2270] | 118 | |
---|
[5001] | 119 | endif |
---|
| 120 | ENDDO |
---|
[1632] | 121 | c$OMP END DO NOWAIT |
---|
| 122 | ENDDO |
---|
[2270] | 123 | |
---|
[1632] | 124 | c |
---|
| 125 | c Quand il s'agit de la premiere couche au-dessus du sol, on |
---|
| 126 | c doit imprimer un message d'avertissement (saturation possible). |
---|
| 127 | c |
---|
[3800] | 128 | !write(lunout,*) 'qminimum 106' |
---|
[1632] | 129 | nb_pump=0 |
---|
| 130 | c$OMP DO SCHEDULE(STATIC) |
---|
| 131 | DO i = ijb, ije |
---|
[5001] | 132 | zx_pump(i) = AMAX1( 0.0, seuil_vap - q(i,1,iq_vap) ) |
---|
| 133 | q(i,1,iq_vap) = AMAX1( q(i,1,iq_vap), seuil_vap ) |
---|
[1632] | 134 | IF (zx_pump(i) > 0.0) THEN |
---|
| 135 | nb_pump = nb_pump+1 |
---|
| 136 | Index_pump(nb_pump)=i |
---|
| 137 | ENDIF |
---|
| 138 | ENDDO |
---|
[4384] | 139 | c$OMP END DO NOWAIT |
---|
[1632] | 140 | ! pompe = SSUM(ije-ijb+1,zx_pump(ijb),1) |
---|
| 141 | |
---|
| 142 | IF (imprim.LE.100 .AND. nb_pump .GT. 0 ) THEN |
---|
| 143 | PRINT *, 'ATT!:on pompe de l eau au sol' |
---|
| 144 | DO i = 1, nb_pump |
---|
| 145 | imprim = imprim + 1 |
---|
| 146 | PRINT*,' en ',index_pump(i),zx_pump(index_pump(i)) |
---|
| 147 | ENDDO |
---|
| 148 | ENDIF |
---|
[2270] | 149 | |
---|
[3800] | 150 | !write(lunout,*) 'qminimum 128' |
---|
[4124] | 151 | if (niso > 0) then |
---|
[3800] | 152 | !write(lunout,*) 'qminimum 140' |
---|
[2270] | 153 | ! CRisi: traiter de même les traceurs d'eau |
---|
| 154 | ! Mais il faut les prendre à l'envers pour essayer de conserver la |
---|
| 155 | ! masse. |
---|
| 156 | ! 1) pompage dans le sol |
---|
| 157 | ! On suppose que ce pompage se fait sans isotopes -> on ne modifie |
---|
| 158 | ! rien ici et on croise les doigts pour que ça ne soit pas trop |
---|
| 159 | ! génant |
---|
[3800] | 160 | ! en fait, si, c'est genant quand les isotopes doivent eux même transporter des |
---|
| 161 | ! traceurs -> apporter aussi un peu d'isotopes... Combien? |
---|
| 162 | ! Essayer tnat/2 = -500 permil? C'est déjà mieux que -1000 |
---|
| 163 | ! permil... |
---|
| 164 | ! pb: que faire pour les traceurs? |
---|
| 165 | c$OMP DO SCHEDULE(STATIC) |
---|
[2270] | 166 | DO i = ijb, ije |
---|
| 167 | if (zx_pump(i).gt.0.0) then |
---|
[5001] | 168 | q_follow(i,1,1)=q_follow(i,1,1)+zx_pump(i) |
---|
[2270] | 169 | endif !if (zx_pump(i).gt.0.0) then |
---|
| 170 | enddo !DO i = ijb, ije |
---|
[4384] | 171 | c$OMP END DO NOWAIT |
---|
[2270] | 172 | |
---|
| 173 | ! 2) transfert de vap vers les couches plus hautes |
---|
[3800] | 174 | !write(lunout,*) 'qminimum 158' |
---|
[2270] | 175 | do k=2,llm |
---|
[3800] | 176 | c$OMP DO SCHEDULE(STATIC) |
---|
[2270] | 177 | DO i = ijb, ije |
---|
[5001] | 178 | if (zx_defau_diag(i,k,1).gt.0.0) then |
---|
[3800] | 179 | ! on ajoute la vapeur en k |
---|
[5001] | 180 | ! write(lunout,*) 'i,k,q_follow(i,k-1,ivap)=', |
---|
| 181 | ! : i,k,q_follow(i,k-1,1) |
---|
| 182 | if (q_follow(i,k-1,1).lt.min_qParent) then |
---|
[3800] | 183 | write(lunout,*) 'tmp qmin: on stoppe' |
---|
| 184 | write(lunout,*) 'zx_pump(i)=',zx_pump(i) |
---|
[5001] | 185 | write(lunout,*) 'q_follow(i,:,ivap)=', |
---|
| 186 | : q_follow(i,:,1) |
---|
[3800] | 187 | write(lunout,*) 'k=',k |
---|
| 188 | call abort_gcm("qminimum","not enough vapor",1) |
---|
| 189 | endif |
---|
[4143] | 190 | do ixt=1,ntiso |
---|
[3800] | 191 | ! write(lunout,*) 'qmin 168: ixt=',ixt |
---|
[5001] | 192 | ! write(lunout,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=', |
---|
[4143] | 193 | ! : q(i,k,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 194 | ! write(lunout,*) 'zx_defau_diag(i,k,ivap)=', |
---|
| 195 | ! : zx_defau_diag(i,k,1) |
---|
| 196 | ! write(lunout,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=', |
---|
[4143] | 197 | ! : q(i,k-1,iqIsoPha(ixt,iq_vap)) |
---|
[3800] | 198 | |
---|
[4143] | 199 | q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 200 | : +zx_defau_diag(i,k,1) |
---|
| 201 | : *q(i,k-1,iqIsoPha(ixt,iq_vap))/q_follow(i,k-1,1) |
---|
[2270] | 202 | |
---|
[4143] | 203 | if (isoCheck) then |
---|
| 204 | if(iso_verif_noNaN_nostop(q(i,k,iqIsoPha(ixt,iq_vap)), |
---|
[2270] | 205 | : 'qminimum 155').eq.1) then |
---|
| 206 | write(*,*) 'i,k,ixt=',i,k,ixt |
---|
[5001] | 207 | write(*,*) 'q_follow(i,k-1,ivap)=', |
---|
| 208 | : q_follow(i,k-1,1) |
---|
[4143] | 209 | write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=', |
---|
| 210 | : q(i,k,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 211 | write(*,*) 'zx_defau_diag(i,k,ivap)=', |
---|
| 212 | : zx_defau_diag(i,k,1) |
---|
[4143] | 213 | write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=', |
---|
| 214 | : q(i,k-1,iqIsoPha(ixt,iq_vap)) |
---|
[4469] | 215 | CALL abort_gcm("qminimum_loc","stopped",1) |
---|
[2270] | 216 | endif |
---|
| 217 | endif |
---|
| 218 | |
---|
| 219 | ! et on la retranche en k-1 |
---|
[4143] | 220 | q(i,k-1,iqIsoPha(ixt,iq_vap)) = |
---|
| 221 | : q(i,k-1,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 222 | : -zx_defau_diag(i,k,1) |
---|
[2270] | 223 | : *deltap(i,k)/deltap(i,k-1) |
---|
[4143] | 224 | : *q(i,k-1,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 225 | : /q_follow(i,k-1,1) |
---|
[2270] | 226 | |
---|
[4143] | 227 | if (isoCheck) then |
---|
| 228 | if (iso_verif_noNaN_nostop( |
---|
| 229 | : q(i,k-1,iqIsoPha(ixt,iq_vap)), |
---|
[2270] | 230 | : 'qminimum 175').eq.1) then |
---|
| 231 | write(*,*) 'k,i,ixt=',k,i,ixt |
---|
[5001] | 232 | write(*,*) 'q_follow(i,k-1,ivap)=', |
---|
| 233 | : q_follow(i,k-1,1) |
---|
[4143] | 234 | write(*,*) 'q(i,k,iqIsoPha(ixt,iq_vap))=', |
---|
| 235 | : q(i,k,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 236 | write(*,*) 'zx_defau_diag(i,k,ivap)=', |
---|
| 237 | : zx_defau_diag(i,k,1) |
---|
[4143] | 238 | write(*,*) 'q(i,k-1,iqIsoPha(ixt,iq_vap))=', |
---|
| 239 | : q(i,k-1,iqIsoPha(ixt,iq_vap)) |
---|
[4469] | 240 | CALL abort_gcm("qminimum_loc","stopped",1) |
---|
[2270] | 241 | endif |
---|
| 242 | endif |
---|
| 243 | |
---|
| 244 | enddo !do ixt=1,niso |
---|
[5001] | 245 | q_follow(i,k,1)= q_follow(i,k,1) |
---|
| 246 | : +zx_defau_diag(i,k,1) |
---|
| 247 | q_follow(i,k-1,1)= q_follow(i,k-1,1) |
---|
| 248 | : -zx_defau_diag(i,k,1) |
---|
[2270] | 249 | : *deltap(i,k)/deltap(i,k-1) |
---|
[5001] | 250 | endif !if (zx_defau_diag(i,k,1).gt.0.0) then |
---|
[2270] | 251 | enddo !DO i = 1, ip1jmp1 |
---|
[4384] | 252 | c$OMP END DO NOWAIT |
---|
[3800] | 253 | enddo !do k=2,llm |
---|
[2270] | 254 | |
---|
[4143] | 255 | call check_isotopes(q,ijb,ije,'qminimum 168') |
---|
[2270] | 256 | |
---|
| 257 | |
---|
| 258 | ! 3) transfert d'eau de la vapeur au liquide |
---|
| 259 | !write(*,*) 'qminimum 164' |
---|
| 260 | do k=1,llm |
---|
[3800] | 261 | c$OMP DO SCHEDULE(STATIC) |
---|
[2270] | 262 | DO i = ijb, ije |
---|
[5001] | 263 | if (zx_defau_diag(i,k,2).gt.0.0) then |
---|
[2270] | 264 | |
---|
| 265 | ! on ajoute eau liquide en k en k |
---|
[4143] | 266 | do ixt=1,ntiso |
---|
| 267 | q(i,k,iqIsoPha(ixt,iq_liq))=q(i,k,iqIsoPha(ixt,iq_liq)) |
---|
[5001] | 268 | : +zx_defau_diag(i,k,2) |
---|
| 269 | : *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1) |
---|
[2270] | 270 | ! et on la retranche à la vapeur en k |
---|
[4143] | 271 | q(i,k,iqIsoPha(ixt,iq_vap))=q(i,k,iqIsoPha(ixt,iq_vap)) |
---|
[5001] | 272 | : -zx_defau_diag(i,k,2) |
---|
| 273 | : *q(i,k,iqIsoPha(ixt,iq_vap))/q_follow(i,k,1) |
---|
[2270] | 274 | enddo !do ixt=1,niso |
---|
[5001] | 275 | q_follow(i,k,2)= q_follow(i,k,2) |
---|
| 276 | : +zx_defau_diag(i,k,2) |
---|
| 277 | q_follow(i,k,1)= q_follow(i,k,1) |
---|
| 278 | : -zx_defau_diag(i,k,2) |
---|
| 279 | endif !if (zx_defau_diag(i,k,1).gt.0.0) then |
---|
[3800] | 280 | enddo !DO i = ijb, ije |
---|
[4384] | 281 | c$OMP END DO NOWAIT |
---|
[2270] | 282 | enddo !do k=2,llm |
---|
| 283 | |
---|
[4143] | 284 | call check_isotopes(q,ijb,ije,'qminimum 197') |
---|
[2270] | 285 | |
---|
[4124] | 286 | endif !if (niso > 0) then |
---|
[2270] | 287 | !write(*,*) 'qminimum 188' |
---|
[4384] | 288 | c$OMP BARRIER |
---|
| 289 | |
---|
[1632] | 290 | c |
---|
| 291 | RETURN |
---|
| 292 | END |
---|