[109] | 1 | SUBROUTINE disvert_noterre |
---|
| 2 | |
---|
| 3 | c Auteur : F. Forget Y. Wanherdrick, P. Levan |
---|
| 4 | c Nouvelle version 100% Mars !! |
---|
| 5 | c On l'utilise aussi pour Venus et Titan, legerment modifiee. |
---|
| 6 | |
---|
[124] | 7 | #ifdef CPP_IOIPSL |
---|
| 8 | use IOIPSL |
---|
| 9 | #else |
---|
| 10 | ! if not using IOIPSL, we still need to use (a local version of) getin |
---|
| 11 | use ioipsl_getincom |
---|
| 12 | #endif |
---|
| 13 | |
---|
[109] | 14 | IMPLICIT NONE |
---|
| 15 | |
---|
| 16 | #include "dimensions.h" |
---|
| 17 | #include "paramet.h" |
---|
| 18 | #include "comvert.h" |
---|
| 19 | #include "comconst.h" |
---|
| 20 | #include "logic.h" |
---|
[124] | 21 | #include "iniprint.h" |
---|
[109] | 22 | c |
---|
| 23 | c======================================================================= |
---|
| 24 | c Discretisation verticale en coordonnée hybride |
---|
| 25 | c |
---|
| 26 | c======================================================================= |
---|
| 27 | c |
---|
| 28 | c declarations: |
---|
| 29 | c ------------- |
---|
| 30 | c |
---|
| 31 | c |
---|
| 32 | INTEGER l,ll |
---|
| 33 | REAL snorm |
---|
[124] | 34 | REAL alpha,beta,gama,delta,deltaz |
---|
| 35 | real quoi,quand |
---|
[109] | 36 | REAL zsig(llm),sig(llm+1) |
---|
| 37 | INTEGER np,ierr |
---|
| 38 | integer :: ierr1,ierr2,ierr3,ierr4 |
---|
| 39 | REAL x |
---|
| 40 | |
---|
| 41 | REAL SSUM |
---|
| 42 | EXTERNAL SSUM |
---|
| 43 | real newsig |
---|
| 44 | REAL dz0,dz1,nhaut,sig1,esig,csig,zz |
---|
| 45 | real tt,rr,gg, prevz |
---|
| 46 | real s(llm),dsig(llm) |
---|
| 47 | real pseudoalt(llm) |
---|
| 48 | |
---|
| 49 | integer iz |
---|
| 50 | real z, ps,p |
---|
| 51 | |
---|
| 52 | c |
---|
| 53 | c----------------------------------------------------------------------- |
---|
| 54 | c |
---|
[124] | 55 | ! Initializations: |
---|
[109] | 56 | pi=2.*ASIN(1.) |
---|
[124] | 57 | |
---|
| 58 | hybrid=.true. ! default value for hybrid (ie: use hybrid coordinates) |
---|
| 59 | CALL getin('hybrid',hybrid) |
---|
| 60 | write(lunout,*)'disvert_noterre: hybrid=',hybrid |
---|
[109] | 61 | |
---|
| 62 | ! Ouverture possible de fichiers typiquement E.T. |
---|
| 63 | |
---|
| 64 | open(99,file="esasig.def",status='old',form='formatted', |
---|
| 65 | s iostat=ierr2) |
---|
| 66 | if(ierr2.ne.0) then |
---|
| 67 | close(99) |
---|
| 68 | open(99,file="z2sig.def",status='old',form='formatted', |
---|
| 69 | s iostat=ierr4) |
---|
| 70 | endif |
---|
| 71 | |
---|
| 72 | c----------------------------------------------------------------------- |
---|
| 73 | c cas 1 on lit les options dans esasig.def: |
---|
| 74 | c ---------------------------------------- |
---|
| 75 | |
---|
| 76 | IF(ierr2.eq.0) then |
---|
| 77 | |
---|
| 78 | c Lecture de esasig.def : |
---|
| 79 | c Systeme peu souple, mais qui respecte en theorie |
---|
| 80 | c La conservation de l'energie (conversion Energie potentielle |
---|
| 81 | c <-> energie cinetique, d'apres la note de Frederic Hourdin... |
---|
| 82 | |
---|
[124] | 83 | write(lunout,*)'*****************************' |
---|
| 84 | write(lunout,*)'WARNING reading esasig.def' |
---|
| 85 | write(lunout,*)'*****************************' |
---|
| 86 | READ(99,*) scaleheight |
---|
[109] | 87 | READ(99,*) dz0 |
---|
| 88 | READ(99,*) dz1 |
---|
| 89 | READ(99,*) nhaut |
---|
| 90 | CLOSE(99) |
---|
| 91 | |
---|
[124] | 92 | dz0=dz0/scaleheight |
---|
| 93 | dz1=dz1/scaleheight |
---|
[109] | 94 | |
---|
| 95 | sig1=(1.-dz1)/tanh(.5*(llm-1)/nhaut) |
---|
| 96 | |
---|
| 97 | esig=1. |
---|
| 98 | |
---|
| 99 | do l=1,20 |
---|
| 100 | esig=-log((1./sig1-1.)*exp(-dz0)/esig)/(llm-1.) |
---|
| 101 | enddo |
---|
| 102 | csig=(1./sig1-1.)/(exp(esig)-1.) |
---|
| 103 | |
---|
| 104 | DO L = 2, llm |
---|
| 105 | zz=csig*(exp(esig*(l-1.))-1.) |
---|
| 106 | sig(l) =1./(1.+zz) |
---|
| 107 | & * tanh(.5*(llm+1-l)/nhaut) |
---|
| 108 | ENDDO |
---|
| 109 | sig(1)=1. |
---|
| 110 | sig(llm+1)=0. |
---|
| 111 | quoi = 1. + 2.* kappa |
---|
| 112 | s( llm ) = 1. |
---|
| 113 | s(llm-1) = quoi |
---|
| 114 | IF( llm.gt.2 ) THEN |
---|
| 115 | DO ll = 2, llm-1 |
---|
| 116 | l = llm+1 - ll |
---|
| 117 | quand = sig(l+1)/ sig(l) |
---|
| 118 | s(l-1) = quoi * (1.-quand) * s(l) + quand * s(l+1) |
---|
| 119 | ENDDO |
---|
| 120 | END IF |
---|
| 121 | c |
---|
| 122 | snorm=(1.-.5*sig(2)+kappa*(1.-sig(2)))*s(1)+.5*sig(2)*s(2) |
---|
| 123 | DO l = 1, llm |
---|
| 124 | s(l) = s(l)/ snorm |
---|
| 125 | ENDDO |
---|
| 126 | |
---|
| 127 | c----------------------------------------------------------------------- |
---|
| 128 | c cas 2 on lit les options dans z2sig.def: |
---|
| 129 | c ---------------------------------------- |
---|
| 130 | |
---|
| 131 | ELSE IF(ierr4.eq.0) then |
---|
[124] | 132 | write(lunout,*)'****************************' |
---|
| 133 | write(lunout,*)'Reading z2sig.def' |
---|
| 134 | write(lunout,*)'****************************' |
---|
[109] | 135 | |
---|
[124] | 136 | READ(99,*) scaleheight |
---|
[109] | 137 | do l=1,llm |
---|
| 138 | read(99,*) zsig(l) |
---|
| 139 | end do |
---|
| 140 | CLOSE(99) |
---|
| 141 | |
---|
| 142 | sig(1) =1 |
---|
| 143 | do l=2,llm |
---|
[124] | 144 | sig(l) = 0.5 * ( exp(-zsig(l)/scaleheight) + |
---|
| 145 | & exp(-zsig(l-1)/scaleheight) ) |
---|
[109] | 146 | end do |
---|
| 147 | sig(llm+1) =0 |
---|
| 148 | |
---|
| 149 | c----------------------------------------------------------------------- |
---|
| 150 | ELSE |
---|
[124] | 151 | write(lunout,*) 'didn t you forget something ??? ' |
---|
| 152 | write(lunout,*) 'We need file z2sig.def ! (OR esasig.def)' |
---|
[109] | 153 | stop |
---|
| 154 | ENDIF |
---|
| 155 | c----------------------------------------------------------------------- |
---|
| 156 | |
---|
| 157 | DO l=1,llm |
---|
| 158 | nivsigs(l) = FLOAT(l) |
---|
| 159 | ENDDO |
---|
| 160 | |
---|
| 161 | DO l=1,llmp1 |
---|
| 162 | nivsig(l)= FLOAT(l) |
---|
| 163 | ENDDO |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | c----------------------------------------------------------------------- |
---|
| 167 | c .... Calculs de ap(l) et de bp(l) .... |
---|
| 168 | c ......................................... |
---|
| 169 | c |
---|
| 170 | c ..... pa et preff sont lus sur les fichiers start par dynetat0 ..... |
---|
| 171 | c----------------------------------------------------------------------- |
---|
| 172 | c |
---|
| 173 | |
---|
[124] | 174 | if (hybrid) then ! use hybrid coordinates |
---|
| 175 | write(lunout,*) "*********************************" |
---|
| 176 | write(lunout,*) "Using hybrid vertical coordinates" |
---|
| 177 | write(lunout,*) |
---|
[109] | 178 | c Coordonnees hybrides avec mod |
---|
| 179 | DO l = 1, llm |
---|
| 180 | |
---|
| 181 | call sig_hybrid(sig(l),pa,preff,newsig) |
---|
| 182 | bp(l) = EXP( 1. - 1./(newsig**2) ) |
---|
| 183 | ap(l) = pa * (newsig - bp(l) ) |
---|
| 184 | enddo |
---|
| 185 | bp(llmp1) = 0. |
---|
| 186 | ap(llmp1) = 0. |
---|
[124] | 187 | else ! use sigma coordinates |
---|
| 188 | write(lunout,*) "********************************" |
---|
| 189 | write(lunout,*) "Using sigma vertical coordinates" |
---|
| 190 | write(lunout,*) |
---|
[109] | 191 | c Pour ne pas passer en coordonnees hybrides |
---|
| 192 | DO l = 1, llm |
---|
| 193 | ap(l) = 0. |
---|
| 194 | bp(l) = sig(l) |
---|
| 195 | ENDDO |
---|
| 196 | ap(llmp1) = 0. |
---|
| 197 | endif |
---|
| 198 | |
---|
| 199 | bp(llmp1) = 0. |
---|
| 200 | |
---|
[124] | 201 | write(lunout,*)' BP ' |
---|
| 202 | write(lunout,*) bp |
---|
| 203 | write(lunout,*)' AP ' |
---|
| 204 | write(lunout,*) ap |
---|
[109] | 205 | |
---|
| 206 | c Calcul au milieu des couches : |
---|
| 207 | c WARNING : le choix de placer le milieu des couches au niveau de |
---|
| 208 | c pression intermédiaire est arbitraire et pourrait etre modifié. |
---|
| 209 | c Le calcul du niveau pour la derniere couche |
---|
| 210 | c (on met la meme distance (en log pression) entre P(llm) |
---|
| 211 | c et P(llm -1) qu'entre P(llm-1) et P(llm-2) ) est |
---|
[124] | 212 | c Specifique. Ce choix est spécifié ici ET dans exner_milieu.F |
---|
[109] | 213 | |
---|
[110] | 214 | DO l = 1, llm-1 |
---|
[109] | 215 | aps(l) = 0.5 *( ap(l) +ap(l+1)) |
---|
| 216 | bps(l) = 0.5 *( bp(l) +bp(l+1)) |
---|
| 217 | ENDDO |
---|
| 218 | |
---|
[124] | 219 | if (hybrid) then |
---|
[109] | 220 | aps(llm) = aps(llm-1)**2 / aps(llm-2) |
---|
| 221 | bps(llm) = 0.5*(bp(llm) + bp(llm+1)) |
---|
[124] | 222 | else |
---|
| 223 | bps(llm) = bps(llm-1)**2 / bps(llm-2) |
---|
| 224 | aps(llm) = 0. |
---|
| 225 | end if |
---|
[109] | 226 | |
---|
[124] | 227 | write(lunout,*)' BPs ' |
---|
| 228 | write(lunout,*) bps |
---|
| 229 | write(lunout,*)' APs' |
---|
| 230 | write(lunout,*) aps |
---|
[109] | 231 | |
---|
| 232 | DO l = 1, llm |
---|
| 233 | presnivs(l) = aps(l)+bps(l)*preff |
---|
[124] | 234 | pseudoalt(l) = -scaleheight*log(presnivs(l)/preff) |
---|
[109] | 235 | ENDDO |
---|
| 236 | |
---|
[124] | 237 | write(lunout,*)' PRESNIVS' |
---|
| 238 | write(lunout,*)presnivs |
---|
| 239 | write(lunout,*)'Pseudo altitude of Presnivs : (for a scale ', |
---|
| 240 | & 'height of ',scaleheight,' km)' |
---|
| 241 | write(lunout,*)pseudoalt |
---|
[109] | 242 | |
---|
| 243 | c -------------------------------------------------- |
---|
| 244 | c This can be used to plot the vertical discretization |
---|
| 245 | c (> xmgrace -nxy testhybrid.tab ) |
---|
| 246 | c -------------------------------------------------- |
---|
| 247 | c open (53,file='testhybrid.tab') |
---|
[124] | 248 | c scaleheight=15.5 |
---|
[109] | 249 | c do iz=0,34 |
---|
| 250 | c z = -5 + min(iz,34-iz) |
---|
| 251 | c approximation of scale height for Venus |
---|
[124] | 252 | c scaleheight = 15.5 - z/55.*10. |
---|
| 253 | c ps = preff*exp(-z/scaleheight) |
---|
| 254 | c zsig(1)= -scaleheight*log((aps(1) + bps(1)*ps)/preff) |
---|
[109] | 255 | c do l=2,llm |
---|
| 256 | c approximation of scale height for Venus |
---|
| 257 | c if (zsig(l-1).le.55.) then |
---|
[124] | 258 | c scaleheight = 15.5 - zsig(l-1)/55.*10. |
---|
[109] | 259 | c else |
---|
[124] | 260 | c scaleheight = 5.5 - (zsig(l-1)-55.)/35.*2. |
---|
[109] | 261 | c endif |
---|
[124] | 262 | c zsig(l)= zsig(l-1)-scaleheight* |
---|
[109] | 263 | c . log((aps(l) + bps(l)*ps)/(aps(l-1) + bps(l-1)*ps)) |
---|
| 264 | c end do |
---|
| 265 | c write(53,'(I3,50F10.5)') iz, zsig |
---|
| 266 | c end do |
---|
| 267 | c close(53) |
---|
| 268 | c -------------------------------------------------- |
---|
| 269 | |
---|
| 270 | |
---|
| 271 | RETURN |
---|
| 272 | END |
---|
| 273 | |
---|
| 274 | c ************************************************************ |
---|
| 275 | subroutine sig_hybrid(sig,pa,preff,newsig) |
---|
| 276 | c ---------------------------------------------- |
---|
| 277 | c Subroutine utilisee pour calculer des valeurs de sigma modifie |
---|
| 278 | c pour conserver les coordonnees verticales decrites dans |
---|
| 279 | c esasig.def/z2sig.def lors du passage en coordonnees hybrides |
---|
| 280 | c F. Forget 2002 |
---|
| 281 | c Connaissant sig (niveaux "sigma" ou on veut mettre les couches) |
---|
| 282 | c L'objectif est de calculer newsig telle que |
---|
| 283 | c (1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig = sig |
---|
| 284 | c Cela ne se résoud pas analytiquement: |
---|
| 285 | c => on résoud par iterration bourrine |
---|
| 286 | c ---------------------------------------------- |
---|
| 287 | c Information : where exp(1-1./x**2) become << x |
---|
| 288 | c x exp(1-1./x**2) /x |
---|
| 289 | c 1 1 |
---|
| 290 | c 0.68 0.5 |
---|
| 291 | c 0.5 1.E-1 |
---|
| 292 | c 0.391 1.E-2 |
---|
| 293 | c 0.333 1.E-3 |
---|
| 294 | c 0.295 1.E-4 |
---|
| 295 | c 0.269 1.E-5 |
---|
| 296 | c 0.248 1.E-6 |
---|
| 297 | c => on peut utiliser newsig = sig*preff/pa si sig*preff/pa < 0.25 |
---|
| 298 | |
---|
| 299 | |
---|
| 300 | implicit none |
---|
| 301 | real x1, x2, sig,pa,preff, newsig, F |
---|
| 302 | integer j |
---|
| 303 | |
---|
| 304 | newsig = sig |
---|
| 305 | x1=0 |
---|
| 306 | x2=1 |
---|
| 307 | if (sig.ge.1) then |
---|
| 308 | newsig= sig |
---|
| 309 | else if (sig*preff/pa.ge.0.25) then |
---|
| 310 | DO J=1,9999 ! nombre d''iteration max |
---|
| 311 | F=((1 -pa/preff)*exp(1-1./newsig**2)+(pa/preff)*newsig)/sig |
---|
| 312 | c write(0,*) J, ' newsig =', newsig, ' F= ', F |
---|
| 313 | if (F.gt.1) then |
---|
| 314 | X2 = newsig |
---|
| 315 | newsig=(X1+newsig)*0.5 |
---|
| 316 | else |
---|
| 317 | X1 = newsig |
---|
| 318 | newsig=(X2+newsig)*0.5 |
---|
| 319 | end if |
---|
| 320 | c Test : on arete lorsque on approxime sig à moins de 0.01 m près |
---|
| 321 | c (en pseudo altitude) : |
---|
| 322 | IF(abs(10.*log(F)).LT.1.E-5) goto 999 |
---|
| 323 | END DO |
---|
| 324 | else ! if (sig*preff/pa.le.0.25) then |
---|
| 325 | newsig= sig*preff/pa |
---|
| 326 | end if |
---|
| 327 | 999 continue |
---|
| 328 | Return |
---|
| 329 | END |
---|