| 1 | c======================================================================= |
|---|
| 2 | PROGRAM start2archive |
|---|
| 3 | c======================================================================= |
|---|
| 4 | c |
|---|
| 5 | c |
|---|
| 6 | c Date: 01/1997 |
|---|
| 7 | c ---- |
|---|
| 8 | c |
|---|
| 9 | c |
|---|
| 10 | c Objet: Passage des fichiers netcdf d'etat initial "start" et |
|---|
| 11 | c ----- "startfi" a un fichier netcdf unique "start_archive" |
|---|
| 12 | c |
|---|
| 13 | c "start_archive" est une banque d'etats initiaux: |
|---|
| 14 | c On peut stocker plusieurs etats initiaux dans un meme fichier "start_archive" |
|---|
| 15 | c (Veiller dans ce cas avoir un day_ini different pour chacun des start) |
|---|
| 16 | c |
|---|
| 17 | c |
|---|
| 18 | c |
|---|
| 19 | c======================================================================= |
|---|
| 20 | |
|---|
| 21 | use infotrac, only: infotrac_init, nqtot, tname |
|---|
| 22 | use comsoil_h, only: nsoilmx, inertiedat, inertiesoil, |
|---|
| 23 | & nqsoil, qsoil |
|---|
| 24 | use surfdat_h, only: ini_surfdat_h, qsurf,watercaptag |
|---|
| 25 | use comsoil_h, only: ini_comsoil_h |
|---|
| 26 | ! use comgeomphy, only: initcomgeomphy |
|---|
| 27 | use filtreg_mod, only: inifilr |
|---|
| 28 | USE mod_const_mpi, ONLY: COMM_LMDZ |
|---|
| 29 | use control_mod, only: planet_type |
|---|
| 30 | USE comvert_mod, ONLY: ap,bp |
|---|
| 31 | USE comconst_mod, ONLY: daysec,dtphys,rad,g,r,cpp |
|---|
| 32 | USE temps_mod, ONLY: day_ini,hour_ini |
|---|
| 33 | USE iniphysiq_mod, ONLY: iniphysiq |
|---|
| 34 | USE phyetat0_mod, ONLY: phyetat0 |
|---|
| 35 | USE exner_hyb_m, ONLY: exner_hyb |
|---|
| 36 | use comslope_mod, ONLY: nslope,def_slope,def_slope_mean, |
|---|
| 37 | & subslope_dist |
|---|
| 38 | USE comcstfi_h, only: pi |
|---|
| 39 | use surfini_mod, only: surfini |
|---|
| 40 | ! SSO parameters: |
|---|
| 41 | USE surfdat_h, ONLY: phisfi, albedodat, z0, z0_default, |
|---|
| 42 | & zmea, zstd, zsig, zgam, zthe, hmons, summit, base |
|---|
| 43 | use parse_args_mod, only: parse_args, add_sso_fields |
|---|
| 44 | |
|---|
| 45 | implicit none |
|---|
| 46 | |
|---|
| 47 | include "dimensions.h" |
|---|
| 48 | integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) |
|---|
| 49 | include "paramet.h" |
|---|
| 50 | include "comdissip.h" |
|---|
| 51 | include "comgeom.h" |
|---|
| 52 | include "netcdf.inc" |
|---|
| 53 | |
|---|
| 54 | c----------------------------------------------------------------------- |
|---|
| 55 | c Declarations |
|---|
| 56 | c----------------------------------------------------------------------- |
|---|
| 57 | |
|---|
| 58 | c variables dynamiques du GCM |
|---|
| 59 | c ----------------------------- |
|---|
| 60 | REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants |
|---|
| 61 | REAL teta(ip1jmp1,llm) ! temperature potentielle |
|---|
| 62 | REAL,ALLOCATABLE :: q(:,:,:) ! champs advectes |
|---|
| 63 | REAL pks(ip1jmp1) ! exner (f pour filtre) |
|---|
| 64 | REAL pk(ip1jmp1,llm) |
|---|
| 65 | REAL pkf(ip1jmp1,llm) |
|---|
| 66 | REAL phis(ip1jmp1) ! geopotentiel au sol |
|---|
| 67 | REAL masse(ip1jmp1,llm) ! masse de l'atmosphere |
|---|
| 68 | REAL ps(ip1jmp1) ! pression au sol |
|---|
| 69 | REAL p3d(iip1, jjp1, llm+1) ! pression aux interfaces |
|---|
| 70 | |
|---|
| 71 | c Variable Physiques (grille physique) |
|---|
| 72 | c ------------------------------------ |
|---|
| 73 | REAL,ALLOCATABLE :: tsurf(:,:) ! Surface temperature |
|---|
| 74 | REAL,ALLOCATABLE :: tsoil(:,:,:) ! Soil temperature |
|---|
| 75 | REAL,ALLOCATABLE :: watercap(:,:) ! h2o ice layer |
|---|
| 76 | REAL,ALLOCATABLE :: perennial_co2ice(:,:) ! co2 ice layer |
|---|
| 77 | REAL :: tauscaling(ngridmx) ! dust conversion factor |
|---|
| 78 | REAL:: totcloudfrac(ngridmx) ! sub-grid cloud fraction |
|---|
| 79 | REAL q2(ngridmx,llm+1) |
|---|
| 80 | REAL,ALLOCATABLE :: emis(:,:) |
|---|
| 81 | REAL,ALLOCATABLE :: albedo(:,:,:) |
|---|
| 82 | REAL wstar(ngridmx) |
|---|
| 83 | INTEGER start,length |
|---|
| 84 | PARAMETER (length = 100) |
|---|
| 85 | REAL tab_cntrl_fi(length) ! tableau des parametres de startfi |
|---|
| 86 | INTEGER*4 day_ini_fi |
|---|
| 87 | |
|---|
| 88 | c Variable naturelle / grille scalaire |
|---|
| 89 | c ------------------------------------ |
|---|
| 90 | REAL T(ip1jmp1,llm),us(ip1jmp1,llm),vs(ip1jmp1,llm) |
|---|
| 91 | REAL,ALLOCATABLE :: tsurfS(:,:) |
|---|
| 92 | REAL,ALLOCATABLE :: tsoilS(:,:,:) |
|---|
| 93 | REAL,ALLOCATABLE :: inertiesoilS(:,:,:)! Variable Soil Thermal Inertia (obtained from PEM) |
|---|
| 94 | REAL ithS(ip1jmp1,nsoilmx) ! Soil Thermal Inertia for inertie dat (present day climate) |
|---|
| 95 | REAL,ALLOCATABLE :: watercapS(:,:) |
|---|
| 96 | REAL,ALLOCATABLE :: perennial_co2iceS(:,:) |
|---|
| 97 | REAL,ALLOCATABLE :: watercaptag_tmp(:) |
|---|
| 98 | REAL,ALLOCATABLE :: watercaptagS(:) |
|---|
| 99 | REAL :: tauscalingS(ip1jmp1) |
|---|
| 100 | REAL :: totcloudfracS(ip1jmp1) |
|---|
| 101 | REAL q2S(ip1jmp1,llm+1) |
|---|
| 102 | REAL,ALLOCATABLE :: qsurfS(:,:,:) |
|---|
| 103 | REAL,ALLOCATABLE :: emisS(:,:) |
|---|
| 104 | REAL,ALLOCATABLE :: albedoS(:,:) |
|---|
| 105 | REAL, ALLOCATABLE :: subslope_distS(:,:) |
|---|
| 106 | |
|---|
| 107 | ! For SSO parameters: |
|---|
| 108 | REAL zmeaS(ip1jmp1) |
|---|
| 109 | REAL zsigS(ip1jmp1) |
|---|
| 110 | REAL zstdS(ip1jmp1) |
|---|
| 111 | REAL zgamS(ip1jmp1) |
|---|
| 112 | REAL ztheS(ip1jmp1) |
|---|
| 113 | REAL albedodatS(ip1jmp1) |
|---|
| 114 | REAL z0S(ip1jmp1) |
|---|
| 115 | REAL hmonsS(ip1jmp1) |
|---|
| 116 | REAL summitS(ip1jmp1) |
|---|
| 117 | REAL baseS(ip1jmp1) |
|---|
| 118 | |
|---|
| 119 | |
|---|
| 120 | c Variables intermediaires : vent naturel, mais pas coord scalaire |
|---|
| 121 | c---------------------------------------------------------------- |
|---|
| 122 | REAL vn(ip1jm,llm),un(ip1jmp1,llm) |
|---|
| 123 | |
|---|
| 124 | c Autres variables |
|---|
| 125 | c ----------------- |
|---|
| 126 | LOGICAL startdrs |
|---|
| 127 | INTEGER Lmodif |
|---|
| 128 | |
|---|
| 129 | REAL ptotal, co2icetotal |
|---|
| 130 | REAL timedyn,timefi !fraction du jour dans start, startfi |
|---|
| 131 | REAL date |
|---|
| 132 | |
|---|
| 133 | CHARACTER*2 str2 |
|---|
| 134 | CHARACTER*80 fichier |
|---|
| 135 | data fichier /'startfi'/ |
|---|
| 136 | |
|---|
| 137 | INTEGER ij, l,i,j,isoil,iq,islope |
|---|
| 138 | character*80 fichnom |
|---|
| 139 | integer :: ierr,ntime |
|---|
| 140 | integer :: igcm_co2 |
|---|
| 141 | integer :: nq,numvanle |
|---|
| 142 | character(len=30) :: txt ! to store some text |
|---|
| 143 | |
|---|
| 144 | c Netcdf |
|---|
| 145 | c------- |
|---|
| 146 | integer varid,dimid,timelen |
|---|
| 147 | INTEGER nid,nid1 |
|---|
| 148 | |
|---|
| 149 | ! Parse command-line options |
|---|
| 150 | ! Option "--add-sso" adds SSO fields to "start_archive.nc" |
|---|
| 151 | call parse_args() |
|---|
| 152 | |
|---|
| 153 | c----------------------------------------------------------------------- |
|---|
| 154 | c Initialisations |
|---|
| 155 | c----------------------------------------------------------------------- |
|---|
| 156 | |
|---|
| 157 | CALL defrun_new(99, .TRUE. ) |
|---|
| 158 | |
|---|
| 159 | planet_type='mars' |
|---|
| 160 | |
|---|
| 161 | c======================================================================= |
|---|
| 162 | c Lecture des donnees |
|---|
| 163 | c======================================================================= |
|---|
| 164 | ! Load tracer number and names: |
|---|
| 165 | call infotrac_init |
|---|
| 166 | |
|---|
| 167 | ! allocate arrays: |
|---|
| 168 | allocate(q(ip1jmp1,llm,nqtot)) |
|---|
| 169 | |
|---|
| 170 | fichnom = 'start.nc' |
|---|
| 171 | CALL dynetat0(fichnom,vcov,ucov,teta,q,masse, |
|---|
| 172 | . ps,phis,timedyn) |
|---|
| 173 | |
|---|
| 174 | c----------------------------------------------------------------------- |
|---|
| 175 | c Initialisations |
|---|
| 176 | c----------------------------------------------------------------------- |
|---|
| 177 | |
|---|
| 178 | CALL defrun_new(99, .FALSE. ) |
|---|
| 179 | call iniconst |
|---|
| 180 | call inigeom |
|---|
| 181 | call inifilr |
|---|
| 182 | |
|---|
| 183 | ! Initialize the physics |
|---|
| 184 | CALL iniphysiq(iim,jjm,llm, |
|---|
| 185 | & (jjm-1)*iim+2,comm_lmdz, |
|---|
| 186 | & daysec,day_ini,dtphys, |
|---|
| 187 | & rlatu,rlatv,rlonu,rlonv, |
|---|
| 188 | & aire,cu,cv,rad,g,r,cpp,1) |
|---|
| 189 | |
|---|
| 190 | fichnom = 'startfi.nc' |
|---|
| 191 | Lmodif=0 |
|---|
| 192 | |
|---|
| 193 | allocate(tsurf(ngridmx,nslope)) |
|---|
| 194 | allocate(tsoil(ngridmx,nsoilmx,nslope)) |
|---|
| 195 | allocate(watercap(ngridmx,nslope)) |
|---|
| 196 | allocate(perennial_co2ice(ngridmx,nslope)) |
|---|
| 197 | allocate(emis(ngridmx,nslope)) |
|---|
| 198 | allocate(albedo(ngridmx,2,nslope)) |
|---|
| 199 | |
|---|
| 200 | allocate(qsurfS(ip1jmp1,nqtot,nslope)) |
|---|
| 201 | allocate(tsurfS(ip1jmp1,nslope)) |
|---|
| 202 | allocate(tsoilS(ip1jmp1,nsoilmx,nslope)) |
|---|
| 203 | allocate(inertiesoilS(ip1jmp1,nsoilmx,nslope)) |
|---|
| 204 | allocate(watercapS(ip1jmp1,nslope)) |
|---|
| 205 | allocate(perennial_co2iceS(ip1jmp1,nslope)) |
|---|
| 206 | allocate(watercaptagS(ip1jmp1)) |
|---|
| 207 | allocate(emisS(ip1jmp1,nslope)) |
|---|
| 208 | allocate(albedoS(ip1jmp1,nslope)) |
|---|
| 209 | allocate(subslope_distS(ip1jmp1,nslope)) |
|---|
| 210 | |
|---|
| 211 | CALL phyetat0(fichnom,0,Lmodif,nsoilmx,ngridmx,llm,nqtot,nqsoil, |
|---|
| 212 | & day_ini_fi,timefi,tsurf,tsoil,albedo,emis,q2,qsurf,qsoil, |
|---|
| 213 | & tauscaling,totcloudfrac,wstar,watercap,perennial_co2ice, |
|---|
| 214 | & def_slope, def_slope_mean,subslope_dist) |
|---|
| 215 | |
|---|
| 216 | ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1) |
|---|
| 217 | IF (ierr.NE.NF_NOERR) THEN |
|---|
| 218 | write(6,*)' Pb d''ouverture du fichier'//fichnom |
|---|
| 219 | CALL ABORT |
|---|
| 220 | ENDIF |
|---|
| 221 | |
|---|
| 222 | ierr = NF_INQ_VARID (nid1, "controle", varid) |
|---|
| 223 | IF (ierr .NE. NF_NOERR) THEN |
|---|
| 224 | PRINT*, "start2archive: Le champ <controle> est absent" |
|---|
| 225 | CALL abort |
|---|
| 226 | ENDIF |
|---|
| 227 | #ifdef NC_DOUBLE |
|---|
| 228 | ierr = NF_GET_VAR_DOUBLE(nid1, varid, tab_cntrl_fi) |
|---|
| 229 | #else |
|---|
| 230 | ierr = NF_GET_VAR_REAL(nid1, varid, tab_cntrl_fi) |
|---|
| 231 | #endif |
|---|
| 232 | IF (ierr .NE. NF_NOERR) THEN |
|---|
| 233 | PRINT*, "start2archive: Lecture echoue pour <controle>" |
|---|
| 234 | CALL abort |
|---|
| 235 | ENDIF |
|---|
| 236 | |
|---|
| 237 | CALL surfini(ngridmx,nslope,qsurf) |
|---|
| 238 | |
|---|
| 239 | ierr = NF_CLOSE(nid1) |
|---|
| 240 | |
|---|
| 241 | c----------------------------------------------------------------------- |
|---|
| 242 | c Controle de la synchro |
|---|
| 243 | c----------------------------------------------------------------------- |
|---|
| 244 | !mars a voir if ((day_ini_fi.ne.day_ini).or.(abs(timefi-timedyn).gt.1.e-10)) |
|---|
| 245 | if ((mod(day_ini_fi,669).ne.mod(day_ini,669))) |
|---|
| 246 | & stop ' Probleme de Synchro entre start et startfi !!!' |
|---|
| 247 | |
|---|
| 248 | |
|---|
| 249 | c ***************************************************************** |
|---|
| 250 | c Option : Reinitialisation des dates dans la premieres annees : |
|---|
| 251 | do while (day_ini.ge.669) |
|---|
| 252 | day_ini=day_ini-669 |
|---|
| 253 | enddo |
|---|
| 254 | c ***************************************************************** |
|---|
| 255 | |
|---|
| 256 | CALL pression(ip1jmp1, ap, bp, ps, p3d) |
|---|
| 257 | call exner_hyb(ip1jmp1, ps, p3d, pks, pk, pkf) |
|---|
| 258 | |
|---|
| 259 | c======================================================================= |
|---|
| 260 | c Transformation EN VARIABLE NATURELLE / GRILLE SCALAIRE si necessaire |
|---|
| 261 | c======================================================================= |
|---|
| 262 | c Les variables modeles dependent de la resolution. Il faut donc |
|---|
| 263 | c eliminer les facteurs responsables de cette dependance |
|---|
| 264 | c (pour utiliser newstart) |
|---|
| 265 | c======================================================================= |
|---|
| 266 | |
|---|
| 267 | c----------------------------------------------------------------------- |
|---|
| 268 | c Vent (depend de la resolution horizontale) |
|---|
| 269 | c----------------------------------------------------------------------- |
|---|
| 270 | c |
|---|
| 271 | c ucov --> un et vcov --> vn |
|---|
| 272 | c un --> us et vn --> vs |
|---|
| 273 | c |
|---|
| 274 | c----------------------------------------------------------------------- |
|---|
| 275 | |
|---|
| 276 | call covnat(llm,ucov, vcov, un, vn) |
|---|
| 277 | call wind_scal(un,vn,us,vs) |
|---|
| 278 | |
|---|
| 279 | c----------------------------------------------------------------------- |
|---|
| 280 | c Temperature (depend de la resolution verticale => de "sigma.def") |
|---|
| 281 | c----------------------------------------------------------------------- |
|---|
| 282 | c |
|---|
| 283 | c h --> T |
|---|
| 284 | c |
|---|
| 285 | c----------------------------------------------------------------------- |
|---|
| 286 | |
|---|
| 287 | DO l=1,llm |
|---|
| 288 | DO ij=1,ip1jmp1 |
|---|
| 289 | T(ij,l)=teta(ij,l)*pk(ij,l)/cpp !mars deduit de l'equation dans newstart |
|---|
| 290 | ENDDO |
|---|
| 291 | ENDDO |
|---|
| 292 | |
|---|
| 293 | c----------------------------------------------------------------------- |
|---|
| 294 | c Variable physique |
|---|
| 295 | c----------------------------------------------------------------------- |
|---|
| 296 | c |
|---|
| 297 | c tsurf --> tsurfS |
|---|
| 298 | c watercap --> watercapS |
|---|
| 299 | c perennial_co2ice --> perennial_co2iceS |
|---|
| 300 | c tsoil --> tsoilS |
|---|
| 301 | c inertiesoil --> inertiesoilS |
|---|
| 302 | c inertiedat --> ithS |
|---|
| 303 | c emis --> emisS |
|---|
| 304 | c albedo --> albedoS |
|---|
| 305 | c q2 --> q2S |
|---|
| 306 | c qsurf --> qsurfS |
|---|
| 307 | c tauscaling --> tauscalingS |
|---|
| 308 | c totcloudfrac --> totcloudfracS |
|---|
| 309 | c |
|---|
| 310 | c----------------------------------------------------------------------- |
|---|
| 311 | |
|---|
| 312 | do islope=1,nslope |
|---|
| 313 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsurf(:,islope), |
|---|
| 314 | & tsurfS(:,islope)) |
|---|
| 315 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,watercap(:,islope), |
|---|
| 316 | & watercapS(:,islope)) |
|---|
| 317 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,perennial_co2ice(:,islope), |
|---|
| 318 | & perennial_co2iceS(:,islope)) |
|---|
| 319 | call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,tsoil(:,:,islope), |
|---|
| 320 | & tsoilS(:,:,islope)) |
|---|
| 321 | call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,inertiesoil(:,:,islope), |
|---|
| 322 | & inertiesoilS(:,:,islope)) |
|---|
| 323 | ! Note: thermal inertia "inertiedat" is in comsoil.h |
|---|
| 324 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,emis(:,islope), |
|---|
| 325 | & emisS(:,islope)) |
|---|
| 326 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,albedo(:,1,islope), |
|---|
| 327 | & albedoS(:,islope)) |
|---|
| 328 | call gr_fi_dyn(nqtot,ngridmx,iip1,jjp1,qsurf(:,:,islope), |
|---|
| 329 | & qsurfS(:,:,islope)) |
|---|
| 330 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,subslope_dist(:,islope), |
|---|
| 331 | & subslope_distS(:,islope)) |
|---|
| 332 | enddo |
|---|
| 333 | call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,inertiedat,ithS) |
|---|
| 334 | call gr_fi_dyn(llm+1,ngridmx,iip1,jjp1,q2,q2S) |
|---|
| 335 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,tauscaling,tauscalingS) |
|---|
| 336 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,totcloudfrac,totcloudfracS) |
|---|
| 337 | |
|---|
| 338 | allocate(watercaptag_tmp(ngridmx)) |
|---|
| 339 | do ij=1,ngridmx |
|---|
| 340 | if(watercaptag(ij)) then |
|---|
| 341 | watercaptag_tmp(ij)=1 |
|---|
| 342 | else |
|---|
| 343 | watercaptag_tmp(ij)=0 |
|---|
| 344 | endif |
|---|
| 345 | enddo |
|---|
| 346 | |
|---|
| 347 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,watercaptag_tmp(:), |
|---|
| 348 | & watercaptagS(:)) |
|---|
| 349 | |
|---|
| 350 | ! SSO parameters, if needed: |
|---|
| 351 | if (add_sso_fields) then |
|---|
| 352 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,zmea,zmeaS) |
|---|
| 353 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,zstd,zstdS) |
|---|
| 354 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,zsig,zsigS) |
|---|
| 355 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,zthe,ztheS) |
|---|
| 356 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,zgam,zgamS) |
|---|
| 357 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,albedodat,albedodatS) |
|---|
| 358 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,z0,z0S) |
|---|
| 359 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,hmons,hmonsS) |
|---|
| 360 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,summit,summitS) |
|---|
| 361 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,base,baseS) |
|---|
| 362 | endif |
|---|
| 363 | |
|---|
| 364 | c======================================================================= |
|---|
| 365 | c Info pour controler |
|---|
| 366 | c======================================================================= |
|---|
| 367 | |
|---|
| 368 | DO iq=1,nqtot |
|---|
| 369 | if (trim(tname(iq)) .eq. "co2") then |
|---|
| 370 | igcm_co2=iq |
|---|
| 371 | endif |
|---|
| 372 | enddo |
|---|
| 373 | |
|---|
| 374 | ptotal = 0. |
|---|
| 375 | co2icetotal = 0. |
|---|
| 376 | DO j=1,jjp1 |
|---|
| 377 | DO i=1,iim |
|---|
| 378 | DO islope=1,nslope |
|---|
| 379 | ptotal=ptotal+aire(i+(iim+1)*(j-1))*ps(i+(iim+1)*(j-1))/g |
|---|
| 380 | co2icetotal = co2icetotal + |
|---|
| 381 | & qsurfS(i+(iim+1)*(j-1),igcm_co2,islope)* |
|---|
| 382 | & aire(i+(iim+1)*(j-1))* |
|---|
| 383 | & subslope_distS(i+(iim+1)*(j-1),islope)/ |
|---|
| 384 | & cos(pi*def_slope_mean(islope)) |
|---|
| 385 | ENDDO |
|---|
| 386 | ENDDO |
|---|
| 387 | ENDDO |
|---|
| 388 | write(*,*)'Ancienne grille : masse de l''atm :',ptotal |
|---|
| 389 | write(*,*)'Ancienne grille : masse de la glace CO2 :',co2icetotal |
|---|
| 390 | |
|---|
| 391 | c----------------------------------------------------------------------- |
|---|
| 392 | c Passage de "ptotal" et "co2icetotal" par tab_cntrl_fi |
|---|
| 393 | c----------------------------------------------------------------------- |
|---|
| 394 | |
|---|
| 395 | tab_cntrl_fi(49) = ptotal |
|---|
| 396 | tab_cntrl_fi(50) = co2icetotal |
|---|
| 397 | |
|---|
| 398 | c======================================================================= |
|---|
| 399 | c Ecriture dans le fichier "start_archive" |
|---|
| 400 | c======================================================================= |
|---|
| 401 | |
|---|
| 402 | c----------------------------------------------------------------------- |
|---|
| 403 | c Ouverture de "start_archive" |
|---|
| 404 | c----------------------------------------------------------------------- |
|---|
| 405 | |
|---|
| 406 | ierr = NF_OPEN ('start_archive.nc', NF_WRITE,nid) |
|---|
| 407 | |
|---|
| 408 | c----------------------------------------------------------------------- |
|---|
| 409 | c si "start_archive" n'existe pas: |
|---|
| 410 | c 1_ ouverture |
|---|
| 411 | c 2_ creation de l'entete dynamique ("ini_archive") |
|---|
| 412 | c----------------------------------------------------------------------- |
|---|
| 413 | c ini_archive: |
|---|
| 414 | c On met dans l'entete le tab_cntrl dynamique (1 a 16) |
|---|
| 415 | c On y ajoute les valeurs du tab_cntrl_fi (a partir de 51) |
|---|
| 416 | c En plus les deux valeurs ptotal et co2icetotal (99 et 100) |
|---|
| 417 | c----------------------------------------------------------------------- |
|---|
| 418 | |
|---|
| 419 | if (ierr.ne.NF_NOERR) then |
|---|
| 420 | write(*,*)'OK, Could not open file "start_archive.nc"' |
|---|
| 421 | write(*,*)'So let s create a new "start_archive"' |
|---|
| 422 | ierr = NF_CREATE('start_archive.nc', |
|---|
| 423 | & IOR(NF_CLOBBER,NF_64BIT_OFFSET), nid) |
|---|
| 424 | call ini_archive(nid,day_ini,phis,ithS,tab_cntrl_fi, |
|---|
| 425 | & def_slope,subslope_distS) |
|---|
| 426 | endif |
|---|
| 427 | |
|---|
| 428 | c----------------------------------------------------------------------- |
|---|
| 429 | c Ecriture de la coordonnee temps (date en jours) |
|---|
| 430 | c----------------------------------------------------------------------- |
|---|
| 431 | |
|---|
| 432 | date = day_ini + hour_ini |
|---|
| 433 | ierr= NF_INQ_VARID(nid,"Time",varid) |
|---|
| 434 | ierr= NF_INQ_DIMID(nid,"Time",dimid) |
|---|
| 435 | ierr= NF_INQ_DIMLEN(nid,dimid,timelen) |
|---|
| 436 | ntime=timelen+1 |
|---|
| 437 | |
|---|
| 438 | write(*,*) "******************" |
|---|
| 439 | write(*,*) "ntime",ntime |
|---|
| 440 | write(*,*) "******************" |
|---|
| 441 | #ifdef NC_DOUBLE |
|---|
| 442 | ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date) |
|---|
| 443 | #else |
|---|
| 444 | ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date) |
|---|
| 445 | #endif |
|---|
| 446 | if (ierr.ne.NF_NOERR) then |
|---|
| 447 | write(*,*) "time matter ",NF_STRERROR(ierr) |
|---|
| 448 | stop |
|---|
| 449 | endif |
|---|
| 450 | |
|---|
| 451 | c----------------------------------------------------------------------- |
|---|
| 452 | c Ecriture des champs (co2ice,emis,albedo,ps,Tsurf,T,u,v,q2,q,qsurf) |
|---|
| 453 | c----------------------------------------------------------------------- |
|---|
| 454 | c ATTENTION: q2 a une couche de plus!!!! |
|---|
| 455 | c Pour creer un fichier netcdf lisible par grads, |
|---|
| 456 | c On passe donc une des couches de q2 a part |
|---|
| 457 | c comme une variable 2D (la couche au sol: "q2surf") |
|---|
| 458 | c Les lmm autres couches sont nommees "q2atm" (3D) |
|---|
| 459 | c----------------------------------------------------------------------- |
|---|
| 460 | |
|---|
| 461 | call write_archive(nid,ntime,'watercap','couche de glace h2o', |
|---|
| 462 | & 'kg/m2',2,watercapS) |
|---|
| 463 | call write_archive(nid,ntime,'perennial_co2ice', |
|---|
| 464 | &'couche de glace co2','kg/m2',2,perennial_co2iceS) |
|---|
| 465 | call write_archive(nid,ntime,'watercaptag','couche de glace h2o', |
|---|
| 466 | & 'kg/m2',2,watercaptagS) |
|---|
| 467 | call write_archive(nid,ntime,'tauscaling', |
|---|
| 468 | & 'dust conversion factor',' ',2,tauscalingS) |
|---|
| 469 | call write_archive(nid,ntime,'totcloudfrac', |
|---|
| 470 | & 'sub grid cloud fraction',' ',2,totcloudfracS) |
|---|
| 471 | call write_archive(nid,ntime,'emis','grd emis',' ',2,emisS) |
|---|
| 472 | call write_archive(nid,ntime,'albedo','surface albedo',' ', |
|---|
| 473 | & 2,albedoS) |
|---|
| 474 | call write_archive(nid,ntime,'ps','Psurf','Pa',2,ps) |
|---|
| 475 | call write_archive(nid,ntime,'tsurf','surf T','K',2,tsurfS) |
|---|
| 476 | call write_archive(nid,ntime,'temp','temperature','K',3,t) |
|---|
| 477 | call write_archive(nid,ntime,'u','Vent zonal','m.s-1',3,us) |
|---|
| 478 | call write_archive(nid,ntime,'v','Vent merid','m.s-1',3,vs) |
|---|
| 479 | call write_archive(nid,ntime,'q2surf','wind variance','m2.s-2',2, |
|---|
| 480 | . q2S) |
|---|
| 481 | call write_archive(nid,ntime,'q2atm','wind variance','m2.s-2',3, |
|---|
| 482 | . q2S(1,2)) |
|---|
| 483 | ! SSO parameters, if needed |
|---|
| 484 | if (add_sso_fields) then |
|---|
| 485 | call write_archive(nid,ntime,'ZMEA','zmea',' ',2,zmeaS) |
|---|
| 486 | call write_archive(nid,ntime,'ZSTD','zstd',' ',2,zstdS) |
|---|
| 487 | call write_archive(nid,ntime,'ZSIG','zsig',' ',2,zsigS) |
|---|
| 488 | call write_archive(nid,ntime,'ZTHE','zthe',' ',2,ztheS) |
|---|
| 489 | call write_archive(nid,ntime,'ZGAM','zgam',' ',2,zgamS) |
|---|
| 490 | call write_archive(nid,ntime,'albedodat','albedodat', |
|---|
| 491 | & ' ',2,albedodatS) |
|---|
| 492 | call write_archive(nid,ntime,'z0','z0',' ',2,z0S) |
|---|
| 493 | call write_archive(nid,ntime,'summit','summit', |
|---|
| 494 | & ' ',2,summitS) |
|---|
| 495 | call write_archive(nid,ntime,'hmons','hmons',' ',2,hmonsS) |
|---|
| 496 | call write_archive(nid,ntime,'base','base',' ',2,baseS) |
|---|
| 497 | endif |
|---|
| 498 | |
|---|
| 499 | c----------------------------------------------------------------------- |
|---|
| 500 | c Ecriture du champs q ( q[1,nqtot] ) |
|---|
| 501 | c----------------------------------------------------------------------- |
|---|
| 502 | do iq=1,nqtot |
|---|
| 503 | c write(str2,'(i2.2)') iq |
|---|
| 504 | c call write_archive(nid,ntime,'q'//str2,'tracer','kg/kg', |
|---|
| 505 | c . 3,q(1,1,iq)) |
|---|
| 506 | call write_archive(nid,ntime,tname(iq),'tracer','kg/kg', |
|---|
| 507 | & 3,q(1,1,iq)) |
|---|
| 508 | end do |
|---|
| 509 | c----------------------------------------------------------------------- |
|---|
| 510 | c Ecriture du champs qsurf ( qsurf[1,nqtot] ) |
|---|
| 511 | c----------------------------------------------------------------------- |
|---|
| 512 | do iq=1,nqtot |
|---|
| 513 | c write(str2,'(i2.2)') iq |
|---|
| 514 | c call write_archive(nid,ntime,'qsurf'//str2,'Tracer on surface', |
|---|
| 515 | c $ 'kg.m-2',2,qsurfS(1,iq)) |
|---|
| 516 | txt=trim(tname(iq))//"_surf" |
|---|
| 517 | call write_archive(nid,ntime,txt,'Tracer on surface', |
|---|
| 518 | & 'kg.m-2',2,qsurfS(:,iq,:)) |
|---|
| 519 | enddo |
|---|
| 520 | |
|---|
| 521 | |
|---|
| 522 | c----------------------------------------------------------------------- |
|---|
| 523 | c Ecriture du champs tsoil ( Tg[1,10] ) |
|---|
| 524 | c----------------------------------------------------------------------- |
|---|
| 525 | c "tsoil" Temperature au sol definie dans 10 couches dans le sol |
|---|
| 526 | c Les 10 couches sont lues comme 10 champs |
|---|
| 527 | c nommees Tg[1,10] |
|---|
| 528 | |
|---|
| 529 | c do isoil=1,nsoilmx |
|---|
| 530 | c write(str2,'(i2.2)') isoil |
|---|
| 531 | c call write_archive(nid,ntime,'Tg'//str2,'Ground Temperature ', |
|---|
| 532 | c . 'K',2,tsoilS(1,isoil)) |
|---|
| 533 | c enddo |
|---|
| 534 | |
|---|
| 535 | ! Write soil temperatures tsoil |
|---|
| 536 | call write_archive(nid,ntime,'tsoil','Soil temperature', |
|---|
| 537 | & 'K',-3,tsoilS(:,:,:)) |
|---|
| 538 | ! Write soil thermal inertia |
|---|
| 539 | call write_archive(nid,ntime,'inertiesoil','Soil TI', |
|---|
| 540 | & 'J.s-1/2.m-2.K-1',-3,inertiesoilS(:,:,:)) |
|---|
| 541 | ! Write soil thermal inertia for current climate |
|---|
| 542 | call write_archive(nid,ntime,'inertiedat', |
|---|
| 543 | & 'Soil thermal inertia (present day TI)', |
|---|
| 544 | & 'J.s-1/2.m-2.K-1',-3,ithS) |
|---|
| 545 | |
|---|
| 546 | ! Write (0D) volumetric heat capacity (stored in comsoil.h) |
|---|
| 547 | ! call write_archive(nid,ntime,'volcapa', |
|---|
| 548 | ! & 'Soil volumetric heat capacity', |
|---|
| 549 | ! & 'J.m-3.K-1',0,volcapa) |
|---|
| 550 | ! Note: no need to write volcapa, it is stored in "controle" table |
|---|
| 551 | |
|---|
| 552 | ierr=NF_CLOSE(nid) |
|---|
| 553 | c----------------------------------------------------------------------- |
|---|
| 554 | c Fin |
|---|
| 555 | c----------------------------------------------------------------------- |
|---|
| 556 | |
|---|
| 557 | write(*,*) "startarchive: all is well that ends well" |
|---|
| 558 | |
|---|
| 559 | end |
|---|