source: LMDZ5/trunk/libf/phylmd/phys_output_write_mod.F90 @ 2690

Last change on this file since 2690 was 2690, checked in by oboucher, 8 years ago

Adding a module for stratospheric aerosols with a bin scheme.
The module gets activated with -strataer true compiling option.
May not quite work yet, more testing needed, but should not affect
the rest of LMDz as everything is under a CPP_StratAer key.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:keywords set to Id
File size: 77.7 KB
RevLine 
[1798]1!
[2429]2! $Id: phys_output_write_mod.F90 2690 2016-10-30 15:35:25Z oboucher $
[1798]3!
4MODULE phys_output_write_mod
5
[1898]6  USE phytrac_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
7       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
8       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
[1813]9
[1898]10  ! Author: Abderrahmane IDELKADI (original include file)
11  ! Author: Laurent FAIRHEAD (transformation to module/subroutine)
12  ! Author: Ulysse GERARD (effective implementation)
[1813]13
[1898]14CONTAINS
[1798]15
[1898]16  ! ug Routine pour définir (los du premier passageà) ET sortir les variables
17  SUBROUTINE phys_output_write(itap, pdtphys, paprs, pphis, &
18       pplay, lmax_th, aerosol_couple,         &
[2496]19       ok_ade, ok_aie, ivap, iliq, isol, new_aod, ok_sync, &
[1915]20       ptconv, read_climoz, clevSTD, ptconvth, &
[2665]21       d_u, d_t, qx, d_qx, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
[1798]22
[1898]23    ! This subroutine does the actual writing of diagnostics that were
24    ! defined and initialised in phys_output_mod.F90
[1798]25
[2656]26    USE dimphy, only: klon, klev, klevp1
[2429]27    USE mod_phys_lmdz_para, ONLY: is_north_pole_phy,is_south_pole_phy
[2344]28    USE mod_grid_phy_lmdz, ONLY : nbp_lon, nbp_lat
29    USE time_phylmdz_mod, only: day_step_phy, start_time, itau_phy
[1897]30    USE phys_output_ctrlout_mod, only: o_phis, o_aire, is_ter, is_lic, is_oce, &
[1898]31         is_ave, is_sic, o_contfracATM, o_contfracOR, &
[2385]32         o_aireTER, o_flat, o_slp, o_ptstar, o_pt0, o_tsol, &
[1898]33         o_t2m, o_t2m_min, o_t2m_max, &
[2103]34         o_t2m_min_mon, o_t2m_max_mon, &
[1898]35         o_q2m, o_ustar, o_u10m, o_v10m, &
[2240]36         o_wind10m, o_wind10max, o_gusts, o_sicf, &
[1898]37         o_psol, o_mass, o_qsurf, o_qsol, &
[2516]38         o_precip, o_ndayrain, o_plul, o_pluc, o_plun, &
[2481]39         o_snow, o_msnow, o_fsnow, o_evap, o_ep,o_epmax_diag, & ! epmax_cape
[1898]40         o_tops, o_tops0, o_topl, o_topl0, &
41         o_SWupTOA, o_SWupTOAclr, o_SWdnTOA, &
42         o_SWdnTOAclr, o_nettop, o_SWup200, &
43         o_SWup200clr, o_SWdn200, o_SWdn200clr, &
44         o_LWup200, o_LWup200clr, o_LWdn200, &
45         o_LWdn200clr, o_sols, o_sols0, &
46         o_soll, o_radsol, o_soll0, o_SWupSFC, &
47         o_SWupSFCclr, o_SWdnSFC, o_SWdnSFCclr, &
48         o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
49         o_LWdnSFCclr, o_bils, o_bils_diss, &
[2042]50         o_bils_ec,o_bils_ech, o_bils_tke, o_bils_kinetic, &
[1898]51         o_bils_latent, o_bils_enthalp, o_sens, &
[2517]52         o_fder, o_ffonte, o_fqcalving, o_fqfonte, o_runofflic, &
[1898]53         o_taux, o_tauy, o_snowsrf, o_qsnow, &
54         o_snowhgt, o_toice, o_sissnow, o_runoff, &
55         o_albslw3, o_pourc_srf, o_fract_srf, &
56         o_taux_srf, o_tauy_srf, o_tsol_srf, &
57         o_evappot_srf, o_ustar_srf, o_u10m_srf, &
58         o_v10m_srf, o_t2m_srf, o_evap_srf, &
59         o_sens_srf, o_lat_srf, o_flw_srf, &
60         o_fsw_srf, o_wbils_srf, o_wbilo_srf, &
[2670]61         o_wevap_srf, o_wrain_srf, o_wsnow_srf, &
[2159]62         o_tke_srf, o_tke_max_srf,o_dltpbltke_srf, o_wstar, &
[2561]63         o_l_mixmin,o_l_mix, &
[1898]64         o_cdrm, o_cdrh, o_cldl, o_cldm, o_cldh, &
[1924]65         o_cldt, o_JrNt, o_cldljn, o_cldmjn, &
66         o_cldhjn, o_cldtjn, o_cldq, o_lwp, o_iwp, &
67         o_ue, o_ve, o_uq, o_vq, o_cape, o_pbase, &
[1898]68         o_ptop, o_fbase, o_plcl, o_plfc, &
[2481]69         o_wbeff, o_cape_max, o_upwd, o_ep,o_epmax_diag, o_Ma, &
[1898]70         o_dnwd, o_dnwd0, o_ftime_con, o_mc, &
[2496]71         o_prw, o_prlw, o_prsw, o_s_pblh, o_s_pblt, o_s_lcl, &
[1898]72         o_s_therm, o_uSTDlevs, o_vSTDlevs, &
73         o_wSTDlevs, o_zSTDlevs, o_qSTDlevs, &
74         o_tSTDlevs, epsfra, o_t_oce_sic, &
75         o_ale_bl, o_alp_bl, o_ale_wk, o_alp_wk, &
[2393]76         o_dtvdf_x    , o_dtvdf_w    , o_dqvdf_x    , o_dqvdf_w    , &
77         o_sens_x     , o_sens_w     , o_flat_x     , o_flat_w     , &
78         o_delta_tsurf, &
79         o_cdragh_x   , o_cdragh_w   , o_cdragm_x   , o_cdragm_w   , &
80         o_kh         , o_kh_x       , o_kh_w       , &
[1898]81         o_ale, o_alp, o_cin, o_WAPE, o_wake_h, &
82         o_wake_s, o_wake_deltat, o_wake_deltaq, &
[2486]83         o_wake_omg, o_dtwak, o_dqwak, o_dqwak2d, o_Vprecip, &
[1898]84         o_ftd, o_fqd, o_wdtrainA, o_wdtrainM, &
85         o_n2, o_s2, o_proba_notrig, &
86         o_random_notrig, o_ale_bl_stat, &
87         o_ale_bl_trig, o_alp_bl_det, &
88         o_alp_bl_fluct_m, o_alp_bl_fluct_tke, &
[2057]89         o_alp_bl_conv, o_alp_bl_stat, &
90         o_slab_qflux, o_tslab, o_slab_bils, &
[2209]91         o_slab_bilg, o_slab_sic, o_slab_tice, &
[2656]92         o_slab_hdiff, o_slab_ekman, &
[1898]93         o_weakinv, o_dthmin, o_cldtau, &
94         o_cldemi, o_pr_con_l, o_pr_con_i, &
95         o_pr_lsc_l, o_pr_lsc_i, o_re, o_fl, &
96         o_rh2m, o_rh2m_min, o_rh2m_max, &
97         o_qsat2m, o_tpot, o_tpote, o_SWnetOR, &
98         o_SWdownOR, o_LWdownOR, o_snowl, &
99         o_solldown, o_dtsvdfo, o_dtsvdft, &
[2243]100         o_dtsvdfg, o_dtsvdfi, o_z0m, o_z0h, o_od550aer, &
[1898]101         o_od865aer, o_absvisaer, o_od550lt1aer, &
[2146]102         o_sconcso4, o_sconcno3, o_sconcoa, o_sconcbc, &
103         o_sconcss, o_sconcdust, o_concso4, o_concno3, &
[1898]104         o_concoa, o_concbc, o_concss, o_concdust, &
105         o_loadso4, o_loadoa, o_loadbc, o_loadss, &
[2146]106         o_loaddust, o_tausumaero, o_tausumaero_lw, &
107         o_topswad, o_topswad0, o_solswad, o_solswad0, &
108         o_toplwad, o_toplwad0, o_sollwad, o_sollwad0, &
[1898]109         o_swtoaas_nat, o_swsrfas_nat, &
110         o_swtoacs_nat, o_swtoaas_ant, &
111         o_swsrfas_ant, o_swtoacs_ant, &
112         o_swsrfcs_ant, o_swtoacf_nat, &
113         o_swsrfcf_nat, o_swtoacf_ant, &
114         o_swsrfcs_nat, o_swsrfcf_ant, &
115         o_swtoacf_zero, o_swsrfcf_zero, &
116         o_topswai, o_solswai, o_scdnc, &
[2536]117         o_cldncl, o_reffclws, o_reffclwc, o_stratomask,&
[1898]118         o_cldnvi, o_lcc, o_lcc3d, o_lcc3dcon, &
119         o_lcc3dstra, o_reffclwtop, o_ec550aer, &
120         o_lwcon, o_iwcon, o_temp, o_theta, &
[2553]121         o_ovapinit, o_ovap, o_oliq, o_ocond, o_geop, &
[1898]122         o_vitu, o_vitv, o_vitw, o_pres, o_paprs, &
[1924]123         o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
[1898]124         o_rnebls, o_rhum, o_ozone, o_ozone_light, &
[2665]125         o_duphy, o_dtphy, o_dqphy, o_dqphy2d, o_dqlphy, o_dqlphy2d, &
[2496]126         o_dqsphy, o_dqsphy2d, o_albe_srf, o_z0m_srf, o_z0h_srf, &
[2209]127         o_ages_srf, o_snow_srf, o_alb1, o_alb2, o_tke, &
[1898]128         o_tke_max, o_kz, o_kz_max, o_clwcon, &
[2496]129         o_dtdyn, o_dqdyn, o_dqdyn2d, o_dqldyn, o_dqldyn2d, &
130         o_dqsdyn, o_dqsdyn2d, o_dudyn, o_dvdyn, &
[1898]131         o_dtcon, o_tntc, o_ducon, o_dvcon, &
[2486]132         o_dqcon, o_dqcon2d, o_tnhusc, o_tnhusc, o_dtlsc, &
133         o_dtlschr, o_dqlsc, o_dqlsc2d, o_beta_prec, &
134         o_dtlscth, o_dtlscst, o_dqlscth, o_dqlscth2d, &
135         o_dqlscst, o_dqlscst2d, o_plulth, o_plulst, &
[1898]136         o_ptconvth, o_lmaxth, o_dtvdf, &
[2486]137         o_dtdis, o_dqvdf, o_dqvdf2d, o_dteva, o_dqeva, o_dqeva2d, &
[1903]138         o_ptconv, o_ratqs, o_dtthe, &
139         o_duthe, o_dvthe, o_ftime_th, &
[1898]140         o_f_th, o_e_th, o_w_th, o_q_th, &
141         o_a_th, o_d_th, o_f0_th, o_zmax_th, &
[2486]142         o_dqthe, o_dqthe2d, o_dtajs, o_dqajs, o_dqajs2d, o_dtswr, &
[1898]143         o_dtsw0, o_dtlwr, o_dtlw0, o_dtec, &
144         o_duvdf, o_dvvdf, o_duoro, o_dvoro, &
145         o_dtoro, o_dulif, o_dvlif, o_dtlif, &
[2333]146         o_du_gwd_hines, o_dv_gwd_hines, o_dthin, o_dqch4, o_rsu, &
147         o_du_gwd_front, o_dv_gwd_front, &
148         o_east_gwstress, o_west_gwstress, &
[1898]149         o_rsd, o_rlu, o_rld, o_rsucs, o_rsdcs, &
150         o_rlucs, o_rldcs, o_tnt, o_tntr, &
151         o_tntscpbl, o_tnhus, o_tnhusscpbl, &
152         o_evu, o_h2o, o_mcd, o_dmc, o_ref_liq, &
153         o_ref_ice, o_rsut4co2, o_rlut4co2, &
154         o_rsutcs4co2, o_rlutcs4co2, o_rsu4co2, &
155         o_rlu4co2, o_rsucs4co2, o_rlucs4co2, &
156         o_rsd4co2, o_rld4co2, o_rsdcs4co2, &
157         o_rldcs4co2, o_tnondef, o_ta, o_zg, &
158         o_hus, o_hur, o_ua, o_va, o_wap, &
159         o_psbg, o_tro3, o_tro3_daylight, &
160         o_uxv, o_vxq, o_vxT, o_wxq, o_vxphi, &
161         o_wxT, o_uxu, o_vxv, o_TxT, o_trac, &
162         o_dtr_vdf, o_dtr_the, o_dtr_con, &
163         o_dtr_lessi_impa, o_dtr_lessi_nucl, &
164         o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
165         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, &
[1938]166         o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
[2333]167         o_ustr_gwd_hines,o_vstr_gwd_hines,o_ustr_gwd_rando,o_vstr_gwd_rando, &
[2538]168         o_ustr_gwd_front,o_vstr_gwd_front, &
169         o_sens_prec_liq_oce, o_sens_prec_liq_sic, &
170         o_sens_prec_sol_oce, o_sens_prec_sol_sic, &
171         o_lat_prec_liq_oce, o_lat_prec_liq_sic, &
[2580]172         o_lat_prec_sol_oce, o_lat_prec_sol_sic, &
173! Marine
174         o_map_prop_hc, o_map_prop_hist, o_map_emis_hc, o_map_iwp_hc, &
175         o_map_deltaz_hc, o_map_pcld_hc, o_map_tcld_hc, &
176         o_map_emis_hist, o_map_iwp_hist, o_map_deltaz_hist, &
177         o_map_rad_hist, &
178         o_map_emis_Cb, o_map_pcld_Cb, o_map_tcld_Cb, &
179         o_map_emis_ThCi, o_map_pcld_ThCi, o_map_tcld_ThCi, &
180         o_map_emis_Anv, o_map_pcld_Anv, o_map_tcld_Anv, &
181         o_map_ntot, o_map_hc,o_map_hist,o_map_Cb,o_map_ThCi,o_map_Anv, &
182         o_alt_tropo
[1798]183
[2690]184#ifdef CPP_StratAer
185    USE phys_output_ctrlout_mod, only:  &
186         o_sulf_convert, o_sulf_nucl, o_sulf_cond_evap, o_ocs_convert, &
187         o_sfluxaer, o_R2SO4, o_OCS_lifetime, o_SO2_lifetime, &
188         o_OCS_backgr_tend, o_SO2_backgr_tend, o_sulf_dep_dry, o_sulf_dep_wet, &
189         o_surf_PM25_sulf, o_ext_strat_550, o_tau_strat_550, &
190         o_p_tropopause, o_vsed_aer, o_tau_strat_1020, o_ext_strat_1020, o_f_r_wet
191#endif
[2580]192
[1897]193    USE phys_state_var_mod, only: pctsrf, paire_ter, rain_fall, snow_fall, &
[2243]194         qsol, z0m, z0h, fevap, agesno, &
[1898]195         nday_rain, rain_con, snow_con, &
196         topsw, toplw, toplw0, swup, swdn, &
197         topsw0, swup0, swdn0, SWup200, SWup200clr, &
198         SWdn200, SWdn200clr, LWup200, LWup200clr, &
199         LWdn200, LWdn200clr, solsw, solsw0, sollw, &
[2366]200         radsol, swradcorr, sollw0, sollwdown, sollw, gustiness, &
[1898]201         sollwdownclr, lwdn0, ftsol, ustar, u10m, &
[2159]202         v10m, pbl_tke, wake_delta_pbl_TKE, &
[2393]203         delta_tsurf, &
[2159]204         wstar, cape, ema_pcb, ema_pct, &
[1898]205         ema_cbmf, Ma, fm_therm, ale_bl, alp_bl, ale, &
206         alp, cin, wake_pe, wake_s, wake_deltat, &
207         wake_deltaq, ftd, fqd, ale_bl_trig, albsol1, &
208         rnebcon, wo, falb1, albsol2, coefh, clwcon0, &
[2194]209         ratqs, entr_therm, zqasc, detr_therm, f0, &
210         lwup, lwdn, lwup0, coefm, &
[1898]211         swupp, lwupp, swup0p, lwup0p, swdnp, lwdnp, &
212         swdn0p, lwdn0p, tnondef, O3sumSTD, uvsumSTD, &
213         vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
214         vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
[2333]215         T2sumSTD, nlevSTD, du_gwd_rando, du_gwd_front, &
[2271]216         ulevSTD, vlevSTD, wlevSTD, philevSTD, qlevSTD, tlevSTD, &
[2282]217         rhlevSTD, O3STD, O3daySTD, uvSTD, vqSTD, vTSTD, wqSTD, &
218         vphiSTD, wTSTD, u2STD, v2STD, T2STD, missing_val_nf90
[1898]219
[2385]220    USE phys_local_var_mod, only: zxfluxlat, slp, ptstar, pt0, zxtsol, zt2m, &
[2243]221         t2m_min_mon, t2m_max_mon, evap, &
[2561]222         l_mixmin,l_mix, &
[2243]223         zu10m, zv10m, zq2m, zustar, zxqsurf, &
[2516]224         rain_lsc, rain_num, snow_lsc, bils, sens, fder, &
[2517]225         zxffonte, zxfqcalving, zxfqfonte, zxrunofflic, fluxu, &
[1898]226         fluxv, zxsnow, qsnow, snowhgt, to_ice, &
227         sissnow, runoff, albsol3_lic, evap_pot, &
[2243]228         t2m, fluxt, fluxlat, fsollw, fsolsw, &
[2670]229         wfbils, wfbilo, wfevap, wfrain, wfsnow, &
230         cdragm, cdragh, cldl, cldm, &
[1924]231         cldh, cldt, JrNt, cldljn, cldmjn, cldhjn, &
232         cldtjn, cldq, flwp, fiwp, ue, ve, uq, vq, &
[2496]233         plcl, plfc, wbeff, upwd, dnwd, dnwd0, prw, prlw, prsw, &
[1898]234         s_pblh, s_pblt, s_lcl, s_therm, uwriteSTD, &
235         vwriteSTD, wwriteSTD, phiwriteSTD, qwriteSTD, &
[2393]236         twriteSTD, ale_wake, alp_wake, &
237         dtvdf_x    ,dtvdf_w    ,dqvdf_x    ,dqvdf_w    , &
238         sens_x     ,sens_w     ,zxfluxlat_x,zxfluxlat_w, &
239         cdragh_x   ,cdragh_w   ,cdragm_x   ,cdragm_w   , &
240         kh         ,kh_x       ,kh_w       , &
241         wake_h, &
[1898]242         wake_omg, d_t_wake, d_q_wake, Vprecip, &
243         wdtrainA, wdtrainM, n2, s2, proba_notrig, &
244         random_notrig, ale_bl_stat, &
245         alp_bl_det, alp_bl_fluct_m, alp_bl_conv, &
246         alp_bl_stat, alp_bl_fluct_tke, slab_wfbils, &
247         weak_inversion, dthmin, cldtau, cldemi, &
248         pmflxr, pmflxs, prfl, psfl, re, fl, rh2m, &
[2243]249         qsat2m, tpote, tpot, d_ts, od550aer, &
[2146]250         od865aer, absvisaer, od550lt1aer, sconcso4, sconcno3, &
251         sconcoa, sconcbc, sconcss, sconcdust, concso4, concno3, &
[1898]252         concoa, concbc, concss, concdust, loadso4, &
253         loadoa, loadbc, loadss, loaddust, tausum_aero, &
254         topswad_aero, topswad0_aero, solswad_aero, &
255         solswad0_aero, topsw_aero, solsw_aero, &
256         topsw0_aero, solsw0_aero, topswcf_aero, &
257         solswcf_aero, topswai_aero, solswai_aero, &
[2146]258         toplwad_aero, toplwad0_aero, sollwad_aero, &
259         sollwad0_aero, toplwai_aero, sollwai_aero, &
[2536]260         scdnc, cldncl, reffclws, reffclwc, cldnvi, stratomask,&
[1898]261         lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop, &
262         ec550aer, flwc, fiwc, t_seri, theta, q_seri, &
[2553]263         ql_seri, qs_seri, tr_seri, &
[2284]264         zphi, u_seri, v_seri, omega, cldfra, &
[2499]265         rneb, rnebjn, zx_rh, d_t_dyn,  &
266         d_q_dyn,  d_ql_dyn, d_qs_dyn, &
267         d_q_dyn2d,  d_ql_dyn2d, d_qs_dyn2d, &
[1898]268         d_u_dyn, d_v_dyn, d_t_con, d_t_ajsb, d_t_ajs, &
[1943]269         d_u_ajs, d_v_ajs, &
[1898]270         d_u_con, d_v_con, d_q_con, d_q_ajs, d_t_lsc, &
[2194]271         d_t_lwr,d_t_lw0,d_t_swr,d_t_sw0, &
[1898]272         d_t_eva, d_q_lsc, beta_prec, d_t_lscth, &
273         d_t_lscst, d_q_lscth, d_q_lscst, plul_th, &
274         plul_st, d_t_vdf, d_t_diss, d_q_vdf, d_q_eva, &
275         zw2, fraca, zmax_th, d_q_ajsb, d_t_ec, d_u_vdf, &
276         d_v_vdf, d_u_oro, d_v_oro, d_t_oro, d_u_lif, &
[2333]277         d_v_lif, d_t_lif, du_gwd_hines, dv_gwd_hines, d_t_hin, &
278         dv_gwd_rando, dv_gwd_front, &
279         east_gwstress, west_gwstress, &
[2481]280         d_q_ch4, pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD, &
281         ep, epmax_diag ! epmax_cape
[1898]282
[2690]283#ifdef CPP_StratAer
284    USE phys_local_var_mod, only:  &
285         sulf_convert, sulf_nucl, sulf_cond_evap, ocs_convert, &
286         sfluxaer, R2SO4, OCS_lifetime, SO2_lifetime, &
287         OCS_backgr_tend, SO2_backgr_tend, sulf_dep_dry, sulf_dep_wet, &
288         surf_PM25_sulf, tau_strat_550, p_tropopause, tausum_strat, &
289         vsed_aer, tau_strat_1020, f_r_wet
290#endif
291
[1897]292    USE phys_output_var_mod, only: vars_defined, snow_o, zfra_o, bils_diss, &
[2042]293         bils_ec,bils_ech, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
[2333]294         itau_con, nfiles, clef_files, nid_files, &
295         zustr_gwd_hines, zvstr_gwd_hines,zustr_gwd_rando, zvstr_gwd_rando, &
[2538]296         zustr_gwd_front, zvstr_gwd_front,     &
[2580]297         sens_prec_liq_o, sens_prec_sol_o, lat_prec_liq_o, lat_prec_sol_o, &
298! Marine
299         map_prop_hc, map_prop_hist, &
300         map_emis_hc,map_iwp_hc,map_deltaz_hc,&
301         map_pcld_hc,map_tcld_hc,&
302         map_emis_hist,map_iwp_hist,map_deltaz_hist,&
303         map_rad_hist,&
304         map_ntot,map_hc,map_hist,&
305         map_Cb,map_ThCi,map_Anv,&
306         map_emis_Cb,map_pcld_Cb,map_tcld_Cb,&
307         map_emis_ThCi,map_pcld_ThCi,map_tcld_ThCi,&
308         map_emis_Anv,map_pcld_Anv,map_tcld_Anv, &
309         alt_tropo
310
[2656]311    USE ocean_slab_mod, only: nslay, tslab, slab_bils, slab_bilg, tice, &
312        seaice, slab_ekman,slab_hdiff, dt_ekman, dt_hdiff
[2209]313    USE pbl_surface_mod, only: snow
[1897]314    USE indice_sol_mod, only: nbsrf
[2320]315    USE infotrac_phy, only: nqtot, nqo, type_trac
[2351]316    USE geometry_mod, only: cell_area
[2209]317    USE surface_data, only: type_ocean, version_ocean, ok_veget, ok_snow
[2003]318!    USE aero_mod, only: naero_spc
[2146]319    USE aero_mod, only: naero_tot, id_STRAT_phy
[1897]320    USE ioipsl, only: histend, histsync
321    USE iophy, only: set_itau_iophy, histwrite_phy
322    USE netcdf, only: nf90_fill_real
[2319]323    USE print_control_mod, ONLY: prt_level,lunout
[1897]324
[2319]325
[1825]326#ifdef CPP_XIOS
327    ! ug Pour les sorties XIOS
[2002]328    USE xios, ONLY: xios_update_calendar
[2271]329    USE wxios, only: wxios_closedef, missing_val
[1825]330#endif
[1915]331    USE phys_cal_mod, only : mth_len
[1825]332
[2645]333#ifdef CPP_RRTM
334    USE YOESW, ONLY : RSUN
335#endif
[2114]336
[1798]337    IMPLICIT NONE
338
[2114]339
[1798]340    INCLUDE "clesphys.h"
341    INCLUDE "thermcell.h"
342    INCLUDE "compbl.h"
343    INCLUDE "YOMCST.h"
344
[1898]345    ! Input
[2496]346    INTEGER :: itap, ivap, iliq, isol, read_climoz
[1798]347    INTEGER, DIMENSION(klon) :: lmax_th
348    LOGICAL :: aerosol_couple, ok_sync
349    LOGICAL :: ok_ade, ok_aie, new_aod
350    LOGICAL, DIMENSION(klon, klev) :: ptconv, ptconvth
351    REAL :: pdtphys
352    CHARACTER (LEN=4), DIMENSION(nlevSTD) :: clevSTD
[1971]353    REAL, DIMENSION(klon,nlevSTD) :: zx_tmp_fi3d_STD
[1798]354    REAL, DIMENSION(klon) :: pphis
[2665]355    REAL, DIMENSION(klon, klev) :: pplay, d_u, d_t
[1798]356    REAL, DIMENSION(klon, klev+1) :: paprs
357    REAL, DIMENSION(klon,klev,nqtot) :: qx, d_qx
[2344]358    REAL, DIMENSION(klon, klev) :: zmasse
[2530]359    INTEGER :: flag_aerosol_strat
[2003]360    INTEGER :: flag_aerosol
361    LOGICAL :: ok_cdnc
[1828]362    REAL, DIMENSION(3) :: freq_moyNMC
[1798]363
[1898]364    ! Local
[1798]365    INTEGER :: itau_w
[1821]366    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
[1798]367    REAL, DIMENSION (klon) :: zx_tmp_fi2d
368    REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
369    REAL, DIMENSION (klon,klev+1) :: zx_tmp_fi3d1
370    CHARACTER (LEN=4)              :: bb2
[2344]371    INTEGER, DIMENSION(nbp_lon*nbp_lat)  :: ndex2d
372    INTEGER, DIMENSION(nbp_lon*nbp_lat*klev) :: ndex3d
[1798]373    REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
[2271]374!   REAL, PARAMETER :: missing_val=nf90_fill_real
375#ifndef CPP_XIOS
376    REAL :: missing_val
377#endif
[1915]378    REAL, PARAMETER :: un_jour=86400.
[2645]379    INTEGER ISW
380    CHARACTER*1 ch1
[1798]381
[1898]382    ! On calcul le nouveau tau:
[2551]383    itau_w = itau_phy + itap
[1898]384    ! On le donne à iophy pour que les histwrite y aient accès:
385    CALL set_itau_iophy(itau_w)
386
[2690]387    IF (.NOT.vars_defined) THEN
[1898]388       iinitend = 2
[1821]389    ELSE
[1898]390       iinitend = 1
[1798]391    ENDIF
[1898]392
393    ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
394    DO iinit=1, iinitend
[1825]395#ifdef CPP_XIOS
[1898]396       !$OMP MASTER
397       IF (vars_defined) THEN
[2690]398          IF (prt_level >= 10) then
[2002]399             write(lunout,*)"phys_output_write: call xios_update_calendar, itau_w=",itau_w
[2690]400          ENDIF
[2095]401!          CALL xios_update_calendar(itau_w)
402          CALL xios_update_calendar(itap)
[2690]403       ENDIF
[1898]404       !$OMP END MASTER
405       !$OMP BARRIER
[1825]406#endif
[1898]407       ! On procède à l'écriture ou à la définition des nombreuses variables:
[1813]408!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1898]409       CALL histwrite_phy(o_phis, pphis)
[1798]410
[2429]411       zx_tmp_fi2d = cell_area
[2690]412       IF (is_north_pole_phy) then
[2429]413         zx_tmp_fi2d(1) = cell_area(1)/nbp_lon
[2690]414       ENDIF
415       IF (is_south_pole_phy) then
[2429]416         zx_tmp_fi2d(klon) = cell_area(klon)/nbp_lon
[2690]417       ENDIf
[2429]418       CALL histwrite_phy(o_aire, zx_tmp_fi2d)
419
[1898]420       IF (vars_defined) THEN
421          DO i=1, klon
422             zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
423          ENDDO
424       ENDIF
[1813]425
[1898]426       CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
427       CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
428       CALL histwrite_phy(o_aireTER, paire_ter)
[2645]429!
430#ifdef CPP_XIOS
431       CALL histwrite_phy("R_ecc",R_ecc)
432       CALL histwrite_phy("R_peri",R_peri)
433       CALL histwrite_phy("R_incl",R_incl)
434       CALL histwrite_phy("solaire",solaire)
435!
436#ifdef CPP_RRTM
437      IF (iflag_rrtm.EQ.1) THEN
438        DO ISW=1, NSW
439          WRITE(ch1,'(i1)') ISW
440!         zx_tmp_0d=RSUN(ISW)
441!         CALL histwrite_phy("rsun"//ch1,zx_tmp_0d)
442          CALL histwrite_phy("rsun"//ch1,RSUN(ISW))
443        ENDDO
444      ENDIF
445#endif
446!
447       CALL histwrite_phy("co2_ppm",co2_ppm)
448       CALL histwrite_phy("CH4_ppb",CH4_ppb)
449       CALL histwrite_phy("N2O_ppb",N2O_ppb)
450       CALL histwrite_phy("CFC11_ppt",CFC11_ppt)
451       CALL histwrite_phy("CFC12_ppt",CFC12_ppt)
452!
453#endif
454
[1813]455!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[2580]456! Simulateur AIRS
457     IF (ok_airs) then
458      CALL histwrite_phy(o_alt_tropo,alt_tropo)
459 
460      CALL histwrite_phy(o_map_prop_hc,map_prop_hc)
461      CALL histwrite_phy(o_map_prop_hist,map_prop_hist)
462
463      CALL histwrite_phy(o_map_emis_hc,map_emis_hc)
464      CALL histwrite_phy(o_map_iwp_hc,map_iwp_hc)
465      CALL histwrite_phy(o_map_deltaz_hc,map_deltaz_hc)
466      CALL histwrite_phy(o_map_pcld_hc,map_pcld_hc)
467      CALL histwrite_phy(o_map_tcld_hc,map_tcld_hc)
468
469      CALL histwrite_phy(o_map_emis_hist,map_emis_hist)
470      CALL histwrite_phy(o_map_iwp_hist,map_iwp_hist)
471      CALL histwrite_phy(o_map_deltaz_hist,map_deltaz_hist)
472
473      CALL histwrite_phy(o_map_ntot,map_ntot)
474      CALL histwrite_phy(o_map_hc,map_hc)
475      CALL histwrite_phy(o_map_hist,map_hist)
476
477      CALL histwrite_phy(o_map_Cb,map_Cb)
478      CALL histwrite_phy(o_map_ThCi,map_ThCi)
479      CALL histwrite_phy(o_map_Anv,map_Anv)
480
481      CALL histwrite_phy(o_map_emis_Cb,map_emis_Cb)
482      CALL histwrite_phy(o_map_pcld_Cb,map_pcld_Cb)
483      CALL histwrite_phy(o_map_tcld_Cb,map_tcld_Cb)
484
485      CALL histwrite_phy(o_map_emis_ThCi,map_emis_ThCi)
486      CALL histwrite_phy(o_map_pcld_ThCi,map_pcld_ThCi)
487      CALL histwrite_phy(o_map_tcld_ThCi,map_tcld_ThCi)
488
489      CALL histwrite_phy(o_map_emis_Anv,map_emis_Anv)
490      CALL histwrite_phy(o_map_pcld_Anv,map_pcld_Anv)
491      CALL histwrite_phy(o_map_tcld_Anv,map_tcld_Anv)
492     ENDIF
493
[1898]494       CALL histwrite_phy(o_flat, zxfluxlat)
[2385]495       CALL histwrite_phy(o_ptstar, ptstar)
496       CALL histwrite_phy(o_pt0, pt0)
[1898]497       CALL histwrite_phy(o_slp, slp)
498       CALL histwrite_phy(o_tsol, zxtsol)
499       CALL histwrite_phy(o_t2m, zt2m)
500       CALL histwrite_phy(o_t2m_min, zt2m)
501       CALL histwrite_phy(o_t2m_max, zt2m)
[2146]502       CALL histwrite_phy(o_t2m_max_mon, t2m_max_mon)
503       CALL histwrite_phy(o_t2m_min_mon, t2m_min_mon)
[1813]504
[1898]505       IF (vars_defined) THEN
506          DO i=1, klon
507             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
508          ENDDO
509       ENDIF
510       CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
[1813]511
[1898]512       IF (vars_defined) THEN
513          DO i=1, klon
514             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
515          ENDDO
516       ENDIF
517       CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
[1813]518
[2240]519       CALL histwrite_phy(o_gusts, gustiness)
520
[1898]521       IF (vars_defined) THEN
522          DO i = 1, klon
523             zx_tmp_fi2d(i) = pctsrf(i,is_sic)
524          ENDDO
525       ENDIF
526       CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
527       CALL histwrite_phy(o_q2m, zq2m)
528       CALL histwrite_phy(o_ustar, zustar)
529       CALL histwrite_phy(o_u10m, zu10m)
530       CALL histwrite_phy(o_v10m, zv10m)
[1813]531
[1898]532       IF (vars_defined) THEN
533          DO i = 1, klon
534             zx_tmp_fi2d(i) = paprs(i,1)
535          ENDDO
536       ENDIF
537       CALL histwrite_phy(o_psol, zx_tmp_fi2d)
538       CALL histwrite_phy(o_mass, zmasse)
539       CALL histwrite_phy(o_qsurf, zxqsurf)
[1813]540
[1898]541       IF (.NOT. ok_veget) THEN
542          CALL histwrite_phy(o_qsol, qsol)
543       ENDIF
[1813]544
[1898]545       IF (vars_defined) THEN
546          DO i = 1, klon
547             zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
548          ENDDO
549       ENDIF
[1813]550
[1898]551       CALL histwrite_phy(o_precip, zx_tmp_fi2d)
552       CALL histwrite_phy(o_ndayrain, nday_rain)
[1813]553
[2481]554       ! epmax_cape:
[2483]555!       CALL histwrite_phy(o_epmax_diag, epmax_diag)
[2481]556       CALL histwrite_phy(o_ep, ep)
557
[1898]558       IF (vars_defined) THEN
559          DO i = 1, klon
560             zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
561          ENDDO
562       ENDIF
563       CALL histwrite_phy(o_plul, zx_tmp_fi2d)
[2516]564       CALL histwrite_phy(o_plun, rain_num)
[1813]565
[1898]566       IF (vars_defined) THEN
567          DO i = 1, klon
568             zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
569          ENDDO
570       ENDIF
571       CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
572       CALL histwrite_phy(o_snow, snow_fall)
[2209]573       CALL histwrite_phy(o_msnow, zxsnow)
[1898]574       CALL histwrite_phy(o_fsnow, zfra_o)
575       CALL histwrite_phy(o_evap, evap)
[2366]576       CALL histwrite_phy(o_tops, topsw*swradcorr)
577       CALL histwrite_phy(o_tops0, topsw0*swradcorr)
[1898]578       CALL histwrite_phy(o_topl, toplw)
579       CALL histwrite_phy(o_topl0, toplw0)
[1813]580
[1898]581       IF (vars_defined) THEN
[2366]582          zx_tmp_fi2d(:) = swup(:,klevp1)*swradcorr(:)
[1898]583       ENDIF
584       CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
[1813]585
[1898]586       IF (vars_defined) THEN
[2366]587          zx_tmp_fi2d(:) = swup0(:,klevp1)*swradcorr(:)
[1898]588       ENDIF
589       CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
[1813]590
[1898]591       IF (vars_defined) THEN
[2366]592          zx_tmp_fi2d(:) = swdn(:,klevp1)*swradcorr(:)
[1898]593       ENDIF
594       CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
[1813]595
[1898]596       IF (vars_defined) THEN
[2366]597          zx_tmp_fi2d(:) = swdn0(:,klevp1)*swradcorr(:)
[1898]598       ENDIF
599       CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
[1813]600
[1898]601       IF (vars_defined) THEN
[2366]602          zx_tmp_fi2d(:) = topsw(:)*swradcorr(:)-toplw(:)
[1898]603       ENDIF
604       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
[2366]605       CALL histwrite_phy(o_SWup200, SWup200*swradcorr)
606       CALL histwrite_phy(o_SWup200clr, SWup200clr*swradcorr)
607       CALL histwrite_phy(o_SWdn200, SWdn200*swradcorr)
608       CALL histwrite_phy(o_SWdn200clr, SWdn200clr*swradcorr)
[1898]609       CALL histwrite_phy(o_LWup200, LWup200)
610       CALL histwrite_phy(o_LWup200clr, LWup200clr)
611       CALL histwrite_phy(o_LWdn200, LWdn200)
612       CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
[2366]613       CALL histwrite_phy(o_sols, solsw*swradcorr)
614       CALL histwrite_phy(o_sols0, solsw0*swradcorr)
[1898]615       CALL histwrite_phy(o_soll, sollw)
[2366]616       CALL histwrite_phy(o_soll0, sollw0)
[1898]617       CALL histwrite_phy(o_radsol, radsol)
[1813]618
[1898]619       IF (vars_defined) THEN
[2366]620          zx_tmp_fi2d(:) = swup(:,1)*swradcorr(:)
[1898]621       ENDIF
622       CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
[1813]623
[1898]624       IF (vars_defined) THEN
[2366]625          zx_tmp_fi2d(:) = swup0(:,1)*swradcorr(:)
[1898]626       ENDIF
627       CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
[1813]628
[1898]629       IF (vars_defined) THEN
[2366]630          zx_tmp_fi2d(:) = swdn(:,1)*swradcorr(:)
[1898]631       ENDIF
632       CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
[1813]633
[1898]634       IF (vars_defined) THEN
[2366]635          zx_tmp_fi2d(:) = swdn0(:,1)*swradcorr(:)
[1898]636       ENDIF
637       CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
[1813]638
[1898]639       IF (vars_defined) THEN
[2366]640          zx_tmp_fi2d(:)=sollwdown(:)-sollw(:)
[1898]641       ENDIF
642       CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
643       CALL histwrite_phy(o_LWdnSFC, sollwdown)
[1813]644
[1898]645       IF (vars_defined) THEN
646          sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
647          zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
648       ENDIF
649       CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
650       CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
651       CALL histwrite_phy(o_bils, bils)
652       CALL histwrite_phy(o_bils_diss, bils_diss)
653       CALL histwrite_phy(o_bils_ec, bils_ec)
[2051]654       IF (iflag_ener_conserv>=1) THEN
655         CALL histwrite_phy(o_bils_ech, bils_ech)
656       ENDIF
[1898]657       CALL histwrite_phy(o_bils_tke, bils_tke)
658       CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
659       CALL histwrite_phy(o_bils_latent, bils_latent)
660       CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
[1813]661
[1898]662       IF (vars_defined) THEN
663          zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
664       ENDIF
665       CALL histwrite_phy(o_sens, zx_tmp_fi2d)
666       CALL histwrite_phy(o_fder, fder)
667       CALL histwrite_phy(o_ffonte, zxffonte)
668       CALL histwrite_phy(o_fqcalving, zxfqcalving)
669       CALL histwrite_phy(o_fqfonte, zxfqfonte)
[2517]670       CALL histwrite_phy(o_runofflic, zxrunofflic)
[1898]671       IF (vars_defined) THEN
672          zx_tmp_fi2d=0.
673          DO nsrf=1,nbsrf
674             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
675          ENDDO
676       ENDIF
677       CALL histwrite_phy(o_taux, zx_tmp_fi2d)
[1813]678
[1898]679       IF (vars_defined) THEN
680          zx_tmp_fi2d=0.
681          DO nsrf=1,nbsrf
682             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
683          ENDDO
684       ENDIF
685       CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
[1813]686
[1898]687       IF (ok_snow) THEN
[2209]688          CALL histwrite_phy(o_snowsrf, snow_o)
[1898]689          CALL histwrite_phy(o_qsnow, qsnow)
690          CALL histwrite_phy(o_snowhgt,snowhgt)
691          CALL histwrite_phy(o_toice,to_ice)
692          CALL histwrite_phy(o_sissnow,sissnow)
693          CALL histwrite_phy(o_runoff,runoff)
694          CALL histwrite_phy(o_albslw3,albsol3_lic)
695       ENDIF
[1813]696
[1898]697       DO nsrf = 1, nbsrf
[2670]698
[1898]699          IF (vars_defined)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
700          CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
701          IF (vars_defined)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
702          CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
703          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
704          CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
705          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
706          CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
707          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
708          CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
709          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
710          CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
711          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
712          CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
713          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
714          CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
715          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
716          CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
717          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
718          CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
719          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
720          CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
721          IF (vars_defined)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
722          CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
723          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
724          CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
725          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
726          CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
727          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
728          CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
729          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
730          CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
731          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
732          CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
[2670]733          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfevap( 1 : klon, nsrf)
734          CALL histwrite_phy(o_wevap_srf(nsrf), zx_tmp_fi2d)
735          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfrain( 1 : klon, nsrf)
736          CALL histwrite_phy(o_wrain_srf(nsrf), zx_tmp_fi2d)
737          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfsnow( 1 : klon, nsrf)
738          CALL histwrite_phy(o_wsnow_srf(nsrf), zx_tmp_fi2d)
[1865]739
[1898]740          IF (iflag_pbl > 1) THEN
741             CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
[2561]742             CALL histwrite_phy(o_l_mix(nsrf),  l_mix(:,1:klev,nsrf))
743             CALL histwrite_phy(o_l_mixmin(nsrf),  l_mixmin(:,1:klev,nsrf))
[1898]744             CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
745          ENDIF
[2159]746!jyg<
[2255]747          IF (iflag_pbl > 1 .AND. iflag_wake>=1  .AND. iflag_pbl_split >=1) THEN
[2159]748             CALL histwrite_phy(o_dltpbltke_srf(nsrf), wake_delta_pbl_TKE(:,1:klev,nsrf))
749          ENDIF
750!>jyg
[1813]751
[1898]752       ENDDO
[2538]753
754       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_liq_o(1 : klon, 1)
755       CALL histwrite_phy(o_sens_prec_liq_oce, zx_tmp_fi2d)       
756       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_liq_o(1 : klon, 2)
757       CALL histwrite_phy(o_sens_prec_liq_sic, zx_tmp_fi2d)       
758       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_sol_o(1 : klon, 1)
759       CALL histwrite_phy(o_sens_prec_sol_oce, zx_tmp_fi2d)       
760       IF (vars_defined) zx_tmp_fi2d(1 : klon) = sens_prec_sol_o(1 : klon, 2)
761       CALL histwrite_phy(o_sens_prec_sol_sic, zx_tmp_fi2d)       
762
763       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_liq_o(1 : klon, 1)
764       CALL histwrite_phy(o_lat_prec_liq_oce, zx_tmp_fi2d)       
765       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_liq_o(1 : klon, 2)
766       CALL histwrite_phy(o_lat_prec_liq_sic, zx_tmp_fi2d)       
767       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_sol_o(1 : klon, 1)
768       CALL histwrite_phy(o_lat_prec_sol_oce, zx_tmp_fi2d)       
769       IF (vars_defined) zx_tmp_fi2d(1 : klon) = lat_prec_sol_o(1 : klon, 2)
770       CALL histwrite_phy(o_lat_prec_sol_sic, zx_tmp_fi2d)       
771
[1898]772       DO nsrf=1,nbsrf+1
773          CALL histwrite_phy(o_wstar(nsrf), wstar(1 : klon, nsrf))
774       ENDDO
[1813]775
[1898]776       CALL histwrite_phy(o_cdrm, cdragm)
777       CALL histwrite_phy(o_cdrh, cdragh)
778       CALL histwrite_phy(o_cldl, cldl)
779       CALL histwrite_phy(o_cldm, cldm)
780       CALL histwrite_phy(o_cldh, cldh)
781       CALL histwrite_phy(o_cldt, cldt)
[1924]782       CALL histwrite_phy(o_JrNt, JrNt)
783       CALL histwrite_phy(o_cldljn, cldl*JrNt)
784       CALL histwrite_phy(o_cldmjn, cldm*JrNt)
785       CALL histwrite_phy(o_cldhjn, cldh*JrNt)
786       CALL histwrite_phy(o_cldtjn, cldt*JrNt)
[1898]787       CALL histwrite_phy(o_cldq, cldq)
788       IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
789       CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
790       IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
791       CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
792       CALL histwrite_phy(o_ue, ue)
793       CALL histwrite_phy(o_ve, ve)
794       CALL histwrite_phy(o_uq, uq)
795       CALL histwrite_phy(o_vq, vq)
[2690]796       IF (iflag_con.GE.3) THEN ! sb
[1898]797          CALL histwrite_phy(o_cape, cape)
798          CALL histwrite_phy(o_pbase, ema_pcb)
799          CALL histwrite_phy(o_ptop, ema_pct)
800          CALL histwrite_phy(o_fbase, ema_cbmf)
[2690]801          IF (iflag_con /= 30) THEN
[1898]802             CALL histwrite_phy(o_plcl, plcl)
803             CALL histwrite_phy(o_plfc, plfc)
804             CALL histwrite_phy(o_wbeff, wbeff)
[2690]805          ENDIF
[1816]806
[1898]807          CALL histwrite_phy(o_cape_max, cape)
[1813]808
[1898]809          CALL histwrite_phy(o_upwd, upwd)
810          CALL histwrite_phy(o_Ma, Ma)
811          CALL histwrite_phy(o_dnwd, dnwd)
812          CALL histwrite_phy(o_dnwd0, dnwd0)
813          IF (vars_defined)         zx_tmp_fi2d=float(itau_con)/float(itap)
814          CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
815          IF (vars_defined) THEN
[2690]816             IF (iflag_thermals>=1)THEN
[1898]817                zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
818             ELSE
819                zx_tmp_fi3d=dnwd+dnwd0+upwd
820             ENDIF
821          ENDIF
822          CALL histwrite_phy(o_mc, zx_tmp_fi3d)
823       ENDIF !iflag_con .GE. 3
824       CALL histwrite_phy(o_prw, prw)
[2496]825       CALL histwrite_phy(o_prlw, prlw)
826       CALL histwrite_phy(o_prsw, prsw)
[1898]827       CALL histwrite_phy(o_s_pblh, s_pblh)
828       CALL histwrite_phy(o_s_pblt, s_pblt)
829       CALL histwrite_phy(o_s_lcl, s_lcl)
830       CALL histwrite_phy(o_s_therm, s_therm)
831       !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
832       !       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
833       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
834       !    $o_s_capCL%name,itau_w,s_capCL)
835       !       ENDIF
836       !       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
837       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
838       !    $o_s_oliqCL%name,itau_w,s_oliqCL)
839       !       ENDIF
840       !       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
841       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
842       !    $o_s_cteiCL%name,itau_w,s_cteiCL)
843       !       ENDIF
844       !       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
845       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
846       !    $o_s_trmb1%name,itau_w,s_trmb1)
847       !       ENDIF
848       !       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
849       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
850       !    $o_s_trmb2%name,itau_w,s_trmb2)
851       !       ENDIF
852       !       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
853       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
854       !    $o_s_trmb3%name,itau_w,s_trmb3)
855       !       ENDIF
[1813]856
[2282]857#ifdef CPP_IOIPSL
858#ifndef CPP_XIOS
[2271]859  IF (.NOT.ok_all_xml) THEN
[1898]860       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
861       ! Champs interpolles sur des niveaux de pression
[2271]862       missing_val=missing_val_nf90
[1898]863       DO iff=1, nfiles
864          ll=0
865          DO k=1, nlevSTD
866             bb2=clevSTD(k)
[2690]867             IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
[1898]868                  bb2.EQ."500".OR.bb2.EQ."200".OR. &
869                  bb2.EQ."100".OR. &
870                  bb2.EQ."50".OR.bb2.EQ."10") THEN
[1813]871
[1898]872                ! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
873                ll=ll+1
874                CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
875                CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
876                CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
877                CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
878                CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
879                CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
[1813]880
[1898]881             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
882          ENDDO
[1813]883       ENDDO
[2282]884  ENDIF
885#endif
886#endif
887#ifdef CPP_XIOS
[2690]888  IF (ok_all_xml) THEN
[2271]889!XIOS  CALL xios_get_field_attr("u850",default_value=missing_val)
890!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
891          ll=0
892          DO k=1, nlevSTD
893             bb2=clevSTD(k)
[2690]894             IF (bb2.EQ."850".OR.bb2.EQ."700".OR. &
[2271]895                bb2.EQ."500".OR.bb2.EQ."200".OR. &
896                bb2.EQ."100".OR. &
897                bb2.EQ."50".OR.bb2.EQ."10") THEN
898                ll=ll+1
[2282]899                CALL histwrite_phy(o_uSTDlevs(ll),ulevSTD(:,k))
900                CALL histwrite_phy(o_vSTDlevs(ll),vlevSTD(:,k))
901                CALL histwrite_phy(o_wSTDlevs(ll),wlevSTD(:,k))
902                CALL histwrite_phy(o_zSTDlevs(ll),philevSTD(:,k))
903                CALL histwrite_phy(o_qSTDlevs(ll),qlevSTD(:,k))
904                CALL histwrite_phy(o_tSTDlevs(ll),tlevSTD(:,k))
[2271]905             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
906          ENDDO
907  ENDIF
[2282]908#endif
[1898]909       IF (vars_defined) THEN
910          DO i=1, klon
911             IF (pctsrf(i,is_oce).GT.epsfra.OR. &
912                  pctsrf(i,is_sic).GT.epsfra) THEN
913                zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
914                     ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
915                     (pctsrf(i,is_oce)+pctsrf(i,is_sic))
916             ELSE
917                zx_tmp_fi2d(i) = 273.15
918             ENDIF
919          ENDDO
[1813]920       ENDIF
[1898]921       CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
[1813]922
[1898]923       ! Couplage convection-couche limite
924       IF (iflag_con.GE.3) THEN
925          IF (iflag_coupl>=1) THEN
926             CALL histwrite_phy(o_ale_bl, ale_bl)
927             CALL histwrite_phy(o_alp_bl, alp_bl)
928          ENDIF !iflag_coupl>=1
929       ENDIF !(iflag_con.GE.3)
930       ! Wakes
931       IF (iflag_con.EQ.3) THEN
932          IF (iflag_wake>=1) THEN
933             CALL histwrite_phy(o_ale_wk, ale_wake)
934             CALL histwrite_phy(o_alp_wk, alp_wake)
[2393]935             IF (iflag_pbl_split>=1) THEN
936               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dtvdf_x(1:klon,1:klev)/pdtphys
937               CALL histwrite_phy(o_dtvdf_x    ,zx_tmp_fi3d)
938               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dtvdf_w(1:klon,1:klev)/pdtphys
939               CALL histwrite_phy(o_dtvdf_w    ,zx_tmp_fi3d)
940               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dqvdf_x(1:klon,1:klev)/pdtphys
941               CALL histwrite_phy(o_dqvdf_x    ,zx_tmp_fi3d)
942               IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=dqvdf_w(1:klon,1:klev)/pdtphys
943               CALL histwrite_phy(o_dqvdf_w    ,zx_tmp_fi3d)
944               CALL histwrite_phy(o_sens_x     ,sens_x     )
945               CALL histwrite_phy(o_sens_w     ,sens_w     )
946               CALL histwrite_phy(o_flat_x     ,zxfluxlat_x)
947               CALL histwrite_phy(o_flat_w     ,zxfluxlat_w)
948               CALL histwrite_phy(o_delta_tsurf,delta_tsurf)
949               CALL histwrite_phy(o_cdragh_x   ,cdragh_x   )
950               CALL histwrite_phy(o_cdragh_w   ,cdragh_w   )
951               CALL histwrite_phy(o_cdragm_x   ,cdragm_x   )
952               CALL histwrite_phy(o_cdragm_w   ,cdragm_w   )
953               CALL histwrite_phy(o_kh         ,kh         )
954               CALL histwrite_phy(o_kh_x       ,kh_x       )
955               CALL histwrite_phy(o_kh_w       ,kh_w       )
956             ENDIF   ! (iflag_pbl_split>=1)
[1898]957             CALL histwrite_phy(o_ale, ale)
958             CALL histwrite_phy(o_alp, alp)
959             CALL histwrite_phy(o_cin, cin)
960             CALL histwrite_phy(o_WAPE, wake_pe)
961             CALL histwrite_phy(o_wake_h, wake_h)
962             CALL histwrite_phy(o_wake_s, wake_s)
963             CALL histwrite_phy(o_wake_deltat, wake_deltat)
964             CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
965             CALL histwrite_phy(o_wake_omg, wake_omg)
966             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
967                  /pdtphys
968             CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
969             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
970             CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
[2486]971             CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
972             CALL histwrite_phy(o_dqwak2d, zx_tmp_fi2d)
[1898]973          ENDIF ! iflag_wake>=1
974          CALL histwrite_phy(o_ftd, ftd)
975          CALL histwrite_phy(o_fqd, fqd)
[2253]976       ENDIF !(iflag_con.EQ.3)
977       IF (iflag_con.EQ.3.OR.iflag_con.EQ.30) THEN
[1898]978          ! sortie RomP convection descente insaturee iflag_con=30
[2253]979          ! etendue a iflag_con=3 (jyg)
[1898]980          CALL histwrite_phy(o_Vprecip, Vprecip)
981          CALL histwrite_phy(o_wdtrainA, wdtrainA)
982          CALL histwrite_phy(o_wdtrainM, wdtrainM)
983       ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
[1813]984!!! nrlmd le 10/04/2012
[1898]985       IF (iflag_trig_bl>=1) THEN
986          CALL histwrite_phy(o_n2, n2)
987          CALL histwrite_phy(o_s2, s2)
988          CALL histwrite_phy(o_proba_notrig, proba_notrig)
989          CALL histwrite_phy(o_random_notrig, random_notrig)
990          CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
991          CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
[1813]992       ENDIF  !(iflag_trig_bl>=1)
[1898]993       IF (iflag_clos_bl>=1) THEN
994          CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
995          CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
996          CALL histwrite_phy(o_alp_bl_fluct_tke,  &
997               alp_bl_fluct_tke)
998          CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
999          CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
[1813]1000       ENDIF  !(iflag_clos_bl>=1)
1001!!! fin nrlmd le 10/04/2012
[2057]1002       ! Output of slab ocean variables
[1898]1003       IF (type_ocean=='slab ') THEN
[2057]1004          CALL histwrite_phy(o_slab_qflux, slab_wfbils)
1005          CALL histwrite_phy(o_slab_bils, slab_bils)
1006          IF (nslay.EQ.1) THEN
1007              zx_tmp_fi2d(:)=tslab(:,1)
1008              CALL histwrite_phy(o_tslab, zx_tmp_fi2d)
1009          ELSE
[2656]1010              CALL histwrite_phy(o_tslab, tslab(:,1:nslay))
[2690]1011          ENDIF
[2209]1012          IF (version_ocean=='sicINT') THEN
1013              CALL histwrite_phy(o_slab_bilg, slab_bilg)
1014              CALL histwrite_phy(o_slab_tice, tice)
1015              CALL histwrite_phy(o_slab_sic, seaice)
[2690]1016          ENDIF
[2656]1017          IF (slab_hdiff) THEN
1018            IF (nslay.EQ.1) THEN
1019                zx_tmp_fi2d(:)=dt_hdiff(:,1)
1020                CALL histwrite_phy(o_slab_hdiff, zx_tmp_fi2d)
1021            ELSE
1022                CALL histwrite_phy(o_slab_hdiff, dt_hdiff(:,1:nslay))
[2690]1023            ENDIF
1024          ENDIF
[2656]1025          IF (slab_ekman.GT.0) THEN
1026            IF (nslay.EQ.1) THEN
1027                zx_tmp_fi2d(:)=dt_ekman(:,1)
1028                CALL histwrite_phy(o_slab_ekman, zx_tmp_fi2d)
1029            ELSE
1030                CALL histwrite_phy(o_slab_ekman, dt_ekman(:,1:nslay))
[2690]1031            ENDIF
1032          ENDIF
[1898]1033       ENDIF !type_ocean == force/slab
1034       CALL histwrite_phy(o_weakinv, weak_inversion)
1035       CALL histwrite_phy(o_dthmin, dthmin)
1036       CALL histwrite_phy(o_cldtau, cldtau)
1037       CALL histwrite_phy(o_cldemi, cldemi)
1038       CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
1039       CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
1040       CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
1041       CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
1042       CALL histwrite_phy(o_re, re)
1043       CALL histwrite_phy(o_fl, fl)
1044       IF (vars_defined) THEN
1045          DO i=1, klon
1046             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
1047          ENDDO
1048       ENDIF
1049       CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
[1813]1050
[1898]1051       IF (vars_defined) THEN
1052          DO i=1, klon
1053             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
1054          ENDDO
1055       ENDIF
1056       CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
[1813]1057
[1898]1058       IF (vars_defined) THEN
1059          DO i=1, klon
1060             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
1061          ENDDO
1062       ENDIF
1063       CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
[1813]1064
[1898]1065       CALL histwrite_phy(o_qsat2m, qsat2m)
1066       CALL histwrite_phy(o_tpot, tpot)
1067       CALL histwrite_phy(o_tpote, tpote)
1068       IF (vars_defined) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
1069       CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
1070       IF (vars_defined) zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
1071       CALL histwrite_phy(o_SWdownOR,  zx_tmp_fi2d)
1072       CALL histwrite_phy(o_LWdownOR, sollwdown)
1073       CALL histwrite_phy(o_snowl, snow_lsc)
1074       CALL histwrite_phy(o_solldown, sollwdown)
1075       CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
1076       CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
1077       CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
1078       CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
[2243]1079       CALL histwrite_phy(o_z0m, z0m(:,nbsrf+1))
1080       CALL histwrite_phy(o_z0h, z0h(:,nbsrf+1))
[1898]1081       ! OD550 per species
[2146]1082!--OLIVIER
1083!This is warranted by treating INCA aerosols as offline aerosols
1084!       IF (new_aod .and. (.not. aerosol_couple)) THEN
1085       IF (new_aod) THEN
[2003]1086          IF (flag_aerosol.GT.0) THEN
[1898]1087             CALL histwrite_phy(o_od550aer, od550aer)
1088             CALL histwrite_phy(o_od865aer, od865aer)
1089             CALL histwrite_phy(o_absvisaer, absvisaer)
1090             CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
1091             CALL histwrite_phy(o_sconcso4, sconcso4)
[2146]1092             CALL histwrite_phy(o_sconcno3, sconcno3)
[1898]1093             CALL histwrite_phy(o_sconcoa, sconcoa)
1094             CALL histwrite_phy(o_sconcbc, sconcbc)
1095             CALL histwrite_phy(o_sconcss, sconcss)
1096             CALL histwrite_phy(o_sconcdust, sconcdust)
1097             CALL histwrite_phy(o_concso4, concso4)
[2146]1098             CALL histwrite_phy(o_concno3, concno3)
[1898]1099             CALL histwrite_phy(o_concoa, concoa)
1100             CALL histwrite_phy(o_concbc, concbc)
1101             CALL histwrite_phy(o_concss, concss)
1102             CALL histwrite_phy(o_concdust, concdust)
1103             CALL histwrite_phy(o_loadso4, loadso4)
1104             CALL histwrite_phy(o_loadoa, loadoa)
1105             CALL histwrite_phy(o_loadbc, loadbc)
1106             CALL histwrite_phy(o_loadss, loadss)
1107             CALL histwrite_phy(o_loaddust, loaddust)
1108             !--STRAT AER
[1813]1109          ENDIF
[2530]1110          IF (flag_aerosol.GT.0.OR.flag_aerosol_strat.GT.0) THEN
[2003]1111             DO naero = 1, naero_tot
[2690]1112                CALL histwrite_phy(o_tausumaero(naero),tausum_aero(:,2,naero))
[1898]1113             END DO
[1813]1114          ENDIF
[2530]1115          IF (flag_aerosol_strat.GT.0) THEN
[2690]1116             CALL histwrite_phy(o_tausumaero_lw,tausum_aero(:,6,id_STRAT_phy))
[2146]1117          ENDIF
[1898]1118       ENDIF
[2690]1119#ifdef CPP_StratAer
1120       IF (type_trac=='coag') THEN
1121          CALL histwrite_phy(o_sulf_convert, sulf_convert)
1122          CALL histwrite_phy(o_sulf_nucl, sulf_nucl)
1123          CALL histwrite_phy(o_sulf_cond_evap, sulf_cond_evap)
1124          CALL histwrite_phy(o_ocs_convert, ocs_convert)
1125          CALL histwrite_phy(o_R2SO4, R2SO4)
1126          CALL histwrite_phy(o_OCS_lifetime, OCS_lifetime)
1127          CALL histwrite_phy(o_SO2_lifetime, SO2_lifetime)
1128          CALL histwrite_phy(o_OCS_backgr_tend, OCS_backgr_tend)
1129          CALL histwrite_phy(o_SO2_backgr_tend, SO2_backgr_tend)
1130          CALL histwrite_phy(o_sulf_dep_dry, sulf_dep_dry)
1131          CALL histwrite_phy(o_sulf_dep_wet, sulf_dep_wet)
1132          CALL histwrite_phy(o_surf_PM25_sulf, surf_PM25_sulf)
1133          CALL histwrite_phy(o_p_tropopause, p_tropopause)
1134          CALL histwrite_phy(o_sfluxaer, sfluxaer)
1135          CALL histwrite_phy(o_vsed_aer, vsed_aer)
1136          CALL histwrite_phy(o_f_r_wet, f_r_wet)
1137          CALL histwrite_phy(o_ext_strat_550, tau_strat_550)
1138          CALL histwrite_phy(o_ext_strat_1020, tau_strat_1020)
1139          CALL histwrite_phy(o_tau_strat_550, tausum_strat(:,1))
1140          CALL histwrite_phy(o_tau_strat_1020, tausum_strat(:,2))
1141       ENDIF
1142#endif
[1813]1143       IF (ok_ade) THEN
[2366]1144          CALL histwrite_phy(o_topswad, topswad_aero*swradcorr)
1145          CALL histwrite_phy(o_topswad0, topswad0_aero*swradcorr)
1146          CALL histwrite_phy(o_solswad, solswad_aero*swradcorr)
1147          CALL histwrite_phy(o_solswad0, solswad0_aero*swradcorr)
[2146]1148          CALL histwrite_phy(o_toplwad, toplwad_aero)
1149          CALL histwrite_phy(o_toplwad0, toplwad0_aero)
1150          CALL histwrite_phy(o_sollwad, sollwad_aero)
1151          CALL histwrite_phy(o_sollwad0, sollwad0_aero)
[1898]1152          !====MS forcing diagnostics
[2690]1153          IF (new_aod) THEN
[2366]1154             zx_tmp_fi2d(:)=topsw_aero(:,1)*swradcorr(:)
1155             CALL histwrite_phy(o_swtoaas_nat,zx_tmp_fi2d)
1156             zx_tmp_fi2d(:)=solsw_aero(:,1)*swradcorr(:)
1157             CALL histwrite_phy(o_swsrfas_nat,zx_tmp_fi2d)
1158             zx_tmp_fi2d(:)=topsw0_aero(:,1)*swradcorr(:)
1159             CALL histwrite_phy(o_swtoacs_nat,zx_tmp_fi2d)
1160             zx_tmp_fi2d(:)=solsw0_aero(:,1)*swradcorr(:)
1161             CALL histwrite_phy(o_swsrfcs_nat,zx_tmp_fi2d)
[1898]1162             !ant
[2366]1163             zx_tmp_fi2d(:)=topsw_aero(:,2)*swradcorr(:)
1164             CALL histwrite_phy(o_swtoaas_ant,zx_tmp_fi2d)
1165             zx_tmp_fi2d(:)=solsw_aero(:,2)*swradcorr(:)
1166             CALL histwrite_phy(o_swsrfas_ant,zx_tmp_fi2d)
1167             zx_tmp_fi2d(:)=topsw0_aero(:,2)*swradcorr(:)
1168             CALL histwrite_phy(o_swtoacs_ant,zx_tmp_fi2d)
1169             zx_tmp_fi2d(:)=solsw0_aero(:,2)*swradcorr(:)
1170             CALL histwrite_phy(o_swsrfcs_ant,zx_tmp_fi2d)
[1898]1171             !cf
[2690]1172             IF (.not. aerosol_couple) THEN
[2366]1173                zx_tmp_fi2d(:)=topswcf_aero(:,1)*swradcorr(:)
1174                CALL histwrite_phy(o_swtoacf_nat,zx_tmp_fi2d)
1175                zx_tmp_fi2d(:)=solswcf_aero(:,1)*swradcorr(:)
1176                CALL histwrite_phy(o_swsrfcf_nat,zx_tmp_fi2d)
1177                zx_tmp_fi2d(:)=topswcf_aero(:,2)*swradcorr(:)
1178                CALL histwrite_phy(o_swtoacf_ant,zx_tmp_fi2d)
1179                zx_tmp_fi2d(:)=solswcf_aero(:,2)*swradcorr(:)
1180                CALL histwrite_phy(o_swsrfcf_ant,zx_tmp_fi2d)
1181                zx_tmp_fi2d(:)=topswcf_aero(:,3)*swradcorr(:)
1182                CALL histwrite_phy(o_swtoacf_zero,zx_tmp_fi2d)
1183                zx_tmp_fi2d(:)=solswcf_aero(:,3)*swradcorr(:)
1184                CALL histwrite_phy(o_swsrfcf_zero,zx_tmp_fi2d)
[2690]1185             ENDIF
1186          ENDIF ! new_aod
[1898]1187          !====MS forcing diagnostics
[1813]1188       ENDIF
1189       IF (ok_aie) THEN
[2366]1190          CALL histwrite_phy(o_topswai, topswai_aero*swradcorr)
1191          CALL histwrite_phy(o_solswai, solswai_aero*swradcorr)
[2003]1192       ENDIF
1193       IF (flag_aerosol.GT.0.AND.ok_cdnc) THEN
[1898]1194          CALL histwrite_phy(o_scdnc, scdnc)
1195          CALL histwrite_phy(o_cldncl, cldncl)
1196          CALL histwrite_phy(o_reffclws, reffclws)
1197          CALL histwrite_phy(o_reffclwc, reffclwc)
1198          CALL histwrite_phy(o_cldnvi, cldnvi)
1199          CALL histwrite_phy(o_lcc, lcc)
1200          CALL histwrite_phy(o_lcc3d, lcc3d)
1201          CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
1202          CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
1203          CALL histwrite_phy(o_reffclwtop, reffclwtop)
[1813]1204       ENDIF
[1898]1205       ! Champs 3D:
[1813]1206       IF (ok_ade .OR. ok_aie) then
[1898]1207          CALL histwrite_phy(o_ec550aer, ec550aer)
[1813]1208       ENDIF
[1898]1209       CALL histwrite_phy(o_lwcon, flwc)
1210       CALL histwrite_phy(o_iwcon, fiwc)
1211       CALL histwrite_phy(o_temp, t_seri)
1212       CALL histwrite_phy(o_theta, theta)
1213       CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
1214       CALL histwrite_phy(o_ovap, q_seri)
1215       CALL histwrite_phy(o_oliq, ql_seri)
[2553]1216       CALL histwrite_phy(o_ocond, ql_seri+qs_seri)
[1898]1217       CALL histwrite_phy(o_geop, zphi)
1218       CALL histwrite_phy(o_vitu, u_seri)
1219       CALL histwrite_phy(o_vitv, v_seri)
1220       CALL histwrite_phy(o_vitw, omega)
1221       CALL histwrite_phy(o_pres, pplay)
1222       CALL histwrite_phy(o_paprs, paprs(:,1:klev))
[2377]1223       CALL histwrite_phy(o_zfull,zphi/RG)
[1813]1224
[2541]1225       IF (flag_aerosol_strat.EQ.2) THEN
1226         CALL histwrite_phy(o_stratomask, stratomask)
1227       ENDIF
1228     
[1898]1229       IF (vars_defined)  THEN
[2377]1230        zx_tmp_fi3d(:,1)= pphis(:)/RG
1231        DO k = 2, klev
1232         DO i = 1, klon
1233            zx_tmp_fi3d(i,k) = zphi(i,k)/RG + &
1234                          (zphi(i,k)-zphi(i,k-1))/RG * &
1235                          (paprs(i,k)-pplay(i,k))/(pplay(i,k)-pplay(i,k-1))
1236         ENDDO
1237        ENDDO
[1898]1238       ENDIF
1239       CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
1240       CALL histwrite_phy(o_rneb, cldfra)
1241       CALL histwrite_phy(o_rnebcon, rnebcon)
1242       CALL histwrite_phy(o_rnebls, rneb)
[1938]1243       IF (vars_defined)  THEN
1244          DO k=1, klev
1245             DO i=1, klon
1246                zx_tmp_fi3d(i,k)=cldfra(i,k)*JrNt(i)
1247             ENDDO
1248          ENDDO
1249       ENDIF
[1924]1250       CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
[1898]1251       CALL histwrite_phy(o_rhum, zx_rh)
1252       CALL histwrite_phy(o_ozone, &
1253            wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
[1813]1254
[1898]1255       IF (read_climoz == 2) THEN
1256          CALL histwrite_phy(o_ozone_light, &
1257               wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1258       ENDIF
[1813]1259
[2665]1260       CALL histwrite_phy(o_duphy, d_u)
1261
[1898]1262       CALL histwrite_phy(o_dtphy, d_t)
[2496]1263
[1898]1264       CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
[2486]1265       CALL water_int(klon,klev,d_qx(:,:,ivap),zmasse,zx_tmp_fi2d)
1266       CALL histwrite_phy(o_dqphy2d,  zx_tmp_fi2d)
[2496]1267
1268       CALL histwrite_phy(o_dqlphy,  d_qx(:,:,iliq))
1269       CALL water_int(klon,klev,d_qx(:,:,iliq),zmasse,zx_tmp_fi2d)
1270       CALL histwrite_phy(o_dqlphy2d,  zx_tmp_fi2d)
1271
1272       IF (nqo.EQ.3) THEN
1273       CALL histwrite_phy(o_dqsphy,  d_qx(:,:,isol))
1274       CALL water_int(klon,klev,d_qx(:,:,isol),zmasse,zx_tmp_fi2d)
1275       CALL histwrite_phy(o_dqsphy2d,  zx_tmp_fi2d)
1276       ELSE
1277       zx_tmp_fi3d=0.0
1278       CALL histwrite_phy(o_dqsphy,  zx_tmp_fi3d)
1279       zx_tmp_fi2d=0.0
1280       CALL histwrite_phy(o_dqsphy2d,  zx_tmp_fi2d)
1281       ENDIF
1282
[1898]1283       DO nsrf=1, nbsrf
1284          IF (vars_defined) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
1285          CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
[2243]1286          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0m( 1 : klon, nsrf)
1287          CALL histwrite_phy(o_z0m_srf(nsrf), zx_tmp_fi2d)
1288          IF (vars_defined) zx_tmp_fi2d(1 : klon) = z0h( 1 : klon, nsrf)
1289          CALL histwrite_phy(o_z0h_srf(nsrf), zx_tmp_fi2d)
[1898]1290          IF (vars_defined) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
1291          CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
[2209]1292          IF (vars_defined) zx_tmp_fi2d(1 : klon) = snow( 1 : klon, nsrf)
1293          CALL histwrite_phy(o_snow_srf(nsrf), zx_tmp_fi2d)
[1898]1294       ENDDO !nsrf=1, nbsrf
1295       CALL histwrite_phy(o_alb1, albsol1)
1296       CALL histwrite_phy(o_alb2, albsol2)
1297       !FH Sorties pour la couche limite
[2690]1298       IF (iflag_pbl>1) THEN
[1898]1299          zx_tmp_fi3d=0.
1300          IF (vars_defined) THEN
[2690]1301             DO nsrf=1,nbsrf
1302                DO k=1,klev
[1898]1303                   zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
1304                        +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
[2690]1305                ENDDO
1306             ENDDO
[1898]1307          ENDIF
1308          CALL histwrite_phy(o_tke, zx_tmp_fi3d)
[1813]1309
[1898]1310          CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
1311       ENDIF
[1813]1312
[1898]1313       CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
[1813]1314
[1898]1315       CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
[1813]1316
[1898]1317       CALL histwrite_phy(o_clwcon, clwcon0)
1318       CALL histwrite_phy(o_dtdyn, d_t_dyn)
[2496]1319
[1898]1320       CALL histwrite_phy(o_dqdyn, d_q_dyn)
[2496]1321
[2499]1322       CALL histwrite_phy(o_dqdyn2d,d_q_dyn2d)
1323
[2496]1324       CALL histwrite_phy(o_dqldyn, d_ql_dyn)
1325
[2499]1326       CALL histwrite_phy(o_dqldyn2d, d_ql_dyn2d)
1327
[2496]1328       CALL histwrite_phy(o_dqsdyn, d_qs_dyn)
1329
[2499]1330       CALL histwrite_phy(o_dqsdyn2d, d_qs_dyn2d)
1331
[1898]1332       CALL histwrite_phy(o_dudyn, d_u_dyn)
1333       CALL histwrite_phy(o_dvdyn, d_v_dyn)
[1813]1334
[1898]1335       IF (vars_defined) THEN
1336          zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
1337       ENDIF
1338       CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
[2102]1339       if(iflag_thermals.eq.0)then
[1898]1340          IF (vars_defined) THEN
1341             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
1342                  d_t_ajsb(1:klon,1:klev)/pdtphys
1343          ENDIF
1344          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
[2102]1345       else if(iflag_thermals.ge.1.and.iflag_wake.EQ.1)then
[1898]1346          IF (vars_defined) THEN
1347             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
1348                  d_t_ajs(1:klon,1:klev)/pdtphys + &
1349                  d_t_wake(1:klon,1:klev)/pdtphys
1350          ENDIF
1351          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
1352       endif
1353       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
1354       CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
1355       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
1356       CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
1357       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1358       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
[2486]1359       CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1360       CALL histwrite_phy(o_dqcon2d, zx_tmp_fi2d)
[1813]1361
[2690]1362       IF (iflag_thermals.EQ.0) THEN
[1898]1363          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1364          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
[2690]1365       ELSE IF (iflag_thermals.GE.1.AND.iflag_wake.EQ.1) THEN
[1898]1366          IF (vars_defined) THEN
1367             zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
1368                  d_q_ajs(1:klon,1:klev)/pdtphys + &
1369                  d_q_wake(1:klon,1:klev)/pdtphys
1370          ENDIF
1371          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
1372       ENDIF
[1813]1373
[1898]1374       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
1375       CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
1376       IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
1377            d_t_eva(1:klon,1:klev))/pdtphys
1378       CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
1379       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
1380       CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
[2486]1381       CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1382       CALL histwrite_phy(o_dqlsc2d, zx_tmp_fi2d)
[1898]1383       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
1384       CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
[1813]1385!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1898]1386       ! Sorties specifiques a la separation thermiques/non thermiques
[2690]1387       IF (iflag_thermals>=1) THEN
1388          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
[1898]1389          CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
[2690]1390          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
[1898]1391          CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
[2690]1392          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
[1898]1393          CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
[2486]1394          CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1395          CALL histwrite_phy(o_dqlscth2d, zx_tmp_fi2d)
[2690]1396          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
[1898]1397          CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
[2486]1398          CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1399          CALL histwrite_phy(o_dqlscst2d, zx_tmp_fi2d)
[1898]1400          CALL histwrite_phy(o_plulth, plul_th)
1401          CALL histwrite_phy(o_plulst, plul_st)
1402          IF (vars_defined) THEN
[2690]1403             DO k=1,klev
1404                DO i=1,klon
1405                   IF (ptconvth(i,k)) THEN
[1898]1406                      zx_tmp_fi3d(i,k)=1.
[2690]1407                   ELSE
[1898]1408                      zx_tmp_fi3d(i,k)=0.
[2690]1409                   ENDIF
1410                ENDDO
1411             ENDDO
[1898]1412          ENDIF
1413          CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
1414          IF (vars_defined) THEN
1415             do i=1,klon
1416                zx_tmp_fi2d(1:klon)=lmax_th(:)
1417             enddo
1418          ENDIF
1419          CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
[2690]1420       ENDIF ! iflag_thermals>=1
[1813]1421!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[1898]1422       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
1423       CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
[2690]1424       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
[1898]1425       CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
1426       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1427       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
[2486]1428       CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1429       CALL histwrite_phy(o_dqvdf2d, zx_tmp_fi2d)
[1898]1430       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1431       CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
1432       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1433       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
[2486]1434       CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1435       CALL histwrite_phy(o_dqeva2d, zx_tmp_fi2d)
[1898]1436       zpt_conv = 0.
1437       WHERE (ptconv) zpt_conv = 1.
1438       CALL histwrite_phy(o_ptconv, zpt_conv)
1439       CALL histwrite_phy(o_ratqs, ratqs)
1440       IF (vars_defined) THEN
1441          zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
1442               d_t_ajsb(1:klon,1:klev)/pdtphys
1443       ENDIF
1444       CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
[1903]1445       IF (vars_defined) THEN
[1943]1446          zx_tmp_fi3d(1:klon,1:klev)=d_u_ajs(1:klon,1:klev)/pdtphys
[1903]1447       ENDIF
1448       CALL histwrite_phy(o_duthe, zx_tmp_fi3d)
1449       IF (vars_defined) THEN
[1943]1450          zx_tmp_fi3d(1:klon,1:klev)=d_v_ajs(1:klon,1:klev)/pdtphys
[1903]1451       ENDIF
1452       CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
1453
[1813]1454       IF (iflag_thermals>=1) THEN
[1898]1455          ! Pour l instant 0 a y reflichir pour les thermiques
1456          zx_tmp_fi2d=0.
1457          CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
1458          CALL histwrite_phy(o_f_th, fm_therm)
1459          CALL histwrite_phy(o_e_th, entr_therm)
1460          CALL histwrite_phy(o_w_th, zw2)
1461          CALL histwrite_phy(o_q_th, zqasc)
1462          CALL histwrite_phy(o_a_th, fraca)
1463          CALL histwrite_phy(o_d_th, detr_therm)
1464          CALL histwrite_phy(o_f0_th, f0)
1465          CALL histwrite_phy(o_zmax_th, zmax_th)
1466          IF (vars_defined) THEN
1467             zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
1468                  d_q_ajsb(1:klon,1:klev)/pdtphys
1469          ENDIF
1470          CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
[2486]1471          CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1472          CALL histwrite_phy(o_dqthe2d, zx_tmp_fi2d)
[1898]1473       ENDIF !iflag_thermals
[2690]1474       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
[1898]1475       CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
[2690]1476       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
[1898]1477       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
[2486]1478       CALL water_int(klon,klev,zx_tmp_fi3d,zmasse,zx_tmp_fi2d)
1479       CALL histwrite_phy(o_dqajs2d, zx_tmp_fi2d)
[2690]1480       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys
[1898]1481       CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
[2690]1482       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_sw0(1:klon,1:klev)/pdtphys
[1898]1483       CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
[2690]1484       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lwr(1:klon,1:klev)/pdtphys
[1898]1485       CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
[2690]1486       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lw0(1:klon,1:klev)/pdtphys
[1898]1487       CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
[2690]1488       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
[1898]1489       CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
[2690]1490       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
[1898]1491       CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
[2690]1492       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
[1898]1493       CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
[1813]1494       IF (ok_orodr) THEN
[2690]1495          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
[1898]1496          CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
[2690]1497          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
[1898]1498          CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
[2690]1499          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
[1898]1500          CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
[1813]1501       ENDIF
[1898]1502       IF (ok_orolf) THEN
[2690]1503          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
[1898]1504          CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
[1903]1505
[2690]1506          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
[1903]1507          CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
1508
[2690]1509          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
[1903]1510          CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
[1813]1511       ENDIF
1512
1513       IF (ok_hines) THEN
[2333]1514          CALL histwrite_phy(o_du_gwd_hines, du_gwd_hines/pdtphys)
1515          CALL histwrite_phy(o_dv_gwd_hines, dv_gwd_hines/pdtphys)
[2690]1516          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
[1898]1517          CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
[2333]1518          CALL histwrite_phy(o_ustr_gwd_hines, zustr_gwd_hines)
1519          CALL histwrite_phy(o_vstr_gwd_hines, zvstr_gwd_hines)
[2690]1520       ENDIF
[2333]1521
[2690]1522       IF (.not. ok_hines .and. ok_gwd_rando) THEN
[2333]1523          CALL histwrite_phy(o_du_gwd_front, du_gwd_front / pdtphys)
1524          CALL histwrite_phy(o_dv_gwd_front, dv_gwd_front / pdtphys)
1525          CALL histwrite_phy(o_ustr_gwd_front, zustr_gwd_front)
1526          CALL histwrite_phy(o_vstr_gwd_front, zvstr_gwd_front)
[1898]1527       ENDIF
[1938]1528
[2690]1529       IF (ok_gwd_rando) THEN
[1938]1530          CALL histwrite_phy(o_du_gwd_rando, du_gwd_rando / pdtphys)
1531          CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_rando / pdtphys)
[2333]1532          CALL histwrite_phy(o_ustr_gwd_rando, zustr_gwd_rando)
[1938]1533          CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
[2333]1534          CALL histwrite_phy(o_east_gwstress, east_gwstress )
1535          CALL histwrite_phy(o_west_gwstress, west_gwstress )
[2690]1536       ENDIF
[1938]1537
[2690]1538       IF (ok_qch4) THEN
[2136]1539          CALL histwrite_phy(o_dqch4, d_q_ch4 / pdtphys)
1540       ENDIF
1541
[2366]1542       DO k=1, klevp1
1543         zx_tmp_fi3d1(:,k)=swup(:,k)*swradcorr(:)
1544       ENDDO
1545       CALL histwrite_phy(o_rsu, zx_tmp_fi3d1)
1546       DO k=1, klevp1
1547         zx_tmp_fi3d1(:,k)=swdn(:,k)*swradcorr(:)
1548       ENDDO
1549       CALL histwrite_phy(o_rsd, zx_tmp_fi3d1)
1550       DO k=1, klevp1
1551         zx_tmp_fi3d1(:,k)=swup0(:,k)*swradcorr(:)
1552       ENDDO
1553       CALL histwrite_phy(o_rsucs, zx_tmp_fi3d1)
1554       DO k=1, klevp1
1555         zx_tmp_fi3d1(:,k)=swdn0(:,k)*swradcorr(:)
1556       ENDDO
1557       CALL histwrite_phy(o_rsdcs, zx_tmp_fi3d1)
1558
[1898]1559       CALL histwrite_phy(o_rlu, lwup)
1560       CALL histwrite_phy(o_rld, lwdn)
1561       CALL histwrite_phy(o_rlucs, lwup0)
1562       CALL histwrite_phy(o_rldcs, lwdn0)
[2366]1563
[2690]1564       IF (vars_defined) THEN
[1898]1565          zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
1566               d_t_dyn(1:klon,1:klev)
1567       ENDIF
1568       CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
[2366]1569
[2690]1570       IF (vars_defined) THEN
[2194]1571          zx_tmp_fi3d(1:klon,1:klev)=d_t_swr(1:klon,1:klev)/pdtphys + &
1572               d_t_lwr(1:klon,1:klev)/pdtphys
[1898]1573       ENDIF
1574       CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
[2690]1575       IF (vars_defined) THEN
[1898]1576          zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
1577               d_t_eva(1:klon,1:klev)+ &
1578               d_t_vdf(1:klon,1:klev))/pdtphys
1579       ENDIF
1580       CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
[2690]1581       IF (vars_defined) THEN
[1898]1582          zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
1583               d_q_dyn(1:klon,1:klev)
1584       ENDIF
1585       CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
[2690]1586       IF (vars_defined) THEN
[1898]1587          zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
1588               d_q_eva(1:klon,1:klev)/pdtphys
1589       ENDIF
1590       CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
1591       CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
[2690]1592       IF (vars_defined) THEN
[1898]1593          zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
1594               ql_seri(1:klon,1:klev)
1595       ENDIF
1596       CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
[2690]1597       IF (iflag_con >= 3) THEN
1598          IF (vars_defined) THEN
[1813]1599             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
1600                  dnwd0(1:klon,1:klev))
[1898]1601          ENDIF
1602          CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
[2690]1603          IF (vars_defined) THEN
[1813]1604             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
1605                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev)
[1898]1606          ENDIF
1607          CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
[2690]1608       ELSE IF (iflag_con == 2) THEN
[1898]1609          CALL histwrite_phy(o_mcd,  pmfd)
1610          CALL histwrite_phy(o_dmc,  pmfu + pmfd)
[2690]1611       ENDIF
[1898]1612       CALL histwrite_phy(o_ref_liq, ref_liq)
1613       CALL histwrite_phy(o_ref_ice, ref_ice)
[2690]1614       IF (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
[1898]1615            RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
1616            RCFC12_per.NE.RCFC12_act) THEN
[2690]1617          IF (vars_defined) zx_tmp_fi2d(:) = swupp(:,klevp1)*swradcorr(:)
[1898]1618          CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
[2690]1619          IF (vars_defined) zx_tmp_fi2d(:) = lwupp(:,klevp1)
[1898]1620          CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
[2690]1621          IF (vars_defined) zx_tmp_fi2d(:) = swup0p(:,klevp1)*swradcorr(:)
[1898]1622          CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
[2690]1623          IF (vars_defined) zx_tmp_fi2d(:) = lwup0p(:,klevp1)
[1898]1624          CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
[2366]1625          DO k=1, klevp1
1626            zx_tmp_fi3d1(:,k)=swupp(:,k)*swradcorr(:)
1627          ENDDO
1628          CALL histwrite_phy(o_rsu4co2, zx_tmp_fi3d1)
1629          DO k=1, klevp1
1630            zx_tmp_fi3d1(:,k)=swup0p(:,k)*swradcorr(:)
1631          ENDDO
1632          CALL histwrite_phy(o_rsucs4co2, zx_tmp_fi3d1)
1633          DO k=1, klevp1
1634            zx_tmp_fi3d1(:,k)=swdnp(:,k)*swradcorr(:)
1635          ENDDO
1636          CALL histwrite_phy(o_rsd4co2, zx_tmp_fi3d1)
1637          DO k=1, klevp1
1638            zx_tmp_fi3d1(:,k)=swdn0p(:,k)*swradcorr(:)
1639          ENDDO
1640          CALL histwrite_phy(o_rsdcs4co2, zx_tmp_fi3d1)
[1898]1641          CALL histwrite_phy(o_rlu4co2, lwupp)
1642          CALL histwrite_phy(o_rlucs4co2, lwup0p)
1643          CALL histwrite_phy(o_rld4co2, lwdnp)
1644          CALL histwrite_phy(o_rldcs4co2, lwdn0p)
1645       ENDIF
[1828]1646!!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
[2282]1647#ifdef CPP_IOIPSL
1648#ifndef CPP_XIOS
1649  IF (.NOT.ok_all_xml) THEN
1650       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
1651       ! Champs interpolles sur des niveaux de pression
1652       missing_val=missing_val_nf90
[1898]1653       DO iff=7, nfiles
[1828]1654
[1898]1655          CALL histwrite_phy(o_tnondef,tnondef(:,:,iff-6),iff)
1656          CALL histwrite_phy(o_ta,twriteSTD(:,:,iff-6),iff)
1657          CALL histwrite_phy(o_zg,phiwriteSTD(:,:,iff-6),iff)
1658          CALL histwrite_phy(o_hus,qwriteSTD(:,:,iff-6),iff)
1659          CALL histwrite_phy(o_hur,rhwriteSTD(:,:,iff-6),iff)
1660          CALL histwrite_phy(o_ua,uwriteSTD(:,:,iff-6),iff)
1661          CALL histwrite_phy(o_va,vwriteSTD(:,:,iff-6),iff)
1662          CALL histwrite_phy(o_wap,wwriteSTD(:,:,iff-6),iff)
[2690]1663          IF (vars_defined) THEN
[1898]1664             DO k=1, nlevSTD
1665                DO i=1, klon
[2690]1666                   IF (tnondef(i,k,iff-6).NE.missing_val) THEN
1667                      IF (freq_outNMC(iff-6).LT.0) THEN
[1915]1668                         freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
1669                      ELSE
1670                         freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
1671                      ENDIF
[1971]1672                      zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,iff-6))/freq_moyNMC(iff-6)
[1898]1673                   ELSE
[1971]1674                      zx_tmp_fi3d_STD(i,k) = missing_val
[1898]1675                   ENDIF
1676                ENDDO
1677             ENDDO
1678          ENDIF
[1971]1679          CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD,iff)
[2690]1680          IF (vars_defined) THEN
[1898]1681             DO k=1, nlevSTD
1682                DO i=1, klon
[2690]1683                   IF (O3sumSTD(i,k,iff-6).NE.missing_val) THEN
[1971]1684                      zx_tmp_fi3d_STD(i,k) = O3sumSTD(i,k,iff-6) * 1.e+9
[1898]1685                   ELSE
[1971]1686                      zx_tmp_fi3d_STD(i,k) = missing_val
[1898]1687                   ENDIF
1688                ENDDO
1689             ENDDO !k=1, nlevSTD
1690          ENDIF
[1971]1691          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD,iff)
[2690]1692          IF (read_climoz == 2) THEN
1693             IF (vars_defined) THEN
[1898]1694                DO k=1, nlevSTD
1695                   DO i=1, klon
[2690]1696                      IF (O3daysumSTD(i,k,iff-6).NE.missing_val) THEN
[1971]1697                         zx_tmp_fi3d_STD(i,k) = O3daysumSTD(i,k,iff-6) * 1.e+9
[1898]1698                      ELSE
[1971]1699                         zx_tmp_fi3d_STD(i,k) = missing_val
[1898]1700                      ENDIF
1701                   ENDDO
1702                ENDDO !k=1, nlevSTD
1703             ENDIF
[1971]1704             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD,iff)
[1898]1705          endif
1706          CALL histwrite_phy(o_uxv,uvsumSTD(:,:,iff-6),iff)
1707          CALL histwrite_phy(o_vxq,vqsumSTD(:,:,iff-6),iff)
1708          CALL histwrite_phy(o_vxT,vTsumSTD(:,:,iff-6),iff)
1709          CALL histwrite_phy(o_wxq,wqsumSTD(:,:,iff-6),iff)
1710          CALL histwrite_phy(o_vxphi,vphisumSTD(:,:,iff-6),iff)
1711          CALL histwrite_phy(o_wxT,wTsumSTD(:,:,iff-6),iff)
1712          CALL histwrite_phy(o_uxu,u2sumSTD(:,:,iff-6),iff)
1713          CALL histwrite_phy(o_vxv,v2sumSTD(:,:,iff-6),iff)
1714          CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
1715       ENDDO !nfiles
[2282]1716  ENDIF
1717#endif
1718#endif
1719#ifdef CPP_XIOS
[2690]1720  IF (ok_all_xml) THEN
[2282]1721!      DO iff=7, nfiles
1722
1723!         CALL histwrite_phy(o_tnondef,tnondef(:,:,3))
1724          CALL histwrite_phy(o_ta,tlevSTD(:,:))
1725          CALL histwrite_phy(o_zg,philevSTD(:,:))
1726          CALL histwrite_phy(o_hus,qlevSTD(:,:))
1727          CALL histwrite_phy(o_hur,rhlevSTD(:,:))
1728          CALL histwrite_phy(o_ua,ulevSTD(:,:))
1729          CALL histwrite_phy(o_va,vlevSTD(:,:))
1730          CALL histwrite_phy(o_wap,wlevSTD(:,:))
[2690]1731!         IF (vars_defined) THEN
[2282]1732!            DO k=1, nlevSTD
1733!               DO i=1, klon
[2690]1734!                  IF (tnondef(i,k,3).NE.missing_val) THEN
1735!                     IF (freq_outNMC(iff-6).LT.0) THEN
[2282]1736!                        freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
1737!                     ELSE
1738!                        freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
1739!                     ENDIF
1740!                     zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,3))/freq_moyNMC(iff-6)
1741!                  ELSE
1742!                     zx_tmp_fi3d_STD(i,k) = missing_val
1743!                  ENDIF
1744!               ENDDO
1745!            ENDDO
1746!         ENDIF
1747!         CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD)
[2690]1748          IF (vars_defined) THEN
[2282]1749             DO k=1, nlevSTD
1750                DO i=1, klon
[2690]1751                   IF (O3STD(i,k).NE.missing_val) THEN
[2282]1752                      zx_tmp_fi3d_STD(i,k) = O3STD(i,k) * 1.e+9
1753                   ELSE
1754                      zx_tmp_fi3d_STD(i,k) = missing_val
1755                   ENDIF
1756                ENDDO
1757             ENDDO !k=1, nlevSTD
1758          ENDIF
1759          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD)
[2690]1760          IF (read_climoz == 2) THEN
1761             IF (vars_defined) THEN
[2282]1762                DO k=1, nlevSTD
1763                   DO i=1, klon
[2690]1764                      IF (O3daySTD(i,k).NE.missing_val) THEN
[2282]1765                         zx_tmp_fi3d_STD(i,k) = O3daySTD(i,k) * 1.e+9
1766                      ELSE
1767                         zx_tmp_fi3d_STD(i,k) = missing_val
1768                      ENDIF
1769                   ENDDO
1770                ENDDO !k=1, nlevSTD
1771             ENDIF
1772             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD)
[2690]1773          ENDIF
[2282]1774          CALL histwrite_phy(o_uxv,uvSTD(:,:))
1775          CALL histwrite_phy(o_vxq,vqSTD(:,:))
1776          CALL histwrite_phy(o_vxT,vTSTD(:,:))
1777          CALL histwrite_phy(o_wxq,wqSTD(:,:))
1778          CALL histwrite_phy(o_vxphi,vphiSTD(:,:))
1779          CALL histwrite_phy(o_wxT,wTSTD(:,:))
1780          CALL histwrite_phy(o_uxu,u2STD(:,:))
1781          CALL histwrite_phy(o_vxv,v2STD(:,:))
1782          CALL histwrite_phy(o_TxT,T2STD(:,:))
1783!      ENDDO !nfiles
1784  ENDIF
1785#endif
[1828]1786!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[2114]1787        IF (nqtot.GE.nqo+1) THEN
[2690]1788          DO iq=nqo+1,nqtot
1789            IF (type_trac == 'lmdz' .OR. type_trac == 'repr' .OR. type_trac == 'coag') THEN
[2284]1790             CALL histwrite_phy(o_trac(iq-nqo), tr_seri(:,:,iq-nqo))
[2086]1791             CALL histwrite_phy(o_dtr_vdf(iq-nqo),d_tr_cl(:,:,iq-nqo))
1792             CALL histwrite_phy(o_dtr_the(iq-nqo),d_tr_th(:,:,iq-nqo))
1793             CALL histwrite_phy(o_dtr_con(iq-nqo),d_tr_cv(:,:,iq-nqo))
1794             CALL histwrite_phy(o_dtr_lessi_impa(iq-nqo),d_tr_lessi_impa(:,:,iq-nqo))
1795             CALL histwrite_phy(o_dtr_lessi_nucl(iq-nqo),d_tr_lessi_nucl(:,:,iq-nqo))
1796             CALL histwrite_phy(o_dtr_insc(iq-nqo),d_tr_insc(:,:,iq-nqo))
1797             CALL histwrite_phy(o_dtr_bcscav(iq-nqo),d_tr_bcscav(:,:,iq-nqo))
1798             CALL histwrite_phy(o_dtr_evapls(iq-nqo),d_tr_evapls(:,:,iq-nqo))
1799             CALL histwrite_phy(o_dtr_ls(iq-nqo),d_tr_ls(:,:,iq-nqo))
1800             CALL histwrite_phy(o_dtr_trsp(iq-nqo),d_tr_trsp(:,:,iq-nqo))
1801             CALL histwrite_phy(o_dtr_sscav(iq-nqo),d_tr_sscav(:,:,iq-nqo))
1802             CALL histwrite_phy(o_dtr_sat(iq-nqo),d_tr_sat(:,:,iq-nqo))
1803             CALL histwrite_phy(o_dtr_uscav(iq-nqo),d_tr_uscav(:,:,iq-nqo))
[1898]1804             zx_tmp_fi2d=0.
[2690]1805             IF (vars_defined) THEN
[1898]1806                DO k=1,klev
[2284]1807                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*tr_seri(:,k,iq-nqo)
[1898]1808                ENDDO
1809             ENDIF
[2086]1810             CALL histwrite_phy(o_trac_cum(iq-nqo), zx_tmp_fi2d)
[2690]1811            ENDIF
[1898]1812          ENDDO
1813       ENDIF
[1813]1814
[2690]1815       IF (.NOT.vars_defined) THEN
[1898]1816          !$OMP MASTER
[2097]1817#ifndef CPP_IOIPSL_NO_OUTPUT
[1898]1818          DO iff=1,nfiles
1819             IF (clef_files(iff)) THEN
1820                CALL histend(nid_files(iff))
1821                ndex2d = 0
1822                ndex3d = 0
[1821]1823
[1898]1824             ENDIF ! clef_files
1825          ENDDO !  iff
[1852]1826#endif
[1825]1827#ifdef CPP_XIOS
[1898]1828          !On finalise l'initialisation:
1829          CALL wxios_closedef()
[1825]1830#endif
[1898]1831          !$OMP END MASTER
1832          !$OMP BARRIER
1833          vars_defined = .TRUE.
[2690]1834       ENDIF
[1821]1835
[2690]1836    ENDDO
[1821]1837
[2690]1838    IF (vars_defined) THEN
[1898]1839       ! On synchronise les fichiers pour IOIPSL
[2097]1840#ifndef CPP_IOIPSL_NO_OUTPUT
[1898]1841       !$OMP MASTER
1842       DO iff=1,nfiles
[1798]1843          IF (ok_sync .AND. clef_files(iff)) THEN
[1898]1844             CALL histsync(nid_files(iff))
[1798]1845          ENDIF
[1898]1846       END DO
1847       !$OMP END MASTER
[1852]1848#endif
[1798]1849    ENDIF
1850
[1898]1851  END SUBROUTINE phys_output_write
[1798]1852
[1898]1853END MODULE phys_output_write_mod
Note: See TracBrowser for help on using the repository browser.