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