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

Last change on this file since 2688 was 2670, checked in by oboucher, 9 years ago

adding new diagnostics for evap/rain/snow weighted by surface types
this parallels what was done for wbilo (net flux)
new diagnostics are wevap_??? wrain_??? wsnow_???
where ??? is ter, oce, lic or sic.

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