Changeset 1639
- Timestamp:
- Dec 6, 2016, 11:50:13 AM (8 years ago)
- Location:
- trunk/LMDZ.VENUS/libf/phyvenus
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LMDZ.VENUS/libf/phyvenus/new_cloud_sedim.F
r1621 r1639 262 262 c On peut avoir theoriquement le cas ou on epuise tout le VMR present 263 263 IF (zqi_sa(ig,l).LT.0.0D0) THEN 264 265 264 c PRINT*,'STOP sedimentation on epuise tout le VMR present' 265 c PRINT*,'couche',ig,'level',l 266 266 c STOP 267 267 c Ce n est pas juste mais il faudrait alors adapter les pas … … 286 286 c On peut avoir theoriquement le cas ou on epuise tout le VMR present 287 287 IF (zqi_wv(ig,l).LT.0.0D0) THEN 288 289 288 c PRINT*,'STOP sedimentation on epuise tout le VMR present' 289 c PRINT*,'couche',ig,'level',l 290 290 c STOP 291 291 c Ce n est pas juste mais il faudrait alors adapter les pas -
trunk/LMDZ.VENUS/libf/phyvenus/new_cloud_venus.F
r1442 r1639 19 19 USE chemparam_mod 20 20 IMPLICIT NONE 21 22 #include "YOMCST.h" 23 21 22 #include "YOMCST.h" 23 24 24 INTEGER, INTENT(IN) :: nblon ! nombre de points horizontaux 25 25 INTEGER, INTENT(IN) :: nblev ! nombre de couches verticales 26 26 27 27 !---------------------------------------------------------------------------- 28 28 ! Ambient air state variables: … … 34 34 !---------------------------------------------------------------------------- 35 35 ! Thermodynamic functions: 36 REAL :: RHODROPLET 36 REAL :: RHODROPLET 37 37 !---------------------------------------------------------------------------- 38 38 ! Auxilary variables: … … 47 47 ! Ridder's Method variables: 48 48 REAL :: WVMIN, WVMAX, WVACC 49 49 50 50 INTEGER :: NBROOT 51 51 52 52 INTEGER :: MAXITE 53 53 PARAMETER(MAXITE=20) 54 54 55 55 INTEGER :: NBRAC 56 PARAMETER(NBRAC= 20)57 56 PARAMETER(NBRAC=5) 57 58 58 INTEGER :: FLAG 59 59 !---------------------------------------------------------------------------- 60 60 c Ratio radius shell model du mode 3 61 c ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62 c Ce ratio correspond aux mesures effectuées par J. Cimino (1982), Icarus 63 c Fixer ce parametre a 0 revient a une gouttelette pure en liquide acide sulfurique 64 REAL, PARAMETER :: qrad = 0.97 65 REAL :: qmass 66 c masse volumique du coeur (kg.m-3) 67 REAL, PARAMETER :: rho_core = 2500.0 61 68 !---------------------------------------------------------------------------- 62 69 ! External functions needed: 63 70 REAL :: IRFRMWV 64 !---------------------------------------------------------------------------- 65 66 71 !---------------------------------------------------------------------------- 72 73 67 74 ! >>> Program starts here: 68 75 … … 70 77 ! These aerosols will then be given an equilibrium composition for the given size distribution 71 78 72 ! Hanna Vehkamäki and Markku Kulmala and Ismo Napari 79 ! Hanna Vehkamäki and Markku Kulmala and Ismo Napari 73 80 ! and Kari E. J. Lehtinen and Claudia Timmreck and Madis Noppel and Ari Laaksonen, 2002, 74 ! An improved parameterization for sulfuric acid/water nucleation rates for tropospheric 81 ! An improved parameterization for sulfuric acid/water nucleation rates for tropospheric 75 82 !and stratospheric conditions, () J. Geophys. Res., 107, PP. 4622-4631 76 83 … … 82 89 WH2SO4(:,:)=0.0E+0 83 90 rho_droplet(:,:)=0.0E+0 84 91 85 92 DO ilev=cloudmin, cloudmax 86 DO ilon=1, nblon 87 93 DO ilon=1, nblon 94 88 95 ! Boucle sur les modes 89 96 RMODE=0.0E+0 90 97 K_SAV = 0.0 91 98 92 99 DO imode=1, nbr_mode 93 100 IF (K_MASS(ilon,ilev,imode).GT.K_SAV) THEN … … 106 113 ! Accuracy de WVeq 107 114 WVACC=WVMAX*1.0E-3 108 115 109 116 ! BRACWV borne la fonction f(WV) - WV = 0 110 117 ! de WV=0 à WV=WVtot on cherche l'intervalle où f(WV) - WV = 0 111 ! avec précisément f(WVliq de WSA<=WVinput) + WVinput - WVtot = 0 118 ! avec précisément f(WVliq de WSA<=WVinput) + WVinput - WVtot = 0 112 119 ! Elle fait appel à la fct/ssrtine ITERWV() 113 120 114 121 CALL BRACWV(WVMIN,WVMAX,NBRAC,RMODE, 115 122 & mrt_wv(ilon,ilev),mrt_sa(ilon,ilev),TT(ilon,ilev), 116 123 & PP(ilon,ilev),FLAG,WSAFLAG,NBROOT) 117 124 118 125 SELECT CASE(FLAG) 119 120 CASE(1) 121 ! Cas NROOT=1 ou NROOT>1 mais dans un intervalle restreint WVTOT (cas courant) 122 ! IRFRMWV Ridder's method pour trouver, sur [WVmin,WVmax], WVo tel que f(WVo) - WVo = 0 126 127 CASE(1) 128 ! Cas NROOT=1 ou NROOT>1 mais dans un intervalle restreint WVTOT (cas courant) 129 ! IRFRMWV Ridder's method pour trouver, sur [WVmin,WVmax], WVo tel que f(WVo) - WVo = 0 123 130 ! Elle fait appel la fct/ssrtine ITERWV() 124 131 125 132 WH2SO4(ilon,ilev)=IRFRMWV(WVMIN,WVMAX,WVACC,MAXITE,RMODE, 126 133 & TT(ilon,ilev),PP(ilon,ilev), 127 & mrt_wv(ilon,ilev),mrt_sa(ilon,ilev),NBROOT) 134 & mrt_wv(ilon,ilev),mrt_sa(ilon,ilev),NBROOT) 128 135 129 136 rho_droplet(ilon,ilev)=RHODROPLET(WH2SO4(ilon,ilev), 130 & TT(ilon,ilev)) 137 & TT(ilon,ilev)) 131 138 132 139 ! IF (rho_droplet(ilon,ilev).LT.1100.) THEN … … 139 146 ! STOP 140 147 ! ENDIF 141 148 142 149 CONCM= PP(ilon,ilev)/(1.3806488E-23*TT(ilon,ilev)) !air number density, molec/m3 143 150 144 NH2SO4=mrt_sa(ilon,ilev)*CONCM145 NH2O=mrt_wv(ilon,ilev)*CONCM151 NH2SO4=mrt_sa(ilon,ilev)*CONCM 152 NH2O=mrt_wv(ilon,ilev)*CONCM 146 153 147 154 CALL CALCM_SAT(NH2SO4,NH2O,WH2SO4(ilon,ilev), … … 150 157 151 158 ! Boucle sur les modes 152 DO imode=1, nbr_mode 153 IF (K_MASS(ilon,ilev,imode).GT.0.) THEN 159 ! ********************************************* 160 ! AVEC MODE 3 type J. Cimino 1982, Icarus 161 ! ********************************************* 162 ! Mode 1 et 2 avec les Kmass modifies 163 DO imode=1, nbr_mode-1 164 ! calcul qmass 165 qmass = (rho_core*qrad**3)/ 166 & (rho_core*qrad**3 + rho_droplet(ilon,ilev)*(1.-qrad**3)) 167 168 IF (K_MASS(ilon,ilev,imode).GT.0.) THEN 154 169 NBRTOT(ilon,ilev,imode)= 1.E-6*3./(4.*RPI)* 155 & K_MASS(ilon,ilev,imode) *MCONDTOT*156 & EXP(-4.5*DLOG(STDDEV(ilon,ilev,imode))**2.)/170 & K_MASS(ilon,ilev,imode)/(1.-qmass*K_MASS(ilon,ilev,3))* 171 & MCONDTOT*EXP(-4.5*DLOG(STDDEV(ilon,ilev,imode))**2.)/ 157 172 & (R_MEDIAN(ilon,ilev,imode)**3.) 158 173 ELSE 159 174 NBRTOT(ilon,ilev,imode)=0.0E+0 160 ENDIF 161 ENDDO 175 ENDIF 176 ENDDO 177 ! Mode 3 reste identique car on veut le N correspondant aux mesures de Knollenberg 178 IF (K_MASS(ilon,ilev,3).GT.0.) THEN 179 NBRTOT(ilon,ilev,3)= 1.E-6*3./(4.*RPI)* 180 & K_MASS(ilon,ilev,3)*MCONDTOT* 181 & EXP(-4.5*DLOG(STDDEV(ilon,ilev,3))**2.)/ 182 & (R_MEDIAN(ilon,ilev,3)**3.) 183 ELSE 184 NBRTOT(ilon,ilev,3)=0.0E+0 185 ENDIF 162 186 163 187 ! Passage de #/m3 en VMR … … 167 191 mr_wv(ilon,ilev)=mrt_wv(ilon,ilev)-H2O_liq 168 192 mr_sa(ilon,ilev)=mrt_sa(ilon,ilev)-H2SO4_liq 169 193 170 194 ! Problemes quand on a condense tout, on peut obtenir des -1e-24 171 195 ! aprs la soustraction et conversion de ND VMR 172 IF (mr_wv(ilon,ilev).LE.0.0) mr_wv(ilon,ilev)=1.0E-30 196 IF (mr_wv(ilon,ilev).LE.0.0) mr_wv(ilon,ilev)=1.0E-30 173 197 IF (mr_sa(ilon,ilev).LE.0.0) mr_sa(ilon,ilev)=1.0E-30 174 198 … … 176 200 177 201 CASE(2) 178 ! Cas NROOT=0 mais proche de 0 202 ! Cas NROOT=0 mais proche de 0 179 203 180 204 WH2SO4(ilon,ilev)=WSAFLAG 181 205 182 206 rho_droplet(ilon,ilev)=RHODROPLET(WH2SO4(ilon,ilev), 183 & TT(ilon,ilev)) 207 & TT(ilon,ilev)) 184 208 185 209 ! ATTENTION ce IF ne sert a rien en fait, juste a retenir une situation 186 210 ! ubuesque dans mon code ou sans ce IF les valeurs de rho_droplets sont 187 ! incoh rentes avec TT et WH2SO4 (a priori lorsque NTOT=0)211 ! incoherentes avec TT et WH2SO4 (a priori lorsque NTOT=0) 188 212 ! Juste le fait de METTRE un IF fait que rho_droplet a la bonne valeur 189 213 ! donne par RHODROPLET (cf test externe en Python), sinon, la valeur est trop 190 ! basse (de l'ordre de 1000 kg/m3) et correspond parfois la valeur avec191 ! WSA=0.1 (pas totalement sur) 214 ! basse (de l'ordre de 1000 kg/m3) et correspond parfois a la valeur avec 215 ! WSA=0.1 (pas totalement sur) 192 216 ! En tous cas, incoherent avec ce qui est attendue pour le WSA et T donnee 193 ! La version avec le IF (rho<1100 & WSA>0.1) est CORRECTE, rho_droplet a 217 ! La version avec le IF (rho<1100 & WSA>0.1) est CORRECTE, rho_droplet a 194 218 ! la bonne valeur (tests externes Python confirment) 195 219 196 220 IF ((rho_droplet(ilon,ilev).LT.1100.).AND. 197 221 & (WH2SO4(ilon,ilev).GT.0.1))THEN … … 203 227 PRINT*,'FLAG',FLAG,'NROOT',NBROOT 204 228 STOP 205 ENDIF 206 207 229 ENDIF 230 231 208 232 CONCM= PP(ilon,ilev)/(1.3806488E-23*TT(ilon,ilev)) !air number density, molec/m3 209 233 … … 216 240 217 241 ! Boucle sur les modes 218 DO imode=1, nbr_mode 219 IF (K_MASS(ilon,ilev,imode).GT.0.) THEN 242 ! ********************************************* 243 ! AVEC MODE 3 type J. Cimino 1982, Icarus 244 ! ********************************************* 245 ! Mode 1 et 2 avec alcul coeff*Kmass 246 DO imode=1, nbr_mode-1 247 ! calcul qmass 248 qmass = (rho_core*qrad**3)/ 249 & (rho_core*qrad**3 + rho_droplet(ilon,ilev)*(1.-qrad**3)) 250 251 IF (K_MASS(ilon,ilev,imode).GT.0.) THEN 220 252 NBRTOT(ilon,ilev,imode)= 1.E-6*3./(4.*RPI)* 221 & K_MASS(ilon,ilev,imode) *MCONDTOT*222 & EXP(-4.5*DLOG(STDDEV(ilon,ilev,imode))**2.)/253 & K_MASS(ilon,ilev,imode)/(1.-qmass*K_MASS(ilon,ilev,3))* 254 & MCONDTOT*EXP(-4.5*DLOG(STDDEV(ilon,ilev,imode))**2.)/ 223 255 & (R_MEDIAN(ilon,ilev,imode)**3.) 224 256 ELSE 225 257 NBRTOT(ilon,ilev,imode)=0.0E+0 226 ENDIF 227 ENDDO 258 ENDIF 259 ENDDO 260 ! Mode 3 reste identique car on veut le N correspondant aux mesures de Knollenberg 261 IF (K_MASS(ilon,ilev,3).GT.0.) THEN 262 NBRTOT(ilon,ilev,3)= 1.E-6*3./(4.*RPI)* 263 & K_MASS(ilon,ilev,3)*MCONDTOT* 264 & EXP(-4.5*DLOG(STDDEV(ilon,ilev,3))**2.)/ 265 & (R_MEDIAN(ilon,ilev,3)**3.) 266 ELSE 267 NBRTOT(ilon,ilev,3)=0.0E+0 268 ENDIF 269 228 270 229 271 ! Passage de #/m3 en VMR … … 233 275 mr_wv(ilon,ilev)=mrt_wv(ilon,ilev)-H2O_liq 234 276 mr_sa(ilon,ilev)=mrt_sa(ilon,ilev)-H2SO4_liq 235 277 236 278 ! Problmes quand on a condense tout, on peut obtenir des -1e-24 237 279 ! aprs la soustraction et conversion de ND VMR 238 IF (mr_wv(ilon,ilev).LE.0.0) mr_wv(ilon,ilev)=1.0E-30 280 IF (mr_wv(ilon,ilev).LE.0.0) mr_wv(ilon,ilev)=1.0E-30 239 281 IF (mr_sa(ilon,ilev).LE.0.0) mr_sa(ilon,ilev)=1.0E-30 240 282 241 283 CASE(3) 242 ! Cas 0 NROOT 284 ! Cas 0 NROOT 243 285 mr_wv(ilon,ilev)=mrt_wv(ilon,ilev) 244 286 mr_sa(ilon,ilev)=mrt_sa(ilon,ilev) … … 246 288 WH2SO4(ilon,ilev)=0.0E+0 247 289 DO imode=1, nbr_mode 248 NBRTOT(ilon,ilev,imode)=0.0E+0 249 ENDDO 250 251 END SELECT 252 ENDDO !FIN boucle ilon 253 ENDDO !FIN boucle ilev 254 290 NBRTOT(ilon,ilev,imode)=0.0E+0 291 ENDDO 292 293 END SELECT 294 ENDDO !FIN boucle ilon 295 ENDDO !FIN boucle ilev 296 255 297 END SUBROUTINE new_cloud_venus 256 257 298 299 258 300 !***************************************************************************** 259 !* SUBROUTINE ITERWV() 301 !* SUBROUTINE ITERWV() 260 302 SUBROUTINE ITERWV(WV,WVLIQ,WVEQOUT,WVTOT,WSAOUT,SATOT, 261 303 + TAIR,PAIR,RADIUS) 262 304 !***************************************************************************** 263 !* Cette routine est la solution par it ration afin de trouver WSA pour un WV,264 !* et donc LPPWV, donn . Ce qui nous donne egalement le WV correspondant au265 !* WSA solution 266 !* For VenusGCM by A. Stolzenbach 07/2014 305 !* Cette routine est la solution par iteration afin de trouver WSA pour un WV, 306 !* et donc LPPWV, donne. Ce qui nous donne egalement le WV correspondant au 307 !* WSA solution 308 !* For VenusGCM by A. Stolzenbach 07/2014 267 309 !* OUTPUT: WVEQ et WSAOUT 268 310 269 311 IMPLICIT NONE 270 REAL, INTENT(IN) :: WV, WVTOT, SATOT, TAIR, PAIR, RADIUS 271 312 REAL, INTENT(IN) :: WV, WVTOT, SATOT, TAIR, PAIR, RADIUS 313 272 314 REAl, INTENT(OUT) :: WVEQOUT, WSAOUT, WVLIQ 273 315 274 316 REAL :: WSAMIN, WSAMAX, WSAACC 275 PARAMETER(WSAACC=0.0 01)276 317 PARAMETER(WSAACC=0.01) 318 277 319 REAL :: LPPWV 278 320 279 321 INTEGER :: MAXITSA, NBRACSA, NBROOT 280 322 PARAMETER(MAXITSA=20) 281 PARAMETER(NBRACSA= 20)282 323 PARAMETER(NBRACSA=5) 324 283 325 LOGICAl :: FLAG1,FLAG2 284 326 285 ! External Function 327 ! External Function 286 328 REAl :: IRFRMSA, WVCOND 287 329 288 330 IF (RADIUS.LT.1E-30) THEN 289 331 PRINT*,'RMODE == 0 FLAG 3' 290 332 STOP 291 333 ENDIF 292 ! Initialisation WSA=[0.1,1.0] 334 ! Initialisation WSA=[0.1,1.0] 293 335 WSAMIN=0.1 294 336 WSAMAX=1.0 295 337 296 338 LPPWV=DLOG(PAIR*WV) 297 298 ! Appel Bracket de KEEQ 339 340 ! Appel Bracket de KEEQ 299 341 CALL BRACWSA(WSAMIN,WSAMAX,NBRACSA,RADIUS,TAIR, 300 342 & LPPWV,FLAG1,FLAG2,NBROOT) 301 302 IF ((.NOT.FLAG1).AND.(.NOT.FLAG2).AND.(NBROOT.EQ.1)) THEN 343 344 IF ((.NOT.FLAG1).AND.(.NOT.FLAG2).AND.(NBROOT.EQ.1)) THEN 303 345 ! Appel Ridder's Method 304 346 305 WSAOUT=IRFRMSA(WSAMIN,WSAMAX,WSAACC,MAXITSA, 347 WSAOUT=IRFRMSA(WSAMIN,WSAMAX,WSAACC,MAXITSA, 306 348 & RADIUS,TAIR,PAIR,LPPWV,NBROOT) 307 349 ! IF (WSAOUT.EQ.1.0) WSAOUT=0.999999 … … 313 355 IF (FLAG2.AND.(.NOT.FLAG1)) WSAOUT=WSAMIN 314 356 IF (FLAG1.AND.FLAG2) THEN 315 PRINT*,'FLAGs B ARCWSA tous TRUE'357 PRINT*,'FLAGs BRACWSA tous TRUE' 316 358 STOP 317 359 ENDIF 318 360 ENDIF 319 320 361 362 321 363 ! WVEQ output correspondant a WVliq lie a WSA calcule 322 364 WVLIQ=WVCOND(WSAOUT,TAIR,PAIR,SATOT) 323 365 WVEQOUT=(WVLIQ+WV)/WVTOT-1.0 324 366 325 367 END SUBROUTINE ITERWV 326 368 327 369 328 370 !***************************************************************************** 329 !* SUBROUTINE BRACWV() 371 !* SUBROUTINE BRACWV() 330 372 SUBROUTINE BRACWV(XA,XB,N,RADIUS,WVTOT,SATOT,TAIR,PAIR, 331 373 + FLAGWV,WSAFLAG,NROOT) 332 374 !***************************************************************************** 333 375 !* Bracket de ITERWV 334 !* From Numerical Recipes 335 !* Adapted for VenusGCM A. Stolzenbach 07/2014 376 !* From Numerical Recipes 377 !* Adapted for VenusGCM A. Stolzenbach 07/2014 336 378 !* X est WVinput 337 !* OUTPUT: XA et XB 379 !* OUTPUT: XA et XB 338 380 339 381 IMPLICIT NONE … … 341 383 REAL, INTENT(IN) :: WVTOT,SATOT,RADIUS,TAIR,PAIR 342 384 INTEGER, INTENT(IN) :: N 343 385 344 386 REAL, INTENT(INOUT) :: XA,XB 345 387 REAL, INTENT(OUT) :: WSAFLAG 346 388 347 389 INTEGER :: I,J 348 390 349 391 INTEGER, INTENT(OUT) :: NROOT 350 392 351 393 REAL :: FP, FC, X, WVEQ, WVLIQ, WSAOUT 352 394 REAL :: XMAX,XMIN,WVEQACC 353 395 354 396 INTEGER, INTENT(OUT) :: FLAGWV 355 397 … … 358 400 ! s'approche de 0 mais ne l'atteint pas. 359 401 WVEQACC=1.0E-3 360 402 361 403 FLAGWV=1 362 404 363 405 NROOT=0 364 406 365 X=XA 407 ! 25/11/2016 408 ! On change ordre on va du max au min 409 X=XB 366 410 XMAX=XB 367 411 XMIN=XA 368 412 369 413 ! CAS 1 On borne la fonction (WVEQ=0) 370 414 371 415 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSAOUT,SATOT,TAIR,PAIR,RADIUS) 372 416 FP=WVEQ 373 374 DO I= 1,N-1417 418 DO I=N-1,1,-1 375 419 X=(1.-DLOG(REAL(N-I))/DLOG(REAL(N)))*XMAX 376 420 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSAOUT,SATOT,TAIR,PAIR,RADIUS) 377 421 FC=WVEQ 378 422 379 IF ((FP*FC).LT.0.0) THEN 423 IF ((FP*FC).LT.0.0) THEN 380 424 NROOT=NROOT+1 381 ! Si NROOT>1 on place la borne sup output la borne min du calcul en i 425 ! Si NROOT>1 on place la borne sup output la borne min du calcul en i 382 426 IF (NROOT.GT.1) THEN 383 XB=(1.-DLOG(REAL( N-I+1))/DLOG(REAL(N)))*XMAX427 XB=(1.-DLOG(REAL(I+1))/DLOG(REAL(N)))*XMAX 384 428 ENDIF 385 429 … … 387 431 XA=XMIN 388 432 ELSE 389 XA= (1.-DLOG(REAL(N-I+1))/DLOG(REAL(N)))*XMAX433 XA=X 390 434 ENDIF 391 XB=X392 ENDIF 435 RETURN 436 ENDIF 393 437 FP=FC 394 438 ENDDO 395 439 396 ! CAS 2 on refait la boucle pour tester si WVEQ est proche de 0 440 ! CAS 2 on refait la boucle pour tester si WVEQ est proche de 0 397 441 ! avec le seuil WVEQACC 398 442 IF (NROOT.EQ.0) THEN 399 X=XM IN443 X=XMAX 400 444 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSAOUT,SATOT, 401 445 + TAIR,PAIR,RADIUS) 402 DO J= 1,N-1446 DO J=N-1,1,-1 403 447 X=(1.-DLOG(REAL(N-J))/DLOG(REAL(N)))*XMAX 404 448 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSAOUT,SATOT, 405 449 + TAIR,PAIR,RADIUS) 406 450 407 451 IF (ABS(WVEQ).LE.WVEQACC) THEN 408 452 WSAFLAG=WSAOUT … … 412 456 ENDDO 413 457 414 ! CAS 3 Pas de borne, WVEQ jamais proche de 0 458 ! CAS 3 Pas de borne, WVEQ jamais proche de 0 415 459 FLAGWV=3 416 460 RETURN … … 418 462 419 463 END SUBROUTINE BRACWV 420 464 421 465 !***************************************************************************** 422 !* SUBROUTINE BRACWSA() 466 !* SUBROUTINE BRACWSA() 423 467 SUBROUTINE BRACWSA(XA,XB,N,RADIUS,TAIR,LPPWVINP,FLAGH,FLAGL, 424 468 + NROOT) 425 469 !***************************************************************************** 426 470 !* Bracket de KEEQ 427 !* From Numerical Recipes 428 !* Adapted for VenusGCM A. Stolzenbach 07/2014 429 471 !* From Numerical Recipes 472 !* Adapted for VenusGCM A. Stolzenbach 07/2014 473 430 474 IMPLICIT NONE 431 475 … … 433 477 ! External functions needed: 434 478 REAl KEEQ 435 !---------------------------------------------------------------------------- 436 437 REAL, INTENT(IN) :: RADIUS,TAIR,LPPWVINP 479 !---------------------------------------------------------------------------- 480 481 REAL, INTENT(IN) :: RADIUS,TAIR,LPPWVINP 438 482 INTEGER, INTENT(IN) :: N 439 483 440 484 REAL, INTENT(INOUT) :: XA,XB 441 485 442 486 INTEGER, INTENT(OUT) :: NROOT 443 487 444 488 INTEGER :: I, J 445 489 446 490 REAL :: DX, FP, FC, X 447 491 448 492 LOGICAL, INTENT(OUT) :: FLAGH,FLAGL 449 450 493 494 451 495 FLAGL=.FALSE. 452 FLAGH=.FALSE. 496 FLAGH=.FALSE. 453 497 NROOT=0 454 498 DX=(XB-XA)/N 455 X=X A499 X=XB 456 500 FP=KEEQ(RADIUS,TAIR,X,LPPWVINP) 457 458 DO I= 1,N459 X=X +DX501 502 DO I=N,1,-1 503 X=X-DX 460 504 FC=KEEQ(RADIUS,TAIR,X,LPPWVINP) 461 505 462 506 IF ((FP*FC).LE.0.) THEN 463 507 NROOT=NROOT+1 464 XA=X -DX465 XB=X 466 !RETURN508 XA=X 509 XB=X+DX 510 RETURN 467 511 ! IF (NROOT.GT.1) THEN 468 512 ! PRINT*,'On a plus d1 intervalle KEEQ=0' … … 479 523 ! ENDIF 480 524 ENDIF 481 525 482 526 FP=FC 483 527 ENDDO 484 528 485 529 IF (NROOT.EQ.0) THEN 486 530 ! PRINT*,'On a 0 intervalle KEEQ=0' … … 492 536 ! PRINT*,'NBRAC',N 493 537 ! STOP 494 538 495 539 ! X=XA 496 540 ! FP=KEEQ(RADIUS,TAIR,X,LPPWVINP) … … 503 547 504 548 505 ! Test determine la tendance globale KEEQ sur [WSAMIN,WSAMAX] 549 ! Test determine la tendance globale KEEQ sur [WSAMIN,WSAMAX] 506 550 IF ((ABS(KEEQ(RADIUS,TAIR,XA,LPPWVINP))- 507 551 & ABS(KEEQ(RADIUS,TAIR,XB,LPPWVINP))).GT.0.0) FLAGH=.TRUE. … … 511 555 ! STOP 512 556 ENDIF 513 557 514 558 END SUBROUTINE BRACWSA 515 516 559 560 517 561 !***************************************************************************** 518 !* REAL FUNCTION WVCOND() 562 !* REAL FUNCTION WVCOND() 519 563 REAL FUNCTION WVCOND(WSA,T,P,SAt) 520 564 !***************************************************************************** … … 527 571 ! T: temperature (K) 528 572 ! P: pressure (Pa) 529 ! OUTPUT: 573 ! OUTPUT: 530 574 ! WVCOND : VMR H2O condense 531 575 532 576 ! USE chemparam_mod 533 577 534 578 IMPLICIT NONE 535 579 … … 545 589 REAL NH2SO4 546 590 REAL H2OCOND, H2SO4COND 547 591 548 592 549 593 CONCM= (P)/(1.3806488E-23*T) !air number density, molec/m3? CHECK UNITS! 550 594 551 595 NH2SO4=SAt*CONCM 552 596 553 597 pstand=1.01325E+5 !Pa 1 atm pressure 554 598 … … 565 609 566 610 !acid sat.vap.PP over mixture (flat surface): 567 satpacid=act(2)*acidps ! Pa 611 satpacid=act(2)*acidps ! Pa 568 612 569 613 ! Conversion from Pa to N.D #/m3 570 614 DND2=satpacid/(1.3806488E-23*T) 571 615 572 616 ! H2SO4COND N.D #/m3 condensee ssi H2SO4>H2SO4sat 573 617 IF (NH2SO4.GT.DND2) THEN … … 576 620 H2OCOND=H2SO4COND*98.078*(1.0-WSA)/(18.0153*WSA) 577 621 578 ! Si on a H2SO4<H2SO4sat on ne condense rien, VMR = 1.0E-30 622 ! Si on a H2SO4<H2SO4sat on ne condense rien, VMR = 1.0E-30 579 623 ELSE 580 624 H2OCOND=1.0E-30*CONCM … … 582 626 583 627 !***************************************************** 584 ! ATTENTION: Ici on ne prends pas en compte 628 ! ATTENTION: Ici on ne prends pas en compte 585 629 ! si H2O en defaut! 586 630 ! On veut la situation theorique 587 631 ! a l'equilibre 588 !***************************************************** 632 !***************************************************** 589 633 ! Test si H2O en defaut H2Ocond>H2O dispo 590 634 ! IF ((H2OCOND.GT.NH2O).AND.(NH2SO4.GE.DND2)) THEN 591 635 592 636 ! On peut alors condenser tout le H2O dispo 593 637 ! H2OCOND=NH2O 594 638 ! On met alors egalement a jour le H2SO4 cond correspondant au H2O cond 595 639 ! H2SO4COND=H2OCOND*18.0153*WSA/(98.078*(1.0-WSA)) 596 640 597 641 ! END IF 598 642 599 ! Calcul de H2O condense VMR 643 ! Calcul de H2O condense VMR 600 644 WVCOND=H2OCOND/CONCM 601 645 602 646 END FUNCTION WVCOND 603 647 604 648 !***************************************************************************** 605 !* REAL FUNCTION IRFRMWV() 649 !* REAL FUNCTION IRFRMWV() 606 650 REAL FUNCTION IRFRMWV(X1,X2,XACC,MAXIT,RADIUS,TAIR,PAIR, 607 651 + WVTOT,SATOT,NROOT) … … 616 660 617 661 IMPLICIT NONE 618 662 619 663 REAL, INTENT(IN) :: X1, X2 620 REAL, INTENT(IN) :: XACC 664 REAL, INTENT(IN) :: XACC 621 665 INTEGER, INTENT(IN) :: MAXIT,NROOT 622 666 623 667 ! LOCAL VARIABLES 624 668 REAL :: XL, XH, XM, XNEW, X … … 627 671 REAL :: ANS, S, FSIGN 628 672 INTEGER i 629 673 630 674 ! External variables needed: 631 675 REAL, INTENT(IN) :: TAIR,PAIR … … 633 677 REAL, INTENT(IN) :: RADIUS 634 678 635 679 636 680 ! Initialisation 637 681 X=X1 638 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT,TAIR,PAIR,RADIUS) 682 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT,TAIR,PAIR,RADIUS) 639 683 FL=WVEQ 640 684 X=X2 641 685 CALL ITERWV(X,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT,TAIR,PAIR,RADIUS) 642 686 FH=WVEQ 643 644 ! Test Bracketed values 687 688 ! Test Bracketed values 645 689 IF (((FL.LT.0.).AND.(FH.GT.0.)).OR. 646 690 & ((FL.GT.0.).AND.(FH.LT.0.))) … … 649 693 XH=X2 650 694 ANS=-9.99e99 651 695 652 696 DO i=1, MAXIT 653 697 XM=0.5*(XL+XH) … … 656 700 FM=WVEQ 657 701 S=SQRT(FM*FM-FL*FH) 658 702 659 703 IF (S.EQ.0.0) THEN 660 704 IRFRMWV=WSALOC 661 705 RETURN 662 ENDIF 663 706 ENDIF 707 664 708 IF (FL.GT.FH) THEN 665 709 FSIGN=1.0 … … 667 711 FSIGN=-1.0 668 712 ENDIF 669 670 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 671 713 714 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 715 672 716 IF (ABS(XNEW-ANS).LE.XACC) THEN 673 717 IRFRMWV=WSALOC 674 718 RETURN 675 ENDIF 676 719 ENDIF 720 677 721 ANS=XNEW 678 722 CALL ITERWV(ANS,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT, 679 723 & TAIR,PAIR,RADIUS) 680 724 FNEW=WVEQ 681 725 682 726 IF (FNEW.EQ.0.0) THEN 683 727 IRFRMWV=WSALOC 684 728 RETURN 685 729 ENDIF 686 730 687 731 IF (SIGN(FM, FNEW).NE.FM) THEN 688 732 XL=XM … … 708 752 XH=X2 709 753 ANS=-9.99e99 710 754 711 755 DO i=1, MAXIT 712 756 XM=0.5*(XL+XH) … … 720 764 FSIGN=-1.0 721 765 ENDIF 722 723 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 724 766 767 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 768 725 769 ANS=XNEW 726 770 CALL ITERWV(ANS,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT, … … 753 797 PRINT*,'NROOT de BRACWV', NROOT 754 798 IF (ABS(FL).LT.XACC) THEN 755 PRINT*,'IRFRMWV FL == 0',FL 799 PRINT*,'IRFRMWV FL == 0',FL 756 800 PRINT*,'X1',X1,'X2',X2,'FH',FH 757 801 CALL ITERWV(X1,WVLIQ,WVEQ,WVTOT,WSALOC,SATOT, … … 768 812 RETURN 769 813 ENDIF 770 IF ((ABS(FL).GT.XACC).AND.(ABS(FH).GT.XACC)) THEN 814 IF ((ABS(FL).GT.XACC).AND.(ABS(FH).GT.XACC)) THEN 771 815 PRINT*,'STOP dans IRFRMWV avec rien == 0' 772 816 PRINT*,'X1',X1,'X2',X2 773 817 PRINT*,'Fcalc',FL,FH 774 818 PRINT*,'T',TAIR,'P',PAIR,'R',RADIUS 775 STOP 819 STOP 776 820 ENDIF 777 IF ((ABS(FL).LT.XACC).AND.(ABS(FH).LT.XACC)) THEN 821 IF ((ABS(FL).LT.XACC).AND.(ABS(FH).LT.XACC)) THEN 778 822 PRINT*,'STOP dans IRFRMWV Trop de solution < WVACC' 779 823 PRINT*,FL,FH 780 STOP 824 STOP 781 825 ENDIF 782 783 826 827 784 828 ENDIF 785 829 ! FIN Test Bracketed values 786 830 787 831 END FUNCTION IRFRMWV 788 832 789 833 !***************************************************************************** 790 !* REAL FUNCTION IRFRMSA() 834 !* REAL FUNCTION IRFRMSA() 791 835 REAL FUNCTION IRFRMSA(X1,X2,XACC,MAXIT,RADIUS,TAIR,PAIR,LPPWV, 792 836 + NB) … … 801 845 802 846 IMPLICIT NONE 803 847 804 848 REAL, INTENT(IN) :: X1, X2 805 REAL, INTENT(IN) :: XACC 849 REAL, INTENT(IN) :: XACC 806 850 INTEGER, INTENT(IN) :: MAXIT, NB 807 851 808 852 ! LOCAL VARIABLES 809 853 REAL XL, XH, XM, XNEW … … 811 855 REAL ANS, S, FSIGN 812 856 INTEGER i 813 857 814 858 ! External variables needed: 815 859 REAL, INTENT(IN) :: TAIR,PAIR 816 860 REAL, INTENT(IN) :: LPPWV 817 861 REAL, INTENT(IN) :: RADIUS 818 862 819 863 ! External functions needed: 820 864 REAL KEEQ 821 865 822 866 823 867 824 868 ! Initialisation 825 869 FL=KEEQ(RADIUS,TAIR,X1,LPPWV) 826 870 FH=KEEQ(RADIUS,TAIR,X2,LPPWV) 827 828 ! Test Bracketed values 871 872 ! Test Bracketed values 829 873 IF (((FL.LT.0.).AND.(FH.GT.0.)).OR.((FL.GT.0.).AND.(FH.LT.0.))) 830 874 & THEN … … 832 876 XH=X2 833 877 ANS=-9.99e99 834 878 835 879 DO i=1, MAXIT 836 880 XM=0.5*(XL+XH) 837 881 FM=KEEQ(RADIUS,TAIR,XM,LPPWV) 838 882 S=SQRT(FM*FM-FL*FH) 839 883 840 884 IF (S.EQ.0.0) THEN 841 885 IRFRMSA=ANS 842 886 RETURN 843 ENDIF 844 887 ENDIF 888 845 889 IF (FL.GT.FH) THEN 846 890 FSIGN=1.0 … … 848 892 FSIGN=-1.0 849 893 ENDIF 850 851 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 852 894 895 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 896 853 897 IF (ABS(XNEW-ANS).LE.XACC) THEN 854 898 IRFRMSA=ANS 855 899 RETURN 856 ENDIF 857 900 ENDIF 901 858 902 ANS=XNEW 859 903 FNEW=KEEQ(RADIUS,TAIR,ANS,LPPWV) 860 904 861 905 IF (FNEW.EQ.0.0) THEN 862 906 IRFRMSA=ANS 863 907 RETURN 864 908 ENDIF 865 909 866 910 IF (SIGN(FM, FNEW).NE.FM) THEN 867 911 XL=XM … … 888 932 PRINT*,'Borne XL',XL,'XH',XH 889 933 ANS=-9.99e99 890 934 891 935 DO i=1, MAXIT 892 936 XM=0.5*(XL+XH) 893 937 FM=KEEQ(RADIUS,TAIR,XM,LPPWV) 894 938 S=SQRT(FM*FM-FL*FH) 895 939 896 940 IF (FL.GT.FH) THEN 897 941 FSIGN=1.0 … … 899 943 FSIGN=-1.0 900 944 ENDIF 901 902 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 903 945 946 XNEW=XM+(XM-XL)*(FSIGN*FM/S) 947 904 948 ANS=XNEW 905 949 FNEW=KEEQ(RADIUS,TAIR,ANS,LPPWV) … … 937 981 IF ((FL.NE.0.).AND.(FH.NE.0.)) THEN 938 982 PRINT*,'IRFRMSA FH and FL neq 0: ', FL, FH 939 PRINT*,'X1',X1,'X2',X2 983 PRINT*,'X1',X1,'X2',X2 940 984 PRINT*,'Kind F', KIND(FL), KIND(FH) 941 985 PRINT*,'Kind X', KIND(X1), KIND(X2) … … 944 988 PRINT*,'nb root BRACWSA',NB 945 989 STOP 946 ENDIF 947 990 ENDIF 991 948 992 ENDIF 949 993 ! FIN Test Bracketed values 950 994 951 995 END function IRFRMSA 952 996 953 997 !***************************************************************************** 954 !* REAL FUNCTION KEEQ() 998 !* REAL FUNCTION KEEQ() 955 999 REAL FUNCTION KEEQ(RADIUS,TAIR,WSA,LPPWV) 956 1000 !***************************************************************************** … … 985 1029 + C1=2.0d0*MH2O/RGAS) 986 1030 987 1031 988 1032 KEEQ=LPPWV-C1*SIGMADROPLET(WSA,TAIR)/ 989 1033 & (TAIR*RADIUS*RHODROPLET(WSA,TAIR))- 990 1034 & PWVSAS_GV(TAIR,WSA) 991 1035 992 1036 END FUNCTION KEEQ 993 1037 994 1038 ***************************************************************************** 995 1039 * REAL FUNCTION PWVSAS_GV(TAIR,WSA) … … 1048 1092 + K2=K1*K1/2.0) 1049 1093 ! 1050 ! 1051 CP=CPH2O(WSA) 1052 F=-FFH2O(WSA) 1053 L=-LH2O(WSA) 1054 ALFA=ALH2O(WSA) 1094 INTEGER :: KLO,KHI,K,I,NPOINT 1095 PARAMETER(NPOINT=110) 1096 REAL, DIMENSION(NPOINT) :: WTAB(NPOINT) 1097 DATA (WTAB(I),I=1,NPOINT)/ 1098 +0.00000,0.08932,0.09819,0.10792,0.11980,0.13461,0.15360,0.16525, 1099 +0.17882,0.19482,0.21397,0.23728,0.26629,0.27999,0.29517,0.31209, 1100 +0.33107,0.35251,0.36430,0.37691,0.39043,0.40495,0.42059,0.43749, 1101 +0.44646,0.45580,0.46555,0.47572,0.48634,0.49745,0.50908,0.52126, 1102 +0.53405,0.54747,0.56159,0.57646,0.58263,0.58893,0.59537,0.60195, 1103 +0.60868,0.61557,0.62261,0.62981,0.63718,0.64472,0.65245,0.66037, 1104 +0.66847,0.67678,0.68530,0.69404,0.70300,0.71220,0.72164,0.73133, 1105 +0.73628,0.74129,0.74637,0.75152,0.75675,0.76204,0.76741,0.77286, 1106 +0.77839,0.78399,0.78968,0.79545,0.80130,0.80724,0.81327,0.81939, 1107 +0.82560,0.83191,0.83832,0.84482,0.85143,0.85814,0.86495,0.87188, 1108 +0.87892,0.88607,0.89334,0.90073,0.90824,0.91588,0.92365,0.93156, 1109 +0.93959,0.94777,0.95610,0.96457,0.97319,0.98196,0.99090,0.99270, 1110 +0.99452,0.99634,0.99725,0.99817,0.99835,0.99853,0.99872,0.99890, 1111 +0.99908,0.99927,0.99945,0.99963,0.99982,1.0000/ 1112 ! 1113 KLO=1 1114 KHI=NPOINT 1115 1 IF(KHI-KLO.GT.1) THEN 1116 K=(KHI+KLO)/2 1117 IF(WTAB(K).GT.MAX(WTAB(1),WSA)) THEN 1118 KHI=K 1119 ELSE 1120 KLO=K 1121 ENDIF 1122 GOTO 1 1123 ENDIF 1124 ! 1125 CP=CPH2O(WSA,KHI,KLO) 1126 F=-FFH2O(WSA,KHI,KLO) 1127 L=-LH2O(WSA,KHI,KLO) 1128 ALFA=ALH2O(WSA,KHI,KLO) 1055 1129 ! 1056 1130 A=ADOT+(CP-K1*ALFA)/RGAS … … 1070 1144 ******************************************************************************* 1071 1145 * REAL FUNCTION CPH2O(W) 1072 REAL FUNCTION CPH2O(W )1146 REAL FUNCTION CPH2O(W,khi_in,klo_in) 1073 1147 ******************************************************************************* 1074 1148 * … … 1086 1160 + Y2(NPOINT),YWORK(NPOINT) 1087 1161 REAL, INTENT(IN):: W 1162 INTEGER, INTENT(IN):: khi_in,klo_in 1163 INTEGER :: khi,klo 1088 1164 REAL :: CPH 1089 1165 LOGICAL :: FIRST … … 1125 1201 CALL SPLINE(WTAB,CPHTAB,NPOINT,YWORK,Y2) 1126 1202 ENDIF 1127 CALL SPLINT(WTAB,CPHTAB,Y2,NPOINT,W,CPH) 1203 1204 if(khi_in.GT.NPOINT) then 1205 khi=NPOINT 1206 klo=NPOINT-1 1207 else 1208 khi=khi_in 1209 klo=klo_in 1210 endif 1211 1212 CALL SPLINT(WTAB(khi),WTAB(klo),CPHTAB(khi),CPHTAB(klo), 1213 . Y2(khi),Y2(klo),W,CPH) 1128 1214 CPH2O=CPH 1129 1215 … … 1131 1217 ! 1132 1218 ******************************************************************************* 1133 REAL FUNCTION FFH2O(W )1219 REAL FUNCTION FFH2O(W,khi,klo) 1134 1220 * REAL FUNCTION FFH2O(W) 1135 1221 ******************************************************************************* … … 1147 1233 REAL, DIMENSION(NPOINT) :: WTAB,FFTAB,Y2,YWORK 1148 1234 REAL, INTENT(IN) :: W 1235 INTEGER, INTENT(IN):: khi,klo 1149 1236 REAL :: FF 1150 1237 LOGICAL :: FIRST … … 1186 1273 CALL SPLINE(WTAB,FFTAB,NPOINT,YWORK,Y2) 1187 1274 ENDIF 1188 CALL SPLINT(WTAB,FFTAB,Y2,NPOINT,W,FF) 1275 1276 CALL SPLINT(WTAB(khi),WTAB(klo),FFTAB(khi),FFTAB(klo), 1277 . Y2(khi),Y2(klo),W,FF) 1189 1278 FFH2O=FF 1190 1279 … … 1192 1281 ! 1193 1282 ******************************************************************************* 1194 REAL FUNCTION LH2O(W )1283 REAL FUNCTION LH2O(W,khi,klo) 1195 1284 * REAL FUNCTION LH2O(W) 1196 1285 ******************************************************************************* … … 1208 1297 REAL, DIMENSION(NPOINT) :: WTAB,LTAB,Y2,YWORK 1209 1298 REAL, INTENT(IN) :: W 1299 INTEGER, INTENT(IN):: khi,klo 1210 1300 REAL :: L 1211 1301 LOGICAL :: FIRST … … 1247 1337 CALL SPLINE(WTAB,LTAB,NPOINT,YWORK,Y2) 1248 1338 ENDIF 1249 CALL SPLINT(WTAB,LTAB,Y2,NPOINT,W,L) 1339 1340 CALL SPLINT(WTAB(khi),WTAB(klo),LTAB(khi),LTAB(klo), 1341 . Y2(khi),Y2(klo),W,L) 1250 1342 LH2O=L 1251 1343 1252 1344 END FUNCTION LH2O 1253 1345 ******************************************************************************* 1254 REAL FUNCTION ALH2O(W )1346 REAL FUNCTION ALH2O(W,khi_in,klo_in) 1255 1347 * REAL FUNCTION ALH2O(W) 1256 1348 ******************************************************************************* … … 1268 1360 REAL, DIMENSION(NPOINT) :: WTAB,ATAB,Y2,YWORK 1269 1361 REAL, INTENT(IN) :: W 1362 INTEGER, INTENT(IN):: khi_in,klo_in 1363 INTEGER :: khi,klo 1270 1364 REAL :: A 1271 1365 LOGICAL :: FIRST … … 1304 1398 CALL SPLINE(WTAB,ATAB,NPOINT,YWORK,Y2) 1305 1399 ENDIF 1306 CALL SPLINT(WTAB,ATAB,Y2,NPOINT,MAX(WTAB(1),W),A) 1400 1401 if(klo_in.LT.15) then 1402 khi=2 1403 klo=1 1404 else 1405 khi=khi_in-14 1406 klo=klo_in-14 1407 endif 1408 1409 CALL SPLINT(WTAB(khi),WTAB(klo),ATAB(khi),ATAB(klo), 1410 . Y2(khi),Y2(klo),W,A) 1307 1411 ALH2O=A 1308 1412 … … 1358 1462 1359 1463 !****************************************************************************** 1360 SUBROUTINE SPLINT(XA ,YA,Y2A,N,X,Y)1464 SUBROUTINE SPLINT(XAhi,XAlo,YAhi,YAlo,Y2Ahi,Y2Alo,X,Y) 1361 1465 !****************************************************************************** 1362 1466 ! Cubic spline calculation … … 1364 1468 IMPLICIT NONE 1365 1469 1366 INTEGER, INTENT(IN) :: N 1367 INTEGER :: KLO,KHI,K 1368 REAL, INTENT(IN), DIMENSION(N) :: XA,YA,Y2A 1470 REAL, INTENT(IN) :: XAhi,XAlo,YAhi,YAlo,Y2Ahi,Y2Alo 1369 1471 REAL, INTENT(IN) :: X 1370 1472 REAL, INTENT(OUT) :: Y 1371 1473 REAL :: H,A,B 1372 1474 ! 1373 KLO=1 1374 KHI=N 1375 1 IF(KHI-KLO.GT.1) THEN 1376 K=(KHI+KLO)/2 1377 IF(XA(K).GT.X) THEN 1378 KHI=K 1379 ELSE 1380 KLO=K 1381 ENDIF 1382 GOTO 1 1383 ENDIF 1384 H=XA(KHI)-XA(KLO) 1385 A=(XA(KHI)-X)/H 1386 B=(X-XA(KLO))/H 1387 Y=A*YA(KLO)+B*YA(KHI)+ 1388 + ((A**3-A)*Y2A(KLO)+(B**3-B)*Y2A(KHI))*(H**2)/6.0d0 1475 H=XAhi-XAlo 1476 A=(XAhi-X)/H 1477 B=(X-XAlo)/H 1478 Y=A*YAlo+B*YAhi+ 1479 + ((A**3-A)*Y2Alo+(B**3-B)*Y2Ahi)*(H**2)/6.0d0 1389 1480 ! 1390 1481 … … 1394 1485 + T,H2SO4COND,H2OCOND,RMTOT) 1395 1486 1396 ! DERIVE NO (TOTAL NUMBER OF AEROSOL PARTICLES CONCENTRATION) 1397 ! FROM TOTAL H2SO4 AND RMOD/SIGMA OF AEROSOL LOG-NORMAL 1487 ! DERIVE NO (TOTAL NUMBER OF AEROSOL PARTICLES CONCENTRATION) 1488 ! FROM TOTAL H2SO4 AND RMOD/SIGMA OF AEROSOL LOG-NORMAL 1398 1489 ! SIZE DISTRIBTUION 1399 1490 ! ASSUMING ALL THE H2SO4 ABOVE MIXTURE SAT PRESSURE modified by H2SO4 activity IS CONDENSED … … 1409 1500 ! T: temperature (K) 1410 1501 ! 1411 ! OUTPUT: 1502 ! OUTPUT: 1412 1503 ! RMTOT: Total condensed "Mass" (M_tot_distrib / rho_droplet), sans dimension 1413 ! mais rho_droplet et M_tot_distrib doivent tre de meme dimension1504 ! mais rho_droplet et M_tot_distrib doivent etre de meme dimension 1414 1505 ! H2OCOND 1415 1506 ! H2SO4COND 1416 1507 1417 1508 1418 1509 1419 1510 IMPLICIT NONE 1420 1511 … … 1430 1521 ! masse of an H2SO4 molecule (kg) 1431 1522 RMH2S4=98.078/(6.02214129E+26) 1432 1523 1433 1524 pstand=1.01325E+5 !Pa 1 atm pressure 1434 1525 … … 1445 1536 1446 1537 !acid sat.vap.PP over mixture (flat surface): 1447 satpacid=act(2)*acidps ! Pa 1538 satpacid=act(2)*acidps ! Pa 1448 1539 1449 1540 ! Conversion from Pa to N.D #/m3 … … 1451 1542 ! Conversion from N.D #/m3 TO #/cm3 1452 1543 ! DND2=DND2*1.d-6 1453 1544 1454 1545 ! H2SO4COND N.D #/m3 condensee ssi H2SO4>H2SO4sat 1455 1546 IF (H2SO4.GE.DND2) THEN … … 1458 1549 H2OCOND=H2SO4COND*98.078*(1.0-WSA)/(18.0153*WSA) 1459 1550 1460 ! RMTOT: = Mass of H2SO4 satur per cm3 of air/ Mass of sulfuric acid part of droplet solution per cm3 1551 ! RMTOT: = Mass of H2SO4 satur per m3 of air/ Mass of sulfuric acid part of droplet solution per m3 1552 ! RMTOT = Mtot/rho_droplet 1461 1553 ! RMTOT=M_distrib/rho_droplet 1462 1554 1463 1555 RMTOT=H2SO4COND*RMH2S4/(DENSO4*WSA) 1464 1556 … … 1469 1561 RMTOT=0.0E+0 1470 1562 END IF 1471 1563 1472 1564 ! Test si H2O en defaut H2Ocond>H2O dispo 1473 1565 IF ((H2OCOND.GT.H2O).AND.(H2SO4.GE.DND2)) THEN … … 1484 1576 ! PRINT*,'WSA',WSA,'RHO',DENSO4 1485 1577 ! STOP 1486 1487 1578 1579 1488 1580 ! On peut alors condenser tout le H2O dispo 1489 1581 H2OCOND=H2O 1490 1582 ! On met alors egalement a jour le H2SO4 cond correspondant au H2O cond 1491 1583 H2SO4COND=H2OCOND*18.0153*WSA/(98.078*(1.0-WSA)) 1492 1493 ! RMTOT: = Mass of H2SO4 satur per cm3 of air/ Mass of sulfuric acid part of droplet solution per cm31494 ! RMTOT=Volume of aerosol cm3 /cm3 of air1495 ! Volume of aerosol/ cm3 air1496 1584 1585 ! RMTOT: = Mass of H2SO4 satur per m3 of air/ Mass of sulfuric acid part of droplet solution per m3 1586 ! RMTOT=Volume of aerosol m3 /m3 of air 1587 ! Volume of aerosol/m3 air 1588 1497 1589 RMTOT=H2SO4COND*RMH2S4/(DENSO4*WSA) 1498 1590 1499 1591 END IF 1500 1592 1501 1593 END SUBROUTINE CALCM_SAT 1502 1594 … … 1510 1602 ! mole fraction 0,...,1 1511 1603 ! J. Phys. Chem. Ref. Data, Vol. 20, No. 6,PP.1157, 1991 1512 !+++++++++++++++++++++++++++++++++++++++++++++++++++ 1604 !+++++++++++++++++++++++++++++++++++++++++++++++++++ 1513 1605 1514 1606 IMPLICIT NONE … … 1523 1615 ! write(*,*) 'x, T ', x, T 1524 1616 1525 act(2)=activitya(x,T) 1617 act(2)=activitya(x,T) 1526 1618 act(1)=activityw(x,T) 1527 1619 … … 1535 1627 1536 1628 REAL, INTENT(IN) :: T 1537 m111=-23.524503387D0 1538 & +0.0406889449841D0*T 1539 & -0.151369362907D-4*T**2+2961.44445015D0/T 1629 m111=-23.524503387D0 1630 & +0.0406889449841D0*T 1631 & -0.151369362907D-4*T**2+2961.44445015D0/T 1540 1632 & +0.492476973663D0*dlog(T) 1541 1633 END FUNCTION m111 … … 1544 1636 1545 1637 REAL, INTENT(IN) :: T 1546 m121=1114.58541077D0-1.1833078936D0*T 1547 & -0.00209946114412D0*T**2-246749.842271D0/T 1638 m121=1114.58541077D0-1.1833078936D0*T 1639 & -0.00209946114412D0*T**2-246749.842271D0/T 1548 1640 & +34.1234558134D0*dlog(T) 1549 1641 END FUNCTION m121 … … 1552 1644 1553 1645 REAL, INTENT(IN) :: T 1554 m221=-80.1488100747D0-0.0116246143257D0*T 1555 & +0.606767928954D-5*T**2+3092.72150882D0/T 1646 m221=-80.1488100747D0-0.0116246143257D0*T 1647 & +0.606767928954D-5*T**2+3092.72150882D0/T 1556 1648 & +12.7601667471D0*dlog(T) 1557 1649 END FUNCTION m221 … … 1560 1652 1561 1653 REAL, INTENT(IN) :: T 1562 m122=888.711613784D0-2.50531359687D0*T 1563 & +0.000605638824061D0*T**2-196985.296431D0/T 1654 m122=888.711613784D0-2.50531359687D0*T 1655 & +0.000605638824061D0*T**2-196985.296431D0/T 1564 1656 & +74.550064338D0*dlog(T) 1565 1657 END FUNCTION m122 … … 1568 1660 1569 1661 REAL, INTENT(IN) :: T 1570 e111=2887.31663295D0-3.32602457749D0*T 1571 & -0.2820472833D-2*T**2-528216.112353D0/T 1662 e111=2887.31663295D0-3.32602457749D0*T 1663 & -0.2820472833D-2*T**2-528216.112353D0/T 1572 1664 & +0.68699743564D0*dlog(T) 1573 1665 END FUNCTION e111 … … 1576 1668 1577 1669 REAL, INTENT(IN) :: T 1578 e121=-370.944593249D0-0.690310834523D0*T 1579 & +0.56345508422D-3*T**2-3822.52997064D0/T 1670 e121=-370.944593249D0-0.690310834523D0*T 1671 & +0.56345508422D-3*T**2-3822.52997064D0/T 1580 1672 & +94.2682037574D0*dlog(T) 1581 1673 END FUNCTION e121 … … 1584 1676 1585 1677 REAL, INTENT(IN) :: T 1586 e211=38.3025318809D0-0.0295997878789D0*T 1587 & +0.120999746782D-4*T**2-3246.97498999D0/T 1678 e211=38.3025318809D0-0.0295997878789D0*T 1679 & +0.120999746782D-4*T**2-3246.97498999D0/T 1588 1680 & -3.83566039532D0*dlog(T) 1589 1681 END FUNCTION e211 … … 1592 1684 1593 1685 REAL, INTENT(IN) :: T 1594 e221=2324.76399402D0-0.141626921317D0*T 1595 & -0.00626760562881D0*T**2-450590.687961D0/T 1686 e221=2324.76399402D0-0.141626921317D0*T 1687 & -0.00626760562881D0*T**2-450590.687961D0/T 1596 1688 & -61.2339472744D0*dlog(T) 1597 1689 END FUNCTION e221 … … 1600 1692 1601 1693 REAL, INTENT(IN) :: T 1602 e122=-1633.85547832D0-3.35344369968D0*T 1603 & +0.00710978119903D0*T**2+198200.003569D0/T 1694 e122=-1633.85547832D0-3.35344369968D0*T 1695 & +0.00710978119903D0*T**2+198200.003569D0/T 1604 1696 & +246.693619189D0*dlog(T) 1605 1697 END FUNCTION e122 … … 1608 1700 1609 1701 REAL, INTENT(IN) :: T 1610 e212=1273.75159848D0+1.03333898148D0*T 1611 & +0.00341400487633D0*T**2+195290.667051D0/T 1702 e212=1273.75159848D0+1.03333898148D0*T 1703 & +0.00341400487633D0*T**2+195290.667051D0/T 1612 1704 & -431.737442782D0*dlog(T) 1613 1705 END FUNCTION e212 … … 1616 1708 1617 1709 REAL, INTENT(IN) :: T,x1 1618 REAL :: 1619 & m111,m121,m221,m122 1710 REAL :: 1711 & m111,m121,m221,m122 1620 1712 & ,e111,e121,e211,e122,e212,e221 1621 lnAa=-( 1622 & (2*m111(T)+e111(T)*(2*dlog(x1)+1))*x1 1623 & +(2*m121(T)+e211(T)*dlog(1-x1)+e121(T)*(dlog(x1)+1))*(1-x1) 1624 & -(m111(T)+e111(T)*(dlog(x1)+1))*x1*x1 1625 & -(2*m121(T)+e121(T)*(dlog(x1)+1)+e211(T)*(dlog(1-x1)+1) 1626 & -(2*m122(T)+e122(T)*dlog(x1) 1627 & +e212(T)*dlog(1-x1))*(1-x1))*x1*(1-x1) 1628 & -(m221(T)+e221(T)*(dlog(1-x1)+1))*(1-x1)**2 1629 & -x1*(1-x1)*( 1630 & (6*m122(T)+e122(T)*(3*dlog(x1)+1) 1631 & +e212(T)*(3*dlog(1-x1)+1) 1632 & )*x1*(1-x1) 1633 & -(2*m122(T)+e122(T)*(dlog(x1)+1) 1634 & +e212(T)*dlog(1-x1) 1635 & )*(1-x1)) 1713 lnAa=-( 1714 & (2*m111(T)+e111(T)*(2*dlog(x1)+1))*x1 1715 & +(2*m121(T)+e211(T)*dlog(1-x1)+e121(T)*(dlog(x1)+1))*(1-x1) 1716 & -(m111(T)+e111(T)*(dlog(x1)+1))*x1*x1 1717 & -(2*m121(T)+e121(T)*(dlog(x1)+1)+e211(T)*(dlog(1-x1)+1) 1718 & -(2*m122(T)+e122(T)*dlog(x1) 1719 & +e212(T)*dlog(1-x1))*(1-x1))*x1*(1-x1) 1720 & -(m221(T)+e221(T)*(dlog(1-x1)+1))*(1-x1)**2 1721 & -x1*(1-x1)*( 1722 & (6*m122(T)+e122(T)*(3*dlog(x1)+1) 1723 & +e212(T)*(3*dlog(1-x1)+1) 1724 & )*x1*(1-x1) 1725 & -(2*m122(T)+e122(T)*(dlog(x1)+1) 1726 & +e212(T)*dlog(1-x1) 1727 & )*(1-x1)) 1636 1728 & ) 1637 1729 END FUNCTION lnAa … … 1640 1732 1641 1733 REAL, INTENT(IN) :: T,x1 1642 REAL :: 1643 & m111,m121,m221,m122 1734 REAL :: 1735 & m111,m121,m221,m122 1644 1736 & ,e111,e121,e211,e122,e212,e221 1645 lnAw=-( 1646 & (2*m121(T)+e121(T)*dlog(x1)+e211(T)*(dlog(1-x1)+1))*x1 1647 & +(2*m221(T)+e221(T)*(2*dlog(1-x1)+1))*(1-x1) 1648 & -(m111(T)+e111(T)*(dlog(x1)+1))*x1*x1 1649 & -(2*m121(T)+e121(T)*(dlog(x1)+1) 1650 & +e211(T)*(dlog(1-x1)+1))*x1*(1-x1) 1651 & -(m221(T)+e221(T)*(dlog(1-x1)+1))*(1-x1)**2 1652 & +x1*(2*m122(T)+e122(T)*dlog(x1)+e212(T)*dlog(1-x1))*x1*(1-x1) 1653 & +x1*(1-x1)*((2*m122(T)+e122(T)*dlog(x1) 1654 & +e212(T)*(dlog(1-x1)+1))*x1 1655 & -(6*m122(T)+e122(T)*(3*dlog(x1)+1) 1656 & +e212(T)*(3*dlog(1-x1)+1))*(1-x1)*x1) 1737 lnAw=-( 1738 & (2*m121(T)+e121(T)*dlog(x1)+e211(T)*(dlog(1-x1)+1))*x1 1739 & +(2*m221(T)+e221(T)*(2*dlog(1-x1)+1))*(1-x1) 1740 & -(m111(T)+e111(T)*(dlog(x1)+1))*x1*x1 1741 & -(2*m121(T)+e121(T)*(dlog(x1)+1) 1742 & +e211(T)*(dlog(1-x1)+1))*x1*(1-x1) 1743 & -(m221(T)+e221(T)*(dlog(1-x1)+1))*(1-x1)**2 1744 & +x1*(2*m122(T)+e122(T)*dlog(x1)+e212(T)*dlog(1-x1))*x1*(1-x1) 1745 & +x1*(1-x1)*((2*m122(T)+e122(T)*dlog(x1) 1746 & +e212(T)*(dlog(1-x1)+1))*x1 1747 & -(6*m122(T)+e122(T)*(3*dlog(x1)+1) 1748 & +e212(T)*(3*dlog(1-x1)+1))*(1-x1)*x1) 1657 1749 & ) 1658 1750 END FUNCTION lnAw … … 1671 1763 FUNCTION activityw(xal,T) 1672 1764 1673 REAL, INTENT(IN) :: T,xal 1765 REAL, INTENT(IN) :: T,xal 1674 1766 REAL :: lnAw 1675 1767 … … 1702 1794 a=0.11864+xmass*(-0.11651+xmass*(0.76852+xmass* 1703 1795 & (-2.40909+xmass*(2.95434-xmass*1.25852)))) 1704 b=-0.00015709+xmass*(0.00040102+xmass*(-0.00239950+xmass* 1796 b=-0.00015709+xmass*(0.00040102+xmass*(-0.00239950+xmass* 1705 1797 & (0.007611235+xmass*(-0.00937386+xmass*0.00389722)))) 1706 1798 SIGMADROPLET=a+t*b … … 1745 1837 1746 1838 a=0.7681724+xmass*(2.1847140+xmass*(7.1630022+xmass* 1747 & (-44.31447+xmass* 1839 & (-44.31447+xmass* 1748 1840 & (88.75606+xmass*(-75.73729+xmass*23.43228))))) 1749 1841 b=1.808225e-3+xmass*(-9.294656e-3+xmass*(-0.03742148+ … … 1757 1849 RETURN 1758 1850 END FUNCTION RHODROPLET 1759 1760 1761 1762 -
trunk/LMDZ.VENUS/libf/phyvenus/radlwsw.F
r1591 r1639 25 25 c With extension NLTE (G. Gilli, 2014) 26 26 27 c Ksi matrices latitudinaly interpolated (I. Garate-Lopez, 2016) 28 27 29 c====================================================================== 28 30 use dimphy … … 74 76 integer mat0,lat,ips,isza,ips0,isza0 75 77 real factp,factz,ksi 76 78 c ------- for lat-interp ---------------- 79 integer mat0A, mat0B, latA, latB, kasua 80 integer ipsA, ipsB, iszaA, iszaB, ips0A, ips0B, isza0A, isza0B 81 real lat_deg, latA_deg, latB_deg 82 real factlat, k1, k2, k3, k4 83 c -------------------------------------- 77 84 logical firstcall 78 85 data firstcall/.true./ 79 86 save firstcall 80 87 88 cERROR ! For checking if the file it's being read 81 89 c------------------------------------------- 82 90 c Initialisations … … 99 107 ENDDO 100 108 109 101 110 c+++++++ BOUCLE SUR LA GRILLE +++++++++++++++++++++++++ 102 111 DO j = 1, klon … … 110 119 zcool(k) = 0.0 111 120 ENDDO 121 c zheat(1:klev)=0.0 !Explicit loop (no change in performance) 122 c zcool(1:klev)=0.0 123 112 124 DO k = 1, klev+1 113 125 ZFLNET(k) = 0.0 114 126 ZFSNET(k) = 0.0 115 127 ENDDO 128 c ZFLNET(1:klev+1)=0.0 129 c ZFSNET(1:klev+1)=0.0 130 116 131 ztopsw = 0.0 117 132 ztoplw = 0.0 … … 120 135 zsollwdown = 0.0 121 136 122 123 124 137 zfract = fract(j) 138 zrmu0 = rmu0(j) 139 125 140 DO k = 1, klev+1 126 141 PPB(k) = paprs(j,k)/1.e5 … … 132 147 ENDDO 133 148 pt0(klev+1) = 0. 134 149 135 150 DO k = 0,klev+1 136 151 DO i = 0,klev+1 … … 139 154 ENDDO 140 155 ENDDO 141 156 142 157 c====================================================================== 143 158 c Getting psi and deltapsi … … 160 175 c finding the right matrixes 161 176 c -------------------------- 162 mat0 = 0 163 if (nlatve.eq.1) then ! clouds are taken as uniform 164 lat=1 165 else 166 if (abs(latitude_deg(j)).le.50.) then 167 lat=1 168 elseif (abs(latitude_deg(j)).le.60.) then 169 lat=2 170 elseif (abs(latitude_deg(j)).le.70.) then 171 lat=3 172 elseif (abs(latitude_deg(j)).le.80.) then 173 lat=4 174 else 175 lat=5 176 endif 177 endif 178 177 178 mat0 = 0 179 mat0A = 0 180 mat0B = 0 181 182 c Latitude 183 c -------- 184 lat = 0 185 latA = 0 186 latB = 0 187 188 c write(*,*) 'nlatve:', nlatve 189 190 lat_deg = abs(latitude_deg(j)) 191 192 c if (nlatve.eq.1) then ! clouds are taken as uniform 193 if ((nlatve.eq.1).or.(lat_deg.le.25.)) then 194 lat = 1 195 elseif (lat_deg.le.50.) then 196 lat = 1 197 latA = 1 198 latB = 2 199 latA_deg = 25.0 200 latB_deg = 55.0 201 elseif (lat_deg.le.55.) then 202 lat = 2 203 latA = 1 204 latB = 2 205 latA_deg = 25.0 206 latB_deg = 55.0 207 elseif (lat_deg.le.60.) then 208 lat = 2 209 latA = 2 210 latB = 3 211 latA_deg = 55.0 212 latB_deg = 65.0 213 elseif (lat_deg.le.65.) then 214 lat = 3 215 latA = 2 216 latB = 3 217 latA_deg = 55.0 218 latB_deg = 65.0 219 elseif (lat_deg.le.70.) then 220 lat = 3 221 latA = 3 222 latB = 4 223 latA_deg = 65.0 224 latB_deg = 75.0 225 elseif (lat_deg.le.75.) then 226 lat = 4 227 latA = 3 228 latB = 4 229 latA_deg = 65.0 230 latB_deg = 75.0 231 elseif (lat_deg.le.80.) then 232 lat = 4 233 latA = 4 234 latB = 5 235 latA_deg = 75.0 236 latB_deg = 85.0 237 elseif (lat_deg.le.85.) then 238 lat = 5 239 latA = 4 240 latB = 5 241 latA_deg = 75.0 242 latB_deg = 85.0 243 else 244 lat = 5 245 endif 246 247 c write(*,*) 'Lat',lat,'LatA',latA,'LatB',latB 248 249 factlat = 0 250 if (latA.gt.0) then 251 factlat = (lat_deg - latA_deg) / (latB_deg - latA_deg) 252 endif 253 254 c write (*,*) 'Factor de correccion:', factlat 255 256 257 c Pressure at Surface 258 c ------------------- 259 179 260 ips0=0 180 if (nbpsve(lat).gt.1) then 261 ips0A=0 262 ips0B=0 263 if (nbpsve(lat).gt.1) then ! Interpolation on ps 181 264 do ips=1,nbpsve(lat)-1 182 265 if ( (psurfve(ips,lat).ge.paprs(j,1)) 183 . 266 . .and.(psurfve(ips+1,lat).lt.paprs(j,1)) ) then 184 267 ips0 = ips 185 268 c print*,'ig=',j,' ips0=',ips … … 192 275 ips0=1 193 276 endif 277 278 if (latA.eq.lat) then 279 ips0A=ips0 280 else 281 if (latA.gt.0) then 282 if (nbpsve(latA).gt.1) then 283 do ipsA=1,nbpsve(latA)-1 284 if ( (psurfve(ipsA,latA).ge.paprs(j,1)) 285 . .and.(psurfve(ipsA+1,latA).lt.paprs(j,1)) ) then 286 ips0A = ipsA 287 exit 288 endif 289 enddo 290 else ! Only one ps, no interpolation 291 ips0A=1 292 endif ! nbpsve(latA).gt.1 293 endif ! latA.gt.0 (if latA=0 ips0A is not used, so it doesn't matter) 294 endif ! latA.eq.lat 295 296 if (latB.eq.lat) then 297 ips0B=ips0 298 else 299 if (latB.gt.0) then 300 if (nbpsve(latB).gt.1) then 301 do ipsB=1,nbpsve(latB)-1 302 if ( (psurfve(ipsB,latB).ge.paprs(j,1)) 303 . .and.(psurfve(ipsB+1,latB).lt.paprs(j,1)) ) then 304 ips0B = ipsB 305 exit 306 endif 307 enddo 308 else 309 ips0B=1 310 endif ! nbpsve(latB).gt.1 311 endif ! latB.gt.0 (if latB=0 ips0B is not used, so it doesn't matter) 312 endif ! latB.eq.lat 313 314 315 c Solar Zenith Angle 316 c ------------------ 317 194 318 isza0=0 319 isza0A=0 320 isza0B=0 195 321 if (nbszave(lat).gt.1) then 196 322 do isza=1,nbszave(lat)-1 197 323 if ( (szave(isza,lat).ge.zrmu0) 198 . 324 . .and.(szave(isza+1,lat).lt.zrmu0) ) then 199 325 isza0 = isza 200 326 c print*,'ig=',j,' isza0=',isza … … 207 333 isza0=-99 208 334 endif 335 336 337 if (latA.eq.lat) then 338 isza0A=isza0 339 else 340 if (latA.gt.0) then 341 if (nbszave(latA).gt.1) then 342 do iszaA=1,nbszave(latA)-1 343 if ( (szave(iszaA,latA).ge.zrmu0) 344 . .and.(szave(iszaA+1,latA).lt.zrmu0) ) then 345 isza0A = iszaA 346 exit 347 endif 348 enddo 349 else ! Only one sza, no interpolation 350 isza0A=-99 351 endif ! nbszave(latA).gt.1 352 endif ! latA.gt.0 (if latA=0 isza0A is not used, so it doesn't matter) 353 endif ! latA.eq.lat 354 355 if (latB.eq.lat) then 356 isza0B=isza0 357 else 358 if (latB.gt.0) then 359 if (nbszave(latB).gt.1) then 360 do iszaB=1,nbszave(latB)-1 361 if ( (szave(iszaB,latB).ge.zrmu0) 362 . .and.(szave(iszaB+1,latB).lt.zrmu0) ) then 363 isza0B = iszaB 364 exit 365 endif 366 enddo 367 else ! Only one sza, no interpolation 368 isza0B=-99 369 endif ! nbszave(latB).gt.1 370 endif ! latB.gt.0 (if latB=0 isza0B is not used, so it doesn't matter) 371 endif ! latB.eq.lat 372 373 c write(*,*) 'nbszave', nbszave(lat),'nbpsve(lat)',nbpsve(lat) 374 209 375 210 376 c -------- Probleme aux bords … … 215 381 . /(psurfve(ips0+1,lat)-psurfve(ips0,lat)) 216 382 endif 217 if ((ips0.eq.0).and.(psurfve(nbpsve(lat),lat).le.paprs(j,1))) 218 . 383 if ((ips0.eq.0).and.(psurfve(nbpsve(lat),lat).le.paprs(j,1))) 384 . then 219 385 ips0 = nbpsve(lat)-1 220 386 print*,'Extrapolation! ig=',j,' ips0=',ips0 … … 230 396 stop 231 397 endif 232 398 399 400 233 401 if (isza0.eq.-99) then 234 mat0 = indexve(lat)+ips0 402 mat0 = indexve(lat) +ips0 403 mat0A = indexve(latA)+ips0A 404 mat0B = indexve(latB)+ips0B 235 405 else 236 mat0 = indexve(lat)+(isza0-1)*nbpsve(lat)+ips0 406 mat0 = indexve(lat) +(isza0 -1)*nbpsve(lat) +ips0 407 mat0A = indexve(latA)+(isza0A-1)*nbpsve(latA)+ips0A 408 mat0B = indexve(latB)+(isza0B-1)*nbpsve(latB)+ips0B 237 409 endif 238 410 411 c write(*,*) 'Second revision> Lat',lat,'LatA',latA,'LatB',latB 412 239 413 c interpolation of ksi and computation of psi,deltapsi 240 414 c ---------------------------------------------------- 241 do band=1,nnuve 242 do k=0,klev+1 243 do i=0,klev+1 244 if (isza0.eq.-99) then 245 ksi = ksive(i,k,band,mat0)*(1-factp) 246 . +ksive(i,k,band,mat0+1)*factp 247 else 248 ksi = ksive(i,k,band,mat0)*(1-factp)*(1-factz) 249 . +ksive(i,k,band,mat0+1)*factp *(1-factz) 250 . +ksive(i,k,band,mat0+nbpsve(lat))*(1-factp)*factz 251 . +ksive(i,k,band,mat0+nbpsve(lat)+1)*factp *factz 252 endif 253 254 psi(i,k) = psi(i,k) + 255 . RPI*ksi*(bplck(i,band)-bplck(k,band)) 256 deltapsi(i,k) = deltapsi(i,k) + RPI*ksi*zdblay(i,band) 257 enddo 258 enddo 259 enddo 415 416 if (isza0.eq.-99) then 417 if (latA.gt.0) then ! Not being in the two extremal bins 418 419 do band=1,nnuve 420 do k=0,klev+1 421 do i=k+1,klev+1 422 k1 = ksive(i,k,band,mat0A)*(1-factlat) 423 . + ksive(i,k,band,mat0B)*factlat 424 k2 = ksive(i,k,band,mat0A+1)*(1-factlat) 425 . + ksive(i,k,band,mat0B+1)*factlat 426 ksi = k1*(1-factp) + k2*factp 427 psi(i,k) = psi(i,k) + 428 . RPI*ksi*(bplck(i,band)-bplck(k,band)) 429 c ONLY NEEDED IF IMPLICIT CHOSEN IN LW_VENUS_VE (not the case right now) 430 c deltapsi(i,k) = deltapsi(i,k) + RPI*ksi*zdblay(i,band) 431 c deltapsi(k,i) = deltapsi(k,i) + RPI*ksi*zdblay(k,band) 432 433 kasua=1 434 enddo 435 enddo 436 enddo 437 do k=0,klev+1 438 do i=k+1,klev+1 439 psi(k,i) = -psi(i,k) 440 enddo 441 enddo 442 443 else ! latA=0 --> extremal bins 444 445 do band=1,nnuve 446 do k=0,klev+1 447 do i=k+1,klev+1 448 ksi = ksive(i,k,band,mat0)*(1-factp) 449 . + ksive(i,k,band,mat0+1)*factp 450 psi(i,k) = psi(i,k) + 451 . RPI*ksi*(bplck(i,band)-bplck(k,band)) 452 c ONLY NEEDED IF IMPLICIT CHOSEN IN LW_VENUS_VE (not the case right now) 453 c deltapsi(i,k) = deltapsi(i,k) + RPI*ksi*zdblay(i,band) 454 c deltapsi(k,i) = deltapsi(k,i) + RPI*ksi*zdblay(k,band) 455 456 kasua=2 457 enddo 458 enddo 459 enddo 460 do k=0,klev+1 461 do i=k+1,klev+1 462 psi(k,i) = -psi(i,k) 463 enddo 464 enddo 465 466 endif ! latA.gt.0 467 468 else ! isza0=!-99 469 470 if (latA.gt.0) then ! Not being in the two extremal bins 471 472 do band=1,nnuve 473 do k=0,klev+1 474 do i=k+1,klev+1 475 k1 = ksive(i,k,band,mat0A)*(1-factlat) 476 . + ksive(i,k,band,mat0B)*factlat 477 k2 = ksive(i,k,band,mat0A+1)*(1-factlat) 478 . + ksive(i,k,band,mat0B+1)*factlat 479 k3 = ksive(i,k,band,mat0A+nbpsve(latA))*(1-factlat) 480 . + ksive(i,k,band,mat0B+nbpsve(latB))*factlat 481 k4 = ksive(i,k,band,mat0A+nbpsve(latA)+1)*(1-factlat) 482 . + ksive(i,k,band,mat0B+nbpsve(latB)+1)*factlat 483 ksi = ( k1*(1-factp) + k2*factp )*(1-factz) 484 . + ( k3*(1-factp) + k4*factp )*factz 485 psi(i,k) = psi(i,k) + 486 . RPI*ksi*(bplck(i,band)-bplck(k,band)) 487 c ONLY NEEDED IF IMPLICIT CHOSEN IN LW_VENUS_VE (not the case right now) 488 c deltapsi(i,k) = deltapsi(i,k) + RPI*ksi*zdblay(i,band) 489 c deltapsi(k,i) = deltapsi(k,i) + RPI*ksi*zdblay(k,band) 490 491 kasua=3 492 enddo 493 enddo 494 enddo 495 do k=0,klev+1 496 do i=k+1,klev+1 497 psi(k,i) = -psi(i,k) 498 enddo 499 enddo 500 501 else ! latA=0 --> extremal bins 502 503 do band=1,nnuve 504 do k=0,klev+1 505 do i=k+1,klev+1 506 ksi = ksive(i,k,band,mat0)*(1-factp)*(1-factz) 507 . + ksive(i,k,band,mat0+1)*factp *(1-factz) 508 . + ksive(i,k,band,mat0+nbpsve(lat))*(1-factp)*factz 509 . + ksive(i,k,band,mat0+nbpsve(lat)+1)*factp *factz 510 psi(i,k) = psi(i,k) + 511 . RPI*ksi*(bplck(i,band)-bplck(k,band)) 512 c ONLY NEEDED IF IMPLICIT CHOSEN IN LW_VENUS_VE (not the case right now) 513 c deltapsi(i,k) = deltapsi(i,k) + RPI*ksi*zdblay(i,band) 514 c deltapsi(k,i) = deltapsi(k,i) + RPI*ksi*zdblay(k,band) 515 516 kasua=4 517 enddo 518 enddo 519 enddo 520 do k=0,klev+1 521 do i=k+1,klev+1 522 psi(k,i) = -psi(i,k) 523 enddo 524 enddo 525 526 endif ! latA.gt.0 527 endif ! isza0.eq.-99 528 529 c write(*,*) 'Kasua:', kasua 260 530 261 531 c====================================================================== … … 358 628 RETURN 359 629 END 360
Note: See TracChangeset
for help on using the changeset viewer.