Changeset 1083 for LMDZ4


Ignore:
Timestamp:
Jan 28, 2009, 12:51:09 PM (16 years ago)
Author:
lguez
Message:

Évolution des entrées-sorties : lecture des noms et des niveaux de
sortie des variables à partir d'un fichier "outputs.def".
Abderrahmane IDELKADI

Location:
LMDZ4/branches/LMDZ4-dev
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_mod.F90

    r1082 r1083  
    1212  IMPLICIT NONE
    1313
    14   private histdef2d, histdef3d
     14  private histdef2d, histdef3d, conf_physoutputs
     15
    1516
    1617   integer, parameter                           :: nfiles = 5
     
    2728!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    2829!! Definition pour chaque variable du niveau d ecriture dans chaque fichier
    29 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/ histmth, histday, histhf, histins /)!!!!!!!!!!!!
     30!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!/ histmth, histday, histhf, histins /),'!!!!!!!!!!!!
    3031!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    3132
     
    3334  integer, private:: levmax(nfiles)
    3435
     36  TYPE ctrl_out
     37   integer,dimension(5) :: flag
     38   character(len=20)     :: name
     39  END TYPE ctrl_out
     40
     41
    3542!!! 1D
    36   integer, dimension(nfiles) , save :: flag_phis         = (/ 1, 1, 10, 1, 1 /)
    37   integer, dimension(nfiles) , save :: flag_aire         = (/ 1, 1, 10,  1, 1 /)
    38   integer, dimension(nfiles) , save :: flag_contfracATM  = (/ 10, 1,  1, 10, 10 /)
    39   integer, dimension(nfiles) , save :: flag_contfracOR   = (/ 10, 1,  1, 10, 10 /)
    40   integer, dimension(nfiles) , save :: flag_aireTER      = (/ 10, 10, 1, 10, 10 /)
     43  type(ctrl_out) :: o_phis         = ctrl_out((/ 1, 1, 10, 1, 1 /), 'phis')
     44  type(ctrl_out) :: o_aire         = ctrl_out((/ 1, 1, 10,  1, 1 /),'aire')
     45  type(ctrl_out) :: o_contfracATM  = ctrl_out((/ 10, 1,  1, 10, 10 /),'contfracATM')
     46  type(ctrl_out) :: o_contfracOR   = ctrl_out((/ 10, 1,  1, 10, 10 /),'contfracOR')
     47  type(ctrl_out) :: o_aireTER      = ctrl_out((/ 10, 10, 1, 10, 10 /),'aireTER')
    4148 
    4249!!! 2D
    43   integer, dimension(nfiles) , save :: flag_flat         = (/ 10, 1, 10, 10, 1 /)
    44   integer, dimension(nfiles) , save :: flag_slp          = (/ 1, 1, 1, 10, 1 /)
    45   integer, dimension(nfiles) , save :: flag_tsol         = (/ 1, 1, 1, 1, 1 /)
    46   integer, dimension(nfiles) , save :: flag_t2m          = (/ 1, 1, 1, 1, 1 /)
    47   integer, dimension(nfiles) , save :: flag_t2m_min      = (/ 1, 1, 10, 10, 10 /)
    48   integer, dimension(nfiles) , save :: flag_t2m_max      = (/ 1, 1, 10, 10, 10 /)
    49   integer, dimension(nfiles) , save :: flag_t2m_sol      = (/ 10, 4, 10, 10, 10 /)
    50   integer, dimension(nfiles) , save :: flag_wind10m      = (/ 1, 1, 1, 10, 10 /)
    51   integer, dimension(nfiles) , save :: flag_wind10max    = (/ 10, 1, 10, 10, 10 /)
    52   integer, dimension(nfiles) , save :: flag_sicf         = (/ 1, 1, 10, 10, 10 /)
    53   integer, dimension(nfiles) , save :: flag_q2m          = (/ 1, 1, 1, 1, 1 /)
    54   integer, dimension(nfiles) , save :: flag_u10m         = (/ 1, 1, 1, 1, 1 /)
    55   integer, dimension(nfiles) , save :: flag_v10m         = (/ 1, 1, 1, 1, 1 /)
    56   integer, dimension(nfiles) , save :: flag_psol         = (/ 1, 1, 1, 1, 1 /)
    57   integer, dimension(nfiles) , save :: flag_qsurf        = (/ 1, 10, 10, 10, 10 /)
    58 
    59   integer, dimension(nfiles) , save :: flag_u10m_sol     = (/ 10, 4, 10, 10, 10 /)
    60   integer, dimension(nfiles) , save :: flag_v10m_sol     = (/ 10, 4, 10, 10, 10 /)
    61 
    62   integer, dimension(nfiles) , save :: flag_qsol         = (/ 1, 10, 10, 1, 1 /)
    63 
    64   integer, dimension(nfiles),save   :: flag_ndayrain     = (/ 1, 10, 10, 10, 10 /)
    65   integer, dimension(nfiles),save   :: flag_precip       = (/ 1, 1, 1, 1, 1 /)
    66   integer,  dimension(nfiles), save :: flag_plul         = (/ 1, 1, 1, 1, 10 /)
    67 
    68   integer, dimension(nfiles) , save :: flag_pluc         = (/ 1, 1, 1, 1, 10 /)
    69   integer, dimension(nfiles) , save :: flag_snow         = (/ 1, 1, 10, 1, 10 /)
    70   integer, dimension(nfiles) , save :: flag_evap         = (/ 1, 1, 10, 1, 10 /)
    71   integer, dimension(nfiles) , save :: flag_tops         = (/ 1, 1, 10, 10, 10 /)
    72   integer, dimension(nfiles) , save :: flag_tops0        = (/ 1, 5, 10, 10, 10 /)
    73   integer, dimension(nfiles) , save :: flag_topl         = (/ 1, 1, 10, 1, 10 /)
    74   integer, dimension(nfiles) , save :: flag_topl0        = (/ 1, 5, 10, 10, 10 /)
    75   integer, dimension(nfiles) , save :: flag_SWupTOA      = (/ 1, 4, 10, 10, 10 /)
    76   integer, dimension(nfiles) , save :: flag_SWupTOAclr   = (/ 1, 4, 10, 10, 10 /)
    77   integer, dimension(nfiles) , save :: flag_SWdnTOA      = (/ 1, 4, 10, 10, 10 /)
    78   integer, dimension(nfiles) , save :: flag_SWdnTOAclr   = (/ 1, 4, 10, 10, 10 /)
    79   integer, dimension(nfiles) , save :: flag_SWup200      = (/ 1, 10, 10, 10, 10 /)
    80   integer, dimension(nfiles) , save :: flag_SWup200clr   = (/ 10, 1, 10, 10, 10 /)
    81   integer, dimension(nfiles) , save :: flag_SWdn200      = (/ 1, 10, 10, 10, 10 /)
    82   integer, dimension(nfiles) , save :: flag_SWdn200clr   = (/ 10, 1, 10, 10, 10 /)
     50  type(ctrl_out) :: o_flat         = ctrl_out((/ 10, 1, 10, 10, 1 /),'flat')
     51  type(ctrl_out) :: o_slp          = ctrl_out((/ 1, 1, 1, 10, 1 /),'slp')
     52  type(ctrl_out) :: o_tsol         = ctrl_out((/ 1, 1, 1, 1, 1 /),'tsol')
     53  type(ctrl_out) :: o_t2m          = ctrl_out((/ 1, 1, 1, 1, 1 /),'t2m')
     54  type(ctrl_out) :: o_t2m_min      = ctrl_out((/ 1, 1, 10, 10, 10 /),'t2m_min')
     55  type(ctrl_out) :: o_t2m_max      = ctrl_out((/ 1, 1, 10, 10, 10 /),'t2m_max')
     56  type(ctrl_out),dimension(4) :: o_t2m_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_ter'), &
     57                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_lic'), &
     58                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_oce'), &
     59                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'t2m_sic') /)
     60
     61  type(ctrl_out) :: o_wind10m      = ctrl_out((/ 1, 1, 1, 10, 10 /),'wind10m')
     62  type(ctrl_out) :: o_wind10max    = ctrl_out((/ 10, 1, 10, 10, 10 /),'wind10max')
     63  type(ctrl_out) :: o_sicf         = ctrl_out((/ 1, 1, 10, 10, 10 /),'sicf')
     64  type(ctrl_out) :: o_q2m          = ctrl_out((/ 1, 1, 1, 1, 1 /),'q2m')
     65  type(ctrl_out) :: o_u10m         = ctrl_out((/ 1, 1, 1, 1, 1 /),'u10m')
     66  type(ctrl_out) :: o_v10m         = ctrl_out((/ 1, 1, 1, 1, 1 /),'v10m')
     67  type(ctrl_out) :: o_psol         = ctrl_out((/ 1, 1, 1, 1, 1 /),'psol')
     68  type(ctrl_out) :: o_qsurf        = ctrl_out((/ 1, 10, 10, 10, 10 /),'qsurf')
     69
     70  type(ctrl_out),dimension(4) :: o_u10m_srf     = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_ter'), &
     71                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_lic'), &
     72                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_oce'), &
     73                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'u10m_sic') /)
     74
     75  type(ctrl_out),dimension(4) :: o_v10m_srf     = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_ter'), &
     76                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_lic'), &
     77                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_oce'), &
     78                                              ctrl_out((/ 10, 4, 10, 10, 10 /),'v10m_sic') /)
     79
     80  type(ctrl_out) :: o_qsol         = ctrl_out((/ 1, 10, 10, 1, 1 /),'qsol')
     81
     82  type(ctrl_out) :: o_ndayrain     = ctrl_out((/ 1, 10, 10, 10, 10 /),'ndayrain')
     83  type(ctrl_out) :: o_precip       = ctrl_out((/ 1, 1, 1, 1, 1 /),'precip')
     84  type(ctrl_out) :: o_plul         = ctrl_out((/ 1, 1, 1, 1, 10 /),'plul')
     85
     86  type(ctrl_out) :: o_pluc         = ctrl_out((/ 1, 1, 1, 1, 10 /),'pluc')
     87  type(ctrl_out) :: o_snow         = ctrl_out((/ 1, 1, 10, 1, 10 /),'snow')
     88  type(ctrl_out) :: o_evap         = ctrl_out((/ 1, 1, 10, 1, 10 /),'evap')
     89  type(ctrl_out) :: o_tops         = ctrl_out((/ 1, 1, 10, 10, 10 /),'tops')
     90  type(ctrl_out) :: o_tops0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'tops0')
     91  type(ctrl_out) :: o_topl         = ctrl_out((/ 1, 1, 10, 1, 10 /),'topl')
     92  type(ctrl_out) :: o_topl0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'topl0')
     93  type(ctrl_out) :: o_SWupTOA      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupTOA')
     94  type(ctrl_out) :: o_SWupTOAclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupTOAclr')
     95  type(ctrl_out) :: o_SWdnTOA      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnTOA')
     96  type(ctrl_out) :: o_SWdnTOAclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnTOAclr')
     97  type(ctrl_out) :: o_SWup200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'SWup200')
     98  type(ctrl_out) :: o_SWup200clr   = ctrl_out((/ 10, 1, 10, 10, 10 /),'SWup200clr')
     99  type(ctrl_out) :: o_SWdn200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'SWdn200')
     100  type(ctrl_out) :: o_SWdn200clr   = ctrl_out((/ 10, 1, 10, 10, 10 /),'SWdn200clr')
    83101
    84102! arajouter
    85 !  integer, dimension(nfiles) , save :: flag_LWupTOA     = (/ 1, 4, 10, 10, 10 /)
    86 !  integer, dimension(nfiles) , save :: flag_LWupTOAclr  = (/ 1, 4, 10, 10, 10 /)
    87 !  integer, dimension(nfiles) , save :: flag_LWdnTOA     = (/ 1, 4, 10, 10, 10 /)
    88 !  integer, dimension(nfiles) , save :: flag_LWdnTOAclr  = (/ 1, 4, 10, 10, 10 /)
    89 
    90   integer, dimension(nfiles) , save :: flag_LWup200      = (/ 1, 10, 10, 10, 10 /)
    91   integer, dimension(nfiles) , save :: flag_LWup200clr   = (/ 1, 10, 10, 10, 10 /)
    92   integer, dimension(nfiles) , save :: flag_LWdn200      = (/ 1, 10, 10, 10, 10 /)
    93   integer, dimension(nfiles) , save :: flag_LWdn200clr   = (/ 1, 10, 10, 10, 10 /)
    94   integer, dimension(nfiles) , save :: flag_sols         = (/ 1, 1, 10, 1, 10 /)
    95   integer, dimension(nfiles) , save :: flag_sols0        = (/ 1, 5, 10, 10, 10 /)
    96   integer, dimension(nfiles) , save :: flag_soll         = (/ 1, 1, 10, 1, 10 /)
    97   integer, dimension(nfiles) , save :: flag_soll0        = (/ 1, 5, 10, 10, 10 /)
    98   integer, dimension(nfiles) , save :: flag_radsol       = (/ 1, 1, 10, 10, 10 /)
    99   integer, dimension(nfiles) , save :: flag_SWupSFC      = (/ 1, 4, 10, 10, 10 /)
    100   integer, dimension(nfiles) , save :: flag_SWupSFCclr   = (/ 1, 4, 10, 10, 10 /)
    101   integer, dimension(nfiles) , save :: flag_SWdnSFC      = (/ 1, 1, 10, 10, 10 /)
    102   integer, dimension(nfiles) , save :: flag_SWdnSFCclr   = (/ 1, 4, 10, 10, 10 /)
    103   integer, dimension(nfiles) , save :: flag_LWupSFC      = (/ 1, 4, 10, 10, 10 /)
    104   integer, dimension(nfiles) , save :: flag_LWupSFCclr   = (/ 1, 4, 10, 10, 10 /)
    105   integer, dimension(nfiles) , save :: flag_LWdnSFC      = (/ 1, 4, 10, 10, 10 /)
    106   integer, dimension(nfiles) , save :: flag_LWdnSFCclr   = (/ 1, 4, 10, 10, 10 /)
    107   integer, dimension(nfiles) , save :: flag_bils         = (/ 1, 2, 10, 1, 10 /)
    108   integer, dimension(nfiles) , save :: flag_sens         = (/ 1, 1, 10, 1, 1 /)
    109   integer, dimension(nfiles) , save :: flag_fder         = (/ 1, 2, 10, 1, 10 /)
    110   integer, dimension(nfiles) , save :: flag_ffonte       = (/ 1, 10, 10, 10, 10 /)
    111   integer, dimension(nfiles) , save :: flag_fqcalving    = (/ 1, 10, 10, 10, 10 /)
    112   integer, dimension(nfiles) , save :: flag_fqfonte      = (/ 1, 10, 10, 10, 10 /)
    113 
    114   integer, dimension(nfiles) , save :: flag_taux_sol     = (/ 1, 4, 10, 1, 10 /)
    115   integer, dimension(nfiles) , save :: flag_tauy_sol     = (/ 1, 4, 10, 1, 10 /)
    116 
    117   integer, dimension(nfiles) , save :: flag_pourc_sol    = (/ 1, 4, 10, 1, 10 /)
    118   integer, dimension(nfiles) , save :: flag_fract_sol    = (/ 1, 4, 10, 1, 10 /)
    119   integer, dimension(nfiles) , save :: flag_tsol_sol     = (/ 1, 4, 10, 1, 10 /)
    120   integer, dimension(nfiles) , save :: flag_sens_sol     = (/ 1, 4, 10, 1, 10 /)
    121   integer, dimension(nfiles) , save :: flag_lat_sol      = (/ 1, 4, 10, 1, 10 /)
    122   integer, dimension(nfiles) , save :: flag_flw_sol      = (/ 1, 10, 10, 10, 10 /)
    123   integer, dimension(nfiles) , save :: flag_fsw_sol      = (/ 1, 10, 10, 10, 10 /)
    124   integer, dimension(nfiles) , save :: flag_wbils_sol    = (/ 1, 10, 10, 10, 10 /)
    125   integer, dimension(nfiles) , save :: flag_wbilo_sol    = (/ 1, 10, 10, 10, 10 /)
    126 
    127   integer, dimension(nfiles) , save :: flag_cdrm         = (/ 1, 10, 10, 1, 10 /)
    128   integer, dimension(nfiles) , save :: flag_cdrh         = (/ 1, 10, 10, 1, 10 /)
    129   integer, dimension(nfiles) , save :: flag_cldl         = (/ 1, 1, 10, 10, 10 /)
    130   integer, dimension(nfiles) , save :: flag_cldm         = (/ 1, 1, 10, 10, 10 /)
    131   integer, dimension(nfiles) , save :: flag_cldh         = (/ 1, 1, 10, 10, 10 /)
    132   integer, dimension(nfiles) , save :: flag_cldt         = (/ 1, 1, 2, 10, 10 /)
    133   integer, dimension(nfiles) , save :: flag_cldq         = (/ 1, 1, 10, 10, 10 /)
    134   integer, dimension(nfiles) , save :: flag_lwp          = (/ 1, 5, 10, 10, 10 /)
    135   integer, dimension(nfiles) , save :: flag_iwp          = (/ 1, 5, 10, 10, 10 /)
    136   integer, dimension(nfiles) , save :: flag_ue           = (/ 1, 10, 10, 10, 10 /)
    137   integer, dimension(nfiles) , save :: flag_ve           = (/ 1, 10, 10, 10, 10 /)
    138   integer, dimension(nfiles) , save :: flag_uq           = (/ 1, 10, 10, 10, 10 /)
    139   integer, dimension(nfiles) , save :: flag_vq           = (/ 1, 10, 10, 10, 10 /)
     103!  type(ctrl_out) :: o_LWupTOA     = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupTOA')
     104!  type(ctrl_out) :: o_LWupTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupTOAclr')
     105!  type(ctrl_out) :: o_LWdnTOA     = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnTOA')
     106!  type(ctrl_out) :: o_LWdnTOAclr  = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnTOAclr')
     107
     108  type(ctrl_out) :: o_LWup200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWup200')
     109  type(ctrl_out) :: o_LWup200clr   = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWup200clr')
     110  type(ctrl_out) :: o_LWdn200      = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWdn200')
     111  type(ctrl_out) :: o_LWdn200clr   = ctrl_out((/ 1, 10, 10, 10, 10 /),'LWdn200clr')
     112  type(ctrl_out) :: o_sols         = ctrl_out((/ 1, 1, 10, 1, 10 /),'sols')
     113  type(ctrl_out) :: o_sols0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'sols0')
     114  type(ctrl_out) :: o_soll         = ctrl_out((/ 1, 1, 10, 1, 10 /),'soll')
     115  type(ctrl_out) :: o_soll0        = ctrl_out((/ 1, 5, 10, 10, 10 /),'soll0')
     116  type(ctrl_out) :: o_radsol       = ctrl_out((/ 1, 1, 10, 10, 10 /),'radsol')
     117  type(ctrl_out) :: o_SWupSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupSFC')
     118  type(ctrl_out) :: o_SWupSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWupSFCclr')
     119  type(ctrl_out) :: o_SWdnSFC      = ctrl_out((/ 1, 1, 10, 10, 10 /),'SWdnSFC')
     120  type(ctrl_out) :: o_SWdnSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'SWdnSFCclr')
     121  type(ctrl_out) :: o_LWupSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupSFC')
     122  type(ctrl_out) :: o_LWupSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWupSFCclr')
     123  type(ctrl_out) :: o_LWdnSFC      = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnSFC')
     124  type(ctrl_out) :: o_LWdnSFCclr   = ctrl_out((/ 1, 4, 10, 10, 10 /),'LWdnSFCclr')
     125  type(ctrl_out) :: o_bils         = ctrl_out((/ 1, 2, 10, 1, 10 /),'bils')
     126  type(ctrl_out) :: o_sens         = ctrl_out((/ 1, 1, 10, 1, 1 /),'sens')
     127  type(ctrl_out) :: o_fder         = ctrl_out((/ 1, 2, 10, 1, 10 /),'fder')
     128  type(ctrl_out) :: o_ffonte       = ctrl_out((/ 1, 10, 10, 10, 10 /),'ffonte')
     129  type(ctrl_out) :: o_fqcalving    = ctrl_out((/ 1, 10, 10, 10, 10 /),'fqcalving')
     130  type(ctrl_out) :: o_fqfonte      = ctrl_out((/ 1, 10, 10, 10, 10 /),'fqfonte')
     131
     132  type(ctrl_out),dimension(4) :: o_taux_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_ter'), &
     133                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_lic'), &
     134                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_oce'), &
     135                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'taux_sic') /)
     136
     137  type(ctrl_out),dimension(4) :: o_tauy_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_ter'), &
     138                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_lic'), &
     139                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_oce'), &
     140                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tauy_sic') /)
     141
     142
     143  type(ctrl_out),dimension(4) :: o_pourc_srf    = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_ter'), &
     144                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_lic'), &
     145                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_oce'), &
     146                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'pourc_sic') /)     
     147
     148  type(ctrl_out),dimension(4) :: o_fract_srf    = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_ter'), &
     149                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_lic'), &
     150                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_oce'), &
     151                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'fract_sic') /)
     152
     153  type(ctrl_out),dimension(4) :: o_tsol_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_ter'), &
     154                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_lic'), &
     155                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_oce'), &
     156                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'tsol_sic') /)
     157
     158  type(ctrl_out),dimension(4) :: o_sens_srf     = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_ter'), &
     159                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_lic'), &
     160                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_oce'), &
     161                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'sens_sic') /)
     162
     163  type(ctrl_out),dimension(4) :: o_lat_srf      = (/ ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_ter'), &
     164                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_lic'), &
     165                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_oce'), &
     166                                                 ctrl_out((/ 1, 4, 10, 1, 10 /),'lat_sic') /)
     167
     168  type(ctrl_out),dimension(4) :: o_flw_srf      = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_ter'), &
     169                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_lic'), &
     170                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_oce'), &
     171                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'flw_sic') /)
     172                                                 
     173  type(ctrl_out),dimension(4) :: o_fsw_srf      = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_ter'), &
     174                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_lic'), &
     175                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_oce'), &
     176                                                  ctrl_out((/ 1, 10, 10, 10, 10 /),'fsw_sic') /)
     177
     178  type(ctrl_out),dimension(4) :: o_wbils_srf    = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_ter'), &
     179                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_lic'), &
     180                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_oce'), &
     181                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbils_sic') /)
     182
     183  type(ctrl_out),dimension(4) :: o_wbilo_srf    = (/ ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_ter'), &
     184                                                     ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_lic'), &
     185                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_oce'), &
     186                                                 ctrl_out((/ 1, 10, 10, 10, 10 /),'wbilo_sic') /)
     187
     188
     189  type(ctrl_out) :: o_cdrm         = ctrl_out((/ 1, 10, 10, 1, 10 /),'cdrm')
     190  type(ctrl_out) :: o_cdrh         = ctrl_out((/ 1, 10, 10, 1, 10 /),'cdrh')
     191  type(ctrl_out) :: o_cldl         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldl')
     192  type(ctrl_out) :: o_cldm         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldm')
     193  type(ctrl_out) :: o_cldh         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldh')
     194  type(ctrl_out) :: o_cldt         = ctrl_out((/ 1, 1, 2, 10, 10 /),'cldt')
     195  type(ctrl_out) :: o_cldq         = ctrl_out((/ 1, 1, 10, 10, 10 /),'cldq')
     196  type(ctrl_out) :: o_lwp          = ctrl_out((/ 1, 5, 10, 10, 10 /),'lwp')
     197  type(ctrl_out) :: o_iwp          = ctrl_out((/ 1, 5, 10, 10, 10 /),'iwp')
     198  type(ctrl_out) :: o_ue           = ctrl_out((/ 1, 10, 10, 10, 10 /),'ue')
     199  type(ctrl_out) :: o_ve           = ctrl_out((/ 1, 10, 10, 10, 10 /),'ve')
     200  type(ctrl_out) :: o_uq           = ctrl_out((/ 1, 10, 10, 10, 10 /),'uq')
     201  type(ctrl_out) :: o_vq           = ctrl_out((/ 1, 10, 10, 10, 10 /),'vq')
    140202 
    141   integer, dimension(nfiles) , save :: flag_cape         = (/ 1, 10, 10, 10, 10 /)
    142   integer, dimension(nfiles) , save :: flag_pbase        = (/ 1, 10, 10, 10, 10 /)
    143   integer, dimension(nfiles) , save :: flag_ptop         = (/ 1, 4, 10, 10, 10 /)
    144   integer, dimension(nfiles) , save :: flag_fbase        = (/ 1, 10, 10, 10, 10 /)
    145   integer, dimension(nfiles) , save :: flag_prw          = (/ 1, 1, 10, 10, 10 /)
    146 
    147   integer, dimension(nfiles) , save :: flag_s_pblh       = (/ 1, 10, 10, 1, 1 /)
    148   integer, dimension(nfiles) , save :: flag_s_pblt       = (/ 1, 10, 10, 1, 1 /)
    149   integer, dimension(nfiles) , save :: flag_s_lcl       = (/ 1, 10, 10, 1, 10 /)
    150   integer, dimension(nfiles) , save :: flag_s_capCL      = (/ 1, 10, 10, 1, 10 /)
    151   integer, dimension(nfiles) , save :: flag_s_oliqCL    = (/ 1, 10, 10, 1, 10 /)
    152   integer, dimension(nfiles) , save :: flag_s_cteiCL     = (/ 1, 10, 10, 1, 1 /)
    153   integer, dimension(nfiles) , save :: flag_s_therm      = (/ 1, 10, 10, 1, 1 /)
    154   integer, dimension(nfiles) , save :: flag_s_trmb1      = (/ 1, 10, 10, 1, 10 /)
    155   integer, dimension(nfiles) , save :: flag_s_trmb2      = (/ 1, 10, 10, 1, 10 /)
    156   integer, dimension(nfiles) , save :: flag_s_trmb3      = (/ 1, 10, 10, 1, 10 /)
    157 
    158   integer, dimension(nfiles) , save :: flag_slab_bils    = (/ 1, 1, 10, 10, 10 /)
    159 
    160   integer, dimension(nfiles) , save :: flag_ale_bl    = (/ 1, 1, 1, 1, 10 /)
    161   integer, dimension(nfiles) , save :: flag_alp_bl    = (/ 1, 1, 1, 1, 10 /)
    162   integer, dimension(nfiles) , save :: flag_ale_wk    = (/ 1, 1, 1, 1, 10 /)
    163   integer, dimension(nfiles) , save :: flag_alp_wk    = (/ 1, 1, 1, 1, 10 /)
    164 
    165   integer, dimension(nfiles) , save :: flag_ale       = (/ 1, 1, 1, 1, 10 /)
    166   integer, dimension(nfiles) , save :: flag_alp       = (/ 1, 1, 1, 1, 10 /)
    167   integer, dimension(nfiles) , save :: flag_cin       = (/ 1, 1, 1, 1, 10 /)
    168   integer, dimension(nfiles) , save :: flag_wape       = (/ 1, 1, 1, 1, 10 /)
     203  type(ctrl_out) :: o_cape         = ctrl_out((/ 1, 10, 10, 10, 10 /),'cape')
     204  type(ctrl_out) :: o_pbase        = ctrl_out((/ 1, 10, 10, 10, 10 /),'pbase')
     205  type(ctrl_out) :: o_ptop         = ctrl_out((/ 1, 4, 10, 10, 10 /),'ptop')
     206  type(ctrl_out) :: o_fbase        = ctrl_out((/ 1, 10, 10, 10, 10 /),'fbase')
     207  type(ctrl_out) :: o_prw          = ctrl_out((/ 1, 1, 10, 10, 10 /),'prw')
     208
     209  type(ctrl_out) :: o_s_pblh       = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_pblh')
     210  type(ctrl_out) :: o_s_pblt       = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_pblt')
     211  type(ctrl_out) :: o_s_lcl        = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_lcl')
     212  type(ctrl_out) :: o_s_capCL      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_capCL')
     213  type(ctrl_out) :: o_s_oliqCL     = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_oliqCL')
     214  type(ctrl_out) :: o_s_cteiCL     = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_cteiCL')
     215  type(ctrl_out) :: o_s_therm      = ctrl_out((/ 1, 10, 10, 1, 1 /),'s_therm')
     216  type(ctrl_out) :: o_s_trmb1      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb1')
     217  type(ctrl_out) :: o_s_trmb2      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb2')
     218  type(ctrl_out) :: o_s_trmb3      = ctrl_out((/ 1, 10, 10, 1, 10 /),'s_trmb3')
     219
     220  type(ctrl_out) :: o_slab_bils    = ctrl_out((/ 1, 1, 10, 10, 10 /),'slab_bils_oce')
     221
     222  type(ctrl_out) :: o_ale_bl       = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale_bl')
     223  type(ctrl_out) :: o_alp_bl       = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp_bl')
     224  type(ctrl_out) :: o_ale_wk       = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale_wk')
     225  type(ctrl_out) :: o_alp_wk       = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp_wk')
     226
     227  type(ctrl_out) :: o_ale          = ctrl_out((/ 1, 1, 1, 1, 10 /),'ale')
     228  type(ctrl_out) :: o_alp          = ctrl_out((/ 1, 1, 1, 1, 10 /),'alp')
     229  type(ctrl_out) :: o_cin          = ctrl_out((/ 1, 1, 1, 1, 10 /),'cin')
     230  type(ctrl_out) :: o_wape         = ctrl_out((/ 1, 1, 1, 1, 10 /),'wape')
    169231
    170232
     
    177239!      on ecrit ph  a 500   au niv 3
    178240
    179   integer, dimension(nfiles) , save :: flag_ulevsSTD     = (/ 1, 1, 3, 10, 10 /)
    180   integer, dimension(nfiles) , save :: flag_vlevsSTD     = (/ 1, 1, 3, 10, 10 /)
    181   integer, dimension(nfiles) , save :: flag_wlevsSTD     = (/ 1, 1, 10, 10, 10 /)
    182   integer, dimension(nfiles) , save :: flag_tlevsSTD     = (/ 10, 10, 3, 10, 10 /)
    183   integer, dimension(nfiles) , save :: flag_qlevsSTD     = (/ 10, 10, 3, 10, 10 /)
    184   integer, dimension(nfiles) , save :: flag_philevsSTD   = (/ 1, 1, 1, 10, 10 /)
    185 
    186   integer, dimension(nfiles) , save :: flag_t_oce_sic    = (/ 1, 10, 10, 10, 10 /)
    187 
    188   integer, dimension(nfiles) , save :: flag_weakinv      = (/ 10, 1, 10, 10, 10 /)
    189   integer, dimension(nfiles) , save :: flag_dthmin       = (/ 10, 1, 10, 10, 10 /)
    190   integer, dimension(nfiles) , save :: flag_u10_sol      = (/ 10, 4, 10, 10, 10 /)
    191   integer, dimension(nfiles) , save :: flag_v10_sol      = (/ 10, 4, 10, 10, 10 /)
    192   integer, dimension(nfiles) , save :: flag_cldtau       = (/ 10, 5, 10, 10, 10 /)                     
    193   integer, dimension(nfiles) , save :: flag_cldemi       = (/ 10, 5, 10, 10, 10 /)
    194   integer, dimension(nfiles) , save :: flag_rh2m         = (/ 10, 5, 10, 10, 10 /)
    195   integer, dimension(nfiles) , save :: flag_qsat2m       = (/ 10, 5, 10, 10, 10 /)
    196   integer, dimension(nfiles) , save :: flag_tpot         = (/ 10, 5, 10, 10, 10 /)
    197   integer, dimension(nfiles) , save :: flag_tpote        = (/ 10, 5, 10, 10, 10 /)
    198   integer, dimension(nfiles) , save :: flag_tke          = (/ 4, 10, 10, 10, 10 /)
    199   integer, dimension(nfiles) , save :: flag_tke_max      = (/ 4, 10, 10, 10, 10 /)
    200   integer, dimension(nfiles) , save :: flag_tke_sol      = (/ 10, 4, 10, 10, 10 /)
    201   integer, dimension(nfiles) , save :: flag_tke_max_sol  = (/ 10, 4, 10, 10, 10 /)
    202   integer, dimension(nfiles) , save :: flag_kz           = (/ 4, 10, 10, 10, 10 /)
    203   integer, dimension(nfiles) , save :: flag_kz_max       = (/ 4, 10, 10, 10, 10 /)
    204   integer, dimension(nfiles) , save :: flag_SWnetOR      = (/ 10, 10, 2, 10, 10 /)
    205   integer, dimension(nfiles) , save :: flag_SWdownOR     = (/ 10, 10, 2, 10, 10 /)
    206   integer, dimension(nfiles) , save :: flag_LWdownOR     = (/ 10, 10, 2, 10, 10 /)
    207 
    208   integer, dimension(nfiles) , save :: flag_snowl         = (/ 10, 1, 10, 10, 10 /)
    209   integer, dimension(nfiles) , save :: flag_cape_max      = (/ 10, 1, 10, 10, 10 /)
    210   integer, dimension(nfiles) , save :: flag_solldown      = (/ 10, 1, 10, 1, 10 /)
    211 
    212   integer, dimension(nfiles) , save :: flag_dtsvdfo       = (/ 10, 10, 10, 1, 10 /)
    213   integer, dimension(nfiles) , save :: flag_dtsvdft       = (/ 10, 10, 10, 1, 10 /)
    214   integer, dimension(nfiles) , save :: flag_dtsvdfg       = (/ 10, 10, 10, 1, 10 /)
    215   integer, dimension(nfiles) , save :: flag_dtsvdfi       = (/ 10, 10, 10, 1, 10 /)
    216   integer, dimension(nfiles) , save :: flag_rugs          = (/ 10, 10, 10, 1, 1 /)
     241                                             
     242  type(ctrl_out),dimension(4) :: o_uSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'u850'), &
     243                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u700'), &
     244                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u500'), &
     245                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'u200') /)
     246
     247  type(ctrl_out),dimension(4) :: o_vSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'v850'), &
     248                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v700'), &
     249                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v500'), &
     250                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'v200') /)
     251
     252  type(ctrl_out),dimension(4) :: o_wSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'w850'), &
     253                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w700'), &
     254                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w500'), &
     255                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'w200') /)
     256
     257  type(ctrl_out),dimension(4) :: o_tSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'t850'), &
     258                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t700'), &
     259                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t500'), &
     260                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'t200') /)
     261
     262  type(ctrl_out),dimension(4) :: o_qSTDlevs     = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'q850'), &
     263                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q700'), &
     264                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q500'), &
     265                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'q200') /)
     266
     267  type(ctrl_out),dimension(4) :: o_phiSTDlevs   = (/ ctrl_out((/ 1, 1, 3, 10, 10 /),'phi850'), &
     268                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi700'), &
     269                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi500'), &
     270                                                     ctrl_out((/ 1, 1, 3, 10, 10 /),'phi200') /)
     271
     272
     273  type(ctrl_out) :: o_t_oce_sic    = ctrl_out((/ 1, 10, 10, 10, 10 /),'t_oce_sic')
     274
     275  type(ctrl_out) :: o_weakinv      = ctrl_out((/ 10, 1, 10, 10, 10 /),'weakinv')
     276  type(ctrl_out) :: o_dthmin       = ctrl_out((/ 10, 1, 10, 10, 10 /),'dthmin')
     277  type(ctrl_out),dimension(4) :: o_u10_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_ter'), &
     278                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_lic'), &
     279                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_oce'), &
     280                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'u10_sic') /)
     281
     282  type(ctrl_out),dimension(4) :: o_v10_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_ter'), &
     283                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_lic'), &
     284                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_oce'), &
     285                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'v10_sic') /)
     286  type(ctrl_out) :: o_cldtau       = ctrl_out((/ 10, 5, 10, 10, 10 /),'cldtau')                     
     287  type(ctrl_out) :: o_cldemi       = ctrl_out((/ 10, 5, 10, 10, 10 /),'cldemi')
     288  type(ctrl_out) :: o_rh2m         = ctrl_out((/ 10, 5, 10, 10, 10 /),'rh2m')
     289  type(ctrl_out) :: o_qsat2m       = ctrl_out((/ 10, 5, 10, 10, 10 /),'qsat2m')
     290  type(ctrl_out) :: o_tpot         = ctrl_out((/ 10, 5, 10, 10, 10 /),'tpot')
     291  type(ctrl_out) :: o_tpote        = ctrl_out((/ 10, 5, 10, 10, 10 /),'tpote')
     292  type(ctrl_out) :: o_tke          = ctrl_out((/ 4, 10, 10, 10, 10 /),'tke ')
     293  type(ctrl_out) :: o_tke_max      = ctrl_out((/ 4, 10, 10, 10, 10 /),'tke_max')
     294  type(ctrl_out),dimension(4) :: o_tke_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_ter'), &
     295                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_lic'), &
     296                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_oce'), &
     297                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_sic') /)
     298
     299  type(ctrl_out),dimension(4) :: o_tke_max_srf      = (/ ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_ter'), &
     300                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_lic'), &
     301                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_oce'), &
     302                                                 ctrl_out((/ 10, 4, 10, 10, 10 /),'tke_max_sic') /)
     303
     304  type(ctrl_out) :: o_kz           = ctrl_out((/ 4, 10, 10, 10, 10 /),'kz')
     305  type(ctrl_out) :: o_kz_max       = ctrl_out((/ 4, 10, 10, 10, 10 /),'kz_max')
     306  type(ctrl_out) :: o_SWnetOR      = ctrl_out((/ 10, 10, 2, 10, 10 /),'SWnetOR')
     307  type(ctrl_out) :: o_SWdownOR     = ctrl_out((/ 10, 10, 2, 10, 10 /),'SWdownOR')
     308  type(ctrl_out) :: o_LWdownOR     = ctrl_out((/ 10, 10, 2, 10, 10 /),'LWdownOR')
     309
     310  type(ctrl_out) :: o_snowl        = ctrl_out((/ 10, 1, 10, 10, 10 /),'snowl')
     311  type(ctrl_out) :: o_cape_max     = ctrl_out((/ 10, 1, 10, 10, 10 /),'cape_max')
     312  type(ctrl_out) :: o_solldown     = ctrl_out((/ 10, 1, 10, 1, 10 /),'solldown')
     313
     314  type(ctrl_out) :: o_dtsvdfo      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfo')
     315  type(ctrl_out) :: o_dtsvdft      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdft')
     316  type(ctrl_out) :: o_dtsvdfg      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfg')
     317  type(ctrl_out) :: o_dtsvdfi      = ctrl_out((/ 10, 10, 10, 1, 10 /),'dtsvdfi')
     318  type(ctrl_out) :: o_rugs         = ctrl_out((/ 10, 10, 10, 1, 1 /),'rugs')
    217319
    218320!!!!!!!!!!!!!!!!!!!!!! 3D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    219   integer, dimension(nfiles) , save :: flag_lwcon        = (/ 2, 5, 10, 10, 1 /)
    220   integer, dimension(nfiles) , save :: flag_iwcon        = (/ 2, 5, 10, 10, 10 /)
    221   integer, dimension(nfiles) , save :: flag_temp         = (/ 2, 3, 4, 1, 1 /)
    222   integer, dimension(nfiles) , save :: flag_theta         = (/ 2, 3, 4, 1, 1 /)
    223   integer, dimension(nfiles) , save :: flag_ovap         = (/ 2, 3, 4, 1, 1 /)
    224   integer, dimension(nfiles) , save :: flag_wvapp        = (/ 2, 10, 10, 10, 10 /)
    225   integer, dimension(nfiles) , save :: flag_geop         = (/ 2, 3, 10, 1, 1 /)
    226   integer, dimension(nfiles) , save :: flag_vitu         = (/ 2, 3, 4, 1, 1 /)
    227   integer, dimension(nfiles) , save :: flag_vitv         = (/ 2, 3, 4, 1, 1 /)
    228   integer, dimension(nfiles) , save :: flag_vitw         = (/ 2, 3, 10, 10, 1 /)
    229   integer, dimension(nfiles) , save :: flag_pres         = (/ 2, 3, 10, 1, 1 /)
    230   integer, dimension(nfiles) , save :: flag_rneb         = (/ 2, 5, 10, 10, 1 /)
    231   integer, dimension(nfiles) , save :: flag_rnebcon      = (/ 2, 5, 10, 10, 1 /)
    232   integer, dimension(nfiles) , save :: flag_rhum         = (/ 2, 10, 10, 10, 10 /)
    233   integer, dimension(nfiles) , save :: flag_ozone        = (/ 2, 10, 10, 10, 10 /)
    234   integer, dimension(nfiles) , save :: flag_upwd         = (/ 2, 10, 10, 10, 10 /)
    235   integer, dimension(nfiles) , save :: flag_dtphy        = (/ 2, 10, 10, 10, 1 /)
    236   integer, dimension(nfiles) , save :: flag_dqphy        = (/ 2, 10, 10, 10, 1 /)
    237   integer, dimension(nfiles) , save :: flag_pr_con_l     = (/ 2, 10, 10, 10, 10 /)
    238   integer, dimension(nfiles) , save :: flag_pr_con_i     = (/ 2, 10, 10, 10, 10 /)
    239   integer, dimension(nfiles) , save :: flag_pr_lsc_l     = (/ 2, 10, 10, 10, 10 /)
    240   integer, dimension(nfiles) , save :: flag_pr_lsc_i     = (/ 2, 10, 10, 10, 10 /)
     321  type(ctrl_out) :: o_lwcon        = ctrl_out((/ 2, 5, 10, 10, 1 /),'lwcon')
     322  type(ctrl_out) :: o_iwcon        = ctrl_out((/ 2, 5, 10, 10, 10 /),'iwcon')
     323  type(ctrl_out) :: o_temp         = ctrl_out((/ 2, 3, 4, 1, 1 /),'temp')
     324  type(ctrl_out) :: o_theta        = ctrl_out((/ 2, 3, 4, 1, 1 /),'theta')
     325  type(ctrl_out) :: o_ovap         = ctrl_out((/ 2, 3, 4, 1, 1 /),'ovap')
     326  type(ctrl_out) :: o_wvapp        = ctrl_out((/ 2, 10, 10, 10, 10 /),'wvapp')
     327  type(ctrl_out) :: o_geop         = ctrl_out((/ 2, 3, 10, 1, 1 /),'geop')
     328  type(ctrl_out) :: o_vitu         = ctrl_out((/ 2, 3, 4, 1, 1 /),'vitu')
     329  type(ctrl_out) :: o_vitv         = ctrl_out((/ 2, 3, 4, 1, 1 /),'vitv')
     330  type(ctrl_out) :: o_vitw         = ctrl_out((/ 2, 3, 10, 10, 1 /),'vitw')
     331  type(ctrl_out) :: o_pres         = ctrl_out((/ 2, 3, 10, 1, 1 /),'pres')
     332  type(ctrl_out) :: o_rneb         = ctrl_out((/ 2, 5, 10, 10, 1 /),'rneb')
     333  type(ctrl_out) :: o_rnebcon      = ctrl_out((/ 2, 5, 10, 10, 1 /),'rnebcon')
     334  type(ctrl_out) :: o_rhum         = ctrl_out((/ 2, 10, 10, 10, 10 /),'rhum')
     335  type(ctrl_out) :: o_ozone        = ctrl_out((/ 2, 10, 10, 10, 10 /),'ozone')
     336  type(ctrl_out) :: o_upwd         = ctrl_out((/ 2, 10, 10, 10, 10 /),'upwd')
     337  type(ctrl_out) :: o_dtphy        = ctrl_out((/ 2, 10, 10, 10, 1 /),'dtphy')
     338  type(ctrl_out) :: o_dqphy        = ctrl_out((/ 2, 10, 10, 10, 1 /),'dqphy')
     339  type(ctrl_out) :: o_pr_con_l     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_con_l')
     340  type(ctrl_out) :: o_pr_con_i     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_con_i')
     341  type(ctrl_out) :: o_pr_lsc_l     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_lsc_l')
     342  type(ctrl_out) :: o_pr_lsc_i     = ctrl_out((/ 2, 10, 10, 10, 10 /),'pr_lsc_i')
    241343!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    242344
    243   integer, dimension(nfiles) , save :: flag_albe_sol     = (/ 3, 4, 10, 1, 10 /)
    244   integer, dimension(nfiles) , save :: flag_ages_sol     = (/ 3, 10, 10, 10, 10 /)
    245   integer, dimension(nfiles) , save :: flag_rugs_sol     = (/ 3, 4, 10, 1, 10 /)
    246 
    247   integer, dimension(nfiles) , save :: flag_albs         = (/ 3, 10, 10, 1, 10 /)
    248   integer, dimension(nfiles) , save :: flag_albslw       = (/ 3, 10, 10, 1, 10 /)
    249 
    250   integer, dimension(nfiles) , save :: flag_clwcon       = (/ 4, 10, 10, 10, 10 /)
    251   integer, dimension(nfiles) , save :: flag_Ma           = (/ 4, 10, 10, 10, 10 /)
    252   integer, dimension(nfiles) , save :: flag_dnwd         = (/ 4, 10, 10, 10, 10 /)
    253   integer, dimension(nfiles) , save :: flag_dnwd0        = (/ 4, 10, 10, 10, 10 /)
    254   integer, dimension(nfiles) , save :: flag_dtdyn        = (/ 4, 10, 10, 10, 1 /)
    255   integer, dimension(nfiles) , save :: flag_dqdyn        = (/ 4, 10, 10, 10, 1 /)
    256   integer, dimension(nfiles) , save :: flag_dudyn        = (/ 4, 10, 10, 10, 1 /) !AXC
    257   integer, dimension(nfiles) , save :: flag_dvdyn        = (/ 4, 10, 10, 10, 1 /) !AXC
    258   integer, dimension(nfiles) , save :: flag_dtcon        = (/ 4, 5, 10, 10, 10 /)
    259   integer, dimension(nfiles) , save :: flag_ducon        = (/ 4, 10, 10, 10, 10 /)
    260   integer, dimension(nfiles) , save :: flag_dqcon        = (/ 4, 5, 10, 10, 10 /)
    261   integer, dimension(nfiles) , save :: flag_dtwak        = (/ 4, 5, 10, 10, 10 /)
    262   integer, dimension(nfiles) , save :: flag_dqwak        = (/ 4, 5, 10, 10, 10 /)
    263   integer, dimension(nfiles) , save :: flag_wake_h       = (/ 4, 5, 10, 10, 10 /)
    264   integer, dimension(nfiles) , save :: flag_wake_s       = (/ 4, 5, 10, 10, 10 /)
    265   integer, dimension(nfiles) , save :: flag_wake_deltat  = (/ 4, 5, 10, 10, 10 /)
    266   integer, dimension(nfiles) , save :: flag_wake_deltaq  = (/ 4, 5, 10, 10, 10 /)
    267   integer, dimension(nfiles) , save :: flag_wake_omg     = (/ 4, 5, 10, 10, 10 /)
    268   integer, dimension(nfiles) , save :: flag_Vprecip      = (/ 4, 5, 10, 10, 10 /)
    269   integer, dimension(nfiles) , save :: flag_ftd          = (/ 4, 5, 10, 10, 10 /)
    270   integer, dimension(nfiles) , save :: flag_fqd          = (/ 4, 5, 10, 10, 10 /)
    271   integer, dimension(nfiles) , save :: flag_dtlsc        = (/ 4, 10, 10, 10, 10 /)
    272   integer, dimension(nfiles) , save :: flag_dtlschr      = (/ 4, 10, 10, 10, 10 /)
    273   integer, dimension(nfiles) , save :: flag_dqlsc        = (/ 4, 10, 10, 10, 10 /)
    274   integer, dimension(nfiles) , save :: flag_dtvdf        = (/ 4, 10, 10, 1, 10 /)
    275   integer, dimension(nfiles) , save :: flag_dqvdf        = (/ 4, 10, 10, 1, 10 /)
    276   integer, dimension(nfiles) , save :: flag_dteva        = (/ 4, 10, 10, 10, 10 /)
    277   integer, dimension(nfiles) , save :: flag_dqeva        = (/ 4, 10, 10, 10, 10 /)
    278   integer, dimension(nfiles) , save :: flag_ptconv       = (/ 4, 10, 10, 10, 10 /)
    279   integer, dimension(nfiles) , save :: flag_ratqs        = (/ 4, 10, 10, 10, 10 /)
    280   integer, dimension(nfiles) , save :: flag_dtthe        = (/ 4, 10, 10, 10, 10 /)
    281   integer, dimension(nfiles) , save :: flag_f_th        = (/ 4, 10, 10, 10, 10 /)
    282   integer, dimension(nfiles) , save :: flag_e_th        = (/ 4, 10, 10, 10, 10 /)
    283   integer, dimension(nfiles) , save :: flag_w_th        = (/ 4, 10, 10, 10, 10 /)
    284   integer, dimension(nfiles) , save :: flag_lambda_th        = (/ 4, 10, 10, 10, 10 /)
    285   integer, dimension(nfiles) , save :: flag_q_th        = (/ 4, 10, 10, 10, 10 /)
    286   integer, dimension(nfiles) , save :: flag_a_th        = (/ 4, 10, 10, 10, 10 /)
    287   integer, dimension(nfiles) , save :: flag_d_th        = (/ 4, 10, 10, 10, 10 /)
    288   integer, dimension(nfiles) , save :: flag_f0_th        = (/ 4, 10, 10, 10, 10 /)
    289   integer, dimension(nfiles) , save :: flag_zmax_th        = (/ 4, 10, 10, 10, 10 /)
    290   integer, dimension(nfiles) , save :: flag_dqthe        = (/ 4, 10, 10, 10, 1 /)
    291   integer, dimension(nfiles) , save :: flag_dtajs        = (/ 4, 10, 10, 10, 10 /)
    292   integer, dimension(nfiles) , save :: flag_dqajs        = (/ 4, 10, 10, 10, 10 /)
    293   integer, dimension(nfiles) , save :: flag_dtswr        = (/ 4, 10, 10, 10, 1 /)
    294   integer, dimension(nfiles) , save :: flag_dtsw0        = (/ 4, 10, 10, 10, 10 /)
    295   integer, dimension(nfiles) , save :: flag_dtlwr        = (/ 4, 10, 10, 10, 1 /)
    296   integer, dimension(nfiles) , save :: flag_dtlw0        = (/ 4, 10, 10, 10, 10 /)
    297   integer, dimension(nfiles) , save :: flag_dtec         = (/ 4, 10, 10, 10, 10 /)
    298   integer, dimension(nfiles) , save :: flag_duvdf        = (/ 4, 10, 10, 10, 10 /)
    299   integer, dimension(nfiles) , save :: flag_dvvdf        = (/ 4, 10, 10, 10, 10 /)
    300   integer, dimension(nfiles) , save :: flag_duoro        = (/ 4, 10, 10, 10, 10 /)
    301   integer, dimension(nfiles) , save :: flag_dvoro        = (/ 4, 10, 10, 10, 10 /)
    302   integer, dimension(nfiles) , save :: flag_dulif        = (/ 4, 10, 10, 10, 10 /)
    303   integer, dimension(nfiles) , save :: flag_dvlif        = (/ 4, 10, 10, 10, 10 /)
    304   integer, dimension(nfiles) , save :: flag_trac         = (/ 4, 10, 10, 10, 10 /)
    305 
     345  type(ctrl_out),dimension(4) :: o_albe_srf     = (/ ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_ter'), &
     346                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_lic'), &
     347                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_oce'), &
     348                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'albe_sic') /)
     349
     350  type(ctrl_out),dimension(4) :: o_ages_srf     = (/ ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_ter'), &
     351                                                 ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_lic'), &
     352                                                 ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_oce'), &
     353                                                 ctrl_out((/ 3, 10, 10, 10, 10 /),'ages_sic') /)
     354
     355  type(ctrl_out),dimension(4) :: o_rugs_srf     = (/ ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_ter'), &
     356                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_lic'), &
     357                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_oce'), &
     358                                                 ctrl_out((/ 3, 4, 10, 1, 10 /),'rugs_sic') /)
     359
     360  type(ctrl_out) :: o_albs         = ctrl_out((/ 3, 10, 10, 1, 10 /),'albs')
     361  type(ctrl_out) :: o_albslw       = ctrl_out((/ 3, 10, 10, 1, 10 /),'albslw')
     362
     363  type(ctrl_out) :: o_clwcon       = ctrl_out((/ 4, 10, 10, 10, 10 /),'clwcon')
     364  type(ctrl_out) :: o_Ma           = ctrl_out((/ 4, 10, 10, 10, 10 /),'Ma')
     365  type(ctrl_out) :: o_dnwd         = ctrl_out((/ 4, 10, 10, 10, 10 /),'dnwd')
     366  type(ctrl_out) :: o_dnwd0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dnwd0')
     367  type(ctrl_out) :: o_dtdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtdyn')
     368  type(ctrl_out) :: o_dqdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dqdyn')
     369  type(ctrl_out) :: o_dudyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dudyn')  !AXC
     370  type(ctrl_out) :: o_dvdyn        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dvdyn')  !AXC
     371  type(ctrl_out) :: o_dtcon        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dtcon')
     372  type(ctrl_out) :: o_ducon        = ctrl_out((/ 4, 10, 10, 10, 10 /),'ducon')
     373  type(ctrl_out) :: o_dqcon        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dqcon')
     374  type(ctrl_out) :: o_dtwak        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dtwak')
     375  type(ctrl_out) :: o_dqwak        = ctrl_out((/ 4, 5, 10, 10, 10 /),'dqwak')
     376  type(ctrl_out) :: o_wake_h       = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_h')
     377  type(ctrl_out) :: o_wake_s       = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_s')
     378  type(ctrl_out) :: o_wake_deltat  = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_deltat')
     379  type(ctrl_out) :: o_wake_deltaq  = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_deltaq')
     380  type(ctrl_out) :: o_wake_omg     = ctrl_out((/ 4, 5, 10, 10, 10 /),'wake_omg')
     381  type(ctrl_out) :: o_Vprecip      = ctrl_out((/ 10, 10, 10, 10, 10 /),'Vprecip')
     382  type(ctrl_out) :: o_ftd          = ctrl_out((/ 4, 5, 10, 10, 10 /),'ftd')
     383  type(ctrl_out) :: o_fqd          = ctrl_out((/ 4, 5, 10, 10, 10 /),'fqd')
     384  type(ctrl_out) :: o_dtlsc        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlsc')
     385  type(ctrl_out) :: o_dtlschr      = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlschr')
     386  type(ctrl_out) :: o_dqlsc        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqlsc')
     387  type(ctrl_out) :: o_dtvdf        = ctrl_out((/ 4, 10, 10, 1, 10 /),'dtvdf')
     388  type(ctrl_out) :: o_dqvdf        = ctrl_out((/ 4, 10, 10, 1, 10 /),'dqvdf')
     389  type(ctrl_out) :: o_dteva        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dteva')
     390  type(ctrl_out) :: o_dqeva        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqeva')
     391  type(ctrl_out) :: o_ptconv       = ctrl_out((/ 4, 10, 10, 10, 10 /),'ptconv')
     392  type(ctrl_out) :: o_ratqs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'ratqs')
     393  type(ctrl_out) :: o_dtthe        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtthe')
     394  type(ctrl_out) :: o_f_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'f_th')
     395  type(ctrl_out) :: o_e_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'e_th')
     396  type(ctrl_out) :: o_w_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'w_th')
     397  type(ctrl_out) :: o_lambda_th    = ctrl_out((/ 4, 10, 10, 10, 10 /),'lambda_th')
     398  type(ctrl_out) :: o_q_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'q_th')
     399  type(ctrl_out) :: o_a_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'a_th')
     400  type(ctrl_out) :: o_d_th         = ctrl_out((/ 4, 10, 10, 10, 10 /),'d_th')
     401  type(ctrl_out) :: o_f0_th        = ctrl_out((/ 4, 10, 10, 10, 10 /),'f0_th')
     402  type(ctrl_out) :: o_zmax_th      = ctrl_out((/ 4, 10, 10, 10, 10 /),'zmax_th')
     403  type(ctrl_out) :: o_dqthe        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dqthe')
     404  type(ctrl_out) :: o_dtajs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtajs')
     405  type(ctrl_out) :: o_dqajs        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dqajs')
     406  type(ctrl_out) :: o_dtswr        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtswr')
     407  type(ctrl_out) :: o_dtsw0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtsw0')
     408  type(ctrl_out) :: o_dtlwr        = ctrl_out((/ 4, 10, 10, 10, 1 /),'dtlwr')
     409  type(ctrl_out) :: o_dtlw0        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtlw0')
     410  type(ctrl_out) :: o_dtec         = ctrl_out((/ 4, 10, 10, 10, 10 /),'dtec')
     411  type(ctrl_out) :: o_duvdf        = ctrl_out((/ 4, 10, 10, 10, 10 /),'duvdf')
     412  type(ctrl_out) :: o_dvvdf        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvvdf')
     413  type(ctrl_out) :: o_duoro        = ctrl_out((/ 4, 10, 10, 10, 10 /),'duoro')
     414  type(ctrl_out) :: o_dvoro        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvoro')
     415  type(ctrl_out) :: o_dulif        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dulif')
     416  type(ctrl_out) :: o_dvlif        = ctrl_out((/ 4, 10, 10, 10, 10 /),'dvlif')
     417
     418! Attention a refaire correctement
     419  type(ctrl_out),dimension(2) :: o_trac         = (/ ctrl_out((/ 4, 10, 10, 10, 10 /),'trac01'), &
     420                                                     ctrl_out((/ 4, 10, 10, 10, 10 /),'trac02') /)
    306421    CONTAINS
    307422
     
    338453  real, dimension(klev)                 :: presnivs
    339454  character(len=4), dimension(nlevSTD)  :: clevSTD
    340   integer                               :: nsrf, k, iq, iiq, iff, i, j
     455  integer                               :: nsrf, k, iq, iiq, iff, i, j, ilev
    341456  logical                               :: ok_veget
    342457  integer                               :: iflag_pbl
     
    355470!                 entre [lonmin_reg,lonmax_reg] et [latmin_reg,latmax_reg]
    356471
    357   logical, dimension(nfiles), save  :: ok_reglim         = (/ .false., .false., .false., .false., .true. /) 
     472  logical, dimension(nfiles), save  :: ok_reglim         = (/ .false., .false., .false., .false., .true. /)
    358473  real, dimension(nfiles), save     :: lonmin_reg        = (/ 0., -45., 0., 0., -162. /)
    359474  real, dimension(nfiles), save     :: lonmax_reg        = (/ 90., 45., 90., 90., -144. /)
     
    456571!     &                     nhorim, nid_hf3d)
    457572
    458 !         CALL histvert(nid_hf3d,"presnivs", &
    459 !     &                 "Vertical levels","mb", &
     573!         CALL histvert(nid_hf3d, "presnivs", &
     574!     &                 "Vertical levels", "mb", &
    460575!     &                 klev, presnivs/100., nvertm)
    461576!          ENDIF
    462577
    463578!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    464  CALL histdef2d(iff,flag_phis,"phis","Surface geop.height","m2/s2")
     579 CALL histdef2d(iff,o_phis%flag,o_phis%name,"Surface geop.height", "m2/s2")
    465580   type_ecri(1) = 'once'
    466581   type_ecri(2) = 'once'
    467582   type_ecri(3) = 'once'
    468583   type_ecri(4) = 'once'
    469  CALL histdef2d(iff,flag_aire,"aire","Grid area","-")
    470  CALL histdef2d(iff,flag_contfracATM,"contfracATM","% sfce ter+lic","-")
     584 CALL histdef2d(iff,o_aire%flag,o_aire%name,"Grid area", "-")
     585 CALL histdef2d(iff,o_contfracATM%flag,o_contfracATM%name,"% sfce ter+lic", "-")
    471586   type_ecri(1) = 'ave(X)'
    472587   type_ecri(2) = 'ave(X)'
     
    475590
    476591!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    477  CALL histdef2d(iff,flag_contfracOR,"contfracOR","% sfce terre OR","-" )
    478  CALL histdef2d(iff,flag_aireTER,"aireTER","Grid area CONT","-" )
    479  CALL histdef2d(iff,flag_flat,"flat","Latent heat flux","W/m2")
    480  CALL histdef2d(iff,flag_slp,"slp","Sea Level Pressure", "Pa" )
    481  CALL histdef2d(iff,flag_tsol,"tsol","Surface Temperature", "K")
    482  CALL histdef2d( iff,flag_t2m,"t2m","Temperature 2m", "K" )
    483  CALL histdef2d(iff,flag_t2m_min,"t2m_min","Temp 2m min", "K" )
    484  CALL histdef2d(iff,flag_t2m_max,"t2m_max", "Temp 2m max", "K" )
    485  CALL histdef2d(iff,flag_wind10m,"wind10m","10-m wind speed","m/s")
    486  CALL histdef2d(iff,flag_wind10max,"wind10max","10m wind speed max","m/s")
    487  CALL histdef2d(iff,flag_sicf,"sicf","Sea-ice fraction", "-" )
    488  CALL histdef2d(iff,flag_q2m,"q2m","Specific humidity 2m", "kg/kg")
    489  CALL histdef2d(iff,flag_u10m,"u10m","Vent zonal 10m", "m/s" )
    490  CALL histdef2d(iff,flag_v10m,"v10m","Vent meridien 10m", "m/s")
    491  CALL histdef2d(iff,flag_psol,"psol","Surface Pressure","Pa" )
    492  CALL histdef2d(iff,flag_qsurf,"qsurf","Surface Air humidity", "kg/kg")
     592 CALL histdef2d(iff,o_contfracOR%flag,o_contfracOR%name,"% sfce terre OR", "-" )
     593 CALL histdef2d(iff,o_aireTER%flag,o_aireTER%name,"Grid area CONT", "-" )
     594 CALL histdef2d(iff,o_flat%flag,o_flat%name, "Latent heat flux", "W/m2")
     595 CALL histdef2d(iff,o_slp%flag,o_slp%name, "Sea Level Pressure", "Pa" )
     596 CALL histdef2d(iff,o_tsol%flag,o_tsol%name, "Surface Temperature", "K")
     597 CALL histdef2d(iff,o_t2m%flag,o_t2m%name, "Temperature 2m", "K" )
     598 CALL histdef2d(iff,o_t2m_min%flag,o_t2m_min%name, "Temp 2m min", "K" )
     599 CALL histdef2d(iff,o_t2m_max%flag,o_t2m_max%name, "Temp 2m max", "K" )
     600 CALL histdef2d(iff,o_wind10m%flag,o_wind10m%name, "10-m wind speed", "m/s")
     601 CALL histdef2d(iff,o_wind10max%flag,o_wind10max%name, "10m wind speed max", "m/s")
     602 CALL histdef2d(iff,o_sicf%flag,o_sicf%name, "Sea-ice fraction", "-" )
     603 CALL histdef2d(iff,o_q2m%flag,o_q2m%name, "Specific humidity 2m", "kg/kg")
     604 CALL histdef2d(iff,o_u10m%flag,o_u10m%name, "Vent zonal 10m", "m/s" )
     605 CALL histdef2d(iff,o_v10m%flag,o_v10m%name, "Vent meridien 10m", "m/s")
     606 CALL histdef2d(iff,o_psol%flag,o_psol%name, "Surface Pressure", "Pa" )
     607 CALL histdef2d(iff,o_qsurf%flag,o_qsurf%name, "Surface Air humidity", "kg/kg")
    493608
    494609  if (.not. ok_veget) then
    495  CALL histdef2d(iff,flag_qsol,"qsol","Soil watter content", "mm" )
     610 CALL histdef2d(iff,o_qsol%flag,o_qsol%name, "Soil watter content", "mm" )
    496611  endif
    497612
    498  CALL histdef2d(iff,flag_ndayrain,"ndayrain","Number of dayrain(liq+sol)","-")
    499  CALL histdef2d(iff,flag_precip,"precip","Precip Totale liq+sol","kg/(s*m2)" )
    500  CALL histdef2d(iff,flag_plul,"plul","Large-scale Precip.","kg/(s*m2)")
    501  CALL histdef2d(iff,flag_pluc,"pluc","Convective Precip.","kg/(s*m2)")
    502  CALL histdef2d(iff,flag_snow,"snow","Snow fall","kg/(s*m2)" )
    503  CALL histdef2d(iff,flag_evap,"evap","Evaporat", "kg/(s*m2)" )
    504  CALL histdef2d(iff,flag_tops,"tops","Solar rad. at TOA","W/m2")
    505  CALL histdef2d(iff,flag_tops0,"tops0","CS Solar rad. at TOA", "W/m2")
    506  CALL histdef2d(iff,flag_topl,"topl","IR rad. at TOA", "W/m2" )
    507  CALL histdef2d(iff,flag_topl0,"topl0", "IR rad. at TOA","W/m2")
    508  CALL histdef2d(iff,flag_SWupTOA,"SWupTOA","SWup at TOA","W/m2")
    509  CALL histdef2d(iff,flag_SWupTOAclr,"SWupTOAclr","SWup clear sky at TOA","W/m2")
    510  CALL histdef2d(iff,flag_SWdnTOA, "SWdnTOA","SWdn at TOA","W/m2" )
    511  CALL histdef2d(iff,flag_SWdnTOAclr,"SWdnTOAclr","SWdn clear sky at TOA","W/m2")
    512  CALL histdef2d(iff,flag_SWup200,"SWup200","SWup at 200mb","W/m2" )
    513  CALL histdef2d(iff,flag_SWup200clr,"SWup200clr","SWup clear sky at 200mb","W/m2")
    514  CALL histdef2d(iff,flag_SWdn200,"SWdn200","SWdn at 200mb","W/m2" )
    515  CALL histdef2d(iff,flag_SWdn200clr,"SWdn200clr","SWdn clear sky at 200mb","W/m2")
    516  CALL histdef2d(iff,flag_LWup200,"LWup200","LWup at 200mb","W/m2")
    517  CALL histdef2d(iff,flag_LWup200clr, "LWup200clr","LWup clear sky at 200mb","W/m2")
    518  CALL histdef2d(iff,flag_LWdn200,"LWdn200","LWdn at 200mb","W/m2")
    519  CALL histdef2d(iff,flag_LWdn200clr, "LWdn200clr","LWdn clear sky at 200mb","W/m2")
    520  CALL histdef2d(iff,flag_sols,"sols","Solar rad. at surf.","W/m2")
    521  CALL histdef2d(iff,flag_sols0,"sols0","Solar rad. at surf.","W/m2")
    522  CALL histdef2d(iff,flag_soll,"soll","IR rad. at surface","W/m2") 
    523  CALL histdef2d(iff,flag_radsol,"radsol","Rayonnement au sol","W/m2")
    524  CALL histdef2d(iff,flag_soll0,"soll0","IR rad. at surface","W/m2")
    525  CALL histdef2d(iff,flag_SWupSFC,"SWupSFC","SWup at surface","W/m2")
    526  CALL histdef2d(iff,flag_SWupSFCclr,"SWupSFCclr","SWup clear sky at surface","W/m2")
    527  CALL histdef2d(iff,flag_SWdnSFC,"SWdnSFC","SWdn at surface","W/m2")
    528  CALL histdef2d(iff,flag_SWdnSFCclr,"SWdnSFCclr","SWdn clear sky at surface","W/m2")
    529  CALL histdef2d(iff,flag_LWupSFC,"LWupSFC","Upwd. IR rad. at surface","W/m2")
    530  CALL histdef2d(iff,flag_LWdnSFC,"LWdnSFC","Down. IR rad. at surface","W/m2")
    531  CALL histdef2d(iff,flag_LWupSFCclr,"LWupSFCclr","CS Upwd. IR rad. at surface","W/m2")
    532  CALL histdef2d(iff,flag_LWdnSFCclr,"LWdnSFCclr","Down. CS IR rad. at surface","W/m2")
    533  CALL histdef2d(iff,flag_bils,"bils","Surf. total heat flux","W/m2")
    534  CALL histdef2d(iff,flag_sens,"sens","Sensible heat flux","W/m2")
    535  CALL histdef2d(iff,flag_fder,"fder","Heat flux derivation","W/m2")
    536  CALL histdef2d(iff,flag_ffonte,"ffonte","Thermal flux for snow melting","W/m2")
    537  CALL histdef2d(iff,flag_fqcalving,"fqcalving","Ice Calving","kg/m2/s")
    538  CALL histdef2d(iff,flag_fqfonte,"fqfonte","Land ice melt","kg/m2/s")
     613 CALL histdef2d(iff,o_ndayrain%flag,o_ndayrain%name, "Number of dayrain(liq+sol)", "-")
     614 CALL histdef2d(iff,o_precip%flag,o_precip%name, "Precip Totale liq+sol", "kg/(s*m2)" )
     615 CALL histdef2d(iff,o_plul%flag,o_plul%name, "Large-scale Precip.", "kg/(s*m2)")
     616 CALL histdef2d(iff,o_pluc%flag,o_pluc%name, "Convective Precip.", "kg/(s*m2)")
     617 CALL histdef2d(iff,o_snow%flag,o_snow%name, "Snow fall", "kg/(s*m2)" )
     618 CALL histdef2d(iff,o_evap%flag,o_evap%name, "Evaporat", "kg/(s*m2)" )
     619 CALL histdef2d(iff,o_tops%flag,o_tops%name, "Solar rad. at TOA", "W/m2")
     620 CALL histdef2d(iff,o_tops0%flag,o_tops0%name, "CS Solar rad. at TOA", "W/m2")
     621 CALL histdef2d(iff,o_topl%flag,o_topl%name, "IR rad. at TOA", "W/m2" )
     622 CALL histdef2d(iff,o_topl0%flag,o_topl0%name, "IR rad. at TOA", "W/m2")
     623 CALL histdef2d(iff,o_SWupTOA%flag,o_SWupTOA%name, "SWup at TOA", "W/m2")
     624 CALL histdef2d(iff,o_SWupTOAclr%flag,o_SWupTOAclr%name, "SWup clear sky at TOA", "W/m2")
     625 CALL histdef2d(iff,o_SWdnTOA%flag,o_SWdnTOA%name, "SWdn at TOA", "W/m2" )
     626 CALL histdef2d(iff,o_SWdnTOAclr%flag,o_SWdnTOAclr%name, "SWdn clear sky at TOA", "W/m2")
     627 CALL histdef2d(iff,o_SWup200%flag,o_SWup200%name, "SWup at 200mb", "W/m2" )
     628 CALL histdef2d(iff,o_SWup200clr%flag,o_SWup200clr%name, "SWup clear sky at 200mb", "W/m2")
     629 CALL histdef2d(iff,o_SWdn200%flag,o_SWdn200%name, "SWdn at 200mb", "W/m2" )
     630 CALL histdef2d(iff,o_SWdn200clr%flag,o_SWdn200clr%name, "SWdn clear sky at 200mb", "W/m2")
     631 CALL histdef2d(iff,o_LWup200%flag,o_LWup200%name, "LWup at 200mb", "W/m2")
     632 CALL histdef2d(iff,o_LWup200clr%flag,o_LWup200clr%name, "LWup clear sky at 200mb", "W/m2")
     633 CALL histdef2d(iff,o_LWdn200%flag,o_LWdn200%name, "LWdn at 200mb", "W/m2")
     634 CALL histdef2d(iff,o_LWdn200clr%flag,o_LWdn200clr%name, "LWdn clear sky at 200mb", "W/m2")
     635 CALL histdef2d(iff,o_sols%flag,o_sols%name, "Solar rad. at surf.", "W/m2")
     636 CALL histdef2d(iff,o_sols0%flag,o_sols0%name, "Solar rad. at surf.", "W/m2")
     637 CALL histdef2d(iff,o_soll%flag,o_soll%name, "IR rad. at surface", "W/m2") 
     638 CALL histdef2d(iff,o_radsol%flag,o_radsol%name, "Rayonnement au sol", "W/m2")
     639 CALL histdef2d(iff,o_soll0%flag,o_soll0%name, "IR rad. at surface", "W/m2")
     640 CALL histdef2d(iff,o_SWupSFC%flag,o_SWupSFC%name, "SWup at surface", "W/m2")
     641 CALL histdef2d(iff,o_SWupSFCclr%flag,o_SWupSFCclr%name, "SWup clear sky at surface", "W/m2")
     642 CALL histdef2d(iff,o_SWdnSFC%flag,o_SWdnSFC%name, "SWdn at surface", "W/m2")
     643 CALL histdef2d(iff,o_SWdnSFCclr%flag,o_SWdnSFCclr%name, "SWdn clear sky at surface", "W/m2")
     644 CALL histdef2d(iff,o_LWupSFC%flag,o_LWupSFC%name, "Upwd. IR rad. at surface", "W/m2")
     645 CALL histdef2d(iff,o_LWdnSFC%flag,o_LWdnSFC%name, "Down. IR rad. at surface", "W/m2")
     646 CALL histdef2d(iff,o_LWupSFCclr%flag,o_LWupSFCclr%name, "CS Upwd. IR rad. at surface", "W/m2")
     647 CALL histdef2d(iff,o_LWdnSFCclr%flag,o_LWdnSFCclr%name, "Down. CS IR rad. at surface", "W/m2")
     648 CALL histdef2d(iff,o_bils%flag,o_bils%name, "Surf. total heat flux", "W/m2")
     649 CALL histdef2d(iff,o_sens%flag,o_sens%name, "Sensible heat flux", "W/m2")
     650 CALL histdef2d(iff,o_fder%flag,o_fder%name, "Heat flux derivation", "W/m2")
     651 CALL histdef2d(iff,o_ffonte%flag,o_ffonte%name, "Thermal flux for snow melting", "W/m2")
     652 CALL histdef2d(iff,o_fqcalving%flag,o_fqcalving%name, "Ice Calving", "kg/m2/s")
     653 CALL histdef2d(iff,o_fqfonte%flag,o_fqfonte%name, "Land ice melt", "kg/m2/s")
    539654
    540655     DO nsrf = 1, nbsrf
    541  CALL histdef2d(iff,flag_pourc_sol,"pourc_"//clnsurf(nsrf),"% "//clnsurf(nsrf),"%")
    542  CALL histdef2d(iff,flag_fract_sol,"fract_"//clnsurf(nsrf),"Fraction "//clnsurf(nsrf),"1")
    543  CALL histdef2d(iff,flag_taux_sol,"taux_"//clnsurf(nsrf),"Zonal wind stress"//clnsurf(nsrf),"Pa")
    544  CALL histdef2d(iff,flag_tauy_sol,"tauy_"//clnsurf(nsrf),"Meridional wind stress "//clnsurf(nsrf),"Pa")
    545  CALL histdef2d(iff,flag_tsol_sol,"tsol_"//clnsurf(nsrf),"Temperature "//clnsurf(nsrf),"K")
    546  CALL histdef2d(iff,flag_u10m_sol,"u10m_"//clnsurf(nsrf),"Vent Zonal 10m "//clnsurf(nsrf),"m/s")
    547  CALL histdef2d(iff,flag_v10m_sol,"v10m_"//clnsurf(nsrf),"Vent meredien 10m "//clnsurf(nsrf),"m/s")
    548  CALL histdef2d(iff,flag_t2m_sol,"t2m_"//clnsurf(nsrf),"Temp 2m "//clnsurf(nsrf),"K")
    549  CALL histdef2d(iff,flag_sens_sol,"sens_"//clnsurf(nsrf),"Sensible heat flux "//clnsurf(nsrf),"W/m2")
    550  CALL histdef2d(iff,flag_lat_sol,"lat_"//clnsurf(nsrf),"Latent heat flux "//clnsurf(nsrf),"W/m2")
    551  CALL histdef2d(iff,flag_flw_sol,"flw_"//clnsurf(nsrf),"LW "//clnsurf(nsrf),"W/m2")
    552  CALL histdef2d(iff,flag_fsw_sol,"fsw_"//clnsurf(nsrf),"SW "//clnsurf(nsrf),"W/m2")
    553  CALL histdef2d(iff,flag_wbils_sol,"wbils_"//clnsurf(nsrf),"Bilan sol "//clnsurf(nsrf),"W/m2" )
    554  CALL histdef2d(iff,flag_wbilo_sol,"wbilo_"//clnsurf(nsrf),"Bilan eau "//clnsurf(nsrf),"kg/(m2*s)")
     656 CALL histdef2d(iff,o_pourc_srf(nsrf)%flag,o_pourc_srf(nsrf)%name,"% "//clnsurf(nsrf),"%")
     657 CALL histdef2d(iff,o_fract_srf(nsrf)%flag,o_fract_srf(nsrf)%name,"Fraction "//clnsurf(nsrf),"1")
     658 CALL histdef2d(iff,o_taux_srf(nsrf)%flag,o_taux_srf(nsrf)%name,"Zonal wind stress"//clnsurf(nsrf),"Pa")
     659 CALL histdef2d(iff,o_tauy_srf(nsrf)%flag,o_tauy_srf(nsrf)%name,"Meridional wind stress "//clnsurf(nsrf),"Pa")
     660 CALL histdef2d(iff,o_tsol_srf(nsrf)%flag,o_tsol_srf(nsrf)%name,"Temperature "//clnsurf(nsrf),"K")
     661 CALL histdef2d(iff,o_u10m_srf(nsrf)%flag,o_u10m_srf(nsrf)%name,"Vent Zonal 10m "//clnsurf(nsrf),"m/s")
     662 CALL histdef2d(iff,o_v10m_srf(nsrf)%flag,o_v10m_srf(nsrf)%name,"Vent meredien 10m "//clnsurf(nsrf),"m/s")
     663 CALL histdef2d(iff,o_t2m_srf(nsrf)%flag,o_t2m_srf(nsrf)%name,"Temp 2m "//clnsurf(nsrf),"K")
     664 CALL histdef2d(iff,o_sens_srf(nsrf)%flag,o_sens_srf(nsrf)%name,"Sensible heat flux "//clnsurf(nsrf),"W/m2")
     665 CALL histdef2d(iff,o_lat_srf(nsrf)%flag,o_lat_srf(nsrf)%name,"Latent heat flux "//clnsurf(nsrf),"W/m2")
     666 CALL histdef2d(iff,o_flw_srf(nsrf)%flag,o_flw_srf(nsrf)%name,"LW "//clnsurf(nsrf),"W/m2")
     667 CALL histdef2d(iff,o_fsw_srf(nsrf)%flag,o_fsw_srf(nsrf)%name,"SW "//clnsurf(nsrf),"W/m2")
     668 CALL histdef2d(iff,o_wbils_srf(nsrf)%flag,o_wbils_srf(nsrf)%name,"Bilan sol "//clnsurf(nsrf),"W/m2" )
     669 CALL histdef2d(iff,o_wbilo_srf(nsrf)%flag,o_wbilo_srf(nsrf)%name,"Bilan eau "//clnsurf(nsrf),"kg/(m2*s)")
    555670  if (iflag_pbl>1 .and. lev_files(iff).gt.10 ) then
    556  CALL histdef2d(iff,flag_tke_sol,"tke_"//clnsurf(nsrf),"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
    557  CALL histdef2d(iff,flag_tke_max_sol,"tke_max_"//clnsurf(nsrf),"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
     671 CALL histdef2d(iff,o_tke_srf(nsrf)%flag,o_tke_srf(nsrf)%name,"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
     672 CALL histdef2d(iff,o_tke_max_srf(nsrf)%flag,o_tke_max_srf(nsrf)%name,"Max Turb. Kinetic Energy "//clnsurf(nsrf),"-")
    558673  endif
    559  CALL histdef2d(iff,flag_albe_sol, "albe_"//clnsurf(nsrf),"Albedo surf. "//clnsurf(nsrf),"-")
    560  CALL histdef2d(iff,flag_rugs_sol,"rugs_"//clnsurf(nsrf),"Latent heat flux "//clnsurf(nsrf),"W/m2")
    561  CALL histdef2d(iff,flag_ages_sol,"ages_"//clnsurf(nsrf),"Snow age","day")
     674 CALL histdef2d(iff,o_albe_srf(nsrf)%flag,o_albe_srf(nsrf)%name,"Albedo surf. "//clnsurf(nsrf),"-")
     675 CALL histdef2d(iff,o_rugs_srf(nsrf)%flag,o_rugs_srf(nsrf)%name,"Latent heat flux "//clnsurf(nsrf),"W/m2")
     676 CALL histdef2d(iff,o_ages_srf(nsrf)%flag,o_ages_srf(nsrf)%name,"Snow age", "day")
    562677     END DO
    563678
    564  CALL histdef2d(iff,flag_albs,"albs","Surface albedo","-")
    565  CALL histdef2d(iff,flag_albslw,"albslw","Surface albedo LW","-")
    566  CALL histdef2d(iff,flag_cdrm,"cdrm","Momentum drag coef.", "-")
    567  CALL histdef2d(iff,flag_cdrh,"cdrh","Heat drag coef.", "-" )
    568  CALL histdef2d(iff,flag_cldl,"cldl","Low-level cloudiness", "-")
    569  CALL histdef2d(iff,flag_cldm,"cldm","Mid-level cloudiness", "-")
    570  CALL histdef2d(iff,flag_cldh,"cldh","High-level cloudiness", "-")
    571  CALL histdef2d(iff,flag_cldt,"cldt","Total cloudiness","%")
    572  CALL histdef2d(iff,flag_cldq,"cldq","Cloud liquid water path","kg/m2")
    573  CALL histdef2d(iff,flag_lwp,"lwp","Cloud water path","kg/m2")
    574  CALL histdef2d(iff,flag_iwp,"iwp","Cloud ice water path","kg/m2" )
    575  CALL histdef2d(iff,flag_ue,"ue","Zonal energy transport","-")
    576  CALL histdef2d(iff,flag_ve,"ve","Merid energy transport", "-")
    577  CALL histdef2d(iff,flag_uq,"uq","Zonal humidity transport", "-")
    578  CALL histdef2d(iff,flag_vq,"vq","Merid humidity transport", "-")
     679 CALL histdef2d(iff,o_albs%flag,o_albs%name, "Surface albedo", "-")
     680 CALL histdef2d(iff,o_albslw%flag,o_albslw%name, "Surface albedo LW", "-")
     681 CALL histdef2d(iff,o_cdrm%flag,o_cdrm%name, "Momentum drag coef.", "-")
     682 CALL histdef2d(iff,o_cdrh%flag,o_cdrh%name, "Heat drag coef.", "-" )
     683 CALL histdef2d(iff,o_cldl%flag,o_cldl%name, "Low-level cloudiness", "-")
     684 CALL histdef2d(iff,o_cldm%flag,o_cldm%name, "Mid-level cloudiness", "-")
     685 CALL histdef2d(iff,o_cldh%flag,o_cldh%name, "High-level cloudiness", "-")
     686 CALL histdef2d(iff,o_cldt%flag,o_cldt%name, "Total cloudiness", "%")
     687 CALL histdef2d(iff,o_cldq%flag,o_cldq%name, "Cloud liquid water path", "kg/m2")
     688 CALL histdef2d(iff,o_lwp%flag,o_lwp%name, "Cloud water path", "kg/m2")
     689 CALL histdef2d(iff,o_iwp%flag,o_iwp%name, "Cloud ice water path", "kg/m2" )
     690 CALL histdef2d(iff,o_ue%flag,o_ue%name, "Zonal energy transport", "-")
     691 CALL histdef2d(iff,o_ve%flag,o_ve%name, "Merid energy transport", "-")
     692 CALL histdef2d(iff,o_uq%flag,o_uq%name, "Zonal humidity transport", "-")
     693 CALL histdef2d(iff,o_vq%flag,o_vq%name, "Merid humidity transport", "-")
    579694
    580695     IF(iflag_con.GE.3) THEN ! sb
    581  CALL histdef2d(iff,flag_cape,"cape","Conv avlbl pot ener","J/kg")
    582  CALL histdef2d(iff,flag_pbase,"pbase","Cld base pressure", "mb")
    583  CALL histdef2d(iff,flag_ptop,"ptop","Cld top pressure", "mb")
    584  CALL histdef2d(iff,flag_fbase,"fbase","Cld base mass flux","kg/m2/s")
    585  CALL histdef2d(iff,flag_prw,"prw","Precipitable water","kg/m2")
     696 CALL histdef2d(iff,o_cape%flag,o_cape%name, "Conv avlbl pot ener", "J/kg")
     697 CALL histdef2d(iff,o_pbase%flag,o_pbase%name, "Cld base pressure", "mb")
     698 CALL histdef2d(iff,o_ptop%flag,o_ptop%name, "Cld top pressure", "mb")
     699 CALL histdef2d(iff,o_fbase%flag,o_fbase%name, "Cld base mass flux", "kg/m2/s")
     700 CALL histdef2d(iff,o_prw%flag,o_prw%name, "Precipitable water", "kg/m2")
    586701     ENDIF !iflag_con .GE. 3
    587702
    588  CALL histdef2d(iff,flag_s_pblh,"s_pblh","Boundary Layer Height","m")
    589  CALL histdef2d(iff,flag_s_pblt,"s_pblt","t at Boundary Layer Height","K")
    590  CALL histdef2d(iff,flag_s_lcl,"s_lcl","Condensation level","m")
    591  CALL histdef2d(iff,flag_s_capCL,"s_capCL","Conv avlbl pot enerfor ABL", "J/m2" )
    592  CALL histdef2d(iff,flag_s_oliqCL,"s_oliqCL","Liq Water in BL","kg/m2")
    593  CALL histdef2d(iff,flag_s_cteiCL,"s_cteiCL","Instability criteria(ABL)","K")
    594  CALL histdef2d(iff,flag_s_therm,"s_therm","Exces du thermique", "K")
    595  CALL histdef2d(iff,flag_s_trmb1,"s_trmb1","deep_cape(HBTM2)","J/m2")
    596  CALL histdef2d(iff,flag_s_trmb2,"s_trmb2","inhibition (HBTM2)","J/m2")
    597  CALL histdef2d(iff,flag_s_trmb3,"s_trmb3","Point Omega (HBTM2)","m")
     703 CALL histdef2d(iff,o_s_pblh%flag,o_s_pblh%name, "Boundary Layer Height", "m")
     704 CALL histdef2d(iff,o_s_pblt%flag,o_s_pblt%name, "t at Boundary Layer Height", "K")
     705 CALL histdef2d(iff,o_s_lcl%flag,o_s_lcl%name, "Condensation level", "m")
     706 CALL histdef2d(iff,o_s_capCL%flag,o_s_capCL%name, "Conv avlbl pot enerfor ABL", "J/m2" )
     707 CALL histdef2d(iff,o_s_oliqCL%flag,o_s_oliqCL%name, "Liq Water in BL", "kg/m2")
     708 CALL histdef2d(iff,o_s_cteiCL%flag,o_s_cteiCL%name, "Instability criteria(ABL)", "K")
     709 CALL histdef2d(iff,o_s_therm%flag,o_s_therm%name, "Exces du thermique", "K")
     710 CALL histdef2d(iff,o_s_trmb1%flag,o_s_trmb1%name, "deep_cape(HBTM2)", "J/m2")
     711 CALL histdef2d(iff,o_s_trmb2%flag,o_s_trmb2%name, "inhibition (HBTM2)", "J/m2")
     712 CALL histdef2d(iff,o_s_trmb3%flag,o_s_trmb3%name, "Point Omega (HBTM2)", "m")
    598713
    599714! Champs interpolles sur des niveaux de pression
     
    609724   type_ecri(3) = 'inst(X)'
    610725   type_ecri(4) = 'inst(X)'
     726
     727! Attention a reverifier
     728
     729        ilev=0       
    611730        DO k=1, nlevSTD
    612731     IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
    613      IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
     732!     IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
    614733     IF(bb2.EQ."850".OR.bb2.EQ."700".OR.bb2.EQ."500".OR.bb2.EQ."200")THEN
    615  CALL histdef2d(iff,flag_ulevsSTD,"u"//bb2,"Zonal wind "//bb2//"mb","m/s")
    616  CALL histdef2d(iff,flag_vlevsSTD,"v"//bb2,"Meridional wind "//bb2//"mb","m/s")
    617  CALL histdef2d(iff,flag_wlevsSTD,"w"//bb2,"Vertical wind "//bb2//"mb","m/s")
    618  CALL histdef2d(iff,flag_philevsSTD,"phi"//bb2,"Geopotential "//bb2//"mb","m")
    619  CALL histdef2d(iff,flag_qlevsSTD,"q"//bb2,"Specific humidity "//bb2//"mb","kg/kg" )
    620  CALL histdef2d(iff,flag_tlevsSTD,"t"//bb2,"Temperature "//bb2//"mb","K")
    621      ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
     734      ilev=ilev+1
     735      print*,'ilev bb2 flag name ',ilev,bb2,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name
     736 CALL histdef2d(iff,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name,"Zonal wind "//bb2//"mb", "m/s")
     737 CALL histdef2d(iff,o_vSTDlevs(ilev)%flag,o_vSTDlevs(ilev)%name,"Meridional wind "//bb2//"mb", "m/s")
     738 CALL histdef2d(iff,o_wSTDlevs(ilev)%flag,o_wSTDlevs(ilev)%name,"Vertical wind "//bb2//"mb", "Pa/s")
     739 CALL histdef2d(iff,o_phiSTDlevs(ilev)%flag,o_phiSTDlevs(ilev)%name,"Geopotential "//bb2//"mb", "m")
     740 CALL histdef2d(iff,o_qSTDlevs(ilev)%flag,o_qSTDlevs(ilev)%name,"Specific humidity "//bb2//"mb", "kg/kg" )
     741 CALL histdef2d(iff,o_tSTDlevs(ilev)%flag,o_tSTDlevs(ilev)%name,"Temperature "//bb2//"mb", "K")
     742     ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR."500".OR.bb2.EQ."200")
    622743       ENDDO
    623744   zstophym(iff) = dtime
     
    627748   type_ecri(4) = 'inst(X)'
    628749
    629  CALL histdef2d(iff,flag_t_oce_sic,"t_oce_sic","Temp mixte oce-sic","K")
     750 CALL histdef2d(iff,o_t_oce_sic%flag,o_t_oce_sic%name, "Temp mixte oce-sic", "K")
    630751
    631752 IF (ocean=='slab') &
    632       CALL histdef2d(iff,flag_slab_bils, "slab_wbils_oce","Bilan au sol sur ocean slab", "W/m2")
     753     CALL histdef2d(iff,o_slab_bils%flag, o_slab_bils%name,"Bilan au sol sur ocean slab", "W/m2")
    633754
    634755 IF (iflag_con.GE.3) THEN
    635  CALL histdef2d(iff,flag_ale_bl,"ale_bl","ALE BL","m2/s2")
    636  CALL histdef2d(iff,flag_alp_bl,"alp_bl","ALP BL","m2/s2")
    637  CALL histdef2d(iff,flag_ale_wk,"ale_wk","ALE WK","m2/s2")
    638  CALL histdef2d(iff,flag_alp_wk,"alp_wk","ALP WK","m2/s2")
    639 
    640  CALL histdef2d(iff,flag_ale,"ale","ALE","m2/s2")
    641  CALL histdef2d(iff,flag_alp,"alp","ALP","W/m2")
    642  CALL histdef2d(iff,flag_cin,"cin","Convective INhibition","m2/s2")
    643  CALL histdef2d(iff,flag_wape,"WAPE","WAPE","m2/s2")
     756 CALL histdef2d(iff,o_ale_bl%flag,o_ale_bl%name, "ALE BL", "m2/s2")
     757 CALL histdef2d(iff,o_alp_bl%flag,o_alp_bl%name, "ALP BL", "m2/s2")
     758 CALL histdef2d(iff,o_ale_wk%flag,o_ale_wk%name, "ALE WK", "m2/s2")
     759 CALL histdef2d(iff,o_alp_wk%flag,o_alp_wk%name, "ALP WK", "m2/s2")
     760
     761 CALL histdef2d(iff,o_ale%flag,o_ale%name, "ALE", "m2/s2")
     762 CALL histdef2d(iff,o_alp%flag,o_alp%name, "ALP", "W/m2")
     763 CALL histdef2d(iff,o_cin%flag,o_cin%name, "Convective INhibition", "m2/s2")
     764 CALL histdef2d(iff,o_wape%flag,o_WAPE%name, "WAPE", "m2/s2")
    644765 ENDIF !(iflag_con.GE.3)
    645766
    646  CALL histdef2d(iff,flag_weakinv, "weakinv","Weak inversion", "-")
    647  CALL histdef2d(iff,flag_dthmin,"dthmin","dTheta mini", "K/m")
    648  CALL histdef2d(iff,flag_rh2m,"rh2m","Relative humidity at 2m", "%" )
    649  CALL histdef2d(iff,flag_qsat2m,"qsat2m","Saturant humidity at 2m", "%")
    650  CALL histdef2d(iff,flag_tpot,"tpot","Surface air potential temperature","K")
    651  CALL histdef2d(iff,flag_tpote,"tpote","Surface air equivalent potential temperature","K")
    652  CALL histdef2d(iff,flag_SWnetOR,"SWnetOR","Sfce net SW radiation OR", "W/m2")
    653  CALL histdef2d(iff,flag_SWdownOR,"SWdownOR","Sfce incident SW radiation OR","W/m2")
    654  CALL histdef2d(iff,flag_LWdownOR,"LWdownOR","Sfce incident LW radiation OR","W/m2")
    655  CALL histdef2d(iff,flag_snowl,"snowl","Solid Large-scale Precip.","kg/(m2*s)")
     767 CALL histdef2d(iff,o_weakinv%flag,o_weakinv%name, "Weak inversion", "-")
     768 CALL histdef2d(iff,o_dthmin%flag,o_dthmin%name, "dTheta mini", "K/m")
     769 CALL histdef2d(iff,o_rh2m%flag,o_rh2m%name, "Relative humidity at 2m", "%" )
     770 CALL histdef2d(iff,o_qsat2m%flag,o_qsat2m%name, "Saturant humidity at 2m", "%")
     771 CALL histdef2d(iff,o_tpot%flag,o_tpot%name, "Surface air potential temperature", "K")
     772 CALL histdef2d(iff,o_tpote%flag,o_tpote%name, "Surface air equivalent potential temperature", "K")
     773 CALL histdef2d(iff,o_SWnetOR%flag,o_SWnetOR%name, "Sfce net SW radiation OR", "W/m2")
     774 CALL histdef2d(iff,o_SWdownOR%flag,o_SWdownOR%name, "Sfce incident SW radiation OR", "W/m2")
     775 CALL histdef2d(iff,o_LWdownOR%flag,o_LWdownOR%name, "Sfce incident LW radiation OR", "W/m2")
     776 CALL histdef2d(iff,o_snowl%flag,o_snowl%name, "Solid Large-scale Precip.", "kg/(m2*s)")
    656777 IF (iflag_con.GE.3) THEN
    657  CALL histdef2d(iff,flag_cape_max,"cape_max","CAPE max.", "J/kg")
     778 CALL histdef2d(iff,o_cape_max%flag,o_cape_max%name, "CAPE max.", "J/kg")
    658779 ENDIF !(iflag_con.GE.3)
    659  CALL histdef2d(iff,flag_solldown,"solldown","Down. IR rad. at surface","W/m2")
    660  CALL histdef2d(iff,flag_dtsvdfo,"dtsvdfo","Boundary-layer dTs(o)","K/s")
    661  CALL histdef2d(iff,flag_dtsvdft,"dtsvdft","Boundary-layer dTs(t)","K/s")
    662  CALL histdef2d(iff,flag_dtsvdfg,"dtsvdfg","Boundary-layer dTs(g)","K/s")
    663  CALL histdef2d(iff,flag_dtsvdfi,"dtsvdfi","Boundary-layer dTs(g)","K/s")
    664  CALL histdef2d(iff,flag_rugs,"rugs","rugosity", "-" )
     780 CALL histdef2d(iff,o_solldown%flag,o_solldown%name, "Down. IR rad. at surface", "W/m2")
     781 CALL histdef2d(iff,o_dtsvdfo%flag,o_dtsvdfo%name, "Boundary-layer dTs(o)", "K/s")
     782 CALL histdef2d(iff,o_dtsvdft%flag,o_dtsvdft%name, "Boundary-layer dTs(t)", "K/s")
     783 CALL histdef2d(iff,o_dtsvdfg%flag,o_dtsvdfg%name, "Boundary-layer dTs(g)", "K/s")
     784 CALL histdef2d(iff,o_dtsvdfi%flag,o_dtsvdfi%name, "Boundary-layer dTs(g)", "K/s")
     785 CALL histdef2d(iff,o_rugs%flag,o_rugs%name, "rugosity", "-" )
    665786
    666787! Champs 3D:
    667  CALL histdef3d(iff,flag_lwcon,"lwcon","Cloud liquid water content","kg/kg")
    668  CALL histdef3d(iff,flag_iwcon,"iwcon","Cloud ice water content","kg/kg")
    669  CALL histdef3d(iff,flag_temp,"temp","Air temperature","K" )
    670  CALL histdef3d(iff,flag_theta,"theta","Potential air temperature","K" )
    671  CALL histdef3d(iff,flag_ovap,"ovap","Specific humidity","kg/kg" )
    672  CALL histdef3d(iff,flag_geop,"geop","Geopotential height","m2/s2")
    673  CALL histdef3d(iff,flag_vitu,"vitu","Zonal wind", "m/s" )
    674  CALL histdef3d(iff,flag_vitv,"vitv","Meridional wind","m/s" )
    675  CALL histdef3d(iff,flag_vitw,"vitw","Vertical wind","Pa/s" )
    676  CALL histdef3d(iff,flag_pres,"pres","Air pressure", "Pa" )
    677  CALL histdef3d(iff,flag_rneb,"rneb","Cloud fraction","-")
    678  CALL histdef3d(iff,flag_rnebcon,"rnebcon","Convective Cloud Fraction","-")
    679  CALL histdef3d(iff,flag_rhum,"rhum","Relative humidity","-")
    680  CALL histdef3d(iff,flag_ozone,"ozone","Ozone concentration", "ppmv")
     788 CALL histdef3d(iff,o_lwcon%flag,o_lwcon%name, "Cloud liquid water content", "kg/kg")
     789 CALL histdef3d(iff,o_iwcon%flag,o_iwcon%name, "Cloud ice water content", "kg/kg")
     790 CALL histdef3d(iff,o_temp%flag,o_temp%name, "Air temperature", "K" )
     791 CALL histdef3d(iff,o_theta%flag,o_theta%name, "Potential air temperature", "K" )
     792 CALL histdef3d(iff,o_ovap%flag,o_ovap%name, "Specific humidity", "kg/kg" )
     793 CALL histdef3d(iff,o_geop%flag,o_geop%name, "Geopotential height", "m2/s2")
     794 CALL histdef3d(iff,o_vitu%flag,o_vitu%name, "Zonal wind", "m/s" )
     795 CALL histdef3d(iff,o_vitv%flag,o_vitv%name, "Meridional wind", "m/s" )
     796 CALL histdef3d(iff,o_vitw%flag,o_vitw%name, "Vertical wind", "Pa/s" )
     797 CALL histdef3d(iff,o_pres%flag,o_pres%name, "Air pressure", "Pa" )
     798 CALL histdef3d(iff,o_rneb%flag,o_rneb%name, "Cloud fraction", "-")
     799 CALL histdef3d(iff,o_rnebcon%flag,o_rnebcon%name, "Convective Cloud Fraction", "-")
     800 CALL histdef3d(iff,o_rhum%flag,o_rhum%name, "Relative humidity", "-")
     801 CALL histdef3d(iff,o_ozone%flag,o_ozone%name, "Ozone concentration", "ppmv")
    681802 IF(iflag_con.GE.3) THEN
    682   CALL histdef3d(iff,flag_upwd,"upwd","saturated updraft", "kg/m2/s")
     803  CALL histdef3d(iff,o_upwd%flag,o_upwd%name, "saturated updraft", "kg/m2/s")
    683804 ENDIF !iflag_con.GE.3
    684  CALL histdef3d(iff,flag_dtphy,"dtphy","Physics dT","K/s")
    685  CALL histdef3d(iff,flag_dqphy,"dqphy","Physics dQ", "(kg/kg)/s")
    686  CALL histdef3d(iff,flag_cldtau,"cldtau","Cloud optical thickness","1")
    687  CALL histdef3d(iff,flag_cldemi,"cldemi","Cloud optical emissivity","1")
     805 CALL histdef3d(iff,o_dtphy%flag,o_dtphy%name, "Physics dT", "K/s")
     806 CALL histdef3d(iff,o_dqphy%flag,o_dqphy%name, "Physics dQ", "(kg/kg)/s")
     807 CALL histdef3d(iff,o_cldtau%flag,o_cldtau%name, "Cloud optical thickness", "1")
     808 CALL histdef3d(iff,o_cldemi%flag,o_cldemi%name, "Cloud optical emissivity", "1")
    688809!IM: bug ?? dimensionnement variables (klon,klev+1) pmflxr, pmflxs, prfl, psfl
    689 ! CALL histdef3d(iff,flag_pr_con_l,"pmflxr","Convective precipitation lic"," ")
    690 ! CALL histdef3d(iff,flag_pr_con_i,"pmflxs","Convective precipitation ice"," ")
    691 ! CALL histdef3d(iff,flag_pr_lsc_l,"prfl","Large scale precipitation lic"," ")
    692 ! CALL histdef3d(iff,flag_pr_lsc_i,"psfl","Large scale precipitation ice"," ")
     810! CALL histdef3d(iff,o_pr_con_l%flag,o_pmflxr%name, "Convective precipitation lic", " ")
     811! CALL histdef3d(iff,o_pr_con_i%flag,o_pmflxs%name, "Convective precipitation ice", " ")
     812! CALL histdef3d(iff,o_pr_lsc_l%flag,o_prfl%name, "Large scale precipitation lic", " ")
     813! CALL histdef3d(iff,o_pr_lsc_i%flag,o_psfl%name, "Large scale precipitation ice", " ")
    693814
    694815!FH Sorties pour la couche limite
    695816     if (iflag_pbl>1) then
    696  CALL histdef3d(iff,flag_tke,"tke","TKE","m2/s2")
    697  CALL histdef3d(iff,flag_tke_max,"tke_max","TKE max","m2/s2")
     817 CALL histdef3d(iff,o_tke%flag,o_tke%name, "TKE", "m2/s2")
     818 CALL histdef3d(iff,o_tke_max%flag,o_tke_max%name, "TKE max", "m2/s2")
    698819     endif
    699820
    700  CALL histdef3d(iff,flag_kz,"kz","Kz melange","m2/s")
    701  CALL histdef3d(iff,flag_kz_max,"kz_max","Kz melange max","m2/s" )
    702  CALL histdef3d(iff,flag_clwcon,"clwcon","Convective Cloud Liquid water content", "kg/kg")
     821 CALL histdef3d(iff,o_kz%flag,o_kz%name, "Kz melange", "m2/s")
     822 CALL histdef3d(iff,o_kz_max%flag,o_kz_max%name, "Kz melange max", "m2/s" )
     823 CALL histdef3d(iff,o_clwcon%flag,o_clwcon%name, "Convective Cloud Liquid water content", "kg/kg")
    703824 IF(iflag_con.GE.3) THEN
    704  CALL histdef3d(iff,flag_Ma,"Ma","undilute adiab updraft","kg/m2/s")
    705  CALL histdef3d(iff,flag_dnwd,"dnwd","saturated downdraft","kg/m2/s")
    706  CALL histdef3d(iff,flag_dnwd0,"dnwd0","unsat. downdraft", "kg/m2/s")
     825 CALL histdef3d(iff,o_Ma%flag,o_Ma%name, "undilute adiab updraft", "kg/m2/s")
     826 CALL histdef3d(iff,o_dnwd%flag,o_dnwd%name, "saturated downdraft", "kg/m2/s")
     827 CALL histdef3d(iff,o_dnwd0%flag,o_dnwd0%name, "unsat. downdraft", "kg/m2/s")
    707828 ENDIF !(iflag_con.GE.3)
    708  CALL histdef3d(iff,flag_dtdyn,"dtdyn","Dynamics dT","K/s")
    709  CALL histdef3d(iff,flag_dqdyn,"dqdyn","Dynamics dQ", "(kg/kg)/s")
    710  CALL histdef3d(iff,flag_dudyn,"dudyn","Dynamics dU","m/s2")
    711  CALL histdef3d(iff,flag_dvdyn,"dvdyn","Dynamics dV","m/s2")
    712  CALL histdef3d(iff,flag_dtcon,"dtcon","Convection dT","K/s")
    713  CALL histdef3d(iff,flag_ducon,"ducon","Convection du","m/s2")
    714  CALL histdef3d(iff,flag_dqcon,"dqcon","Convection dQ", "(kg/kg)/s")
    715  IF(iflag_con.GE.3) THEN
     829 CALL histdef3d(iff,o_dtdyn%flag,o_dtdyn%name, "Dynamics dT", "K/s")
     830 CALL histdef3d(iff,o_dqdyn%flag,o_dqdyn%name, "Dynamics dQ", "(kg/kg)/s")
     831 CALL histdef3d(iff,o_dudyn%flag,o_dudyn%name, "Dynamics dU", "m/s2")
     832 CALL histdef3d(iff,o_dvdyn%flag,o_dvdyn%name, "Dynamics dV", "m/s2")
     833 CALL histdef3d(iff,o_dtcon%flag,o_dtcon%name, "Convection dT", "K/s")
     834 CALL histdef3d(iff,o_ducon%flag,o_ducon%name, "Convection du", "m/s2")
     835 CALL histdef3d(iff,o_dqcon%flag,o_dqcon%name, "Convection dQ", "(kg/kg)/s")
     836 IF(iflag_con.EQ.3) THEN
    716837 IF (iflag_wake == 1) THEN
    717    CALL histdef2d(iff,flag_wake_h,"wake_h","wake_h", "-")
    718    CALL histdef2d(iff,flag_wake_s,"wake_s","wake_s", "-")
    719    CALL histdef3d(iff,flag_dtwak,"dtwak","Wake dT","K/s")
    720    CALL histdef3d(iff,flag_dqwak,"dqwak","Wake dQ","(kg/kg)/s")
    721    CALL histdef3d(iff,flag_wake_deltat,"wake_deltat","wake_deltat", " ")
    722    CALL histdef3d(iff,flag_wake_deltaq,"wake_deltaq","wake_deltaq", " ")
    723    CALL histdef3d(iff,flag_wake_omg,"wake_omg","wake_omg", " ")
     838   CALL histdef2d(iff,o_wake_h%flag,o_wake_h%name, "wake_h", "-")
     839   CALL histdef2d(iff,o_wake_s%flag,o_wake_s%name, "wake_s", "-")
     840   CALL histdef3d(iff,o_dtwak%flag,o_dtwak%name, "Wake dT", "K/s")
     841   CALL histdef3d(iff,o_dqwak%flag,o_dqwak%name, "Wake dQ", "(kg/kg)/s")
     842   CALL histdef3d(iff,o_wake_deltat%flag,o_wake_deltat%name, "wake_deltat", " ")
     843   CALL histdef3d(iff,o_wake_deltaq%flag,o_wake_deltaq%name, "wake_deltaq", " ")
     844   CALL histdef3d(iff,o_wake_omg%flag,o_wake_omg%name, "wake_omg", " ")
    724845 ENDIF
    725    CALL histdef3d(iff,flag_Vprecip,"Vprecip","precipitation vertical profile","-")
    726    CALL histdef3d(iff,flag_ftd,"ftd","tend temp due aux descentes precip","-")
    727    CALL histdef3d(iff,flag_fqd,"fqd","tend vap eau due aux descentes precip","-")
    728  ENDIF !(iflag_con.GE.3)
    729 
    730  CALL histdef3d(iff,flag_dtlsc,"dtlsc","Condensation dT", "K/s")
    731  CALL histdef3d(iff,flag_dtlschr,"dtlschr","Large-scale condensational heating rate","K/s")
    732  CALL histdef3d(iff,flag_dqlsc,"dqlsc","Condensation dQ","(kg/kg)/s")
    733  CALL histdef3d(iff,flag_dtvdf,"dtvdf","Boundary-layer dT", "K/s")
    734  CALL histdef3d(iff,flag_dqvdf,"dqvdf","Boundary-layer dQ","(kg/kg)/s")
    735  CALL histdef3d(iff,flag_dteva,"dteva","Reevaporation dT", "K/s")
    736  CALL histdef3d(iff,flag_dqeva,"dqeva","Reevaporation dQ","(kg/kg)/s")
    737  CALL histdef3d(iff,flag_ptconv,"ptconv","POINTS CONVECTIFS"," ")
    738  CALL histdef3d(iff,flag_ratqs,"ratqs", "RATQS"," ")
    739  CALL histdef3d(iff,flag_dtthe,"dtthe","Dry adjust. dT", "K/s")
     846   CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name, "precipitation vertical profile", "-")
     847   CALL histdef3d(iff,o_ftd%flag,o_ftd%name, "tend temp due aux descentes precip", "-")
     848   CALL histdef3d(iff,o_fqd%flag,o_fqd%name,"tend vap eau due aux descentes precip", "-")
     849 ENDIF !(iflag_con.EQ.3)
     850
     851 CALL histdef3d(iff,o_dtlsc%flag,o_dtlsc%name, "Condensation dT", "K/s")
     852 CALL histdef3d(iff,o_dtlschr%flag,o_dtlschr%name,"Large-scale condensational heating rate","K/s")
     853 CALL histdef3d(iff,o_dqlsc%flag,o_dqlsc%name, "Condensation dQ", "(kg/kg)/s")
     854 CALL histdef3d(iff,o_dtvdf%flag,o_dtvdf%name, "Boundary-layer dT", "K/s")
     855 CALL histdef3d(iff,o_dqvdf%flag,o_dqvdf%name, "Boundary-layer dQ", "(kg/kg)/s")
     856 CALL histdef3d(iff,o_dteva%flag,o_dteva%name, "Reevaporation dT", "K/s")
     857 CALL histdef3d(iff,o_dqeva%flag,o_dqeva%name, "Reevaporation dQ", "(kg/kg)/s")
     858 CALL histdef3d(iff,o_ptconv%flag,o_ptconv%name, "POINTS CONVECTIFS", " ")
     859 CALL histdef3d(iff,o_ratqs%flag,o_ratqs%name, "RATQS", " ")
     860 CALL histdef3d(iff,o_dtthe%flag,o_dtthe%name, "Dry adjust. dT", "K/s")
    740861
    741862if(iflag_thermals.gt.1) THEN
    742  CALL histdef3d(iff,flag_f_th,"f_th","Thermal plume mass flux", "K/s")
    743  CALL histdef3d(iff,flag_e_th,"e_th","Thermal plume entrainment", "K/s")
    744  CALL histdef3d(iff,flag_w_th,"w_th","Thermal plume vertical velocity", "m/s")
    745  CALL histdef3d(iff,flag_lambda_th,"lambda_th","Thermal plume vertical velocity", "m/s")
    746  CALL histdef3d(iff,flag_q_th,"q_th","Thermal plume total humidity", "kg/kg")
    747  CALL histdef3d(iff,flag_a_th,"a_th","Thermal plume fraction", "")
    748  CALL histdef3d(iff,flag_d_th,"d_th","Thermal plume detrainment", "K/s")
     863 CALL histdef3d(iff,o_f_th%flag,o_f_th%name, "Thermal plume mass flux", "K/s")
     864 CALL histdef3d(iff,o_e_th%flag,o_e_th%name,"Thermal plume entrainment","K/s")
     865 CALL histdef3d(iff,o_w_th%flag,o_w_th%name,"Thermal plume vertical velocity","m/s")
     866 CALL histdef3d(iff,o_lambda_th%flag,o_lambda_th%name,"Thermal plume vertical velocity","m/s")
     867 CALL histdef3d(iff,o_q_th%flag,o_q_th%name, "Thermal plume total humidity", "kg/kg")
     868 CALL histdef3d(iff,o_a_th%flag,o_a_th%name, "Thermal plume fraction", "")
     869 CALL histdef3d(iff,o_d_th%flag,o_d_th%name, "Thermal plume detrainment", "K/s")
    749870endif !iflag_thermals.gt.1
    750  CALL histdef2d(iff,flag_f0_th,"f0_th","Thermal closure mass flux", "K/s")
    751  CALL histdef2d(iff,flag_zmax_th,"zmax_th","Thermal plume height", "K/s")
    752  CALL histdef3d(iff,flag_dqthe,"dqthe","Dry adjust. dQ","(kg/kg)/s")
    753  CALL histdef3d(iff,flag_dtajs,"dtajs","Dry adjust. dT", "K/s")
    754  CALL histdef3d(iff,flag_dqajs,"dqajs","Dry adjust. dQ","(kg/kg)/s")
    755  CALL histdef3d(iff,flag_dtswr,"dtswr","SW radiation dT","K/s")
    756  CALL histdef3d(iff,flag_dtsw0,"dtsw0","CS SW radiation dT","K/s")
    757  CALL histdef3d(iff,flag_dtlwr,"dtlwr","LW radiation dT","K/s")
    758  CALL histdef3d(iff,flag_dtlw0,"dtlw0", "CS LW radiation dT","K/s")
    759  CALL histdef3d(iff,flag_dtec,"dtec","Cinetic dissip dT","K/s")
    760  CALL histdef3d(iff,flag_duvdf,"duvdf","Boundary-layer dU","m/s2")
    761  CALL histdef3d(iff,flag_dvvdf,"dvvdf","Boundary-layer dV", "m/s2")
     871 CALL histdef2d(iff,o_f0_th%flag,o_f0_th%name, "Thermal closure mass flux", "K/s")
     872 CALL histdef2d(iff,o_zmax_th%flag,o_zmax_th%name, "Thermal plume height", "K/s")
     873 CALL histdef3d(iff,o_dqthe%flag,o_dqthe%name, "Dry adjust. dQ", "(kg/kg)/s")
     874 CALL histdef3d(iff,o_dtajs%flag,o_dtajs%name, "Dry adjust. dT", "K/s")
     875 CALL histdef3d(iff,o_dqajs%flag,o_dqajs%name, "Dry adjust. dQ", "(kg/kg)/s")
     876 CALL histdef3d(iff,o_dtswr%flag,o_dtswr%name, "SW radiation dT", "K/s")
     877 CALL histdef3d(iff,o_dtsw0%flag,o_dtsw0%name, "CS SW radiation dT", "K/s")
     878 CALL histdef3d(iff,o_dtlwr%flag,o_dtlwr%name, "LW radiation dT", "K/s")
     879 CALL histdef3d(iff,o_dtlw0%flag,o_dtlw0%name, "CS LW radiation dT", "K/s")
     880 CALL histdef3d(iff,o_dtec%flag,o_dtec%name, "Cinetic dissip dT", "K/s")
     881 CALL histdef3d(iff,o_duvdf%flag,o_duvdf%name, "Boundary-layer dU", "m/s2")
     882 CALL histdef3d(iff,o_dvvdf%flag,o_dvvdf%name, "Boundary-layer dV", "m/s2")
    762883
    763884     IF (ok_orodr) THEN
    764  CALL histdef3d(iff,flag_duoro,"duoro","Orography dU","m/s2")
    765  CALL histdef3d(iff,flag_dvoro,"dvoro","Orography dV", "m/s2")
     885 CALL histdef3d(iff,o_duoro%flag,o_duoro%name, "Orography dU", "m/s2")
     886 CALL histdef3d(iff,o_dvoro%flag,o_dvoro%name, "Orography dV", "m/s2")
    766887     ENDIF
    767888
    768889     IF (ok_orolf) THEN
    769  CALL histdef3d(iff,flag_dulif,"dulif","Orography dU","m/s2")
    770  CALL histdef3d(iff,flag_dvlif,"dvlif","Orography dV", "m/s2")
     890 CALL histdef3d(iff,o_dulif%flag,o_dulif%name, "Orography dU", "m/s2")
     891 CALL histdef3d(iff,o_dvlif%flag,o_dvlif%name, "Orography dV", "m/s2")
    771892     ENDIF
    772893
    773894      if (nqmax>=3) THEN
    774     DO iq=3,nqmax
     895!Attention    DO iq=3,nqmax
     896    DO iq=3,4 
    775897       iiq=niadv(iq)
    776  CALL histdef3d ( iff, flag_trac, tnom(iq),ttext(iiq), "-" )
     898! CALL histdef3d (iff, o_trac%flag,'o_'//tnom(iq)%name,ttext(iiq), "-" )
     899  CALL histdef3d (iff, o_trac(iq-2)%flag,o_trac(iq-2)%name,ttext(iiq), "-" )
    777900    ENDDO
    778901      endif
     
    804927       integer                          :: iff
    805928       integer, dimension(nfiles)       :: flag_var
    806        character(len=*)                 :: nomvar
     929       character(len=20)                 :: nomvar
    807930       character(len=*)                 :: titrevar
    808931       character(len=*)                 :: unitvar
     932
     933       if (iff.eq.1) then
     934   call conf_physoutputs(nomvar,flag_var)
     935       endif
    809936       
    810937       if ( flag_var(iff)<=lev_files(iff) ) then
     
    831958       integer                          :: iff
    832959       integer, dimension(nfiles)       :: flag_var
    833        character(len=*)                 :: nomvar
     960       character(len=20)                 :: nomvar
    834961       character(len=*)                 :: titrevar
    835962       character(len=*)                 :: unitvar
     963
     964       if (iff.eq.1) then
     965   call conf_physoutputs(nomvar,flag_var)
     966       endif
    836967
    837968       if ( flag_var(iff)<=lev_files(iff) ) then
     
    843974      end subroutine histdef3d
    844975
     976      SUBROUTINE conf_physoutputs(nam_var,flag_var)
     977       use ioipsl
     978
     979       IMPLICIT NONE
     980
     981       character(len=20)                :: nam_var
     982       integer, dimension(nfiles)      :: flag_var
     983       integer, dimension(nfiles),save :: flag_var_omp
     984       character(len=20),save           :: nam_var_omp
     985
     986        flag_var_omp = flag_var
     987        nam_var_omp = nam_var
     988        print*,'Avant getin: nam_var flag_var ',nam_var,flag_var(:)
     989        call getin('flag_'//nam_var,flag_var_omp)
     990        flag_var = flag_var_omp
     991        call getin('name_'//nam_var,nam_var_omp)
     992        nam_var=nam_var_omp
     993       
     994        print*,'Apres getin: nam_var flag_var ',nam_var,flag_var(:)
     995
     996      END SUBROUTINE conf_physoutputs
     997
    845998END MODULE phys_output_mod
    846999
  • LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_write.h

    r1067 r1083  
    88
    99!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    10        IF (flag_phis(iff)<=lev_files(iff)) THEN
     10       IF (o_phis%flag(iff)<=lev_files(iff)) THEN
    1111         CALL histwrite_phy(nid_files(iff),
    12      $                      "phis",itau_w,pphis)
    13        ENDIF
    14 
    15        IF (flag_aire(iff)<=lev_files(iff)) THEN
    16        CALL histwrite_phy(nid_files(iff),"aire",itau_w,airephy)
    17        ENDIF
    18 
    19        IF (flag_pourc_sol(iff)<=lev_files(iff)) THEN
    20       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_ter)* 100.
    21       CALL histwrite_phy(nid_files(iff),
    22      $                   "pourc_"//clnsurf(is_ter),itau_w,
    23      $                   zx_tmp_fi2d)
    24        ENDIF
    25 
    26        IF (flag_fract_sol(iff)<=lev_files(iff)) THEN
    27       zx_tmp_fi2d(1 : klon) = pctsrf(1 : klon, is_ter)
    28       CALL histwrite_phy(nid_files(iff),
    29      $               "fract_"//clnsurf(is_ter),itau_w,
    30      $               zx_tmp_fi2d)
    31        ENDIF
    32 
    33        IF (flag_contfracATM(iff)<=lev_files(iff)) THEN
     12     $                      o_phis%name,itau_w,pphis)
     13       ENDIF
     14
     15       IF (o_aire%flag(iff)<=lev_files(iff)) THEN
     16       CALL histwrite_phy(nid_files(iff),o_aire%name,itau_w,airephy)
     17       ENDIF
     18
     19       IF (o_contfracATM%flag(iff)<=lev_files(iff)) THEN
    3420      DO i=1, klon
    3521       zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
    3622      ENDDO
    3723      CALL histwrite_phy(nid_files(iff),
    38      $                   "contfracATM",itau_w,zx_tmp_fi2d)
    39        ENDIF
    40 
    41        IF (flag_contfracOR(iff)<=lev_files(iff)) THEN
    42       CALL histwrite_phy(nid_files(iff),"contfracOR",itau_w,
     24     $             o_contfracATM%name,itau_w,zx_tmp_fi2d)
     25       ENDIF
     26
     27       IF (o_contfracOR%flag(iff)<=lev_files(iff)) THEN
     28      CALL histwrite_phy(nid_files(iff),o_contfracOR%name,itau_w,
    4329     $                   pctsrf(:,is_ter))
    4430       ENDIF
    4531
    46        IF (flag_aireTER(iff)<=lev_files(iff)) THEN
    47       CALL histwrite_phy(nid_files(iff),
    48      $                  "aireTER",itau_w,paire_ter)
     32       IF (o_aireTER%flag(iff)<=lev_files(iff)) THEN
     33      CALL histwrite_phy(nid_files(iff),
     34     $                  o_aireTER%name,itau_w,paire_ter)
    4935       ENDIF
    5036
    5137!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    5238
    53        IF (flag_flat(iff)<=lev_files(iff)) THEN
    54       CALL histwrite_phy(nid_files(iff),"flat",itau_w,zxfluxlat)
    55        ENDIF
    56 
    57        IF (flag_slp(iff)<=lev_files(iff)) THEN
    58       CALL histwrite_phy(nid_files(iff),"slp",itau_w,slp)
    59        ENDIF
    60 
    61        IF (flag_tsol(iff)<=lev_files(iff)) THEN
    62       CALL histwrite_phy(nid_files(iff),"tsol",itau_w,zxtsol)
    63        ENDIF
    64 
    65        IF (flag_t2m(iff)<=lev_files(iff)) THEN
    66       CALL histwrite_phy(nid_files(iff),"t2m",itau_w,zt2m)
    67        ENDIF
    68 
    69        IF (flag_t2m_min(iff)<=lev_files(iff)) THEN
    70       CALL histwrite_phy(nid_files(iff),"t2m_min",itau_w,zt2m)
    71        ENDIF
    72 
    73        IF (flag_t2m_max(iff)<=lev_files(iff)) THEN
    74       CALL histwrite_phy(nid_files(iff),"t2m_max",itau_w,zt2m)
    75        ENDIF
    76 
    77        IF (flag_wind10m(iff)<=lev_files(iff)) THEN
     39       IF (o_flat%flag(iff)<=lev_files(iff)) THEN
     40      CALL histwrite_phy(nid_files(iff),o_flat%name,itau_w,zxfluxlat)
     41       ENDIF
     42
     43       IF (o_slp%flag(iff)<=lev_files(iff)) THEN
     44      CALL histwrite_phy(nid_files(iff),o_slp%name,itau_w,slp)
     45       ENDIF
     46
     47       IF (o_tsol%flag(iff)<=lev_files(iff)) THEN
     48      CALL histwrite_phy(nid_files(iff),o_tsol%name,itau_w,zxtsol)
     49       ENDIF
     50
     51       IF (o_t2m%flag(iff)<=lev_files(iff)) THEN
     52      CALL histwrite_phy(nid_files(iff),o_t2m%name,itau_w,zt2m)
     53       ENDIF
     54
     55       IF (o_t2m_min%flag(iff)<=lev_files(iff)) THEN
     56      CALL histwrite_phy(nid_files(iff),o_t2m_min%name,itau_w,zt2m)
     57       ENDIF
     58
     59       IF (o_t2m_max%flag(iff)<=lev_files(iff)) THEN
     60      CALL histwrite_phy(nid_files(iff),o_t2m_max%name,itau_w,zt2m)
     61       ENDIF
     62
     63       IF (o_wind10m%flag(iff)<=lev_files(iff)) THEN
    7864      DO i=1, klon
    7965       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
    8066      ENDDO
    81       CALL histwrite_phy(nid_files(iff),"wind10m",itau_w,zx_tmp_fi2d)
    82        ENDIF
    83 
    84        IF (flag_wind10max(iff)<=lev_files(iff)) THEN
     67      CALL histwrite_phy(nid_files(iff),
     68     s                  o_wind10m%name,itau_w,zx_tmp_fi2d)
     69       ENDIF
     70
     71       IF (o_wind10max%flag(iff)<=lev_files(iff)) THEN
    8572      DO i=1, klon
    8673       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
    8774      ENDDO
    88       CALL histwrite_phy(nid_files(iff),"wind10max",
     75      CALL histwrite_phy(nid_files(iff),o_wind10max%name,
    8976     $                   itau_w,zx_tmp_fi2d)
    9077       ENDIF
    9178
    92        IF (flag_sicf(iff)<=lev_files(iff)) THEN
     79       IF (o_sicf%flag(iff)<=lev_files(iff)) THEN
    9380      DO i = 1, klon
    9481         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
    9582      ENDDO
    96       CALL histwrite_phy(nid_files(iff),"sicf",itau_w,zx_tmp_fi2d)
    97        ENDIF
    98 
    99        IF (flag_q2m(iff)<=lev_files(iff)) THEN
    100       CALL histwrite_phy(nid_files(iff),"q2m",itau_w,zq2m)
    101        ENDIF
    102 
    103        IF (flag_u10m(iff)<=lev_files(iff)) THEN
    104       CALL histwrite_phy(nid_files(iff),"u10m",itau_w,zu10m)
    105        ENDIF
    106 
    107        IF (flag_v10m(iff)<=lev_files(iff)) THEN
    108       CALL histwrite_phy(nid_files(iff),"v10m",itau_w,zv10m)
    109        ENDIF
    110 
    111        IF (flag_psol(iff)<=lev_files(iff)) THEN
     83      CALL histwrite_phy(nid_files(iff),
     84     $                   o_sicf%name,itau_w,zx_tmp_fi2d)
     85       ENDIF
     86
     87       IF (o_q2m%flag(iff)<=lev_files(iff)) THEN
     88      CALL histwrite_phy(nid_files(iff),o_q2m%name,itau_w,zq2m)
     89       ENDIF
     90
     91       IF (o_u10m%flag(iff)<=lev_files(iff)) THEN
     92      CALL histwrite_phy(nid_files(iff),o_u10m%name,itau_w,zu10m)
     93       ENDIF
     94
     95       IF (o_v10m%flag(iff)<=lev_files(iff)) THEN
     96      CALL histwrite_phy(nid_files(iff),o_v10m%name,itau_w,zv10m)
     97       ENDIF
     98
     99       IF (o_psol%flag(iff)<=lev_files(iff)) THEN
    112100      DO i = 1, klon
    113101         zx_tmp_fi2d(i) = paprs(i,1)
    114102      ENDDO
    115       CALL histwrite_phy(nid_files(iff),"psol",itau_w,zx_tmp_fi2d)
    116        ENDIF
    117 
    118        IF (flag_qsurf(iff)<=lev_files(iff)) THEN
    119       CALL histwrite_phy(nid_files(iff),"qsurf",itau_w,zxqsurf)
     103      CALL histwrite_phy(nid_files(iff),
     104     s                   o_psol%name,itau_w,zx_tmp_fi2d)
     105       ENDIF
     106
     107       IF (o_qsurf%flag(iff)<=lev_files(iff)) THEN
     108      CALL histwrite_phy(nid_files(iff),o_qsurf%name,itau_w,zxqsurf)
    120109       ENDIF
    121110
    122111       if (.not. ok_veget) then
    123          IF (flag_qsol(iff)<=lev_files(iff)) THEN
    124         CALL histwrite_phy(nid_files(iff),"qsol",itau_w,qsol)
     112         IF (o_qsol%flag(iff)<=lev_files(iff)) THEN
     113        CALL histwrite_phy(nid_files(iff),o_qsol%name,itau_w,qsol)
    125114         ENDIF
    126115       endif
    127116
    128       IF (flag_precip(iff)<=lev_files(iff)) THEN
     117      IF (o_precip%flag(iff)<=lev_files(iff)) THEN
    129118       DO i = 1, klon
    130119         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
    131120       ENDDO
    132       CALL histwrite_phy(nid_files(iff),"precip",itau_w,zx_tmp_fi2d)
    133       ENDIF
    134 
    135        IF (flag_ndayrain(iff)<=lev_files(iff)) THEN
    136       CALL histwrite_phy(nid_files(iff),"ndayrain",itau_w,nday_rain)
    137        ENDIF
    138 
    139       IF (flag_plul(iff)<=lev_files(iff)) THEN
     121      CALL histwrite_phy(nid_files(iff),o_precip%name,
     122     s                   itau_w,zx_tmp_fi2d)
     123      ENDIF
     124
     125       IF (o_ndayrain%flag(iff)<=lev_files(iff)) THEN
     126      CALL histwrite_phy(nid_files(iff),o_ndayrain%name,
     127     s                   itau_w,nday_rain)
     128       ENDIF
     129
     130      IF (o_plul%flag(iff)<=lev_files(iff)) THEN
    140131       DO i = 1, klon
    141132         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
    142133       ENDDO
    143       CALL histwrite_phy(nid_files(iff),"plul",itau_w,zx_tmp_fi2d)
    144       ENDIF
    145 
    146       IF (flag_pluc(iff)<=lev_files(iff)) THEN
     134      CALL histwrite_phy(nid_files(iff),o_plul%name,itau_w,zx_tmp_fi2d)
     135      ENDIF
     136
     137      IF (o_pluc%flag(iff)<=lev_files(iff)) THEN
    147138      DO i = 1, klon
    148139         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
    149140      ENDDO
    150       CALL histwrite_phy(nid_files(iff),"pluc",itau_w,zx_tmp_fi2d)
    151       ENDIF
    152 
    153        IF (flag_snow(iff)<=lev_files(iff)) THEN
    154       CALL histwrite_phy(nid_files(iff),"snow",itau_w,snow_fall)
    155        ENDIF
    156 
    157        IF (flag_evap(iff)<=lev_files(iff)) THEN
    158       CALL histwrite_phy(nid_files(iff),"evap",itau_w,evap)
    159        ENDIF
    160 
    161        IF (flag_tops(iff)<=lev_files(iff)) THEN
    162       CALL histwrite_phy(nid_files(iff),"tops",itau_w,topsw)
    163        ENDIF
    164 
    165        IF (flag_tops0(iff)<=lev_files(iff)) THEN
    166       CALL histwrite_phy(nid_files(iff),"tops0",itau_w,topsw0)
    167        ENDIF
    168 
    169        IF (flag_topl(iff)<=lev_files(iff)) THEN
    170       CALL histwrite_phy(nid_files(iff),"topl",itau_w,toplw)
    171        ENDIF
    172 
    173        IF (flag_topl0(iff)<=lev_files(iff)) THEN
    174       CALL histwrite_phy(nid_files(iff),"topl0",itau_w,toplw0)
    175        ENDIF
    176 
    177        IF (flag_SWupTOA(iff)<=lev_files(iff)) THEN
     141      CALL histwrite_phy(nid_files(iff),o_pluc%name,itau_w,zx_tmp_fi2d)
     142      ENDIF
     143
     144       IF (o_snow%flag(iff)<=lev_files(iff)) THEN
     145      CALL histwrite_phy(nid_files(iff),o_snow%name,itau_w,snow_fall)
     146       ENDIF
     147
     148       IF (o_evap%flag(iff)<=lev_files(iff)) THEN
     149      CALL histwrite_phy(nid_files(iff),o_evap%name,itau_w,evap)
     150       ENDIF
     151
     152       IF (o_tops%flag(iff)<=lev_files(iff)) THEN
     153      CALL histwrite_phy(nid_files(iff),o_tops%name,itau_w,topsw)
     154       ENDIF
     155
     156       IF (o_tops0%flag(iff)<=lev_files(iff)) THEN
     157      CALL histwrite_phy(nid_files(iff),o_tops0%name,itau_w,topsw0)
     158       ENDIF
     159
     160       IF (o_topl%flag(iff)<=lev_files(iff)) THEN
     161      CALL histwrite_phy(nid_files(iff),o_topl%name,itau_w,toplw)
     162       ENDIF
     163
     164       IF (o_topl0%flag(iff)<=lev_files(iff)) THEN
     165      CALL histwrite_phy(nid_files(iff),o_topl0%name,itau_w,toplw0)
     166       ENDIF
     167
     168       IF (o_SWupTOA%flag(iff)<=lev_files(iff)) THEN
    178169      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
    179       CALL histwrite_phy(nid_files(iff), "SWupTOA",itau_w,zx_tmp_fi2d)
    180        ENDIF
    181 
    182        IF (flag_SWupTOAclr(iff)<=lev_files(iff)) THEN
     170      CALL histwrite_phy(nid_files(iff),o_SWupTOA%name,
     171     s                     itau_w,zx_tmp_fi2d)
     172       ENDIF
     173
     174       IF (o_SWupTOAclr%flag(iff)<=lev_files(iff)) THEN
    183175      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
    184176      CALL histwrite_phy(nid_files(iff),
    185      $                  "SWupTOAclr",itau_w,zx_tmp_fi2d)
    186        ENDIF
    187 
    188        IF (flag_SWdnTOA(iff)<=lev_files(iff)) THEN
     177     $                  o_SWupTOAclr%name,itau_w,zx_tmp_fi2d)
     178       ENDIF
     179
     180       IF (o_SWdnTOA%flag(iff)<=lev_files(iff)) THEN
    189181      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
    190       CALL histwrite_phy(nid_files(iff), "SWdnTOA",itau_w,zx_tmp_fi2d)
    191        ENDIF
    192 
    193        IF (flag_SWdnTOAclr(iff)<=lev_files(iff)) THEN
     182      CALL histwrite_phy(nid_files(iff),
     183     s                  o_SWdnTOA%name,itau_w,zx_tmp_fi2d)
     184       ENDIF
     185
     186       IF (o_SWdnTOAclr%flag(iff)<=lev_files(iff)) THEN
    194187      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
    195188      CALL histwrite_phy(nid_files(iff),
    196      $                  "SWdnTOAclr",itau_w,zx_tmp_fi2d)
    197        ENDIF
    198 
    199        IF (flag_SWup200(iff)<=lev_files(iff)) THEN
    200       CALL histwrite_phy(nid_files(iff),"SWup200",itau_w,SWup200)
    201        ENDIF
    202 
    203        IF (flag_SWup200clr(iff)<=lev_files(iff)) THEN
    204       CALL histwrite_phy(nid_files(iff),"SWup200clr",itau_w,SWup200clr)
    205        ENDIF
    206 
    207        IF (flag_SWdn200(iff)<=lev_files(iff)) THEN
    208       CALL histwrite_phy(nid_files(iff),"SWdn200",itau_w,SWdn200)
    209        ENDIF
    210 
    211        IF (flag_SWdn200clr(iff)<=lev_files(iff)) THEN
    212       CALL histwrite_phy(nid_files(iff),"SWdn200clr",itau_w,SWdn200clr)
    213        ENDIF
    214 
    215        IF (flag_LWup200(iff)<=lev_files(iff)) THEN
    216       CALL histwrite_phy(nid_files(iff),"LWup200",itau_w,LWup200)
    217        ENDIF
    218 
    219        IF (flag_LWup200clr(iff)<=lev_files(iff)) THEN
    220       CALL histwrite_phy(nid_files(iff),"LWup200clr",itau_w,LWup200clr)
    221        ENDIF
    222 
    223        IF (flag_LWdn200(iff)<=lev_files(iff)) THEN
    224       CALL histwrite_phy(nid_files(iff),"LWdn200",itau_w,zx_tmp_fi2d)
    225        ENDIF
    226 
    227        IF (flag_LWdn200clr(iff)<=lev_files(iff)) THEN
    228       CALL histwrite_phy(nid_files(iff),"LWdn200clr",itau_w,zx_tmp_fi2d)
    229        ENDIF
    230 
    231        IF (flag_sols(iff)<=lev_files(iff)) THEN
    232       CALL histwrite_phy(nid_files(iff),"sols",itau_w,solsw)
    233        ENDIF
    234 
    235        IF (flag_sols0(iff)<=lev_files(iff)) THEN
    236       CALL histwrite_phy(nid_files(iff),"sols0",itau_w,solsw0)
    237        ENDIF
    238 
    239        IF (flag_soll(iff)<=lev_files(iff)) THEN
    240       CALL histwrite_phy(nid_files(iff),"soll",itau_w,sollw)
    241        ENDIF
    242 
    243        IF (flag_radsol(iff)<=lev_files(iff)) THEN
    244       CALL histwrite_phy(nid_files(iff),"radsol",itau_w,radsol)
    245        ENDIF
    246 
    247        IF (flag_soll0(iff)<=lev_files(iff)) THEN
    248       CALL histwrite_phy(nid_files(iff),"soll0",itau_w,sollw0)
    249        ENDIF
    250 
    251        IF (flag_SWupSFC(iff)<=lev_files(iff)) THEN
     189     $                  o_SWdnTOAclr%name,itau_w,zx_tmp_fi2d)
     190       ENDIF
     191
     192       IF (o_SWup200%flag(iff)<=lev_files(iff)) THEN
     193      CALL histwrite_phy(nid_files(iff),o_SWup200%name,itau_w,SWup200)
     194       ENDIF
     195
     196       IF (o_SWup200clr%flag(iff)<=lev_files(iff)) THEN
     197      CALL histwrite_phy(nid_files(iff),
     198     s                   o_SWup200clr%name,itau_w,SWup200clr)
     199       ENDIF
     200
     201       IF (o_SWdn200%flag(iff)<=lev_files(iff)) THEN
     202      CALL histwrite_phy(nid_files(iff),o_SWdn200%name,itau_w,SWdn200)
     203       ENDIF
     204
     205       IF (o_SWdn200clr%flag(iff)<=lev_files(iff)) THEN
     206      CALL histwrite_phy(nid_files(iff),
     207     s                o_SWdn200clr%name,itau_w,SWdn200clr)
     208       ENDIF
     209
     210       IF (o_LWup200%flag(iff)<=lev_files(iff)) THEN
     211      CALL histwrite_phy(nid_files(iff),o_LWup200%name,itau_w,LWup200)
     212       ENDIF
     213
     214       IF (o_LWup200clr%flag(iff)<=lev_files(iff)) THEN
     215      CALL histwrite_phy(nid_files(iff),
     216     s                   o_LWup200clr%name,itau_w,LWup200clr)
     217       ENDIF
     218
     219       IF (o_LWdn200%flag(iff)<=lev_files(iff)) THEN
     220      CALL histwrite_phy(nid_files(iff),
     221     s                   o_LWdn200%name,itau_w,zx_tmp_fi2d)
     222       ENDIF
     223
     224       IF (o_LWdn200clr%flag(iff)<=lev_files(iff)) THEN
     225      CALL histwrite_phy(nid_files(iff),
     226     s                  o_LWdn200clr%name,itau_w,zx_tmp_fi2d)
     227       ENDIF
     228
     229       IF (o_sols%flag(iff)<=lev_files(iff)) THEN
     230      CALL histwrite_phy(nid_files(iff),o_sols%name,itau_w,solsw)
     231       ENDIF
     232
     233       IF (o_sols0%flag(iff)<=lev_files(iff)) THEN
     234      CALL histwrite_phy(nid_files(iff),o_sols0%name,itau_w,solsw0)
     235       ENDIF
     236
     237       IF (o_soll%flag(iff)<=lev_files(iff)) THEN
     238      CALL histwrite_phy(nid_files(iff),o_soll%name,itau_w,sollw)
     239       ENDIF
     240
     241       IF (o_radsol%flag(iff)<=lev_files(iff)) THEN
     242      CALL histwrite_phy(nid_files(iff),o_radsol%name,itau_w,radsol)
     243       ENDIF
     244
     245       IF (o_soll0%flag(iff)<=lev_files(iff)) THEN
     246      CALL histwrite_phy(nid_files(iff),o_soll0%name,itau_w,sollw0)
     247       ENDIF
     248
     249       IF (o_SWupSFC%flag(iff)<=lev_files(iff)) THEN
    252250      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
    253       CALL histwrite_phy(nid_files(iff), "SWupSFC",itau_w,zx_tmp_fi2d)
    254        ENDIF
    255 
    256        IF (flag_SWupSFCclr(iff)<=lev_files(iff)) THEN
     251      CALL histwrite_phy(nid_files(iff),
     252     s               o_SWupSFC%name,itau_w,zx_tmp_fi2d)
     253       ENDIF
     254
     255       IF (o_SWupSFCclr%flag(iff)<=lev_files(iff)) THEN
    257256      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
    258257      CALL histwrite_phy(nid_files(iff),
    259      $                   "SWupSFCclr",itau_w,zx_tmp_fi2d)
    260        ENDIF
    261 
    262        IF (flag_SWdnSFC(iff)<=lev_files(iff)) THEN
     258     $                   o_SWupSFCclr%name,itau_w,zx_tmp_fi2d)
     259       ENDIF
     260
     261       IF (o_SWdnSFC%flag(iff)<=lev_files(iff)) THEN
    263262      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
    264263      CALL histwrite_phy(nid_files(iff),
    265      $                   "SWdnSFC",itau_w,zx_tmp_fi2d)
    266        ENDIF
    267 
    268        IF (flag_SWdnSFCclr(iff)<=lev_files(iff)) THEN
     264     $                   o_SWdnSFC%name,itau_w,zx_tmp_fi2d)
     265       ENDIF
     266
     267       IF (o_SWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
    269268      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
    270269      CALL histwrite_phy(nid_files(iff),
    271      $                  "SWdnSFCclr",itau_w,zx_tmp_fi2d)
    272        ENDIF
    273 
    274        IF (flag_LWupSFC(iff)<=lev_files(iff)) THEN
     270     $                  o_SWdnSFCclr%name,itau_w,zx_tmp_fi2d)
     271       ENDIF
     272
     273       IF (o_LWupSFC%flag(iff)<=lev_files(iff)) THEN
    275274      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
    276275      CALL histwrite_phy(nid_files(iff),
    277      $                    "LWupSFC",itau_w,zx_tmp_fi2d)
    278        ENDIF
    279 
    280        IF (flag_LWdnSFC(iff)<=lev_files(iff)) THEN
    281       CALL histwrite_phy(nid_files(iff),
    282      $                   "LWdnSFC",itau_w,sollwdown)
     276     $                    o_LWupSFC%name,itau_w,zx_tmp_fi2d)
     277       ENDIF
     278
     279       IF (o_LWdnSFC%flag(iff)<=lev_files(iff)) THEN
     280      CALL histwrite_phy(nid_files(iff),
     281     $                   o_LWdnSFC%name,itau_w,sollwdown)
    283282       ENDIF
    284283
    285284       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
    286        IF (flag_LWupSFCclr(iff)<=lev_files(iff)) THEN
     285       IF (o_LWupSFCclr%flag(iff)<=lev_files(iff)) THEN
    287286      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
    288287      CALL histwrite_phy(nid_files(iff),
    289      $                   "LWupSFCclr",itau_w,zx_tmp_fi2d)
    290        ENDIF
    291 
    292        IF (flag_LWdnSFCclr(iff)<=lev_files(iff)) THEN
    293       CALL histwrite_phy(nid_files(iff),
    294      $                   "LWdnSFCclr",itau_w,sollwdownclr)
    295        ENDIF
    296 
    297        IF (flag_bils(iff)<=lev_files(iff)) THEN
    298       CALL histwrite_phy(nid_files(iff),"bils",itau_w,bils)
    299        ENDIF
    300 
    301        IF (flag_sens(iff)<=lev_files(iff)) THEN
     288     $                   o_LWupSFCclr%name,itau_w,zx_tmp_fi2d)
     289       ENDIF
     290
     291       IF (o_LWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
     292      CALL histwrite_phy(nid_files(iff),
     293     $                   o_LWdnSFCclr%name,itau_w,sollwdownclr)
     294       ENDIF
     295
     296       IF (o_bils%flag(iff)<=lev_files(iff)) THEN
     297      CALL histwrite_phy(nid_files(iff),o_bils%name,itau_w,bils)
     298       ENDIF
     299
     300       IF (o_sens%flag(iff)<=lev_files(iff)) THEN
    302301      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
    303       CALL histwrite_phy(nid_files(iff),"sens",itau_w,zx_tmp_fi2d)
    304        ENDIF
    305 
    306        IF (flag_fder(iff)<=lev_files(iff)) THEN
    307       CALL histwrite_phy(nid_files(iff),"fder",itau_w,fder)
    308        ENDIF
    309 
    310        IF (flag_ffonte(iff)<=lev_files(iff)) THEN
    311        CALL histwrite_phy(nid_files(iff),"ffonte",itau_w,zxffonte)
    312        ENDIF
    313 
    314        IF (flag_fqcalving(iff)<=lev_files(iff)) THEN
     302      CALL histwrite_phy(nid_files(iff),o_sens%name,itau_w,zx_tmp_fi2d)
     303       ENDIF
     304
     305       IF (o_fder%flag(iff)<=lev_files(iff)) THEN
     306      CALL histwrite_phy(nid_files(iff),o_fder%name,itau_w,fder)
     307       ENDIF
     308
     309       IF (o_ffonte%flag(iff)<=lev_files(iff)) THEN
     310       CALL histwrite_phy(nid_files(iff),o_ffonte%name,itau_w,zxffonte)
     311       ENDIF
     312
     313       IF (o_fqcalving%flag(iff)<=lev_files(iff)) THEN
    315314       CALL histwrite_phy(nid_files(iff),
    316      $                    "fqcalving",itau_w,zxfqcalving)
    317        ENDIF
    318 
    319        IF (flag_fqfonte(iff)<=lev_files(iff)) THEN
     315     $                    o_fqcalving%name,itau_w,zxfqcalving)
     316       ENDIF
     317
     318       IF (o_fqfonte%flag(iff)<=lev_files(iff)) THEN
    320319       CALL histwrite_phy(nid_files(iff),
    321      $                    "fqfonte",itau_w,zxfqfonte)
     320     $                   o_fqfonte%name,itau_w,zxfqfonte)
    322321       ENDIF
    323322
    324323         DO nsrf = 1, nbsrf
    325            IF(nsrf.GE.2) THEN
    326             IF (flag_pourc_sol(iff)<=lev_files(iff)) THEN
     324!           IF(nsrf.GE.2) THEN
     325            IF (o_pourc_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    327326            zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
    328327            CALL histwrite_phy(nid_files(iff),
    329      $                     "pourc_"//clnsurf(nsrf),itau_w,
     328     $                     o_pourc_srf(nsrf)%name,itau_w,
    330329     $                     zx_tmp_fi2d)
    331330            ENDIF
    332331
    333           IF (flag_fract_sol(iff)<=lev_files(iff)) THEN
     332          IF (o_fract_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    334333          zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
    335334          CALL histwrite_phy(nid_files(iff),
    336      $                    "fract_"//clnsurf(nsrf),itau_w,
     335     $                  o_fract_srf(nsrf)%name,itau_w,
     336     $                  zx_tmp_fi2d)
     337          ENDIF
     338!         ENDIF !nsrf.GT.2
     339
     340        IF (o_taux_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
     341        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
     342        CALL histwrite_phy(nid_files(iff),
     343     $                     o_taux_srf(nsrf)%name,itau_w,
     344     $                     zx_tmp_fi2d)
     345        ENDIF
     346
     347        IF (o_tauy_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN           
     348        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
     349        CALL histwrite_phy(nid_files(iff),
     350     $                    o_tauy_srf(nsrf)%name,itau_w,
     351     $                    zx_tmp_fi2d)
     352        ENDIF
     353
     354        IF (o_tsol_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
     355        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
     356        CALL histwrite_phy(nid_files(iff),
     357     $                   o_tsol_srf(nsrf)%name,itau_w,
    337358     $      zx_tmp_fi2d)
    338           ENDIF
    339          ENDIF !nsrf.GT.2
    340 
    341         IF (flag_taux_sol(iff)<=lev_files(iff)) THEN
    342         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
    343         CALL histwrite_phy(nid_files(iff),
    344      $                     "taux_"//clnsurf(nsrf),itau_w,
    345      $      zx_tmp_fi2d)
    346         ENDIF
    347 
    348         IF (flag_tauy_sol(iff)<=lev_files(iff)) THEN           
    349         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
    350         CALL histwrite_phy(nid_files(iff),
    351      $                    "tauy_"//clnsurf(nsrf),itau_w,
    352      $      zx_tmp_fi2d)
    353         ENDIF
    354 
    355         IF (flag_tsol_sol(iff)<=lev_files(iff)) THEN
    356         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
    357         CALL histwrite_phy(nid_files(iff),
    358      $                   "tsol_"//clnsurf(nsrf),itau_w,
    359      $      zx_tmp_fi2d)
    360         ENDIF
    361 
    362       IF (flag_u10m_sol(iff)<=lev_files(iff)) THEN
     359        ENDIF
     360
     361      IF (o_u10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    363362      zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
    364       CALL histwrite_phy(nid_files(iff),"u10m_"//clnsurf(nsrf),
     363      CALL histwrite_phy(nid_files(iff),o_u10m_srf(nsrf)%name,
    365364     $                 itau_w,zx_tmp_fi2d)
    366365      ENDIF
    367366
    368       IF (flag_v10m_sol(iff)<=lev_files(iff)) THEN
     367      IF (o_v10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    369368      zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
    370       CALL histwrite_phy(nid_files(iff),"v10m_"//clnsurf(nsrf),
     369      CALL histwrite_phy(nid_files(iff),o_v10m_srf(nsrf)%name,
    371370     $              itau_w,zx_tmp_fi2d)
    372371      ENDIF
    373372 
    374       IF (flag_t2m_sol(iff)<=lev_files(iff)) THEN
     373      IF (o_t2m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    375374      zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
    376       CALL histwrite_phy(nid_files(iff),"t2m_"//clnsurf(nsrf),
     375      CALL histwrite_phy(nid_files(iff),o_t2m_srf(nsrf)%name,
    377376     $           itau_w,zx_tmp_fi2d)
    378377      ENDIF
    379378
    380        IF (flag_sens_sol(iff)<=lev_files(iff)) THEN
     379       IF (o_sens_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    381380       zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
    382381       CALL histwrite_phy(nid_files(iff),
    383      $                     "sens_"//clnsurf(nsrf),itau_w,
     382     $                    o_sens_srf(nsrf)%name,itau_w,
    384383     $      zx_tmp_fi2d)
    385384       ENDIF
    386385
    387         IF (flag_lat_sol(iff)<=lev_files(iff)) THEN
     386        IF (o_lat_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    388387        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
    389388        CALL histwrite_phy(nid_files(iff),
    390      $                 "lat_"//clnsurf(nsrf),itau_w,
     389     $                 o_lat_srf(nsrf)%name,itau_w,
    391390     $                                   zx_tmp_fi2d)
    392391          ENDIF
    393392
    394         IF (flag_flw_sol(iff)<=lev_files(iff)) THEN
     393        IF (o_flw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    395394        zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
    396395        CALL histwrite_phy(nid_files(iff),
    397      $                     "flw_"//clnsurf(nsrf),itau_w,
     396     $                     o_flw_srf(nsrf)%name,itau_w,
    398397     $      zx_tmp_fi2d)
    399398        ENDIF
    400399
    401         IF (flag_fsw_sol(iff)<=lev_files(iff)) THEN
     400        IF (o_fsw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    402401        zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
    403402        CALL histwrite_phy(nid_files(iff),
    404      $                     "fsw_"//clnsurf(nsrf),itau_w,
     403     $                   o_fsw_srf(nsrf)%name,itau_w,
    405404     $      zx_tmp_fi2d)
    406405        ENDIF
    407406
    408         IF (flag_wbils_sol(iff)<=lev_files(iff)) THEN
     407        IF (o_wbils_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    409408        zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
    410409        CALL histwrite_phy(nid_files(iff),
    411      $                     "wbils_"//clnsurf(nsrf),itau_w,
     410     $                   o_wbils_srf(nsrf)%name,itau_w,
    412411     $      zx_tmp_fi2d)
    413412        ENDIF
    414413
    415         IF (flag_wbilo_sol(iff)<=lev_files(iff)) THEN
     414        IF (o_wbilo_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    416415        zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
    417416        CALL histwrite_phy(nid_files(iff),
    418      $                    "wbilo_"//clnsurf(nsrf),itau_w,
     417     $                    o_wbilo_srf(nsrf)%name,itau_w,
    419418     $      zx_tmp_fi2d)
    420419        ENDIF
    421420
    422421       if (iflag_pbl>1 .and. lev_histday.gt.10 ) then
    423         IF (flag_tke_sol(iff)<=lev_files(iff)) THEN
    424         CALL histwrite_phy(nid_files(iff),
    425      $                    "tke_"//clnsurf(nsrf),itau_w,
    426      $      pbl_tke(:,1:klev,nsrf))
    427        ENDIF
    428 
    429         IF (flag_tke_max_sol(iff)<=lev_files(iff)) THEN
    430         CALL histwrite_phy(nid_files(iff),
    431      $                    "tke_max_"//clnsurf(nsrf),itau_w,
     422        IF (o_tke_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
     423        CALL histwrite_phy(nid_files(iff),
     424     $                   o_tke_srf(nsrf)%name,itau_w,
     425     $                    pbl_tke(:,1:klev,nsrf))
     426       ENDIF
     427
     428        IF (o_tke_max_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
     429        CALL histwrite_phy(nid_files(iff),
     430     $                    o_tke_max_srf(nsrf)%name,itau_w,
    432431     $      pbl_tke(:,1:klev,nsrf))
    433432        ENDIF
     
    435434      ENDDO
    436435
    437         IF (flag_cdrm(iff)<=lev_files(iff)) THEN
    438       CALL histwrite_phy(nid_files(iff),"cdrm",itau_w,cdragm)
    439         ENDIF
    440 
    441         IF (flag_cdrh(iff)<=lev_files(iff)) THEN
    442       CALL histwrite_phy(nid_files(iff),"cdrh",itau_w,cdragh)
    443         ENDIF
    444 
    445         IF (flag_cldl(iff)<=lev_files(iff)) THEN
    446       CALL histwrite_phy(nid_files(iff),"cldl",itau_w,cldl)
    447         ENDIF
    448 
    449         IF (flag_cldm(iff)<=lev_files(iff)) THEN
    450       CALL histwrite_phy(nid_files(iff),"cldm",itau_w,cldm)
    451         ENDIF
    452 
    453         IF (flag_cldh(iff)<=lev_files(iff)) THEN
    454       CALL histwrite_phy(nid_files(iff),"cldh",itau_w,cldh)
    455         ENDIF
    456 
    457         IF (flag_cldt(iff)<=lev_files(iff)) THEN
    458       CALL histwrite_phy(nid_files(iff),"cldt",
     436        IF (o_cdrm%flag(iff)<=lev_files(iff)) THEN
     437      CALL histwrite_phy(nid_files(iff),o_cdrm%name,itau_w,cdragm)
     438        ENDIF
     439
     440        IF (o_cdrh%flag(iff)<=lev_files(iff)) THEN
     441      CALL histwrite_phy(nid_files(iff),o_cdrh%name,itau_w,cdragh)
     442        ENDIF
     443
     444        IF (o_cldl%flag(iff)<=lev_files(iff)) THEN
     445      CALL histwrite_phy(nid_files(iff),o_cldl%name,itau_w,cldl)
     446        ENDIF
     447
     448        IF (o_cldm%flag(iff)<=lev_files(iff)) THEN
     449      CALL histwrite_phy(nid_files(iff),o_cldm%name,itau_w,cldm)
     450        ENDIF
     451
     452        IF (o_cldh%flag(iff)<=lev_files(iff)) THEN
     453      CALL histwrite_phy(nid_files(iff),o_cldh%name,itau_w,cldh)
     454        ENDIF
     455
     456        IF (o_cldt%flag(iff)<=lev_files(iff)) THEN
     457      CALL histwrite_phy(nid_files(iff),o_cldt%name,
    459458     &                   itau_w,cldt*100)
    460459        ENDIF
    461460
    462         IF (flag_cldq(iff)<=lev_files(iff)) THEN
    463       CALL histwrite_phy(nid_files(iff),"cldq",itau_w,cldq)
    464         ENDIF
    465 
    466         IF (flag_lwp(iff)<=lev_files(iff)) THEN
     461        IF (o_cldq%flag(iff)<=lev_files(iff)) THEN
     462      CALL histwrite_phy(nid_files(iff),o_cldq%name,itau_w,cldq)
     463        ENDIF
     464
     465        IF (o_lwp%flag(iff)<=lev_files(iff)) THEN
    467466      zx_tmp_fi2d(1:klon) = flwp(1:klon)
    468       CALL histwrite_phy(nid_files(iff),"lwp",itau_w,zx_tmp_fi2d)
    469         ENDIF
    470 
    471         IF (flag_iwp(iff)<=lev_files(iff)) THEN
     467      CALL histwrite_phy(nid_files(iff),
     468     s                   o_lwp%name,itau_w,zx_tmp_fi2d)
     469        ENDIF
     470
     471        IF (o_iwp%flag(iff)<=lev_files(iff)) THEN
    472472      zx_tmp_fi2d(1:klon) = fiwp(1:klon)
    473       CALL histwrite_phy(nid_files(iff),"iwp",itau_w,zx_tmp_fi2d)
    474         ENDIF
    475 
    476         IF (flag_ue(iff)<=lev_files(iff)) THEN
    477       CALL histwrite_phy(nid_files(iff),"ue",itau_w,ue)
    478         ENDIF
    479 
    480         IF (flag_ve(iff)<=lev_files(iff)) THEN
    481       CALL histwrite_phy(nid_files(iff),"ve",itau_w,ve)
    482         ENDIF
    483 
    484         IF (flag_uq(iff)<=lev_files(iff)) THEN
    485       CALL histwrite_phy(nid_files(iff),"uq",itau_w,uq)
    486         ENDIF
    487 
    488         IF (flag_vq(iff)<=lev_files(iff)) THEN
    489       CALL histwrite_phy(nid_files(iff),"vq",itau_w,vq)
     473      CALL histwrite_phy(nid_files(iff),
     474     s                    o_iwp%name,itau_w,zx_tmp_fi2d)
     475        ENDIF
     476
     477        IF (o_ue%flag(iff)<=lev_files(iff)) THEN
     478      CALL histwrite_phy(nid_files(iff),o_ue%name,itau_w,ue)
     479        ENDIF
     480
     481        IF (o_ve%flag(iff)<=lev_files(iff)) THEN
     482      CALL histwrite_phy(nid_files(iff),o_ve%name,itau_w,ve)
     483        ENDIF
     484
     485        IF (o_uq%flag(iff)<=lev_files(iff)) THEN
     486      CALL histwrite_phy(nid_files(iff),o_uq%name,itau_w,uq)
     487        ENDIF
     488
     489        IF (o_vq%flag(iff)<=lev_files(iff)) THEN
     490      CALL histwrite_phy(nid_files(iff),o_vq%name,itau_w,vq)
    490491        ENDIF
    491492
    492493      IF(iflag_con.GE.3) THEN ! sb
    493         IF (flag_cape(iff)<=lev_files(iff)) THEN
    494       CALL histwrite_phy(nid_files(iff),"cape",itau_w,cape)
    495         ENDIF
    496 
    497         IF (flag_pbase(iff)<=lev_files(iff)) THEN
    498       CALL histwrite_phy(nid_files(iff),"pbase",itau_w,pbase)
    499         ENDIF
    500 
    501         IF (flag_ptop(iff)<=lev_files(iff)) THEN
    502       CALL histwrite_phy(nid_files(iff),"ptop",itau_w,ema_pct)
    503         ENDIF
    504 
    505         IF (flag_fbase(iff)<=lev_files(iff)) THEN
    506       CALL histwrite_phy(nid_files(iff),"fbase",itau_w,ema_cbmf)
    507         ENDIF
    508 
    509         IF (flag_prw(iff)<=lev_files(iff)) THEN
    510       CALL histwrite_phy(nid_files(iff),"prw",itau_w,prw)
     494        IF (o_cape%flag(iff)<=lev_files(iff)) THEN
     495      CALL histwrite_phy(nid_files(iff),o_cape%name,itau_w,cape)
     496        ENDIF
     497
     498        IF (o_pbase%flag(iff)<=lev_files(iff)) THEN
     499      CALL histwrite_phy(nid_files(iff),o_pbase%name,itau_w,pbase)
     500        ENDIF
     501
     502        IF (o_ptop%flag(iff)<=lev_files(iff)) THEN
     503      CALL histwrite_phy(nid_files(iff),o_ptop%name,itau_w,ema_pct)
     504        ENDIF
     505
     506        IF (o_fbase%flag(iff)<=lev_files(iff)) THEN
     507      CALL histwrite_phy(nid_files(iff),o_fbase%name,itau_w,ema_cbmf)
     508        ENDIF
     509
     510        IF (o_prw%flag(iff)<=lev_files(iff)) THEN
     511      CALL histwrite_phy(nid_files(iff),o_prw%name,itau_w,prw)
    511512        ENDIF
    512513      ENDIF !iflag_con .GE. 3
    513514
    514         IF (flag_s_pblh(iff)<=lev_files(iff)) THEN
    515       CALL histwrite_phy(nid_files(iff),"s_pblh",itau_w,s_pblh)
    516         ENDIF
    517 
    518         IF (flag_s_pblt(iff)<=lev_files(iff)) THEN
    519       CALL histwrite_phy(nid_files(iff),"s_pblt",itau_w,s_pblt)
    520         ENDIF
    521 
    522         IF (flag_s_lcl(iff)<=lev_files(iff)) THEN
    523       CALL histwrite_phy(nid_files(iff),"s_lcl",itau_w,s_lcl)
    524         ENDIF
    525 
    526         IF (flag_s_capCL(iff)<=lev_files(iff)) THEN
    527       CALL histwrite_phy(nid_files(iff),"s_capCL",itau_w,s_capCL)
    528         ENDIF
    529 
    530         IF (flag_s_oliqCL(iff)<=lev_files(iff)) THEN
    531       CALL histwrite_phy(nid_files(iff),"s_oliqCL",itau_w,s_oliqCL)
    532         ENDIF
    533 
    534         IF (flag_s_cteiCL(iff)<=lev_files(iff)) THEN
    535       CALL histwrite_phy(nid_files(iff),"s_cteiCL",itau_w,s_cteiCL)
    536         ENDIF
    537 
    538         IF (flag_s_therm(iff)<=lev_files(iff)) THEN
    539       CALL histwrite_phy(nid_files(iff),"s_therm",itau_w,s_therm)
    540         ENDIF
    541 
    542         IF (flag_s_trmb1(iff)<=lev_files(iff)) THEN
    543       CALL histwrite_phy(nid_files(iff),"s_trmb1",itau_w,s_trmb1)
    544         ENDIF
    545 
    546         IF (flag_s_trmb2(iff)<=lev_files(iff)) THEN
    547       CALL histwrite_phy(nid_files(iff),"s_trmb2",itau_w,s_trmb2)
    548         ENDIF
    549 
    550         IF (flag_s_trmb3(iff)<=lev_files(iff)) THEN
    551       CALL histwrite_phy(nid_files(iff),"s_trmb3",itau_w,s_trmb3)
     515        IF (o_s_pblh%flag(iff)<=lev_files(iff)) THEN
     516      CALL histwrite_phy(nid_files(iff),o_s_pblh%name,itau_w,s_pblh)
     517        ENDIF
     518
     519        IF (o_s_pblt%flag(iff)<=lev_files(iff)) THEN
     520      CALL histwrite_phy(nid_files(iff),o_s_pblt%name,itau_w,s_pblt)
     521        ENDIF
     522
     523        IF (o_s_lcl%flag(iff)<=lev_files(iff)) THEN
     524      CALL histwrite_phy(nid_files(iff),o_s_lcl%name,itau_w,s_lcl)
     525        ENDIF
     526
     527        IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
     528      CALL histwrite_phy(nid_files(iff),o_s_capCL%name,itau_w,s_capCL)
     529        ENDIF
     530
     531        IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
     532      CALL histwrite_phy(nid_files(iff),o_s_oliqCL%name,itau_w,s_oliqCL)
     533        ENDIF
     534
     535        IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
     536      CALL histwrite_phy(nid_files(iff),o_s_cteiCL%name,itau_w,s_cteiCL)
     537        ENDIF
     538
     539        IF (o_s_therm%flag(iff)<=lev_files(iff)) THEN
     540      CALL histwrite_phy(nid_files(iff),o_s_therm%name,itau_w,s_therm)
     541        ENDIF
     542
     543        IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
     544      CALL histwrite_phy(nid_files(iff),o_s_trmb1%name,itau_w,s_trmb1)
     545        ENDIF
     546
     547        IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
     548      CALL histwrite_phy(nid_files(iff),o_s_trmb2%name,itau_w,s_trmb2)
     549        ENDIF
     550
     551        IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
     552      CALL histwrite_phy(nid_files(iff),o_s_trmb3%name,itau_w,s_trmb3)
    552553        ENDIF
    553554
     
    559560!      on ecrit u v t q a 850 700 500 200 au niv 3
    560561
     562        ll=0
    561563        DO k=1, nlevSTD
    562564         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
     
    566568
    567569! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    568        IF (flag_ulevsSTD(iff)<=lev_files(iff)) THEN
    569        CALL histwrite_phy(nid_files(iff),"u"//bb2,
    570      & itau_w,uwriteSTD(:,k,iff))
    571        ENDIF
    572 
    573        IF (flag_vlevsSTD(iff)<=lev_files(iff)) THEN
    574       CALL histwrite_phy(nid_files(iff),"v"//bb2, 
    575      & itau_w,vwriteSTD(:,k,iff))
    576        ENDIF
    577 
    578        IF (flag_wlevsSTD(iff)<=lev_files(iff)) THEN
    579       CALL histwrite_phy(nid_files(iff),"w"//bb2,
    580      & itau_w,wwriteSTD(:,k,iff))
    581        ENDIF
    582 
    583        IF (flag_philevsSTD(iff)<=lev_files(iff)) THEN
    584       CALL histwrite_phy(nid_files(iff),
    585      $                  "phi"//bb2,
     570          ll=ll+1
     571       IF (o_uSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     572       CALL histwrite_phy(nid_files(iff),o_uSTDlevs(ll)%name,
     573     &                    itau_w,uwriteSTD(:,k,iff))
     574       ENDIF
     575
     576       IF (o_vSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     577      CALL histwrite_phy(nid_files(iff),o_vSTDlevs(ll)%name, 
     578     &                   itau_w,vwriteSTD(:,k,iff))
     579       ENDIF
     580
     581       IF (o_wSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     582      CALL histwrite_phy(nid_files(iff),o_wSTDlevs(ll)%name,
     583     &                    itau_w,wwriteSTD(:,k,iff))
     584       ENDIF
     585
     586       IF (o_phiSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     587      CALL histwrite_phy(nid_files(iff),o_phiSTDlevs(ll)%name,
    586588     &               itau_w,phiwriteSTD(:,k,iff))
    587589       ENDIF
    588590
    589        IF (flag_qlevsSTD(iff)<=lev_files(iff)) THEN
    590       CALL histwrite_phy(nid_files(iff),"q"//bb2,
    591      & itau_w, qwriteSTD(:,k,iff))
    592        ENDIF
    593 
    594        IF (flag_tlevsSTD(iff)<=lev_files(iff)) THEN
    595       CALL histwrite_phy(nid_files(iff),"t"//bb2,
    596      & itau_w, twriteSTD(:,k,iff))
     591       IF (o_qSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     592      CALL histwrite_phy(nid_files(iff),o_qSTDlevs(ll)%name,
     593     &                   itau_w, qwriteSTD(:,k,iff))
     594       ENDIF
     595
     596       IF (o_tSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
     597      CALL histwrite_phy(nid_files(iff),o_tSTDlevs(ll)%name,
     598     &                   itau_w, twriteSTD(:,k,iff))
    597599       ENDIF
    598600
     
    600602       ENDDO
    601603
    602       IF (flag_t_oce_sic(iff)<=lev_files(iff)) THEN
     604      IF (o_t_oce_sic%flag(iff)<=lev_files(iff)) THEN
    603605      DO i=1, klon
    604606       IF (pctsrf(i,is_oce).GT.epsfra.OR.
     
    611613       ENDIF
    612614      ENDDO
    613       CALL histwrite_phy(nid_files(iff),"t_oce_sic",itau_w,zx_tmp_fi2d)
     615      CALL histwrite_phy(nid_files(iff),
     616     s                   o_t_oce_sic%name,itau_w,zx_tmp_fi2d)
    614617      ENDIF
    615618
     
    618621      IF (iflag_con.GE.3) THEN
    619622      IF (iflag_coupl.EQ.1) THEN
    620        IF (flag_ale_bl(iff)<=lev_files(iff)) THEN
    621        CALL histwrite_phy(nid_files(iff),"ale_bl",itau_w,ale_bl)
    622        ENDIF
    623        IF (flag_alp_bl(iff)<=lev_files(iff)) THEN
    624        CALL histwrite_phy(nid_files(iff),"alp_bl",itau_w,alp_bl)
     623       IF (o_ale_bl%flag(iff)<=lev_files(iff)) THEN
     624       CALL histwrite_phy(nid_files(iff),o_ale_bl%name,itau_w,ale_bl)
     625       ENDIF
     626       IF (o_alp_bl%flag(iff)<=lev_files(iff)) THEN
     627       CALL histwrite_phy(nid_files(iff),o_alp_bl%name,itau_w,alp_bl)
    625628       ENDIF
    626629      ENDIF !iflag_coupl.EQ.1
    627 
     630      ENDIF !(iflag_con.GE.3)
     631      IF (iflag_con.EQ.3) THEN
    628632      IF (iflag_wake.EQ.1) THEN
    629        IF (flag_ale_wk(iff)<=lev_files(iff)) THEN
    630        CALL histwrite_phy(nid_files(iff),"ale_wk",itau_w,ale_wake)
    631        ENDIF
    632        IF (flag_alp_wk(iff)<=lev_files(iff)) THEN
    633        CALL histwrite_phy(nid_files(iff),"alp_wk",itau_w,alp_wake)
    634        ENDIF
    635 
    636        IF (flag_ale(iff)<=lev_files(iff)) THEN
    637        CALL histwrite_phy(nid_files(iff),"ale",itau_w,ale)
    638        ENDIF
    639        IF (flag_alp(iff)<=lev_files(iff)) THEN
    640        CALL histwrite_phy(nid_files(iff),"alp",itau_w,alp)
    641        ENDIF
    642        IF (flag_cin(iff)<=lev_files(iff)) THEN
    643        CALL histwrite_phy(nid_files(iff),"cin",itau_w,cin)
    644        ENDIF
    645        IF (flag_wape(iff)<=lev_files(iff)) THEN
    646        CALL histwrite_phy(nid_files(iff),"WAPE",itau_w,wake_pe)
    647        ENDIF
    648        IF (flag_wake_h(iff)<=lev_files(iff)) THEN
    649       CALL histwrite_phy(nid_files(iff),"wake_h",itau_w,wake_h)
    650        ENDIF
    651 
    652        IF (flag_wake_s(iff)<=lev_files(iff)) THEN
    653       CALL histwrite_phy(nid_files(iff),"wake_s",itau_w,wake_s)
    654        ENDIF
    655 
    656         IF (flag_wake_deltat(iff)<=lev_files(iff)) THEN
    657        CALL histwrite_phy(nid_files(iff),"wake_deltat",
     633       IF (o_ale_wk%flag(iff)<=lev_files(iff)) THEN
     634       CALL histwrite_phy(nid_files(iff),o_ale_wk%name,itau_w,ale_wake)
     635       ENDIF
     636       IF (o_alp_wk%flag(iff)<=lev_files(iff)) THEN
     637       CALL histwrite_phy(nid_files(iff),o_alp_wk%name,itau_w,alp_wake)
     638       ENDIF
     639
     640       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
     641       CALL histwrite_phy(nid_files(iff),o_ale%name,itau_w,ale)
     642       ENDIF
     643       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
     644       CALL histwrite_phy(nid_files(iff),o_alp%name,itau_w,alp)
     645       ENDIF
     646       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
     647       CALL histwrite_phy(nid_files(iff),o_cin%name,itau_w,cin)
     648       ENDIF
     649       IF (o_wape%flag(iff)<=lev_files(iff)) THEN
     650       CALL histwrite_phy(nid_files(iff),o_WAPE%name,itau_w,wake_pe)
     651       ENDIF
     652       IF (o_wake_h%flag(iff)<=lev_files(iff)) THEN
     653      CALL histwrite_phy(nid_files(iff),o_wake_h%name,itau_w,wake_h)
     654       ENDIF
     655
     656       IF (o_wake_s%flag(iff)<=lev_files(iff)) THEN
     657      CALL histwrite_phy(nid_files(iff),o_wake_s%name,itau_w,wake_s)
     658       ENDIF
     659
     660        IF (o_wake_deltat%flag(iff)<=lev_files(iff)) THEN
     661       CALL histwrite_phy(nid_files(iff),o_wake_deltat%name,
    658662     $                     itau_w,wake_deltat)
    659663        ENDIF
    660664
    661         IF (flag_wake_deltaq(iff)<=lev_files(iff)) THEN
    662        CALL histwrite_phy(nid_files(iff),"wake_deltaq",
     665        IF (o_wake_deltaq%flag(iff)<=lev_files(iff)) THEN
     666       CALL histwrite_phy(nid_files(iff),o_wake_deltaq%name,
    663667     $                    itau_w,wake_deltaq)
    664668        ENDIF
    665669
    666         IF (flag_wake_omg(iff)<=lev_files(iff)) THEN
    667        CALL histwrite_phy(nid_files(iff),"wake_omg",itau_w,wake_omg)
    668         ENDIF
    669       ENDIF
    670 
    671         IF (flag_Vprecip(iff)<=lev_files(iff)) THEN
    672        CALL histwrite_phy(nid_files(iff),"Vprecip",itau_w,Vprecip)
    673         ENDIF
    674 
    675         IF (flag_ftd(iff)<=lev_files(iff)) THEN
    676        CALL histwrite_phy(nid_files(iff),"ftd",itau_w,ftd)
    677         ENDIF
    678 
    679         IF (flag_fqd(iff)<=lev_files(iff)) THEN
    680        CALL histwrite_phy(nid_files(iff),"fqd",itau_w,fqd)
    681         ENDIF
    682 
    683       ENDIF !(iflag_con.GE.3)
     670        IF (o_wake_omg%flag(iff)<=lev_files(iff)) THEN
     671       CALL histwrite_phy(nid_files(iff),
     672     s                    o_wake_omg%name,itau_w,wake_omg)
     673        ENDIF
     674      ENDIF
     675
     676        IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
     677       CALL histwrite_phy(nid_files(iff),o_Vprecip%name,itau_w,Vprecip)
     678        ENDIF
     679
     680        IF (o_ftd%flag(iff)<=lev_files(iff)) THEN
     681       CALL histwrite_phy(nid_files(iff),o_ftd%name,itau_w,ftd)
     682        ENDIF
     683
     684        IF (o_fqd%flag(iff)<=lev_files(iff)) THEN
     685       CALL histwrite_phy(nid_files(iff),o_fqd%name,itau_w,fqd)
     686        ENDIF
     687
     688      ENDIF !(iflag_con.EQ.3)
    684689 
    685690      ELSE IF (type_ocean=='slab  ') THEN
    686691
    687       IF ( flag_slab_bils(iff)<=lev_files(iff))
     692      IF ( o_slab_bils%flag(iff)<=lev_files(iff))
    688693     $     CALL histwrite_phy(
    689      $     nid_files(iff),"slab_wbils_oce",itau_w,slab_wfbils)
     694     $     nid_files(iff),o_slab_bils%name,itau_w,slab_wfbils)
    690695
    691696      ENDIF !type_ocean == force/slab
    692697
    693       IF (flag_weakinv(iff)<=lev_files(iff)) THEN
    694       CALL histwrite_phy(nid_files(iff),"weakinv",itau_w,weak_inversion)
    695       ENDIF
    696 
    697       IF (flag_dthmin(iff)<=lev_files(iff)) THEN
    698       CALL histwrite_phy(nid_files(iff),"dthmin",itau_w,dthmin)
    699       ENDIF
    700 
    701        IF (flag_cldtau(iff)<=lev_files(iff)) THEN
    702        CALL histwrite_phy(nid_files(iff),"cldtau",itau_w,cldtau)
    703        ENDIF
    704 
    705        IF (flag_cldemi(iff)<=lev_files(iff)) THEN
    706        CALL histwrite_phy(nid_files(iff),"cldemi",itau_w,cldemi)
    707        ENDIF
    708 
    709 !      IF (flag_pr_con_l(iff)<=lev_files(iff)) THEN
    710 !      CALL histwrite_phy(nid_files(iff),"pmflxr",itau_w,pmflxr)
     698      IF (o_weakinv%flag(iff)<=lev_files(iff)) THEN
     699      CALL histwrite_phy(nid_files(iff),
     700     s                  o_weakinv%name,itau_w,weak_inversion)
     701      ENDIF
     702
     703      IF (o_dthmin%flag(iff)<=lev_files(iff)) THEN
     704      CALL histwrite_phy(nid_files(iff),o_dthmin%name,itau_w,dthmin)
     705      ENDIF
     706
     707       IF (o_cldtau%flag(iff)<=lev_files(iff)) THEN
     708       CALL histwrite_phy(nid_files(iff),o_cldtau%name,itau_w,cldtau)
     709       ENDIF
     710
     711       IF (o_cldemi%flag(iff)<=lev_files(iff)) THEN
     712       CALL histwrite_phy(nid_files(iff),o_cldemi%name,itau_w,cldemi)
     713       ENDIF
     714
     715!      IF (o_pr_con_l%flag(iff)<=lev_files(iff)) THEN
     716!      CALL histwrite_phy(nid_files(iff),o_pmflxr%name,itau_w,pmflxr)
    711717!      ENDIF
    712718
    713 !      IF (flag_pr_con_i(iff)<=lev_files(iff)) THEN
    714 !      CALL histwrite_phy(nid_files(iff),"pmflxs",itau_w,pmflxs)
     719!      IF (o_pr_con_i%flag(iff)<=lev_files(iff)) THEN
     720!      CALL histwrite_phy(nid_files(iff),o_pmflxs%name,itau_w,pmflxs)
    715721!      ENDIF
    716722
    717 !      IF (flag_pr_lsc_l(iff)<=lev_files(iff)) THEN
    718 !      CALL histwrite_phy(nid_files(iff),"prfl",itau_w,prfl)
     723!      IF (o_pr_lsc_l%flag(iff)<=lev_files(iff)) THEN
     724!      CALL histwrite_phy(nid_files(iff),o_prfl%name,itau_w,prfl)
    719725!      ENDIF
    720726
    721 !      IF (flag_pr_lsc_i(iff)<=lev_files(iff)) THEN
    722 !      CALL histwrite_phy(nid_files(iff),"psfl",itau_w,psfl)
     727!      IF (o_pr_lsc_i%flag(iff)<=lev_files(iff)) THEN
     728!      CALL histwrite_phy(nid_files(iff),o_psfl%name,itau_w,psfl)
    723729!      ENDIF
    724730
    725       IF (flag_rh2m(iff)<=lev_files(iff)) THEN
     731      IF (o_rh2m%flag(iff)<=lev_files(iff)) THEN
    726732      DO i=1, klon
    727733       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
    728734      ENDDO
    729       CALL histwrite_phy(nid_files(iff),"rh2m",itau_w,zx_tmp_fi2d)
    730       ENDIF
    731 
    732       IF (flag_qsat2m(iff)<=lev_files(iff)) THEN
    733       CALL histwrite_phy(nid_files(iff),"qsat2m",itau_w,qsat2m)
    734       ENDIF
    735 
    736       IF (flag_tpot(iff)<=lev_files(iff)) THEN
    737       CALL histwrite_phy(nid_files(iff),"tpot",itau_w,tpot)
    738       ENDIF
    739 
    740        IF (flag_tpote(iff)<=lev_files(iff)) THEN
    741       CALL histwrite_phy(nid_files(iff),"tpote",itau_w,tpote)
    742        ENDIF
    743 
    744       IF (flag_SWnetOR(iff)<=lev_files(iff)) THEN
     735      CALL histwrite_phy(nid_files(iff),o_rh2m%name,itau_w,zx_tmp_fi2d)
     736      ENDIF
     737
     738      IF (o_qsat2m%flag(iff)<=lev_files(iff)) THEN
     739      CALL histwrite_phy(nid_files(iff),o_qsat2m%name,itau_w,qsat2m)
     740      ENDIF
     741
     742      IF (o_tpot%flag(iff)<=lev_files(iff)) THEN
     743      CALL histwrite_phy(nid_files(iff),o_tpot%name,itau_w,tpot)
     744      ENDIF
     745
     746       IF (o_tpote%flag(iff)<=lev_files(iff)) THEN
     747      CALL histwrite_phy(nid_files(iff),o_tpote%name,itau_w,tpote)
     748       ENDIF
     749
     750      IF (o_SWnetOR%flag(iff)<=lev_files(iff)) THEN
    745751      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
    746       CALL histwrite_phy(nid_files(iff),"SWnetOR",itau_w, zx_tmp_fi2d)
    747       ENDIF
    748 
    749       IF (flag_SWdownOR(iff)<=lev_files(iff)) THEN
     752      CALL histwrite_phy(nid_files(iff),
     753     s                   o_SWnetOR%name,itau_w, zx_tmp_fi2d)
     754      ENDIF
     755
     756      IF (o_SWdownOR%flag(iff)<=lev_files(iff)) THEN
    750757      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
    751       CALL histwrite_phy(nid_files(iff),"SWdownOR",itau_w, zx_tmp_fi2d)
    752       ENDIF
    753 
    754       IF (flag_LWdownOR(iff)<=lev_files(iff)) THEN
    755       CALL histwrite_phy(nid_files(iff),"LWdownOR",itau_w,sollwdown)
    756       ENDIF
    757 
    758       IF (flag_snowl(iff)<=lev_files(iff)) THEN
    759       CALL histwrite_phy(nid_files(iff),"snowl",itau_w,snow_lsc)
     758      CALL histwrite_phy(nid_files(iff),
     759     s                   o_SWdownOR%name,itau_w, zx_tmp_fi2d)
     760      ENDIF
     761
     762      IF (o_LWdownOR%flag(iff)<=lev_files(iff)) THEN
     763      CALL histwrite_phy(nid_files(iff),
     764     s                  o_LWdownOR%name,itau_w,sollwdown)
     765      ENDIF
     766
     767      IF (o_snowl%flag(iff)<=lev_files(iff)) THEN
     768      CALL histwrite_phy(nid_files(iff),o_snowl%name,itau_w,snow_lsc)
    760769      ENDIF
    761770
    762771      IF (iflag_con.GE.3) THEN
    763       IF (flag_cape_max(iff)<=lev_files(iff)) THEN
    764       CALL histwrite_phy(nid_files(iff),"cape_max",itau_w,cape)
     772      IF (o_cape_max%flag(iff)<=lev_files(iff)) THEN
     773      CALL histwrite_phy(nid_files(iff),o_cape_max%name,itau_w,cape)
    765774      ENDIF
    766775      ENDIF !(iflag_con.GE.3)
    767776
    768       IF (flag_solldown(iff)<=lev_files(iff)) THEN
    769       CALL histwrite_phy(nid_files(iff),"solldown",itau_w,sollwdown)
    770       ENDIF
    771 
    772       IF (flag_dtsvdfo(iff)<=lev_files(iff)) THEN
    773       CALL histwrite_phy(nid_files(iff),"dtsvdfo",itau_w,d_ts(:,is_oce))
    774       ENDIF
    775 
    776       IF (flag_dtsvdft(iff)<=lev_files(iff)) THEN
    777       CALL histwrite_phy(nid_files(iff),"dtsvdft",itau_w,d_ts(:,is_ter))
    778       ENDIF
    779 
    780        IF (flag_dtsvdfg(iff)<=lev_files(iff)) THEN
    781         CALL histwrite_phy(nid_files(iff),
    782      $                     "dtsvdfg",itau_w, d_ts(:,is_lic))
    783        ENDIF
    784 
    785        IF (flag_dtsvdfi(iff)<=lev_files(iff)) THEN
    786       CALL histwrite_phy(nid_files(iff),"dtsvdfi",itau_w,d_ts(:,is_sic))
    787        ENDIF
    788 
    789        IF (flag_rugs(iff)<=lev_files(iff)) THEN
    790       CALL histwrite_phy(nid_files(iff),"rugs",itau_w,zxrugs)
     777      IF (o_solldown%flag(iff)<=lev_files(iff)) THEN
     778      CALL histwrite_phy(nid_files(iff),
     779     s                   o_solldown%name,itau_w,sollwdown)
     780      ENDIF
     781
     782      IF (o_dtsvdfo%flag(iff)<=lev_files(iff)) THEN
     783      CALL histwrite_phy(nid_files(iff),
     784     s                 o_dtsvdfo%name,itau_w,d_ts(:,is_oce))
     785      ENDIF
     786
     787      IF (o_dtsvdft%flag(iff)<=lev_files(iff)) THEN
     788      CALL histwrite_phy(nid_files(iff),
     789     s                   o_dtsvdft%name,itau_w,d_ts(:,is_ter))
     790      ENDIF
     791
     792       IF (o_dtsvdfg%flag(iff)<=lev_files(iff)) THEN
     793        CALL histwrite_phy(nid_files(iff),
     794     $                   o_dtsvdfg%name,itau_w, d_ts(:,is_lic))
     795       ENDIF
     796
     797       IF (o_dtsvdfi%flag(iff)<=lev_files(iff)) THEN
     798      CALL histwrite_phy(nid_files(iff),
     799     s                   o_dtsvdfi%name,itau_w,d_ts(:,is_sic))
     800       ENDIF
     801
     802       IF (o_rugs%flag(iff)<=lev_files(iff)) THEN
     803      CALL histwrite_phy(nid_files(iff),o_rugs%name,itau_w,zxrugs)
    791804       ENDIF
    792805
    793806! Champs 3D:
    794        IF (flag_lwcon(iff)<=lev_files(iff)) THEN
    795       CALL histwrite_phy(nid_files(iff),"lwcon",itau_w,flwc)
    796        ENDIF
    797 
    798        IF (flag_iwcon(iff)<=lev_files(iff)) THEN
    799       CALL histwrite_phy(nid_files(iff),"iwcon",itau_w,fiwc)
    800        ENDIF
    801 
    802        IF (flag_temp(iff)<=lev_files(iff)) THEN
    803       CALL histwrite_phy(nid_files(iff),"temp",itau_w,t_seri)
    804        ENDIF
    805 
    806        IF (flag_theta(iff)<=lev_files(iff)) THEN
    807       CALL histwrite_phy(nid_files(iff),"theta",itau_w,theta)
    808        ENDIF
    809 
    810        IF (flag_ovap(iff)<=lev_files(iff)) THEN
    811       CALL histwrite_phy(nid_files(iff),"ovap",itau_w,qx(:,:,ivap))
    812        ENDIF
    813 
    814        IF (flag_geop(iff)<=lev_files(iff)) THEN
    815       CALL histwrite_phy(nid_files(iff),"geop",itau_w,zphi)
    816        ENDIF
    817 
    818        IF (flag_vitu(iff)<=lev_files(iff)) THEN
    819       CALL histwrite_phy(nid_files(iff),"vitu",itau_w,u_seri)
    820        ENDIF
    821 
    822        IF (flag_vitv(iff)<=lev_files(iff)) THEN
    823       CALL histwrite_phy(nid_files(iff),"vitv",itau_w,v_seri)
    824        ENDIF
    825 
    826        IF (flag_vitw(iff)<=lev_files(iff)) THEN
    827       CALL histwrite_phy(nid_files(iff),"vitw",itau_w,omega)
    828        ENDIF
    829 
    830         IF (flag_pres(iff)<=lev_files(iff)) THEN
    831       CALL histwrite_phy(nid_files(iff),"pres",itau_w,pplay)
    832         ENDIF
    833 
    834        IF (flag_rneb(iff)<=lev_files(iff)) THEN
    835       CALL histwrite_phy(nid_files(iff),"rneb",itau_w,cldfra)
    836        ENDIF
    837 
    838        IF (flag_rnebcon(iff)<=lev_files(iff)) THEN
    839       CALL histwrite_phy(nid_files(iff),"rnebcon",itau_w,rnebcon)
    840        ENDIF
    841 
    842        IF (flag_rhum(iff)<=lev_files(iff)) THEN
    843       CALL histwrite_phy(nid_files(iff),"rhum",itau_w,zx_rh)
    844        ENDIF
    845 
    846       IF (flag_ozone(iff)<=lev_files(iff)) THEN
     807       IF (o_lwcon%flag(iff)<=lev_files(iff)) THEN
     808      CALL histwrite_phy(nid_files(iff),o_lwcon%name,itau_w,flwc)
     809       ENDIF
     810
     811       IF (o_iwcon%flag(iff)<=lev_files(iff)) THEN
     812      CALL histwrite_phy(nid_files(iff),o_iwcon%name,itau_w,fiwc)
     813       ENDIF
     814
     815       IF (o_temp%flag(iff)<=lev_files(iff)) THEN
     816      CALL histwrite_phy(nid_files(iff),o_temp%name,itau_w,t_seri)
     817       ENDIF
     818
     819       IF (o_theta%flag(iff)<=lev_files(iff)) THEN
     820      CALL histwrite_phy(nid_files(iff),o_theta%name,itau_w,theta)
     821       ENDIF
     822
     823       IF (o_ovap%flag(iff)<=lev_files(iff)) THEN
     824      CALL histwrite_phy(nid_files(iff),o_ovap%name,itau_w,qx(:,:,ivap))
     825       ENDIF
     826
     827       IF (o_geop%flag(iff)<=lev_files(iff)) THEN
     828      CALL histwrite_phy(nid_files(iff),o_geop%name,itau_w,zphi)
     829       ENDIF
     830
     831       IF (o_vitu%flag(iff)<=lev_files(iff)) THEN
     832      CALL histwrite_phy(nid_files(iff),o_vitu%name,itau_w,u_seri)
     833       ENDIF
     834
     835       IF (o_vitv%flag(iff)<=lev_files(iff)) THEN
     836      CALL histwrite_phy(nid_files(iff),o_vitv%name,itau_w,v_seri)
     837       ENDIF
     838
     839       IF (o_vitw%flag(iff)<=lev_files(iff)) THEN
     840      CALL histwrite_phy(nid_files(iff),o_vitw%name,itau_w,omega)
     841       ENDIF
     842
     843        IF (o_pres%flag(iff)<=lev_files(iff)) THEN
     844      CALL histwrite_phy(nid_files(iff),o_pres%name,itau_w,pplay)
     845        ENDIF
     846
     847       IF (o_rneb%flag(iff)<=lev_files(iff)) THEN
     848      CALL histwrite_phy(nid_files(iff),o_rneb%name,itau_w,cldfra)
     849       ENDIF
     850
     851       IF (o_rnebcon%flag(iff)<=lev_files(iff)) THEN
     852      CALL histwrite_phy(nid_files(iff),o_rnebcon%name,itau_w,rnebcon)
     853       ENDIF
     854
     855       IF (o_rhum%flag(iff)<=lev_files(iff)) THEN
     856      CALL histwrite_phy(nid_files(iff),o_rhum%name,itau_w,zx_rh)
     857       ENDIF
     858
     859      IF (o_ozone%flag(iff)<=lev_files(iff)) THEN
    847860      DO k=1, klev
    848861       DO i=1, klon
     
    852865       ENDDO !i
    853866      ENDDO !k
    854       CALL histwrite_phy(nid_files(iff),"ozone",itau_w,zx_tmp_fi3d)
     867      CALL histwrite_phy(nid_files(iff),o_ozone%name,itau_w,zx_tmp_fi3d)
    855868      ENDIF
    856869
    857870      IF(iflag_con.GE.3) THEN
    858        IF (flag_upwd(iff)<=lev_files(iff)) THEN
    859       CALL histwrite_phy(nid_files(iff),"upwd",itau_w,upwd)
     871       IF (o_upwd%flag(iff)<=lev_files(iff)) THEN
     872      CALL histwrite_phy(nid_files(iff),o_upwd%name,itau_w,upwd)
    860873       ENDIF
    861874      ENDIF !(iflag_con.GE.3)
    862875
    863        IF (flag_dtphy(iff)<=lev_files(iff)) THEN
    864       CALL histwrite_phy(nid_files(iff),"dtphy",itau_w,d_t)
    865        ENDIF
    866 
    867        IF (flag_dqphy(iff)<=lev_files(iff)) THEN
    868       CALL histwrite_phy(nid_files(iff),"dqphy",itau_w, d_qx(:,:,ivap))
     876       IF (o_dtphy%flag(iff)<=lev_files(iff)) THEN
     877      CALL histwrite_phy(nid_files(iff),o_dtphy%name,itau_w,d_t)
     878       ENDIF
     879
     880       IF (o_dqphy%flag(iff)<=lev_files(iff)) THEN
     881      CALL histwrite_phy(nid_files(iff),
     882     s                  o_dqphy%name,itau_w, d_qx(:,:,ivap))
    869883       ENDIF
    870884
    871885        DO nsrf=1, nbsrf
    872         IF (flag_albe_sol(iff)<=lev_files(iff)) THEN
     886        IF (o_albe_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    873887        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
    874         CALL histwrite_phy(nid_files(iff),"albe_"//clnsurf(nsrf),itau_w,
     888        CALL histwrite_phy(nid_files(iff),
     889     s                    o_albe_srf(nsrf)%name,itau_w,
     890     $                     zx_tmp_fi2d)
     891        ENDIF
     892
     893        IF (o_rugs_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN 
     894        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
     895        CALL histwrite_phy(nid_files(iff),
     896     s                     o_rugs_srf(nsrf)%name,itau_w,
    875897     $      zx_tmp_fi2d)
    876898        ENDIF
    877899
    878         IF (flag_rugs_sol(iff)<=lev_files(iff)) THEN 
    879         zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
    880         CALL histwrite_phy(nid_files(iff),"rugs_"//clnsurf(nsrf),itau_w,
    881      $      zx_tmp_fi2d)
    882         ENDIF
    883 
    884         IF (flag_ages_sol(iff)<=lev_files(iff)) THEN
     900        IF (o_ages_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
    885901        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
    886         CALL histwrite_phy(nid_files(iff),"ages_"//clnsurf(nsrf),itau_w
     902        CALL histwrite_phy(nid_files(iff),
     903     s                     o_ages_srf(nsrf)%name,itau_w
    887904     $    ,zx_tmp_fi2d)
    888905        ENDIF
    889906        ENDDO !nsrf=1, nbsrf
    890907
    891        IF (flag_albs(iff)<=lev_files(iff)) THEN
    892       CALL histwrite_phy(nid_files(iff),"albs",itau_w,albsol1)
    893        ENDIF
    894 
    895        IF (flag_albslw(iff)<=lev_files(iff)) THEN
    896       CALL histwrite_phy(nid_files(iff),"albslw",itau_w,albsol2)
     908       IF (o_albs%flag(iff)<=lev_files(iff)) THEN
     909      CALL histwrite_phy(nid_files(iff),o_albs%name,itau_w,albsol1)
     910       ENDIF
     911
     912       IF (o_albslw%flag(iff)<=lev_files(iff)) THEN
     913      CALL histwrite_phy(nid_files(iff),o_albslw%name,itau_w,albsol2)
    897914       ENDIF
    898915
     
    906923         enddo
    907924      enddo
    908        IF (flag_tke(iff)<=lev_files(iff)) THEN
    909       CALL histwrite_phy(nid_files(iff),"tke",itau_w,zx_tmp_fi3d)
    910        ENDIF
    911 
    912        IF (flag_tke_max(iff)<=lev_files(iff)) THEN
    913       CALL histwrite_phy(nid_files(iff),"tke_max",itau_w,zx_tmp_fi3d)
     925       IF (o_tke%flag(iff)<=lev_files(iff)) THEN
     926      CALL histwrite_phy(nid_files(iff),o_tke%name,itau_w,zx_tmp_fi3d)
     927       ENDIF
     928
     929       IF (o_tke_max%flag(iff)<=lev_files(iff)) THEN
     930      CALL histwrite_phy(nid_files(iff),
     931     s                   o_tke_max%name,itau_w,zx_tmp_fi3d)
    914932       ENDIF
    915933      endif
    916934
    917        IF (flag_kz(iff)<=lev_files(iff)) THEN
    918       ! combinaision de cdrag et le coef melange dans la meme variable
    919       zx_tmp_fi3d(:,1)     = cdragh(:)
    920       zx_tmp_fi3d(:,2:klev)= coefh(:,2:klev)
    921       CALL histwrite_phy(nid_files(iff),"kz",itau_w,zx_tmp_fi3d)
    922        ENDIF
    923 
    924        IF (flag_kz_max(iff)<=lev_files(iff)) THEN
    925       ! combinaision de cdrag et le coef melange dans la meme variable
    926       zx_tmp_fi3d(:,1)     = cdragh(:)
    927       zx_tmp_fi3d(:,2:klev)= coefh(:,2:klev)
    928       CALL histwrite_phy(nid_files(iff),"kz_max",itau_w,zx_tmp_fi3d)
    929        ENDIF
    930 
    931        IF (flag_clwcon(iff)<=lev_files(iff)) THEN
    932       CALL histwrite_phy(nid_files(iff),"clwcon",itau_w,clwcon0)
     935       IF (o_kz%flag(iff)<=lev_files(iff)) THEN
     936      CALL histwrite_phy(nid_files(iff),o_kz%name,itau_w,coefh)
     937       ENDIF
     938
     939       IF (o_kz_max%flag(iff)<=lev_files(iff)) THEN
     940      CALL histwrite_phy(nid_files(iff),o_kz_max%name,itau_w,coefh)
     941       ENDIF
     942
     943       IF (o_clwcon%flag(iff)<=lev_files(iff)) THEN
     944      CALL histwrite_phy(nid_files(iff),o_clwcon%name,itau_w,clwcon0)
    933945       ENDIF
    934946
    935947      IF(iflag_con.GE.3) THEN
    936        IF (flag_Ma(iff)<=lev_files(iff)) THEN
    937       CALL histwrite_phy(nid_files(iff),"Ma",itau_w,Ma)
    938        ENDIF
    939 
    940        IF (flag_dnwd(iff)<=lev_files(iff)) THEN
    941       CALL histwrite_phy(nid_files(iff),"dnwd",itau_w,dnwd)
    942        ENDIF
    943 
    944        IF (flag_dnwd0(iff)<=lev_files(iff)) THEN
    945       CALL histwrite_phy(nid_files(iff),"dnwd0",itau_w,dnwd0)
     948       IF (o_Ma%flag(iff)<=lev_files(iff)) THEN
     949      CALL histwrite_phy(nid_files(iff),o_Ma%name,itau_w,Ma)
     950       ENDIF
     951
     952       IF (o_dnwd%flag(iff)<=lev_files(iff)) THEN
     953      CALL histwrite_phy(nid_files(iff),o_dnwd%name,itau_w,dnwd)
     954       ENDIF
     955
     956       IF (o_dnwd0%flag(iff)<=lev_files(iff)) THEN
     957      CALL histwrite_phy(nid_files(iff),o_dnwd0%name,itau_w,dnwd0)
    946958       ENDIF
    947959      ENDIF !(iflag_con.GE.3)
    948960
    949        IF (flag_dtdyn(iff)<=lev_files(iff)) THEN
    950       CALL histwrite_phy(nid_files(iff),"dtdyn",itau_w,d_t_dyn)
    951        ENDIF
    952 
    953        IF (flag_dqdyn(iff)<=lev_files(iff)) THEN
    954       CALL histwrite_phy(nid_files(iff),"dqdyn",itau_w,d_q_dyn)
    955        ENDIF
    956 
    957        IF (flag_dudyn(iff)<=lev_files(iff)) THEN
    958       CALL histwrite_phy(nid_files(iff),"dudyn",itau_w,d_u_dyn)
     961       IF (o_dtdyn%flag(iff)<=lev_files(iff)) THEN
     962      CALL histwrite_phy(nid_files(iff),o_dtdyn%name,itau_w,d_t_dyn)
     963       ENDIF
     964
     965       IF (o_dqdyn%flag(iff)<=lev_files(iff)) THEN
     966      CALL histwrite_phy(nid_files(iff),o_dqdyn%name,itau_w,d_q_dyn)
     967       ENDIF
     968
     969       IF (o_dudyn%flag(iff)<=lev_files(iff)) THEN
     970      CALL histwrite_phy(nid_files(iff),o_dudyn%name,itau_w,d_u_dyn)
    959971       ENDIF                                                   
    960972
    961        IF (flag_dvdyn(iff)<=lev_files(iff)) THEN                 
    962       CALL histwrite_phy(nid_files(iff),"dvdyn",itau_w,d_v_dyn) 
     973       IF (o_dvdyn%flag(iff)<=lev_files(iff)) THEN                 
     974      CALL histwrite_phy(nid_files(iff),o_dvdyn%name,itau_w,d_v_dyn) 
    963975       ENDIF                                                     
    964976
    965        IF (flag_dtcon(iff)<=lev_files(iff)) THEN
     977       IF (o_dtcon%flag(iff)<=lev_files(iff)) THEN
    966978      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
    967       CALL histwrite_phy(nid_files(iff),"dtcon",itau_w,zx_tmp_fi3d)
    968        ENDIF
    969 
    970        IF (flag_ducon(iff)<=lev_files(iff)) THEN
     979      CALL histwrite_phy(nid_files(iff),o_dtcon%name,itau_w,zx_tmp_fi3d)
     980       ENDIF
     981
     982       IF (o_ducon%flag(iff)<=lev_files(iff)) THEN
    971983      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
    972       CALL histwrite_phy(nid_files(iff),"ducon",itau_w,zx_tmp_fi3d)
    973        ENDIF
    974 
    975        IF (flag_dqcon(iff)<=lev_files(iff)) THEN
     984      CALL histwrite_phy(nid_files(iff),o_ducon%name,itau_w,zx_tmp_fi3d)
     985       ENDIF
     986
     987       IF (o_dqcon%flag(iff)<=lev_files(iff)) THEN
    976988      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
    977       CALL histwrite_phy(nid_files(iff),"dqcon",itau_w,zx_tmp_fi3d)
     989      CALL histwrite_phy(nid_files(iff),o_dqcon%name,itau_w,zx_tmp_fi3d)
    978990       ENDIF
    979991
    980992      IF(iflag_con.GE.3) THEN
    981993       IF (iflag_wake == 1) THEN
    982          IF (flag_dtwak(iff)<=lev_files(iff)) THEN
    983            zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)           &
     994         IF (o_dtwak%flag(iff)<=lev_files(iff)) THEN
     995           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)           
    984996     &                                        /pdtphys
    985            CALL histwrite_phy(nid_files(iff),"dtwak",itau_w,zx_tmp_fi3d)
     997           CALL histwrite_phy(nid_files(iff),
     998     &                       o_dtwak%name,itau_w,zx_tmp_fi3d)
    986999         ENDIF
    9871000
    988         IF (flag_dqwak(iff)<=lev_files(iff)) THEN
     1001        IF (o_dqwak%flag(iff)<=lev_files(iff)) THEN
    9891002        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
    990         CALL histwrite_phy(nid_files(iff),"dqwak",itau_w,zx_tmp_fi3d)
     1003        CALL histwrite_phy(nid_files(iff),
     1004     &                     o_dqwak%name,itau_w,zx_tmp_fi3d)
    9911005        ENDIF
    9921006       ENDIF
    9931007      ENDIF !(iflag_con.GE.3)
    9941008
    995        IF (flag_dtlsc(iff)<=lev_files(iff)) THEN
     1009       IF (o_dtlsc%flag(iff)<=lev_files(iff)) THEN
    9961010      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
    997       CALL histwrite_phy(nid_files(iff),"dtlsc",itau_w,zx_tmp_fi3d)
    998        ENDIF
    999 
    1000        IF (flag_dtlschr(iff)<=lev_files(iff)) THEN
     1011      CALL histwrite_phy(nid_files(iff),o_dtlsc%name,itau_w,zx_tmp_fi3d)
     1012       ENDIF
     1013
     1014       IF (o_dtlschr%flag(iff)<=lev_files(iff)) THEN
    10011015      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
    10021016     $                           d_t_eva(1:klon,1:klev))/pdtphys
    1003       CALL histwrite_phy(nid_files(iff),"dtlschr",itau_w,zx_tmp_fi3d)
    1004        ENDIF
    1005 
    1006        IF (flag_dqlsc(iff)<=lev_files(iff)) THEN
     1017      CALL histwrite_phy(nid_files(iff),
     1018     s                   o_dtlschr%name,itau_w,zx_tmp_fi3d)
     1019       ENDIF
     1020
     1021       IF (o_dqlsc%flag(iff)<=lev_files(iff)) THEN
    10071022      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
    1008       CALL histwrite_phy(nid_files(iff),"dqlsc",itau_w,zx_tmp_fi3d)
    1009        ENDIF
    1010 
    1011        IF (flag_dtvdf(iff)<=lev_files(iff)) THEN
     1023      CALL histwrite_phy(nid_files(iff),o_dqlsc%name,itau_w,zx_tmp_fi3d)
     1024       ENDIF
     1025
     1026       IF (o_dtvdf%flag(iff)<=lev_files(iff)) THEN
    10121027      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
    1013       CALL histwrite_phy(nid_files(iff),"dtvdf",itau_w,zx_tmp_fi3d)
    1014        ENDIF
    1015 
    1016        IF (flag_dqvdf(iff)<=lev_files(iff)) THEN
     1028      CALL histwrite_phy(nid_files(iff),o_dtvdf%name,itau_w,zx_tmp_fi3d)
     1029       ENDIF
     1030
     1031       IF (o_dqvdf%flag(iff)<=lev_files(iff)) THEN
    10171032      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
    1018       CALL histwrite_phy(nid_files(iff),"dqvdf",itau_w,zx_tmp_fi3d)
    1019        ENDIF
    1020 
    1021        IF (flag_dteva(iff)<=lev_files(iff)) THEN
     1033      CALL histwrite_phy(nid_files(iff),o_dqvdf%name,itau_w,zx_tmp_fi3d)
     1034       ENDIF
     1035
     1036       IF (o_dteva%flag(iff)<=lev_files(iff)) THEN
    10221037      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
    1023       CALL histwrite_phy(nid_files(iff),"dteva",itau_w,zx_tmp_fi3d)
    1024        ENDIF
    1025 
    1026        IF (flag_dqeva(iff)<=lev_files(iff)) THEN
     1038      CALL histwrite_phy(nid_files(iff),o_dteva%name,itau_w,zx_tmp_fi3d)
     1039       ENDIF
     1040
     1041       IF (o_dqeva%flag(iff)<=lev_files(iff)) THEN
    10271042      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
    1028       CALL histwrite_phy(nid_files(iff),"dqeva",itau_w,zx_tmp_fi3d)
    1029        ENDIF
    1030 
    1031        IF (flag_ptconv(iff)<=lev_files(iff)) THEN
     1043      CALL histwrite_phy(nid_files(iff),o_dqeva%name,itau_w,zx_tmp_fi3d)
     1044       ENDIF
     1045
     1046       IF (o_ptconv%flag(iff)<=lev_files(iff)) THEN
    10321047      zpt_conv = 0.
    10331048      where (ptconv) zpt_conv = 1.
    1034       CALL histwrite_phy(nid_files(iff),"ptconv",itau_w,zpt_conv)
    1035        ENDIF
    1036 
    1037        IF (flag_ratqs(iff)<=lev_files(iff)) THEN
    1038       CALL histwrite_phy(nid_files(iff),"ratqs",itau_w,ratqs)
    1039        ENDIF
    1040 
    1041        IF (flag_dtthe(iff)<=lev_files(iff)) THEN
     1049      CALL histwrite_phy(nid_files(iff),o_ptconv%name,itau_w,zpt_conv)
     1050       ENDIF
     1051
     1052       IF (o_ratqs%flag(iff)<=lev_files(iff)) THEN
     1053      CALL histwrite_phy(nid_files(iff),o_ratqs%name,itau_w,ratqs)
     1054       ENDIF
     1055
     1056       IF (o_dtthe%flag(iff)<=lev_files(iff)) THEN
    10421057      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys
    1043       CALL histwrite_phy(nid_files(iff),"dtthe",itau_w,zx_tmp_fi3d)
     1058      CALL histwrite_phy(nid_files(iff),o_dtthe%name,itau_w,zx_tmp_fi3d)
    10441059       ENDIF
    10451060
    10461061       IF (iflag_thermals.gt.1) THEN
    1047         IF (flag_f_th(iff)<=lev_files(iff)) THEN
    1048         CALL histwrite_phy(nid_files(iff),"f_th",itau_w,fm_therm)
    1049         ENDIF
    1050 
    1051         IF (flag_e_th(iff)<=lev_files(iff)) THEN
    1052         CALL histwrite_phy(nid_files(iff),"e_th",itau_w,entr_therm)
    1053         ENDIF
    1054 
    1055         IF (flag_w_th(iff)<=lev_files(iff)) THEN
    1056         CALL histwrite_phy(nid_files(iff),"w_th",itau_w,zw2)
    1057         ENDIF
    1058 
    1059         IF (flag_q_th(iff)<=lev_files(iff)) THEN
    1060         CALL histwrite_phy(nid_files(iff),"q_th",itau_w,zqasc)
    1061         ENDIF
    1062 
    1063         IF (flag_lambda_th(iff)<=lev_files(iff)) THEN
    1064         CALL histwrite_phy(nid_files(iff),"lambda_th",itau_w,lambda_th)
    1065         ENDIF
    1066 
    1067         IF (flag_a_th(iff)<=lev_files(iff)) THEN
    1068         CALL histwrite_phy(nid_files(iff),"a_th",itau_w,fraca)
    1069         ENDIF
    1070 
    1071        IF (flag_d_th(iff)<=lev_files(iff)) THEN
    1072        CALL histwrite_phy(nid_files(iff),"d_th",itau_w,detr_therm)
     1062        IF (o_f_th%flag(iff)<=lev_files(iff)) THEN
     1063        CALL histwrite_phy(nid_files(iff),o_f_th%name,itau_w,fm_therm)
     1064        ENDIF
     1065
     1066        IF (o_e_th%flag(iff)<=lev_files(iff)) THEN
     1067        CALL histwrite_phy(nid_files(iff),o_e_th%name,itau_w,entr_therm)
     1068        ENDIF
     1069
     1070        IF (o_w_th%flag(iff)<=lev_files(iff)) THEN
     1071        CALL histwrite_phy(nid_files(iff),o_w_th%name,itau_w,zw2)
     1072        ENDIF
     1073
     1074        IF (o_q_th%flag(iff)<=lev_files(iff)) THEN
     1075        CALL histwrite_phy(nid_files(iff),o_q_th%name,itau_w,zqasc)
     1076        ENDIF
     1077
     1078        IF (o_lambda_th%flag(iff)<=lev_files(iff)) THEN
     1079        CALL histwrite_phy(nid_files(iff),
     1080     s                     o_lambda_th%name,itau_w,lambda_th)
     1081        ENDIF
     1082
     1083        IF (o_a_th%flag(iff)<=lev_files(iff)) THEN
     1084        CALL histwrite_phy(nid_files(iff),o_a_th%name,itau_w,fraca)
     1085        ENDIF
     1086
     1087       IF (o_d_th%flag(iff)<=lev_files(iff)) THEN
     1088       CALL histwrite_phy(nid_files(iff),o_d_th%name,itau_w,detr_therm)
    10731089       ENDIF
    10741090
    10751091       ENDIF !iflag_thermals
    10761092
    1077        IF (flag_f0_th(iff)<=lev_files(iff)) THEN
    1078       CALL histwrite_phy(nid_files(iff),"f0_th",itau_w,f0)
    1079        ENDIF
    1080 
    1081        IF (flag_f0_th(iff)<=lev_files(iff)) THEN
    1082       CALL histwrite_phy(nid_files(iff),"zmax_th",itau_w,zmax0)
    1083        ENDIF
    1084 
    1085        IF (flag_dqthe(iff)<=lev_files(iff)) THEN
     1093       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
     1094      CALL histwrite_phy(nid_files(iff),o_f0_th%name,itau_w,f0)
     1095       ENDIF
     1096
     1097       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
     1098      CALL histwrite_phy(nid_files(iff),o_zmax_th%name,itau_w,zmax0)
     1099       ENDIF
     1100
     1101       IF (o_dqthe%flag(iff)<=lev_files(iff)) THEN
    10861102      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
    1087       CALL histwrite_phy(nid_files(iff),"dqthe",itau_w,zx_tmp_fi3d)
    1088        ENDIF
    1089 
    1090        IF (flag_dtajs(iff)<=lev_files(iff)) THEN
     1103      CALL histwrite_phy(nid_files(iff),o_dqthe%name,itau_w,zx_tmp_fi3d)
     1104       ENDIF
     1105
     1106       IF (o_dtajs%flag(iff)<=lev_files(iff)) THEN
    10911107      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
    1092       CALL histwrite_phy(nid_files(iff),"dtajs",itau_w,zx_tmp_fi3d)
    1093        ENDIF
    1094 
    1095        IF (flag_dqajs(iff)<=lev_files(iff)) THEN
     1108      CALL histwrite_phy(nid_files(iff),o_dtajs%name,itau_w,zx_tmp_fi3d)
     1109       ENDIF
     1110
     1111       IF (o_dqajs%flag(iff)<=lev_files(iff)) THEN
    10961112      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
    1097       CALL histwrite_phy(nid_files(iff),"dqajs",itau_w,zx_tmp_fi3d)
    1098        ENDIF
    1099 
    1100        IF (flag_dtswr(iff)<=lev_files(iff)) THEN
     1113      CALL histwrite_phy(nid_files(iff),o_dqajs%name,itau_w,zx_tmp_fi3d)
     1114       ENDIF
     1115
     1116       IF (o_dtswr%flag(iff)<=lev_files(iff)) THEN
    11011117      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
    1102       CALL histwrite_phy(nid_files(iff),"dtswr",itau_w,zx_tmp_fi3d)
    1103        ENDIF
    1104 
    1105        IF (flag_dtsw0(iff)<=lev_files(iff)) THEN
     1118      CALL histwrite_phy(nid_files(iff),o_dtswr%name,itau_w,zx_tmp_fi3d)
     1119       ENDIF
     1120
     1121       IF (o_dtsw0%flag(iff)<=lev_files(iff)) THEN
    11061122      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
    1107       CALL histwrite_phy(nid_files(iff),"dtsw0",itau_w,zx_tmp_fi3d)
    1108        ENDIF
    1109 
    1110        IF (flag_dtlwr(iff)<=lev_files(iff)) THEN
     1123      CALL histwrite_phy(nid_files(iff),o_dtsw0%name,itau_w,zx_tmp_fi3d)
     1124       ENDIF
     1125
     1126       IF (o_dtlwr%flag(iff)<=lev_files(iff)) THEN
    11111127      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
    1112       CALL histwrite_phy(nid_files(iff),"dtlwr",itau_w,zx_tmp_fi3d)
    1113        ENDIF
    1114 
    1115        IF (flag_dtlw0(iff)<=lev_files(iff)) THEN
     1128      CALL histwrite_phy(nid_files(iff),o_dtlwr%name,itau_w,zx_tmp_fi3d)
     1129       ENDIF
     1130
     1131       IF (o_dtlw0%flag(iff)<=lev_files(iff)) THEN
    11161132      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
    1117       CALL histwrite_phy(nid_files(iff),"dtlw0",itau_w,zx_tmp_fi3d)
    1118        ENDIF
    1119 
    1120        IF (flag_dtec(iff)<=lev_files(iff)) THEN
     1133      CALL histwrite_phy(nid_files(iff),o_dtlw0%name,itau_w,zx_tmp_fi3d)
     1134       ENDIF
     1135
     1136       IF (o_dtec%flag(iff)<=lev_files(iff)) THEN
    11211137      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
    1122       CALL histwrite_phy(nid_files(iff),"dtec",itau_w,zx_tmp_fi3d)
    1123        ENDIF
    1124 
    1125        IF (flag_duvdf(iff)<=lev_files(iff)) THEN
     1138      CALL histwrite_phy(nid_files(iff),o_dtec%name,itau_w,zx_tmp_fi3d)
     1139       ENDIF
     1140
     1141       IF (o_duvdf%flag(iff)<=lev_files(iff)) THEN
    11261142      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
    1127       CALL histwrite_phy(nid_files(iff),"duvdf",itau_w,zx_tmp_fi3d)
    1128        ENDIF
    1129 
    1130        IF (flag_dvvdf(iff)<=lev_files(iff)) THEN
     1143      CALL histwrite_phy(nid_files(iff),o_duvdf%name,itau_w,zx_tmp_fi3d)
     1144       ENDIF
     1145
     1146       IF (o_dvvdf%flag(iff)<=lev_files(iff)) THEN
    11311147      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
    1132       CALL histwrite_phy(nid_files(iff),"dvvdf",itau_w,zx_tmp_fi3d)
     1148      CALL histwrite_phy(nid_files(iff),o_dvvdf%name,itau_w,zx_tmp_fi3d)
    11331149       ENDIF
    11341150
    11351151       IF (ok_orodr) THEN
    1136       IF (flag_duoro(iff)<=lev_files(iff)) THEN
     1152      IF (o_duoro%flag(iff)<=lev_files(iff)) THEN
    11371153      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
    1138       CALL histwrite_phy(nid_files(iff),"duoro",itau_w,zx_tmp_fi3d)
    1139        ENDIF
    1140 
    1141       IF (flag_dvoro(iff)<=lev_files(iff)) THEN
     1154      CALL histwrite_phy(nid_files(iff),o_duoro%name,itau_w,zx_tmp_fi3d)
     1155       ENDIF
     1156
     1157      IF (o_dvoro%flag(iff)<=lev_files(iff)) THEN
    11421158      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
    1143       CALL histwrite_phy(nid_files(iff),"dvoro",itau_w,zx_tmp_fi3d)
     1159      CALL histwrite_phy(nid_files(iff),o_dvoro%name,itau_w,zx_tmp_fi3d)
    11441160      ENDIF
    11451161       ENDIF
    11461162
    11471163        IF (ok_orolf) THEN
    1148        IF (flag_dulif(iff)<=lev_files(iff)) THEN
     1164       IF (o_dulif%flag(iff)<=lev_files(iff)) THEN
    11491165      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
    1150       CALL histwrite_phy(nid_files(iff),"dulif",itau_w,zx_tmp_fi3d)
    1151        ENDIF
    1152 
    1153         IF (flag_dvlif(iff)<=lev_files(iff)) THEN
     1166      CALL histwrite_phy(nid_files(iff),o_dulif%name,itau_w,zx_tmp_fi3d)
     1167       ENDIF
     1168
     1169        IF (o_dvlif%flag(iff)<=lev_files(iff)) THEN
    11541170      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
    1155       CALL histwrite_phy(nid_files(iff),"dvlif",itau_w,zx_tmp_fi3d)
    1156        ENDIF
    1157         ENDIF
    1158 
    1159        IF (flag_trac(iff)<=lev_files(iff)) THEN
     1171      CALL histwrite_phy(nid_files(iff),o_dvlif%name,itau_w,zx_tmp_fi3d)
     1172       ENDIF
     1173        ENDIF
     1174
     1175!       IF (o_trac%flag(iff)<=lev_files(iff)) THEN
    11601176         if (nqmax.GE.3) THEN
    1161            DO iq=3,nqmax
    1162          CALL histwrite_phy(nid_files(iff),tnom(iq),itau_w,qx(:,:,iq))
     1177!           DO iq=3,nqmax
     1178           DO iq=3,4
     1179       IF (o_trac(iq-2)%flag(iff)<=lev_files(iff)) THEN
     1180         CALL histwrite_phy(nid_files(iff),
     1181     s                  o_trac(iq-2)%name,itau_w,qx(:,:,iq))
     1182       ENDIF
    11631183           ENDDO
    1164           endif
    1165 
    1166        ENDIF
     1184         endif
     1185
    11671186      if (ok_sync) then
    11681187c$OMP MASTER
  • LMDZ4/branches/LMDZ4-dev/run.def

    r524 r1083  
    11#
    2 # $Header$
     2# $Header: /home/cvsroot/LMDZ4/run.def,v 1.1.1.1 2004-05-19 12:53:05 lmdzadmin Exp $
    33#
    44INCLUDEDEF=physiq.def
    55INCLUDEDEF=gcm.def
    66INCLUDEDEF=orchidee.def
     7INCLUDEDEF=outputs.def
    78## Jour de l'etat initial ( = 350  si 20 Decembre ,par expl. ,comme ici )
    89dayref=1
Note: See TracChangeset for help on using the changeset viewer.