[711] | 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 | |
---|
[1415] | 21 | use infotrac, only: infotrac_init, nqtot, tname |
---|
[787] | 22 | USE comsoil_h |
---|
[1543] | 23 | |
---|
| 24 | ! USE comgeomfi_h, ONLY: lati, long, area |
---|
[1216] | 25 | ! use control_mod |
---|
[1543] | 26 | ! use comgeomphy, only: initcomgeomphy |
---|
[1297] | 27 | use slab_ice_h, only: noceanmx |
---|
| 28 | ! to use 'getin' |
---|
| 29 | USE ioipsl_getincom |
---|
[1316] | 30 | USE planete_mod, only: year_day |
---|
[1543] | 31 | USE mod_const_mpi, ONLY: COMM_LMDZ |
---|
[1415] | 32 | USE control_mod, only: planet_type |
---|
[1397] | 33 | USE callkeys_mod, ONLY: ok_slab_ocean |
---|
[1403] | 34 | use filtreg_mod, only: inifilr |
---|
[1422] | 35 | USE comvert_mod, ONLY: ap,bp |
---|
[1543] | 36 | USE comconst_mod, ONLY: daysec,dtphys,rad,g,r,cpp |
---|
[1422] | 37 | USE temps_mod, ONLY: day_ini |
---|
[1543] | 38 | USE iniphysiq_mod, ONLY: iniphysiq |
---|
[1669] | 39 | use phyetat0_mod, only: phyetat0 |
---|
[711] | 40 | implicit none |
---|
| 41 | |
---|
[1543] | 42 | include "dimensions.h" |
---|
[1308] | 43 | integer, parameter :: ngridmx = (2+(jjm-1)*iim - 1/jjm) |
---|
[1543] | 44 | include "paramet.h" |
---|
| 45 | include "comdissip.h" |
---|
| 46 | include "comgeom.h" |
---|
[1216] | 47 | !#include "control.h" |
---|
[711] | 48 | |
---|
[1308] | 49 | !#include "dimphys.h" |
---|
| 50 | !#include "planete.h" |
---|
[1216] | 51 | !#include"advtrac.h" |
---|
[1543] | 52 | include "netcdf.inc" |
---|
[711] | 53 | c----------------------------------------------------------------------- |
---|
| 54 | c Declarations |
---|
| 55 | c----------------------------------------------------------------------- |
---|
| 56 | |
---|
| 57 | c variables dynamiques du GCM |
---|
| 58 | c ----------------------------- |
---|
| 59 | REAL vcov(ip1jm,llm),ucov(ip1jmp1,llm) ! vents covariants |
---|
| 60 | REAL teta(ip1jmp1,llm) ! temperature potentielle |
---|
[1216] | 61 | REAL,ALLOCATABLE :: q(:,:,:) ! champs advectes |
---|
[711] | 62 | REAL pks(ip1jmp1) ! exner (f pour filtre) |
---|
| 63 | REAL pk(ip1jmp1,llm) |
---|
| 64 | REAL pkf(ip1jmp1,llm) |
---|
| 65 | REAL beta(iip1,jjp1,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 ------------------------------------ |
---|
[1543] | 73 | REAL tsurf(ngridmx) ! Surface temperature |
---|
| 74 | REAL,ALLOCATABLE :: tsoil(:,:) ! Soil temperature |
---|
| 75 | REAL co2ice(ngridmx) ! CO2 ice layer |
---|
[1308] | 76 | REAL q2(ngridmx,llm+1) |
---|
[1216] | 77 | REAL,ALLOCATABLE :: qsurf(:,:) |
---|
[711] | 78 | REAL emis(ngridmx) |
---|
| 79 | INTEGER start,length |
---|
| 80 | PARAMETER (length = 100) |
---|
| 81 | REAL tab_cntrl_fi(length) ! tableau des parametres de startfi |
---|
| 82 | REAL tab_cntrl_dyn(length) ! tableau des parametres de start |
---|
| 83 | INTEGER*4 day_ini_fi |
---|
| 84 | |
---|
| 85 | ! added by FF for cloud fraction setup |
---|
| 86 | REAL hice(ngridmx) |
---|
[1308] | 87 | REAL cloudfrac(ngridmx,llm),totalcloudfrac(ngridmx) |
---|
[711] | 88 | |
---|
[1297] | 89 | ! added by BC for slab ocean |
---|
| 90 | REAL rnat(ngridmx),pctsrf_sic(ngridmx),sea_ice(ngridmx) |
---|
| 91 | REAL tslab(ngridmx,noceanmx),tsea_ice(ngridmx) |
---|
[711] | 92 | |
---|
[1297] | 93 | |
---|
[711] | 94 | c Variable naturelle / grille scalaire |
---|
| 95 | c ------------------------------------ |
---|
| 96 | REAL T(ip1jmp1,llm),us(ip1jmp1,llm),vs(ip1jmp1,llm) |
---|
| 97 | REAL tsurfS(ip1jmp1) |
---|
[1543] | 98 | REAL,ALLOCATABLE :: tsoilS(:,:) |
---|
| 99 | REAL,ALLOCATABLE :: ithS(:,:) ! Soil Thermal Inertia |
---|
[711] | 100 | REAL co2iceS(ip1jmp1) |
---|
[1216] | 101 | REAL q2S(ip1jmp1,llm+1) |
---|
| 102 | REAL,ALLOCATABLE :: qsurfS(:,:) |
---|
[711] | 103 | REAL emisS(ip1jmp1) |
---|
| 104 | |
---|
| 105 | ! added by FF for cloud fraction setup |
---|
| 106 | REAL hiceS(ip1jmp1) |
---|
| 107 | REAL cloudfracS(ip1jmp1,llm),totalcloudfracS(ip1jmp1) |
---|
| 108 | |
---|
[1297] | 109 | ! added by BC for slab ocean |
---|
| 110 | REAL rnatS(ip1jmp1),pctsrf_sicS(ip1jmp1),sea_iceS(ip1jmp1) |
---|
| 111 | REAL tslabS(ip1jmp1,noceanmx),tsea_iceS(ip1jmp1) |
---|
| 112 | |
---|
| 113 | |
---|
[711] | 114 | c Variables intermediaires : vent naturel, mais pas coord scalaire |
---|
| 115 | c---------------------------------------------------------------- |
---|
| 116 | REAL vn(ip1jm,llm),un(ip1jmp1,llm) |
---|
| 117 | |
---|
| 118 | c Autres variables |
---|
| 119 | c ----------------- |
---|
| 120 | LOGICAL startdrs |
---|
| 121 | INTEGER Lmodif |
---|
| 122 | |
---|
| 123 | REAL ptotal, co2icetotal |
---|
| 124 | REAL timedyn,timefi !fraction du jour dans start, startfi |
---|
| 125 | REAL date |
---|
| 126 | |
---|
| 127 | CHARACTER*2 str2 |
---|
| 128 | CHARACTER*80 fichier |
---|
| 129 | data fichier /'startfi'/ |
---|
| 130 | |
---|
| 131 | INTEGER ij, l,i,j,isoil,iq |
---|
| 132 | character*80 fichnom |
---|
| 133 | integer :: ierr,ntime |
---|
| 134 | integer :: nq,numvanle |
---|
| 135 | character(len=30) :: txt ! to store some text |
---|
| 136 | |
---|
| 137 | c Netcdf |
---|
| 138 | c------- |
---|
| 139 | integer varid,dimid,timelen |
---|
| 140 | INTEGER nid,nid1 |
---|
| 141 | |
---|
| 142 | c----------------------------------------------------------------------- |
---|
| 143 | c Initialisations |
---|
| 144 | c----------------------------------------------------------------------- |
---|
| 145 | |
---|
[1216] | 146 | CALL defrun_new(99, .TRUE. ) |
---|
[711] | 147 | |
---|
[1415] | 148 | planet_type="generic" |
---|
| 149 | |
---|
[711] | 150 | c======================================================================= |
---|
| 151 | c Lecture des donnees |
---|
| 152 | c======================================================================= |
---|
[1216] | 153 | ! Load tracer number and names: |
---|
[1415] | 154 | call infotrac_init |
---|
[711] | 155 | |
---|
[1216] | 156 | ! allocate arrays: |
---|
| 157 | allocate(q(ip1jmp1,llm,nqtot)) |
---|
| 158 | allocate(qsurf(ngridmx,nqtot)) |
---|
| 159 | allocate(qsurfS(ip1jmp1,nqtot)) |
---|
[1227] | 160 | ! other array allocations: |
---|
[1543] | 161 | ! call ini_comsoil_h(ngridmx) ! done via iniphysiq |
---|
[1216] | 162 | |
---|
[711] | 163 | fichnom = 'start.nc' |
---|
[1415] | 164 | CALL dynetat0(fichnom,vcov,ucov,teta,q,masse, |
---|
[711] | 165 | . ps,phis,timedyn) |
---|
| 166 | |
---|
| 167 | ! load 'controle' array from dynamics start file |
---|
| 168 | |
---|
| 169 | ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1) |
---|
| 170 | IF (ierr.NE.NF_NOERR) THEN |
---|
| 171 | write(6,*)' Pb d''ouverture du fichier'//trim(fichnom) |
---|
| 172 | CALL ABORT |
---|
| 173 | ENDIF |
---|
| 174 | |
---|
| 175 | ierr = NF_INQ_VARID (nid1, "controle", varid) |
---|
| 176 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 177 | PRINT*, "start2archive: Le champ <controle> est absent" |
---|
| 178 | CALL abort |
---|
| 179 | ENDIF |
---|
| 180 | #ifdef NC_DOUBLE |
---|
| 181 | ierr = NF_GET_VAR_DOUBLE(nid1, varid, tab_cntrl_dyn) |
---|
| 182 | #else |
---|
| 183 | ierr = NF_GET_VAR_REAL(nid1, varid, tab_cntrl_dyn) |
---|
| 184 | #endif |
---|
| 185 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 186 | PRINT*, "start2archive: Lecture echoue pour <controle>" |
---|
| 187 | CALL abort |
---|
| 188 | ENDIF |
---|
| 189 | |
---|
| 190 | ierr = NF_CLOSE(nid1) |
---|
[1543] | 191 | |
---|
| 192 | ! Get value of the "subsurface_layers" dimension from physics start file |
---|
| 193 | fichnom = 'startfi.nc' |
---|
| 194 | ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1) |
---|
| 195 | IF (ierr.NE.NF_NOERR) THEN |
---|
| 196 | write(6,*)' Pb d''ouverture du fichier'//trim(fichnom) |
---|
| 197 | CALL ABORT |
---|
| 198 | ENDIF |
---|
| 199 | ierr = NF_INQ_DIMID(nid1,"subsurface_layers",varid) |
---|
| 200 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 201 | PRINT*, "start2archive: No subsurface_layers dimension!!" |
---|
| 202 | CALL abort |
---|
| 203 | ENDIF |
---|
| 204 | ierr = NF_INQ_DIMLEN(nid1,varid,nsoilmx) |
---|
| 205 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 206 | PRINT*, "start2archive: Failed reading subsurface_layers value!!" |
---|
| 207 | CALL abort |
---|
| 208 | ENDIF |
---|
| 209 | ierr = NF_CLOSE(nid1) |
---|
[711] | 210 | |
---|
[1543] | 211 | ! allocate arrays of nsoilmx size |
---|
| 212 | allocate(tsoil(ngridmx,nsoilmx)) |
---|
| 213 | allocate(tsoilS(ip1jmp1,nsoilmx)) |
---|
| 214 | allocate(ithS(ip1jmp1,nsoilmx)) |
---|
[711] | 215 | |
---|
[1543] | 216 | c----------------------------------------------------------------------- |
---|
| 217 | c Initialisations |
---|
| 218 | c----------------------------------------------------------------------- |
---|
| 219 | |
---|
| 220 | CALL defrun_new(99, .FALSE. ) |
---|
| 221 | call iniconst |
---|
| 222 | call inigeom |
---|
| 223 | call inifilr |
---|
| 224 | |
---|
| 225 | ! Initialize the physics |
---|
| 226 | CALL iniphysiq(iim,jjm,llm, |
---|
| 227 | & (jjm-1)*iim+2,comm_lmdz, |
---|
| 228 | & daysec,day_ini,dtphys, |
---|
| 229 | & rlatu,rlatv,rlonu,rlonv, |
---|
| 230 | & aire,cu,cv,rad,g,r,cpp, |
---|
| 231 | & 1) |
---|
| 232 | |
---|
[711] | 233 | fichnom = 'startfi.nc' |
---|
| 234 | Lmodif=0 |
---|
| 235 | |
---|
[1694] | 236 | ! Initialize tracer names, indexes and properties |
---|
| 237 | CALL initracer(ngridmx,nqtot,tname) |
---|
[1297] | 238 | |
---|
[1669] | 239 | CALL phyetat0(.true.,ngridmx,llm,fichnom,0,Lmodif,nsoilmx,nqtot, |
---|
[1308] | 240 | . day_ini_fi,timefi, |
---|
[711] | 241 | . tsurf,tsoil,emis,q2,qsurf, |
---|
| 242 | ! change FF 05/2011 |
---|
[1297] | 243 | . cloudfrac,totalcloudfrac,hice, |
---|
| 244 | ! change BC 05/2014 |
---|
| 245 | . rnat,pctsrf_sic,tslab,tsea_ice,sea_ice) |
---|
[711] | 246 | |
---|
| 247 | |
---|
[1297] | 248 | |
---|
| 249 | |
---|
[711] | 250 | ! load 'controle' array from physics start file |
---|
| 251 | |
---|
| 252 | ierr = NF_OPEN (fichnom, NF_NOWRITE,nid1) |
---|
| 253 | IF (ierr.NE.NF_NOERR) THEN |
---|
| 254 | write(6,*)' Pb d''ouverture du fichier'//trim(fichnom) |
---|
| 255 | CALL ABORT |
---|
| 256 | ENDIF |
---|
| 257 | |
---|
| 258 | ierr = NF_INQ_VARID (nid1, "controle", varid) |
---|
| 259 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 260 | PRINT*, "start2archive: Le champ <controle> est absent" |
---|
| 261 | CALL abort |
---|
| 262 | ENDIF |
---|
| 263 | #ifdef NC_DOUBLE |
---|
| 264 | ierr = NF_GET_VAR_DOUBLE(nid1, varid, tab_cntrl_fi) |
---|
| 265 | #else |
---|
| 266 | ierr = NF_GET_VAR_REAL(nid1, varid, tab_cntrl_fi) |
---|
| 267 | #endif |
---|
| 268 | IF (ierr .NE. NF_NOERR) THEN |
---|
| 269 | PRINT*, "start2archive: Lecture echoue pour <controle>" |
---|
| 270 | CALL abort |
---|
| 271 | ENDIF |
---|
| 272 | |
---|
| 273 | ierr = NF_CLOSE(nid1) |
---|
| 274 | |
---|
| 275 | |
---|
| 276 | c----------------------------------------------------------------------- |
---|
| 277 | c Controle de la synchro |
---|
| 278 | c----------------------------------------------------------------------- |
---|
| 279 | !mars a voir if ((day_ini_fi.ne.day_ini).or.(abs(timefi-timedyn).gt.1.e-10)) |
---|
| 280 | if ((day_ini_fi.ne.day_ini)) |
---|
| 281 | & stop ' Probleme de Synchro entre start et startfi !!!' |
---|
| 282 | |
---|
| 283 | |
---|
| 284 | c ***************************************************************** |
---|
| 285 | c Option : Reinitialisation des dates dans la premieres annees : |
---|
| 286 | do while (day_ini.ge.year_day) |
---|
| 287 | day_ini=day_ini-year_day |
---|
| 288 | enddo |
---|
| 289 | c ***************************************************************** |
---|
| 290 | |
---|
| 291 | CALL pression(ip1jmp1, ap, bp, ps, p3d) |
---|
| 292 | call exner_hyb(ip1jmp1, ps, p3d, beta, pks, pk, pkf) |
---|
| 293 | |
---|
| 294 | c======================================================================= |
---|
| 295 | c Transformation EN VARIABLE NATURELLE / GRILLE SCALAIRE si necessaire |
---|
| 296 | c======================================================================= |
---|
| 297 | c Les variables modeles dependent de la resolution. Il faut donc |
---|
| 298 | c eliminer les facteurs responsables de cette dependance |
---|
| 299 | c (pour utiliser newstart) |
---|
| 300 | c======================================================================= |
---|
| 301 | |
---|
| 302 | c----------------------------------------------------------------------- |
---|
| 303 | c Vent (depend de la resolution horizontale) |
---|
| 304 | c----------------------------------------------------------------------- |
---|
| 305 | c |
---|
| 306 | c ucov --> un et vcov --> vn |
---|
| 307 | c un --> us et vn --> vs |
---|
| 308 | c |
---|
| 309 | c----------------------------------------------------------------------- |
---|
| 310 | |
---|
| 311 | call covnat(llm,ucov, vcov, un, vn) |
---|
| 312 | call wind_scal(un,vn,us,vs) |
---|
| 313 | |
---|
| 314 | c----------------------------------------------------------------------- |
---|
| 315 | c Temperature (depend de la resolution verticale => de "sigma.def") |
---|
| 316 | c----------------------------------------------------------------------- |
---|
| 317 | c |
---|
| 318 | c h --> T |
---|
| 319 | c |
---|
| 320 | c----------------------------------------------------------------------- |
---|
| 321 | |
---|
| 322 | DO l=1,llm |
---|
| 323 | DO ij=1,ip1jmp1 |
---|
| 324 | T(ij,l)=teta(ij,l)*pk(ij,l)/cpp !mars deduit de l'equation dans newstart |
---|
| 325 | ENDDO |
---|
| 326 | ENDDO |
---|
| 327 | |
---|
| 328 | c----------------------------------------------------------------------- |
---|
| 329 | c Variable physique |
---|
| 330 | c----------------------------------------------------------------------- |
---|
| 331 | c |
---|
| 332 | c tsurf --> tsurfS |
---|
| 333 | c co2ice --> co2iceS |
---|
| 334 | c tsoil --> tsoilS |
---|
| 335 | c emis --> emisS |
---|
| 336 | c q2 --> q2S |
---|
| 337 | c qsurf --> qsurfS |
---|
| 338 | c |
---|
| 339 | c----------------------------------------------------------------------- |
---|
| 340 | |
---|
| 341 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsurf,tsurfS) |
---|
| 342 | ! call gr_fi_dyn(1,ngridmx,iip1,jjp1,co2ice,co2iceS) |
---|
| 343 | call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,tsoil,tsoilS) |
---|
| 344 | ! Note: thermal inertia "inertiedat" is in comsoil.h |
---|
| 345 | call gr_fi_dyn(nsoilmx,ngridmx,iip1,jjp1,inertiedat,ithS) |
---|
| 346 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,emis,emisS) |
---|
| 347 | call gr_fi_dyn(llm+1,ngridmx,iip1,jjp1,q2,q2S) |
---|
[1216] | 348 | call gr_fi_dyn(nqtot,ngridmx,iip1,jjp1,qsurf,qsurfS) |
---|
[711] | 349 | call gr_fi_dyn(llm,ngridmx,iip1,jjp1,cloudfrac,cloudfracS) |
---|
| 350 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,hice,hiceS) |
---|
| 351 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,totalcloudfrac,totalcloudfracS) |
---|
| 352 | |
---|
[1297] | 353 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,rnat,rnatS) |
---|
| 354 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,pctsrf_sic,pctsrf_sicS) |
---|
| 355 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,tsea_ice,tsea_iceS) |
---|
| 356 | call gr_fi_dyn(1,ngridmx,iip1,jjp1,sea_ice,sea_iceS) |
---|
| 357 | call gr_fi_dyn(noceanmx,ngridmx,iip1,jjp1,tslab,tslabS) |
---|
| 358 | |
---|
[711] | 359 | c======================================================================= |
---|
| 360 | c Info pour controler |
---|
| 361 | c======================================================================= |
---|
| 362 | |
---|
| 363 | ptotal = 0. |
---|
| 364 | co2icetotal = 0. |
---|
| 365 | DO j=1,jjp1 |
---|
| 366 | DO i=1,iim |
---|
| 367 | ptotal=ptotal+aire(i+(iim+1)*(j-1))*ps(i+(iim+1)*(j-1))/g |
---|
| 368 | ! co2icetotal = co2icetotal + |
---|
| 369 | ! & co2iceS(i+(iim+1)*(j-1))*aire(i+(iim+1)*(j-1)) |
---|
| 370 | ENDDO |
---|
| 371 | ENDDO |
---|
| 372 | write(*,*)'Ancienne grille : masse de l''atm :',ptotal |
---|
| 373 | ! write(*,*)'Ancienne grille : masse de la glace CO2 :',co2icetotal |
---|
| 374 | |
---|
| 375 | c----------------------------------------------------------------------- |
---|
| 376 | c Passage de "ptotal" et "co2icetotal" par tab_cntrl_fi |
---|
| 377 | c----------------------------------------------------------------------- |
---|
| 378 | |
---|
| 379 | tab_cntrl_fi(49) = ptotal |
---|
| 380 | tab_cntrl_fi(50) = co2icetotal |
---|
| 381 | |
---|
| 382 | c======================================================================= |
---|
| 383 | c Ecriture dans le fichier "start_archive" |
---|
| 384 | c======================================================================= |
---|
| 385 | |
---|
| 386 | c----------------------------------------------------------------------- |
---|
| 387 | c Ouverture de "start_archive" |
---|
| 388 | c----------------------------------------------------------------------- |
---|
| 389 | |
---|
| 390 | ierr = NF_OPEN ('start_archive.nc', NF_WRITE,nid) |
---|
| 391 | |
---|
| 392 | c----------------------------------------------------------------------- |
---|
| 393 | c si "start_archive" n'existe pas: |
---|
| 394 | c 1_ ouverture |
---|
| 395 | c 2_ creation de l'entete dynamique ("ini_archive") |
---|
| 396 | c----------------------------------------------------------------------- |
---|
| 397 | c ini_archive: |
---|
| 398 | c On met dans l'entete le tab_cntrl dynamique (1 a 16) |
---|
| 399 | c On y ajoute les valeurs du tab_cntrl_fi (a partir de 51) |
---|
| 400 | c En plus les deux valeurs ptotal et co2icetotal (99 et 100) |
---|
| 401 | c----------------------------------------------------------------------- |
---|
| 402 | |
---|
| 403 | if (ierr.ne.NF_NOERR) then |
---|
| 404 | write(*,*)'OK, Could not open file "start_archive.nc"' |
---|
| 405 | write(*,*)'So let s create a new "start_archive"' |
---|
| 406 | ierr = NF_CREATE('start_archive.nc', NF_CLOBBER, nid) |
---|
| 407 | call ini_archive(nid,day_ini,phis,ithS,tab_cntrl_fi, |
---|
| 408 | & tab_cntrl_dyn) |
---|
| 409 | endif |
---|
| 410 | |
---|
| 411 | c----------------------------------------------------------------------- |
---|
| 412 | c Ecriture de la coordonnee temps (date en jours) |
---|
| 413 | c----------------------------------------------------------------------- |
---|
| 414 | |
---|
| 415 | date = day_ini |
---|
| 416 | ierr= NF_INQ_VARID(nid,"Time",varid) |
---|
| 417 | ierr= NF_INQ_DIMID(nid,"Time",dimid) |
---|
| 418 | ierr= NF_INQ_DIMLEN(nid,dimid,timelen) |
---|
| 419 | ntime=timelen+1 |
---|
| 420 | |
---|
| 421 | write(*,*) "******************" |
---|
| 422 | write(*,*) "ntime",ntime |
---|
| 423 | write(*,*) "******************" |
---|
| 424 | #ifdef NC_DOUBLE |
---|
| 425 | ierr= NF_PUT_VARA_DOUBLE(nid,varid,ntime,1,date) |
---|
| 426 | #else |
---|
| 427 | ierr= NF_PUT_VARA_REAL(nid,varid,ntime,1,date) |
---|
| 428 | #endif |
---|
| 429 | if (ierr.ne.NF_NOERR) then |
---|
| 430 | write(*,*) "time matter ",NF_STRERROR(ierr) |
---|
| 431 | stop |
---|
| 432 | endif |
---|
| 433 | |
---|
| 434 | c----------------------------------------------------------------------- |
---|
| 435 | c Ecriture des champs (co2ice,emis,ps,Tsurf,T,u,v,q2,q,qsurf) |
---|
| 436 | c----------------------------------------------------------------------- |
---|
| 437 | c ATTENTION: q2 a une couche de plus!!!! |
---|
| 438 | c Pour creer un fichier netcdf lisible par grads, |
---|
| 439 | c On passe donc une des couches de q2 a part |
---|
| 440 | c comme une variable 2D (la couche au sol: "q2surf") |
---|
| 441 | c Les lmm autres couches sont nommees "q2atm" (3D) |
---|
| 442 | c----------------------------------------------------------------------- |
---|
| 443 | |
---|
| 444 | ! call write_archive(nid,ntime,'co2ice','couche de glace co2', |
---|
| 445 | ! & 'kg/m2',2,co2iceS) |
---|
| 446 | call write_archive(nid,ntime,'emis','grd emis',' ',2,emisS) |
---|
| 447 | call write_archive(nid,ntime,'ps','Psurf','Pa',2,ps) |
---|
| 448 | call write_archive(nid,ntime,'tsurf','surf T','K',2,tsurfS) |
---|
| 449 | call write_archive(nid,ntime,'temp','temperature','K',3,t) |
---|
| 450 | call write_archive(nid,ntime,'u','Vent zonal','m.s-1',3,us) |
---|
| 451 | call write_archive(nid,ntime,'v','Vent merid','m.s-1',3,vs) |
---|
| 452 | call write_archive(nid,ntime,'q2surf','wind variance','m2.s-2',2, |
---|
| 453 | . q2S) |
---|
| 454 | call write_archive(nid,ntime,'q2atm','wind variance','m2.s-2',3, |
---|
| 455 | . q2S(1,2)) |
---|
| 456 | |
---|
| 457 | c----------------------------------------------------------------------- |
---|
[1216] | 458 | c Ecriture du champs q ( q[1,nqtot] ) |
---|
[711] | 459 | c----------------------------------------------------------------------- |
---|
[1216] | 460 | do iq=1,nqtot |
---|
| 461 | call write_archive(nid,ntime,tname(iq),'tracer','kg/kg', |
---|
[711] | 462 | & 3,q(1,1,iq)) |
---|
| 463 | end do |
---|
| 464 | c----------------------------------------------------------------------- |
---|
[1216] | 465 | c Ecriture du champs qsurf ( qsurf[1,nqtot] ) |
---|
[711] | 466 | c----------------------------------------------------------------------- |
---|
[1216] | 467 | do iq=1,nqtot |
---|
| 468 | txt=trim(tname(iq))//"_surf" |
---|
[711] | 469 | call write_archive(nid,ntime,txt,'Tracer on surface', |
---|
| 470 | & 'kg.m-2',2,qsurfS(1,iq)) |
---|
| 471 | enddo |
---|
| 472 | |
---|
| 473 | |
---|
| 474 | c----------------------------------------------------------------------- |
---|
| 475 | c Ecriture du champs tsoil ( Tg[1,10] ) |
---|
| 476 | c----------------------------------------------------------------------- |
---|
| 477 | c "tsoil" Temperature au sol definie dans 10 couches dans le sol |
---|
| 478 | c Les 10 couches sont lues comme 10 champs |
---|
| 479 | c nommees Tg[1,10] |
---|
| 480 | |
---|
| 481 | c do isoil=1,nsoilmx |
---|
| 482 | c write(str2,'(i2.2)') isoil |
---|
| 483 | c call write_archive(nid,ntime,'Tg'//str2,'Ground Temperature ', |
---|
| 484 | c . 'K',2,tsoilS(1,isoil)) |
---|
| 485 | c enddo |
---|
| 486 | |
---|
| 487 | ! Write soil temperatures tsoil |
---|
| 488 | call write_archive(nid,ntime,'tsoil','Soil temperature', |
---|
| 489 | & 'K',-3,tsoilS) |
---|
| 490 | |
---|
| 491 | ! Write soil thermal inertia |
---|
| 492 | call write_archive(nid,ntime,'inertiedat', |
---|
| 493 | & 'Soil thermal inertia', |
---|
| 494 | & 'J.s-1/2.m-2.K-1',-3,ithS) |
---|
| 495 | |
---|
| 496 | ! Write (0D) volumetric heat capacity (stored in comsoil.h) |
---|
| 497 | ! call write_archive(nid,ntime,'volcapa', |
---|
| 498 | ! & 'Soil volumetric heat capacity', |
---|
| 499 | ! & 'J.m-3.K-1',0,volcapa) |
---|
| 500 | ! Note: no need to write volcapa, it is stored in "controle" table |
---|
| 501 | |
---|
| 502 | c----------------------------------------------------------------------- |
---|
| 503 | c Ecriture du champs cloudfrac,hice,totalcloudfrac |
---|
| 504 | c----------------------------------------------------------------------- |
---|
| 505 | call write_archive(nid,ntime,'hice', |
---|
| 506 | & 'Height of oceanic ice','m',2,hiceS) |
---|
| 507 | call write_archive(nid,ntime,'totalcloudfrac', |
---|
| 508 | & 'Total cloud Fraction','',2,totalcloudfracS) |
---|
| 509 | call write_archive(nid,ntime,'cloudfrac' |
---|
| 510 | & ,'Cloud fraction','',3,cloudfracS) |
---|
[1297] | 511 | |
---|
[711] | 512 | c----------------------------------------------------------------------- |
---|
[1297] | 513 | c Slab ocean |
---|
| 514 | c----------------------------------------------------------------------- |
---|
| 515 | OPEN(99,file='callphys.def',status='old',form='formatted' |
---|
| 516 | & ,iostat=ierr) |
---|
| 517 | CLOSE(99) |
---|
| 518 | |
---|
| 519 | IF(ierr.EQ.0) THEN |
---|
| 520 | |
---|
| 521 | |
---|
| 522 | write(*,*) "Use slab-ocean ?" |
---|
| 523 | ok_slab_ocean=.false. ! default value |
---|
| 524 | call getin("ok_slab_ocean",ok_slab_ocean) |
---|
| 525 | write(*,*) "ok_slab_ocean = ",ok_slab_ocean |
---|
| 526 | |
---|
| 527 | if(ok_slab_ocean) then |
---|
| 528 | call write_archive(nid,ntime,'rnat' |
---|
| 529 | & ,'rnat','',2,rnatS) |
---|
| 530 | call write_archive(nid,ntime,'pctsrf_sic' |
---|
| 531 | & ,'pctsrf_sic','',2,pctsrf_sicS) |
---|
| 532 | call write_archive(nid,ntime,'sea_ice' |
---|
| 533 | & ,'sea_ice','',2,sea_iceS) |
---|
| 534 | call write_archive(nid,ntime,'tslab' |
---|
[1478] | 535 | & ,'tslab','',-2,tslabS) |
---|
[1297] | 536 | call write_archive(nid,ntime,'tsea_ice' |
---|
| 537 | & ,'tsea_ice','',2,tsea_iceS) |
---|
| 538 | endif !ok_slab_ocean |
---|
| 539 | ENDIF |
---|
| 540 | c----------------------------------------------------------------------- |
---|
[711] | 541 | c Fin |
---|
| 542 | c----------------------------------------------------------------------- |
---|
| 543 | ierr=NF_CLOSE(nid) |
---|
| 544 | |
---|
[1216] | 545 | write(*,*) "start2archive: All is well that ends well." |
---|
| 546 | |
---|
[711] | 547 | end |
---|