| 1 | ! |
|---|
| 2 | ! $Header$ |
|---|
| 3 | ! |
|---|
| 4 | c |
|---|
| 5 | c |
|---|
| 6 | PROGRAM gcm |
|---|
| 7 | |
|---|
| 8 | #ifdef CPP_IOIPSL |
|---|
| 9 | USE IOIPSL |
|---|
| 10 | #endif |
|---|
| 11 | |
|---|
| 12 | USE filtreg_mod |
|---|
| 13 | USE infotrac |
|---|
| 14 | |
|---|
| 15 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 16 | ! FH 2008/05/09 On elimine toutes les clefs physiques dans la dynamique |
|---|
| 17 | ! A nettoyer. On ne veut qu'une ou deux routines d'interface |
|---|
| 18 | ! dynamique -> physique pour l'initialisation |
|---|
| 19 | #ifdef CPP_PHYS |
|---|
| 20 | USE dimphy |
|---|
| 21 | USE comgeomphy |
|---|
| 22 | USE mod_phys_lmdz_para, ONLY : klon_mpi_para_nb |
|---|
| 23 | #endif |
|---|
| 24 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 25 | |
|---|
| 26 | IMPLICIT NONE |
|---|
| 27 | |
|---|
| 28 | c ...... Version du 10/01/98 .......... |
|---|
| 29 | |
|---|
| 30 | c avec coordonnees verticales hybrides |
|---|
| 31 | c avec nouveaux operat. dissipation * ( gradiv2,divgrad2,nxgraro2 ) |
|---|
| 32 | |
|---|
| 33 | c======================================================================= |
|---|
| 34 | c |
|---|
| 35 | c Auteur: P. Le Van /L. Fairhead/F.Hourdin |
|---|
| 36 | c ------- |
|---|
| 37 | c |
|---|
| 38 | c Objet: |
|---|
| 39 | c ------ |
|---|
| 40 | c |
|---|
| 41 | c GCM LMD nouvelle grille |
|---|
| 42 | c |
|---|
| 43 | c======================================================================= |
|---|
| 44 | c |
|---|
| 45 | c ... Dans inigeom , nouveaux calculs pour les elongations cu , cv |
|---|
| 46 | c et possibilite d'appeler une fonction f(y) a derivee tangente |
|---|
| 47 | c hyperbolique a la place de la fonction a derivee sinusoidale. |
|---|
| 48 | c ... Possibilite de choisir le schema pour l'advection de |
|---|
| 49 | c q , en modifiant iadv dans traceur.def (MAF,10/02) . |
|---|
| 50 | c |
|---|
| 51 | c Pour Van-Leer + Vapeur d'eau saturee, iadv(1)=4. (F.Codron,10/99) |
|---|
| 52 | c Pour Van-Leer iadv=10 |
|---|
| 53 | c |
|---|
| 54 | c----------------------------------------------------------------------- |
|---|
| 55 | c Declarations: |
|---|
| 56 | c ------------- |
|---|
| 57 | |
|---|
| 58 | #include "dimensions.h" |
|---|
| 59 | #include "paramet.h" |
|---|
| 60 | #include "comconst.h" |
|---|
| 61 | #include "comdissnew.h" |
|---|
| 62 | #include "comvert.h" |
|---|
| 63 | #include "comgeom.h" |
|---|
| 64 | #include "logic.h" |
|---|
| 65 | #include "temps.h" |
|---|
| 66 | #include "control.h" |
|---|
| 67 | #include "ener.h" |
|---|
| 68 | #include "description.h" |
|---|
| 69 | #include "serre.h" |
|---|
| 70 | #include "com_io_dyn.h" |
|---|
| 71 | #include "iniprint.h" |
|---|
| 72 | #include "tracstoke.h" |
|---|
| 73 | |
|---|
| 74 | INTEGER longcles |
|---|
| 75 | PARAMETER ( longcles = 20 ) |
|---|
| 76 | REAL clesphy0( longcles ) |
|---|
| 77 | SAVE clesphy0 |
|---|
| 78 | |
|---|
| 79 | |
|---|
| 80 | |
|---|
| 81 | REAL zdtvr |
|---|
| 82 | INTEGER nbetatmoy, nbetatdem,nbetat |
|---|
| 83 | |
|---|
| 84 | c variables dynamiques |
|---|
| 85 | REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants |
|---|
| 86 | REAL teta(ip1jmp1,llm) ! temperature potentielle |
|---|
| 87 | REAL, ALLOCATABLE, DIMENSION(:,:,:):: q! champs advectes |
|---|
| 88 | REAL ps(ip1jmp1) ! pression au sol |
|---|
| 89 | REAL p (ip1jmp1,llmp1 ) ! pression aux interfac.des couches |
|---|
| 90 | REAL pks(ip1jmp1) ! exner au sol |
|---|
| 91 | REAL pk(ip1jmp1,llm) ! exner au milieu des couches |
|---|
| 92 | REAL pkf(ip1jmp1,llm) ! exner filt.au milieu des couches |
|---|
| 93 | REAL masse(ip1jmp1,llm) ! masse d'air |
|---|
| 94 | REAL phis(ip1jmp1) ! geopotentiel au sol |
|---|
| 95 | REAL phi(ip1jmp1,llm) ! geopotentiel |
|---|
| 96 | REAL w(ip1jmp1,llm) ! vitesse verticale |
|---|
| 97 | |
|---|
| 98 | c variables dynamiques intermediaire pour le transport |
|---|
| 99 | |
|---|
| 100 | c variables pour le fichier histoire |
|---|
| 101 | REAL dtav ! intervalle de temps elementaire |
|---|
| 102 | |
|---|
| 103 | REAL time_0 |
|---|
| 104 | |
|---|
| 105 | LOGICAL lafin |
|---|
| 106 | INTEGER ij,iq,l,i,j |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | real time_step, t_wrt, t_ops |
|---|
| 110 | |
|---|
| 111 | REAL rdayvrai,rdaym_ini,rday_ecri |
|---|
| 112 | LOGICAL first |
|---|
| 113 | |
|---|
| 114 | LOGICAL call_iniphys |
|---|
| 115 | data call_iniphys/.true./ |
|---|
| 116 | |
|---|
| 117 | REAL alpha(ip1jmp1,llm),beta(ip1jmp1,llm) |
|---|
| 118 | c+jld variables test conservation energie |
|---|
| 119 | c REAL ecin(ip1jmp1,llm),ecin0(ip1jmp1,llm) |
|---|
| 120 | C Tendance de la temp. potentiel d (theta)/ d t due a la |
|---|
| 121 | C tansformation d'energie cinetique en energie thermique |
|---|
| 122 | C cree par la dissipation |
|---|
| 123 | REAL dhecdt(ip1jmp1,llm) |
|---|
| 124 | c REAL vcont(ip1jm,llm),ucont(ip1jmp1,llm) |
|---|
| 125 | c REAL d_h_vcol, d_qt, d_qw, d_ql, d_ec |
|---|
| 126 | CHARACTER (len=15) :: ztit |
|---|
| 127 | c-jld |
|---|
| 128 | |
|---|
| 129 | |
|---|
| 130 | character (len=80) :: dynhist_file, dynhistave_file |
|---|
| 131 | character (len=20) :: modname |
|---|
| 132 | character (len=80) :: abort_message |
|---|
| 133 | |
|---|
| 134 | C Calendrier |
|---|
| 135 | LOGICAL true_calendar |
|---|
| 136 | PARAMETER (true_calendar = .false.) |
|---|
| 137 | |
|---|
| 138 | c----------------------------------------------------------------------- |
|---|
| 139 | c variables pour l'initialisation de la physique : |
|---|
| 140 | c ------------------------------------------------ |
|---|
| 141 | INTEGER ngridmx |
|---|
| 142 | PARAMETER( ngridmx = 2+(jjm-1)*iim - 1/jjm ) |
|---|
| 143 | REAL zcufi(ngridmx),zcvfi(ngridmx) |
|---|
| 144 | REAL latfi(ngridmx),lonfi(ngridmx) |
|---|
| 145 | REAL airefi(ngridmx) |
|---|
| 146 | SAVE latfi, lonfi, airefi |
|---|
| 147 | |
|---|
| 148 | c----------------------------------------------------------------------- |
|---|
| 149 | c Initialisations: |
|---|
| 150 | c ---------------- |
|---|
| 151 | |
|---|
| 152 | abort_message = 'last timestep reached' |
|---|
| 153 | modname = 'gcm' |
|---|
| 154 | descript = 'Run GCM LMDZ' |
|---|
| 155 | lafin = .FALSE. |
|---|
| 156 | dynhist_file = 'dyn_hist.nc' |
|---|
| 157 | dynhistave_file = 'dyn_hist_ave.nc' |
|---|
| 158 | |
|---|
| 159 | |
|---|
| 160 | c-------------------------------------------------------------------------- |
|---|
| 161 | c Iflag_phys controle l'appel a la physique : |
|---|
| 162 | c ------------------------------------------- |
|---|
| 163 | c 0 : pas de physique |
|---|
| 164 | c 1 : Normale (appel a phylmd, phymars ...) |
|---|
| 165 | c 2 : rappel Newtonien pour la temperature + friction au sol |
|---|
| 166 | iflag_phys=1 |
|---|
| 167 | |
|---|
| 168 | c-------------------------------------------------------------------------- |
|---|
| 169 | c Lecture de l'etat initial : |
|---|
| 170 | c --------------------------- |
|---|
| 171 | c T : on lit start.nc |
|---|
| 172 | c F : le modele s'autoinitialise avec un cas academique (iniacademic) |
|---|
| 173 | read_start=.true. |
|---|
| 174 | #ifdef CPP_IOIPSL |
|---|
| 175 | #else |
|---|
| 176 | read_start=.false. |
|---|
| 177 | #endif |
|---|
| 178 | #ifdef CPP_PHYS |
|---|
| 179 | #else |
|---|
| 180 | read_start=.false. |
|---|
| 181 | #endif |
|---|
| 182 | |
|---|
| 183 | c----------------------------------------------------------------------- |
|---|
| 184 | c Choix du calendrier |
|---|
| 185 | c ------------------- |
|---|
| 186 | |
|---|
| 187 | #ifdef CPP_IOIPSL |
|---|
| 188 | if (true_calendar) then |
|---|
| 189 | call ioconf_calendar('gregorian') |
|---|
| 190 | else |
|---|
| 191 | call ioconf_calendar('360d') |
|---|
| 192 | endif |
|---|
| 193 | #endif |
|---|
| 194 | c---------------------------------------------------------------------- |
|---|
| 195 | c lecture des fichiers gcm.def ou run.def |
|---|
| 196 | c --------------------------------------- |
|---|
| 197 | c |
|---|
| 198 | #ifdef CPP_IOIPSL |
|---|
| 199 | CALL conf_gcm( 99, .TRUE. , clesphy0 ) |
|---|
| 200 | #else |
|---|
| 201 | CALL defrun( 99, .TRUE. , clesphy0 ) |
|---|
| 202 | #endif |
|---|
| 203 | |
|---|
| 204 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 205 | ! FH 2008/05/02 |
|---|
| 206 | ! A nettoyer. On ne veut qu'une ou deux routines d'interface |
|---|
| 207 | ! dynamique -> physique pour l'initialisation |
|---|
| 208 | #ifdef CPP_PHYS |
|---|
| 209 | CALL Init_Phys_lmdz(iim,jjp1,llm,1,(jjm-1)*iim+2) |
|---|
| 210 | call InitComgeomphy |
|---|
| 211 | #endif |
|---|
| 212 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
|---|
| 213 | |
|---|
| 214 | IF (config_inca /= 'none') THEN |
|---|
| 215 | #ifdef INCA |
|---|
| 216 | call init_const_lmdz(nbtr,anneeref,dayref,iphysiq,day_step,nday) |
|---|
| 217 | call init_inca_para(iim,jjm+1,klon,1,klon_mpi_para_nb,0) |
|---|
| 218 | #endif |
|---|
| 219 | END IF |
|---|
| 220 | c |
|---|
| 221 | c |
|---|
| 222 | c------------------------------------ |
|---|
| 223 | c Initialisation partie parallele |
|---|
| 224 | c------------------------------------ |
|---|
| 225 | |
|---|
| 226 | c |
|---|
| 227 | c |
|---|
| 228 | c----------------------------------------------------------------------- |
|---|
| 229 | c Initialisation des traceurs |
|---|
| 230 | c --------------------------- |
|---|
| 231 | c Choix du nombre de traceurs et du schema pour l'advection |
|---|
| 232 | c dans fichier traceur.def, par default ou via INCA |
|---|
| 233 | call infotrac_init |
|---|
| 234 | |
|---|
| 235 | c Allocation de la tableau q : champs advectes |
|---|
| 236 | allocate(q(ip1jmp1,llm,nqtot)) |
|---|
| 237 | |
|---|
| 238 | c----------------------------------------------------------------------- |
|---|
| 239 | c Lecture de l'etat initial : |
|---|
| 240 | c --------------------------- |
|---|
| 241 | |
|---|
| 242 | c lecture du fichier start.nc |
|---|
| 243 | if (read_start) then |
|---|
| 244 | #ifdef CPP_IOIPSL |
|---|
| 245 | CALL dynetat0("start.nc",vcov,ucov, |
|---|
| 246 | . teta,q,masse,ps,phis, time_0) |
|---|
| 247 | c write(73,*) 'ucov',ucov |
|---|
| 248 | c write(74,*) 'vcov',vcov |
|---|
| 249 | c write(75,*) 'teta',teta |
|---|
| 250 | c write(76,*) 'ps',ps |
|---|
| 251 | c write(77,*) 'q',q |
|---|
| 252 | |
|---|
| 253 | #endif |
|---|
| 254 | endif |
|---|
| 255 | |
|---|
| 256 | IF (config_inca /= 'none') THEN |
|---|
| 257 | #ifdef INCA |
|---|
| 258 | call init_inca_dim(klon,llm,iim,jjm, |
|---|
| 259 | $ rlonu,rlatu,rlonv,rlatv) |
|---|
| 260 | #endif |
|---|
| 261 | END IF |
|---|
| 262 | |
|---|
| 263 | |
|---|
| 264 | c le cas echeant, creation d un etat initial |
|---|
| 265 | IF (prt_level > 9) WRITE(lunout,*) |
|---|
| 266 | . 'AVANT iniacademic AVANT AVANT AVANT AVANT' |
|---|
| 267 | if (.not.read_start) then |
|---|
| 268 | CALL iniacademic(vcov,ucov,teta,q,masse,ps,phis,time_0) |
|---|
| 269 | endif |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | c----------------------------------------------------------------------- |
|---|
| 273 | c Lecture des parametres de controle pour la simulation : |
|---|
| 274 | c ------------------------------------------------------- |
|---|
| 275 | c on recalcule eventuellement le pas de temps |
|---|
| 276 | |
|---|
| 277 | IF(MOD(day_step,iperiod).NE.0) THEN |
|---|
| 278 | abort_message = |
|---|
| 279 | . 'Il faut choisir un nb de pas par jour multiple de iperiod' |
|---|
| 280 | call abort_gcm(modname,abort_message,1) |
|---|
| 281 | ENDIF |
|---|
| 282 | |
|---|
| 283 | IF(MOD(day_step,iphysiq).NE.0) THEN |
|---|
| 284 | abort_message = |
|---|
| 285 | * 'Il faut choisir un nb de pas par jour multiple de iphysiq' |
|---|
| 286 | call abort_gcm(modname,abort_message,1) |
|---|
| 287 | ENDIF |
|---|
| 288 | |
|---|
| 289 | zdtvr = daysec/FLOAT(day_step) |
|---|
| 290 | IF(dtvr.NE.zdtvr) THEN |
|---|
| 291 | WRITE(lunout,*) |
|---|
| 292 | . 'WARNING!!! changement de pas de temps',dtvr,'>',zdtvr |
|---|
| 293 | ENDIF |
|---|
| 294 | |
|---|
| 295 | C |
|---|
| 296 | C on remet le calendrier à zero si demande |
|---|
| 297 | c |
|---|
| 298 | if (annee_ref .ne. anneeref .or. day_ref .ne. dayref) then |
|---|
| 299 | write(lunout,*) |
|---|
| 300 | . ' Attention les dates initiales lues dans le fichier' |
|---|
| 301 | write(lunout,*) |
|---|
| 302 | . ' restart ne correspondent pas a celles lues dans ' |
|---|
| 303 | write(lunout,*)' gcm.def' |
|---|
| 304 | if (raz_date .ne. 1) then |
|---|
| 305 | write(lunout,*) |
|---|
| 306 | . ' On garde les dates du fichier restart' |
|---|
| 307 | else |
|---|
| 308 | annee_ref = anneeref |
|---|
| 309 | day_ref = dayref |
|---|
| 310 | day_ini = dayref |
|---|
| 311 | itau_dyn = 0 |
|---|
| 312 | itau_phy = 0 |
|---|
| 313 | time_0 = 0. |
|---|
| 314 | write(lunout,*) |
|---|
| 315 | . ' On reinitialise a la date lue dans gcm.def' |
|---|
| 316 | endif |
|---|
| 317 | ELSE |
|---|
| 318 | raz_date = 0 |
|---|
| 319 | endif |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | c nombre d'etats dans les fichiers demarrage et histoire |
|---|
| 323 | nbetatdem = nday / iecri |
|---|
| 324 | nbetatmoy = nday / periodav + 1 |
|---|
| 325 | |
|---|
| 326 | c----------------------------------------------------------------------- |
|---|
| 327 | c Initialisation des constantes dynamiques : |
|---|
| 328 | c ------------------------------------------ |
|---|
| 329 | dtvr = zdtvr |
|---|
| 330 | CALL iniconst |
|---|
| 331 | |
|---|
| 332 | c----------------------------------------------------------------------- |
|---|
| 333 | c Initialisation de la geometrie : |
|---|
| 334 | c -------------------------------- |
|---|
| 335 | CALL inigeom |
|---|
| 336 | |
|---|
| 337 | c----------------------------------------------------------------------- |
|---|
| 338 | c Initialisation du filtre : |
|---|
| 339 | c -------------------------- |
|---|
| 340 | CALL inifilr |
|---|
| 341 | c |
|---|
| 342 | c----------------------------------------------------------------------- |
|---|
| 343 | c Initialisation de la dissipation : |
|---|
| 344 | c ---------------------------------- |
|---|
| 345 | |
|---|
| 346 | CALL inidissip( lstardis, nitergdiv, nitergrot, niterh , |
|---|
| 347 | * tetagdiv, tetagrot , tetatemp ) |
|---|
| 348 | |
|---|
| 349 | c----------------------------------------------------------------------- |
|---|
| 350 | c Initialisation de la physique : |
|---|
| 351 | c ------------------------------- |
|---|
| 352 | #ifdef CPP_PHYS |
|---|
| 353 | IF (call_iniphys.and.iflag_phys.eq.1) THEN |
|---|
| 354 | latfi(1)=rlatu(1) |
|---|
| 355 | lonfi(1)=0. |
|---|
| 356 | zcufi(1) = cu(1) |
|---|
| 357 | zcvfi(1) = cv(1) |
|---|
| 358 | DO j=2,jjm |
|---|
| 359 | DO i=1,iim |
|---|
| 360 | latfi((j-2)*iim+1+i)= rlatu(j) |
|---|
| 361 | lonfi((j-2)*iim+1+i)= rlonv(i) |
|---|
| 362 | zcufi((j-2)*iim+1+i) = cu((j-1)*iip1+i) |
|---|
| 363 | zcvfi((j-2)*iim+1+i) = cv((j-1)*iip1+i) |
|---|
| 364 | ENDDO |
|---|
| 365 | ENDDO |
|---|
| 366 | latfi(ngridmx)= rlatu(jjp1) |
|---|
| 367 | lonfi(ngridmx)= 0. |
|---|
| 368 | zcufi(ngridmx) = cu(ip1jm+1) |
|---|
| 369 | zcvfi(ngridmx) = cv(ip1jm-iim) |
|---|
| 370 | CALL gr_dyn_fi(1,iip1,jjp1,ngridmx,aire,airefi) |
|---|
| 371 | WRITE(lunout,*) |
|---|
| 372 | . 'WARNING!!! vitesse verticale nulle dans la physique' |
|---|
| 373 | CALL iniphysiq(ngridmx,llm,daysec,day_ini,dtphys , |
|---|
| 374 | , latfi,lonfi,airefi,zcufi,zcvfi,rad,g,r,cpp ) |
|---|
| 375 | call_iniphys=.false. |
|---|
| 376 | ENDIF |
|---|
| 377 | #endif |
|---|
| 378 | |
|---|
| 379 | c numero de stockage pour les fichiers de redemarrage: |
|---|
| 380 | |
|---|
| 381 | c----------------------------------------------------------------------- |
|---|
| 382 | c Initialisation des I/O : |
|---|
| 383 | c ------------------------ |
|---|
| 384 | |
|---|
| 385 | |
|---|
| 386 | day_end = day_ini + nday |
|---|
| 387 | WRITE(lunout,300)day_ini,day_end |
|---|
| 388 | |
|---|
| 389 | #ifdef CPP_IOIPSL |
|---|
| 390 | CALL dynredem0("restart.nc", day_end, phis) |
|---|
| 391 | |
|---|
| 392 | ecripar = .TRUE. |
|---|
| 393 | |
|---|
| 394 | if ( 1.eq.1) then |
|---|
| 395 | time_step = zdtvr |
|---|
| 396 | t_ops = iecri * daysec |
|---|
| 397 | t_wrt = iecri * daysec |
|---|
| 398 | CALL inithist(dynhist_file,day_ref,annee_ref,time_step, |
|---|
| 399 | . t_ops, t_wrt, histid, histvid) |
|---|
| 400 | |
|---|
| 401 | t_ops = iperiod * time_step |
|---|
| 402 | t_wrt = periodav * daysec |
|---|
| 403 | CALL initdynav(dynhistave_file,day_ref,annee_ref,time_step, |
|---|
| 404 | . t_ops, t_wrt, histaveid) |
|---|
| 405 | |
|---|
| 406 | dtav = iperiod*dtvr/daysec |
|---|
| 407 | endif |
|---|
| 408 | |
|---|
| 409 | |
|---|
| 410 | #endif |
|---|
| 411 | |
|---|
| 412 | c Choix des frequences de stokage pour le offline |
|---|
| 413 | c istdyn=day_step/4 ! stockage toutes les 6h=1jour/4 |
|---|
| 414 | c istdyn=day_step/12 ! stockage toutes les 2h=1jour/12 |
|---|
| 415 | istdyn=day_step/4 ! stockage toutes les 6h=1jour/12 |
|---|
| 416 | istphy=istdyn/iphysiq |
|---|
| 417 | |
|---|
| 418 | |
|---|
| 419 | c |
|---|
| 420 | c----------------------------------------------------------------------- |
|---|
| 421 | c Integration temporelle du modele : |
|---|
| 422 | c ---------------------------------- |
|---|
| 423 | |
|---|
| 424 | c write(78,*) 'ucov',ucov |
|---|
| 425 | c write(78,*) 'vcov',vcov |
|---|
| 426 | c write(78,*) 'teta',teta |
|---|
| 427 | c write(78,*) 'ps',ps |
|---|
| 428 | c write(78,*) 'q',q |
|---|
| 429 | |
|---|
| 430 | |
|---|
| 431 | CALL leapfrog(ucov,vcov,teta,ps,masse,phis,q,clesphy0, |
|---|
| 432 | . time_0) |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | |
|---|
| 436 | 300 FORMAT('1'/,15x,'run du pas',i7,2x,'au pas',i7,2x, |
|---|
| 437 | . 'c''est a dire du jour',i7,3x,'au jour',i7//) |
|---|
| 438 | END |
|---|
| 439 | |
|---|