Index: LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phys_output_write_spl_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 5117)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/Dust/phys_output_write_spl_mod.F90	(revision 5118)
@@ -1,78 +1,77 @@
-
 ! $Id: phys_output_write_mod.F90 2298 2015-06-14 19:13:32Z fairhead $
 
 MODULE phys_output_write_spl_mod
 
-!JE20150620<<
-!JE20150620>>
-!JE20150620<<
+  !JE20150620<<
+  !JE20150620>>
+  !JE20150620<<
 
   USE time_phylmdz_mod, ONLY: day_step_phy, start_time, itau_phy
 
   USE phytracr_spl_mod, ONLY: ok_chimeredust, id_prec, id_fine, id_coss, &
-       id_codu, id_scdu , &
-       d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
-       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
-       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav ,&
-       diff_aod550_tot,&
-       diag_aod670_tot, diag_aod865_tot, &
-       diff_aod550_tr2, diag_aod670_tr2, diag_aod865_tr2, &
-       diag_aod550_ss, diag_aod670_ss, diag_aod865_ss, &
-       diag_aod550_dust, diag_aod670_dust, diag_aod865_dust , &
-       diag_aod550_dustsco, diag_aod670_dustsco, diag_aod865_dustsco, &
-!       aod550_aqua, aod670_aqua, aod865_aqua, &
-!       aod550_terra, aod670_terra, aod865_terra, &
-       aod550_aqua,aod550_tr2_aqua,aod550_ss_aqua,aod550_dust_aqua,aod550_dustsco_aqua,&
-       aod670_aqua,aod670_tr2_aqua,aod670_ss_aqua,aod670_dust_aqua,aod670_dustsco_aqua,&
-       aod865_aqua,aod865_tr2_aqua,aod865_ss_aqua,aod865_dust_aqua,aod865_dustsco_aqua,&
-       aod550_terra,aod550_tr2_terra,aod550_ss_terra,aod550_dust_terra,aod550_dustsco_terra,&
-       aod670_terra,aod670_tr2_terra,aod670_ss_terra,aod670_dust_terra,aod670_dustsco_terra,&
-       aod865_terra,aod865_tr2_terra,aod865_ss_terra,aod865_dust_terra,aod865_dustsco_terra,&
-       trm01,trm02,trm03,trm04,trm05, &
-       sconc01,sconc02,sconc03,sconc04,sconc05, &
-       flux01,flux02,flux03,flux04,flux05,&
-       ds01,ds02,ds03,ds04,ds05, &
-       dh01,dh02,dh03,dh04,dh05, &
-       dtrconv01,dtrconv02,dtrconv03,dtrconv04,dtrconv05, &
-       dtherm01,dtherm02,dtherm03,dtherm04,dtherm05, &
-       dhkecv01,dhkecv02,dhkecv03,dhkecv04,dhkecv05, &
-       d_tr_ds01,d_tr_ds02,d_tr_ds03,d_tr_ds04,d_tr_ds05, &
-       dhkelsc01,dhkelsc02,dhkelsc03,dhkelsc04,dhkelsc05, &
-       d_tr_cv01,d_tr_cv02,d_tr_cv03,d_tr_cv04,d_tr_cv05, &
-       d_tr_trsp01,d_tr_trsp02,d_tr_trsp03,d_tr_trsp04,d_tr_trsp05, &
-       d_tr_sscav01,d_tr_sscav02,d_tr_sscav03,d_tr_sscav04,d_tr_sscav05, &
-       d_tr_sat01,d_tr_sat02,d_tr_sat03,d_tr_sat04,d_tr_sat05, &
-       d_tr_uscav01,d_tr_uscav02,d_tr_uscav03,d_tr_uscav04,d_tr_uscav05, &
-       d_tr_insc01,d_tr_insc02,d_tr_insc03,d_tr_insc04,d_tr_insc05, &
-       d_tr_bcscav01,d_tr_bcscav02,d_tr_bcscav03,d_tr_bcscav04,d_tr_bcscav05, &
-       d_tr_evapls01,d_tr_evapls02,d_tr_evapls03,d_tr_evapls04,d_tr_evapls05, &
-       d_tr_ls01,d_tr_ls02,d_tr_ls03,d_tr_ls04,d_tr_ls05, &
-       d_tr_dyn01,d_tr_dyn02,d_tr_dyn03,d_tr_dyn04,d_tr_dyn05, &
-       d_tr_cl01,d_tr_cl02,d_tr_cl03,d_tr_cl04,d_tr_cl05, &
-       d_tr_th01,d_tr_th02,d_tr_th03,d_tr_th04,d_tr_th05, &
-       sed_ss,sed_dust,sed_dustsco,his_g2pgas,his_g2paer, &
-       sed_ss3D,sed_dust3D,sed_dustsco3D, &
-       fluxbb, &
-       fluxff,fluxbcbb,fluxbcff,fluxbcnff, &
-       fluxbcba,fluxbc,fluxombb,fluxomff,fluxomnff, &
-       fluxomba,fluxomnat,fluxom,fluxh2sff,fluxh2snff, &
-       fluxso2ff,fluxso2nff,fluxso2bb,fluxso2vol,fluxso2ba, &
-       fluxso2,fluxso4ff,fluxso4nff,fluxso4ba,fluxso4bb, &
-       fluxso4,fluxdms,fluxh2sbio,fluxdustec,&
-       fluxddfine,  &
-       fluxddcoa,fluxddsco,fluxdd, &
-       fluxssfine,fluxsscoa, &
-       fluxss,flux_sparam_ind,flux_sparam_bb,flux_sparam_ff, &
-       flux_sparam_ddfine,flux_sparam_ddcoa, &
-       flux_sparam_ddsco,flux_sparam_ssfine, &
-       flux_sparam_sscoa,u10m_ss,v10m_ss
+          id_codu, id_scdu, &
+          d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
+          d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls, &
+          d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav, &
+          diff_aod550_tot, &
+          diag_aod670_tot, diag_aod865_tot, &
+          diff_aod550_tr2, diag_aod670_tr2, diag_aod865_tr2, &
+          diag_aod550_ss, diag_aod670_ss, diag_aod865_ss, &
+          diag_aod550_dust, diag_aod670_dust, diag_aod865_dust, &
+          diag_aod550_dustsco, diag_aod670_dustsco, diag_aod865_dustsco, &
+          !       aod550_aqua, aod670_aqua, aod865_aqua, &
+          !       aod550_terra, aod670_terra, aod865_terra, &
+          aod550_aqua, aod550_tr2_aqua, aod550_ss_aqua, aod550_dust_aqua, aod550_dustsco_aqua, &
+          aod670_aqua, aod670_tr2_aqua, aod670_ss_aqua, aod670_dust_aqua, aod670_dustsco_aqua, &
+          aod865_aqua, aod865_tr2_aqua, aod865_ss_aqua, aod865_dust_aqua, aod865_dustsco_aqua, &
+          aod550_terra, aod550_tr2_terra, aod550_ss_terra, aod550_dust_terra, aod550_dustsco_terra, &
+          aod670_terra, aod670_tr2_terra, aod670_ss_terra, aod670_dust_terra, aod670_dustsco_terra, &
+          aod865_terra, aod865_tr2_terra, aod865_ss_terra, aod865_dust_terra, aod865_dustsco_terra, &
+          trm01, trm02, trm03, trm04, trm05, &
+          sconc01, sconc02, sconc03, sconc04, sconc05, &
+          flux01, flux02, flux03, flux04, flux05, &
+          ds01, ds02, ds03, ds04, ds05, &
+          dh01, dh02, dh03, dh04, dh05, &
+          dtrconv01, dtrconv02, dtrconv03, dtrconv04, dtrconv05, &
+          dtherm01, dtherm02, dtherm03, dtherm04, dtherm05, &
+          dhkecv01, dhkecv02, dhkecv03, dhkecv04, dhkecv05, &
+          d_tr_ds01, d_tr_ds02, d_tr_ds03, d_tr_ds04, d_tr_ds05, &
+          dhkelsc01, dhkelsc02, dhkelsc03, dhkelsc04, dhkelsc05, &
+          d_tr_cv01, d_tr_cv02, d_tr_cv03, d_tr_cv04, d_tr_cv05, &
+          d_tr_trsp01, d_tr_trsp02, d_tr_trsp03, d_tr_trsp04, d_tr_trsp05, &
+          d_tr_sscav01, d_tr_sscav02, d_tr_sscav03, d_tr_sscav04, d_tr_sscav05, &
+          d_tr_sat01, d_tr_sat02, d_tr_sat03, d_tr_sat04, d_tr_sat05, &
+          d_tr_uscav01, d_tr_uscav02, d_tr_uscav03, d_tr_uscav04, d_tr_uscav05, &
+          d_tr_insc01, d_tr_insc02, d_tr_insc03, d_tr_insc04, d_tr_insc05, &
+          d_tr_bcscav01, d_tr_bcscav02, d_tr_bcscav03, d_tr_bcscav04, d_tr_bcscav05, &
+          d_tr_evapls01, d_tr_evapls02, d_tr_evapls03, d_tr_evapls04, d_tr_evapls05, &
+          d_tr_ls01, d_tr_ls02, d_tr_ls03, d_tr_ls04, d_tr_ls05, &
+          d_tr_dyn01, d_tr_dyn02, d_tr_dyn03, d_tr_dyn04, d_tr_dyn05, &
+          d_tr_cl01, d_tr_cl02, d_tr_cl03, d_tr_cl04, d_tr_cl05, &
+          d_tr_th01, d_tr_th02, d_tr_th03, d_tr_th04, d_tr_th05, &
+          sed_ss, sed_dust, sed_dustsco, his_g2pgas, his_g2paer, &
+          sed_ss3D, sed_dust3D, sed_dustsco3D, &
+          fluxbb, &
+          fluxff, fluxbcbb, fluxbcff, fluxbcnff, &
+          fluxbcba, fluxbc, fluxombb, fluxomff, fluxomnff, &
+          fluxomba, fluxomnat, fluxom, fluxh2sff, fluxh2snff, &
+          fluxso2ff, fluxso2nff, fluxso2bb, fluxso2vol, fluxso2ba, &
+          fluxso2, fluxso4ff, fluxso4nff, fluxso4ba, fluxso4bb, &
+          fluxso4, fluxdms, fluxh2sbio, fluxdustec, &
+          fluxddfine, &
+          fluxddcoa, fluxddsco, fluxdd, &
+          fluxssfine, fluxsscoa, &
+          fluxss, flux_sparam_ind, flux_sparam_bb, flux_sparam_ff, &
+          flux_sparam_ddfine, flux_sparam_ddcoa, &
+          flux_sparam_ddsco, flux_sparam_ssfine, &
+          flux_sparam_sscoa, u10m_ss, v10m_ss
 
   USE dustemission_mod, ONLY: m1dflux, m2dflux, m3dflux
 
-!  USE phytrac_mod, ONLY: d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
-!       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
-!       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
-
-!JE20150620>>
+  !  USE phytrac_mod, ONLY: d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
+  !       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
+  !       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
+
+  !JE20150620>>
 
   ! Author: Abderrahmane IDELKADI (original include file)
@@ -80,12 +79,12 @@
   ! Author: Ulysse GERARD (effective implementation)
 
-CONTAINS 
+CONTAINS
 
   ! ug Routine pour définir (lors du premier passageà) ET sortir les variables
   SUBROUTINE phys_output_write_spl(itap, pdtphys, paprs, pphis, &
-       pplay, lmax_th, aerosol_couple,         &
-       ok_ade, ok_aie, ivap, ok_sync, &
-       ptconv, read_climoz, clevSTD, ptconvth, &
-       d_t, qx, d_qx, d_tr_dyn, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
+          pplay, lmax_th, aerosol_couple, &
+          ok_ade, ok_aie, ivap, ok_sync, &
+          ptconv, read_climoz, clevSTD, ptconvth, &
+          d_t, qx, d_qx, d_tr_dyn, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
 
     ! This SUBROUTINE does the actual writing of diagnostics that were
@@ -96,288 +95,288 @@
     USE control_mod, ONLY: day_step, iphysiq
     USE phys_output_ctrlout_mod, ONLY: o_phis, o_aire, is_ter, is_lic, is_oce, &
-         is_ave, is_sic, o_contfracATM, o_contfracOR, &
-         o_aireTER, o_flat, o_slp, o_tsol, &
-         o_t2m, o_t2m_min, o_t2m_max, &
-         o_t2m_min_mon, o_t2m_max_mon, &
-         o_q2m, o_ustar, o_u10m, o_v10m, &
-         o_wind10m, o_wind10max, o_gusts, o_sicf, &
-         o_psol, o_mass, o_qsurf, o_qsol, &
-         o_precip, o_ndayrain, o_plul, o_pluc, &
-         o_snow, o_msnow, o_fsnow, o_evap, &
-         o_tops, o_tops0, o_topl, o_topl0, &
-         o_SWupTOA, o_SWupTOAclr, o_SWdnTOA, &
-         o_SWdnTOAclr, o_nettop, o_SWup200, &
-         o_SWup200clr, o_SWdn200, o_SWdn200clr, &
-         o_LWup200, o_LWup200clr, o_LWdn200, &
-         o_LWdn200clr, o_sols, o_sols0, &
-         o_soll, o_radsol, o_soll0, o_SWupSFC, &
-         o_SWupSFCclr, o_SWdnSFC, o_SWdnSFCclr, &
-         o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
-         o_LWdnSFCclr, o_bils, o_bils_diss, &
-         o_bils_ec,o_bils_ech, o_bils_tke, o_bils_kinetic, &
-         o_bils_latent, o_bils_enthalp, o_sens, &
-         o_fder, o_ffonte, o_fqcalving, o_fqfonte, &
-         o_taux, o_tauy, o_snowsrf, o_qsnow, &
-         o_snowhgt, o_toice, o_sissnow, o_runoff, &
-         o_albslw3, o_pourc_srf, o_fract_srf, &
-         o_taux_srf, o_tauy_srf, o_tsol_srf, &
-         o_evappot_srf, o_ustar_srf, o_u10m_srf, &
-         o_v10m_srf, o_t2m_srf, o_evap_srf, &
-         o_sens_srf, o_lat_srf, o_flw_srf, &
-         o_fsw_srf, o_wbils_srf, o_wbilo_srf, &
-         o_tke_srf, o_tke_max_srf,o_dltpbltke_srf, o_wstar, &
-         o_cdrm, o_cdrh, o_cldl, o_cldm, o_cldh, &
-         o_cldt, o_JrNt, o_cldljn, o_cldmjn, &
-         o_cldhjn, o_cldtjn, o_cldq, o_lwp, o_iwp, &
-         o_ue, o_ve, o_uq, o_vq, o_cape, o_pbase, &
-         o_ptop, o_fbase, o_plcl, o_plfc, &
-         o_wbeff, o_cape_max, o_upwd, o_Ma, &
-         o_dnwd, o_dnwd0, o_ftime_con, o_mc, &
-         o_prw, o_s_pblh, o_s_pblt, o_s_lcl, &
-         o_s_therm, o_uSTDlevs, o_vSTDlevs, &
-         o_wSTDlevs, o_zSTDlevs, o_qSTDlevs, &
-         o_tSTDlevs, epsfra, o_t_oce_sic, &
-         o_ale_bl, o_alp_bl, o_ale_wk, o_alp_wk, &
-         o_ale, o_alp, o_cin, o_WAPE, o_wake_h, &
-         o_wake_s, o_wake_deltat, o_wake_deltaq, &
-         o_wake_omg, o_dtwak, o_dqwak, o_Vprecip, &
-         o_ftd, o_fqd, o_wdtrainA, o_wdtrainM, &
-         o_n2, o_s2, o_proba_notrig, &
-         o_random_notrig, o_ale_bl_stat, &
-         o_ale_bl_trig, o_alp_bl_det, &
-         o_alp_bl_fluct_m, o_alp_bl_fluct_tke, &
-         o_alp_bl_conv, o_alp_bl_stat, &
-         o_slab_qflux, o_tslab, &
-         !o_slab_bils, &
-         o_slab_bilg, o_slab_sic, o_slab_tice, &
-         o_weakinv, o_dthmin, o_cldtau, &
-         o_cldemi, o_pr_con_l, o_pr_con_i, &
-         o_pr_lsc_l, o_pr_lsc_i, o_re, o_fl, &
-         o_rh2m, &
-         !o_rh2m_min, o_rh2m_max, &
-         o_qsat2m, o_tpot, o_tpote, o_SWnetOR, &
-         o_LWdownOR, o_snowl, &
-         o_solldown, o_dtsvdfo, o_dtsvdft, &
-         o_dtsvdfg, o_dtsvdfi, o_z0m, o_z0h, o_od550aer, &
-         o_od865aer, o_abs550aer, o_od550lt1aer, &
-         o_sconcso4, o_sconcno3, o_sconcoa, o_sconcbc, &
-         o_sconcss, o_sconcdust, o_concso4, o_concno3, &
-         o_concoa, o_concbc, o_concss, o_concdust, &
-         o_loadso4, o_loadoa, o_loadbc, o_loadss, &
-         o_loaddust, o_tausumaero, o_tausumaero_lw, &
-         o_topswad, o_topswad0, o_solswad, o_solswad0, &
-         o_toplwad, o_toplwad0, o_sollwad, o_sollwad0, &
-         o_swtoaas_nat, o_swsrfas_nat, &
-         o_swtoacs_nat, o_swtoaas_ant, &
-         o_swsrfas_ant, o_swtoacs_ant, &
-         o_swsrfcs_ant, o_swtoacf_nat, &
-         o_swsrfcf_nat, o_swtoacf_ant, &
-         o_swsrfcs_nat, o_swsrfcf_ant, &
-         o_swtoacf_zero, o_swsrfcf_zero, &
-         o_topswai, o_solswai, o_scdnc, &
-         o_cldncl, o_reffclws, o_reffclwc, &
-         o_cldnvi, o_lcc, o_lcc3d, o_lcc3dcon, &
-         o_lcc3dstra, o_reffclwtop, o_ec550aer, &
-         o_lwcon, o_iwcon, o_temp, o_theta, &
-         o_ovapinit, o_ovap, o_oliq, o_geop, &
-         o_vitu, o_vitv, o_vitw, o_pres, o_paprs, &
-         o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
-         o_rnebls, o_rhum, o_ozone, o_ozone_light, &
-         o_dtphy, o_dqphy, o_albe_srf, o_z0m_srf, o_z0h_srf, &
-         o_ages_srf, o_snow_srf, o_alb1, o_alb2, o_tke, &
-         o_tke_max, o_kz, o_kz_max, o_clwcon, &
-         o_dtdyn, o_dqdyn, o_dudyn, o_dvdyn, &
-         o_dtcon, o_tntc, o_ducon, o_dvcon, &
-         o_dqcon, o_tnhusc, o_tnhusc, o_dtlsc, &
-         o_dtlschr, o_dqlsc, o_beta_prec, &
-         o_dtlscth, o_dtlscst, o_dqlscth, &
-         o_dqlscst, o_plulth, o_plulst, &
-         o_ptconvth, o_lmaxth, o_dtvdf, &
-         o_dtdis, o_dqvdf, o_dteva, o_dqeva, &
-         o_ptconv, o_ratqs, o_dtthe, & 
-         o_duthe, o_dvthe, o_ftime_th, &
-         o_f_th, o_e_th, o_w_th, o_q_th, &
-         o_a_th, o_d_th, o_f0_th, o_zmax_th, &
-         o_dqthe, o_dtajs, o_dqajs, o_dtswr, &
-         o_dtsw0, o_dtlwr, o_dtlw0, o_dtec, &
-         o_duvdf, o_dvvdf, o_duoro, o_dvoro, &
-         o_dtoro, o_dulif, o_dvlif, o_dtlif, &
- !       o_duhin, o_dvhin, o_dthin, &
-         o_dqch4, o_rsu, &
-         o_rsd, o_rlu, o_rld, o_rsucs, o_rsdcs, &
-         o_rlucs, o_rldcs, o_tnt, o_tntr, &
-         o_tntscpbl, o_tnhus, o_tnhusscpbl, &
-         o_evu, o_h2o, o_mcd, o_dmc, o_ref_liq, &
-         o_ref_ice, o_rsut4co2, o_rlut4co2, &
-         o_rsutcs4co2, o_rlutcs4co2, o_rsu4co2, &
-         o_rlu4co2, o_rsucs4co2, o_rlucs4co2, &
-         o_rsd4co2, o_rld4co2, o_rsdcs4co2, &
-         o_rldcs4co2, o_tnondef, o_ta, o_zg, &
-         o_hus, o_hur, o_ua, o_va, o_wap, &
-         o_psbg, o_tro3, o_tro3_daylight, &
-         o_uxv, o_vxq, o_vxT, o_wxq, o_vxphi, &
-         o_wxT, o_uxu, o_vxv, o_TxT, o_trac, &
-         o_dtr_vdf, o_dtr_the, o_dtr_con, &
-         o_dtr_lessi_impa, o_dtr_lessi_nucl, &
-         o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
-!        o_dtr_ls, o_dtr_dyn, o_dtr_cl, o_dtr_trsp, o_dtr_sscav, &
-         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, &
-         o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
-!JE20150620<<
-!         o_vstr_gwd_rando
-         o_vstr_gwd_rando, &
-         o_m1dflux,o_m2dflux,o_m3dflux, &
-         o_taue550, &
-         o_taue670,o_taue865, &
-         o_taue550_tr2, o_taue670_tr2, o_taue865_tr2, &
-         o_taue550_ss,o_taue670_ss, o_taue865_ss, &
-         o_taue550_dust, o_taue670_dust, o_taue865_dust, &
-         o_taue550_dustsco, o_taue670_dustsco, o_taue865_dustsco, &
-         o_taue550_aqua, o_taue670_aqua, o_taue865_aqua, &
-         o_taue550_terra, o_taue670_terra, o_taue865_terra, &
-         o_taue550_fine_aqua     ,         o_taue670_fine_aqua     ,  &
-         o_taue865_fine_aqua     ,         o_taue550_coss_aqua      ,  &
-         o_taue670_coss_aqua      ,         o_taue865_coss_aqua      ,  &
-         o_taue550_codu_aqua    ,         o_taue670_codu_aqua    ,  &
-         o_taue865_codu_aqua    ,         o_taue670_scdu_aqua ,  &
-         o_taue550_scdu_aqua ,         o_taue865_scdu_aqua ,  &
-         o_taue550_fine_terra     ,         o_taue670_fine_terra     ,&
-         o_taue865_fine_terra     ,         o_taue550_coss_terra      ,&
-         o_taue670_coss_terra      ,         o_taue865_coss_terra      ,&
-         o_taue550_codu_terra    ,         o_taue670_codu_terra    ,&
-         o_taue865_codu_terra    ,         o_taue670_scdu_terra ,&
-         o_taue550_scdu_terra ,         o_taue865_scdu_terra ,&
-         o_trm01,o_trm02,o_trm03,o_trm04,o_trm05,&
-         o_sconc01,o_sconc02,o_sconc03,o_sconc04,o_sconc05, &
-         o_flux01,o_flux02,o_flux03,o_flux04,o_flux05, &
-         o_ds01,o_ds02,o_ds03,o_ds04,o_ds05, &
-         o_dh01,o_dh02,o_dh03,o_dh04,o_dh05, &
-         o_dtrconv01,o_dtrconv02,o_dtrconv03,o_dtrconv04,o_dtrconv05, &
-         o_dtherm01,o_dtherm02,o_dtherm03,o_dtherm04,o_dtherm05, &
-         o_dhkecv01,o_dhkecv02,o_dhkecv03,o_dhkecv04,o_dhkecv05, &
-         o_d_tr_ds01,o_d_tr_ds02,o_d_tr_ds03,o_d_tr_ds04,o_d_tr_ds05, &
-         o_dhkelsc01,o_dhkelsc02,o_dhkelsc03,o_dhkelsc04,o_dhkelsc05, &
-         o_d_tr_sat01,o_d_tr_cv01,o_d_tr_cv02,o_d_tr_cv03,o_d_tr_cv04,o_d_tr_cv05,&
-         o_d_tr_trsp01,o_d_tr_trsp02,o_d_tr_trsp03,o_d_tr_trsp04,o_d_tr_trsp05,&
-         o_d_tr_sscav01,o_d_tr_sscav02,o_d_tr_sscav03,o_d_tr_sscav04,o_d_tr_sscav05,&
-         o_d_tr_sat02,o_d_tr_sat03,o_d_tr_sat04,o_d_tr_sat05,  &
-         o_d_tr_uscav01,o_d_tr_uscav02,o_d_tr_uscav03,o_d_tr_uscav04,o_d_tr_uscav05,&
-         o_d_tr_insc01,o_d_tr_insc02,o_d_tr_insc03,o_d_tr_insc04,o_d_tr_insc05,&
-         o_d_tr_bcscav01,o_d_tr_bcscav02,o_d_tr_bcscav03,o_d_tr_bcscav04,o_d_tr_bcscav05,&
-         o_d_tr_evapls01,o_d_tr_evapls02,o_d_tr_evapls03,o_d_tr_evapls04,o_d_tr_evapls05,&
-         o_d_tr_ls01,o_d_tr_ls02,o_d_tr_ls03,o_d_tr_ls04,o_d_tr_ls05,&
-         o_d_tr_dyn01,o_d_tr_dyn02,o_d_tr_dyn03,o_d_tr_dyn04,o_d_tr_dyn05,&
-         o_d_tr_cl01,o_d_tr_cl02,o_d_tr_cl03,o_d_tr_cl04,o_d_tr_cl05,&
-         o_d_tr_th01,o_d_tr_th02,o_d_tr_th03,o_d_tr_th04,o_d_tr_th05,&
-         o_sed_ss,o_sed_dust,o_sed_dustsco,o_g2p_gas,o_g2p_aer, &
-         o_sed_ss3D,o_sed_dust3D,o_sed_dustsco3D, &
-         o_fluxbb, &
-         o_fluxff    ,o_fluxbcbb  ,o_fluxbcff  ,o_fluxbcnff , &
-         o_fluxbcba  ,o_fluxbc    ,o_fluxombb  ,o_fluxomff  , &
-         o_fluxomnff ,o_fluxomba  ,o_fluxomnat ,o_fluxom    , &
-         o_fluxh2sff ,o_fluxh2snff,o_fluxso2ff ,o_fluxso2nff, &
-         o_fluxso2bb ,o_fluxso2vol,o_fluxso2ba ,o_fluxso2   , &
-         o_fluxso4ff ,o_fluxso4nff,o_fluxso4bb ,o_fluxso4ba , &
-         o_fluxso4   ,o_fluxdms   ,o_fluxh2sbio,o_fluxdustec, &
-         o_fluxddfine,o_fluxddcoa ,o_fluxddsco ,o_fluxdd    ,&
-         o_fluxssfine,o_fluxsscoa, o_fluxss, &
-         o_flux_sparam_ind,o_flux_sparam_bb, &
-         o_flux_sparam_ff ,o_flux_sparam_ddfine  ,o_flux_sparam_ddcoa, &
-         o_flux_sparam_ddsco,o_flux_sparam_ssfine,o_flux_sparam_sscoa, &
-         o_u10m_ss,o_v10m_ss
-
-!JE20150620>>
+            is_ave, is_sic, o_contfracATM, o_contfracOR, &
+            o_aireTER, o_flat, o_slp, o_tsol, &
+            o_t2m, o_t2m_min, o_t2m_max, &
+            o_t2m_min_mon, o_t2m_max_mon, &
+            o_q2m, o_ustar, o_u10m, o_v10m, &
+            o_wind10m, o_wind10max, o_gusts, o_sicf, &
+            o_psol, o_mass, o_qsurf, o_qsol, &
+            o_precip, o_ndayrain, o_plul, o_pluc, &
+            o_snow, o_msnow, o_fsnow, o_evap, &
+            o_tops, o_tops0, o_topl, o_topl0, &
+            o_SWupTOA, o_SWupTOAclr, o_SWdnTOA, &
+            o_SWdnTOAclr, o_nettop, o_SWup200, &
+            o_SWup200clr, o_SWdn200, o_SWdn200clr, &
+            o_LWup200, o_LWup200clr, o_LWdn200, &
+            o_LWdn200clr, o_sols, o_sols0, &
+            o_soll, o_radsol, o_soll0, o_SWupSFC, &
+            o_SWupSFCclr, o_SWdnSFC, o_SWdnSFCclr, &
+            o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
+            o_LWdnSFCclr, o_bils, o_bils_diss, &
+            o_bils_ec, o_bils_ech, o_bils_tke, o_bils_kinetic, &
+            o_bils_latent, o_bils_enthalp, o_sens, &
+            o_fder, o_ffonte, o_fqcalving, o_fqfonte, &
+            o_taux, o_tauy, o_snowsrf, o_qsnow, &
+            o_snowhgt, o_toice, o_sissnow, o_runoff, &
+            o_albslw3, o_pourc_srf, o_fract_srf, &
+            o_taux_srf, o_tauy_srf, o_tsol_srf, &
+            o_evappot_srf, o_ustar_srf, o_u10m_srf, &
+            o_v10m_srf, o_t2m_srf, o_evap_srf, &
+            o_sens_srf, o_lat_srf, o_flw_srf, &
+            o_fsw_srf, o_wbils_srf, o_wbilo_srf, &
+            o_tke_srf, o_tke_max_srf, o_dltpbltke_srf, o_wstar, &
+            o_cdrm, o_cdrh, o_cldl, o_cldm, o_cldh, &
+            o_cldt, o_JrNt, o_cldljn, o_cldmjn, &
+            o_cldhjn, o_cldtjn, o_cldq, o_lwp, o_iwp, &
+            o_ue, o_ve, o_uq, o_vq, o_cape, o_pbase, &
+            o_ptop, o_fbase, o_plcl, o_plfc, &
+            o_wbeff, o_cape_max, o_upwd, o_Ma, &
+            o_dnwd, o_dnwd0, o_ftime_con, o_mc, &
+            o_prw, o_s_pblh, o_s_pblt, o_s_lcl, &
+            o_s_therm, o_uSTDlevs, o_vSTDlevs, &
+            o_wSTDlevs, o_zSTDlevs, o_qSTDlevs, &
+            o_tSTDlevs, epsfra, o_t_oce_sic, &
+            o_ale_bl, o_alp_bl, o_ale_wk, o_alp_wk, &
+            o_ale, o_alp, o_cin, o_WAPE, o_wake_h, &
+            o_wake_s, o_wake_deltat, o_wake_deltaq, &
+            o_wake_omg, o_dtwak, o_dqwak, o_Vprecip, &
+            o_ftd, o_fqd, o_wdtrainA, o_wdtrainM, &
+            o_n2, o_s2, o_proba_notrig, &
+            o_random_notrig, o_ale_bl_stat, &
+            o_ale_bl_trig, o_alp_bl_det, &
+            o_alp_bl_fluct_m, o_alp_bl_fluct_tke, &
+            o_alp_bl_conv, o_alp_bl_stat, &
+            o_slab_qflux, o_tslab, &
+            !o_slab_bils, &
+            o_slab_bilg, o_slab_sic, o_slab_tice, &
+            o_weakinv, o_dthmin, o_cldtau, &
+            o_cldemi, o_pr_con_l, o_pr_con_i, &
+            o_pr_lsc_l, o_pr_lsc_i, o_re, o_fl, &
+            o_rh2m, &
+            !o_rh2m_min, o_rh2m_max, &
+            o_qsat2m, o_tpot, o_tpote, o_SWnetOR, &
+            o_LWdownOR, o_snowl, &
+            o_solldown, o_dtsvdfo, o_dtsvdft, &
+            o_dtsvdfg, o_dtsvdfi, o_z0m, o_z0h, o_od550aer, &
+            o_od865aer, o_abs550aer, o_od550lt1aer, &
+            o_sconcso4, o_sconcno3, o_sconcoa, o_sconcbc, &
+            o_sconcss, o_sconcdust, o_concso4, o_concno3, &
+            o_concoa, o_concbc, o_concss, o_concdust, &
+            o_loadso4, o_loadoa, o_loadbc, o_loadss, &
+            o_loaddust, o_tausumaero, o_tausumaero_lw, &
+            o_topswad, o_topswad0, o_solswad, o_solswad0, &
+            o_toplwad, o_toplwad0, o_sollwad, o_sollwad0, &
+            o_swtoaas_nat, o_swsrfas_nat, &
+            o_swtoacs_nat, o_swtoaas_ant, &
+            o_swsrfas_ant, o_swtoacs_ant, &
+            o_swsrfcs_ant, o_swtoacf_nat, &
+            o_swsrfcf_nat, o_swtoacf_ant, &
+            o_swsrfcs_nat, o_swsrfcf_ant, &
+            o_swtoacf_zero, o_swsrfcf_zero, &
+            o_topswai, o_solswai, o_scdnc, &
+            o_cldncl, o_reffclws, o_reffclwc, &
+            o_cldnvi, o_lcc, o_lcc3d, o_lcc3dcon, &
+            o_lcc3dstra, o_reffclwtop, o_ec550aer, &
+            o_lwcon, o_iwcon, o_temp, o_theta, &
+            o_ovapinit, o_ovap, o_oliq, o_geop, &
+            o_vitu, o_vitv, o_vitw, o_pres, o_paprs, &
+            o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
+            o_rnebls, o_rhum, o_ozone, o_ozone_light, &
+            o_dtphy, o_dqphy, o_albe_srf, o_z0m_srf, o_z0h_srf, &
+            o_ages_srf, o_snow_srf, o_alb1, o_alb2, o_tke, &
+            o_tke_max, o_kz, o_kz_max, o_clwcon, &
+            o_dtdyn, o_dqdyn, o_dudyn, o_dvdyn, &
+            o_dtcon, o_tntc, o_ducon, o_dvcon, &
+            o_dqcon, o_tnhusc, o_tnhusc, o_dtlsc, &
+            o_dtlschr, o_dqlsc, o_beta_prec, &
+            o_dtlscth, o_dtlscst, o_dqlscth, &
+            o_dqlscst, o_plulth, o_plulst, &
+            o_ptconvth, o_lmaxth, o_dtvdf, &
+            o_dtdis, o_dqvdf, o_dteva, o_dqeva, &
+            o_ptconv, o_ratqs, o_dtthe, &
+            o_duthe, o_dvthe, o_ftime_th, &
+            o_f_th, o_e_th, o_w_th, o_q_th, &
+            o_a_th, o_d_th, o_f0_th, o_zmax_th, &
+            o_dqthe, o_dtajs, o_dqajs, o_dtswr, &
+            o_dtsw0, o_dtlwr, o_dtlw0, o_dtec, &
+            o_duvdf, o_dvvdf, o_duoro, o_dvoro, &
+            o_dtoro, o_dulif, o_dvlif, o_dtlif, &
+            !       o_duhin, o_dvhin, o_dthin, &
+            o_dqch4, o_rsu, &
+            o_rsd, o_rlu, o_rld, o_rsucs, o_rsdcs, &
+            o_rlucs, o_rldcs, o_tnt, o_tntr, &
+            o_tntscpbl, o_tnhus, o_tnhusscpbl, &
+            o_evu, o_h2o, o_mcd, o_dmc, o_ref_liq, &
+            o_ref_ice, o_rsut4co2, o_rlut4co2, &
+            o_rsutcs4co2, o_rlutcs4co2, o_rsu4co2, &
+            o_rlu4co2, o_rsucs4co2, o_rlucs4co2, &
+            o_rsd4co2, o_rld4co2, o_rsdcs4co2, &
+            o_rldcs4co2, o_tnondef, o_ta, o_zg, &
+            o_hus, o_hur, o_ua, o_va, o_wap, &
+            o_psbg, o_tro3, o_tro3_daylight, &
+            o_uxv, o_vxq, o_vxT, o_wxq, o_vxphi, &
+            o_wxT, o_uxu, o_vxv, o_TxT, o_trac, &
+            o_dtr_vdf, o_dtr_the, o_dtr_con, &
+            o_dtr_lessi_impa, o_dtr_lessi_nucl, &
+            o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
+            !        o_dtr_ls, o_dtr_dyn, o_dtr_cl, o_dtr_trsp, o_dtr_sscav, &
+            o_dtr_ls, o_dtr_trsp, o_dtr_sscav, &
+            o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
+            !JE20150620<<
+            !         o_vstr_gwd_rando
+            o_vstr_gwd_rando, &
+            o_m1dflux, o_m2dflux, o_m3dflux, &
+            o_taue550, &
+            o_taue670, o_taue865, &
+            o_taue550_tr2, o_taue670_tr2, o_taue865_tr2, &
+            o_taue550_ss, o_taue670_ss, o_taue865_ss, &
+            o_taue550_dust, o_taue670_dust, o_taue865_dust, &
+            o_taue550_dustsco, o_taue670_dustsco, o_taue865_dustsco, &
+            o_taue550_aqua, o_taue670_aqua, o_taue865_aqua, &
+            o_taue550_terra, o_taue670_terra, o_taue865_terra, &
+            o_taue550_fine_aqua, o_taue670_fine_aqua, &
+            o_taue865_fine_aqua, o_taue550_coss_aqua, &
+            o_taue670_coss_aqua, o_taue865_coss_aqua, &
+            o_taue550_codu_aqua, o_taue670_codu_aqua, &
+            o_taue865_codu_aqua, o_taue670_scdu_aqua, &
+            o_taue550_scdu_aqua, o_taue865_scdu_aqua, &
+            o_taue550_fine_terra, o_taue670_fine_terra, &
+            o_taue865_fine_terra, o_taue550_coss_terra, &
+            o_taue670_coss_terra, o_taue865_coss_terra, &
+            o_taue550_codu_terra, o_taue670_codu_terra, &
+            o_taue865_codu_terra, o_taue670_scdu_terra, &
+            o_taue550_scdu_terra, o_taue865_scdu_terra, &
+            o_trm01, o_trm02, o_trm03, o_trm04, o_trm05, &
+            o_sconc01, o_sconc02, o_sconc03, o_sconc04, o_sconc05, &
+            o_flux01, o_flux02, o_flux03, o_flux04, o_flux05, &
+            o_ds01, o_ds02, o_ds03, o_ds04, o_ds05, &
+            o_dh01, o_dh02, o_dh03, o_dh04, o_dh05, &
+            o_dtrconv01, o_dtrconv02, o_dtrconv03, o_dtrconv04, o_dtrconv05, &
+            o_dtherm01, o_dtherm02, o_dtherm03, o_dtherm04, o_dtherm05, &
+            o_dhkecv01, o_dhkecv02, o_dhkecv03, o_dhkecv04, o_dhkecv05, &
+            o_d_tr_ds01, o_d_tr_ds02, o_d_tr_ds03, o_d_tr_ds04, o_d_tr_ds05, &
+            o_dhkelsc01, o_dhkelsc02, o_dhkelsc03, o_dhkelsc04, o_dhkelsc05, &
+            o_d_tr_sat01, o_d_tr_cv01, o_d_tr_cv02, o_d_tr_cv03, o_d_tr_cv04, o_d_tr_cv05, &
+            o_d_tr_trsp01, o_d_tr_trsp02, o_d_tr_trsp03, o_d_tr_trsp04, o_d_tr_trsp05, &
+            o_d_tr_sscav01, o_d_tr_sscav02, o_d_tr_sscav03, o_d_tr_sscav04, o_d_tr_sscav05, &
+            o_d_tr_sat02, o_d_tr_sat03, o_d_tr_sat04, o_d_tr_sat05, &
+            o_d_tr_uscav01, o_d_tr_uscav02, o_d_tr_uscav03, o_d_tr_uscav04, o_d_tr_uscav05, &
+            o_d_tr_insc01, o_d_tr_insc02, o_d_tr_insc03, o_d_tr_insc04, o_d_tr_insc05, &
+            o_d_tr_bcscav01, o_d_tr_bcscav02, o_d_tr_bcscav03, o_d_tr_bcscav04, o_d_tr_bcscav05, &
+            o_d_tr_evapls01, o_d_tr_evapls02, o_d_tr_evapls03, o_d_tr_evapls04, o_d_tr_evapls05, &
+            o_d_tr_ls01, o_d_tr_ls02, o_d_tr_ls03, o_d_tr_ls04, o_d_tr_ls05, &
+            o_d_tr_dyn01, o_d_tr_dyn02, o_d_tr_dyn03, o_d_tr_dyn04, o_d_tr_dyn05, &
+            o_d_tr_cl01, o_d_tr_cl02, o_d_tr_cl03, o_d_tr_cl04, o_d_tr_cl05, &
+            o_d_tr_th01, o_d_tr_th02, o_d_tr_th03, o_d_tr_th04, o_d_tr_th05, &
+            o_sed_ss, o_sed_dust, o_sed_dustsco, o_g2p_gas, o_g2p_aer, &
+            o_sed_ss3D, o_sed_dust3D, o_sed_dustsco3D, &
+            o_fluxbb, &
+            o_fluxff, o_fluxbcbb, o_fluxbcff, o_fluxbcnff, &
+            o_fluxbcba, o_fluxbc, o_fluxombb, o_fluxomff, &
+            o_fluxomnff, o_fluxomba, o_fluxomnat, o_fluxom, &
+            o_fluxh2sff, o_fluxh2snff, o_fluxso2ff, o_fluxso2nff, &
+            o_fluxso2bb, o_fluxso2vol, o_fluxso2ba, o_fluxso2, &
+            o_fluxso4ff, o_fluxso4nff, o_fluxso4bb, o_fluxso4ba, &
+            o_fluxso4, o_fluxdms, o_fluxh2sbio, o_fluxdustec, &
+            o_fluxddfine, o_fluxddcoa, o_fluxddsco, o_fluxdd, &
+            o_fluxssfine, o_fluxsscoa, o_fluxss, &
+            o_flux_sparam_ind, o_flux_sparam_bb, &
+            o_flux_sparam_ff, o_flux_sparam_ddfine, o_flux_sparam_ddcoa, &
+            o_flux_sparam_ddsco, o_flux_sparam_ssfine, o_flux_sparam_sscoa, &
+            o_u10m_ss, o_v10m_ss
+
+    !JE20150620>>
 
     USE phys_state_var_mod, ONLY: pctsrf, paire_ter, rain_fall, snow_fall, &
-         qsol, z0m, z0h, fevap, agesno, &
-         nday_rain, rain_con, snow_con, &
-         topsw, toplw, toplw0, swup, swdn, &
-         topsw0, swup0, swdn0, SWup200, SWup200clr, &
-         SWdn200, SWdn200clr, LWup200, LWup200clr, &
-         LWdn200, LWdn200clr, solsw, solsw0, sollw, &
-         radsol, sollw0, sollwdown, sollw, gustiness, &
-         sollwdownclr, lwdn0, ftsol, ustar, u10m, &
-         v10m, pbl_tke, wake_delta_pbl_TKE, &
-         wstar, cape, ema_pcb, ema_pct, &
-         ema_cbmf, Ma, fm_therm, ale_bl, alp_bl, ale, &
-         alp, cin, wake_pe, wake_s, wake_deltat, &
-         ale_wake, ale_bl_stat, &
-         wake_deltaq, ftd, fqd, ale_bl_trig, albsol1, &
-         rnebcon, wo, falb1, albsol2, coefh, clwcon0, &
-         ratqs, entr_therm, zqasc, detr_therm, f0, &
-         lwup, lwdn, lwup0, coefm, &
-         swupp, lwupp, swup0p, lwup0p, swdnp, lwdnp, &
-         swdn0p, lwdn0p, tnondef, O3sumSTD, uvsumSTD, &
-         vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
-         vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
-         T2sumSTD, nlevSTD, &
-!        du_gwd_rando, dv_gwd_rando, &
-         ulevSTD, vlevSTD, wlevSTD, philevSTD, qlevSTD, tlevSTD, &
-         rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, &
-         vphiSTD, wTSTD, u2STD, v2STD, T2STD, missing_val_nf90
+            qsol, z0m, z0h, fevap, agesno, &
+            nday_rain, rain_con, snow_con, &
+            topsw, toplw, toplw0, swup, swdn, &
+            topsw0, swup0, swdn0, SWup200, SWup200clr, &
+            SWdn200, SWdn200clr, LWup200, LWup200clr, &
+            LWdn200, LWdn200clr, solsw, solsw0, sollw, &
+            radsol, sollw0, sollwdown, sollw, gustiness, &
+            sollwdownclr, lwdn0, ftsol, ustar, u10m, &
+            v10m, pbl_tke, wake_delta_pbl_TKE, &
+            wstar, cape, ema_pcb, ema_pct, &
+            ema_cbmf, Ma, fm_therm, ale_bl, alp_bl, ale, &
+            alp, cin, wake_pe, wake_s, wake_deltat, &
+            ale_wake, ale_bl_stat, &
+            wake_deltaq, ftd, fqd, ale_bl_trig, albsol1, &
+            rnebcon, wo, falb1, albsol2, coefh, clwcon0, &
+            ratqs, entr_therm, zqasc, detr_therm, f0, &
+            lwup, lwdn, lwup0, coefm, &
+            swupp, lwupp, swup0p, lwup0p, swdnp, lwdnp, &
+            swdn0p, lwdn0p, tnondef, O3sumSTD, uvsumSTD, &
+            vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
+            vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
+            T2sumSTD, nlevSTD, &
+            !        du_gwd_rando, dv_gwd_rando, &
+            ulevSTD, vlevSTD, wlevSTD, philevSTD, qlevSTD, tlevSTD, &
+            rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, &
+            vphiSTD, wTSTD, u2STD, v2STD, T2STD, missing_val_nf90
 
     USE phys_local_var_mod, ONLY: zxfluxlat, slp, zxtsol, zt2m, &
-         t2m_min_mon, t2m_max_mon, evap, &
-         zu10m, zv10m, zq2m, zustar, zxqsurf, &
-         rain_lsc, snow_lsc, bils, sens, fder, &
-         zxffonte, zxfqcalving, zxfqfonte, fluxu, &
-         fluxv, zxsnow, qsnow, snowhgt, to_ice, &
-         sissnow, runoff, albsol3_lic, evap_pot, &
-         t2m, fluxt, fluxlat, fsollw, fsolsw, &
-         wfbils, cdragm, cdragh, cldl, cldm, &
-         cldh, cldt, JrNt, &
-         ! cldljn, cldmjn, cldhjn, cldtjn &
-         cldq, flwp, fiwp, ue, ve, uq, vq, &
-         plcl, plfc, wbeff, upwd, dnwd, dnwd0, prw, &
-         s_pblh, s_pblt, s_lcl, s_therm, uwriteSTD, &
-         vwriteSTD, wwriteSTD, phiwriteSTD, qwriteSTD, &
-         twriteSTD, alp_wake, wake_h, &
-         !ale_wake, &
-         wake_omg, d_t_wake, d_q_wake, Vprecip, &
-         wdtrainA, wdtrainM, n2, s2, proba_notrig, &
-         random_notrig, &
-         !ale_bl_stat, &
-         alp_bl_det, alp_bl_fluct_m, alp_bl_conv, &
-         alp_bl_stat, alp_bl_fluct_tke, slab_wfbils, &
-         weak_inversion, dthmin, cldtau, cldemi, &
-         pmflxr, pmflxs, prfl, psfl, re, fl, rh2m, &
-         qsat2m, tpote, tpot, d_ts, od550aer, &
-         od865aer, abs550aer, od550lt1aer, sconcso4, sconcno3, &
-         sconcoa, sconcbc, sconcss, sconcdust, concso4, concno3, &
-         concoa, concbc, concss, concdust, loadso4, &
-         loadoa, loadbc, loadss, loaddust, tausum_aero, &
-         topswad_aero, topswad0_aero, solswad_aero, &
-         solswad0_aero, topsw_aero, solsw_aero, &
-         topsw0_aero, solsw0_aero, topswcf_aero, &
-         solswcf_aero, topswai_aero, solswai_aero, &
-         toplwad_aero, toplwad0_aero, sollwad_aero, &
-         sollwad0_aero, toplwai_aero, sollwai_aero, &
-         !scdnc, cldncl, reffclws, reffclwc, cldnvi, &
-         !lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop, &
-         ec550aer, flwc, fiwc, t_seri, theta, q_seri, &
-!jyg<
-!!         ql_seri, zphi, u_seri, v_seri, omega, cldfra, &
-         ql_seri, tr_seri, &
-         zphi, u_seri, v_seri, omega, cldfra, &
-!>jyg
-         rneb, rnebjn, zx_rh, d_t_dyn, d_q_dyn, &
-         d_u_dyn, d_v_dyn, d_t_con, d_t_ajsb, d_t_ajs, &
-         d_u_ajs, d_v_ajs, &
-         d_u_con, d_v_con, d_q_con, d_q_ajs, d_t_lsc, &
-         d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0, &
-         d_t_eva, d_q_lsc, beta_prec, d_t_lscth, &
-         d_t_lscst, d_q_lscth, d_q_lscst, plul_th, &
-         plul_st, d_t_vdf, d_t_diss, d_q_vdf, d_q_eva, &
-         zw2, fraca, zmax_th, d_q_ajsb, d_t_ec, d_u_vdf, &
-         d_v_vdf, d_u_oro, d_v_oro, d_t_oro, d_u_lif, &
-         d_v_lif, d_t_lif, &
-!        d_u_hin, d_v_hin, d_t_hin, &
-         d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD
+            t2m_min_mon, t2m_max_mon, evap, &
+            zu10m, zv10m, zq2m, zustar, zxqsurf, &
+            rain_lsc, snow_lsc, bils, sens, fder, &
+            zxffonte, zxfqcalving, zxfqfonte, fluxu, &
+            fluxv, zxsnow, qsnow, snowhgt, to_ice, &
+            sissnow, runoff, albsol3_lic, evap_pot, &
+            t2m, fluxt, fluxlat, fsollw, fsolsw, &
+            wfbils, cdragm, cdragh, cldl, cldm, &
+            cldh, cldt, JrNt, &
+            ! cldljn, cldmjn, cldhjn, cldtjn &
+            cldq, flwp, fiwp, ue, ve, uq, vq, &
+            plcl, plfc, wbeff, upwd, dnwd, dnwd0, prw, &
+            s_pblh, s_pblt, s_lcl, s_therm, uwriteSTD, &
+            vwriteSTD, wwriteSTD, phiwriteSTD, qwriteSTD, &
+            twriteSTD, alp_wake, wake_h, &
+            !ale_wake, &
+            wake_omg, d_t_wake, d_q_wake, Vprecip, &
+            wdtrainA, wdtrainM, n2, s2, proba_notrig, &
+            random_notrig, &
+            !ale_bl_stat, &
+            alp_bl_det, alp_bl_fluct_m, alp_bl_conv, &
+            alp_bl_stat, alp_bl_fluct_tke, slab_wfbils, &
+            weak_inversion, dthmin, cldtau, cldemi, &
+            pmflxr, pmflxs, prfl, psfl, re, fl, rh2m, &
+            qsat2m, tpote, tpot, d_ts, od550aer, &
+            od865aer, abs550aer, od550lt1aer, sconcso4, sconcno3, &
+            sconcoa, sconcbc, sconcss, sconcdust, concso4, concno3, &
+            concoa, concbc, concss, concdust, loadso4, &
+            loadoa, loadbc, loadss, loaddust, tausum_aero, &
+            topswad_aero, topswad0_aero, solswad_aero, &
+            solswad0_aero, topsw_aero, solsw_aero, &
+            topsw0_aero, solsw0_aero, topswcf_aero, &
+            solswcf_aero, topswai_aero, solswai_aero, &
+            toplwad_aero, toplwad0_aero, sollwad_aero, &
+            sollwad0_aero, toplwai_aero, sollwai_aero, &
+            !scdnc, cldncl, reffclws, reffclwc, cldnvi, &
+            !lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop, &
+            ec550aer, flwc, fiwc, t_seri, theta, q_seri, &
+            !jyg<
+            !!         ql_seri, zphi, u_seri, v_seri, omega, cldfra, &
+            ql_seri, tr_seri, &
+            zphi, u_seri, v_seri, omega, cldfra, &
+            !>jyg
+            rneb, rnebjn, zx_rh, d_t_dyn, d_q_dyn, &
+            d_u_dyn, d_v_dyn, d_t_con, d_t_ajsb, d_t_ajs, &
+            d_u_ajs, d_v_ajs, &
+            d_u_con, d_v_con, d_q_con, d_q_ajs, d_t_lsc, &
+            d_t_lwr, d_t_lw0, d_t_swr, d_t_sw0, &
+            d_t_eva, d_q_lsc, beta_prec, d_t_lscth, &
+            d_t_lscst, d_q_lscth, d_q_lscst, plul_th, &
+            plul_st, d_t_vdf, d_t_diss, d_q_vdf, d_q_eva, &
+            zw2, fraca, zmax_th, d_q_ajsb, d_t_ec, d_u_vdf, &
+            d_v_vdf, d_u_oro, d_v_oro, d_t_oro, d_u_lif, &
+            d_v_lif, d_t_lif, &
+            !        d_u_hin, d_v_hin, d_t_hin, &
+            d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD
 
     USE phys_output_var_mod, ONLY: vars_defined, snow_o, zfra_o, bils_diss, &
-         bils_ec,bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
-         itau_con, nfiles, clef_files, nid_files, zvstr_gwd_rando, &
-         scdnc, cldncl, reffclws, reffclwc, cldnvi, &
-         lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop
+            bils_ec, bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
+            itau_con, nfiles, clef_files, nid_files, zvstr_gwd_rando, &
+            scdnc, cldncl, reffclws, reffclwc, cldnvi, &
+            lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop
     USE ocean_slab_mod, ONLY: tslab, slab_bilg, tice, seaice
     USE pbl_surface_mod, ONLY: snow
@@ -386,5 +385,5 @@
     USE lmdz_geometry, ONLY: cell_area
     USE surface_data, ONLY: type_ocean, version_ocean, ok_veget, landice_opt
-!    USE aero_mod, ONLY: naero_spc
+    !    USE aero_mod, ONLY: naero_spc
     USE aero_mod, ONLY: naero_tot, id_STRAT_phy
     USE ioipsl, ONLY: histend, histsync
@@ -396,13 +395,13 @@
     USE phys_cal_mod, ONLY: mth_len
     USE lmdz_yomcst
+    USE lmdz_iniprint, ONLY: lunout, prt_level
 
     IMPLICIT NONE
 
-!   INCLUDE "temps.h"
+    !   INCLUDE "temps.h"
     INCLUDE "clesphys.h"
     INCLUDE "alpale.h"
     INCLUDE "compbl.h"
     INCLUDE "dimensions.h"
-    include "iniprint.h"
 
     ! Input
@@ -413,35 +412,35 @@
     LOGICAL, DIMENSION(klon, klev) :: ptconv, ptconvth
     REAL :: pdtphys
-    CHARACTER (LEN=4), DIMENSION(nlevSTD) :: clevSTD
-    REAL, DIMENSION(klon,nlevSTD) :: zx_tmp_fi3d_STD
+    CHARACTER (LEN = 4), DIMENSION(nlevSTD) :: clevSTD
+    REAL, DIMENSION(klon, nlevSTD) :: zx_tmp_fi3d_STD
     REAL, DIMENSION(klon) :: pphis
     REAL, DIMENSION(klon, klev) :: pplay, d_t
-    REAL, DIMENSION(klon, klev+1) :: paprs
-    REAL, DIMENSION(klon,klev,nqtot) :: qx, d_qx
-    REAL,DIMENSION(klon,klev,nbtr),INTENT(IN)    :: d_tr_dyn
+    REAL, DIMENSION(klon, klev + 1) :: paprs
+    REAL, DIMENSION(klon, klev, nqtot) :: qx, d_qx
+    REAL, DIMENSION(klon, klev, nbtr), INTENT(IN) :: d_tr_dyn
     REAL, DIMENSION(klon, llm) :: zmasse
     INTEGER :: flag_aerosol_strat
-    INTEGER :: flag_aerosol 
+    INTEGER :: flag_aerosol
     LOGICAL :: ok_cdnc
     REAL, DIMENSION(3) :: freq_moyNMC
 
     ! Local
-    INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
+    INTEGER, PARAMETER :: jjmp1 = jjm + 1 - 1 / jjm
     INTEGER :: itau_w
-    INTEGER :: i, iinit, iinitend=1, iff, iq, itr, nsrf, k, ll, naero
+    INTEGER :: i, iinit, iinitend = 1, iff, iq, itr, nsrf, k, ll, naero
     REAL, DIMENSION (klon) :: zx_tmp_fi2d
-    REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
-    REAL, DIMENSION (klon,klev+1) :: zx_tmp_fi3d1
-    CHARACTER (LEN=4)              :: bb2
-    INTEGER, DIMENSION(iim*jjmp1)  :: ndex2d
-    INTEGER, DIMENSION(iim*jjmp1*klev) :: ndex3d
+    REAL, DIMENSION (klon, klev) :: zx_tmp_fi3d, zpt_conv
+    REAL, DIMENSION (klon, klev + 1) :: zx_tmp_fi3d1
+    CHARACTER (LEN = 4) :: bb2
+    INTEGER, DIMENSION(iim * jjmp1) :: ndex2d
+    INTEGER, DIMENSION(iim * jjmp1 * klev) :: ndex3d
     REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
     REAL :: missing_val
-    REAL, PARAMETER :: un_jour=86400.
+    REAL, PARAMETER :: un_jour = 86400.
 
     IF (using_xios) THEN
-      missing_val=missing_val_xios
+      missing_val = missing_val_xios
     ELSE
-      missing_val=nf90_fill_real
+      missing_val = nf90_fill_real
     ENDIF
 
@@ -451,1226 +450,1227 @@
     CALL set_itau_iophy(itau_w)
 
-!AS, vu avec LF : le test est fait maintenant au debut du pdt, pas a la fin, alors on ne passe plus qu'une fois
-! Donc le "IF (.NOT.vars_defined)" devient inutile, et la boucle "DO iinit=1, iinitend" pourra etre eliminee 
-!  ainsi que iinit, iinitend
-!    IF (.NOT.vars_defined) THEN
-!       iinitend = 2
-!    ELSE
-!       iinitend = 1
-!    ENDIF
+    !AS, vu avec LF : le test est fait maintenant au debut du pdt, pas a la fin, alors on ne passe plus qu'une fois
+    ! Donc le "IF (.NOT.vars_defined)" devient inutile, et la boucle "DO iinit=1, iinitend" pourra etre eliminee
+    !  ainsi que iinit, iinitend
+    !    IF (.NOT.vars_defined) THEN
+    !       iinitend = 2
+    !    ELSE
+    !       iinitend = 1
+    !    ENDIF
 
     ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
-    DO iinit=1, iinitend
-       IF (using_xios) THEN
-         !$OMP MASTER
-         IF (vars_defined) THEN
-            IF (prt_level >= 10) THEN
-               WRITE(lunout,*)"phys_output_write: CALL xios_update_calendar, itau_w=",itau_w
-            ENDIF
-!           CALL xios_update_calendar(itau_w)
-            CALL xios_update_calendar(itap)
-         ENDIF
-         !$OMP END MASTER
-         !$OMP BARRIER
-       ENDIF !using_xios
-
-       ! On procède à l'écriture ou à la définition des nombreuses variables:
-!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       CALL histwrite_phy(o_phis, pphis)
-       CALL histwrite_phy(o_aire, cell_area)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
-          ENDDO
-       ENDIF
-
-       CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
-       CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
-       CALL histwrite_phy(o_aireTER, paire_ter)
-
-!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-! JE20141223 <<
-       INCLUDE "spla_output_write.h"
-! JE20141223 >>
-
-       CALL histwrite_phy(o_flat, zxfluxlat)
-       CALL histwrite_phy(o_slp, slp)
-       CALL histwrite_phy(o_tsol, zxtsol)
-       CALL histwrite_phy(o_t2m, zt2m)
-       CALL histwrite_phy(o_t2m_min, zt2m)
-       CALL histwrite_phy(o_t2m_max, zt2m)
-       CALL histwrite_phy(o_t2m_max_mon, t2m_max_mon)
-       CALL histwrite_phy(o_t2m_min_mon, t2m_min_mon)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_gusts, gustiness)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = pctsrf(i,is_sic)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
-       CALL histwrite_phy(o_q2m, zq2m)
-       CALL histwrite_phy(o_ustar, zustar)
-       CALL histwrite_phy(o_u10m, zu10m)
-       CALL histwrite_phy(o_v10m, zv10m)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = paprs(i,1)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_psol, zx_tmp_fi2d)
-       CALL histwrite_phy(o_mass, zmasse)
-       CALL histwrite_phy(o_qsurf, zxqsurf)
-
-       IF (.NOT. ok_veget) THEN
-          CALL histwrite_phy(o_qsol, qsol)
-       ENDIF
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
-          ENDDO
-       ENDIF
-
-       CALL histwrite_phy(o_precip, zx_tmp_fi2d)
-       CALL histwrite_phy(o_ndayrain, nday_rain)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_plul, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i = 1, klon
-             zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
-       CALL histwrite_phy(o_snow, snow_fall)
-       CALL histwrite_phy(o_msnow, zxsnow)
-       CALL histwrite_phy(o_fsnow, zfra_o)
-       CALL histwrite_phy(o_evap, evap)
-       CALL histwrite_phy(o_tops, topsw)
-       CALL histwrite_phy(o_tops0, topsw0)
-       CALL histwrite_phy(o_topl, toplw)
-       CALL histwrite_phy(o_topl0, toplw0)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
-       ENDIF
-       CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
-       ENDIF
-       CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
-       ENDIF
-       CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
-       ENDIF
-       CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(:) = topsw(:)-toplw(:)
-       ENDIF
-       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
-       CALL histwrite_phy(o_SWup200, SWup200)
-       CALL histwrite_phy(o_SWup200clr, SWup200clr)
-       CALL histwrite_phy(o_SWdn200, SWdn200)
-       CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
-       CALL histwrite_phy(o_LWup200, LWup200)
-       CALL histwrite_phy(o_LWup200clr, LWup200clr)
-       CALL histwrite_phy(o_LWdn200, LWdn200)
-       CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
-       CALL histwrite_phy(o_sols, solsw)
-       CALL histwrite_phy(o_sols0, solsw0)
-       CALL histwrite_phy(o_soll, sollw)
-       CALL histwrite_phy(o_radsol, radsol)
-       CALL histwrite_phy(o_soll0, sollw0)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
-       ENDIF
-       CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
-       ENDIF
-       CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
-       ENDIF
-       CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
-       ENDIF
-       CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
-       ENDIF
-       CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdnSFC, sollwdown)
-
-       IF (vars_defined) THEN
-          sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
-          zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
-       ENDIF
-       CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
-       CALL histwrite_phy(o_bils, bils)
-       CALL histwrite_phy(o_bils_diss, bils_diss)
-       CALL histwrite_phy(o_bils_ec, bils_ec)
-       IF (iflag_ener_conserv>=1) THEN
-         CALL histwrite_phy(o_bils_ech, bils_ech)
-       ENDIF
-       CALL histwrite_phy(o_bils_tke, bils_tke)
-       CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
-       CALL histwrite_phy(o_bils_latent, bils_latent)
-       CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
-       ENDIF
-       CALL histwrite_phy(o_sens, zx_tmp_fi2d)
-       CALL histwrite_phy(o_fder, fder)
-       CALL histwrite_phy(o_ffonte, zxffonte)
-       CALL histwrite_phy(o_fqcalving, zxfqcalving)
-       CALL histwrite_phy(o_fqfonte, zxfqfonte)
-       IF (vars_defined) THEN
-          zx_tmp_fi2d=0.
-          DO nsrf=1,nbsrf
-             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_taux, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi2d=0.
-          DO nsrf=1,nbsrf
-             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
-
-       IF (landice_opt >= 1 ) THEN
-          CALL histwrite_phy(o_snowsrf, snow_o)
-          CALL histwrite_phy(o_qsnow, qsnow)
-          CALL histwrite_phy(o_snowhgt,snowhgt)
-          CALL histwrite_phy(o_toice,to_ice)
-          CALL histwrite_phy(o_sissnow,sissnow)
-          CALL histwrite_phy(o_runoff,runoff)
-          CALL histwrite_phy(o_albslw3,albsol3_lic)
-       ENDIF
-
-       DO nsrf = 1, nbsrf
-          IF (vars_defined)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
-          CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
-          CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
-          CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
-          CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
-          CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
-          CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
-          CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
-          CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
-          CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
-          CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
-          CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
-          CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
-          CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
-          CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
-
-          IF (iflag_pbl > 1) THEN
-             CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
-             CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
+    DO iinit = 1, iinitend
+      IF (using_xios) THEN
+        !$OMP MASTER
+        IF (vars_defined) THEN
+          IF (prt_level >= 10) THEN
+            WRITE(lunout, *)"phys_output_write: CALL xios_update_calendar, itau_w=", itau_w
           ENDIF
-!jyg<
-          IF (iflag_pbl > 1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) THEN
-             CALL histwrite_phy(o_dltpbltke_srf(nsrf), wake_delta_pbl_TKE(:,1:klev,nsrf))
-          ENDIF
-!>jyg
-
-       ENDDO
-       DO nsrf=1,nbsrf+1
-          CALL histwrite_phy(o_wstar(nsrf), wstar(1 : klon, nsrf))
-       ENDDO
-
-       CALL histwrite_phy(o_cdrm, cdragm)
-       CALL histwrite_phy(o_cdrh, cdragh)
-       CALL histwrite_phy(o_cldl, cldl)
-       CALL histwrite_phy(o_cldm, cldm)
-       CALL histwrite_phy(o_cldh, cldh)
-       CALL histwrite_phy(o_cldt, cldt)
-       CALL histwrite_phy(o_JrNt, JrNt)
-
-       !CALL histwrite_phy(o_cldljn, cldl*JrNt)
-       IF (vars_defined)  zx_tmp_fi2d=cldl*JrNt
-       CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
-       !CALL histwrite_phy(o_cldmjn, cldm*JrNt)
-       IF (vars_defined)  zx_tmp_fi2d=cldm*JrNt
-       CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
-       !CALL histwrite_phy(o_cldhjn, cldh*JrNt)
-       IF (vars_defined)  zx_tmp_fi2d=cldh*JrNt
-       CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
-       !CALL histwrite_phy(o_cldtjn, cldt*JrNt)
-       IF (vars_defined)  zx_tmp_fi2d=cldt*JrNt
-       CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_cldq, cldq)
-       IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
-       CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
-       IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
-       CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
-       CALL histwrite_phy(o_ue, ue)
-       CALL histwrite_phy(o_ve, ve)
-       CALL histwrite_phy(o_uq, uq)
-       CALL histwrite_phy(o_vq, vq)
-       IF (iflag_con>=3) THEN ! sb
-          CALL histwrite_phy(o_cape, cape)
-          CALL histwrite_phy(o_pbase, ema_pcb)
-          CALL histwrite_phy(o_ptop, ema_pct)
-          CALL histwrite_phy(o_fbase, ema_cbmf)
-          IF (iflag_con /= 30) THEN
-             CALL histwrite_phy(o_plcl, plcl)
-             CALL histwrite_phy(o_plfc, plfc)
-             CALL histwrite_phy(o_wbeff, wbeff)
-          ENDIF
-
-          CALL histwrite_phy(o_cape_max, cape)
-
-          CALL histwrite_phy(o_upwd, upwd)
-          CALL histwrite_phy(o_Ma, Ma)
-          CALL histwrite_phy(o_dnwd, dnwd)
-          CALL histwrite_phy(o_dnwd0, dnwd0)
-          IF (vars_defined)         zx_tmp_fi2d=float(itau_con)/float(itap)
-          CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
-          IF (vars_defined) THEN
-             IF (iflag_thermals>=1)THEN
-                zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
-             ELSE
-                zx_tmp_fi3d=dnwd+dnwd0+upwd
-             ENDIF
-          ENDIF
-          CALL histwrite_phy(o_mc, zx_tmp_fi3d)
-       ENDIF !iflag_con .GE. 3
-       CALL histwrite_phy(o_prw, prw)
-       CALL histwrite_phy(o_s_pblh, s_pblh)
-       CALL histwrite_phy(o_s_pblt, s_pblt)
-       CALL histwrite_phy(o_s_lcl, s_lcl)
-       CALL histwrite_phy(o_s_therm, s_therm)
-       !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
-       !       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_capCL%name,itau_w,s_capCL)
-       !       ENDIF
-       !       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_oliqCL%name,itau_w,s_oliqCL)
-       !       ENDIF
-       !       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_cteiCL%name,itau_w,s_cteiCL)
-       !       ENDIF
-       !       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb1%name,itau_w,s_trmb1)
-       !       ENDIF
-       !       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb2%name,itau_w,s_trmb2)
-       !       ENDIF
-       !       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
-       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
-       !    $o_s_trmb3%name,itau_w,s_trmb3)
-       !       ENDIF
-
-  IF (.NOT. using_xios) THEN
-    IF (.NOT.ok_all_xml) THEN
-         ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
-         ! Champs interpolles sur des niveaux de pression
-         DO iff=1, nfiles
-           ll=0
-            DO k=1, nlevSTD
-               bb2=clevSTD(k)
-               IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
-                    bb2.EQ."500".OR.bb2.EQ."200".OR. &
-                    bb2.EQ."100".OR. &
-                    bb2.EQ."50".OR.bb2.EQ."10") THEN
-
-                  ! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-                  ll=ll+1
-                  CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
-                  CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
-                  CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
-                  CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
-                  CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
-                  CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
-
-               ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
-            ENDDO
-         ENDDO
-    ENDIF
-  ENDIF !.NOT.using_xios
-
-  IF (using_xios) THEN
-    IF (ok_all_xml) THEN
-  !XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
-  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-          ll=0
-          DO k=1, nlevSTD
-             bb2=clevSTD(k) 
-             IF (bb2=="850".OR.bb2=="700".OR. &
-                bb2=="500".OR.bb2=="200".OR. &
-                bb2=="100".OR. &
-                bb2=="50".OR.bb2=="10") THEN
-                ll=ll+1
-                CALL histwrite_phy(o_uSTDlevs(ll),ulevSTD(:,k))
-                CALL histwrite_phy(o_vSTDlevs(ll),vlevSTD(:,k))
-                CALL histwrite_phy(o_wSTDlevs(ll),wlevSTD(:,k))
-                CALL histwrite_phy(o_zSTDlevs(ll),philevSTD(:,k))
-                CALL histwrite_phy(o_qSTDlevs(ll),qlevSTD(:,k))
-                CALL histwrite_phy(o_tSTDlevs(ll),tlevSTD(:,k))
-             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
-          ENDDO
-    ENDIF
-  ENDIF !using_xios
-       IF (vars_defined) THEN
-          DO i=1, klon
-             IF (pctsrf(i,is_oce)>epsfra.OR. &
-                  pctsrf(i,is_sic)>epsfra) THEN
-                zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
-                     ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
-                     (pctsrf(i,is_oce)+pctsrf(i,is_sic))
-             ELSE
-                zx_tmp_fi2d(i) = 273.15
-             ENDIF
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
-
-       ! Couplage convection-couche limite
-       IF (iflag_con>=3) THEN
-          IF (iflag_coupl>=1) THEN
-             CALL histwrite_phy(o_ale_bl, ale_bl)
-             CALL histwrite_phy(o_alp_bl, alp_bl)
-          ENDIF !iflag_coupl>=1
-       ENDIF !(iflag_con.GE.3)
-       ! Wakes
-       IF (iflag_con==3) THEN
-          IF (iflag_wake>=1) THEN
-             CALL histwrite_phy(o_ale_wk, ale_wake)
-             CALL histwrite_phy(o_alp_wk, alp_wake)
-             CALL histwrite_phy(o_ale, ale)
-             CALL histwrite_phy(o_alp, alp)
-             CALL histwrite_phy(o_cin, cin)
-             CALL histwrite_phy(o_WAPE, wake_pe)
-             CALL histwrite_phy(o_wake_h, wake_h)
-             CALL histwrite_phy(o_wake_s, wake_s)
-             CALL histwrite_phy(o_wake_deltat, wake_deltat)
-             CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
-             CALL histwrite_phy(o_wake_omg, wake_omg)
-             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
-                  /pdtphys
-             CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
-             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
-             CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
-          ENDIF ! iflag_wake>=1
-          CALL histwrite_phy(o_ftd, ftd)
-          CALL histwrite_phy(o_fqd, fqd)
-       ENDIF !(iflag_con.EQ.3)
-       IF (iflag_con==3.OR.iflag_con==30) THEN
-          ! sortie RomP convection descente insaturee iflag_con=30
-          ! etendue a iflag_con=3 (jyg)
-          CALL histwrite_phy(o_Vprecip, Vprecip)
-          CALL histwrite_phy(o_wdtrainA, wdtrainA)
-          CALL histwrite_phy(o_wdtrainM, wdtrainM)
-       ENDIF !(iflag_con.EQ.3.OR.iflag_con.EQ.30)
-!!! nrlmd le 10/04/2012
-       IF (iflag_trig_bl>=1) THEN
-          CALL histwrite_phy(o_n2, n2)
-          CALL histwrite_phy(o_s2, s2)
-          CALL histwrite_phy(o_proba_notrig, proba_notrig)
-          CALL histwrite_phy(o_random_notrig, random_notrig)
-          CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
-          CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
-       ENDIF  !(iflag_trig_bl>=1)
-       IF (iflag_clos_bl>=1) THEN
-          CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
-          CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
-          CALL histwrite_phy(o_alp_bl_fluct_tke,  &
-               alp_bl_fluct_tke)
-          CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
-          CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
-       ENDIF  !(iflag_clos_bl>=1)
-!!! fin nrlmd le 10/04/2012
-       ! Output of slab ocean variables
-       IF (type_ocean=='slab ') THEN
-          CALL histwrite_phy(o_slab_qflux, slab_wfbils)
-          !CALL histwrite_phy(o_slab_bils, slab_bils)
-          IF (nslay==1) THEN
-              zx_tmp_fi2d(:)=tslab(:,1)
-              CALL histwrite_phy(o_tslab, zx_tmp_fi2d)
-          ELSE
-              CALL histwrite_phy(o_tslab, tslab)
-          ENDIF
-          IF (version_ocean=='sicINT') THEN
-              CALL histwrite_phy(o_slab_bilg, slab_bilg)
-              CALL histwrite_phy(o_slab_tice, tice)
-              CALL histwrite_phy(o_slab_sic, seaice)
-          ENDIF
-       ENDIF !type_ocean == force/slab
-       CALL histwrite_phy(o_weakinv, weak_inversion)
-       CALL histwrite_phy(o_dthmin, dthmin)
-       CALL histwrite_phy(o_cldtau, cldtau)
-       CALL histwrite_phy(o_cldemi, cldemi)
-       CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
-       CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
-       CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
-       CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
-       CALL histwrite_phy(o_re, re)
-       CALL histwrite_phy(o_fl, fl)
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-          ENDDO
-       ENDIF
-       !CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
-
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
-          ENDDO
-       ENDIF
-       !CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
-
-       CALL histwrite_phy(o_qsat2m, qsat2m)
-       CALL histwrite_phy(o_tpot, tpot)
-       CALL histwrite_phy(o_tpote, tpote)
-       IF (vars_defined) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
-       CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
-       CALL histwrite_phy(o_LWdownOR, sollwdown)
-       CALL histwrite_phy(o_snowl, snow_lsc)
-       CALL histwrite_phy(o_solldown, sollwdown)
-       CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
-       CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
-       CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
-       CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
-       CALL histwrite_phy(o_z0m, z0m(:,nbsrf+1))
-       CALL histwrite_phy(o_z0h, z0h(:,nbsrf+1))
-       ! OD550 per species
-!--OLIVIER
-!This is warranted by treating INCA aerosols as offline aerosols
-       IF (flag_aerosol>0) THEN
-          CALL histwrite_phy(o_od550aer, od550aer)
-          CALL histwrite_phy(o_od865aer, od865aer)
-          CALL histwrite_phy(o_abs550aer, abs550aer)
-          CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
-          CALL histwrite_phy(o_sconcso4, sconcso4)
-          CALL histwrite_phy(o_sconcno3, sconcno3)
-          CALL histwrite_phy(o_sconcoa, sconcoa)
-          CALL histwrite_phy(o_sconcbc, sconcbc)
-          CALL histwrite_phy(o_sconcss, sconcss)
-          CALL histwrite_phy(o_sconcdust, sconcdust)
-          CALL histwrite_phy(o_concso4, concso4)
-          CALL histwrite_phy(o_concno3, concno3)
-          CALL histwrite_phy(o_concoa, concoa)
-          CALL histwrite_phy(o_concbc, concbc)
-          CALL histwrite_phy(o_concss, concss)
-          CALL histwrite_phy(o_concdust, concdust)
-          CALL histwrite_phy(o_loadso4, loadso4)
-          CALL histwrite_phy(o_loadoa, loadoa)
-          CALL histwrite_phy(o_loadbc, loadbc)
-          CALL histwrite_phy(o_loadss, loadss)
-          CALL histwrite_phy(o_loaddust, loaddust)
-          !--STRAT AER
-       ENDIF
-       IF (flag_aerosol>0.OR.flag_aerosol_strat>=1) THEN
-!          DO naero = 1, naero_spc
-!--correction mini bug OB
-          DO naero = 1, naero_tot
-             CALL histwrite_phy(o_tausumaero(naero), &
-                  tausum_aero(:,2,naero) )
-          ENDDO
-       ENDIF
-       IF (flag_aerosol_strat>=1) THEN
-          CALL histwrite_phy(o_tausumaero_lw, &
-               tausum_aero(:,6,id_STRAT_phy) )
-       ENDIF
-       IF (ok_ade) THEN
-          CALL histwrite_phy(o_topswad, topswad_aero)
-          CALL histwrite_phy(o_topswad0, topswad0_aero)
-          CALL histwrite_phy(o_solswad, solswad_aero)
-          CALL histwrite_phy(o_solswad0, solswad0_aero)
-          CALL histwrite_phy(o_toplwad, toplwad_aero)
-          CALL histwrite_phy(o_toplwad0, toplwad0_aero)
-          CALL histwrite_phy(o_sollwad, sollwad_aero)
-          CALL histwrite_phy(o_sollwad0, sollwad0_aero)
-          !====MS forcing diagnostics
-          CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:,1))
-          CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:,1))
-          CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:,1))
-          CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:,1))
-          !ant
-          CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:,2))
-          CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:,2))
-          CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:,2))
-          CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:,2))
-          !cf
-          IF (.NOT. aerosol_couple) THEN
-             CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:,1))
-             CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:,1))
-             CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:,2))
-             CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:,2))
-             CALL histwrite_phy(o_swtoacf_zero,topswcf_aero(:,3))
-             CALL histwrite_phy(o_swsrfcf_zero,solswcf_aero(:,3))
-          ENDIF
-          !====MS forcing diagnostics
-       ENDIF
-       IF (ok_aie) THEN
-          CALL histwrite_phy(o_topswai, topswai_aero)
-          CALL histwrite_phy(o_solswai, solswai_aero)
-       ENDIF
-       IF (flag_aerosol>0.AND.ok_cdnc) THEN
-          CALL histwrite_phy(o_scdnc, scdnc)
-          CALL histwrite_phy(o_cldncl, cldncl)
-          CALL histwrite_phy(o_reffclws, reffclws)
-          CALL histwrite_phy(o_reffclwc, reffclwc)
-          CALL histwrite_phy(o_cldnvi, cldnvi)
-          CALL histwrite_phy(o_lcc, lcc)
-          CALL histwrite_phy(o_lcc3d, lcc3d)
-          CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
-          CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
-          CALL histwrite_phy(o_reffclwtop, reffclwtop)
-       ENDIF
-       ! Champs 3D:
-       IF (ok_ade .OR. ok_aie) THEN
-          CALL histwrite_phy(o_ec550aer, ec550aer)
-       ENDIF
-       CALL histwrite_phy(o_lwcon, flwc)
-       CALL histwrite_phy(o_iwcon, fiwc)
-       CALL histwrite_phy(o_temp, t_seri)
-       CALL histwrite_phy(o_theta, theta)
-       CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
-       CALL histwrite_phy(o_ovap, q_seri)
-       CALL histwrite_phy(o_oliq, ql_seri)
-       CALL histwrite_phy(o_geop, zphi)
-       CALL histwrite_phy(o_vitu, u_seri)
-       CALL histwrite_phy(o_vitv, v_seri)
-       CALL histwrite_phy(o_vitw, omega)
-       CALL histwrite_phy(o_pres, pplay)
-       CALL histwrite_phy(o_paprs, paprs(:,1:klev))
-       IF (vars_defined) THEN
-          DO i=1, klon
-             zx_tmp_fi3d1(i,1)= pphis(i)/RG
-             !020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
-          ENDDO
-          DO k=1, klev
-             !020611        DO k=1, klev-1
-             DO i=1, klon
-                !020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD * 
-                zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD *  &
-                     (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG ) 
-             ENDDO
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_zfull,zx_tmp_fi3d1(:,2:klevp1))
-       !020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
-
-       IF (vars_defined)  THEN
-          DO i=1, klon
-             zx_tmp_fi3d(i,1)= pphis(i)/RG - ( &
-                  (t_seri(i,1)+zxtsol(i))/2. *RD * &
-                  (pplay(i,1) - paprs(i,1)))/( (paprs(i,1)+pplay(i,1))/2.* RG)
-          ENDDO
-          DO k=1, klev-1
-             DO i=1, klon
-                zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - ( &
-                     (t_seri(i,k)+t_seri(i,k+1))/2. *RD *  &
-                     (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG ) 
-             ENDDO
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
-       CALL histwrite_phy(o_rneb, cldfra)
-       CALL histwrite_phy(o_rnebcon, rnebcon)
-       CALL histwrite_phy(o_rnebls, rneb)
-       IF (vars_defined)  THEN
-          DO k=1, klev
-             DO i=1, klon
-                zx_tmp_fi3d(i,k)=cldfra(i,k)*JrNt(i)
-             ENDDO
-          ENDDO
-       ENDIF
-       CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
-       CALL histwrite_phy(o_rhum, zx_rh)
-       !CALL histwrite_phy(o_ozone, &
-       !     wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
-       IF (vars_defined) zx_tmp_fi3d = wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd
-       CALL histwrite_phy(o_ozone, zx_tmp_fi3d)
-
-       IF (read_climoz == 2) THEN
-         !CALL histwrite_phy(o_ozone_light, &
-         !     wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
-         IF (vars_defined) zx_tmp_fi3d = wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd
-         CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
-       ENDIF
-
-       !AS: dans phys_output_write il y a en plus : CALL histwrite_phy(o_duphy, d_u) 
-       CALL histwrite_phy(o_dtphy, d_t)
-       CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
-       DO nsrf=1, nbsrf
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
-          CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0m( 1 : klon, nsrf)
-          CALL histwrite_phy(o_z0m_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0h( 1 : klon, nsrf)
-          CALL histwrite_phy(o_z0h_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
-          CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = snow( 1 : klon, nsrf)
-          CALL histwrite_phy(o_snow_srf(nsrf), zx_tmp_fi2d)
-       ENDDO !nsrf=1, nbsrf
-       CALL histwrite_phy(o_alb1, albsol1)
-       CALL histwrite_phy(o_alb2, albsol2)
-       !FH Sorties pour la couche limite
-       IF (iflag_pbl>1) THEN
-          zx_tmp_fi3d=0.
-          IF (vars_defined) THEN
-             DO nsrf=1,nbsrf
-                DO k=1,klev
-                   zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
-                        +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
-                enddo
-             enddo
-          ENDIF
-          CALL histwrite_phy(o_tke, zx_tmp_fi3d)
-
-          CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
-       ENDIF
-
-       CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
-
-       CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
-
-       CALL histwrite_phy(o_clwcon, clwcon0)
-       CALL histwrite_phy(o_dtdyn, d_t_dyn)
-       CALL histwrite_phy(o_dqdyn, d_q_dyn)
-       CALL histwrite_phy(o_dudyn, d_u_dyn)
-       CALL histwrite_phy(o_dvdyn, d_v_dyn)
-
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
-       IF (iflag_thermals==0)THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
-                  d_t_ajsb(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-       ELSEIF (iflag_thermals>=1.AND.iflag_wake==1)THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
-                  d_t_ajs(1:klon,1:klev)/pdtphys + &
-                  d_t_wake(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
-       ENDIF
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
-
-       IF (iflag_thermals==0) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-       ELSEIF (iflag_thermals>=1.AND.iflag_wake==1) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
-                  d_q_ajs(1:klon,1:klev)/pdtphys + &
-                  d_q_wake(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
-       ENDIF
-
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
-            d_t_eva(1:klon,1:klev))/pdtphys
-       CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
-       CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       ! Sorties specifiques a la separation thermiques/non thermiques
-       IF (iflag_thermals>=1) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
-          CALL histwrite_phy(o_plulth, plul_th)
-          CALL histwrite_phy(o_plulst, plul_st)
-          IF (vars_defined) THEN
-             DO k=1,klev
-                DO i=1,klon
-                   IF (ptconvth(i,k)) THEN
-                      zx_tmp_fi3d(i,k)=1.
-                   ELSE
-                      zx_tmp_fi3d(i,k)=0.
-                   ENDIF
-                enddo
-             enddo
-          ENDIF
-          CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
-          IF (vars_defined) THEN
-             DO i=1,klon
-                zx_tmp_fi2d(1:klon)=lmax_th(:)
-             enddo
-          ENDIF
-          CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
-       ENDIF ! iflag_thermals>=1
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
-       zpt_conv = 0.
-       WHERE (ptconv) zpt_conv = 1.
-       CALL histwrite_phy(o_ptconv, zpt_conv)
-       CALL histwrite_phy(o_ratqs, ratqs)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
-               d_t_ajsb(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_u_ajs(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_duthe, zx_tmp_fi3d) 
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_v_ajs(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
-
-       IF (iflag_thermals>=1) THEN
-          ! Pour l instant 0 a y reflichir pour les thermiques
-          zx_tmp_fi2d=0. 
-          CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
-          CALL histwrite_phy(o_f_th, fm_therm)
-          CALL histwrite_phy(o_e_th, entr_therm)
-          CALL histwrite_phy(o_w_th, zw2)
-          CALL histwrite_phy(o_q_th, zqasc)
-          CALL histwrite_phy(o_a_th, fraca)
-          CALL histwrite_phy(o_d_th, detr_therm)
-          CALL histwrite_phy(o_f0_th, f0)
-          CALL histwrite_phy(o_zmax_th, zmax_th)
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
-                  d_q_ajsb(1:klon,1:klev)/pdtphys
-          ENDIF
-          CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
-       ENDIF !iflag_thermals
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_sw0(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lwr(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lw0(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
-       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
-       CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
-       IF (ok_orodr) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
-       ENDIF
-       IF (ok_orolf) THEN
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_lIF (1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
-
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_lIF (1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
-
-          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lIF (1:klon,1:klev)/pdtphys
-          CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
-       ENDIF
-
-!      IF (ok_hines) THEN
-!         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
-!         CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
-!         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
-!         CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
-!         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
-!         CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
-!      ENDIF
-
-!      IF (ok_gwd_rando) THEN
-!         CALL histwrite_phy(o_du_gwd_rando, du_gwd_ranDO / pdtphys)
-!         CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_ranDO / pdtphys)
-!         CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
-!      ENDIF
-
-       IF (ok_qch4) THEN
-          CALL histwrite_phy(o_dqch4, d_q_ch4 / pdtphys)
-       ENDIF
-
-       CALL histwrite_phy(o_rsu, swup)
-       CALL histwrite_phy(o_rsd, swdn)
-       CALL histwrite_phy(o_rlu, lwup)
-       CALL histwrite_phy(o_rld, lwdn)
-       CALL histwrite_phy(o_rsucs, swup0)
-       CALL histwrite_phy(o_rsdcs, swdn0)
-       CALL histwrite_phy(o_rlucs, lwup0)
-       CALL histwrite_phy(o_rldcs, lwdn0)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
-               d_t_dyn(1:klon,1:klev)
-       ENDIF
-       CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys + &
-               d_t_lwr(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
-               d_t_eva(1:klon,1:klev)+ &
-               d_t_vdf(1:klon,1:klev))/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
-               d_q_dyn(1:klon,1:klev)
-       ENDIF
-       CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
-               d_q_eva(1:klon,1:klev)/pdtphys
-       ENDIF
-       CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
-       CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
-       IF (vars_defined) THEN
-          zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
-               ql_seri(1:klon,1:klev) 
-       ENDIF
-       CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
-       IF (iflag_con >= 3) THEN
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
-                  dnwd0(1:klon,1:klev)) 
-          ENDIF
-          CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
-          IF (vars_defined) THEN
-             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
-                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
-          ENDIF
-          CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
-       ELSEIF (iflag_con == 2) THEN
-          CALL histwrite_phy(o_mcd,  pmfd)
-          CALL histwrite_phy(o_dmc,  pmfu + pmfd)
-       ENDIF
-       CALL histwrite_phy(o_ref_liq, ref_liq)
-       CALL histwrite_phy(o_ref_ice, ref_ice)
-       IF (RCO2_per/=RCO2_act.OR.RCH4_per/=RCH4_act.OR. &
-            RN2O_per/=RN2O_act.OR.RCFC11_per/=RCFC11_act.OR. &
-            RCFC12_per/=RCFC12_act) THEN
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
-          CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
-          CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
-          CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
-          IF (vars_defined) zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
-          CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
-          CALL histwrite_phy(o_rsu4co2, swupp)
-          CALL histwrite_phy(o_rlu4co2, lwupp)
-          CALL histwrite_phy(o_rsucs4co2, swup0p)
-          CALL histwrite_phy(o_rlucs4co2, lwup0p)
-          CALL histwrite_phy(o_rsd4co2, swdnp)
-          CALL histwrite_phy(o_rld4co2, lwdnp)
-          CALL histwrite_phy(o_rsdcs4co2, swdn0p)
-          CALL histwrite_phy(o_rldcs4co2, lwdn0p)
-       ENDIF
-!!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
-
-  IF (.NOT. using_xios) THEN
-    IF (.NOT.ok_all_xml) THEN
-         ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
-         ! Champs interpolles sur des niveaux de pression
-       DO iff=7, nfiles-1 !--here we deal with files 7,8 and 9
-
-          CALL histwrite_phy(o_tnondef,tnondef(:,:,iff-6),iff)
-          CALL histwrite_phy(o_ta,twriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_zg,phiwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_hus,qwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_hur,rhwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_ua,uwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_va,vwriteSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wap,wwriteSTD(:,:,iff-6),iff)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (tnondef(i,k,iff-6).NE.missing_val) THEN
-                      IF (freq_outNMC(iff-6).LT.0) THEN
-                         freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
-                      ELSE
-                         freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
-                      ENDIF
-                      zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,iff-6))/freq_moyNMC(iff-6)
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO
-          ENDIF
-          CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD,iff)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (O3sumSTD(i,k,iff-6).NE.missing_val) THEN
-                      zx_tmp_fi3d_STD(i,k) = O3sumSTD(i,k,iff-6) * 1.e+9
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO !k=1, nlevSTD
-          ENDIF
-          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD,iff)
-          IF (read_climoz == 2) THEN
-             IF (vars_defined) THEN
-                DO k=1, nlevSTD
-                   DO i=1, klon
-                      IF (O3daysumSTD(i,k,iff-6).NE.missing_val) THEN
-                         zx_tmp_fi3d_STD(i,k) = O3daysumSTD(i,k,iff-6) * 1.e+9
-                      ELSE
-                         zx_tmp_fi3d_STD(i,k) = missing_val
-                      ENDIF
-                   ENDDO
-                ENDDO !k=1, nlevSTD
-             ENDIF
-             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD,iff)
-          ENDIF
-          CALL histwrite_phy(o_uxv,uvsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxq,vqsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxT,vTsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wxq,wqsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxphi,vphisumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_wxT,wTsumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_uxu,u2sumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_vxv,v2sumSTD(:,:,iff-6),iff)
-          CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
-       ENDDO !nfiles
-    ENDIF
-  ENDIF
-
-IF (using_xios) THEN
-  IF (ok_all_xml) THEN 
-!      DO iff=7, nfiles
-
-!         CALL histwrite_phy(o_tnondef,tnondef(:,:,3))
-          CALL histwrite_phy(o_ta,tlevSTD(:,:))
-          CALL histwrite_phy(o_zg,philevSTD(:,:))
-          CALL histwrite_phy(o_hus,qlevSTD(:,:))
-          CALL histwrite_phy(o_hur,rhlevSTD(:,:))
-          CALL histwrite_phy(o_ua,ulevSTD(:,:))
-          CALL histwrite_phy(o_va,vlevSTD(:,:))
-          CALL histwrite_phy(o_wap,wlevSTD(:,:))
-!         IF (vars_defined) THEN
-!            DO k=1, nlevSTD
-!               DO i=1, klon
-!                  IF (tnondef(i,k,3).NE.missing_val) THEN
-!                     IF (freq_outNMC(iff-6).LT.0) THEN
-!                        freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
-!                     ELSE
-!                        freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
-!                     ENDIF
-!                     zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(iff-6)
-!                  ELSE
-!                     zx_tmp_fi3d_STD(i,k) = missing_val
-!                  ENDIF
-!               ENDDO
-!            ENDDO
-!         ENDIF
-!         CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD)
-          IF (vars_defined) THEN
-             DO k=1, nlevSTD
-                DO i=1, klon
-                   IF (O3STD(i,k)/=missing_val) THEN
-                      zx_tmp_fi3d_STD(i,k) = O3STD(i,k) * 1.e+9
-                   ELSE
-                      zx_tmp_fi3d_STD(i,k) = missing_val
-                   ENDIF
-                ENDDO
-             ENDDO !k=1, nlevSTD
-          ENDIF
-          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD)
-          IF (read_climoz == 2) THEN
-             IF (vars_defined) THEN
-                DO k=1, nlevSTD
-                   DO i=1, klon
-                      IF (O3daySTD(i,k)/=missing_val) THEN
-                         zx_tmp_fi3d_STD(i,k) = O3daySTD(i,k) * 1.e+9
-                      ELSE
-                         zx_tmp_fi3d_STD(i,k) = missing_val
-                      ENDIF
-                   ENDDO
-                ENDDO !k=1, nlevSTD
-             ENDIF
-             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD)
-          ENDIF
-          CALL histwrite_phy(o_uxv,uvSTD(:,:))
-          CALL histwrite_phy(o_vxq,vqSTD(:,:))
-          CALL histwrite_phy(o_vxT,vTSTD(:,:))
-          CALL histwrite_phy(o_wxq,wqSTD(:,:))
-          CALL histwrite_phy(o_vxphi,vphiSTD(:,:))
-          CALL histwrite_phy(o_wxT,wTSTD(:,:))
-          CALL histwrite_phy(o_uxu,u2STD(:,:))
-          CALL histwrite_phy(o_vxv,v2STD(:,:))
-          CALL histwrite_phy(o_TxT,T2STD(:,:))
-!      ENDDO !nfiles
-    ENDIF
-  ENDIF !using_xios
-!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-           itr = 0
-           DO iq = 1, nqtot
-             IF(.NOT.tracers(iq)%isInPhysics) CYCLE
-             itr = itr+1
-             CALL histwrite_phy(o_trac(itr), tr_seri(:,:,itr))
-             CALL histwrite_phy(o_dtr_vdf(itr),d_tr_cl(:,:,itr))
-             CALL histwrite_phy(o_dtr_the(itr),d_tr_th(:,:,itr))
-             CALL histwrite_phy(o_dtr_con(itr),d_tr_cv(:,:,itr))
-             CALL histwrite_phy(o_dtr_lessi_impa(itr),d_tr_lessi_impa(:,:,itr))
-             CALL histwrite_phy(o_dtr_lessi_nucl(itr),d_tr_lessi_nucl(:,:,itr))
-             CALL histwrite_phy(o_dtr_insc(itr),d_tr_insc(:,:,itr))
-             CALL histwrite_phy(o_dtr_bcscav(itr),d_tr_bcscav(:,:,itr))
-             CALL histwrite_phy(o_dtr_evapls(itr),d_tr_evapls(:,:,itr))
-             CALL histwrite_phy(o_dtr_ls(itr),d_tr_ls(:,:,itr))
-!            CALL histwrite_phy(o_dtr_dyn(itr),d_tr_dyn(:,:,itr))
-!            CALL histwrite_phy(o_dtr_cl(itr),d_tr_cl(:,:,itr))
-             CALL histwrite_phy(o_dtr_trsp(itr),d_tr_trsp(:,:,itr))
-             CALL histwrite_phy(o_dtr_sscav(itr),d_tr_sscav(:,:,itr))
-             CALL histwrite_phy(o_dtr_sat(itr),d_tr_sat(:,:,itr))
-             CALL histwrite_phy(o_dtr_uscav(itr),d_tr_uscav(:,:,itr))
-             zx_tmp_fi2d=0.
-             IF (vars_defined) THEN
-                DO k=1,klev
-                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,itr)
-                ENDDO
-             ENDIF
-             CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
-           ENDDO
-
-       IF (.NOT.vars_defined) THEN
-          !$OMP MASTER
-#ifndef CPP_IOIPSL_NO_OUTPUT 
-          DO iff=1,nfiles
-             IF (clef_files(iff)) THEN
-                CALL histend(nid_files(iff))
-                ndex2d = 0
-                ndex3d = 0
-
-             ENDIF ! clef_files
-          ENDDO !  iff
+          !           CALL xios_update_calendar(itau_w)
+          CALL xios_update_calendar(itap)
+        ENDIF
+        !$OMP END MASTER
+        !$OMP BARRIER
+      ENDIF !using_xios
+
+      ! On procède à l'écriture ou à la définition des nombreuses variables:
+      !!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      CALL histwrite_phy(o_phis, pphis)
+      CALL histwrite_phy(o_aire, cell_area)
+
+      IF (vars_defined) THEN
+        DO i = 1, klon
+          zx_tmp_fi2d(i) = pctsrf(i, is_ter) + pctsrf(i, is_lic)
+        ENDDO
+      ENDIF
+
+      CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
+      CALL histwrite_phy(o_contfracOR, pctsrf(:, is_ter))
+      CALL histwrite_phy(o_aireTER, paire_ter)
+
+      !!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+      ! JE20141223 <<
+      INCLUDE "spla_output_write.h"
+                                                                                                                                                                                                                                                                                                                          ! JE20141223 >>
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_flat, zxfluxlat)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_slp, slp)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tsol, zxtsol)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t2m, zt2m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t2m_min, zt2m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t2m_max, zt2m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t2m_max_mon, t2m_max_mon)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t2m_min_mon, t2m_min_mon)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = SQRT(zu10m(i) * zu10m(i) + zv10m(i) * zv10m(i))
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = SQRT(zu10m(i) * zu10m(i) + zv10m(i) * zv10m(i))
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_gusts, gustiness)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = pctsrf(i, is_sic)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_q2m, zq2m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ustar, zustar)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_u10m, zu10m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_v10m, zv10m)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = paprs(i, 1)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_psol, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_mass, zmasse)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_qsurf, zxqsurf)
+
+                                                                                                                                                                                                                                                                                                                          IF (.NOT. ok_veget) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_qsol, qsol)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_precip, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ndayrain, nday_rain)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_plul, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_snow, snow_fall)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_msnow, zxsnow)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_fsnow, zfra_o)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_evap, evap)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tops, topsw)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tops0, topsw0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_topl, toplw)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_topl0, toplw0)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swup (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swup0 (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swdn (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swdn0 (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(:) = topsw(:) - toplw(:)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWup200, SWup200)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWup200clr, SWup200clr)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdn200, SWdn200)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWup200, LWup200)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWup200clr, LWup200clr)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWdn200, LWdn200)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_sols, solsw)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_sols0, solsw0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_soll, sollw)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_radsol, radsol)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_soll0, sollw0)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swup (1:klon, 1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swup0 (1:klon, 1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swdn (1:klon, 1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = swdn0 (1:klon, 1)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = sollwdown(1:klon) - sollw(1:klon)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWdnSFC, sollwdown)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            sollwdownclr(1:klon) = -1. * lwdn0(1:klon, 1)
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = sollwdownclr(1:klon) - sollw0(1:klon)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils, bils)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_diss, bils_diss)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_ec, bils_ec)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_ener_conserv>=1) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_bils_ech, bils_ech)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_tke, bils_tke)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_latent, bils_latent)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d(1:klon) = -1 * sens(1:klon)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_sens, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_fder, fder)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ffonte, zxffonte)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_fqcalving, zxfqcalving)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_fqfonte, zxfqfonte)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d = 0.
+                                                                                                                                                                                                                                                                                                                            DO nsrf = 1, nbsrf
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf) * fluxu(:, 1, nsrf)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_taux, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d = 0.
+                                                                                                                                                                                                                                                                                                                            DO nsrf = 1, nbsrf
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(:) = zx_tmp_fi2d(:) + pctsrf(:, nsrf) * fluxv(:, 1, nsrf)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (landice_opt >= 1) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_snowsrf, snow_o)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_qsnow, qsnow)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_snowhgt, snowhgt)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_toice, to_ice)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sissnow, sissnow)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_runoff, runoff)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_albslw3, albsol3_lic)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          DO nsrf = 1, nbsrf
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)             zx_tmp_fi2d(1:klon) = pctsrf(1:klon, nsrf) * 100.
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)           zx_tmp_fi2d(1:klon) = pctsrf(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = fluxu(1:klon, 1, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = fluxv(1:klon, 1, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = ftsol(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = evap_pot(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)       zx_tmp_fi2d(1:klon) = ustar(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)       zx_tmp_fi2d(1:klon) = u10m(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)       zx_tmp_fi2d(1:klon) = v10m(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)       zx_tmp_fi2d(1:klon) = t2m(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)       zx_tmp_fi2d(1:klon) = fevap(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)        zx_tmp_fi2d(1:klon) = fluxt(1:klon, 1, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = fluxlat(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = fsollw(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = fsolsw(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d(1:klon) = wfbils(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                            IF (iflag_pbl > 1) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_tke_srf(nsrf), pbl_tke(:, 1:klev, nsrf))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_tke_max_srf(nsrf), pbl_tke(:, 1:klev, nsrf))
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            !jyg<
+                                                                                                                                                                                                                                                                                                                            IF (iflag_pbl > 1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_dltpbltke_srf(nsrf), wake_delta_pbl_TKE(:, 1:klev, nsrf))
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            !>jyg
+
+                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                          DO nsrf = 1, nbsrf + 1
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_wstar(nsrf), wstar(1:klon, nsrf))
+                                                                                                                                                                                                                                                                                                                          ENDDO
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cdrm, cdragm)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cdrh, cdragh)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldl, cldl)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldm, cldm)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldh, cldh)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldt, cldt)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_JrNt, JrNt)
+
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_cldljn, cldl*JrNt)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  zx_tmp_fi2d = cldl * JrNt
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldljn, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_cldmjn, cldm*JrNt)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  zx_tmp_fi2d = cldm * JrNt
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldmjn, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_cldhjn, cldh*JrNt)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  zx_tmp_fi2d = cldh * JrNt
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldhjn, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_cldtjn, cldt*JrNt)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  zx_tmp_fi2d = cldt * JrNt
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldtjn, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldq, cldq)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ue, ue)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ve, ve)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_uq, uq)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vq, vq)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_con>=3) THEN ! sb
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_cape, cape)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_pbase, ema_pcb)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ptop, ema_pct)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_fbase, ema_cbmf)
+                                                                                                                                                                                                                                                                                                                            IF (iflag_con /= 30) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_plcl, plcl)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_plfc, plfc)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wbeff, wbeff)
+                                                                                                                                                                                                                                                                                                                            ENDIF
+
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_cape_max, cape)
+
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_upwd, upwd)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_Ma, Ma)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dnwd, dnwd)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dnwd0, dnwd0)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined)         zx_tmp_fi2d = float(itau_con) / float(itap)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              IF (iflag_thermals>=1)THEN
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi3d = dnwd + dnwd0 + upwd + fm_therm(:, 1:klev)
+                                                                                                                                                                                                                                                                                                                              ELSE
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi3d = dnwd + dnwd0 + upwd
+                                                                                                                                                                                                                                                                                                                              ENDIF
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_mc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF !iflag_con .GE. 3
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_prw, prw)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_s_pblh, s_pblh)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_s_pblt, s_pblt)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_s_lcl, s_lcl)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_s_therm, s_therm)
+                                                                                                                                                                                                                                                                                                                          !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_capCL%name,itau_w,s_capCL)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_oliqCL%name,itau_w,s_oliqCL)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_cteiCL%name,itau_w,s_cteiCL)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_trmb1%name,itau_w,s_trmb1)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_trmb2%name,itau_w,s_trmb2)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+                                                                                                                                                                                                                                                                                                                          !       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                          !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
+                                                                                                                                                                                                                                                                                                                          !    $o_s_trmb3%name,itau_w,s_trmb3)
+                                                                                                                                                                                                                                                                                                                          !       ENDIF
+
+                                                                                                                                                                                                                                                                                                                          IF (.NOT. using_xios) THEN
+                                                                                                                                                                                                                                                                                                                            IF (.NOT.ok_all_xml) THEN
+                                                                                                                                                                                                                                                                                                                              ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
+                                                                                                                                                                                                                                                                                                                              ! Champs interpolles sur des niveaux de pression
+                                                                                                                                                                                                                                                                                                                              DO iff = 1, nfiles
+                                                                                                                                                                                                                                                                                                                                ll = 0
+                                                                                                                                                                                                                                                                                                                                DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                  bb2 = clevSTD(k)
+                                                                                                                                                                                                                                                                                                                                  IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
+                                                                                                                                                                                                                                                                                                                                          bb2.EQ."500".OR.bb2.EQ."200".OR. &
+                                                                                                                                                                                                                                                                                                                                          bb2.EQ."100".OR. &
+                                                                                                                                                                                                                                                                                                                                          bb2.EQ."50".OR.bb2.EQ."10") THEN
+
+                                                                                                                                                                                                                                                                                                                                    ! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                                                                                                                                                                                                                                                                                                                    ll = ll + 1
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_uSTDlevs(ll), uwriteSTD(:, k,iff), iff)
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_vSTDlevs(ll), vwriteSTD(:, k,iff), iff)
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_wSTDlevs(ll), wwriteSTD(:, k,iff), iff)
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_zSTDlevs(ll), phiwriteSTD(:, k,iff), iff)
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_qSTDlevs(ll), qwriteSTD(:, k,iff), iff)
+                                                                                                                                                                                                                                                                                                                                    CALL histwrite_phy(o_tSTDlevs(ll), twriteSTD(:, k,iff), iff)
+
+                                                                                                                                                                                                                                                                                                                                  ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+                                                                                                                                                                                                                                                                                                                                ENDDO
+                                                                                                                                                                                                                                                                                                                              ENDDO
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                          ENDIF !.NOT.using_xios
+
+                                                                                                                                                                                                                                                                                                                          IF (using_xios) THEN
+                                                                                                                                                                                                                                                                                                                            IF (ok_all_xml) THEN
+                                                                                                                                                                                                                                                                                                                              !XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
+                                                                                                                                                                                                                                                                                                                              !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                                                                                                                                                                                                                                                                                                              ll = 0
+                                                                                                                                                                                                                                                                                                                              DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                bb2 = clevSTD(k)
+                                                                                                                                                                                                                                                                                                                                IF (bb2=="850".OR.bb2=="700".OR. &
+                                                                                                                                                                                                                                                                                                                                        bb2=="500".OR.bb2=="200".OR. &
+                                                                                                                                                                                                                                                                                                                                        bb2=="100".OR. &
+                                                                                                                                                                                                                                                                                                                                        bb2=="50".OR.bb2=="10") THEN
+                                                                                                                                                                                                                                                                                                                                  ll = ll + 1
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_uSTDlevs(ll), ulevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_vSTDlevs(ll), vlevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_wSTDlevs(ll), wlevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_zSTDlevs(ll), philevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_qSTDlevs(ll), qlevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                  CALL histwrite_phy(o_tSTDlevs(ll), tlevSTD(:, k))
+                                                                                                                                                                                                                                                                                                                                ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
+                                                                                                                                                                                                                                                                                                                              ENDDO
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                          ENDIF !using_xios
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              IF (pctsrf(i, is_oce)>epsfra.OR. &
+                                                                                                                                                                                                                                                                                                                                      pctsrf(i, is_sic)>epsfra) THEN
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i, is_oce) + &
+                                                                                                                                                                                                                                                                                                                                        ftsol(i, is_sic) * pctsrf(i, is_sic)) / &
+                                                                                                                                                                                                                                                                                                                                        (pctsrf(i, is_oce) + pctsrf(i, is_sic))
+                                                                                                                                                                                                                                                                                                                              ELSE
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi2d(i) = 273.15
+                                                                                                                                                                                                                                                                                                                              ENDIF
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          ! Couplage convection-couche limite
+                                                                                                                                                                                                                                                                                                                          IF (iflag_con>=3) THEN
+                                                                                                                                                                                                                                                                                                                            IF (iflag_coupl>=1) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_ale_bl, ale_bl)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_alp_bl, alp_bl)
+                                                                                                                                                                                                                                                                                                                            ENDIF !iflag_coupl>=1
+                                                                                                                                                                                                                                                                                                                          ENDIF !(iflag_con.GE.3)
+                                                                                                                                                                                                                                                                                                                          ! Wakes
+                                                                                                                                                                                                                                                                                                                          IF (iflag_con==3) THEN
+                                                                                                                                                                                                                                                                                                                            IF (iflag_wake>=1) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_ale_wk, ale_wake)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_alp_wk, alp_wake)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_ale, ale)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_alp, alp)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_cin, cin)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_WAPE, wake_pe)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wake_h, wake_h)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wake_s, wake_s)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wake_deltat, wake_deltat)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_wake_omg, wake_omg)
+                                                                                                                                                                                                                                                                                                                              IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_wake(1:klon, 1:klev) &
+                                                                                                                                                                                                                                                                                                                                      / pdtphys
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                              IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_wake(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            ENDIF ! iflag_wake>=1
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ftd, ftd)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_fqd, fqd)
+                                                                                                                                                                                                                                                                                                                          ENDIF !(iflag_con.EQ.3)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_con==3.OR.iflag_con==30) THEN
+                                                                                                                                                                                                                                                                                                                            ! sortie RomP convection descente insaturee iflag_con=30
+                                                                                                                                                                                                                                                                                                                            ! etendue a iflag_con=3 (jyg)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_Vprecip, Vprecip)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_wdtrainA, wdtrainA)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_wdtrainM, wdtrainM)
+                                                                                                                                                                                                                                                                                                                          ENDIF !(iflag_con.EQ.3.OR.iflag_con.EQ.30)
+                                                                                                                                                                                                                                                                                                                          !!! nrlmd le 10/04/2012
+                                                                                                                                                                                                                                                                                                                          IF (iflag_trig_bl>=1) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_n2, n2)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_s2, s2)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_proba_notrig, proba_notrig)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_random_notrig, random_notrig)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
+                                                                                                                                                                                                                                                                                                                          ENDIF  !(iflag_trig_bl>=1)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_clos_bl>=1) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_alp_bl_fluct_tke, &
+                                                                                                                                                                                                                                                                                                                                    alp_bl_fluct_tke)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
+                                                                                                                                                                                                                                                                                                                          ENDIF  !(iflag_clos_bl>=1)
+                                                                                                                                                                                                                                                                                                                          !!! fin nrlmd le 10/04/2012
+                                                                                                                                                                                                                                                                                                                          ! Output of slab ocean variables
+                                                                                                                                                                                                                                                                                                                          IF (type_ocean=='slab ') THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_slab_qflux, slab_wfbils)
+                                                                                                                                                                                                                                                                                                                            !CALL histwrite_phy(o_slab_bils, slab_bils)
+                                                                                                                                                                                                                                                                                                                            IF (nslay==1) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(:) = tslab(:, 1)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_tslab, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            ELSE
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_tslab, tslab)
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            IF (version_ocean=='sicINT') THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_slab_bilg, slab_bilg)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_slab_tice, tice)
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_slab_sic, seaice)
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                          ENDIF !type_ocean == force/slab
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_weakinv, weak_inversion)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dthmin, dthmin)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldtau, cldtau)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_cldemi, cldemi)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pr_con_l, pmflxr(:, 1:klev))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pr_con_i, pmflxs(:, 1:klev))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pr_lsc_l, prfl(:, 1:klev))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pr_lsc_i, psfl(:, 1:klev))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_re, re)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_fl, fl)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = MIN(100., rh2m(i) * 100.)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = MIN(100., rh2m(i) * 100.)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi2d(i) = MIN(100., rh2m(i) * 100.)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_qsat2m, qsat2m)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tpot, tpot)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tpote, tpote)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi2d(1:klon) = fsolsw(1:klon, is_ter)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_SWnetOR, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_LWdownOR, sollwdown)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_snowl, snow_lsc)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_solldown, sollwdown)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtsvdfo, d_ts(:, is_oce))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtsvdft, d_ts(:, is_ter))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtsvdfg, d_ts(:, is_lic))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtsvdfi, d_ts(:, is_sic))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_z0m, z0m(:, nbsrf + 1))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_z0h, z0h(:, nbsrf + 1))
+                                                                                                                                                                                                                                                                                                                          ! OD550 per species
+                                                                                                                                                                                                                                                                                                                          !--OLIVIER
+                                                                                                                                                                                                                                                                                                                          !This is warranted by treating INCA aerosols as offline aerosols
+                                                                                                                                                                                                                                                                                                                          IF (flag_aerosol>0) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_od550aer, od550aer)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_od865aer, od865aer)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_abs550aer, abs550aer)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcso4, sconcso4)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcno3, sconcno3)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcoa, sconcoa)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcbc, sconcbc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcss, sconcss)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sconcdust, sconcdust)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concso4, concso4)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concno3, concno3)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concoa, concoa)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concbc, concbc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concss, concss)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_concdust, concdust)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_loadso4, loadso4)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_loadoa, loadoa)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_loadbc, loadbc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_loadss, loadss)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_loaddust, loaddust)
+                                                                                                                                                                                                                                                                                                                            !--STRAT AER
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (flag_aerosol>0.OR.flag_aerosol_strat>=1) THEN
+                                                                                                                                                                                                                                                                                                                            !          DO naero = 1, naero_spc
+                                                                                                                                                                                                                                                                                                                            !--correction mini bug OB
+                                                                                                                                                                                                                                                                                                                            DO naero = 1, naero_tot
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_tausumaero(naero), &
+                                                                                                                                                                                                                                                                                                                                      tausum_aero(:, 2, naero))
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (flag_aerosol_strat>=1) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tausumaero_lw, &
+                                                                                                                                                                                                                                                                                                                                    tausum_aero(:, 6, id_STRAT_phy))
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (ok_ade) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_topswad, topswad_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_topswad0, topswad0_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_solswad, solswad_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_solswad0, solswad0_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_toplwad, toplwad_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_toplwad0, toplwad0_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sollwad, sollwad_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_sollwad0, sollwad0_aero)
+                                                                                                                                                                                                                                                                                                                            !====MS forcing diagnostics
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                            !ant
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                            !cf
+                                                                                                                                                                                                                                                                                                                            IF (.NOT. aerosol_couple) THEN
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:, 1))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:, 2))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swtoacf_zero, topswcf_aero(:, 3))
+                                                                                                                                                                                                                                                                                                                              CALL histwrite_phy(o_swsrfcf_zero, solswcf_aero(:, 3))
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            !====MS forcing diagnostics
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (ok_aie) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_topswai, topswai_aero)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_solswai, solswai_aero)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (flag_aerosol>0.AND.ok_cdnc) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_scdnc, scdnc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_cldncl, cldncl)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_reffclws, reffclws)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_reffclwc, reffclwc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_cldnvi, cldnvi)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lcc, lcc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lcc3d, lcc3d)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_reffclwtop, reffclwtop)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          ! Champs 3D:
+                                                                                                                                                                                                                                                                                                                          IF (ok_ade .OR. ok_aie) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ec550aer, ec550aer)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_lwcon, flwc)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_iwcon, fiwc)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_temp, t_seri)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_theta, theta)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ovapinit, qx(:, :, ivap))
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ovap, q_seri)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_oliq, ql_seri)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_geop, zphi)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vitu, u_seri)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vitv, v_seri)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vitw, omega)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_pres, pplay)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_paprs, paprs(:, 1:klev))
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d1(i, 1) = pphis(i) / RG
+                                                                                                                                                                                                                                                                                                                              !020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                            DO k = 1, klev
+                                                                                                                                                                                                                                                                                                                              !020611        DO k=1, klev-1
+                                                                                                                                                                                                                                                                                                                              DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                !020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD *
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi3d1(i, k + 1) = zx_tmp_fi3d1(i, k) - (t_seri(i, k) * RD * &
+                                                                                                                                                                                                                                                                                                                                        (paprs(i, k + 1) - paprs(i, k))) / (pplay(i, k) * RG)
+                                                                                                                                                                                                                                                                                                                              ENDDO
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_zfull, zx_tmp_fi3d1(:, 2:klevp1))
+                                                                                                                                                                                                                                                                                                                          !020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  THEN
+                                                                                                                                                                                                                                                                                                                            DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(i, 1) = pphis(i) / RG - (&
+                                                                                                                                                                                                                                                                                                                                      (t_seri(i, 1) + zxtsol(i)) / 2. * RD * &
+                                                                                                                                                                                                                                                                                                                                              (pplay(i, 1) - paprs(i, 1))) / ((paprs(i, 1) + pplay(i, 1)) / 2. * RG)
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                            DO k = 1, klev - 1
+                                                                                                                                                                                                                                                                                                                              DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi3d(i, k + 1) = zx_tmp_fi3d(i, k) - (&
+                                                                                                                                                                                                                                                                                                                                        (t_seri(i, k) + t_seri(i, k + 1)) / 2. * RD * &
+                                                                                                                                                                                                                                                                                                                                                (pplay(i, k + 1) - pplay(i, k))) / (paprs(i, k) * RG)
+                                                                                                                                                                                                                                                                                                                              ENDDO
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rneb, cldfra)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rnebcon, rnebcon)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rnebls, rneb)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined)  THEN
+                                                                                                                                                                                                                                                                                                                            DO k = 1, klev
+                                                                                                                                                                                                                                                                                                                              DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi3d(i, k) = cldfra(i, k) * JrNt(i)
+                                                                                                                                                                                                                                                                                                                              ENDDO
+                                                                                                                                                                                                                                                                                                                            ENDDO
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rhum, zx_rh)
+                                                                                                                                                                                                                                                                                                                          !CALL histwrite_phy(o_ozone, &
+                                                                                                                                                                                                                                                                                                                          !     wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d = wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ozone, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                          IF (read_climoz == 2) THEN
+                                                                                                                                                                                                                                                                                                                            !CALL histwrite_phy(o_ozone_light, &
+                                                                                                                                                                                                                                                                                                                            !     wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d = wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ozone_light, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          !AS: dans phys_output_write il y a en plus : CALL histwrite_phy(o_duphy, d_u)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtphy, d_t)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqphy, d_qx(:, :, ivap))
+                                                                                                                                                                                                                                                                                                                          DO nsrf = 1, nbsrf
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = falb1(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = z0m(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_z0m_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = z0h(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_z0h_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = agesno(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = snow(1:klon, nsrf)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_snow_srf(nsrf), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          ENDDO !nsrf=1, nbsrf
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_alb1, albsol1)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_alb2, albsol2)
+                                                                                                                                                                                                                                                                                                                          !FH Sorties pour la couche limite
+                                                                                                                                                                                                                                                                                                                          IF (iflag_pbl>1) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d = 0.
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              DO nsrf = 1, nbsrf
+                                                                                                                                                                                                                                                                                                                                DO k = 1, klev
+                                                                                                                                                                                                                                                                                                                                  zx_tmp_fi3d(:, k) = zx_tmp_fi3d(:, k) &
+                                                                                                                                                                                                                                                                                                                                          + pctsrf(:, nsrf) * pbl_tke(:, k, nsrf)
+                                                                                                                                                                                                                                                                                                                                enddo
+                                                                                                                                                                                                                                                                                                                              enddo
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tke, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_kz, coefh(:, :, is_ave))
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_kz_max, coefh(:, :, is_ave))
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_clwcon, clwcon0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtdyn, d_t_dyn)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqdyn, d_q_dyn)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dudyn, d_u_dyn)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dvdyn, d_v_dyn)
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_thermals==0)THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                      d_t_ajsb(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ELSEIF (iflag_thermals>=1.AND.iflag_wake==1)THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = d_t_con(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                      d_t_ajs(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                      d_t_wake(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_u_con(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_v_con(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                          IF (iflag_thermals==0) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ELSEIF (iflag_thermals>=1.AND.iflag_wake==1) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = d_q_con(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                      d_q_ajs(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                      d_q_wake(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lsc(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = (d_t_lsc(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                  d_t_eva(1:klon, 1:klev)) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_lsc(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = beta_prec(1:klon, 1:klev)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                                                                                                                                                                                                                                                                                                          ! Sorties specifiques a la separation thermiques/non thermiques
+                                                                                                                                                                                                                                                                                                                          IF (iflag_thermals>=1) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscth(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lscst(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscth(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_lscst(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_plulth, plul_th)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_plulst, plul_st)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              DO k = 1, klev
+                                                                                                                                                                                                                                                                                                                                DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                  IF (ptconvth(i, k)) THEN
+                                                                                                                                                                                                                                                                                                                                    zx_tmp_fi3d(i, k) = 1.
+                                                                                                                                                                                                                                                                                                                                  ELSE
+                                                                                                                                                                                                                                                                                                                                    zx_tmp_fi3d(i, k) = 0.
+                                                                                                                                                                                                                                                                                                                                  ENDIF
+                                                                                                                                                                                                                                                                                                                                enddo
+                                                                                                                                                                                                                                                                                                                              enddo
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                zx_tmp_fi2d(1:klon) = lmax_th(:)
+                                                                                                                                                                                                                                                                                                                              enddo
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                          ENDIF ! iflag_thermals>=1
+                                                                                                                                                                                                                                                                                                                          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_vdf(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_diss(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_vdf(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_eva(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_eva(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          zpt_conv = 0.
+                                                                                                                                                                                                                                                                                                                          WHERE (ptconv) zpt_conv = 1.
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ptconv, zpt_conv)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ratqs, ratqs)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_t_ajs(1:klon, 1:klev) / pdtphys - &
+                                                                                                                                                                                                                                                                                                                                    d_t_ajsb(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_u_ajs(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_duthe, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_v_ajs(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                          IF (iflag_thermals>=1) THEN
+                                                                                                                                                                                                                                                                                                                            ! Pour l instant 0 a y reflichir pour les thermiques
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi2d = 0.
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_f_th, fm_therm)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_e_th, entr_therm)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_w_th, zw2)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_q_th, zqasc)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_a_th, fraca)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_d_th, detr_therm)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_f0_th, f0)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_zmax_th, zmax_th)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = d_q_ajs(1:klon, 1:klev) / pdtphys - &
+                                                                                                                                                                                                                                                                                                                                      d_q_ajsb(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF !iflag_thermals
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_ajsb(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_q_ajsb(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_swr(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_sw0(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lwr(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lw0(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_ec(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_u_vdf(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_v_vdf(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (ok_orodr) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_u_oro(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_v_oro(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_oro(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          IF (ok_orolf) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_u_lIF (1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_v_lIF (1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
+
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev) = d_t_lIF (1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          !      IF (ok_hines) THEN
+                                                                                                                                                                                                                                                                                                                          !         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          !         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          !         IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          !      ENDIF
+
+                                                                                                                                                                                                                                                                                                                          !      IF (ok_gwd_rando) THEN
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_du_gwd_rando, du_gwd_ranDO / pdtphys)
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_ranDO / pdtphys)
+                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
+                                                                                                                                                                                                                                                                                                                          !      ENDIF
+
+                                                                                                                                                                                                                                                                                                                          IF (ok_qch4) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dqch4, d_q_ch4 / pdtphys)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rsu, swup)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rsd, swdn)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rlu, lwup)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rld, lwdn)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rsucs, swup0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rsdcs, swdn0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rlucs, lwup0)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_rldcs, lwdn0)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_t(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                    d_t_dyn(1:klon, 1:klev)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_t_swr(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                    d_t_lwr(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = (d_t_lsc(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                    d_t_eva(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                    d_t_vdf(1:klon, 1:klev)) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_qx(1:klon, 1:klev, ivap) + &
+                                                                                                                                                                                                                                                                                                                                    d_q_dyn(1:klon, 1:klev)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = d_q_lsc(1:klon, 1:klev) / pdtphys + &
+                                                                                                                                                                                                                                                                                                                                    d_q_eva(1:klon, 1:klev) / pdtphys
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_evu, coefm(:, :, is_ave))
+                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                            zx_tmp_fi3d(1:klon, 1:klev) = q_seri(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                    ql_seri(1:klon, 1:klev)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          IF (iflag_con >= 3) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = -1 * (dnwd(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                      dnwd0(1:klon, 1:klev))
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                              zx_tmp_fi3d(1:klon, 1:klev) = upwd(1:klon, 1:klev) + &
+                                                                                                                                                                                                                                                                                                                                      dnwd(1:klon, 1:klev) + dnwd0(1:klon, 1:klev)
+                                                                                                                                                                                                                                                                                                                            ENDIF
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
+                                                                                                                                                                                                                                                                                                                          ELSEIF (iflag_con == 2) THEN
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_mcd, pmfd)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_dmc, pmfu + pmfd)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ref_liq, ref_liq)
+                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ref_ice, ref_ice)
+                                                                                                                                                                                                                                                                                                                          IF (RCO2_per/=RCO2_act.OR.RCH4_per/=RCH4_act.OR. &
+                                                                                                                                                                                                                                                                                                                                  RN2O_per/=RN2O_act.OR.RCFC11_per/=RCFC11_act.OR. &
+                                                                                                                                                                                                                                                                                                                                  RCFC12_per/=RCFC12_act) THEN
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = swupp (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = lwupp (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = swup0p (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            IF (vars_defined) zx_tmp_fi2d(1:klon) = lwup0p (1:klon, klevp1)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsu4co2, swupp)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rlu4co2, lwupp)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsucs4co2, swup0p)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rlucs4co2, lwup0p)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsd4co2, swdnp)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rld4co2, lwdnp)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rsdcs4co2, swdn0p)
+                                                                                                                                                                                                                                                                                                                            CALL histwrite_phy(o_rldcs4co2, lwdn0p)
+                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                          !!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
+
+                                                                                                                                                                                                                                                                                                                          IF (.NOT. using_xios) THEN
+                                                                                                                                                                                                                                                                                                                            IF (.NOT.ok_all_xml) THEN
+                                                                                                                                                                                                                                                                                                                              ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
+                                                                                                                                                                                                                                                                                                                              ! Champs interpolles sur des niveaux de pression
+                                                                                                                                                                                                                                                                                                                              DO iff = 7, nfiles - 1 !--here we deal with files 7,8 and 9
+
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_tnondef, tnondef(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_ta, twriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_zg, phiwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_hus, qwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_hur, rhwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_ua, uwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_va, vwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                CALL histwrite_phy(o_wap, wwriteSTD(:, :, iff - 6), iff)
+                                                                                                                                                                                                                                                                                                                                IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                  DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                    DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                      IF (tnondef(i, k, iff - 6).NE.missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                        IF (
+                                                                                                                                                                                                                                                                                                                                          freq_outNMC(iff-6).LT.0) THEN
+                                                                                                                                                                                                                                                                                                                                          freq_moyNMC(iff-6) =(mth_len*un_jour)/freq_calNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          freq_moyNMC(iff-6) = freq_outNMC(iff-6)/freq_calNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i, k, iff-6))/freq_moyNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_psbg, zx_tmp_fi3d_STD, iff)
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                          IF (O3sumSTD(i, k, iff-6).NE.missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = O3sumSTD(i, k, iff-6) * 1.e+9
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDDO !k=1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tro3, zx_tmp_fi3d_STD, iff)
+                                                                                                                                                                                                                                                                                                                                          IF (read_climoz == 2) THEN
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                          IF (O3daysumSTD(i, k, iff-6).NE.missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = O3daysumSTD(i, k, iff-6) * 1.e+9
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDDO !k=1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tro3_daylight, zx_tmp_fi3d_STD, iff)
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_uxv, uvsumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxq, vqsumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxT, vTsumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wxq, wqsumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxphi, vphisumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wxT, wTsumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_uxu, u2sumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxv, v2sumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_TxT, T2sumSTD(:, :, iff-6), iff)
+                                                                                                                                                                                                                                                                                                                                          ENDDO !nfiles
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                                          IF (using_xios) THEN
+                                                                                                                                                                                                                                                                                                                                          IF (ok_all_xml) THEN
+                                                                                                                                                                                                                                                                                                                                          !      DO iff=7, nfiles
+
+                                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_tnondef,tnondef(:,:,3))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ta, tlevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_zg, philevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_hus, qlevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_hur, rhlevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_ua, ulevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_va, vlevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wap, wlevSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          !         IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          !            DO k=1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          !               DO i=1, klon
+                                                                                                                                                                                                                                                                                                                                          !                  IF (tnondef(i,k,3).NE.missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                          !                     IF (freq_outNMC(iff-6).LT.0) THEN
+                                                                                                                                                                                                                                                                                                                                          !                        freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          !                     ELSE
+                                                                                                                                                                                                                                                                                                                                          !                        freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          !                     ENDIF
+                                                                                                                                                                                                                                                                                                                                          !                     zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(iff-6)
+                                                                                                                                                                                                                                                                                                                                          !                  ELSE
+                                                                                                                                                                                                                                                                                                                                          !                     zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          !                  ENDIF
+                                                                                                                                                                                                                                                                                                                                          !               ENDDO
+                                                                                                                                                                                                                                                                                                                                          !            ENDDO
+                                                                                                                                                                                                                                                                                                                                          !         ENDIF
+                                                                                                                                                                                                                                                                                                                                          !         CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD)
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                          IF (O3STD(i, k)/=missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = O3STD(i, k) * 1.e+9
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDDO !k=1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tro3, zx_tmp_fi3d_STD)
+                                                                                                                                                                                                                                                                                                                                          IF (read_climoz == 2) THEN
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          DO k = 1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          DO i = 1, klon
+                                                                                                                                                                                                                                                                                                                                          IF (O3daySTD(i, k)/=missing_val) THEN
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = O3daySTD(i, k) * 1.e+9
+                                                                                                                                                                                                                                                                                                                                          ELSE
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi3d_STD(i,k) = missing_val
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDDO !k=1, nlevSTD
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_tro3_daylight, zx_tmp_fi3d_STD)
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_uxv, uvSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxq, vqSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxT, vTSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wxq, wqSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxphi, vphiSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_wxT, wTSTD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_uxu, u2STD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_vxv, v2STD(:, :))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_TxT, T2STD(:, :))
+                                                                                                                                                                                                                                                                                                                                          !      ENDDO !nfiles
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDIF !using_xios
+                                                                                                                                                                                                                                                                                                                                          !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+                                                                                                                                                                                                                                                                                                                                          itr = 0
+                                                                                                                                                                                                                                                                                                                                          DO iq = 1, nqtot
+                                                                                                                                                                                                                                                                                                                                          IF(.NOT.tracers(iq)%isInPhysics) CYCLE
+                                                                                                                                                                                                                                                                                                                                          itr = itr+1
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_trac(itr), tr_seri(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_vdf(itr), d_tr_cl(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_the(itr), d_tr_th(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_con(itr), d_tr_cv(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_lessi_impa(itr), d_tr_lessi_impa(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_lessi_nucl(itr), d_tr_lessi_nucl(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_insc(itr), d_tr_insc(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_bcscav(itr), d_tr_bcscav(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_evapls(itr), d_tr_evapls(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_ls(itr), d_tr_ls(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          !            CALL histwrite_phy(o_dtr_dyn(itr),d_tr_dyn(:,:,itr))
+                                                                                                                                                                                                                                                                                                                                          !            CALL histwrite_phy(o_dtr_cl(itr),d_tr_cl(:,:,itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_trsp(itr), d_tr_trsp(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_sscav(itr), d_tr_sscav(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_sat(itr), d_tr_sat(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_dtr_uscav(itr), d_tr_uscav(:, :, itr))
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi2d=0.
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          DO k = 1, klev
+                                                                                                                                                                                                                                                                                                                                          zx_tmp_fi2d(:) = zx_tmp_fi2d(:)+zmasse(:, k)*tr_seri(:, k, itr)
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          CALL histwrite_phy(o_trac_cum(itr), zx_tmp_fi2d)
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+
+                                                                                                                                                                                                                                                                                                                                          IF (.NOT.vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          !$OMP MASTER
+#ifndef CPP_IOIPSL_NO_OUTPUT
+                                                                                                                                                                                                                                                                                                                                          DO iff = 1, nfiles
+                                                                                                                                                                                                                                                                                                                                          IF (clef_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                                          CALL histend(nid_files(iff))
+                                                                                                                                                                                                                                                                                                                                          ndex2d = 0
+                                                                                                                                                                                                                                                                                                                                          ndex3d = 0
+
+                                                                                                                                                                                                                                                                                                                                          ENDIF ! clef_files
+                                                                                                                                                                                                                                                                                                                                          ENDDO !  iff
 #endif
-          !On finalise l'initialisation:
-          IF (using_xios) CALL wxios_closedef()
-
-          !$OMP END MASTER
-          !$OMP BARRIER
-          vars_defined = .TRUE.
-
-       ENDIF
-
-    ENDDO ! iinit
-
-    IF (vars_defined) THEN
-       ! On synchronise les fichiers pour IOIPSL
-#ifndef CPP_IOIPSL_NO_OUTPUT 
-       !$OMP MASTER
-       DO iff=1,nfiles
-          IF (ok_sync .AND. clef_files(iff)) THEN
-             CALL histsync(nid_files(iff))
-          ENDIF
-       ENDDO
-       !$OMP END MASTER
+                                                                                                                                                                                                                                                                                                                                          !On finalise l'initialisation:
+                                                                                                                                                                                                                                                                                                                                          IF (using_xios) CALL wxios_closedef()
+
+                                                                                                                                                                                                                                                                                                                                          !$OMP END MASTER
+                                                                                                                                                                                                                                                                                                                                          !$OMP BARRIER
+                                                                                                                                                                                                                                                                                                                                          vars_defined = .TRUE.
+
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                                          ENDDO ! iinit
+
+                                                                                                                                                                                                                                                                                                                                          IF (vars_defined) THEN
+                                                                                                                                                                                                                                                                                                                                          ! On synchronise les fichiers pour IOIPSL
+#ifndef CPP_IOIPSL_NO_OUTPUT
+                                                                                                                                                                                                                                                                                                                                          !$OMP MASTER
+                                                                                                                                                                                                                                                                                                                                          DO iff = 1, nfiles
+                                                                                                                                                                                                                                                                                                                                          IF (ok_sync .AND. clef_files(iff)) THEN
+                                                                                                                                                                                                                                                                                                                                          CALL histsync(nid_files(iff))
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+                                                                                                                                                                                                                                                                                                                                          ENDDO
+                                                                                                                                                                                                                                                                                                                                          !$OMP END MASTER
 #endif
-    ENDIF
-
-  END SUBROUTINE phys_output_write_spl
-
-END MODULE phys_output_write_spl_mod
+                                                                                                                                                                                                                                                                                                                                          ENDIF
+
+                                                                                                                                                                                                                                                                                                                                          END SUBROUTINE phys_output_write_spl
+
+                                                                                                                                                                                                                                                                                                                                          END MODULE phys_output_write_spl_mod
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90	(revision 5117)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/StratAer/calcaerosolstrato_rrtm.F90	(revision 5118)
@@ -1,6 +1,5 @@
-
 ! $Id$
 
-SUBROUTINE calcaerosolstrato_rrtm(pplay,t_seri,paprs,debut)
+SUBROUTINE calcaerosolstrato_rrtm(pplay, t_seri, paprs, debut)
 
   USE phys_state_var_mod, ONLY: tau_aero_sw_rrtm, piz_aero_sw_rrtm, cg_aero_sw_rrtm, tau_aero_lw_rrtm
@@ -10,4 +9,5 @@
   USE temps_mod
   USE lmdz_yomcst
+  USE lmdz_iniprint, ONLY: lunout, prt_level
 
   IMPLICIT NONE
@@ -16,106 +16,105 @@
   INCLUDE "clesphys.h"
   INCLUDE "paramet.h"
-  INCLUDE "iniprint.h"
 
-! Variable input
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: t_seri  ! Temperature
-  REAL,DIMENSION(klon,klev),INTENT(IN)   :: pplay   ! pression pour le mileu de chaque couche (en Pa)
-  LOGICAL,INTENT(IN)                     :: debut   ! le flag de l'initialisation de la physique
-  REAL,DIMENSION(klon,klev+1),INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
+  ! Variable input
+  REAL, DIMENSION(klon, klev), INTENT(IN) :: t_seri  ! Temperature
+  REAL, DIMENSION(klon, klev), INTENT(IN) :: pplay   ! pression pour le mileu de chaque couche (en Pa)
+  LOGICAL, INTENT(IN) :: debut   ! le flag de l'initialisation de la physique
+  REAL, DIMENSION(klon, klev + 1), INTENT(IN) :: paprs   ! pression pour chaque inter-couche (en Pa)
 
-! Stratospheric aerosols optical properties
-  REAL, DIMENSION(klon,klev,nbands_sw_rrtm) :: tau_strat, piz_strat, cg_strat
-  REAL, DIMENSION(klon,klev,nwave_sw+nwave_lw) :: tau_strat_wave
-  REAL, DIMENSION(klon,klev,nbands_lw_rrtm) :: tau_lw_abs_rrtm
+  ! Stratospheric aerosols optical properties
+  REAL, DIMENSION(klon, klev, nbands_sw_rrtm) :: tau_strat, piz_strat, cg_strat
+  REAL, DIMENSION(klon, klev, nwave_sw + nwave_lw) :: tau_strat_wave
+  REAL, DIMENSION(klon, klev, nbands_lw_rrtm) :: tau_lw_abs_rrtm
 
   INTEGER k, band, wave, i
   REAL zrho, zdz
 
-!--calculate optical properties of the aerosol size distribution from tr_seri
-  tau_strat=0.0
-  piz_strat=0.0
-  cg_strat=0.0
-  tau_strat_wave=0.0
-  tau_lw_abs_rrtm=0.0
+  !--calculate optical properties of the aerosol size distribution from tr_seri
+  tau_strat = 0.0
+  piz_strat = 0.0
+  cg_strat = 0.0
+  tau_strat_wave = 0.0
+  tau_lw_abs_rrtm = 0.0
 
   CALL miecalc_aer(tau_strat, piz_strat, cg_strat, tau_strat_wave, tau_lw_abs_rrtm, paprs, debut)
 
-!!--test CK: deactivate radiative effect of aerosol
-!  tau_strat=0.0
-!  piz_strat=0.0
-!  cg_strat=0.0
-!  tau_strat_wave=0.0
-!  tau_lw_abs_rrtm=0.0
+  !!--test CK: deactivate radiative effect of aerosol
+  !  tau_strat=0.0
+  !  piz_strat=0.0
+  !  cg_strat=0.0
+  !  tau_strat_wave=0.0
+  !  tau_lw_abs_rrtm=0.0
 
-!--test CK: deactivate SW radiative effect of aerosol (but leave LW)
-!  tau_strat=0.0
-!  piz_strat=0.0
-!  cg_strat=0.0
+  !--test CK: deactivate SW radiative effect of aerosol (but leave LW)
+  !  tau_strat=0.0
+  !  piz_strat=0.0
+  !  cg_strat=0.0
 
-!  DO wave=1, nwave_sw
-!  tau_strat_wave(:,:,wave)=0.0
-!  ENDDO
+  !  DO wave=1, nwave_sw
+  !  tau_strat_wave(:,:,wave)=0.0
+  !  ENDDO
 
-!--test CK: deactivate LW radiative effect of aerosol (but leave SW)
-!  tau_lw_abs_rrtm=0.0
+  !--test CK: deactivate LW radiative effect of aerosol (but leave SW)
+  !  tau_lw_abs_rrtm=0.0
 
-!  DO wave=nwave_sw+1, nwave_sw+nwave_lw
-!  tau_strat_wave(:,:,wave)=0.0
-!  ENDDO
+  !  DO wave=nwave_sw+1, nwave_sw+nwave_lw
+  !  tau_strat_wave(:,:,wave)=0.0
+  !  ENDDO
 
-!--total vertical aod at the 5 SW + 1 LW wavelengths
-  DO wave=1, nwave_sw+nwave_lw
-    DO k=1, klev
-      tausum_aero(:,wave,id_STRAT_phy)=tausum_aero(:,wave,id_STRAT_phy)+tau_strat_wave(:,k,wave)
+  !--total vertical aod at the 5 SW + 1 LW wavelengths
+  DO wave = 1, nwave_sw + nwave_lw
+    DO k = 1, klev
+      tausum_aero(:, wave, id_STRAT_phy) = tausum_aero(:, wave, id_STRAT_phy) + tau_strat_wave(:, k, wave)
     ENDDO
   ENDDO
 
-!--weighted average for cg, piz and tau, adding strat aerosols on top of tropospheric ones
-  DO band=1, nbands_sw_rrtm
+  !--weighted average for cg, piz and tau, adding strat aerosols on top of tropospheric ones
+  DO band = 1, nbands_sw_rrtm
     !--no stratospheric aerosol in index 1
-    cg_aero_sw_rrtm(:,:,1,band)  =  cg_aero_sw_rrtm(:,:,2,band)
-    piz_aero_sw_rrtm(:,:,1,band)  = piz_aero_sw_rrtm(:,:,2,band)
-    tau_aero_sw_rrtm(:,:,1,band)  = tau_aero_sw_rrtm(:,:,2,band)
+    cg_aero_sw_rrtm(:, :, 1, band) = cg_aero_sw_rrtm(:, :, 2, band)
+    piz_aero_sw_rrtm(:, :, 1, band) = piz_aero_sw_rrtm(:, :, 2, band)
+    tau_aero_sw_rrtm(:, :, 1, band) = tau_aero_sw_rrtm(:, :, 2, band)
 
     !--tropospheric and stratospheric aerosol in index 2
-    cg_aero_sw_rrtm(:,:,2,band) = ( cg_aero_sw_rrtm(:,:,2,band)*piz_aero_sw_rrtm(:,:,2,band)*tau_aero_sw_rrtm(:,:,2,band) + &
-                                cg_strat(:,:,band)*piz_strat(:,:,band)*tau_strat(:,:,band) ) /                              &
-                                MAX( piz_aero_sw_rrtm(:,:,2,band)*tau_aero_sw_rrtm(:,:,2,band) +                            &
-                                piz_strat(:,:,band)*tau_strat(:,:,band), 1.e-15 )
-    piz_aero_sw_rrtm(:,:,2,band)= ( piz_aero_sw_rrtm(:,:,2,band)*tau_aero_sw_rrtm(:,:,2,band) +                             &
-                                piz_strat(:,:,band)*tau_strat(:,:,band) ) /                                                 &
-                                MAX( tau_aero_sw_rrtm(:,:,2,band) + tau_strat(:,:,band), 1.e-15 )
-    tau_aero_sw_rrtm(:,:,2,band)= tau_aero_sw_rrtm(:,:,2,band) + tau_strat(:,:,band)
+    cg_aero_sw_rrtm(:, :, 2, band) = (cg_aero_sw_rrtm(:, :, 2, band) * piz_aero_sw_rrtm(:, :, 2, band) * tau_aero_sw_rrtm(:, :, 2, band) + &
+            cg_strat(:, :, band) * piz_strat(:, :, band) * tau_strat(:, :, band)) / &
+            MAX(piz_aero_sw_rrtm(:, :, 2, band) * tau_aero_sw_rrtm(:, :, 2, band) + &
+                    piz_strat(:, :, band) * tau_strat(:, :, band), 1.e-15)
+    piz_aero_sw_rrtm(:, :, 2, band) = (piz_aero_sw_rrtm(:, :, 2, band) * tau_aero_sw_rrtm(:, :, 2, band) + &
+            piz_strat(:, :, band) * tau_strat(:, :, band)) / &
+            MAX(tau_aero_sw_rrtm(:, :, 2, band) + tau_strat(:, :, band), 1.e-15)
+    tau_aero_sw_rrtm(:, :, 2, band) = tau_aero_sw_rrtm(:, :, 2, band) + tau_strat(:, :, band)
   ENDDO
 
-  DO band=1, nbands_lw_rrtm
+  DO band = 1, nbands_lw_rrtm
     !--no stratospheric aerosols in index 1
-    tau_aero_lw_rrtm(:,:,1,band)  = tau_aero_lw_rrtm(:,:,2,band)
+    tau_aero_lw_rrtm(:, :, 1, band) = tau_aero_lw_rrtm(:, :, 2, band)
     !--tropospheric and stratospheric aerosol in index 2
-    tau_aero_lw_rrtm(:,:,2,band)  = tau_aero_lw_rrtm(:,:,2,band) + tau_lw_abs_rrtm(:,:,band) 
+    tau_aero_lw_rrtm(:, :, 2, band) = tau_aero_lw_rrtm(:, :, 2, band) + tau_lw_abs_rrtm(:, :, band)
   ENDDO
 
-  WHERE (tau_aero_sw_rrtm < 1.e-14) piz_aero_sw_rrtm=1.0
-  WHERE (tau_aero_sw_rrtm < 1.e-14) tau_aero_sw_rrtm=1.e-15
-  WHERE (tau_aero_lw_rrtm < 1.e-14) tau_aero_lw_rrtm=1.e-15
+  WHERE (tau_aero_sw_rrtm < 1.e-14) piz_aero_sw_rrtm = 1.0
+  WHERE (tau_aero_sw_rrtm < 1.e-14) tau_aero_sw_rrtm = 1.e-15
+  WHERE (tau_aero_lw_rrtm < 1.e-14) tau_aero_lw_rrtm = 1.e-15
 
-  tausum_strat(:,:)=0.0
-  DO i=1,klon
-  DO k=1,klev
-    IF (stratomask(i,k)>0.5) THEN
-      tausum_strat(i,1)=tausum_strat(i,1)+tau_strat_wave(i,k,2)  !--550 nm
-      tausum_strat(i,2)=tausum_strat(i,2)+tau_strat_wave(i,k,5)  !--1020 nm
-      tausum_strat(i,3)=tausum_strat(i,3)+tau_strat_wave(i,k,6)  !--10 um
-    ENDIF
-  ENDDO
+  tausum_strat(:, :) = 0.0
+  DO i = 1, klon
+    DO k = 1, klev
+      IF (stratomask(i, k)>0.5) THEN
+        tausum_strat(i, 1) = tausum_strat(i, 1) + tau_strat_wave(i, k, 2)  !--550 nm
+        tausum_strat(i, 2) = tausum_strat(i, 2) + tau_strat_wave(i, k, 5)  !--1020 nm
+        tausum_strat(i, 3) = tausum_strat(i, 3) + tau_strat_wave(i, k, 6)  !--10 um
+      ENDIF
+    ENDDO
   ENDDO
 
-  DO i=1,klon
-  DO k=1,klev
-    zrho=pplay(i,k)/t_seri(i,k)/RD            !air density in kg/m3
-    zdz=(paprs(i,k)-paprs(i,k+1))/zrho/RG     !thickness of layer in m
-    tau_strat_550(i,k)=tau_strat_wave(i,k,2)/zdz
-    tau_strat_1020(i,k)=tau_strat_wave(i,k,5)/zdz
-  ENDDO
+  DO i = 1, klon
+    DO k = 1, klev
+      zrho = pplay(i, k) / t_seri(i, k) / RD            !air density in kg/m3
+      zdz = (paprs(i, k) - paprs(i, k + 1)) / zrho / RG     !thickness of layer in m
+      tau_strat_550(i, k) = tau_strat_wave(i, k, 2) / zdz
+      tau_strat_1020(i, k) = tau_strat_wave(i, k, 5) / zdz
+    ENDDO
   ENDDO
 
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/carbon_cycle_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/carbon_cycle_mod.F90	(revision 5117)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/carbon_cycle_mod.F90	(revision 5118)
@@ -1,31 +1,31 @@
 MODULE carbon_cycle_mod
-!=======================================================================
-!   Authors: Patricia Cadule and Laurent Fairhead
-!            base sur un travail anterieur mene par Patricia Cadule et Josefine Ghattas
-
-!  Purpose and description:
-!  -----------------------
-! Control module for the carbon CO2 tracers :
-!   - Initialisation of carbon cycle fields
-!   - Definition of fluxes to be exchanged
-
-! Rest of code is in tracco2i.F90
-
-! Le cas online/offline est defini par le flag carbon_cycle_cpl (y/n)
-! Le transport du traceur CO2 est defini par le flag carbon_cycle_tr (y/n)
-! la provenance des champs (termes de puits) est denini par le flag level_coupling_esm
-
-! level_coupling_esm : level of coupling of the biogeochemical fields between
-! LMDZ, ORCHIDEE and NEMO
-! Definitions of level_coupling_esm in physiq.def
-! level_coupling_esm = 0  ! No field exchange between LMDZ and ORCHIDEE models
-!                         ! No field exchange between LMDZ and NEMO
-! level_coupling_esm = 1  ! Field exchange between LMDZ and ORCHIDEE models
-!                         ! No field exchange between LMDZ and NEMO models
-! level_coupling_esm = 2  ! No field exchange between LMDZ and ORCHIDEE models
-!                         ! Field exchange between LMDZ and NEMO models
-! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
-!                         ! Field exchange between LMDZ and NEMO models
-!=======================================================================
+  !=======================================================================
+  !   Authors: Patricia Cadule and Laurent Fairhead
+  !            base sur un travail anterieur mene par Patricia Cadule et Josefine Ghattas
+
+  !  Purpose and description:
+  !  -----------------------
+  ! Control module for the carbon CO2 tracers :
+  !   - Initialisation of carbon cycle fields
+  !   - Definition of fluxes to be exchanged
+
+  ! Rest of code is in tracco2i.F90
+
+  ! Le cas online/offline est defini par le flag carbon_cycle_cpl (y/n)
+  ! Le transport du traceur CO2 est defini par le flag carbon_cycle_tr (y/n)
+  ! la provenance des champs (termes de puits) est denini par le flag level_coupling_esm
+
+  ! level_coupling_esm : level of coupling of the biogeochemical fields between
+  ! LMDZ, ORCHIDEE and NEMO
+  ! Definitions of level_coupling_esm in physiq.def
+  ! level_coupling_esm = 0  ! No field exchange between LMDZ and ORCHIDEE models
+  !                         ! No field exchange between LMDZ and NEMO
+  ! level_coupling_esm = 1  ! Field exchange between LMDZ and ORCHIDEE models
+  !                         ! No field exchange between LMDZ and NEMO models
+  ! level_coupling_esm = 2  ! No field exchange between LMDZ and ORCHIDEE models
+  !                         ! Field exchange between LMDZ and NEMO models
+  ! level_coupling_esm = 3  ! Field exchange between LMDZ and ORCHIDEE models
+  !                         ! Field exchange between LMDZ and NEMO models
+  !=======================================================================
 
   IMPLICIT NONE
@@ -34,187 +34,187 @@
   PUBLIC :: carbon_cycle_init, infocfields_init
 
-! Variables read from parmeter file physiq.def
+  ! Variables read from parmeter file physiq.def
   LOGICAL, PUBLIC :: carbon_cycle_cpl       ! Coupling of CO2 fluxes between LMDZ/ORCHIDEE and LMDZ/OCEAN(PISCES) 
-!$OMP THREADPRIVATE(carbon_cycle_cpl)
+  !$OMP THREADPRIVATE(carbon_cycle_cpl)
   LOGICAL, PUBLIC :: carbon_cycle_tr        ! 3D transport of CO2 in the atmosphere, parameter read in conf_phys
-!$OMP THREADPRIVATE(carbon_cycle_tr)
+  !$OMP THREADPRIVATE(carbon_cycle_tr)
   LOGICAL, PUBLIC :: carbon_cycle_rad       ! flag to activate CO2 interactive radiatively 
-!$OMP THREADPRIVATE(carbon_cycle_rad)
+  !$OMP THREADPRIVATE(carbon_cycle_rad)
   INTEGER, PUBLIC :: level_coupling_esm     ! Level of coupling for the ESM - 0, 1, 2, 3
-!$OMP THREADPRIVATE(level_coupling_esm)
+  !$OMP THREADPRIVATE(level_coupling_esm)
   LOGICAL, PUBLIC :: read_fco2_ocean_cor    ! flag to read corrective oceanic CO2 flux
-!$OMP THREADPRIVATE(read_fco2_ocean_cor)  
+  !$OMP THREADPRIVATE(read_fco2_ocean_cor)
   REAL, PUBLIC :: var_fco2_ocean_cor        ! corrective oceanic CO2 flux
-!$OMP THREADPRIVATE(var_fco2_ocean_cor)
+  !$OMP THREADPRIVATE(var_fco2_ocean_cor)
   REAL, PUBLIC :: ocean_area_tot            ! total oceanic area to convert flux
-!$OMP THREADPRIVATE(ocean_area_tot)
+  !$OMP THREADPRIVATE(ocean_area_tot)
   LOGICAL, PUBLIC :: read_fco2_land_cor     ! flag to read corrective land CO2 flux
-!$OMP THREADPRIVATE(read_fco2_land_cor)  
+  !$OMP THREADPRIVATE(read_fco2_land_cor)
   REAL, PUBLIC :: var_fco2_land_cor         ! corrective land CO2 flux
-!$OMP THREADPRIVATE(var_fco2_land_cor)
+  !$OMP THREADPRIVATE(var_fco2_land_cor)
   REAL, PUBLIC :: land_area_tot             ! total land area to convert flux
-!$OMP THREADPRIVATE(land_area_tot)
+  !$OMP THREADPRIVATE(land_area_tot)
 
   REAL, PUBLIC :: RCO2_glo
-!$OMP THREADPRIVATE(RCO2_glo)
+  !$OMP THREADPRIVATE(RCO2_glo)
   REAL, PUBLIC :: RCO2_tot
-!$OMP THREADPRIVATE(RCO2_tot)
-
-  LOGICAL :: carbon_cycle_emis_comp_omp=.FALSE.
-  LOGICAL :: carbon_cycle_emis_comp=.FALSE. ! Calculation of emission compatible
-!$OMP THREADPRIVATE(carbon_cycle_emis_comp)
+  !$OMP THREADPRIVATE(RCO2_tot)
+
+  LOGICAL :: carbon_cycle_emis_comp_omp = .FALSE.
+  LOGICAL :: carbon_cycle_emis_comp = .FALSE. ! Calculation of emission compatible
+  !$OMP THREADPRIVATE(carbon_cycle_emis_comp)
 
   LOGICAL :: RCO2_inter_omp
   LOGICAL :: RCO2_inter  ! RCO2 interactive : if true calculate new value RCO2 for the radiation scheme
-!$OMP THREADPRIVATE(RCO2_inter)
-
-! Scalare values when no transport, from physiq.def
+  !$OMP THREADPRIVATE(RCO2_inter)
+
+  ! Scalare values when no transport, from physiq.def
   REAL :: fos_fuel_s_omp
   REAL :: fos_fuel_s  ! carbon_cycle_fos_fuel dans physiq.def
-!$OMP THREADPRIVATE(fos_fuel_s)
+  !$OMP THREADPRIVATE(fos_fuel_s)
   REAL :: emis_land_s ! not yet implemented
-!$OMP THREADPRIVATE(emis_land_s)
+  !$OMP THREADPRIVATE(emis_land_s)
 
   REAL :: airetot     ! Total area of the earth surface
-!$OMP THREADPRIVATE(airetot)
+  !$OMP THREADPRIVATE(airetot)
 
   INTEGER :: ntr_co2  ! Number of tracers concerning the carbon cycle
-!$OMP THREADPRIVATE(ntr_co2)
-
-! fco2_ocn_day : flux CO2 from ocean for 1 day (cumulated) [gC/m2/d]. Allocation and initalization done in cpl_mod
-  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocn_day 
-!$OMP THREADPRIVATE(fco2_ocn_day)
+  !$OMP THREADPRIVATE(ntr_co2)
+
+  ! fco2_ocn_day : flux CO2 from ocean for 1 day (cumulated) [gC/m2/d]. Allocation and initalization done in cpl_mod
+  REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocn_day
+  !$OMP THREADPRIVATE(fco2_ocn_day)
 
   REAL, DIMENSION(:), ALLOCATABLE :: fco2_land_day   ! flux CO2 from land for 1 day (cumulated)  [gC/m2/d]
-!$OMP THREADPRIVATE(fco2_land_day)
+  !$OMP THREADPRIVATE(fco2_land_day)
   REAL, DIMENSION(:), ALLOCATABLE :: fco2_lu_day     ! Emission from land use change for 1 day (cumulated) [gC/m2/d]
-!$OMP THREADPRIVATE(fco2_lu_day)
+  !$OMP THREADPRIVATE(fco2_lu_day)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ff ! Emission from fossil fuel [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_ff)
+  !$OMP THREADPRIVATE(fco2_ff)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_bb ! Emission from biomass burning [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_bb)
+  !$OMP THREADPRIVATE(fco2_bb)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land)
+  !$OMP THREADPRIVATE(fco2_land)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_nbp  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_nbp)
+  !$OMP THREADPRIVATE(fco2_land_nbp)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_nep  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_nep)
+  !$OMP THREADPRIVATE(fco2_land_nep)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_fLuc  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_fLuc)
+  !$OMP THREADPRIVATE(fco2_land_fLuc)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_fwoodharvest  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_fwoodharvest)
+  !$OMP THREADPRIVATE(fco2_land_fwoodharvest)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_fHarvest  ! Net flux from terrestrial ecocsystems [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_fHarvest)
+  !$OMP THREADPRIVATE(fco2_land_fHarvest)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocean ! Net flux from ocean [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_ocean)
+  !$OMP THREADPRIVATE(fco2_ocean)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_ocean_cor ! Net corrective flux from ocean [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_ocean_cor)
+  !$OMP THREADPRIVATE(fco2_ocean_cor)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_cor  ! Net corrective flux from land [kgCO2/m2/s]
-!$OMP THREADPRIVATE(fco2_land_cor)
-
-  REAL, DIMENSION(:,:), ALLOCATABLE :: dtr_add       ! Tracer concentration to be injected 
-!$OMP THREADPRIVATE(dtr_add)
-
-! Following 2 fields will be allocated and initialized in surf_land_orchidee
+  !$OMP THREADPRIVATE(fco2_land_cor)
+
+  REAL, DIMENSION(:, :), ALLOCATABLE :: dtr_add       ! Tracer concentration to be injected
+  !$OMP THREADPRIVATE(dtr_add)
+
+  ! Following 2 fields will be allocated and initialized in surf_land_orchidee
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_land_inst  ! flux CO2 from land at one time step
-!$OMP THREADPRIVATE(fco2_land_inst)
+  !$OMP THREADPRIVATE(fco2_land_inst)
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: fco2_lu_inst    ! Emission from land use change at one time step
-!$OMP THREADPRIVATE(fco2_lu_inst)
-
-! Calculated co2 field to be send to the ocean via the coupler and to ORCHIDEE 
+  !$OMP THREADPRIVATE(fco2_lu_inst)
+
+  ! Calculated co2 field to be send to the ocean via the coupler and to ORCHIDEE
   REAL, DIMENSION(:), ALLOCATABLE, PUBLIC :: co2_send ! Field allocated in phyetat0
-!$OMP THREADPRIVATE(co2_send)
-
-  INTEGER, PARAMETER, PUBLIC :: id_CO2=1              !--temporaire OB -- to be changed
-
-! nbfields : total number of fields 
+  !$OMP THREADPRIVATE(co2_send)
+
+  INTEGER, PARAMETER, PUBLIC :: id_CO2 = 1              !--temporaire OB -- to be changed
+
+  ! nbfields : total number of fields
   INTEGER, PUBLIC :: nbcf
-!$OMP THREADPRIVATE(nbcf)
-
-! nbcf_in : number of fields IN
-  INTEGER, PUBLIC  :: nbcf_in
-!$OMP THREADPRIVATE(nbcf_in)
-
-! nbcf_in_orc : number of fields IN 
-  INTEGER, PUBLIC  :: nbcf_in_orc
-!$OMP THREADPRIVATE(nbcf_in_orc)
-
-! nbcf_in_inca : number of fields IN (from INCA)
-  INTEGER, PUBLIC  :: nbcf_in_inca
-!$OMP THREADPRIVATE(nbcf_in_inca)
-
-! nbcf_in_nemo : number of fields IN (from nemo)
-  INTEGER, PUBLIC  :: nbcf_in_nemo
-!$OMP THREADPRIVATE(nbcf_in_nemo)
-
-! nbcf_in_ant : number of fields IN (from anthropogenic sources)
-  INTEGER, PUBLIC  :: nbcf_in_ant
-!$OMP THREADPRIVATE(nbcf_in_ant)
-
-! nbcf_out : number of fields OUT
+  !$OMP THREADPRIVATE(nbcf)
+
+  ! nbcf_in : number of fields IN
+  INTEGER, PUBLIC :: nbcf_in
+  !$OMP THREADPRIVATE(nbcf_in)
+
+  ! nbcf_in_orc : number of fields IN
+  INTEGER, PUBLIC :: nbcf_in_orc
+  !$OMP THREADPRIVATE(nbcf_in_orc)
+
+  ! nbcf_in_inca : number of fields IN (from INCA)
+  INTEGER, PUBLIC :: nbcf_in_inca
+  !$OMP THREADPRIVATE(nbcf_in_inca)
+
+  ! nbcf_in_nemo : number of fields IN (from nemo)
+  INTEGER, PUBLIC :: nbcf_in_nemo
+  !$OMP THREADPRIVATE(nbcf_in_nemo)
+
+  ! nbcf_in_ant : number of fields IN (from anthropogenic sources)
+  INTEGER, PUBLIC :: nbcf_in_ant
+  !$OMP THREADPRIVATE(nbcf_in_ant)
+
+  ! nbcf_out : number of fields OUT
   INTEGER, PUBLIC :: nbcf_out
-!$OMP THREADPRIVATE(nbcf_out)
-
-! Name of variables
-  CHARACTER(len=25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname     ! coupling field short name for restart (?) and diagnostics
-!$OMP THREADPRIVATE(cfname)
-
-  CHARACTER(len=25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname_in  ! coupling field short name for restart (?) and diagnostics
-!$OMP THREADPRIVATE(cfname_in)
-
-  CHARACTER(len=25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname_out ! coupling field short name for restart (?) and diagnostics
-!$OMP THREADPRIVATE(cfname_out)
-
-  CHARACTER(len=15), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfunits_in  !  coupling field units for diagnostics
-!$OMP THREADPRIVATE(cfunits_in)
-
-  CHARACTER(len=15), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfunits_out !  coupling field units for diagnostics
-!$OMP THREADPRIVATE(cfunits_out)
-
-  CHARACTER(len=120), ALLOCATABLE, DIMENSION(:), PUBLIC :: cftext_in  ! coupling field long name for diagnostics
-!$OMP THREADPRIVATE(cftext_in)
-
-  CHARACTER(len=120), ALLOCATABLE, DIMENSION(:), PUBLIC :: cftext_out ! coupling field long name for diagnostics
-!$OMP THREADPRIVATE(cftext_out)
-
-  CHARACTER(len=5), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfmod1 ! model 1 (rreference) : LMDz
-!$OMP THREADPRIVATE(cfmod1)
-
-  CHARACTER(len=5), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfmod2 ! model 2
-!$OMP THREADPRIVATE(cfmod2)
-
-  CHARACTER(LEN=20), ALLOCATABLE, DIMENSION(:), PUBLIC :: field_out_names
-!$OMP THREADPRIVATE(field_out_names)
-
-  CHARACTER(LEN=20), ALLOCATABLE, DIMENSION(:), PUBLIC :: field_in_names
-!$OMP THREADPRIVATE(field_in_names)
-
-  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC :: fields_in   !  klon,nbcf_in
-!$OMP THREADPRIVATE(fields_in)
-
-  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC :: yfields_in  !  knon,nbcf_in
-!$OMP THREADPRIVATE(yfields_in)
-
-  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC :: fields_out  !  klon,nbcf_out
-!$OMP THREADPRIVATE(fields_out)
-
-  REAL, ALLOCATABLE, DIMENSION(:,:), PUBLIC :: yfields_out !  knon,nbcf_out
-!$OMP THREADPRIVATE(yfields_out)
+  !$OMP THREADPRIVATE(nbcf_out)
+
+  ! Name of variables
+  CHARACTER(len = 25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname     ! coupling field short name for restart (?) and diagnostics
+  !$OMP THREADPRIVATE(cfname)
+
+  CHARACTER(len = 25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname_in  ! coupling field short name for restart (?) and diagnostics
+  !$OMP THREADPRIVATE(cfname_in)
+
+  CHARACTER(len = 25), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfname_out ! coupling field short name for restart (?) and diagnostics
+  !$OMP THREADPRIVATE(cfname_out)
+
+  CHARACTER(len = 15), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfunits_in  !  coupling field units for diagnostics
+  !$OMP THREADPRIVATE(cfunits_in)
+
+  CHARACTER(len = 15), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfunits_out !  coupling field units for diagnostics
+  !$OMP THREADPRIVATE(cfunits_out)
+
+  CHARACTER(len = 120), ALLOCATABLE, DIMENSION(:), PUBLIC :: cftext_in  ! coupling field long name for diagnostics
+  !$OMP THREADPRIVATE(cftext_in)
+
+  CHARACTER(len = 120), ALLOCATABLE, DIMENSION(:), PUBLIC :: cftext_out ! coupling field long name for diagnostics
+  !$OMP THREADPRIVATE(cftext_out)
+
+  CHARACTER(len = 5), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfmod1 ! model 1 (rreference) : LMDz
+  !$OMP THREADPRIVATE(cfmod1)
+
+  CHARACTER(len = 5), ALLOCATABLE, DIMENSION(:), PUBLIC :: cfmod2 ! model 2
+  !$OMP THREADPRIVATE(cfmod2)
+
+  CHARACTER(LEN = 20), ALLOCATABLE, DIMENSION(:), PUBLIC :: field_out_names
+  !$OMP THREADPRIVATE(field_out_names)
+
+  CHARACTER(LEN = 20), ALLOCATABLE, DIMENSION(:), PUBLIC :: field_in_names
+  !$OMP THREADPRIVATE(field_in_names)
+
+  REAL, ALLOCATABLE, DIMENSION(:, :), PUBLIC :: fields_in   !  klon,nbcf_in
+  !$OMP THREADPRIVATE(fields_in)
+
+  REAL, ALLOCATABLE, DIMENSION(:, :), PUBLIC :: yfields_in  !  knon,nbcf_in
+  !$OMP THREADPRIVATE(yfields_in)
+
+  REAL, ALLOCATABLE, DIMENSION(:, :), PUBLIC :: fields_out  !  klon,nbcf_out
+  !$OMP THREADPRIVATE(fields_out)
+
+  REAL, ALLOCATABLE, DIMENSION(:, :), PUBLIC :: yfields_out !  knon,nbcf_out
+  !$OMP THREADPRIVATE(yfields_out)
 
   TYPE, PUBLIC :: co2_trac_type
-     CHARACTER(len = 8) :: name       ! Tracer name in tracer.def
-     INTEGER            :: id         ! Index in total tracer list, tr_seri
-     CHARACTER(len=30)  :: file       ! File name
-     LOGICAL            :: cpl        ! True if this tracers is coupled from ORCHIDEE or PISCES. 
-                                      ! False if read from file.
-     INTEGER            :: updatefreq ! Frequence to inject in second
-     INTEGER            :: readstep   ! Actual time step to read in file
-     LOGICAL            :: updatenow  ! True if this tracer should be updated this time step
+    CHARACTER(len = 8) :: name       ! Tracer name in tracer.def
+    INTEGER :: id         ! Index in total tracer list, tr_seri
+    CHARACTER(len = 30) :: file       ! File name
+    LOGICAL :: cpl        ! True if this tracers is coupled from ORCHIDEE or PISCES.
+    ! False if read from file.
+    INTEGER :: updatefreq ! Frequence to inject in second
+    INTEGER :: readstep   ! Actual time step to read in file
+    LOGICAL :: updatenow  ! True if this tracer should be updated this time step
   END TYPE co2_trac_type
-  INTEGER,PARAMETER :: maxco2trac=5  ! Maximum number of different CO2 fluxes
+  INTEGER, PARAMETER :: maxco2trac = 5  ! Maximum number of different CO2 fluxes
   TYPE(co2_trac_type), DIMENSION(maxco2trac) :: co2trac
 
 CONTAINS
-  
+
   SUBROUTINE carbon_cycle_init()
     ! This SUBROUTINE is called from tracco2i_init, which is called from phytrac_init only at first timestep.
@@ -228,44 +228,44 @@
     IMPLICIT NONE
     INCLUDE "clesphys.h"
- 
-! Local variables
-    INTEGER               :: ierr
+
+    ! Local variables
+    INTEGER :: ierr
 
     IF (carbon_cycle_cpl) THEN
 
-       ierr=0
-
-       IF (.NOT.ALLOCATED(fco2_land)) ALLOCATE(fco2_land(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_nbp)) ALLOCATE(fco2_land_nbp(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nbp',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_nep)) ALLOCATE(fco2_land_nep(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nep',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_fLuc)) ALLOCATE(fco2_land_fLuc(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fLuc',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_fwoodharvest)) ALLOCATE(fco2_land_fwoodharvest(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fwoodharvest',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_fHarvest)) ALLOCATE(fco2_land_fHarvest(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fHarvest',1)
-
-       IF (.NOT.ALLOCATED(fco2_ff)) ALLOCATE(fco2_ff(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ff',1)
-
-       IF (.NOT.ALLOCATED(fco2_bb)) ALLOCATE(fco2_bb(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_bb',1)
-
-       IF (.NOT.ALLOCATED(fco2_ocean)) ALLOCATE(fco2_ocean(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean',1)
-
-       IF (.NOT.ALLOCATED(fco2_ocean_cor)) ALLOCATE(fco2_ocean_cor(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean_cor',1)
-
-       IF (.NOT.ALLOCATED(fco2_land_cor)) ALLOCATE(fco2_land_cor(klon), stat=ierr)
-       IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_cor',1)
+      ierr = 0
+
+      IF (.NOT.ALLOCATED(fco2_land)) ALLOCATE(fco2_land(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_nbp)) ALLOCATE(fco2_land_nbp(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nbp', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_nep)) ALLOCATE(fco2_land_nep(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_nep', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_fLuc)) ALLOCATE(fco2_land_fLuc(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fLuc', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_fwoodharvest)) ALLOCATE(fco2_land_fwoodharvest(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fwoodharvest', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_fHarvest)) ALLOCATE(fco2_land_fHarvest(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_fHarvest', 1)
+
+      IF (.NOT.ALLOCATED(fco2_ff)) ALLOCATE(fco2_ff(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ff', 1)
+
+      IF (.NOT.ALLOCATED(fco2_bb)) ALLOCATE(fco2_bb(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_bb', 1)
+
+      IF (.NOT.ALLOCATED(fco2_ocean)) ALLOCATE(fco2_ocean(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean', 1)
+
+      IF (.NOT.ALLOCATED(fco2_ocean_cor)) ALLOCATE(fco2_ocean_cor(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_ocean_cor', 1)
+
+      IF (.NOT.ALLOCATED(fco2_land_cor)) ALLOCATE(fco2_land_cor(klon), stat = ierr)
+      IF (ierr /= 0) CALL abort_physic('carbon_cycle_init', 'pb in allocation fco2_land_cor', 1)
 
     ENDIF
@@ -275,5 +275,5 @@
   SUBROUTINE infocfields_init
 
-!    USE control_mod, ONLY: planet_type
+    !    USE control_mod, ONLY: planet_type
     USE phys_cal_mod, ONLY: mth_cur
     USE mod_synchro_omp
@@ -283,262 +283,262 @@
     USE dimphy, ONLY: klon
     USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_iniprint, ONLY: lunout, prt_level
 
     IMPLICIT NONE
 
-!=======================================================================
-
-!   Authors: Patricia Cadule and Laurent Fairhead  
-!   -------
-
-!  Purpose and description:
-!  -----------------------
-
-! Infofields
-! this routine enables to define the field exchanges in both directions between
-! the atmospheric circulation model (LMDZ) and ORCHIDEE. In the future this
-! routing might apply to other models (e.g., NEMO, INCA, ...).
-! Therefore, currently with this routine, it is possible to define the coupling
-! fields only between LMDZ and ORCHIDEE.
-! The coupling_fields.def file enables to define the name of the exchanged
-! fields at the coupling interface.
-! field_in_names : the set of names of the exchanged fields in input to ORCHIDEE
-! (LMDZ to ORCHIDEE)
-! field_out_names : the set of names of the exchanged fields in output of
-! ORCHIDEE (ORCHIDEE to LMDZ)
-! n : the number of exchanged fields at th coupling interface
-! nb_fields_in : number of inputs fields to ORCHIDEE (LMDZ to ORCHIDEE)
-! nb_fields_out : number of ouput fields of ORCHIDEE (ORCHIDEE to LMDZ)
-
-! The syntax for coupling_fields.def is as follows:
-! IMPORTANT: each column entry must be separated from the previous one by 3
-! spaces and only that
-! field name         coupling          model 1         model 2         long_name
-!                    direction
-!   10char  -3spaces-  3char  -3spaces- 4char -3spaces- 4char -3spaces-  30char 
-
-! n
-! FIELD1 IN LMDZ ORC
-! ....
-! FIELD(j) IN LMDZ ORC
-! FIELD(j+1) OUT LMDZ ORC
-! ...
-! FIELDn OUT LMDZ ORC   
-
-!=======================================================================
-!   ... 22/12/2017 ....
-!-----------------------------------------------------------------------
-! Declarations
-
-  INCLUDE "clesphys.h"
-  INCLUDE "dimensions.h"
-  INCLUDE "iniprint.h"
-
-! Local variables
-
-  INTEGER :: iq,  ierr, stat, error
-
-  CHARACTER(LEN=20), ALLOCATABLE, DIMENSION(:), SAVE  :: cfname_root
-  CHARACTER(LEN=120), ALLOCATABLE, DIMENSION(:), SAVE :: cftext_root
-  CHARACTER(LEN=15), ALLOCATABLE, DIMENSION(:), SAVE  :: cfunits_root
-
-  CHARACTER(len=3), ALLOCATABLE, DIMENSION(:) :: cfintent_root
-  CHARACTER(len=5), ALLOCATABLE, DIMENSION(:) :: cfmod1_root
-  CHARACTER(len=5), ALLOCATABLE, DIMENSION(:) :: cfmod2_root
-
-  LOGICAL, ALLOCATABLE, DIMENSION(:), SAVE :: mask_in_root
-  LOGICAL, ALLOCATABLE, DIMENSION(:), SAVE :: mask_out_root
-
-  CHARACTER(len=*),parameter :: modname="infocfields"
-
-  CHARACTER(len=10),SAVE :: planet_type="earth"
-
-!-----------------------------------------------------------------------
-
-nbcf=0
-nbcf_in=0
-nbcf_out=0
-
-IF (planet_type=='earth') THEN
-
-    IF (is_mpi_root .AND. is_omp_root) THEN
-
-       IF (level_coupling_esm>0) THEN
-
-          OPEN(200,file='coupling_fields.def',form='formatted',status='old', iostat=ierr)
+    !=======================================================================
+
+    !   Authors: Patricia Cadule and Laurent Fairhead
+    !   -------
+
+    !  Purpose and description:
+    !  -----------------------
+
+    ! Infofields
+    ! this routine enables to define the field exchanges in both directions between
+    ! the atmospheric circulation model (LMDZ) and ORCHIDEE. In the future this
+    ! routing might apply to other models (e.g., NEMO, INCA, ...).
+    ! Therefore, currently with this routine, it is possible to define the coupling
+    ! fields only between LMDZ and ORCHIDEE.
+    ! The coupling_fields.def file enables to define the name of the exchanged
+    ! fields at the coupling interface.
+    ! field_in_names : the set of names of the exchanged fields in input to ORCHIDEE
+    ! (LMDZ to ORCHIDEE)
+    ! field_out_names : the set of names of the exchanged fields in output of
+    ! ORCHIDEE (ORCHIDEE to LMDZ)
+    ! n : the number of exchanged fields at th coupling interface
+    ! nb_fields_in : number of inputs fields to ORCHIDEE (LMDZ to ORCHIDEE)
+    ! nb_fields_out : number of ouput fields of ORCHIDEE (ORCHIDEE to LMDZ)
+
+    ! The syntax for coupling_fields.def is as follows:
+    ! IMPORTANT: each column entry must be separated from the previous one by 3
+    ! spaces and only that
+    ! field name         coupling          model 1         model 2         long_name
+    !                    direction
+    !   10char  -3spaces-  3char  -3spaces- 4char -3spaces- 4char -3spaces-  30char
+
+    ! n
+    ! FIELD1 IN LMDZ ORC
+    ! ....
+    ! FIELD(j) IN LMDZ ORC
+    ! FIELD(j+1) OUT LMDZ ORC
+    ! ...
+    ! FIELDn OUT LMDZ ORC
+
+    !=======================================================================
+    !   ... 22/12/2017 ....
+    !-----------------------------------------------------------------------
+    ! Declarations
+
+    INCLUDE "clesphys.h"
+    INCLUDE "dimensions.h"
+
+    ! Local variables
+
+    INTEGER :: iq, ierr, stat, error
+
+    CHARACTER(LEN = 20), ALLOCATABLE, DIMENSION(:), SAVE :: cfname_root
+    CHARACTER(LEN = 120), ALLOCATABLE, DIMENSION(:), SAVE :: cftext_root
+    CHARACTER(LEN = 15), ALLOCATABLE, DIMENSION(:), SAVE :: cfunits_root
+
+    CHARACTER(len = 3), ALLOCATABLE, DIMENSION(:) :: cfintent_root
+    CHARACTER(len = 5), ALLOCATABLE, DIMENSION(:) :: cfmod1_root
+    CHARACTER(len = 5), ALLOCATABLE, DIMENSION(:) :: cfmod2_root
+
+    LOGICAL, ALLOCATABLE, DIMENSION(:), SAVE :: mask_in_root
+    LOGICAL, ALLOCATABLE, DIMENSION(:), SAVE :: mask_out_root
+
+    CHARACTER(len = *), parameter :: modname = "infocfields"
+
+    CHARACTER(len = 10), SAVE :: planet_type = "earth"
+
+    !-----------------------------------------------------------------------
+
+    nbcf = 0
+    nbcf_in = 0
+    nbcf_out = 0
+
+    IF (planet_type=='earth') THEN
+
+      IF (is_mpi_root .AND. is_omp_root) THEN
+
+        IF (level_coupling_esm>0) THEN
+
+          OPEN(200, file = 'coupling_fields.def', form = 'formatted', status = 'old', iostat = ierr)
 
           IF (ierr==0) THEN
 
-             WRITE(lunout,*) trim(modname),': Open coupling_fields.def : ok'
-             READ(200,*) nbcf
-             WRITE(lunout,*) 'infocfields_mod.F90 --- nbcf=',nbcf
-             ALLOCATE(cfname_root(nbcf))
-             ALLOCATE(cfintent_root(nbcf))
-             ALLOCATE(cfmod1_root(nbcf))
-             ALLOCATE(cfmod2_root(nbcf))
-             ALLOCATE(cftext_root(nbcf))
-             ALLOCATE(cfunits_root(nbcf))
-             ALLOCATE(mask_in_root(nbcf))
-             ALLOCATE(mask_out_root(nbcf))
-
-             nbcf_in=0
-             nbcf_out=0
-
-             DO iq=1,nbcf
-                WRITE(lunout,*) 'infofields : field=',iq
-                READ(200,'(A15,3X,A3,3X,A5,3X,A5,3X,A120,3X,A15)',IOSTAT=ierr) &
-                   cfname_root(iq),cfintent_root(iq),cfmod1_root(iq),cfmod2_root(iq),cftext_root(iq),cfunits_root(iq)
-                cfname_root(iq)=TRIM(cfname_root(iq))
-                cfintent_root(iq)=TRIM(cfintent_root(iq))
-                cfmod1_root(iq)=TRIM(cfmod1_root(iq))
-                cfmod2_root(iq)=TRIM(cfmod2_root(iq))
-                cftext_root(iq)=TRIM(cftext_root(iq))
-                cfunits_root(iq)=TRIM(cfunits_root(iq))
-                WRITE(lunout,*) 'coupling field: ',cfname_root(iq), &  
-                               ', number: ',iq,', INTENT: ',cfintent_root(iq)
-                WRITE(lunout,*) 'coupling field: ',cfname_root(iq), & 
-                               ', number: ',iq,', model 1 (ref): ',cfmod1_root(iq),', model 2: ',cfmod2_root(iq)
-                WRITE(lunout,*) 'coupling field: ',cfname_root(iq), & 
-                               ', number: ',iq,', long name: ',cftext_root(iq),', units ',cfunits_root(iq)
-                IF (nbcf_in+nbcf_out<nbcf) THEN
-                  IF (cfintent_root(iq)/='OUT') THEN
-                    nbcf_in=nbcf_in+1
-                    mask_in_root(iq)=.TRUE.
-                    mask_out_root(iq)=.FALSE.
-                  ELSE IF (cfintent_root(iq)=='OUT') THEN
-                    nbcf_out=nbcf_out+1
-                    mask_in_root(iq)=.FALSE.
-                    mask_out_root(iq)=.TRUE.
-                  ENDIF
-                ELSE
-                  WRITE(lunout,*) 'abort_gcm --- nbcf    : ',nbcf
-                  WRITE(lunout,*) 'abort_gcm --- nbcf_in : ',nbcf_in
-                  WRITE(lunout,*) 'abort_gcm --- nbcf_out: ',nbcf_out
-                  CALL abort_physic('infocfields_init','Problem in the definition of the coupling fields',1)
-               ENDIF
-             ENDDO !DO iq=1,nbcf
+            WRITE(lunout, *) trim(modname), ': Open coupling_fields.def : ok'
+            READ(200, *) nbcf
+            WRITE(lunout, *) 'infocfields_mod.F90 --- nbcf=', nbcf
+            ALLOCATE(cfname_root(nbcf))
+            ALLOCATE(cfintent_root(nbcf))
+            ALLOCATE(cfmod1_root(nbcf))
+            ALLOCATE(cfmod2_root(nbcf))
+            ALLOCATE(cftext_root(nbcf))
+            ALLOCATE(cfunits_root(nbcf))
+            ALLOCATE(mask_in_root(nbcf))
+            ALLOCATE(mask_out_root(nbcf))
+
+            nbcf_in = 0
+            nbcf_out = 0
+
+            DO iq = 1, nbcf
+              WRITE(lunout, *) 'infofields : field=', iq
+              READ(200, '(A15,3X,A3,3X,A5,3X,A5,3X,A120,3X,A15)', IOSTAT = ierr) &
+                      cfname_root(iq), cfintent_root(iq), cfmod1_root(iq), cfmod2_root(iq), cftext_root(iq), cfunits_root(iq)
+              cfname_root(iq) = TRIM(cfname_root(iq))
+              cfintent_root(iq) = TRIM(cfintent_root(iq))
+              cfmod1_root(iq) = TRIM(cfmod1_root(iq))
+              cfmod2_root(iq) = TRIM(cfmod2_root(iq))
+              cftext_root(iq) = TRIM(cftext_root(iq))
+              cfunits_root(iq) = TRIM(cfunits_root(iq))
+              WRITE(lunout, *) 'coupling field: ', cfname_root(iq), &
+                      ', number: ', iq, ', INTENT: ', cfintent_root(iq)
+              WRITE(lunout, *) 'coupling field: ', cfname_root(iq), &
+                      ', number: ', iq, ', model 1 (ref): ', cfmod1_root(iq), ', model 2: ', cfmod2_root(iq)
+              WRITE(lunout, *) 'coupling field: ', cfname_root(iq), &
+                      ', number: ', iq, ', long name: ', cftext_root(iq), ', units ', cfunits_root(iq)
+              IF (nbcf_in + nbcf_out<nbcf) THEN
+                IF (cfintent_root(iq)/='OUT') THEN
+                  nbcf_in = nbcf_in + 1
+                  mask_in_root(iq) = .TRUE.
+                  mask_out_root(iq) = .FALSE.
+                ELSE IF (cfintent_root(iq)=='OUT') THEN
+                  nbcf_out = nbcf_out + 1
+                  mask_in_root(iq) = .FALSE.
+                  mask_out_root(iq) = .TRUE.
+                ENDIF
+              ELSE
+                WRITE(lunout, *) 'abort_gcm --- nbcf    : ', nbcf
+                WRITE(lunout, *) 'abort_gcm --- nbcf_in : ', nbcf_in
+                WRITE(lunout, *) 'abort_gcm --- nbcf_out: ', nbcf_out
+                CALL abort_physic('infocfields_init', 'Problem in the definition of the coupling fields', 1)
+              ENDIF
+            ENDDO !DO iq=1,nbcf
           ELSE
-             WRITE(lunout,*) trim(modname),': infocfields_mod.F90 --- Problem in opening coupling_fields.def'
-             WRITE(lunout,*) trim(modname),': infocfields_mod.F90 --- WARNING using defaut values'
+            WRITE(lunout, *) trim(modname), ': infocfields_mod.F90 --- Problem in opening coupling_fields.def'
+            WRITE(lunout, *) trim(modname), ': infocfields_mod.F90 --- WARNING using defaut values'
           ENDIF ! ierr
           CLOSE(200)
 
-       ENDIF ! level_coupling_esm
-
-    ENDIF !   (is_mpi_root .AND. is_omp_root)
-!$OMP BARRIER
-
-    CALL bcast(nbcf)
-    CALL bcast(nbcf_in)
-    CALL bcast(nbcf_out)
-
-    WRITE(lunout,*) 'infocfields_mod.F90 --- nbcf    =',nbcf
-    WRITE(lunout,*) 'infocfields_mod.F90 --- nbcf_in =',nbcf_in
-    WRITE(lunout,*) 'infocfields_mod.F90 --- nbcf_out=',nbcf_out
-
-    ALLOCATE(cfname(nbcf))
-    ALLOCATE(cfname_in(nbcf_in))
-    ALLOCATE(cftext_in(nbcf_in))
-    ALLOCATE(cfname_out(nbcf_out))
-    ALLOCATE(cftext_out(nbcf_out))
-    ALLOCATE(cfmod1(nbcf))
-    ALLOCATE(cfmod2(nbcf))
-    ALLOCATE(cfunits_in(nbcf_in))
-    ALLOCATE(cfunits_out(nbcf_out))
-       
-    IF (is_mpi_root .AND. is_omp_root) THEN
-
-        IF (nbcf>0)     cfname=cfname_root
-        IF (nbcf_in>0)  cfname_in=PACK(cfname_root,mask_in_root)
-        IF (nbcf_out>0) cfname_out=PACK(cfname_root,mask_out_root)
-        IF (nbcf_in>0)  cftext_in=PACK(cftext_root,mask_in_root)
-        IF (nbcf_out>0) cftext_out=PACK(cftext_root,mask_out_root)
-        IF (nbcf>0)     cfmod1=cfmod1_root
-        IF (nbcf>0)     cfmod2=cfmod2_root
-        IF (nbcf_in>0)  cfunits_in=PACK(cfunits_root,mask_in_root)
-        IF (nbcf_out>0) cfunits_out=PACK(cfunits_root,mask_out_root)
-
-        nbcf_in_orc=0
-        nbcf_in_nemo=0
-        nbcf_in_inca=0
-        nbcf_in_ant=0
-
-        DO iq=1,nbcf
-            IF (cfmod1(iq) == "ORC")  nbcf_in_orc  = nbcf_in_orc  + 1  
-            IF (cfmod1(iq) == "NEMO") nbcf_in_nemo = nbcf_in_nemo + 1  
-            IF (cfmod1(iq) == "INCA") nbcf_in_inca = nbcf_in_inca + 1
-            IF (cfmod1(iq) == "ALL")  nbcf_in_orc  = nbcf_in_orc  + 1  ! ALL = ORC/NEMO/INCA
-            IF (cfmod1(iq) == "ALL")  nbcf_in_nemo = nbcf_in_nemo + 1  ! ALL = ORC/NEMO/INCA 
-            IF (cfmod1(iq) == "ALL")  nbcf_in_inca = nbcf_in_inca + 1  ! ALL = ORC/NEMO/INCA 
-            IF (cfmod1(iq) == "ANT")  nbcf_in_ant  = nbcf_in_ant  + 1  
+        ENDIF ! level_coupling_esm
+
+      ENDIF !   (is_mpi_root .AND. is_omp_root)
+      !$OMP BARRIER
+
+      CALL bcast(nbcf)
+      CALL bcast(nbcf_in)
+      CALL bcast(nbcf_out)
+
+      WRITE(lunout, *) 'infocfields_mod.F90 --- nbcf    =', nbcf
+      WRITE(lunout, *) 'infocfields_mod.F90 --- nbcf_in =', nbcf_in
+      WRITE(lunout, *) 'infocfields_mod.F90 --- nbcf_out=', nbcf_out
+
+      ALLOCATE(cfname(nbcf))
+      ALLOCATE(cfname_in(nbcf_in))
+      ALLOCATE(cftext_in(nbcf_in))
+      ALLOCATE(cfname_out(nbcf_out))
+      ALLOCATE(cftext_out(nbcf_out))
+      ALLOCATE(cfmod1(nbcf))
+      ALLOCATE(cfmod2(nbcf))
+      ALLOCATE(cfunits_in(nbcf_in))
+      ALLOCATE(cfunits_out(nbcf_out))
+
+      IF (is_mpi_root .AND. is_omp_root) THEN
+
+        IF (nbcf>0)     cfname = cfname_root
+        IF (nbcf_in>0)  cfname_in = PACK(cfname_root, mask_in_root)
+        IF (nbcf_out>0) cfname_out = PACK(cfname_root, mask_out_root)
+        IF (nbcf_in>0)  cftext_in = PACK(cftext_root, mask_in_root)
+        IF (nbcf_out>0) cftext_out = PACK(cftext_root, mask_out_root)
+        IF (nbcf>0)     cfmod1 = cfmod1_root
+        IF (nbcf>0)     cfmod2 = cfmod2_root
+        IF (nbcf_in>0)  cfunits_in = PACK(cfunits_root, mask_in_root)
+        IF (nbcf_out>0) cfunits_out = PACK(cfunits_root, mask_out_root)
+
+        nbcf_in_orc = 0
+        nbcf_in_nemo = 0
+        nbcf_in_inca = 0
+        nbcf_in_ant = 0
+
+        DO iq = 1, nbcf
+          IF (cfmod1(iq) == "ORC")  nbcf_in_orc = nbcf_in_orc + 1
+          IF (cfmod1(iq) == "NEMO") nbcf_in_nemo = nbcf_in_nemo + 1
+          IF (cfmod1(iq) == "INCA") nbcf_in_inca = nbcf_in_inca + 1
+          IF (cfmod1(iq) == "ALL")  nbcf_in_orc = nbcf_in_orc + 1  ! ALL = ORC/NEMO/INCA
+          IF (cfmod1(iq) == "ALL")  nbcf_in_nemo = nbcf_in_nemo + 1  ! ALL = ORC/NEMO/INCA
+          IF (cfmod1(iq) == "ALL")  nbcf_in_inca = nbcf_in_inca + 1  ! ALL = ORC/NEMO/INCA
+          IF (cfmod1(iq) == "ANT")  nbcf_in_ant = nbcf_in_ant + 1
         ENDDO
 
-    ENDIF !   (is_mpi_root .AND. is_omp_root)
-!$OMP BARRIER
-
-    CALL bcast(nbcf_in_orc)
-    CALL bcast(nbcf_in_nemo)
-    CALL bcast(nbcf_in_inca)
-    CALL bcast(nbcf_in_ant)
-
-    WRITE(lunout,*) 'nbcf_in_orc  =',nbcf_in_orc
-    WRITE(lunout,*) 'nbcf_in_nemo =',nbcf_in_nemo
-    WRITE(lunout,*) 'nbcf_in_inca =',nbcf_in_inca
-    WRITE(lunout,*) 'nbcf_in_ant  =',nbcf_in_ant
-
-    IF (nbcf_in>0) THEN
-        DO iq=1,nbcf_in
+      ENDIF !   (is_mpi_root .AND. is_omp_root)
+      !$OMP BARRIER
+
+      CALL bcast(nbcf_in_orc)
+      CALL bcast(nbcf_in_nemo)
+      CALL bcast(nbcf_in_inca)
+      CALL bcast(nbcf_in_ant)
+
+      WRITE(lunout, *) 'nbcf_in_orc  =', nbcf_in_orc
+      WRITE(lunout, *) 'nbcf_in_nemo =', nbcf_in_nemo
+      WRITE(lunout, *) 'nbcf_in_inca =', nbcf_in_inca
+      WRITE(lunout, *) 'nbcf_in_ant  =', nbcf_in_ant
+
+      IF (nbcf_in>0) THEN
+        DO iq = 1, nbcf_in
           CALL bcast(cfname_in(iq))
           CALL bcast(cftext_in(iq))
           CALL bcast(cfunits_in(iq))
         ENDDO
-    ENDIF
-
-    IF (nbcf_out>0) THEN
-        DO iq=1,nbcf_out
+      ENDIF
+
+      IF (nbcf_out>0) THEN
+        DO iq = 1, nbcf_out
           CALL bcast(cfname_out(iq))
           CALL bcast(cftext_out(iq))
           CALL bcast(cfunits_out(iq))
         ENDDO
-    ENDIF
-
-    IF (nbcf>0) THEN
-        DO iq=1,nbcf
+      ENDIF
+
+      IF (nbcf>0) THEN
+        DO iq = 1, nbcf
           CALL bcast(cfmod1(iq))
           CALL bcast(cfmod2(iq))
         ENDDO
-    ENDIF
-
-    IF (nbcf_in>0)  WRITE(lunout,*)'infocfields_mod --- cfname_in: ',cfname_in
-    IF (nbcf_out>0) WRITE(lunout,*)'infocfields_mod --- cfname_out: ',cfname_out
-
-    IF (nbcf_in>0)  WRITE(lunout,*)'infocfields_mod --- cftext_in: ',cftext_in
-    IF (nbcf_out>0) WRITE(lunout,*)'infocfields_mod --- cftext_out: ',cftext_out
-
-    IF (nbcf>0) WRITE(lunout,*)'infocfields_mod --- cfmod1: ',cfmod1
-    IF (nbcf>0) WRITE(lunout,*)'infocfields_mod --- cfmod2: ',cfmod2
-
-    IF (nbcf_in>0)  WRITE(lunout,*)'infocfunits_mod --- cfunits_in: ',cfunits_in
-    IF (nbcf_out>0) WRITE(lunout,*)'infocfunits_mod --- cfunits_out: ',cfunits_out
-
-    IF (nbcf_in>0)  WRITE(*,*)'infocfields_init --- number of fields in to LMDZ: ',nbcf_in
-    IF (nbcf_out>0) WRITE(*,*)'infocfields_init --- number of fields out of LMDZ: ',nbcf_out
-
- ELSE
- ! Default values for other planets
-    nbcf=0 
-    nbcf_in=0
-    nbcf_out=0
- ENDIF ! planet_type
-
- ALLOCATE(fields_in(klon,nbcf_in),stat=error)
- IF (error /= 0)  CALL abort_physic(modname,'Pb in allocation fields_in',1)
- ALLOCATE(yfields_in(klon,nbcf_in),stat=error)
- IF (error /= 0)  CALL abort_physic(modname,'Pb in allocation yfields_in',1)
- ALLOCATE(fields_out(klon,nbcf_out),stat=error)
- IF (error /= 0)  CALL abort_physic(modname,'Pb in allocation fields_out',1)
- ALLOCATE(yfields_out(klon,nbcf_out),stat=error)
- IF (error /= 0)  CALL abort_physic(modname,'Pb in allocation yfields_out',1)
-
-END SUBROUTINE infocfields_init
+      ENDIF
+
+      IF (nbcf_in>0)  WRITE(lunout, *)'infocfields_mod --- cfname_in: ', cfname_in
+      IF (nbcf_out>0) WRITE(lunout, *)'infocfields_mod --- cfname_out: ', cfname_out
+
+      IF (nbcf_in>0)  WRITE(lunout, *)'infocfields_mod --- cftext_in: ', cftext_in
+      IF (nbcf_out>0) WRITE(lunout, *)'infocfields_mod --- cftext_out: ', cftext_out
+
+      IF (nbcf>0) WRITE(lunout, *)'infocfields_mod --- cfmod1: ', cfmod1
+      IF (nbcf>0) WRITE(lunout, *)'infocfields_mod --- cfmod2: ', cfmod2
+
+      IF (nbcf_in>0)  WRITE(lunout, *)'infocfunits_mod --- cfunits_in: ', cfunits_in
+      IF (nbcf_out>0) WRITE(lunout, *)'infocfunits_mod --- cfunits_out: ', cfunits_out
+
+      IF (nbcf_in>0)  WRITE(*, *)'infocfields_init --- number of fields in to LMDZ: ', nbcf_in
+      IF (nbcf_out>0) WRITE(*, *)'infocfields_init --- number of fields out of LMDZ: ', nbcf_out
+
+    ELSE
+      ! Default values for other planets
+      nbcf = 0
+      nbcf_in = 0
+      nbcf_out = 0
+    ENDIF ! planet_type
+
+    ALLOCATE(fields_in(klon, nbcf_in), stat = error)
+    IF (error /= 0)  CALL abort_physic(modname, 'Pb in allocation fields_in', 1)
+    ALLOCATE(yfields_in(klon, nbcf_in), stat = error)
+    IF (error /= 0)  CALL abort_physic(modname, 'Pb in allocation yfields_in', 1)
+    ALLOCATE(fields_out(klon, nbcf_out), stat = error)
+    IF (error /= 0)  CALL abort_physic(modname, 'Pb in allocation fields_out', 1)
+    ALLOCATE(yfields_out(klon, nbcf_out), stat = error)
+    IF (error /= 0)  CALL abort_physic(modname, 'Pb in allocation yfields_out', 1)
+
+  END SUBROUTINE infocfields_init
 
 END MODULE carbon_cycle_mod
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/create_limit_unstruct_mod.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/create_limit_unstruct_mod.F90	(revision 5117)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/create_limit_unstruct_mod.F90	(revision 5118)
@@ -1,7 +1,7 @@
 MODULE create_limit_unstruct_mod
-    PRIVATE
-    INTEGER, PARAMETER                             :: lmdep=12
-
-    PUBLIC create_limit_unstruct
+  PRIVATE
+  INTEGER, PARAMETER :: lmdep = 12
+
+  PUBLIC create_limit_unstruct
 
 CONTAINS
@@ -9,311 +9,307 @@
 
   SUBROUTINE create_limit_unstruct
-  USE dimphy
-  USE lmdz_xios
-  USE ioipsl,             ONLY: ioget_year_len
-  USE time_phylmdz_mod, ONLY: annee_ref
-  USE indice_sol_mod
-  USE phys_state_var_mod
-  USE lmdz_phys_para
-  USE lmdz_abort_physic, ONLY: abort_physic
-  IMPLICIT NONE
-    INCLUDE "iniprint.h"
-    REAL,    DIMENSION(:,:),ALLOCATABLE            :: sic
-    REAL,    DIMENSION(:,:),ALLOCATABLE            :: sst
-    REAL,    DIMENSION(klon,lmdep)                 :: rugos
-    REAL,    DIMENSION(klon,lmdep)                 :: albedo
-    REAL,    DIMENSION(:,:),ALLOCATABLE            :: sic_mpi
-    REAL,    DIMENSION(:,:),ALLOCATABLE            :: sst_mpi
-    REAL,    DIMENSION(klon_mpi,lmdep)             :: rugos_mpi
-    REAL,    DIMENSION(klon_mpi,lmdep)             :: albedo_mpi
-    INTEGER                                        :: ndays
-    REAL                                           :: fi_ice(klon)
-    REAL, ALLOCATABLE                              :: sic_year(:,:)
-    REAL, ALLOCATABLE                              :: sst_year(:,:)
-    REAL, ALLOCATABLE                              :: rugos_year(:,:)
-    REAL, ALLOCATABLE                              :: albedo_year(:,:)
-    REAL, ALLOCATABLE                              :: pctsrf_t(:,:,:)
-    REAL, ALLOCATABLE                              :: phy_bil(:,:)
-    REAL, ALLOCATABLE                              :: sst_year_mpi(:,:)
-    REAL, ALLOCATABLE                              :: rugos_year_mpi(:,:)
-    REAL, ALLOCATABLE                              :: albedo_year_mpi(:,:)
-    REAL, ALLOCATABLE                              :: pctsrf_t_mpi(:,:,:)
-    REAL, ALLOCATABLE                              :: phy_bil_mpi(:,:)
-    INTEGER :: l,k
+    USE dimphy
+    USE lmdz_xios
+    USE ioipsl, ONLY: ioget_year_len
+    USE time_phylmdz_mod, ONLY: annee_ref
+    USE indice_sol_mod
+    USE phys_state_var_mod
+    USE lmdz_phys_para
+    USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    IMPLICIT NONE
+    REAL, DIMENSION(:, :), ALLOCATABLE :: sic
+    REAL, DIMENSION(:, :), ALLOCATABLE :: sst
+    REAL, DIMENSION(klon, lmdep) :: rugos
+    REAL, DIMENSION(klon, lmdep) :: albedo
+    REAL, DIMENSION(:, :), ALLOCATABLE :: sic_mpi
+    REAL, DIMENSION(:, :), ALLOCATABLE :: sst_mpi
+    REAL, DIMENSION(klon_mpi, lmdep) :: rugos_mpi
+    REAL, DIMENSION(klon_mpi, lmdep) :: albedo_mpi
+    INTEGER :: ndays
+    REAL :: fi_ice(klon)
+    REAL, ALLOCATABLE :: sic_year(:, :)
+    REAL, ALLOCATABLE :: sst_year(:, :)
+    REAL, ALLOCATABLE :: rugos_year(:, :)
+    REAL, ALLOCATABLE :: albedo_year(:, :)
+    REAL, ALLOCATABLE :: pctsrf_t(:, :, :)
+    REAL, ALLOCATABLE :: phy_bil(:, :)
+    REAL, ALLOCATABLE :: sst_year_mpi(:, :)
+    REAL, ALLOCATABLE :: rugos_year_mpi(:, :)
+    REAL, ALLOCATABLE :: albedo_year_mpi(:, :)
+    REAL, ALLOCATABLE :: pctsrf_t_mpi(:, :, :)
+    REAL, ALLOCATABLE :: phy_bil_mpi(:, :)
+    INTEGER :: l, k
     INTEGER :: nbad
-    INTEGER :: sic_time_axis_size 
+    INTEGER :: sic_time_axis_size
     INTEGER :: sst_time_axis_size
-    CHARACTER(LEN=99)                  :: mess            ! error message
-    
-     
-    ndays=ioget_year_len(annee_ref)
-    
-    IF (is_omp_master) CALL xios_get_axis_attr("time_sic",n_glo=sic_time_axis_size)
+    CHARACTER(LEN = 99) :: mess            ! error message
+
+    ndays = ioget_year_len(annee_ref)
+
+    IF (is_omp_master) CALL xios_get_axis_attr("time_sic", n_glo = sic_time_axis_size)
     CALL bcast_omp(sic_time_axis_size)
-    ALLOCATE(sic_mpi(klon_mpi,sic_time_axis_size))
-    ALLOCATE(sic(klon,sic_time_axis_size))
-    
-    
-    IF (is_omp_master) CALL xios_get_axis_attr("time_sst",n_glo=sst_time_axis_size)
+    ALLOCATE(sic_mpi(klon_mpi, sic_time_axis_size))
+    ALLOCATE(sic(klon, sic_time_axis_size))
+
+    IF (is_omp_master) CALL xios_get_axis_attr("time_sst", n_glo = sst_time_axis_size)
     CALL bcast_omp(sst_time_axis_size)
-    ALLOCATE(sst_mpi(klon_mpi,sst_time_axis_size))
-    ALLOCATE(sst(klon,sst_time_axis_size))
-    
+    ALLOCATE(sst_mpi(klon_mpi, sst_time_axis_size))
+    ALLOCATE(sst(klon, sst_time_axis_size))
+
     IF (is_omp_master) THEN
-      CALL xios_recv_field("sic_limit",sic_mpi)
-      CALL xios_recv_field("sst_limit",sst_mpi)
-      CALL xios_recv_field("rugos_limit",rugos_mpi)
-      CALL xios_recv_field("albedo_limit",albedo_mpi)
-    ENDIF
-    CALL scatter_omp(sic_mpi,sic)
-    CALL scatter_omp(sst_mpi,sst)
-    CALL scatter_omp(rugos_mpi,rugos)
-    CALL scatter_omp(albedo_mpi,albedo)
-    
-    ALLOCATE(sic_year(klon,ndays))
-    ALLOCATE(sst_year(klon,ndays))
-    ALLOCATE(rugos_year(klon,ndays))
-    ALLOCATE(albedo_year(klon,ndays))
-    ALLOCATE(pctsrf_t(klon,nbsrf,ndays))
-    ALLOCATE(phy_bil(klon,ndays)); phy_bil=0.0
-
-
-! sic
+      CALL xios_recv_field("sic_limit", sic_mpi)
+      CALL xios_recv_field("sst_limit", sst_mpi)
+      CALL xios_recv_field("rugos_limit", rugos_mpi)
+      CALL xios_recv_field("albedo_limit", albedo_mpi)
+    ENDIF
+    CALL scatter_omp(sic_mpi, sic)
+    CALL scatter_omp(sst_mpi, sst)
+    CALL scatter_omp(rugos_mpi, rugos)
+    CALL scatter_omp(albedo_mpi, albedo)
+
+    ALLOCATE(sic_year(klon, ndays))
+    ALLOCATE(sst_year(klon, ndays))
+    ALLOCATE(rugos_year(klon, ndays))
+    ALLOCATE(albedo_year(klon, ndays))
+    ALLOCATE(pctsrf_t(klon, nbsrf, ndays))
+    ALLOCATE(phy_bil(klon, ndays)); phy_bil = 0.0
+
+
+    ! sic
     IF (sic_time_axis_size==lmdep) THEN
-      CALL time_interpolation(ndays,sic,'gregorian',sic_year)
+      CALL time_interpolation(ndays, sic, 'gregorian', sic_year)
     ELSE IF (sic_time_axis_size==ndays) THEN
-      sic_year=sic
+      sic_year = sic
     ELSE
-      WRITE(mess,*) 'sic time axis is nor montly, nor daily. sic time interpolation ',&
-                    'is requiered but is not currently managed'
-      CALL abort_physic('create_limit_unstruct',TRIM(mess),1)
-    ENDIF
-    
-    sic_year(:,:)=sic_year(:,:)/100.  ! convert percent to fraction
-    WHERE(sic_year(:,:)>1.0) sic_year(:,:)=1.0    ! Some fractions have some time large negative values
-    WHERE(sic_year(:,:)<0.0) sic_year(:,:)=0.0    ! probably better to apply alse this filter before horizontal interpolation
-    
-! sst
+      WRITE(mess, *) 'sic time axis is nor montly, nor daily. sic time interpolation ', &
+              'is requiered but is not currently managed'
+      CALL abort_physic('create_limit_unstruct', TRIM(mess), 1)
+    ENDIF
+
+    sic_year(:, :) = sic_year(:, :) / 100.  ! convert percent to fraction
+    WHERE(sic_year(:, :)>1.0) sic_year(:, :) = 1.0    ! Some fractions have some time large negative values
+    WHERE(sic_year(:, :)<0.0) sic_year(:, :) = 0.0    ! probably better to apply alse this filter before horizontal interpolation
+
+    ! sst
     IF (sst_time_axis_size==lmdep) THEN
-      CALL time_interpolation(ndays,sst,'gregorian',sst_year)
+      CALL time_interpolation(ndays, sst, 'gregorian', sst_year)
     ELSE IF (sst_time_axis_size==ndays) THEN
-      sst_year=sst
+      sst_year = sst
     ELSE
-      WRITE(mess,*)'sic time axis is nor montly, nor daily. sic time interpolation ',&
-                   'is requiered but is not currently managed'
-      CALL abort_physic('create_limit_unstruct',TRIM(mess),1)
-    ENDIF
-    WHERE(sst_year(:,:)<271.38) sst_year(:,:)=271.38
-
-
-! rugos    
-    DO l=1, lmdep
-      WHERE(NINT(zmasq(:))/=1) rugos(:,l)=0.001
+      WRITE(mess, *)'sic time axis is nor montly, nor daily. sic time interpolation ', &
+              'is requiered but is not currently managed'
+      CALL abort_physic('create_limit_unstruct', TRIM(mess), 1)
+    ENDIF
+    WHERE(sst_year(:, :)<271.38) sst_year(:, :) = 271.38
+
+
+    ! rugos
+    DO l = 1, lmdep
+      WHERE(NINT(zmasq(:))/=1) rugos(:, l) = 0.001
     ENDDO
-    CALL time_interpolation(ndays,rugos,'360_day',rugos_year)
-
-! albedo    
-    CALL time_interpolation(ndays,albedo,'360_day',albedo_year)
-
-
-    DO k=1,ndays
-      fi_ice=sic_year(:,k)
-      WHERE(fi_ice>=1.0  ) fi_ice=1.0
-      WHERE(fi_ice<EPSFRA) fi_ice=0.0
-      pctsrf_t(:,is_ter,k)=pctsrf(:,is_ter)       ! land soil
-      pctsrf_t(:,is_lic,k)=pctsrf(:,is_lic)       ! land ice
-
-!!     IF (icefile==trim(fcpldsic)) THEN           ! SIC=pICE*(1-LIC-TER)
-!!        pctsrf_t(:,is_sic,k)=fi_ice(:)*(1.-pctsrf(:,is_lic)-pctsrf(:,is_ter))
-!!     ELSE IF (icefile==trim(fhistsic)) THEN      ! SIC=pICE
-!!        pctsrf_t(:,is_sic,k)=fi_ice(:)
-!!     ELSE ! icefile==famipsic                    ! SIC=pICE-LIC
-        pctsrf_t(:,is_sic,k)=fi_ice-pctsrf_t(:,is_lic,k)
-!     END IF
-      WHERE(pctsrf_t(:,is_sic,k)<=0) pctsrf_t(:,is_sic,k)=0.
-      WHERE(1.0-zmasq<EPSFRA)
-        pctsrf_t(:,is_sic,k)=0.0
-        pctsrf_t(:,is_oce,k)=0.0
+    CALL time_interpolation(ndays, rugos, '360_day', rugos_year)
+
+    ! albedo
+    CALL time_interpolation(ndays, albedo, '360_day', albedo_year)
+
+    DO k = 1, ndays
+      fi_ice = sic_year(:, k)
+      WHERE(fi_ice>=1.0) fi_ice = 1.0
+      WHERE(fi_ice<EPSFRA) fi_ice = 0.0
+      pctsrf_t(:, is_ter, k) = pctsrf(:, is_ter)       ! land soil
+      pctsrf_t(:, is_lic, k) = pctsrf(:, is_lic)       ! land ice
+
+      !!     IF (icefile==trim(fcpldsic)) THEN           ! SIC=pICE*(1-LIC-TER)
+      !!        pctsrf_t(:,is_sic,k)=fi_ice(:)*(1.-pctsrf(:,is_lic)-pctsrf(:,is_ter))
+      !!     ELSE IF (icefile==trim(fhistsic)) THEN      ! SIC=pICE
+      !!        pctsrf_t(:,is_sic,k)=fi_ice(:)
+      !!     ELSE ! icefile==famipsic                    ! SIC=pICE-LIC
+      pctsrf_t(:, is_sic, k) = fi_ice - pctsrf_t(:, is_lic, k)
+      !     END IF
+      WHERE(pctsrf_t(:, is_sic, k)<=0) pctsrf_t(:, is_sic, k) = 0.
+      WHERE(1.0 - zmasq<EPSFRA)
+        pctsrf_t(:, is_sic, k) = 0.0
+        pctsrf_t(:, is_oce, k) = 0.0
       ELSEWHERE
-        WHERE(pctsrf_t(:,is_sic,k)>=1.0-zmasq)
-          pctsrf_t(:,is_sic,k)=1.0-zmasq
-          pctsrf_t(:,is_oce,k)=0.0
+        WHERE(pctsrf_t(:, is_sic, k)>=1.0 - zmasq)
+          pctsrf_t(:, is_sic, k) = 1.0 - zmasq
+          pctsrf_t(:, is_oce, k) = 0.0
         ELSEWHERE
-          pctsrf_t(:,is_oce,k)=1.0-zmasq-pctsrf_t(:,is_sic,k)
-          WHERE(pctsrf_t(:,is_oce,k)<EPSFRA)
-             pctsrf_t(:,is_oce,k)=0.0
-             pctsrf_t(:,is_sic,k)=1.0-zmasq
+          pctsrf_t(:, is_oce, k) = 1.0 - zmasq - pctsrf_t(:, is_sic, k)
+          WHERE(pctsrf_t(:, is_oce, k)<EPSFRA)
+            pctsrf_t(:, is_oce, k) = 0.0
+            pctsrf_t(:, is_sic, k) = 1.0 - zmasq
           END WHERE
         END WHERE
       END WHERE
-      nbad=COUNT(pctsrf_t(:,is_oce,k)<0.0)
-      IF(nbad>0) WRITE(lunout,*) 'pb sous maille pour nb point = ',nbad
-      nbad=COUNT(abs(sum(pctsrf_t(:,:,k),dim=2)-1.0)>EPSFRA)
-      IF(nbad>0) WRITE(lunout,*) 'pb sous surface pour nb points = ',nbad
+      nbad = COUNT(pctsrf_t(:, is_oce, k)<0.0)
+      IF(nbad>0) WRITE(lunout, *) 'pb sous maille pour nb point = ', nbad
+      nbad = COUNT(abs(sum(pctsrf_t(:, :, k), dim = 2) - 1.0)>EPSFRA)
+      IF(nbad>0) WRITE(lunout, *) 'pb sous surface pour nb points = ', nbad
     END DO
-    
-    ALLOCATE(sst_year_mpi(klon_mpi,ndays))
-    ALLOCATE(rugos_year_mpi(klon_mpi,ndays))
-    ALLOCATE(albedo_year_mpi(klon_mpi,ndays))
-    ALLOCATE(pctsrf_t_mpi(klon_mpi,nbsrf,ndays))
-    ALLOCATE(phy_bil_mpi(klon_mpi,ndays))
-    
-    CALL gather_omp(pctsrf_t   , pctsrf_t_mpi)
-    CALL gather_omp(sst_year   , sst_year_mpi)
-    CALL gather_omp(phy_bil    , phy_bil_mpi)
+
+    ALLOCATE(sst_year_mpi(klon_mpi, ndays))
+    ALLOCATE(rugos_year_mpi(klon_mpi, ndays))
+    ALLOCATE(albedo_year_mpi(klon_mpi, ndays))
+    ALLOCATE(pctsrf_t_mpi(klon_mpi, nbsrf, ndays))
+    ALLOCATE(phy_bil_mpi(klon_mpi, ndays))
+
+    CALL gather_omp(pctsrf_t, pctsrf_t_mpi)
+    CALL gather_omp(sst_year, sst_year_mpi)
+    CALL gather_omp(phy_bil, phy_bil_mpi)
     CALL gather_omp(albedo_year, albedo_year_mpi)
-    CALL gather_omp(rugos_year , rugos_year_mpi)
+    CALL gather_omp(rugos_year, rugos_year_mpi)
 
     IF (is_omp_master) THEN
-      CALL xios_send_field("foce_limout",pctsrf_t_mpi(:,is_oce,:))
-      CALL xios_send_field("fsic_limout",pctsrf_t_mpi(:,is_sic,:))
-      CALL xios_send_field("fter_limout",pctsrf_t_mpi(:,is_ter,:))
-      CALL xios_send_field("flic_limout",pctsrf_t_mpi(:,is_lic,:))
+      CALL xios_send_field("foce_limout", pctsrf_t_mpi(:, is_oce, :))
+      CALL xios_send_field("fsic_limout", pctsrf_t_mpi(:, is_sic, :))
+      CALL xios_send_field("fter_limout", pctsrf_t_mpi(:, is_ter, :))
+      CALL xios_send_field("flic_limout", pctsrf_t_mpi(:, is_lic, :))
       CALL xios_send_field("sst_limout", sst_year_mpi)
-      CALL xios_send_field("bils_limout",phy_bil_mpi)
-      CALL xios_send_field("alb_limout", albedo_year_mpi) 
-      CALL xios_send_field("rug_limout", rugos_year_mpi) 
+      CALL xios_send_field("bils_limout", phy_bil_mpi)
+      CALL xios_send_field("alb_limout", albedo_year_mpi)
+      CALL xios_send_field("rug_limout", rugos_year_mpi)
     ENDIF
   END SUBROUTINE create_limit_unstruct
-  
-  
-  SUBROUTINE time_interpolation(ndays,field_in,calendar,field_out)
-  USE lmdz_libmath_pch, ONLY: pchsp_95, pchfe_95
-  USE lmdz_arth, ONLY: arth
-  USE dimphy, ONLY: klon
-  USE ioipsl,             ONLY: ioget_year_len
-  USE time_phylmdz_mod, ONLY: annee_ref
-  USE lmdz_phys_para
-  USE lmdz_abort_physic, ONLY: abort_physic
-  IMPLICIT NONE
-   INCLUDE "iniprint.h"
-
-   INTEGER,         INTENT(IN)  :: ndays
-   REAL,            INTENT(IN)  :: field_in(klon,lmdep)
-   CHARACTER(LEN=*),INTENT(IN)  :: calendar
-   REAL,            INTENT(OUT) :: field_out(klon,ndays)
- 
-   INTEGER :: ndays_in
-   REAL    :: timeyear(lmdep)   
-   REAL    :: yder(lmdep)   
-   INTEGER :: ij,ierr, n_extrap
-   LOGICAL :: skip
-
-   CHARACTER (len = 50)         :: modname = 'create_limit_unstruct.time_interpolation'
-   CHARACTER (len = 80)         :: abort_message
-
-  
-   IF (is_omp_master) ndays_in=year_len(annee_ref, calendar)
-   CALL bcast_omp(ndays_in)
-   IF (is_omp_master) timeyear=mid_months(annee_ref, calendar, lmdep)
-   CALL bcast_omp(timeyear)
-    
-   n_extrap = 0
-   skip=.FALSE.
-   DO ij=1,klon
-     yder = pchsp_95(timeyear, field_in(ij, :), ibeg=2, iend=2, vc_beg=0., vc_end=0.)
-     CALL pchfe_95(timeyear, field_in(ij, :), yder, skip, arth(0., real(ndays_in) / ndays, ndays), field_out(ij, :), ierr)
-     IF (ierr < 0) THEN
-        abort_message='error in pchfe_95'
-        CALL abort_physic(modname,abort_message,1)
-     endif
-     n_extrap = n_extrap + ierr
-   END DO
-   
-   IF (n_extrap /= 0) THEN
-     WRITE(lunout,*) "get_2Dfield pchfe_95: n_extrap = ", n_extrap
-   ENDIF 
-  
-  
+
+
+  SUBROUTINE time_interpolation(ndays, field_in, calendar, field_out)
+    USE lmdz_libmath_pch, ONLY: pchsp_95, pchfe_95
+    USE lmdz_arth, ONLY: arth
+    USE dimphy, ONLY: klon
+    USE ioipsl, ONLY: ioget_year_len
+    USE time_phylmdz_mod, ONLY: annee_ref
+    USE lmdz_phys_para
+    USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_iniprint, ONLY: lunout, prt_level
+    IMPLICIT NONE
+
+    INTEGER, INTENT(IN) :: ndays
+    REAL, INTENT(IN) :: field_in(klon, lmdep)
+    CHARACTER(LEN = *), INTENT(IN) :: calendar
+    REAL, INTENT(OUT) :: field_out(klon, ndays)
+
+    INTEGER :: ndays_in
+    REAL :: timeyear(lmdep)
+    REAL :: yder(lmdep)
+    INTEGER :: ij, ierr, n_extrap
+    LOGICAL :: skip
+
+    CHARACTER (len = 50) :: modname = 'create_limit_unstruct.time_interpolation'
+    CHARACTER (len = 80) :: abort_message
+
+    IF (is_omp_master) ndays_in = year_len(annee_ref, calendar)
+    CALL bcast_omp(ndays_in)
+    IF (is_omp_master) timeyear = mid_months(annee_ref, calendar, lmdep)
+    CALL bcast_omp(timeyear)
+
+    n_extrap = 0
+    skip = .FALSE.
+    DO ij = 1, klon
+      yder = pchsp_95(timeyear, field_in(ij, :), ibeg = 2, iend = 2, vc_beg = 0., vc_end = 0.)
+      CALL pchfe_95(timeyear, field_in(ij, :), yder, skip, arth(0., real(ndays_in) / ndays, ndays), field_out(ij, :), ierr)
+      IF (ierr < 0) THEN
+        abort_message = 'error in pchfe_95'
+        CALL abort_physic(modname, abort_message, 1)
+      endif
+      n_extrap = n_extrap + ierr
+    END DO
+
+    IF (n_extrap /= 0) THEN
+      WRITE(lunout, *) "get_2Dfield pchfe_95: n_extrap = ", n_extrap
+    ENDIF
+
   END SUBROUTINE time_interpolation
   !-------------------------------------------------------------------------------
 
-  FUNCTION year_len(y,cal_in)
+  FUNCTION year_len(y, cal_in)
+
+    !-------------------------------------------------------------------------------
+    USE ioipsl, ONLY: ioget_calendar, ioconf_calendar, lock_calendar, ioget_year_len
+    IMPLICIT NONE
+    !-------------------------------------------------------------------------------
+    ! Arguments:
+    INTEGER :: year_len
+    INTEGER, INTENT(IN) :: y
+    CHARACTER(LEN = *), INTENT(IN) :: cal_in
+    !-------------------------------------------------------------------------------
+    ! Local variables:
+    CHARACTER(LEN = 20) :: cal_out              ! calendar (for outputs)
+    !-------------------------------------------------------------------------------
+    !--- Getting the input calendar to reset at the end of the function
+    CALL ioget_calendar(cal_out)
+
+    !--- Unlocking calendar and setting it to wanted one
+    CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))
+
+    !--- Getting the number of days in this year
+    year_len = ioget_year_len(y)
+
+    !--- Back to original calendar
+    CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))
+
+  END FUNCTION year_len
 
   !-------------------------------------------------------------------------------
-    USE ioipsl, ONLY: ioget_calendar,ioconf_calendar,lock_calendar,ioget_year_len
-    IMPLICIT NONE
+
+
   !-------------------------------------------------------------------------------
-  ! Arguments:
-    INTEGER                       :: year_len
-    INTEGER,           INTENT(IN) :: y
-    CHARACTER(LEN=*),  INTENT(IN) :: cal_in
-  !-------------------------------------------------------------------------------
-  ! Local variables:
-    CHARACTER(LEN=20)             :: cal_out              ! calendar (for outputs)
-  !-------------------------------------------------------------------------------
-  !--- Getting the input calendar to reset at the end of the function
-    CALL ioget_calendar(cal_out)
-  
-  !--- Unlocking calendar and setting it to wanted one
-    CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))
-  
-  !--- Getting the number of days in this year
-    year_len=ioget_year_len(y)
-  
-  !--- Back to original calendar
-    CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))
-  
-  END FUNCTION year_len
-
-  !-------------------------------------------------------------------------------
-  
-  
-  !-------------------------------------------------------------------------------
-
-  FUNCTION mid_months(y,cal_in,nm)
-
-  !-------------------------------------------------------------------------------
-    USE ioipsl, ONLY: ioget_calendar,ioconf_calendar,lock_calendar,ioget_mon_len
+
+  FUNCTION mid_months(y, cal_in, nm)
+
+    !-------------------------------------------------------------------------------
+    USE ioipsl, ONLY: ioget_calendar, ioconf_calendar, lock_calendar, ioget_mon_len
     USE lmdz_abort_physic, ONLY: abort_physic
     IMPLICIT NONE
-  !-------------------------------------------------------------------------------
-  ! Arguments:
-    INTEGER,                INTENT(IN) :: y               ! year
-    CHARACTER(LEN=*),       INTENT(IN) :: cal_in          ! calendar
-    INTEGER,                INTENT(IN) :: nm              ! months/year number
-    REAL,    DIMENSION(nm)             :: mid_months      ! mid-month times
-  !-------------------------------------------------------------------------------
-  ! Local variables:
-    CHARACTER(LEN=99)                  :: mess            ! error message
-    CHARACTER(LEN=20)                  :: cal_out         ! calendar (for outputs)
-    INTEGER, DIMENSION(nm)             :: mnth            ! months lengths (days)
-    INTEGER                            :: m               ! months counter
-    INTEGER                            :: nd              ! number of days
-    INTEGER                            :: k
-  !-------------------------------------------------------------------------------
-    nd=year_len(y,cal_in)
-  
+    !-------------------------------------------------------------------------------
+    ! Arguments:
+    INTEGER, INTENT(IN) :: y               ! year
+    CHARACTER(LEN = *), INTENT(IN) :: cal_in          ! calendar
+    INTEGER, INTENT(IN) :: nm              ! months/year number
+    REAL, DIMENSION(nm) :: mid_months      ! mid-month times
+    !-------------------------------------------------------------------------------
+    ! Local variables:
+    CHARACTER(LEN = 99) :: mess            ! error message
+    CHARACTER(LEN = 20) :: cal_out         ! calendar (for outputs)
+    INTEGER, DIMENSION(nm) :: mnth            ! months lengths (days)
+    INTEGER :: m               ! months counter
+    INTEGER :: nd              ! number of days
+    INTEGER :: k
+    !-------------------------------------------------------------------------------
+    nd = year_len(y, cal_in)
+
     IF(nm==12) THEN
-  
-    !--- Getting the input calendar to reset at the end of the function
+
+      !--- Getting the input calendar to reset at the end of the function
       CALL ioget_calendar(cal_out)
-  
-    !--- Unlocking calendar and setting it to wanted one
+
+      !--- Unlocking calendar and setting it to wanted one
       CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_in))
-  
-    !--- Getting the length of each month
-      DO m=1,nm; mnth(m)=ioget_mon_len(y,m); END DO
-  
-    !--- Back to original calendar
+
+      !--- Getting the length of each month
+      DO m = 1, nm; mnth(m) = ioget_mon_len(y, m);
+      END DO
+
+      !--- Back to original calendar
       CALL lock_calendar(.FALSE.); CALL ioconf_calendar(TRIM(cal_out))
-  
-    ELSE IF(MODULO(nd,nm)/=0) THEN
-      WRITE(mess,'(a,i3,a,i3,a)')'Unconsistent calendar: ',nd,' days/year, but ',&
-        nm,' months/year. Months number should divide days number.'
-      CALL abort_physic('mid_months',TRIM(mess),1)
-  
+
+    ELSE IF(MODULO(nd, nm)/=0) THEN
+      WRITE(mess, '(a,i3,a,i3,a)')'Unconsistent calendar: ', nd, ' days/year, but ', &
+              nm, ' months/year. Months number should divide days number.'
+      CALL abort_physic('mid_months', TRIM(mess), 1)
+
     ELSE
-      mnth=(/(m,m=1,nm,nd/nm)/)
+      mnth = (/(m, m = 1, nm, nd / nm)/)
     END IF
-  
-  !--- Mid-months times
-    mid_months(1)=0.5*REAL(mnth(1))
-    DO k=2,nm
-      mid_months(k)=mid_months(k-1)+0.5*REAL(mnth(k-1)+mnth(k))
+
+    !--- Mid-months times
+    mid_months(1) = 0.5 * REAL(mnth(1))
+    DO k = 2, nm
+      mid_months(k) = mid_months(k - 1) + 0.5 * REAL(mnth(k - 1) + mnth(k))
     END DO
-  
+
   END FUNCTION mid_months
-  
+
 
 END MODULE create_limit_unstruct_mod
Index: LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90	(revision 5117)
+++ LMDZ6/branches/Amaury_dev/libf/phylmd/infotrac_phy.F90	(revision 5118)
@@ -134,4 +134,5 @@
     USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_INCA, CPPKEY_STRATAER
     USE lmdz_abort_physic, ONLY: abort_physic
+    USE lmdz_iniprint, ONLY: lunout, prt_level
     IMPLICIT NONE
     !==============================================================================================================================
@@ -155,5 +156,4 @@
     ! Declarations:
     INCLUDE "dimensions.h"
-    INCLUDE "iniprint.h"
 
     !------------------------------------------------------------------------------------------------------------------------------
@@ -260,34 +260,34 @@
     IF(fType == 1 .AND. ANY(['inca', 'inco']==type_trac) .AND. lInit) THEN  !=== FOUND OLD STYLE INCA "traceur.def"
       !---------------------------------------------------------------------------------------------------------------------------
-        nqo = SIZE(tracers) - nqCO2
-        CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
-        nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
-        nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
-        IF(ALL([2, 3] /= nqo)) CALL abort_physic(modname, 'Only 2 or 3 water phases allowed ; found nqo=' // TRIM(int2str(nqo)), 1)
-        ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
-        ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
-        CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
-        ALLOCATE(ttr(nqtrue))
-        ttr(1:nqo + nqCO2) = tracers
-        ttr(1:nqo)%component = 'lmdz'
-        ttr(1 + nqo:nqCO2 + nqo)%component = 'co2i'
-        ttr(1 + nqo + nqCO2:nqtrue)%component = 'inca'
-        ttr(1 + nqo:nqtrue)%name = [('CO2     ', k = 1, nqCO2), solsym_inca]
-        ttr(1 + nqo + nqCO2:nqtrue)%parent = tran0
-        ttr(1 + nqo + nqCO2:nqtrue)%phase = 'g'
-        lerr = getKey('hadv', had, ky = tracers(:)%keys)
-        lerr = getKey('vadv', vad, ky = tracers(:)%keys)
-        hadv(1:nqo + nqCO2) = had(:); hadv(1 + nqo + nqCO2:nqtrue) = hadv_inca
-        vadv(1:nqo + nqCO2) = vad(:); vadv(1 + nqo + nqCO2:nqtrue) = vadv_inca
-        CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
-        DO iq = 1, nqtrue
-          t1 => tracers(iq)
-          CALL addKey('name', t1%name, t1%keys)
-          CALL addKey('component', t1%component, t1%keys)
-          CALL addKey('parent', t1%parent, t1%keys)
-          CALL addKey('phase', t1%phase, t1%keys)
-        END DO
-        IF(setGeneration(tracers)) CALL abort_physic(modname, 'See below', 1) !- SET FIELDS %iGeneration, %gen0Name
-        DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
+      nqo = SIZE(tracers) - nqCO2
+      CALL Init_chem_inca_trac(nqINCA)                               !--- Get nqINCA from INCA
+      nbtr = nqINCA + nqCO2                                          !--- Number of tracers passed to phytrac
+      nqtrue = nbtr + nqo                                            !--- Total number of "true" tracers
+      IF(ALL([2, 3] /= nqo)) CALL abort_physic(modname, 'Only 2 or 3 water phases allowed ; found nqo=' // TRIM(int2str(nqo)), 1)
+      ALLOCATE(hadv(nqtrue), hadv_inca(nqINCA), conv_flg_inca(nqINCA), solsym_inca(nqINCA))
+      ALLOCATE(vadv(nqtrue), vadv_inca(nqINCA), pbl_flg_inca(nqINCA))
+      CALL init_transport(solsym_inca, conv_flg_inca, pbl_flg_inca, hadv_inca, vadv_inca)
+      ALLOCATE(ttr(nqtrue))
+      ttr(1:nqo + nqCO2) = tracers
+      ttr(1:nqo)%component = 'lmdz'
+      ttr(1 + nqo:nqCO2 + nqo)%component = 'co2i'
+      ttr(1 + nqo + nqCO2:nqtrue)%component = 'inca'
+      ttr(1 + nqo:nqtrue)%name = [('CO2     ', k = 1, nqCO2), solsym_inca]
+      ttr(1 + nqo + nqCO2:nqtrue)%parent = tran0
+      ttr(1 + nqo + nqCO2:nqtrue)%phase = 'g'
+      lerr = getKey('hadv', had, ky = tracers(:)%keys)
+      lerr = getKey('vadv', vad, ky = tracers(:)%keys)
+      hadv(1:nqo + nqCO2) = had(:); hadv(1 + nqo + nqCO2:nqtrue) = hadv_inca
+      vadv(1:nqo + nqCO2) = vad(:); vadv(1 + nqo + nqCO2:nqtrue) = vadv_inca
+      CALL MOVE_ALLOC(FROM = ttr, TO = tracers)
+      DO iq = 1, nqtrue
+        t1 => tracers(iq)
+        CALL addKey('name', t1%name, t1%keys)
+        CALL addKey('component', t1%component, t1%keys)
+        CALL addKey('parent', t1%parent, t1%keys)
+        CALL addKey('phase', t1%phase, t1%keys)
+      END DO
+      IF(setGeneration(tracers)) CALL abort_physic(modname, 'See below', 1) !- SET FIELDS %iGeneration, %gen0Name
+      DEALLOCATE(had, hadv_inca, vad, vadv_inca, conv_flg_inca, pbl_flg_inca, solsym_inca)
       !---------------------------------------------------------------------------------------------------------------------------
     ELSE                                                              !=== OTHER CASES (OLD OR NEW FORMAT, NO INCA MODULE)
@@ -298,5 +298,5 @@
       nbtr = nqtrue - COUNT(delPhase(tracers(:)%gen0Name) == 'H2O' &
               .AND. tracers(:)%component == 'lmdz') !--- Number of tracers passed to phytrac
-        nqINCA = COUNT(tracers(:)%component == 'inca')
+      nqINCA = COUNT(tracers(:)%component == 'inca')
       lerr = getKey('hadv', hadv, ky = tracers(:)%keys)
       lerr = getKey('vadv', vadv, ky = tracers(:)%keys)
