Changeset 3506


Ignore:
Timestamp:
May 16, 2019, 4:38:11 PM (6 years ago)
Author:
yann meurdesoif
Message:

Solve 2 problems when writing restartphy files at high resolution :

  • large memory consumption that can lead to crash with an oom kill
  • very very long tile due to usage of NF_ENDDEF/NF_REDEF for each saved field. Now the first pass will create the nectdf header and the second pass will write the fields.

YM

Location:
LMDZ6/trunk/libf/phylmd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • LMDZ6/trunk/libf/phylmd/iostart.F90

    r3465 r3506  
    2525
    2626    PUBLIC get_field,get_var,put_field,put_var
    27     PUBLIC Open_startphy,close_startphy,open_restartphy,close_restartphy
     27    PUBLIC Open_startphy,close_startphy,open_restartphy,close_restartphy, enddef_restartphy
    2828   
    2929CONTAINS
     
    326326      ierr = NF90_DEF_DIM (nid_restart, "horizon_klevp1", klon_glo*klevp1, idim4)
    327327
    328       ierr = NF90_ENDDEF(nid_restart)
     328!      ierr = NF90_ENDDEF(nid_restart)
    329329    ENDIF
    330330
    331331  END SUBROUTINE open_restartphy
    332332 
     333  SUBROUTINE enddef_restartphy
     334  USE netcdf
     335  USE mod_phys_lmdz_para
     336  IMPLICIT NONE
     337    INTEGER          :: ierr
     338
     339    IF (is_master) ierr = NF90_ENDDEF(nid_restart)
     340 
     341  END SUBROUTINE enddef_restartphy
     342
    333343  SUBROUTINE close_restartphy
    334344  USE netcdf
     
    337347    INTEGER          :: ierr
    338348
    339     IF (is_mpi_root .AND. is_omp_root) THEN
    340       ierr = NF90_CLOSE (nid_restart)
    341     ENDIF
     349    IF (is_master) ierr = NF90_CLOSE (nid_restart)
    342350 
    343351  END SUBROUTINE close_restartphy
    344352
    345353 
    346   SUBROUTINE put_field_r1(field_name,title,field)
    347   IMPLICIT NONE
     354  SUBROUTINE put_field_r1(pass, field_name,title,field)
     355  IMPLICIT NONE
     356  INTEGER, INTENT(IN)            :: pass
    348357  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    349358  CHARACTER(LEN=*),INTENT(IN)    :: title
    350359  REAL,INTENT(IN)                :: field(:)
    351  
    352     CALL put_field_rgen(field_name,title,field,1)
     360    CALL put_field_rgen(pass, field_name,title,field,1)
    353361 
    354362  END SUBROUTINE put_field_r1
    355363
    356   SUBROUTINE put_field_r2(field_name,title,field)
    357   IMPLICIT NONE
     364  SUBROUTINE put_field_r2(pass, field_name,title,field)
     365  IMPLICIT NONE
     366  INTEGER, INTENT(IN)            :: pass
    358367  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    359368  CHARACTER(LEN=*),INTENT(IN)    :: title
    360369  REAL,INTENT(IN)                :: field(:,:)
    361370 
    362     CALL put_field_rgen(field_name,title,field,size(field,2))
     371    CALL put_field_rgen(pass, field_name,title,field,size(field,2))
    363372 
    364373  END SUBROUTINE put_field_r2
    365374
    366   SUBROUTINE put_field_r3(field_name,title,field)
    367   IMPLICIT NONE
     375  SUBROUTINE put_field_r3(pass, field_name,title,field)
     376  IMPLICIT NONE
     377  INTEGER, INTENT(IN)            :: pass
    368378  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    369379  CHARACTER(LEN=*),INTENT(IN)    :: title
    370380  REAL,INTENT(IN)                :: field(:,:,:)
    371381 
    372     CALL put_field_rgen(field_name,title,field,size(field,2)*size(field,3))
     382    CALL put_field_rgen(pass, field_name,title,field,size(field,2)*size(field,3))
    373383 
    374384  END SUBROUTINE put_field_r3
    375385 
    376   SUBROUTINE put_field_rgen(field_name,title,field,field_size)
     386  SUBROUTINE put_field_rgen(pass, field_name,title,field,field_size)
    377387  USE netcdf
    378388  USE dimphy
     
    381391  USE mod_phys_lmdz_para
    382392  IMPLICIT NONE
     393  INTEGER, INTENT(IN)            :: pass
    383394  CHARACTER(LEN=*),INTENT(IN)    :: field_name
    384395  CHARACTER(LEN=*),INTENT(IN)    :: title
     
    386397  REAL,INTENT(IN)                :: field(klon,field_size)
    387398 
    388   REAL                           :: field_glo(klon_glo,field_size)
    389   REAL                           :: field_glo_tmp(klon_glo,field_size)
    390 !  INTEGER,ALLOCATABLE            :: ind_cell_glo_glo(:)
    391   INTEGER                        :: ind_cell_glo_glo(klon_glo)
     399!  REAL                           :: field_glo(klon_glo,field_size)
     400!  REAL                           :: field_glo_tmp(klon_glo,field_size)
     401  REAL ,ALLOCATABLE              :: field_glo(:,:)
     402  REAL ,ALLOCATABLE              :: field_glo_tmp(:,:)
     403  INTEGER,ALLOCATABLE            :: ind_cell_glo_glo(:)
     404!  INTEGER                        :: ind_cell_glo_glo(klon_glo)
    392405  INTEGER                        :: ierr,i
    393406  INTEGER                        :: nvarid
    394407  INTEGER                        :: idim
    395408   
    396    
    397 !    IF (is_master) ALLOCATE(ind_cell_glo_glo(klon_glo))
    398     CALL gather(ind_cell_glo,ind_cell_glo_glo)
    399 
    400     CALL gather(field,field_glo_tmp)
     409! first pass : definition   
     410  IF (pass==1) THEN
    401411   
    402412    IF (is_master) THEN
    403 
    404       DO i=1,klon_glo
    405        field_glo(ind_cell_glo_glo(i),:)=field_glo_tmp(i,:)
    406       ENDDO
    407 
    408413
    409414      IF (field_size==1) THEN
     
    418423      ENDIF
    419424         
    420       ierr = NF90_REDEF (nid_restart)
     425!      ierr = NF90_REDEF (nid_restart)
    421426#ifdef NC_DOUBLE
    422427      ierr = NF90_DEF_VAR (nid_restart, field_name, NF90_DOUBLE,(/ idim /),nvarid)
     
    425430#endif
    426431      IF (LEN_TRIM(title) > 0) ierr = NF90_PUT_ATT (nid_restart,nvarid,"title", title)
    427       ierr = NF90_ENDDEF(nid_restart)
    428       ierr = NF90_PUT_VAR(nid_restart,nvarid,RESHAPE(field_glo,(/klon_glo*field_size/)))
    429     ENDIF
    430    
    431    END SUBROUTINE put_field_rgen 
    432  
    433    SUBROUTINE put_var_r0(var_name,title,var)
     432!      ierr = NF90_ENDDEF(nid_restart)
     433     ENDIF
     434
     435! second pass : write     
     436   ELSE IF (pass==2) THEN
     437   
     438     IF (is_master) THEN
     439       ALLOCATE(ind_cell_glo_glo(klon_glo))
     440       ALLOCATE(field_glo(klon_glo,field_size))
     441       ALLOCATE(field_glo_tmp(klon_glo,field_size))
     442     ELSE
     443       ALLOCATE(ind_cell_glo_glo(0))
     444       ALLOCATE(field_glo(0,0))
     445     ENDIF
     446     
     447     CALL gather(ind_cell_glo,ind_cell_glo_glo)
     448
     449     CALL gather(field,field_glo_tmp)
     450   
     451     IF (is_master) THEN
     452
     453       DO i=1,klon_glo
     454         field_glo(ind_cell_glo_glo(i),:)=field_glo_tmp(i,:)
     455       ENDDO
     456
     457       ierr = NF90_INQ_VARID(nid_restart, field_name, nvarid)
     458       ierr = NF90_PUT_VAR(nid_restart,nvarid,RESHAPE(field_glo,(/klon_glo*field_size/)))
     459      ENDIF
     460   ENDIF
     461   
     462 END SUBROUTINE put_field_rgen 
     463 
     464
     465 SUBROUTINE put_var_r0(pass, var_name,title,var)
    434466   IMPLICIT NONE
     467     INTEGER, INTENT(IN)            :: pass
    435468     CHARACTER(LEN=*),INTENT(IN) :: var_name
    436469     CHARACTER(LEN=*),INTENT(IN) :: title
     
    440473     varin(1)=var
    441474     
    442      CALL put_var_rgen(var_name,title,varin,size(varin))
     475     CALL put_var_rgen(pass, var_name,title,varin,size(varin))
    443476
    444477  END SUBROUTINE put_var_r0
    445478
    446479
    447    SUBROUTINE put_var_r1(var_name,title,var)
     480   SUBROUTINE put_var_r1(pass, var_name,title,var)
    448481   IMPLICIT NONE
     482     INTEGER, INTENT(IN)            :: pass
    449483     CHARACTER(LEN=*),INTENT(IN) :: var_name
    450484     CHARACTER(LEN=*),INTENT(IN) :: title
    451485     REAL,INTENT(IN)             :: var(:)
    452486     
    453      CALL put_var_rgen(var_name,title,var,size(var))
     487     CALL put_var_rgen(pass, var_name,title,var,size(var))
    454488
    455489  END SUBROUTINE put_var_r1
    456490 
    457   SUBROUTINE put_var_r2(var_name,title,var)
     491  SUBROUTINE put_var_r2(pass, var_name,title,var)
    458492   IMPLICIT NONE
     493     INTEGER, INTENT(IN)            :: pass
    459494     CHARACTER(LEN=*),INTENT(IN) :: var_name
    460495     CHARACTER(LEN=*),INTENT(IN) :: title
    461496     REAL,INTENT(IN)             :: var(:,:)
    462497     
    463      CALL put_var_rgen(var_name,title,var,size(var))
     498     CALL put_var_rgen(pass, var_name,title,var,size(var))
    464499
    465500  END SUBROUTINE put_var_r2     
    466501 
    467   SUBROUTINE put_var_r3(var_name,title,var)
     502  SUBROUTINE put_var_r3(pass, var_name,title,var)
    468503   IMPLICIT NONE
     504     INTEGER, INTENT(IN)            :: pass
    469505     CHARACTER(LEN=*),INTENT(IN) :: var_name
    470506     CHARACTER(LEN=*),INTENT(IN) :: title
    471507     REAL,INTENT(IN)             :: var(:,:,:)
    472508     
    473      CALL put_var_rgen(var_name,title,var,size(var))
     509     CALL put_var_rgen(pass, var_name,title,var,size(var))
    474510
    475511  END SUBROUTINE put_var_r3
    476512
    477   SUBROUTINE put_var_rgen(var_name,title,var,var_size)
     513  SUBROUTINE put_var_rgen(pass, var_name,title,var,var_size)
    478514  USE netcdf
    479515  USE dimphy
    480516  USE mod_phys_lmdz_para
    481517  IMPLICIT NONE
    482      CHARACTER(LEN=*),INTENT(IN) :: var_name
    483      CHARACTER(LEN=*),INTENT(IN) :: title
    484      INTEGER,INTENT(IN)          :: var_size
    485      REAL,INTENT(IN)             :: var(var_size)
    486      
    487      INTEGER :: ierr
    488      INTEGER :: nvarid
     518    INTEGER, INTENT(IN)         :: pass
     519    CHARACTER(LEN=*),INTENT(IN) :: var_name
     520    CHARACTER(LEN=*),INTENT(IN) :: title
     521    INTEGER,INTENT(IN)          :: var_size
     522    REAL,INTENT(IN)             :: var(var_size)
     523   
     524    INTEGER :: ierr
     525    INTEGER :: nvarid
    489526         
    490     IF (is_mpi_root .AND. is_omp_root) THEN
     527    IF (is_master) THEN
    491528
    492529      IF (var_size/=length) THEN
     
    494531        call abort_physic("", "", 1)
    495532      ENDIF
    496      
    497       ierr = NF90_REDEF (nid_restart)
     533
     534     ! first pass : definition   
     535      IF (pass==1) THEN
     536       
     537!      ierr = NF90_REDEF (nid_restart)
    498538
    499539#ifdef NC_DOUBLE
    500       ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_DOUBLE,(/ idim1 /),nvarid)
     540        ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_DOUBLE,(/ idim1 /),nvarid)
    501541#else
    502       ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_FLOAT,(/ idim1 /),nvarid)
     542        ierr = NF90_DEF_VAR (nid_restart, var_name, NF90_FLOAT,(/ idim1 /),nvarid)
    503543#endif
    504       IF (LEN_TRIM(title)>0) ierr = NF90_PUT_ATT (nid_restart,nvarid,"title", title)
    505       ierr = NF90_ENDDEF(nid_restart)
    506      
    507       ierr = NF90_PUT_VAR(nid_restart,nvarid,var)
    508 
     544        IF (LEN_TRIM(title)>0) ierr = NF90_PUT_ATT (nid_restart,nvarid,"title", title)
     545!      ierr = NF90_ENDDEF(nid_restart)
     546
     547    ! second pass : write     
     548      ELSE IF (pass==2) THEN
     549        ierr = NF90_INQ_VARID(nid_restart, var_name, nvarid)
     550        ierr = NF90_PUT_VAR(nid_restart,nvarid,var)
     551      ENDIF
    509552    ENDIF
    510553   
  • LMDZ6/trunk/libf/phylmd/phyredem.F90

    r3317 r3506  
    2929                                treedrg
    3030  USE geometry_mod, ONLY : longitude_deg, latitude_deg
    31   USE iostart, ONLY: open_restartphy, close_restartphy, put_field, put_var
     31  USE iostart, ONLY: open_restartphy, close_restartphy, enddef_restartphy, put_field, put_var
    3232  USE traclmdz_mod, ONLY : traclmdz_to_restart
    3333  USE infotrac_phy, ONLY: type_trac, niadv, tname, nbtr, nqo
     
    6565  CHARACTER (len=2) :: str2
    6666  CHARACTER (len=256) :: nam, lnam
    67   INTEGER           :: it, iiq
     67  INTEGER           :: it, iiq, pass
    6868
    6969  !======================================================================
     
    8080  CALL open_restartphy(fichnom)
    8181
     82 
    8283  DO ierr = 1, length
    8384     tab_cntrl(ierr) = 0.0
     
    104105  tab_cntrl(16) = co2_ppm0
    105106
    106   CALL put_var("controle", "Parametres de controle", tab_cntrl)
    107 
    108   CALL put_field("longitude", &
    109        "Longitudes de la grille physique", longitude_deg)
    110 
    111   CALL put_field("latitude", "Latitudes de la grille physique", latitude_deg)
    112 
    113   ! PB ajout du masque terre/mer
    114 
    115   CALL put_field("masque", "masque terre mer", zmasq)
    116 
    117   ! BP ajout des fraction de chaque sous-surface
    118 
    119   ! Get last fractions from slab ocean
    120   IF (type_ocean == 'slab' .AND. version_ocean == "sicINT") THEN
    121       WHERE (1.-zmasq(:).GT.EPSFRA)
    122           pctsrf(:,is_oce)=(1.-fsic(:))*(1.-zmasq(:))
    123           pctsrf(:,is_sic)=fsic(:)*(1.-zmasq(:))
    124       END WHERE
    125   END IF
    126 
    127   ! 1. fraction de terre
    128 
    129   CALL put_field("FTER", "fraction de continent", pctsrf(:, is_ter))
    130 
    131   ! 2. Fraction de glace de terre
    132 
    133   CALL put_field("FLIC", "fraction glace de terre", pctsrf(:, is_lic))
    134 
    135   ! 3. fraction ocean
    136 
    137   CALL put_field("FOCE", "fraction ocean", pctsrf(:, is_oce))
    138 
    139   ! 4. Fraction glace de mer
    140 
    141   CALL put_field("FSIC", "fraction glace mer", pctsrf(:, is_sic))
    142 
    143   IF(nbsrf>99) THEN
    144     PRINT*, "Trop de sous-mailles";  CALL abort_physic("phyredem", "", 1)
    145   END IF
    146   IF(nsoilmx>99) THEN
    147     PRINT*, "Trop de sous-surfaces"; CALL abort_physic("phyredem", "", 1)
    148   END IF
    149   IF(nsw>99) THEN
    150     PRINT*, "Trop de bandes"; CALL abort_physic("phyredem", "", 1)
    151   END IF
    152 
    153   CALL put_field_srf1("TS","Temperature",ftsol(:,:))
     107  DO pass=1,2   ! pass=1 netcdf definition ; pass=2 netcdf write
     108 
     109    CALL put_var(pass, "controle", "Parametres de controle", tab_cntrl)
     110
     111    CALL put_field(pass,"longitude", &
     112         "Longitudes de la grille physique", longitude_deg)
     113
     114    CALL put_field(pass,"latitude", "Latitudes de la grille physique", latitude_deg)
     115
     116    ! PB ajout du masque terre/mer
     117
     118    CALL put_field(pass,"masque", "masque terre mer", zmasq)
     119
     120    ! BP ajout des fraction de chaque sous-surface
     121
     122    ! Get last fractions from slab ocean
     123    IF (type_ocean == 'slab' .AND. version_ocean == "sicINT") THEN
     124        WHERE (1.-zmasq(:).GT.EPSFRA)
     125            pctsrf(:,is_oce)=(1.-fsic(:))*(1.-zmasq(:))
     126            pctsrf(:,is_sic)=fsic(:)*(1.-zmasq(:))
     127        END WHERE
     128    END IF
     129
     130    ! 1. fraction de terre
     131
     132    CALL put_field(pass,"FTER", "fraction de continent", pctsrf(:, is_ter))
     133
     134    ! 2. Fraction de glace de terre
     135
     136    CALL put_field(pass,"FLIC", "fraction glace de terre", pctsrf(:, is_lic))
     137
     138    ! 3. fraction ocean
     139
     140    CALL put_field(pass,"FOCE", "fraction ocean", pctsrf(:, is_oce))
     141
     142    ! 4. Fraction glace de mer
     143
     144    CALL put_field(pass,"FSIC", "fraction glace mer", pctsrf(:, is_sic))
     145
     146    IF(nbsrf>99) THEN
     147      PRINT*, "Trop de sous-mailles";  CALL abort_physic("phyredem", "", 1)
     148    END IF
     149    IF(nsoilmx>99) THEN
     150      PRINT*, "Trop de sous-surfaces"; CALL abort_physic("phyredem", "", 1)
     151    END IF
     152    IF(nsw>99) THEN
     153      PRINT*, "Trop de bandes"; CALL abort_physic("phyredem", "", 1)
     154    END IF
     155
     156    CALL put_field_srf1(pass,"TS","Temperature",ftsol(:,:))
    154157
    155158! ================== Albedo =======================================
    156   print*,'PHYREDEM NOUVEAU'
    157   CALL put_field_srf2("A_dir_SW","Albedo direct",falb_dir(:,:,:))
    158   CALL put_field_srf2("A_dif_SW","Albedo diffus",falb_dif(:,:,:))
    159 
    160   CALL put_field_srf1("U10M", "u a 10m", u10m)
    161 
    162   CALL put_field_srf1("V10M", "v a 10m", v10m)
     159    print*,'PHYREDEM NOUVEAU'
     160    CALL put_field_srf2(pass,"A_dir_SW","Albedo direct",falb_dir(:,:,:))
     161    CALL put_field_srf2(pass,"A_dif_SW","Albedo diffus",falb_dif(:,:,:))
     162
     163    CALL put_field_srf1(pass,"U10M", "u a 10m", u10m)
     164
     165    CALL put_field_srf1(pass,"V10M", "v a 10m", v10m)
    163166
    164167
    165168! ================== Tsoil =========================================
    166   CALL put_field_srf2("Tsoil","Temperature",tsoil(:,:,:))
     169    CALL put_field_srf2(pass,"Tsoil","Temperature",tsoil(:,:,:))
    167170!FC
    168171!  CALL put_field_srf2("treedrg","freinage arbres",treedrg(:,:,:))
    169   CALL put_field("treedrg_ter","freinage arbres",treedrg(:,:,is_ter))
    170 
    171 
    172   CALL put_field_srf1("QS"  , "Humidite",qsurf(:,:))
    173 
    174   CALL put_field     ("QSOL", "Eau dans le sol (mm)", qsol)
    175 
    176   CALL put_field_srf1("EVAP", "Evaporation", fevap(:,:))
    177 
    178   CALL put_field_srf1("SNOW", "Neige", snow(:,:))
    179 
    180   CALL put_field("RADS", "Rayonnement net a la surface", radsol)
    181 
    182   CALL put_field("solsw", "Rayonnement solaire a la surface", solsw)
    183 
    184   CALL put_field("sollw", "Rayonnement IF a la surface", sollw)
    185 
    186   CALL put_field("sollwdown", "Rayonnement down IF a la surface", sollwdown)
    187 
    188   CALL put_field("fder", "Derive de flux", fder)
    189 
    190   CALL put_field("rain_f", "precipitation liquide", rain_fall)
    191 
    192   CALL put_field("snow_f", "precipitation solide", snow_fall)
    193 
    194   CALL put_field_srf1("Z0m", "rugosite", z0m(:,:))
    195 
    196   CALL put_field_srf1("Z0h", "rugosite", z0h(:,:))
    197 
    198   CALL put_field_srf1("AGESNO", "Age de la neige", agesno(:,:))
    199 
    200   CALL put_field("ZMEA", "ZMEA", zmea)
    201 
    202   CALL put_field("ZSTD", "ZSTD", zstd)
    203 
    204   CALL put_field("ZSIG", "ZSIG", zsig)
    205 
    206   CALL put_field("ZGAM", "ZGAM", zgam)
    207 
    208   CALL put_field("ZTHE", "ZTHE", zthe)
    209 
    210   CALL put_field("ZPIC", "ZPIC", zpic)
    211 
    212   CALL put_field("ZVAL", "ZVAL", zval)
    213 
    214   CALL put_field("RUGSREL", "RUGSREL", rugoro)
    215 
    216   CALL put_field("TANCIEN", "TANCIEN", t_ancien)
    217 
    218   CALL put_field("QANCIEN", "QANCIEN", q_ancien)
    219 
    220   CALL put_field("QLANCIEN", "QLANCIEN", ql_ancien)
    221 
    222   CALL put_field("QSANCIEN", "QSANCIEN", qs_ancien)
    223 
    224   CALL put_field("PRWANCIEN", "PRWANCIEN", prw_ancien)
    225 
    226   CALL put_field("PRLWANCIEN", "PRLWANCIEN", prlw_ancien)
    227 
    228   CALL put_field("PRSWANCIEN", "PRSWANCIEN", prsw_ancien)
    229 
    230   CALL put_field("UANCIEN", "UANCIEN", u_ancien)
    231 
    232   CALL put_field("VANCIEN", "VANCIEN", v_ancien)
    233 
    234   CALL put_field("CLWCON", "Eau liquide convective", clwcon)
    235 
    236   CALL put_field("RNEBCON", "Nebulosite convective", rnebcon)
    237 
    238   CALL put_field("RATQS", "Ratqs", ratqs)
    239 
    240   ! run_off_lic_0
    241 
    242   CALL put_field("RUNOFFLIC0", "Runofflic0", run_off_lic_0)
    243 
    244   ! DEB TKE PBL !
    245 
    246   IF (iflag_pbl>1) then
    247     CALL put_field_srf3("TKE", "Energ. Cineti. Turb.", &
    248          pbl_tke(:,:,:))
    249     CALL put_field_srf3("DELTATKE", "Del TKE wk/env.", &
    250          wake_delta_pbl_tke(:,:,:))
    251   END IF
    252 
    253   ! FIN TKE PBL !
    254   !IM ajout zmax0, f0, sig1, w01
    255   !IM wake_deltat, wake_deltaq, wake_s, wake_cstar, wake_pe, wake_fip
    256 
    257   CALL put_field("ZMAX0", "ZMAX0", zmax0)
    258 
    259   CALL put_field("F0", "F0", f0)
    260 
    261   CALL put_field("sig1", "sig1 Emanuel", sig1)
    262 
    263   CALL put_field("w01", "w01 Emanuel", w01)
    264 
    265   ! wake_deltat
    266   CALL put_field("WAKE_DELTAT", "WAKE_DELTAT", wake_deltat)
    267 
    268   CALL put_field("WAKE_DELTAQ", "WAKE_DELTAQ", wake_deltaq)
    269 
    270   CALL put_field("WAKE_S", "Wake frac. area", wake_s)
    271 
    272   CALL put_field("WAKE_DENS", "Wake num. /unit area", wake_dens)
    273 
    274   CALL put_field("WAKE_CSTAR", "WAKE_CSTAR", wake_cstar)
    275 
    276   CALL put_field("WAKE_PE", "WAKE_PE", wake_pe)
    277 
    278   CALL put_field("WAKE_FIP", "WAKE_FIP", wake_fip)
    279 
    280   ! thermiques
    281 
    282   CALL put_field("FM_THERM", "FM_THERM", fm_therm)
    283 
    284   CALL put_field("ENTR_THERM", "ENTR_THERM", entr_therm)
    285 
    286   CALL put_field("DETR_THERM", "DETR_THERM", detr_therm)
    287 
    288   CALL put_field("ALE_BL", "ALE_BL", ale_bl)
    289 
    290   CALL put_field("ALE_BL_TRIG", "ALE_BL_TRIG", ale_bl_trig)
    291 
    292   CALL put_field("ALP_BL", "ALP_BL", alp_bl)
    293 
    294   CALL put_field("ALE_WAKE", "ALE_WAKE", ale_wake)
    295 
    296   CALL put_field("ALE_BL_STAT", "ALE_BL_STAT", ale_bl_stat)
    297 
    298 
    299   ! trs from traclmdz_mod
    300   IF (type_trac == 'lmdz') THEN
    301      CALL traclmdz_to_restart(trs)
    302      DO it=1, nbtr
     172    CALL put_field(pass,"treedrg_ter","freinage arbres",treedrg(:,:,is_ter))
     173
     174
     175    CALL put_field_srf1(pass,"QS"  , "Humidite",qsurf(:,:))
     176
     177    CALL put_field     (pass,"QSOL", "Eau dans le sol (mm)", qsol)
     178
     179    CALL put_field_srf1(pass,"EVAP", "Evaporation", fevap(:,:))
     180
     181    CALL put_field_srf1(pass,"SNOW", "Neige", snow(:,:))
     182
     183    CALL put_field(pass,"RADS", "Rayonnement net a la surface", radsol)
     184
     185    CALL put_field(pass,"solsw", "Rayonnement solaire a la surface", solsw)
     186
     187    CALL put_field(pass,"sollw", "Rayonnement IF a la surface", sollw)
     188
     189    CALL put_field(pass,"sollwdown", "Rayonnement down IF a la surface", sollwdown)
     190
     191    CALL put_field(pass,"fder", "Derive de flux", fder)
     192
     193    CALL put_field(pass,"rain_f", "precipitation liquide", rain_fall)
     194
     195    CALL put_field(pass,"snow_f", "precipitation solide", snow_fall)
     196
     197    CALL put_field_srf1(pass,"Z0m", "rugosite", z0m(:,:))
     198
     199    CALL put_field_srf1(pass,"Z0h", "rugosite", z0h(:,:))
     200
     201    CALL put_field_srf1(pass,"AGESNO", "Age de la neige", agesno(:,:))
     202
     203    CALL put_field(pass,"ZMEA", "ZMEA", zmea)
     204
     205    CALL put_field(pass,"ZSTD", "ZSTD", zstd)
     206
     207    CALL put_field(pass,"ZSIG", "ZSIG", zsig)
     208
     209    CALL put_field(pass,"ZGAM", "ZGAM", zgam)
     210
     211    CALL put_field(pass,"ZTHE", "ZTHE", zthe)
     212
     213    CALL put_field(pass,"ZPIC", "ZPIC", zpic)
     214
     215    CALL put_field(pass,"ZVAL", "ZVAL", zval)
     216
     217    CALL put_field(pass,"RUGSREL", "RUGSREL", rugoro)
     218
     219    CALL put_field(pass,"TANCIEN", "TANCIEN", t_ancien)
     220
     221    CALL put_field(pass,"QANCIEN", "QANCIEN", q_ancien)
     222
     223    CALL put_field(pass,"QLANCIEN", "QLANCIEN", ql_ancien)
     224
     225    CALL put_field(pass,"QSANCIEN", "QSANCIEN", qs_ancien)
     226
     227    CALL put_field(pass,"PRWANCIEN", "PRWANCIEN", prw_ancien)
     228
     229    CALL put_field(pass,"PRLWANCIEN", "PRLWANCIEN", prlw_ancien)
     230
     231    CALL put_field(pass,"PRSWANCIEN", "PRSWANCIEN", prsw_ancien)
     232
     233    CALL put_field(pass,"UANCIEN", "UANCIEN", u_ancien)
     234
     235    CALL put_field(pass,"VANCIEN", "VANCIEN", v_ancien)
     236
     237    CALL put_field(pass,"CLWCON", "Eau liquide convective", clwcon)
     238
     239    CALL put_field(pass,"RNEBCON", "Nebulosite convective", rnebcon)
     240
     241    CALL put_field(pass,"RATQS", "Ratqs", ratqs)
     242
     243    ! run_off_lic_0
     244
     245    CALL put_field(pass,"RUNOFFLIC0", "Runofflic0", run_off_lic_0)
     246
     247    ! DEB TKE PBL !
     248
     249    IF (iflag_pbl>1) then
     250      CALL put_field_srf3(pass,"TKE", "Energ. Cineti. Turb.", &
     251           pbl_tke(:,:,:))
     252      CALL put_field_srf3(pass,"DELTATKE", "Del TKE wk/env.", &
     253           wake_delta_pbl_tke(:,:,:))
     254    END IF
     255
     256    ! FIN TKE PBL !
     257    !IM ajout zmax0, f0, sig1, w01
     258    !IM wake_deltat, wake_deltaq, wake_s, wake_cstar, wake_pe, wake_fip
     259
     260    CALL put_field(pass,"ZMAX0", "ZMAX0", zmax0)
     261
     262    CALL put_field(pass,"F0", "F0", f0)
     263
     264    CALL put_field(pass,"sig1", "sig1 Emanuel", sig1)
     265
     266    CALL put_field(pass,"w01", "w01 Emanuel", w01)
     267
     268    ! wake_deltat
     269    CALL put_field(pass,"WAKE_DELTAT", "WAKE_DELTAT", wake_deltat)
     270
     271    CALL put_field(pass,"WAKE_DELTAQ", "WAKE_DELTAQ", wake_deltaq)
     272
     273    CALL put_field(pass,"WAKE_S", "Wake frac. area", wake_s)
     274
     275    CALL put_field(pass,"WAKE_DENS", "Wake num. /unit area", wake_dens)
     276
     277    CALL put_field(pass,"WAKE_CSTAR", "WAKE_CSTAR", wake_cstar)
     278
     279    CALL put_field(pass,"WAKE_PE", "WAKE_PE", wake_pe)
     280
     281    CALL put_field(pass,"WAKE_FIP", "WAKE_FIP", wake_fip)
     282
     283    ! thermiques
     284
     285    CALL put_field(pass,"FM_THERM", "FM_THERM", fm_therm)
     286
     287    CALL put_field(pass,"ENTR_THERM", "ENTR_THERM", entr_therm)
     288
     289    CALL put_field(pass,"DETR_THERM", "DETR_THERM", detr_therm)
     290
     291    CALL put_field(pass,"ALE_BL", "ALE_BL", ale_bl)
     292
     293    CALL put_field(pass,"ALE_BL_TRIG", "ALE_BL_TRIG", ale_bl_trig)
     294
     295    CALL put_field(pass,"ALP_BL", "ALP_BL", alp_bl)
     296
     297    CALL put_field(pass,"ALE_WAKE", "ALE_WAKE", ale_wake)
     298
     299    CALL put_field(pass,"ALE_BL_STAT", "ALE_BL_STAT", ale_bl_stat)
     300
     301
     302    ! trs from traclmdz_mod
     303    IF (type_trac == 'lmdz') THEN
     304       CALL traclmdz_to_restart(trs)
     305       DO it=1, nbtr
    303306!!        iiq=niadv(it+2)                                                           ! jyg
    304         iiq=niadv(it+nqo)                                                           ! jyg
    305         CALL put_field("trs_"//tname(iiq), "", trs(:, it))
    306      END DO
    307      IF (carbon_cycle_cpl) THEN
    308         IF (.NOT. ALLOCATED(co2_send)) THEN
    309            ! This is the case of create_etat0_limit, ce0l
    310            ALLOCATE(co2_send(klon))
    311            co2_send(:) = co2_ppm0
     307          iiq=niadv(it+nqo)                                                           ! jyg
     308          CALL put_field(pass,"trs_"//tname(iiq), "", trs(:, it))
     309       END DO
     310       IF (carbon_cycle_cpl) THEN
     311          IF (.NOT. ALLOCATED(co2_send)) THEN
     312             ! This is the case of create_etat0_limit, ce0l
     313             ALLOCATE(co2_send(klon))
     314             co2_send(:) = co2_ppm0
     315          END IF
     316          CALL put_field(pass,"co2_send", "co2_ppm for coupling", co2_send)
     317       END IF
     318    END IF
     319
     320    ! Restart variables for Slab ocean
     321    IF (type_ocean == 'slab') THEN
     322        IF (nslay.EQ.1) THEN
     323          CALL put_field(pass,"tslab", "Slab ocean temperature", tslab)
     324        ELSE
     325          DO it=1,nslay
     326            WRITE(str2,'(i2.2)') it
     327            CALL put_field(pass,"tslab"//str2, "Slab ocean temperature", tslab(:,it))
     328          END DO
    312329        END IF
    313         CALL put_field("co2_send", "co2_ppm for coupling", co2_send)
    314      END IF
    315   END IF
    316 
    317   ! Restart variables for Slab ocean
    318   IF (type_ocean == 'slab') THEN
    319       IF (nslay.EQ.1) THEN
    320         CALL put_field("tslab", "Slab ocean temperature", tslab)
    321       ELSE
    322         DO it=1,nslay
    323           WRITE(str2,'(i2.2)') it
    324           CALL put_field("tslab"//str2, "Slab ocean temperature", tslab(:,it))
    325         END DO
    326       END IF
    327       IF (version_ocean == 'sicINT') THEN
    328           CALL put_field("seaice", "Slab seaice (kg/m2)", seaice)
    329           CALL put_field("slab_tice", "Slab sea ice temperature", tice)
    330       END IF
    331   END IF
    332 
    333   if (ok_gwd_rando) call put_field("du_gwd_rando", &
    334        "tendency on zonal wind due to flott gravity waves", du_gwd_rando)
    335 
    336   IF (.not. ok_hines .and. ok_gwd_rando) call put_field("du_gwd_front", &
    337        "tendency on zonal wind due to acama gravity waves", du_gwd_front)
    338 
    339   CALL close_restartphy
     330        IF (version_ocean == 'sicINT') THEN
     331            CALL put_field(pass,"seaice", "Slab seaice (kg/m2)", seaice)
     332            CALL put_field(pass,"slab_tice", "Slab sea ice temperature", tice)
     333        END IF
     334    END IF
     335
     336    if (ok_gwd_rando) call put_field(pass,"du_gwd_rando", &
     337         "tendency on zonal wind due to flott gravity waves", du_gwd_rando)
     338
     339    IF (.not. ok_hines .and. ok_gwd_rando) call put_field(pass,"du_gwd_front", &
     340         "tendency on zonal wind due to acama gravity waves", du_gwd_front)
     341
     342    IF (pass==1) CALL enddef_restartphy
     343    IF (pass==2) CALL close_restartphy
     344  ENDDO
     345 
    340346  !$OMP BARRIER
    341347
     
    344350
    345351
    346 SUBROUTINE put_field_srf1(nam,lnam,field)
     352SUBROUTINE put_field_srf1(pass,nam,lnam,field)
    347353
    348354  IMPLICIT NONE
     355  INTEGER, INTENT(IN)            :: pass
    349356  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
    350357  REAL,              INTENT(IN) :: field(:,:)
     
    354361    nm=TRIM(nam)//TRIM(str)
    355362    lm=TRIM(lnam)//" de surface No. "//TRIM(str)
    356     CALL put_field(nm,lm,field(:,nsrf))
     363    CALL put_field(pass,nm,lm,field(:,nsrf))
    357364  END DO
    358365
     
    360367
    361368
    362 SUBROUTINE put_field_srf2(nam,lnam,field)
     369SUBROUTINE put_field_srf2(pass,nam,lnam,field)
    363370
    364371  IMPLICIT NONE
     372  INTEGER, INTENT(IN)            :: pass
    365373  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
    366374  REAL,              INTENT(IN) :: field(:,:,:)
     
    372380      nm=TRIM(nam)//TRIM(str)
    373381      lm=TRIM(lnam)//" du sol No. "//TRIM(str)
    374       CALL put_field(nm,lm,field(:,isoil,nsrf))
     382      CALL put_field(pass,nm,lm,field(:,isoil,nsrf))
    375383    END DO
    376384  END DO
     
    379387
    380388
    381 SUBROUTINE put_field_srf3(nam,lnam,field)
     389SUBROUTINE put_field_srf3(pass,nam,lnam,field)
    382390
    383391  IMPLICIT NONE
     392  INTEGER, INTENT(IN)            :: pass
    384393  CHARACTER(LEN=*),  INTENT(IN) :: nam, lnam
    385394  REAL,              INTENT(IN) :: field(:,:,:)
     
    389398    nm=TRIM(nam)//TRIM(str)
    390399    lm=TRIM(lnam)//TRIM(str)
    391     CALL put_field(nm,lm,field(:,1:klev+1,nsrf))
     400    CALL put_field(pass,nm,lm,field(:,1:klev+1,nsrf))
    392401  END DO
    393402
Note: See TracChangeset for help on using the changeset viewer.