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