source: LMDZ5/branches/LMDZ5_SPLA/libf/phylmd/phys_output_write_mod.F90 @ 5434

Last change on this file since 5434 was 2303, checked in by jescribano, 10 years ago

Bugs corrections, control vector is now fine mode+coarse mode and seasalt coarse+fine, change in emission scheme parameters, more outputs at 10h30 and 13h30 LT. (Pending correct optical and sedimentation parameters)

  • 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
File size: 62.0 KB
Line 
1!
2! $Header$
3!
4MODULE phys_output_write_mod
5!JE20141213<
6!!JE20140507<<
7!!  USE phytrac_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
8!!       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
9!!       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
10!  USE phytracr_spl_mod, ONLY : d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
11!       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
12!       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav
13!!JE20140507>>
14
15  USE phytracr_spl_mod, ONLY : ok_chimeredust, id_prec, id_fine, id_coss, &
16       id_codu, id_scdu , &
17       d_tr_cl, d_tr_th, d_tr_cv, d_tr_lessi_impa, &
18       d_tr_lessi_nucl, d_tr_insc, d_tr_bcscav, d_tr_evapls, d_tr_ls,  &
19       d_tr_trsp, d_tr_sscav, d_tr_sat, d_tr_uscav ,&
20       diff_aod550_tot,&
21       diag_aod670_tot, diag_aod865_tot, &
22       diff_aod550_tr2, diag_aod670_tr2, diag_aod865_tr2, &
23       diag_aod550_ss, diag_aod670_ss, diag_aod865_ss, &
24       diag_aod550_dust, diag_aod670_dust, diag_aod865_dust , &
25       diag_aod550_dustsco, diag_aod670_dustsco, diag_aod865_dustsco, &
26!       aod550_aqua, aod670_aqua, aod865_aqua, &
27!       aod550_terra, aod670_terra, aod865_terra, &
28       aod550_aqua,aod550_tr2_aqua,aod550_ss_aqua,aod550_dust_aqua,aod550_dustsco_aqua,&
29       aod670_aqua,aod670_tr2_aqua,aod670_ss_aqua,aod670_dust_aqua,aod670_dustsco_aqua,&
30       aod865_aqua,aod865_tr2_aqua,aod865_ss_aqua,aod865_dust_aqua,aod865_dustsco_aqua,&
31       aod550_terra,aod550_tr2_terra,aod550_ss_terra,aod550_dust_terra,aod550_dustsco_terra,&
32       aod670_terra,aod670_tr2_terra,aod670_ss_terra,aod670_dust_terra,aod670_dustsco_terra,&
33       aod865_terra,aod865_tr2_terra,aod865_ss_terra,aod865_dust_terra,aod865_dustsco_terra,&
34       trm01,trm02,trm03,trm04,trm05, &
35       sconc01,sconc02,sconc03,sconc04,sconc05, &
36       flux01,flux02,flux03,flux04,flux05,&
37       ds01,ds02,ds03,ds04,ds05, &
38       dh01,dh02,dh03,dh04,dh05, &
39       dtrconv01,dtrconv02,dtrconv03,dtrconv04,dtrconv05, &
40       dtherm01,dtherm02,dtherm03,dtherm04,dtherm05, &
41       dhkecv01,dhkecv02,dhkecv03,dhkecv04,dhkecv05, &
42       dhkelsc01,dhkelsc02,dhkelsc03,dhkelsc04,dhkelsc05, &
43       d_tr_cv01,d_tr_cv02,d_tr_cv03,d_tr_cv04,d_tr_cv05, &
44       d_tr_trsp01,d_tr_trsp02,d_tr_trsp03,d_tr_trsp04,d_tr_trsp05, &
45       d_tr_sscav01,d_tr_sscav02,d_tr_sscav03,d_tr_sscav04,d_tr_sscav05, &
46       d_tr_sat01,d_tr_sat02,d_tr_sat03,d_tr_sat04,d_tr_sat05, &
47       d_tr_uscav01,d_tr_uscav02,d_tr_uscav03,d_tr_uscav04,d_tr_uscav05, &
48       sed_ss,sed_dust,sed_dustsco,his_g2pgas,his_g2paer, &
49       fluxbb, &
50       fluxff,fluxbcbb,fluxbcff,fluxbcnff, &
51       fluxbcba,fluxbc,fluxombb,fluxomff,fluxomnff, &
52       fluxomba,fluxomnat,fluxom,fluxh2sff,fluxh2snff, &
53       fluxso2ff,fluxso2nff,fluxso2bb,fluxso2vol,fluxso2ba, &
54       fluxso2,fluxso4ff,fluxso4nff,fluxso4ba,fluxso4bb, &
55       fluxso4,fluxdms,fluxh2sbio,fluxdustec,&
56       fluxddfine,  &
57       fluxddcoa,fluxddsco,fluxdd, &
58       fluxssfine,fluxsscoa, &
59       fluxss,flux_sparam_ind,flux_sparam_bb,flux_sparam_ff, &
60       flux_sparam_ddfine,flux_sparam_ddcoa, &
61       flux_sparam_ddsco,flux_sparam_ssfine, &
62       flux_sparam_sscoa,u10m_ss,v10m_ss
63       
64  USE dustemission_mod, ONLY : m1dflux, m2dflux, m3dflux
65
66!JE20141213>
67
68  ! Author: Abderrahmane IDELKADI (original include file)
69  ! Author: Laurent FAIRHEAD (transformation to module/subroutine)
70  ! Author: Ulysse GERARD (effective implementation)
71
72CONTAINS
73
74  ! ug Routine pour définir (los du premier passageà) ET sortir les variables
75  SUBROUTINE phys_output_write(itap, pdtphys, paprs, pphis, &
76       pplay, lmax_th, aerosol_couple,         &
77       ok_ade, ok_aie, ivap, new_aod, ok_sync, &
78       ptconv, read_climoz, clevSTD, ptconvth, &
79       d_t, qx, d_qx, zmasse, flag_aerosol, flag_aerosol_strat, ok_cdnc)
80
81    ! This subroutine does the actual writing of diagnostics that were
82    ! defined and initialised in phys_output_mod.F90
83
84    USE dimphy, only: klon, klev, klevp1
85    USE control_mod, only: day_step, iphysiq
86    USE phys_output_ctrlout_mod, only: o_phis, o_aire, is_ter, is_lic, is_oce, &
87         is_ave, is_sic, o_contfracATM, o_contfracOR, &
88         o_aireTER, o_flat, o_slp, o_tsol, &
89         o_t2m, o_t2m_min, o_t2m_max, &
90         o_q2m, o_ustar, o_u10m, o_v10m, &
91         o_wind10m, o_wind10max, o_sicf, &
92         o_psol, o_mass, o_qsurf, o_qsol, &
93         o_precip, o_ndayrain, o_plul, o_pluc, &
94         o_snow, o_msnow, o_fsnow, o_evap, &
95         o_tops, o_tops0, o_topl, o_topl0, &
96         o_SWupTOA, o_SWupTOAclr, o_SWdnTOA, &
97         o_SWdnTOAclr, o_nettop, o_SWup200, &
98         o_SWup200clr, o_SWdn200, o_SWdn200clr, &
99         o_LWup200, o_LWup200clr, o_LWdn200, &
100         o_LWdn200clr, o_sols, o_sols0, &
101         o_soll, o_radsol, o_soll0, o_SWupSFC, &
102         o_SWupSFCclr, o_SWdnSFC, o_SWdnSFCclr, &
103         o_LWupSFC, o_LWdnSFC, o_LWupSFCclr, &
104         o_LWdnSFCclr, o_bils, o_bils_diss, &
105         o_bils_ec, o_bils_tke, o_bils_kinetic, &
106         o_bils_latent, o_bils_enthalp, o_sens, &
107         o_fder, o_ffonte, o_fqcalving, o_fqfonte, &
108         o_taux, o_tauy, o_snowsrf, o_qsnow, &
109         o_snowhgt, o_toice, o_sissnow, o_runoff, &
110         o_albslw3, o_pourc_srf, o_fract_srf, &
111         o_taux_srf, o_tauy_srf, o_tsol_srf, &
112         o_evappot_srf, o_ustar_srf, o_u10m_srf, &
113         o_v10m_srf, o_t2m_srf, o_evap_srf, &
114         o_sens_srf, o_lat_srf, o_flw_srf, &
115         o_fsw_srf, o_wbils_srf, o_wbilo_srf, &
116         o_tke_srf, o_tke_max_srf, o_wstar, &
117         o_cdrm, o_cdrh, o_cldl, o_cldm, o_cldh, &
118         o_cldt, o_JrNt, o_cldljn, o_cldmjn, &
119         o_cldhjn, o_cldtjn, o_cldq, o_lwp, o_iwp, &
120         o_ue, o_ve, o_uq, o_vq, o_cape, o_pbase, &
121         o_ptop, o_fbase, o_plcl, o_plfc, &
122         o_wbeff, o_cape_max, o_upwd, o_Ma, &
123         o_dnwd, o_dnwd0, o_ftime_con, o_mc, &
124         o_prw, o_s_pblh, o_s_pblt, o_s_lcl, &
125         o_s_therm, o_uSTDlevs, o_vSTDlevs, &
126         o_wSTDlevs, o_zSTDlevs, o_qSTDlevs, &
127         o_tSTDlevs, epsfra, o_t_oce_sic, &
128         o_ale_bl, o_alp_bl, o_ale_wk, o_alp_wk, &
129         o_ale, o_alp, o_cin, o_WAPE, o_wake_h, &
130         o_wake_s, o_wake_deltat, o_wake_deltaq, &
131         o_wake_omg, o_dtwak, o_dqwak, o_Vprecip, &
132         o_ftd, o_fqd, o_wdtrainA, o_wdtrainM, &
133         o_n2, o_s2, o_proba_notrig, &
134         o_random_notrig, o_ale_bl_stat, &
135         o_ale_bl_trig, o_alp_bl_det, &
136         o_alp_bl_fluct_m, o_alp_bl_fluct_tke, &
137         o_alp_bl_conv, o_alp_bl_stat, o_slab_bils, &
138         o_weakinv, o_dthmin, o_cldtau, &
139         o_cldemi, o_pr_con_l, o_pr_con_i, &
140         o_pr_lsc_l, o_pr_lsc_i, o_re, o_fl, &
141         o_rh2m, o_rh2m_min, o_rh2m_max, &
142         o_qsat2m, o_tpot, o_tpote, o_SWnetOR, &
143         o_SWdownOR, o_LWdownOR, o_snowl, &
144         o_solldown, o_dtsvdfo, o_dtsvdft, &
145         o_dtsvdfg, o_dtsvdfi, o_rugs, o_od550aer, &
146         o_od865aer, o_absvisaer, o_od550lt1aer, &
147         o_sconcso4, o_sconcoa, o_sconcbc, &
148         o_sconcss, o_sconcdust, o_concso4, &
149         o_concoa, o_concbc, o_concss, o_concdust, &
150         o_loadso4, o_loadoa, o_loadbc, o_loadss, &
151         o_loaddust, o_tausumaero, o_topswad, &
152         o_topswad0, o_solswad, o_solswad0, &
153         o_swtoaas_nat, o_swsrfas_nat, &
154         o_swtoacs_nat, o_swtoaas_ant, &
155         o_swsrfas_ant, o_swtoacs_ant, &
156         o_swsrfcs_ant, o_swtoacf_nat, &
157         o_swsrfcf_nat, o_swtoacf_ant, &
158         o_swsrfcs_nat, o_swsrfcf_ant, &
159         o_swtoacf_zero, o_swsrfcf_zero, &
160         o_topswai, o_solswai, o_scdnc, &
161         o_cldncl, o_reffclws, o_reffclwc, &
162         o_cldnvi, o_lcc, o_lcc3d, o_lcc3dcon, &
163         o_lcc3dstra, o_reffclwtop, o_ec550aer, &
164         o_lwcon, o_iwcon, o_temp, o_theta, &
165         o_ovapinit, o_ovap, o_oliq, o_geop, &
166         o_vitu, o_vitv, o_vitw, o_pres, o_paprs, &
167         o_zfull, o_zhalf, o_rneb, o_rnebjn, o_rnebcon, &
168         o_rnebls, o_rhum, o_ozone, o_ozone_light, &
169         o_dtphy, o_dqphy, o_albe_srf, o_rugs_srf, &
170         o_ages_srf, o_alb1, o_alb2, o_tke, &
171         o_tke_max, o_kz, o_kz_max, o_clwcon, &
172         o_dtdyn, o_dqdyn, o_dudyn, o_dvdyn, &
173         o_dtcon, o_tntc, o_ducon, o_dvcon, &
174         o_dqcon, o_tnhusc, o_tnhusc, o_dtlsc, &
175         o_dtlschr, o_dqlsc, o_beta_prec, &
176         o_dtlscth, o_dtlscst, o_dqlscth, &
177         o_dqlscst, o_plulth, o_plulst, &
178         o_ptconvth, o_lmaxth, o_dtvdf, &
179         o_dtdis, o_dqvdf, o_dteva, o_dqeva, &
180         o_ptconv, o_ratqs, o_dtthe, &
181         o_duthe, o_dvthe, o_ftime_th, &
182         o_f_th, o_e_th, o_w_th, o_q_th, &
183         o_a_th, o_d_th, o_f0_th, o_zmax_th, &
184         o_dqthe, o_dtajs, o_dqajs, o_dtswr, &
185         o_dtsw0, o_dtlwr, o_dtlw0, o_dtec, &
186         o_duvdf, o_dvvdf, o_duoro, o_dvoro, &
187         o_dtoro, o_dulif, o_dvlif, o_dtlif, &
188         o_duhin, o_dvhin, o_dthin, o_rsu, &
189         o_rsd, o_rlu, o_rld, o_rsucs, o_rsdcs, &
190         o_rlucs, o_rldcs, o_tnt, o_tntr, &
191         o_tntscpbl, o_tnhus, o_tnhusscpbl, &
192         o_evu, o_h2o, o_mcd, o_dmc, o_ref_liq, &
193         o_ref_ice, o_rsut4co2, o_rlut4co2, &
194         o_rsutcs4co2, o_rlutcs4co2, o_rsu4co2, &
195         o_rlu4co2, o_rsucs4co2, o_rlucs4co2, &
196         o_rsd4co2, o_rld4co2, o_rsdcs4co2, &
197         o_rldcs4co2, o_tnondef, o_ta, o_zg, &
198         o_hus, o_hur, o_ua, o_va, o_wap, &
199         o_psbg, o_tro3, o_tro3_daylight, &
200         o_uxv, o_vxq, o_vxT, o_wxq, o_vxphi, &
201         o_wxT, o_uxu, o_vxv, o_TxT, o_trac, &
202         o_dtr_vdf, o_dtr_the, o_dtr_con, &
203         o_dtr_lessi_impa, o_dtr_lessi_nucl, &
204         o_dtr_insc, o_dtr_bcscav, o_dtr_evapls, &
205         o_dtr_ls, o_dtr_trsp, o_dtr_sscav, &
206         o_dtr_sat, o_dtr_uscav, o_trac_cum, o_du_gwd_rando, o_dv_gwd_rando, &
207!JE         o_vstr_gwd_rando
208         o_vstr_gwd_rando, &
209! JE20141223 spla outputs
210         o_m1dflux,o_m2dflux,o_m3dflux, &
211         o_taue550, &
212         o_taue670,o_taue865, &
213         o_taue550_tr2, o_taue670_tr2, o_taue865_tr2, &
214         o_taue550_ss,o_taue670_ss, o_taue865_ss, &
215         o_taue550_dust, o_taue670_dust, o_taue865_dust, &
216         o_taue550_dustsco, o_taue670_dustsco, o_taue865_dustsco, &
217         o_taue550_aqua, o_taue670_aqua, o_taue865_aqua, &
218         o_taue550_terra, o_taue670_terra, o_taue865_terra, &
219         o_taue550_fine_aqua     ,         o_taue670_fine_aqua     ,  &
220         o_taue865_fine_aqua     ,         o_taue550_coss_aqua      ,  &
221         o_taue670_coss_aqua      ,         o_taue865_coss_aqua      ,  &
222         o_taue550_codu_aqua    ,         o_taue670_codu_aqua    ,  &
223         o_taue865_codu_aqua    ,         o_taue670_scdu_aqua ,  &
224         o_taue550_scdu_aqua ,         o_taue865_scdu_aqua ,  &
225         o_taue550_fine_terra     ,         o_taue670_fine_terra     ,&
226         o_taue865_fine_terra     ,         o_taue550_coss_terra      ,&
227         o_taue670_coss_terra      ,         o_taue865_coss_terra      ,&
228         o_taue550_codu_terra    ,         o_taue670_codu_terra    ,&
229         o_taue865_codu_terra    ,         o_taue670_scdu_terra ,&
230         o_taue550_scdu_terra ,         o_taue865_scdu_terra ,&
231         o_trm01,o_trm02,o_trm03,o_trm04,o_trm05,&
232         o_sconc01,o_sconc02,o_sconc03,o_sconc04,o_sconc05, &
233         o_flux01,o_flux02,o_flux03,o_flux04,o_flux05, &
234         o_ds01,o_ds02,o_ds03,o_ds04,o_ds05, &
235         o_dh01,o_dh02,o_dh03,o_dh04,o_dh05, &
236         o_dtrconv01,o_dtrconv02,o_dtrconv03,o_dtrconv04,o_dtrconv05, &
237         o_dtherm01,o_dtherm02,o_dtherm03,o_dtherm04,o_dtherm05, &
238         o_dhkecv01,o_dhkecv02,o_dhkecv03,o_dhkecv04,o_dhkecv05, &
239         o_dhkelsc01,o_dhkelsc02,o_dhkelsc03,o_dhkelsc04,o_dhkelsc05, &
240         o_d_tr_sat01,o_d_tr_cv01,o_d_tr_cv02,o_d_tr_cv03,o_d_tr_cv04,o_d_tr_cv05, &
241         o_d_tr_trsp01,o_d_tr_trsp02,o_d_tr_trsp03,o_d_tr_trsp04,o_d_tr_trsp05, &
242         o_d_tr_sscav01,o_d_tr_sscav02,o_d_tr_sscav03,o_d_tr_sscav04,o_d_tr_sscav05, &
243         o_d_tr_sat02,o_d_tr_sat03,o_d_tr_sat04,o_d_tr_sat05,  &
244         o_d_tr_uscav01,o_d_tr_uscav02,o_d_tr_uscav03,o_d_tr_uscav04,o_d_tr_uscav05, &
245         o_sed_ss,o_sed_dust,o_sed_dustsco,o_g2p_gas,o_g2p_aer, &
246         o_fluxbb, &
247         o_fluxff    ,o_fluxbcbb  ,o_fluxbcff  ,o_fluxbcnff , &
248         o_fluxbcba  ,o_fluxbc    ,o_fluxombb  ,o_fluxomff  , &
249         o_fluxomnff ,o_fluxomba  ,o_fluxomnat ,o_fluxom    , &
250         o_fluxh2sff ,o_fluxh2snff,o_fluxso2ff ,o_fluxso2nff, &
251         o_fluxso2bb ,o_fluxso2vol,o_fluxso2ba ,o_fluxso2   , &
252         o_fluxso4ff ,o_fluxso4nff,o_fluxso4bb ,o_fluxso4ba , &
253         o_fluxso4   ,o_fluxdms   ,o_fluxh2sbio,o_fluxdustec, &
254         o_fluxddfine,o_fluxddcoa ,o_fluxddsco ,o_fluxdd    ,&
255         o_fluxssfine,o_fluxsscoa, o_fluxss, &
256         o_flux_sparam_ind,o_flux_sparam_bb, &
257         o_flux_sparam_ff ,o_flux_sparam_ddfine  ,o_flux_sparam_ddcoa, &
258         o_flux_sparam_ddsco,o_flux_sparam_ssfine,o_flux_sparam_sscoa, &
259         o_u10m_ss,o_v10m_ss
260
261 
262
263    USE phys_state_var_mod, only: pctsrf, paire_ter, rain_fall, snow_fall, &
264         nday_rain, rain_con, snow_con, &
265         topsw, toplw, toplw0, swup, swdn, &
266         topsw0, swup0, swdn0, SWup200, SWup200clr, &
267         SWdn200, SWdn200clr, LWup200, LWup200clr, &
268         LWdn200, LWdn200clr, solsw, solsw0, sollw, &
269         radsol, sollw0, sollwdown, sollw, &
270         sollwdownclr, lwdn0, ftsol, ustar, u10m, &
271         v10m, pbl_tke, wstar, cape, ema_pcb, ema_pct, &
272         ema_cbmf, Ma, fm_therm, ale_bl, alp_bl, ale, &
273         alp, cin, wake_pe, wake_s, wake_deltat, &
274         wake_deltaq, ftd, fqd, ale_bl_trig, albsol1, &
275         rnebcon, wo, falb1, albsol2, coefh, clwcon0, &
276         ratqs, entr_therm, zqasc, detr_therm, f0, heat, &
277         heat0, cool, cool0, lwup, lwdn, lwup0, coefm, &
278         swupp, lwupp, swup0p, lwup0p, swdnp, lwdnp, &
279         swdn0p, lwdn0p, tnondef, O3sumSTD, uvsumSTD, &
280         vqsumSTD, vTsumSTD, O3daysumSTD, wqsumSTD, &
281         vphisumSTD, wTsumSTD, u2sumSTD, v2sumSTD, &
282         T2sumSTD, nlevSTD, du_gwd_rando, dv_gwd_rando
283
284    USE phys_local_var_mod, only: zxfluxlat, slp, zxtsol, zt2m, &
285         zu10m, zv10m, zq2m, zustar, zxqsurf, qsol, &
286         rain_lsc, snow_lsc, evap, bils, sens, fder, &
287         zxffonte, zxfqcalving, zxfqfonte, fluxu, &
288         fluxv, zxsnow, qsnow, snowhgt, to_ice, &
289         sissnow, runoff, albsol3_lic, evap_pot, &
290         t2m, fevap, fluxt, fluxlat, fsollw, fsolsw, &
291         wfbils, wfbilo, cdragm, cdragh, cldl, cldm, &
292         cldh, cldt, JrNt, cldljn, cldmjn, cldhjn, &
293         cldtjn, cldq, flwp, fiwp, ue, ve, uq, vq, &
294         plcl, plfc, wbeff, upwd, dnwd, dnwd0, prw, &
295         s_pblh, s_pblt, s_lcl, s_therm, uwriteSTD, &
296         vwriteSTD, wwriteSTD, phiwriteSTD, qwriteSTD, &
297         twriteSTD, ale_wake, alp_wake, wake_h, &
298         wake_omg, d_t_wake, d_q_wake, Vprecip, &
299         wdtrainA, wdtrainM, n2, s2, proba_notrig, &
300         random_notrig, ale_bl_stat, &
301         alp_bl_det, alp_bl_fluct_m, alp_bl_conv, &
302         alp_bl_stat, alp_bl_fluct_tke, slab_wfbils, &
303         weak_inversion, dthmin, cldtau, cldemi, &
304         pmflxr, pmflxs, prfl, psfl, re, fl, rh2m, &
305         qsat2m, tpote, tpot, d_ts, zxrugs, od550aer, &
306         od865aer, absvisaer, od550lt1aer, sconcso4, &
307         sconcoa, sconcbc, sconcss, sconcdust, concso4, &
308         concoa, concbc, concss, concdust, loadso4, &
309         loadoa, loadbc, loadss, loaddust, tausum_aero, &
310         topswad_aero, topswad0_aero, solswad_aero, &
311         solswad0_aero, topsw_aero, solsw_aero, &
312         topsw0_aero, solsw0_aero, topswcf_aero, &
313         solswcf_aero, topswai_aero, solswai_aero, &
314         scdnc, cldncl, reffclws, reffclwc, cldnvi, &
315         lcc, lcc3d, lcc3dcon, lcc3dstra, reffclwtop, &
316         ec550aer, flwc, fiwc, t_seri, theta, q_seri, &
317         ql_seri, zphi, u_seri, v_seri, omega, cldfra, &
318         rneb, rnebjn, zx_rh, frugs, agesno, d_t_dyn, d_q_dyn, &
319         d_u_dyn, d_v_dyn, d_t_con, d_t_ajsb, d_t_ajs, &
320         d_u_ajs, d_v_ajs, &
321         d_u_con, d_v_con, d_q_con, d_q_ajs, d_t_lsc, &
322         d_t_eva, d_q_lsc, beta_prec, d_t_lscth, &
323         d_t_lscst, d_q_lscth, d_q_lscst, plul_th, &
324         plul_st, d_t_vdf, d_t_diss, d_q_vdf, d_q_eva, &
325         zw2, fraca, zmax_th, d_q_ajsb, d_t_ec, d_u_vdf, &
326         d_v_vdf, d_u_oro, d_v_oro, d_t_oro, d_u_lif, &
327         d_v_lif, d_t_lif, d_u_hin, d_v_hin, d_t_hin, &
328         pmfd, pmfu, ref_liq, ref_ice, rhwriteSTD
329
330    USE phys_output_var_mod, only: vars_defined, snow_o, zfra_o, bils_diss, &
331         bils_ec, bils_tke, bils_kinetic, bils_latent, bils_enthalp, &
332         itau_con, nfiles, clef_files, nid_files, zvstr_gwd_rando
333    USE indice_sol_mod, only: nbsrf
334    USE infotrac, only: nqtot
335    USE comgeomphy, only: airephy
336    USE surface_data, only: type_ocean, ok_veget, ok_snow
337!    USE aero_mod, only: naero_spc
338    USE aero_mod, only: naero_tot
339    USE ioipsl, only: histend, histsync
340    USE iophy, only: set_itau_iophy, histwrite_phy
341    USE netcdf, only: nf90_fill_real
342
343#ifdef CPP_XIOS
344    ! ug Pour les sorties XIOS
345    USE xios, ONLY: xios_update_calendar
346    USE wxios, only: wxios_closedef
347#endif
348    USE phys_cal_mod, only : mth_len
349
350    IMPLICIT NONE
351
352    INCLUDE "temps.h"
353    INCLUDE "clesphys.h"
354    INCLUDE "thermcell.h"
355    INCLUDE "compbl.h"
356    INCLUDE "YOMCST.h"
357    INCLUDE "dimensions.h"
358    include "iniprint.h"
359
360    ! Input
361    INTEGER :: itap, ivap, read_climoz
362    INTEGER, DIMENSION(klon) :: lmax_th
363    LOGICAL :: aerosol_couple, ok_sync
364    LOGICAL :: ok_ade, ok_aie, new_aod
365    LOGICAL, DIMENSION(klon, klev) :: ptconv, ptconvth
366    REAL :: pdtphys
367    CHARACTER (LEN=4), DIMENSION(nlevSTD) :: clevSTD
368    REAL, DIMENSION(klon,nlevSTD) :: zx_tmp_fi3d_STD
369    REAL, DIMENSION(klon) :: pphis
370    REAL, DIMENSION(klon, klev) :: pplay, d_t
371    REAL, DIMENSION(klon, klev+1) :: paprs
372    REAL, DIMENSION(klon,klev,nqtot) :: qx, d_qx
373    REAL, DIMENSION(klon, llm) :: zmasse
374    LOGICAL :: flag_aerosol_strat
375    INTEGER :: flag_aerosol
376    LOGICAL :: ok_cdnc
377    REAL, DIMENSION(3) :: freq_moyNMC
378
379    ! Local
380    INTEGER, PARAMETER :: jjmp1=jjm+1-1/jjm
381    INTEGER :: itau_w
382    INTEGER :: i, iinit, iinitend=1, iff, iq, nsrf, k, ll, naero
383    REAL, DIMENSION (klon) :: zx_tmp_fi2d
384    REAL, DIMENSION (klon,klev) :: zx_tmp_fi3d, zpt_conv
385    REAL, DIMENSION (klon,klev+1) :: zx_tmp_fi3d1
386    CHARACTER (LEN=4)              :: bb2
387    INTEGER, DIMENSION(iim*jjmp1)  :: ndex2d
388    INTEGER, DIMENSION(iim*jjmp1*klev) :: ndex3d
389    REAL, PARAMETER :: dobson_u = 2.1415e-05 ! Dobson unit, in kg m-2
390    REAL, PARAMETER :: missing_val=nf90_fill_real
391    REAL, PARAMETER :: un_jour=86400.
392
393    ! On calcul le nouveau tau:
394    itau_w = itau_phy + itap + start_time * day_step / iphysiq
395    ! On le donne à iophy pour que les histwrite y aient accès:
396    CALL set_itau_iophy(itau_w)
397
398    IF(.NOT.vars_defined) THEN
399       iinitend = 2
400    ELSE
401       iinitend = 1
402    ENDIF
403
404    ! ug la boucle qui suit ne sert qu'une fois, pour l'initialisation, sinon il n'y a toujours qu'un seul passage:
405    DO iinit=1, iinitend
406#ifdef CPP_XIOS
407       !$OMP MASTER
408       IF (vars_defined) THEN
409          if (prt_level >= 10) then
410             write(lunout,*)"phys_output_write: call xios_update_calendar, itau_w=",itau_w
411          endif
412          CALL xios_update_calendar(itau_w)
413       END IF
414       !$OMP END MASTER
415       !$OMP BARRIER
416#endif
417       ! On procède à l'écriture ou à la définition des nombreuses variables:
418!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
419       CALL histwrite_phy(o_phis, pphis)
420       CALL histwrite_phy(o_aire, airephy)
421
422       IF (vars_defined) THEN
423          DO i=1, klon
424             zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
425          ENDDO
426       ENDIF
427
428       CALL histwrite_phy(o_contfracATM, zx_tmp_fi2d)
429       CALL histwrite_phy(o_contfracOR, pctsrf(:,is_ter))
430       CALL histwrite_phy(o_aireTER, paire_ter)
431!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
432! JE20141223 <<
433#include "spla_output_write.h"
434! JE20141223 >>
435
436       CALL histwrite_phy(o_flat, zxfluxlat)
437       CALL histwrite_phy(o_slp, slp)
438       CALL histwrite_phy(o_tsol, zxtsol)
439       CALL histwrite_phy(o_t2m, zt2m)
440       CALL histwrite_phy(o_t2m_min, zt2m)
441       CALL histwrite_phy(o_t2m_max, zt2m)
442
443       IF (vars_defined) THEN
444          DO i=1, klon
445             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
446          ENDDO
447       ENDIF
448       CALL histwrite_phy(o_wind10m, zx_tmp_fi2d)
449
450       IF (vars_defined) THEN
451          DO i=1, klon
452             zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
453          ENDDO
454       ENDIF
455       CALL histwrite_phy(o_wind10max, zx_tmp_fi2d)
456
457       IF (vars_defined) THEN
458          DO i = 1, klon
459             zx_tmp_fi2d(i) = pctsrf(i,is_sic)
460          ENDDO
461       ENDIF
462       CALL histwrite_phy(o_sicf, zx_tmp_fi2d)
463       CALL histwrite_phy(o_q2m, zq2m)
464       CALL histwrite_phy(o_ustar, zustar)
465       CALL histwrite_phy(o_u10m, zu10m)
466       CALL histwrite_phy(o_v10m, zv10m)
467
468       IF (vars_defined) THEN
469          DO i = 1, klon
470             zx_tmp_fi2d(i) = paprs(i,1)
471          ENDDO
472       ENDIF
473       CALL histwrite_phy(o_psol, zx_tmp_fi2d)
474       CALL histwrite_phy(o_mass, zmasse)
475       CALL histwrite_phy(o_qsurf, zxqsurf)
476
477       IF (.NOT. ok_veget) THEN
478          CALL histwrite_phy(o_qsol, qsol)
479       ENDIF
480
481       IF (vars_defined) THEN
482          DO i = 1, klon
483             zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
484          ENDDO
485       ENDIF
486
487       CALL histwrite_phy(o_precip, zx_tmp_fi2d)
488       CALL histwrite_phy(o_ndayrain, nday_rain)
489
490       IF (vars_defined) THEN
491          DO i = 1, klon
492             zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
493          ENDDO
494       ENDIF
495       CALL histwrite_phy(o_plul, zx_tmp_fi2d)
496
497       IF (vars_defined) THEN
498          DO i = 1, klon
499             zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
500          ENDDO
501       ENDIF
502       CALL histwrite_phy(o_pluc, zx_tmp_fi2d)
503       CALL histwrite_phy(o_snow, snow_fall)
504       CALL histwrite_phy(o_msnow, snow_o)
505       CALL histwrite_phy(o_fsnow, zfra_o)
506       CALL histwrite_phy(o_evap, evap)
507       CALL histwrite_phy(o_tops, topsw)
508       CALL histwrite_phy(o_tops0, topsw0)
509       CALL histwrite_phy(o_topl, toplw)
510       CALL histwrite_phy(o_topl0, toplw0)
511
512       IF (vars_defined) THEN
513          zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
514       ENDIF
515       CALL histwrite_phy(o_SWupTOA, zx_tmp_fi2d)
516
517       IF (vars_defined) THEN
518          zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
519       ENDIF
520       CALL histwrite_phy(o_SWupTOAclr, zx_tmp_fi2d)
521
522       IF (vars_defined) THEN
523          zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
524       ENDIF
525       CALL histwrite_phy(o_SWdnTOA, zx_tmp_fi2d)
526
527       IF (vars_defined) THEN
528          zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
529       ENDIF
530       CALL histwrite_phy(o_SWdnTOAclr, zx_tmp_fi2d)
531
532       IF (vars_defined) THEN
533          zx_tmp_fi2d(:) = topsw(:)-toplw(:)
534       ENDIF
535       CALL histwrite_phy(o_nettop, zx_tmp_fi2d)
536       CALL histwrite_phy(o_SWup200, SWup200)
537       CALL histwrite_phy(o_SWup200clr, SWup200clr)
538       CALL histwrite_phy(o_SWdn200, SWdn200)
539       CALL histwrite_phy(o_SWdn200clr, SWdn200clr)
540       CALL histwrite_phy(o_LWup200, LWup200)
541       CALL histwrite_phy(o_LWup200clr, LWup200clr)
542       CALL histwrite_phy(o_LWdn200, LWdn200)
543       CALL histwrite_phy(o_LWdn200clr, LWdn200clr)
544       CALL histwrite_phy(o_sols, solsw)
545       CALL histwrite_phy(o_sols0, solsw0)
546       CALL histwrite_phy(o_soll, sollw)
547       CALL histwrite_phy(o_radsol, radsol)
548       CALL histwrite_phy(o_soll0, sollw0)
549
550       IF (vars_defined) THEN
551          zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
552       ENDIF
553       CALL histwrite_phy(o_SWupSFC, zx_tmp_fi2d)
554
555       IF (vars_defined) THEN
556          zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
557       ENDIF
558       CALL histwrite_phy(o_SWupSFCclr, zx_tmp_fi2d)
559
560       IF (vars_defined) THEN
561          zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
562       ENDIF
563       CALL histwrite_phy(o_SWdnSFC, zx_tmp_fi2d)
564
565       IF (vars_defined) THEN
566          zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
567       ENDIF
568       CALL histwrite_phy(o_SWdnSFCclr, zx_tmp_fi2d)
569
570       IF (vars_defined) THEN
571          zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
572       ENDIF
573       CALL histwrite_phy(o_LWupSFC, zx_tmp_fi2d)
574       CALL histwrite_phy(o_LWdnSFC, sollwdown)
575
576       IF (vars_defined) THEN
577          sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
578          zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
579       ENDIF
580       CALL histwrite_phy(o_LWupSFCclr, zx_tmp_fi2d)
581       CALL histwrite_phy(o_LWdnSFCclr, sollwdownclr)
582       CALL histwrite_phy(o_bils, bils)
583       CALL histwrite_phy(o_bils_diss, bils_diss)
584       CALL histwrite_phy(o_bils_ec, bils_ec)
585       CALL histwrite_phy(o_bils_tke, bils_tke)
586       CALL histwrite_phy(o_bils_kinetic, bils_kinetic)
587       CALL histwrite_phy(o_bils_latent, bils_latent)
588       CALL histwrite_phy(o_bils_enthalp, bils_enthalp)
589
590       IF (vars_defined) THEN
591          zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
592       ENDIF
593       CALL histwrite_phy(o_sens, zx_tmp_fi2d)
594       CALL histwrite_phy(o_fder, fder)
595       CALL histwrite_phy(o_ffonte, zxffonte)
596       CALL histwrite_phy(o_fqcalving, zxfqcalving)
597       CALL histwrite_phy(o_fqfonte, zxfqfonte)
598       IF (vars_defined) THEN
599          zx_tmp_fi2d=0.
600          DO nsrf=1,nbsrf
601             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
602          ENDDO
603       ENDIF
604       CALL histwrite_phy(o_taux, zx_tmp_fi2d)
605
606       IF (vars_defined) THEN
607          zx_tmp_fi2d=0.
608          DO nsrf=1,nbsrf
609             zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
610          ENDDO
611       ENDIF
612       CALL histwrite_phy(o_tauy, zx_tmp_fi2d)
613
614       IF (ok_snow) THEN
615          CALL histwrite_phy(o_snowsrf, zxsnow)
616          CALL histwrite_phy(o_qsnow, qsnow)
617          CALL histwrite_phy(o_snowhgt,snowhgt)
618          CALL histwrite_phy(o_toice,to_ice)
619          CALL histwrite_phy(o_sissnow,sissnow)
620          CALL histwrite_phy(o_runoff,runoff)
621          CALL histwrite_phy(o_albslw3,albsol3_lic)
622       ENDIF
623
624       DO nsrf = 1, nbsrf
625          IF (vars_defined)             zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
626          CALL histwrite_phy(o_pourc_srf(nsrf), zx_tmp_fi2d)
627          IF (vars_defined)           zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
628          CALL histwrite_phy(o_fract_srf(nsrf), zx_tmp_fi2d)
629          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
630          CALL histwrite_phy(o_taux_srf(nsrf), zx_tmp_fi2d)
631          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
632          CALL histwrite_phy(o_tauy_srf(nsrf), zx_tmp_fi2d)
633          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
634          CALL histwrite_phy(o_tsol_srf(nsrf), zx_tmp_fi2d)
635          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = evap_pot( 1 : klon, nsrf)
636          CALL histwrite_phy(o_evappot_srf(nsrf), zx_tmp_fi2d)
637          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = ustar(1 : klon, nsrf)
638          CALL histwrite_phy(o_ustar_srf(nsrf), zx_tmp_fi2d)
639          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
640          CALL histwrite_phy(o_u10m_srf(nsrf), zx_tmp_fi2d)
641          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
642          CALL histwrite_phy(o_v10m_srf(nsrf), zx_tmp_fi2d)
643          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
644          CALL histwrite_phy(o_t2m_srf(nsrf), zx_tmp_fi2d)
645          IF (vars_defined)       zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
646          CALL histwrite_phy(o_evap_srf(nsrf), zx_tmp_fi2d)
647          IF (vars_defined)        zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
648          CALL histwrite_phy(o_sens_srf(nsrf), zx_tmp_fi2d)
649          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
650          CALL histwrite_phy(o_lat_srf(nsrf), zx_tmp_fi2d)
651          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
652          CALL histwrite_phy(o_flw_srf(nsrf), zx_tmp_fi2d)
653          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
654          CALL histwrite_phy(o_fsw_srf(nsrf), zx_tmp_fi2d)
655          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
656          CALL histwrite_phy(o_wbils_srf(nsrf), zx_tmp_fi2d)
657          IF (vars_defined)         zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
658          CALL histwrite_phy(o_wbilo_srf(nsrf), zx_tmp_fi2d)
659
660          IF (iflag_pbl > 1) THEN
661             CALL histwrite_phy(o_tke_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
662             CALL histwrite_phy(o_tke_max_srf(nsrf),  pbl_tke(:,1:klev,nsrf))
663          ENDIF
664
665       ENDDO
666       DO nsrf=1,nbsrf+1
667          CALL histwrite_phy(o_wstar(nsrf), wstar(1 : klon, nsrf))
668       ENDDO
669
670       CALL histwrite_phy(o_cdrm, cdragm)
671       CALL histwrite_phy(o_cdrh, cdragh)
672       CALL histwrite_phy(o_cldl, cldl)
673       CALL histwrite_phy(o_cldm, cldm)
674       CALL histwrite_phy(o_cldh, cldh)
675       CALL histwrite_phy(o_cldt, cldt)
676       CALL histwrite_phy(o_JrNt, JrNt)
677       CALL histwrite_phy(o_cldljn, cldl*JrNt)
678       CALL histwrite_phy(o_cldmjn, cldm*JrNt)
679       CALL histwrite_phy(o_cldhjn, cldh*JrNt)
680       CALL histwrite_phy(o_cldtjn, cldt*JrNt)
681       CALL histwrite_phy(o_cldq, cldq)
682       IF (vars_defined)       zx_tmp_fi2d(1:klon) = flwp(1:klon)
683       CALL histwrite_phy(o_lwp, zx_tmp_fi2d)
684       IF (vars_defined)       zx_tmp_fi2d(1:klon) = fiwp(1:klon)
685       CALL histwrite_phy(o_iwp, zx_tmp_fi2d)
686       CALL histwrite_phy(o_ue, ue)
687       CALL histwrite_phy(o_ve, ve)
688       CALL histwrite_phy(o_uq, uq)
689       CALL histwrite_phy(o_vq, vq)
690       IF(iflag_con.GE.3) THEN ! sb
691          CALL histwrite_phy(o_cape, cape)
692          CALL histwrite_phy(o_pbase, ema_pcb)
693          CALL histwrite_phy(o_ptop, ema_pct)
694          CALL histwrite_phy(o_fbase, ema_cbmf)
695          if (iflag_con /= 30) then
696             CALL histwrite_phy(o_plcl, plcl)
697             CALL histwrite_phy(o_plfc, plfc)
698             CALL histwrite_phy(o_wbeff, wbeff)
699          end if
700
701          CALL histwrite_phy(o_cape_max, cape)
702
703          CALL histwrite_phy(o_upwd, upwd)
704          CALL histwrite_phy(o_Ma, Ma)
705          CALL histwrite_phy(o_dnwd, dnwd)
706          CALL histwrite_phy(o_dnwd0, dnwd0)
707          IF (vars_defined)         zx_tmp_fi2d=float(itau_con)/float(itap)
708          CALL histwrite_phy(o_ftime_con, zx_tmp_fi2d)
709          IF (vars_defined) THEN
710             IF(iflag_thermals>=1)THEN
711                zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm(:,1:klev)
712             ELSE
713                zx_tmp_fi3d=dnwd+dnwd0+upwd
714             ENDIF
715          ENDIF
716          CALL histwrite_phy(o_mc, zx_tmp_fi3d)
717       ENDIF !iflag_con .GE. 3
718       CALL histwrite_phy(o_prw, prw)
719       CALL histwrite_phy(o_s_pblh, s_pblh)
720       CALL histwrite_phy(o_s_pblt, s_pblt)
721       CALL histwrite_phy(o_s_lcl, s_lcl)
722       CALL histwrite_phy(o_s_therm, s_therm)
723       !IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
724       !       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
725       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
726       !    $o_s_capCL%name,itau_w,s_capCL)
727       !       ENDIF
728       !       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
729       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
730       !    $o_s_oliqCL%name,itau_w,s_oliqCL)
731       !       ENDIF
732       !       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
733       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
734       !    $o_s_cteiCL%name,itau_w,s_cteiCL)
735       !       ENDIF
736       !       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
737       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
738       !    $o_s_trmb1%name,itau_w,s_trmb1)
739       !       ENDIF
740       !       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
741       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
742       !    $o_s_trmb2%name,itau_w,s_trmb2)
743       !       ENDIF
744       !       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
745       !     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
746       !    $o_s_trmb3%name,itau_w,s_trmb3)
747       !       ENDIF
748
749       ! ATTENTION, LES ANCIENS HISTWRITE ONT ETES CONSERVES EN ATTENDANT MIEUX:
750       ! Champs interpolles sur des niveaux de pression
751       DO iff=1, nfiles
752          ll=0
753          DO k=1, nlevSTD
754             bb2=clevSTD(k)
755             IF(bb2.EQ."850".OR.bb2.EQ."700".OR. &
756                  bb2.EQ."500".OR.bb2.EQ."200".OR. &
757                  bb2.EQ."100".OR. &
758                  bb2.EQ."50".OR.bb2.EQ."10") THEN
759
760                ! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
761                ll=ll+1
762                CALL histwrite_phy(o_uSTDlevs(ll),uwriteSTD(:,k,iff), iff)
763                CALL histwrite_phy(o_vSTDlevs(ll),vwriteSTD(:,k,iff), iff)
764                CALL histwrite_phy(o_wSTDlevs(ll),wwriteSTD(:,k,iff), iff)
765                CALL histwrite_phy(o_zSTDlevs(ll),phiwriteSTD(:,k,iff), iff)
766                CALL histwrite_phy(o_qSTDlevs(ll),qwriteSTD(:,k,iff), iff)
767                CALL histwrite_phy(o_tSTDlevs(ll),twriteSTD(:,k,iff), iff)
768
769             ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
770          ENDDO
771       ENDDO
772
773       IF (vars_defined) THEN
774          DO i=1, klon
775             IF (pctsrf(i,is_oce).GT.epsfra.OR. &
776                  pctsrf(i,is_sic).GT.epsfra) THEN
777                zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+ &
778                     ftsol(i, is_sic) * pctsrf(i,is_sic))/ &
779                     (pctsrf(i,is_oce)+pctsrf(i,is_sic))
780             ELSE
781                zx_tmp_fi2d(i) = 273.15
782             ENDIF
783          ENDDO
784       ENDIF
785       CALL histwrite_phy(o_t_oce_sic, zx_tmp_fi2d)
786
787       ! Couplage convection-couche limite
788       IF (iflag_con.GE.3) THEN
789          IF (iflag_coupl>=1) THEN
790             CALL histwrite_phy(o_ale_bl, ale_bl)
791             CALL histwrite_phy(o_alp_bl, alp_bl)
792          ENDIF !iflag_coupl>=1
793       ENDIF !(iflag_con.GE.3)
794       ! Wakes
795       IF (iflag_con.EQ.3) THEN
796          IF (iflag_wake>=1) THEN
797             CALL histwrite_phy(o_ale_wk, ale_wake)
798             CALL histwrite_phy(o_alp_wk, alp_wake)
799             CALL histwrite_phy(o_ale, ale)
800             CALL histwrite_phy(o_alp, alp)
801             CALL histwrite_phy(o_cin, cin)
802             CALL histwrite_phy(o_WAPE, wake_pe)
803             CALL histwrite_phy(o_wake_h, wake_h)
804             CALL histwrite_phy(o_wake_s, wake_s)
805             CALL histwrite_phy(o_wake_deltat, wake_deltat)
806             CALL histwrite_phy(o_wake_deltaq, wake_deltaq)
807             CALL histwrite_phy(o_wake_omg, wake_omg)
808             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev) &
809                  /pdtphys
810             CALL histwrite_phy(o_dtwak, zx_tmp_fi3d)
811             IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
812             CALL histwrite_phy(o_dqwak, zx_tmp_fi3d)
813          ENDIF ! iflag_wake>=1
814          CALL histwrite_phy(o_Vprecip, Vprecip)
815          CALL histwrite_phy(o_ftd, ftd)
816          CALL histwrite_phy(o_fqd, fqd)
817       ELSEIF (iflag_con.EQ.30) THEN
818          ! sortie RomP convection descente insaturee iflag_con=30
819          CALL histwrite_phy(o_Vprecip, Vprecip)
820          CALL histwrite_phy(o_wdtrainA, wdtrainA)
821          CALL histwrite_phy(o_wdtrainM, wdtrainM)
822       ENDIF !(iflag_con.EQ.3.or.iflag_con.EQ.30)
823!!! nrlmd le 10/04/2012
824       IF (iflag_trig_bl>=1) THEN
825          CALL histwrite_phy(o_n2, n2)
826          CALL histwrite_phy(o_s2, s2)
827          CALL histwrite_phy(o_proba_notrig, proba_notrig)
828          CALL histwrite_phy(o_random_notrig, random_notrig)
829          CALL histwrite_phy(o_ale_bl_stat, ale_bl_stat)
830          CALL histwrite_phy(o_ale_bl_trig, ale_bl_trig)
831       ENDIF  !(iflag_trig_bl>=1)
832       IF (iflag_clos_bl>=1) THEN
833          CALL histwrite_phy(o_alp_bl_det, alp_bl_det)
834          CALL histwrite_phy(o_alp_bl_fluct_m, alp_bl_fluct_m)
835          CALL histwrite_phy(o_alp_bl_fluct_tke,  &
836               alp_bl_fluct_tke)
837          CALL histwrite_phy(o_alp_bl_conv, alp_bl_conv)
838          CALL histwrite_phy(o_alp_bl_stat, alp_bl_stat)
839       ENDIF  !(iflag_clos_bl>=1)
840!!! fin nrlmd le 10/04/2012
841       IF (type_ocean=='slab ') THEN
842          CALL histwrite_phy(o_slab_bils, slab_wfbils)
843       ENDIF !type_ocean == force/slab
844       CALL histwrite_phy(o_weakinv, weak_inversion)
845       CALL histwrite_phy(o_dthmin, dthmin)
846       CALL histwrite_phy(o_cldtau, cldtau)
847       CALL histwrite_phy(o_cldemi, cldemi)
848       CALL histwrite_phy(o_pr_con_l, pmflxr(:,1:klev))
849       CALL histwrite_phy(o_pr_con_i, pmflxs(:,1:klev))
850       CALL histwrite_phy(o_pr_lsc_l, prfl(:,1:klev))
851       CALL histwrite_phy(o_pr_lsc_i, psfl(:,1:klev))
852       CALL histwrite_phy(o_re, re)
853       CALL histwrite_phy(o_fl, fl)
854       IF (vars_defined) THEN
855          DO i=1, klon
856             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
857          ENDDO
858       ENDIF
859       CALL histwrite_phy(o_rh2m, zx_tmp_fi2d)
860
861       IF (vars_defined) THEN
862          DO i=1, klon
863             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
864          ENDDO
865       ENDIF
866       CALL histwrite_phy(o_rh2m_min, zx_tmp_fi2d)
867
868       IF (vars_defined) THEN
869          DO i=1, klon
870             zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
871          ENDDO
872       ENDIF
873       CALL histwrite_phy(o_rh2m_max, zx_tmp_fi2d)
874
875       CALL histwrite_phy(o_qsat2m, qsat2m)
876       CALL histwrite_phy(o_tpot, tpot)
877       CALL histwrite_phy(o_tpote, tpote)
878       IF (vars_defined) zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
879       CALL histwrite_phy(o_SWnetOR,  zx_tmp_fi2d)
880       IF (vars_defined) zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
881       CALL histwrite_phy(o_SWdownOR,  zx_tmp_fi2d)
882       CALL histwrite_phy(o_LWdownOR, sollwdown)
883       CALL histwrite_phy(o_snowl, snow_lsc)
884       CALL histwrite_phy(o_solldown, sollwdown)
885       CALL histwrite_phy(o_dtsvdfo, d_ts(:,is_oce))
886       CALL histwrite_phy(o_dtsvdft, d_ts(:,is_ter))
887       CALL histwrite_phy(o_dtsvdfg,  d_ts(:,is_lic))
888       CALL histwrite_phy(o_dtsvdfi, d_ts(:,is_sic))
889       CALL histwrite_phy(o_rugs, zxrugs)
890       ! OD550 per species
891       IF (new_aod .and. (.not. aerosol_couple)) THEN
892          IF (flag_aerosol.GT.0) THEN
893             CALL histwrite_phy(o_od550aer, od550aer)
894             CALL histwrite_phy(o_od865aer, od865aer)
895             CALL histwrite_phy(o_absvisaer, absvisaer)
896             CALL histwrite_phy(o_od550lt1aer, od550lt1aer)
897             CALL histwrite_phy(o_sconcso4, sconcso4)
898             CALL histwrite_phy(o_sconcoa, sconcoa)
899             CALL histwrite_phy(o_sconcbc, sconcbc)
900             CALL histwrite_phy(o_sconcss, sconcss)
901             CALL histwrite_phy(o_sconcdust, sconcdust)
902             CALL histwrite_phy(o_concso4, concso4)
903             CALL histwrite_phy(o_concoa, concoa)
904             CALL histwrite_phy(o_concbc, concbc)
905             CALL histwrite_phy(o_concss, concss)
906             CALL histwrite_phy(o_concdust, concdust)
907             CALL histwrite_phy(o_loadso4, loadso4)
908             CALL histwrite_phy(o_loadoa, loadoa)
909             CALL histwrite_phy(o_loadbc, loadbc)
910             CALL histwrite_phy(o_loadss, loadss)
911             CALL histwrite_phy(o_loaddust, loaddust)
912             !--STRAT AER
913          ENDIF
914          IF (flag_aerosol.GT.0.OR.flag_aerosol_strat) THEN
915!             DO naero = 1, naero_spc
916!--correction mini bug OB
917             DO naero = 1, naero_tot
918                CALL histwrite_phy(o_tausumaero(naero), &
919                     tausum_aero(:,2,naero) )
920             END DO
921          ENDIF
922       ENDIF
923       IF (ok_ade) THEN
924          CALL histwrite_phy(o_topswad, topswad_aero)
925          CALL histwrite_phy(o_topswad0, topswad0_aero)
926          CALL histwrite_phy(o_solswad, solswad_aero)
927          CALL histwrite_phy(o_solswad0, solswad0_aero)
928          !====MS forcing diagnostics
929          if (new_aod) then
930             CALL histwrite_phy(o_swtoaas_nat, topsw_aero(:,1))
931             CALL histwrite_phy(o_swsrfas_nat, solsw_aero(:,1))
932             CALL histwrite_phy(o_swtoacs_nat, topsw0_aero(:,1))
933             CALL histwrite_phy(o_swsrfcs_nat, solsw0_aero(:,1))
934             !ant
935             CALL histwrite_phy(o_swtoaas_ant, topsw_aero(:,2))
936             CALL histwrite_phy(o_swsrfas_ant, solsw_aero(:,2))
937             CALL histwrite_phy(o_swtoacs_ant, topsw0_aero(:,2))
938             CALL histwrite_phy(o_swsrfcs_ant, solsw0_aero(:,2))
939             !cf
940             if (.not. aerosol_couple) then
941                CALL histwrite_phy(o_swtoacf_nat, topswcf_aero(:,1))
942                CALL histwrite_phy(o_swsrfcf_nat, solswcf_aero(:,1))
943                CALL histwrite_phy(o_swtoacf_ant, topswcf_aero(:,2))
944                CALL histwrite_phy(o_swsrfcf_ant, solswcf_aero(:,2))
945                CALL histwrite_phy(o_swtoacf_zero,topswcf_aero(:,3))
946                CALL histwrite_phy(o_swsrfcf_zero,solswcf_aero(:,3))
947             endif
948          endif ! new_aod
949          !====MS forcing diagnostics
950       ENDIF
951       IF (ok_aie) THEN
952          CALL histwrite_phy(o_topswai, topswai_aero)
953          CALL histwrite_phy(o_solswai, solswai_aero)
954       ENDIF
955       IF (flag_aerosol.GT.0.AND.ok_cdnc) THEN
956          CALL histwrite_phy(o_scdnc, scdnc)
957          CALL histwrite_phy(o_cldncl, cldncl)
958          CALL histwrite_phy(o_reffclws, reffclws)
959          CALL histwrite_phy(o_reffclwc, reffclwc)
960          CALL histwrite_phy(o_cldnvi, cldnvi)
961          CALL histwrite_phy(o_lcc, lcc)
962          CALL histwrite_phy(o_lcc3d, lcc3d)
963          CALL histwrite_phy(o_lcc3dcon, lcc3dcon)
964          CALL histwrite_phy(o_lcc3dstra, lcc3dstra)
965          CALL histwrite_phy(o_reffclwtop, reffclwtop)
966       ENDIF
967       ! Champs 3D:
968       IF (ok_ade .OR. ok_aie) then
969          CALL histwrite_phy(o_ec550aer, ec550aer)
970       ENDIF
971       CALL histwrite_phy(o_lwcon, flwc)
972       CALL histwrite_phy(o_iwcon, fiwc)
973       CALL histwrite_phy(o_temp, t_seri)
974       CALL histwrite_phy(o_theta, theta)
975       CALL histwrite_phy(o_ovapinit, qx(:,:,ivap))
976       CALL histwrite_phy(o_ovap, q_seri)
977       CALL histwrite_phy(o_oliq, ql_seri)
978       CALL histwrite_phy(o_geop, zphi)
979       CALL histwrite_phy(o_vitu, u_seri)
980       CALL histwrite_phy(o_vitv, v_seri)
981       CALL histwrite_phy(o_vitw, omega)
982       CALL histwrite_phy(o_pres, pplay)
983       CALL histwrite_phy(o_paprs, paprs(:,1:klev))
984       IF (vars_defined) THEN
985          DO i=1, klon
986             zx_tmp_fi3d1(i,1)= pphis(i)/RG
987             !020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
988          ENDDO
989          DO k=1, klev
990             !020611        DO k=1, klev-1
991             DO i=1, klon
992                !020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD *
993                zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD *  &
994                     (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG )
995             ENDDO
996          ENDDO
997       ENDIF
998       CALL histwrite_phy(o_zfull,zx_tmp_fi3d1(:,2:klevp1))
999       !020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
1000
1001       IF (vars_defined)  THEN
1002          DO i=1, klon
1003             zx_tmp_fi3d(i,1)= pphis(i)/RG - ( &
1004                  (t_seri(i,1)+zxtsol(i))/2. *RD * &
1005                  (pplay(i,1) - paprs(i,1)))/( (paprs(i,1)+pplay(i,1))/2.* RG)
1006          ENDDO
1007          DO k=1, klev-1
1008             DO i=1, klon
1009                zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - ( &
1010                     (t_seri(i,k)+t_seri(i,k+1))/2. *RD *  &
1011                     (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG )
1012             ENDDO
1013          ENDDO
1014       ENDIF
1015       CALL histwrite_phy(o_zhalf, zx_tmp_fi3d)
1016       CALL histwrite_phy(o_rneb, cldfra)
1017       CALL histwrite_phy(o_rnebcon, rnebcon)
1018       CALL histwrite_phy(o_rnebls, rneb)
1019       IF (vars_defined)  THEN
1020          DO k=1, klev
1021             DO i=1, klon
1022                zx_tmp_fi3d(i,k)=cldfra(i,k)*JrNt(i)
1023             ENDDO
1024          ENDDO
1025       ENDIF
1026       CALL histwrite_phy(o_rnebjn, zx_tmp_fi3d)
1027       CALL histwrite_phy(o_rhum, zx_rh)
1028       CALL histwrite_phy(o_ozone, &
1029            wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1030
1031       IF (read_climoz == 2) THEN
1032          CALL histwrite_phy(o_ozone_light, &
1033               wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1034       ENDIF
1035
1036       CALL histwrite_phy(o_dtphy, d_t)
1037       CALL histwrite_phy(o_dqphy,  d_qx(:,:,ivap))
1038       DO nsrf=1, nbsrf
1039          IF (vars_defined) zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
1040          CALL histwrite_phy(o_albe_srf(nsrf), zx_tmp_fi2d)
1041          IF (vars_defined) zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
1042          CALL histwrite_phy(o_rugs_srf(nsrf), zx_tmp_fi2d)
1043          IF (vars_defined) zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
1044          CALL histwrite_phy(o_ages_srf(nsrf), zx_tmp_fi2d)
1045       ENDDO !nsrf=1, nbsrf
1046       CALL histwrite_phy(o_alb1, albsol1)
1047       CALL histwrite_phy(o_alb2, albsol2)
1048       !FH Sorties pour la couche limite
1049       if (iflag_pbl>1) then
1050          zx_tmp_fi3d=0.
1051          IF (vars_defined) THEN
1052             do nsrf=1,nbsrf
1053                do k=1,klev
1054                   zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k) &
1055                        +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
1056                enddo
1057             enddo
1058          ENDIF
1059          CALL histwrite_phy(o_tke, zx_tmp_fi3d)
1060
1061          CALL histwrite_phy(o_tke_max, zx_tmp_fi3d)
1062       ENDIF
1063
1064       CALL histwrite_phy(o_kz, coefh(:,:,is_ave))
1065
1066       CALL histwrite_phy(o_kz_max, coefh(:,:,is_ave))
1067
1068       CALL histwrite_phy(o_clwcon, clwcon0)
1069       CALL histwrite_phy(o_dtdyn, d_t_dyn)
1070       CALL histwrite_phy(o_dqdyn, d_q_dyn)
1071       CALL histwrite_phy(o_dudyn, d_u_dyn)
1072       CALL histwrite_phy(o_dvdyn, d_v_dyn)
1073
1074       IF (vars_defined) THEN
1075          zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
1076       ENDIF
1077       CALL histwrite_phy(o_dtcon, zx_tmp_fi3d)
1078       if(iflag_thermals.eq.1)then
1079          IF (vars_defined) THEN
1080             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
1081                  d_t_ajsb(1:klon,1:klev)/pdtphys
1082          ENDIF
1083          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
1084       else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
1085          IF (vars_defined) THEN
1086             zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys + &
1087                  d_t_ajs(1:klon,1:klev)/pdtphys + &
1088                  d_t_wake(1:klon,1:klev)/pdtphys
1089          ENDIF
1090          CALL histwrite_phy(o_tntc, zx_tmp_fi3d)
1091       endif
1092       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
1093       CALL histwrite_phy(o_ducon, zx_tmp_fi3d)
1094       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_con(1:klon,1:klev)/pdtphys
1095       CALL histwrite_phy(o_dvcon, zx_tmp_fi3d)
1096       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1097       CALL histwrite_phy(o_dqcon, zx_tmp_fi3d)
1098
1099       IF(iflag_thermals.EQ.1) THEN
1100          IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1101          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
1102       ELSE IF(iflag_thermals.GT.1.AND.iflag_wake.EQ.1) THEN
1103          IF (vars_defined) THEN
1104             zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys + &
1105                  d_q_ajs(1:klon,1:klev)/pdtphys + &
1106                  d_q_wake(1:klon,1:klev)/pdtphys
1107          ENDIF
1108          CALL histwrite_phy(o_tnhusc, zx_tmp_fi3d)
1109       ENDIF
1110
1111       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
1112       CALL histwrite_phy(o_dtlsc, zx_tmp_fi3d)
1113       IF (vars_defined) zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+ &
1114            d_t_eva(1:klon,1:klev))/pdtphys
1115       CALL histwrite_phy(o_dtlschr, zx_tmp_fi3d)
1116       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
1117       CALL histwrite_phy(o_dqlsc, zx_tmp_fi3d)
1118       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=beta_prec(1:klon,1:klev)
1119       CALL histwrite_phy(o_beta_prec, zx_tmp_fi3d)
1120!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1121       ! Sorties specifiques a la separation thermiques/non thermiques
1122       if (iflag_thermals>=1) then
1123          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscth(1:klon,1:klev)/pdtphys
1124          CALL histwrite_phy(o_dtlscth, zx_tmp_fi3d)
1125          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lscst(1:klon,1:klev)/pdtphys
1126          CALL histwrite_phy(o_dtlscst, zx_tmp_fi3d)
1127          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscth(1:klon,1:klev)/pdtphys
1128          CALL histwrite_phy(o_dqlscth, zx_tmp_fi3d)
1129          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_lscst(1:klon,1:klev)/pdtphys
1130          CALL histwrite_phy(o_dqlscst, zx_tmp_fi3d)
1131          CALL histwrite_phy(o_plulth, plul_th)
1132          CALL histwrite_phy(o_plulst, plul_st)
1133          IF (vars_defined) THEN
1134             do k=1,klev
1135                do i=1,klon
1136                   if (ptconvth(i,k)) then
1137                      zx_tmp_fi3d(i,k)=1.
1138                   else
1139                      zx_tmp_fi3d(i,k)=0.
1140                   endif
1141                enddo
1142             enddo
1143          ENDIF
1144          CALL histwrite_phy(o_ptconvth, zx_tmp_fi3d)
1145          IF (vars_defined) THEN
1146             do i=1,klon
1147                zx_tmp_fi2d(1:klon)=lmax_th(:)
1148             enddo
1149          ENDIF
1150          CALL histwrite_phy(o_lmaxth, zx_tmp_fi2d)
1151       endif ! iflag_thermals>=1
1152!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1153       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
1154       CALL histwrite_phy(o_dtvdf, zx_tmp_fi3d)
1155       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_diss(1:klon,1:klev)/pdtphys
1156       CALL histwrite_phy(o_dtdis, zx_tmp_fi3d)
1157       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1158       CALL histwrite_phy(o_dqvdf, zx_tmp_fi3d)
1159       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1160       CALL histwrite_phy(o_dteva, zx_tmp_fi3d)
1161       IF (vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1162       CALL histwrite_phy(o_dqeva, zx_tmp_fi3d)
1163       zpt_conv = 0.
1164       WHERE (ptconv) zpt_conv = 1.
1165       CALL histwrite_phy(o_ptconv, zpt_conv)
1166       CALL histwrite_phy(o_ratqs, ratqs)
1167       IF (vars_defined) THEN
1168          zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys - &
1169               d_t_ajsb(1:klon,1:klev)/pdtphys
1170       ENDIF
1171       CALL histwrite_phy(o_dtthe, zx_tmp_fi3d)
1172       IF (vars_defined) THEN
1173          zx_tmp_fi3d(1:klon,1:klev)=d_u_ajs(1:klon,1:klev)/pdtphys
1174       ENDIF
1175       CALL histwrite_phy(o_duthe, zx_tmp_fi3d)
1176       IF (vars_defined) THEN
1177          zx_tmp_fi3d(1:klon,1:klev)=d_v_ajs(1:klon,1:klev)/pdtphys
1178       ENDIF
1179       CALL histwrite_phy(o_dvthe, zx_tmp_fi3d)
1180
1181       IF (iflag_thermals>=1) THEN
1182          ! Pour l instant 0 a y reflichir pour les thermiques
1183          zx_tmp_fi2d=0.
1184          CALL histwrite_phy(o_ftime_th, zx_tmp_fi2d)
1185          CALL histwrite_phy(o_f_th, fm_therm)
1186          CALL histwrite_phy(o_e_th, entr_therm)
1187          CALL histwrite_phy(o_w_th, zw2)
1188          CALL histwrite_phy(o_q_th, zqasc)
1189          CALL histwrite_phy(o_a_th, fraca)
1190          CALL histwrite_phy(o_d_th, detr_therm)
1191          CALL histwrite_phy(o_f0_th, f0)
1192          CALL histwrite_phy(o_zmax_th, zmax_th)
1193          IF (vars_defined) THEN
1194             zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys - &
1195                  d_q_ajsb(1:klon,1:klev)/pdtphys
1196          ENDIF
1197          CALL histwrite_phy(o_dqthe, zx_tmp_fi3d)
1198       ENDIF !iflag_thermals
1199       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
1200       CALL histwrite_phy(o_dtajs, zx_tmp_fi3d)
1201       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
1202       CALL histwrite_phy(o_dqajs, zx_tmp_fi3d)
1203       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
1204       CALL histwrite_phy(o_dtswr, zx_tmp_fi3d)
1205       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
1206       CALL histwrite_phy(o_dtsw0, zx_tmp_fi3d)
1207       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
1208       CALL histwrite_phy(o_dtlwr, zx_tmp_fi3d)
1209       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
1210       CALL histwrite_phy(o_dtlw0, zx_tmp_fi3d)
1211       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)/pdtphys
1212       CALL histwrite_phy(o_dtec, zx_tmp_fi3d)
1213       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
1214       CALL histwrite_phy(o_duvdf, zx_tmp_fi3d)
1215       IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
1216       CALL histwrite_phy(o_dvvdf, zx_tmp_fi3d)
1217       IF (ok_orodr) THEN
1218          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
1219          CALL histwrite_phy(o_duoro, zx_tmp_fi3d)
1220          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
1221          CALL histwrite_phy(o_dvoro, zx_tmp_fi3d)
1222          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
1223          CALL histwrite_phy(o_dtoro, zx_tmp_fi3d)
1224       ENDIF
1225       IF (ok_orolf) THEN
1226          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
1227          CALL histwrite_phy(o_dulif, zx_tmp_fi3d)
1228
1229          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
1230          CALL histwrite_phy(o_dvlif, zx_tmp_fi3d)
1231
1232          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
1233          CALL histwrite_phy(o_dtlif, zx_tmp_fi3d)
1234       ENDIF
1235
1236       IF (ok_hines) THEN
1237          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
1238          CALL histwrite_phy(o_duhin, zx_tmp_fi3d)
1239          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
1240          CALL histwrite_phy(o_dvhin, zx_tmp_fi3d)
1241          IF(vars_defined) zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
1242          CALL histwrite_phy(o_dthin, zx_tmp_fi3d)
1243       ENDIF
1244
1245       IF (ok_gwd_rando) then
1246          CALL histwrite_phy(o_du_gwd_rando, du_gwd_rando / pdtphys)
1247          CALL histwrite_phy(o_dv_gwd_rando, dv_gwd_rando / pdtphys)
1248          CALL histwrite_phy(o_vstr_gwd_rando, zvstr_gwd_rando)
1249       end IF
1250
1251       CALL histwrite_phy(o_rsu, swup)
1252       CALL histwrite_phy(o_rsd, swdn)
1253       CALL histwrite_phy(o_rlu, lwup)
1254       CALL histwrite_phy(o_rld, lwdn)
1255       CALL histwrite_phy(o_rsucs, swup0)
1256       CALL histwrite_phy(o_rsdcs, swdn0)
1257       CALL histwrite_phy(o_rlucs, lwup0)
1258       CALL histwrite_phy(o_rldcs, lwdn0)
1259       IF(vars_defined) THEN
1260          zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+ &
1261               d_t_dyn(1:klon,1:klev)
1262       ENDIF
1263       CALL histwrite_phy(o_tnt, zx_tmp_fi3d)
1264       IF(vars_defined) THEN
1265          zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY - &
1266               cool(1:klon,1:klev)/RDAY
1267       ENDIF
1268       CALL histwrite_phy(o_tntr, zx_tmp_fi3d)
1269       IF(vars_defined) THEN
1270          zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+ &
1271               d_t_eva(1:klon,1:klev)+ &
1272               d_t_vdf(1:klon,1:klev))/pdtphys
1273       ENDIF
1274       CALL histwrite_phy(o_tntscpbl, zx_tmp_fi3d)
1275       IF(vars_defined) THEN
1276          zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+ &
1277               d_q_dyn(1:klon,1:klev)
1278       ENDIF
1279       CALL histwrite_phy(o_tnhus, zx_tmp_fi3d)
1280       IF(vars_defined) THEN
1281          zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+ &
1282               d_q_eva(1:klon,1:klev)/pdtphys
1283       ENDIF
1284       CALL histwrite_phy(o_tnhusscpbl, zx_tmp_fi3d)
1285       CALL histwrite_phy(o_evu, coefm(:,:,is_ave))
1286       IF(vars_defined) THEN
1287          zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+ &
1288               ql_seri(1:klon,1:klev)
1289       ENDIF
1290       CALL histwrite_phy(o_h2o, zx_tmp_fi3d)
1291       if (iflag_con >= 3) then
1292          IF(vars_defined) THEN
1293             zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+ &
1294                  dnwd0(1:klon,1:klev))
1295          ENDIF
1296          CALL histwrite_phy(o_mcd, zx_tmp_fi3d)
1297          IF(vars_defined) THEN
1298             zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) + &
1299                  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev)
1300          ENDIF
1301          CALL histwrite_phy(o_dmc, zx_tmp_fi3d)
1302       else if (iflag_con == 2) then
1303          CALL histwrite_phy(o_mcd,  pmfd)
1304          CALL histwrite_phy(o_dmc,  pmfu + pmfd)
1305       end if
1306       CALL histwrite_phy(o_ref_liq, ref_liq)
1307       CALL histwrite_phy(o_ref_ice, ref_ice)
1308       if (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
1309            RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
1310            RCFC12_per.NE.RCFC12_act) THEN
1311          IF(vars_defined) zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
1312          CALL histwrite_phy(o_rsut4co2, zx_tmp_fi2d)
1313          IF(vars_defined) zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
1314          CALL histwrite_phy(o_rlut4co2, zx_tmp_fi2d)
1315          IF(vars_defined) zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
1316          CALL histwrite_phy(o_rsutcs4co2, zx_tmp_fi2d)
1317          IF(vars_defined) zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
1318          CALL histwrite_phy(o_rlutcs4co2, zx_tmp_fi2d)
1319          CALL histwrite_phy(o_rsu4co2, swupp)
1320          CALL histwrite_phy(o_rlu4co2, lwupp)
1321          CALL histwrite_phy(o_rsucs4co2, swup0p)
1322          CALL histwrite_phy(o_rlucs4co2, lwup0p)
1323          CALL histwrite_phy(o_rsd4co2, swdnp)
1324          CALL histwrite_phy(o_rld4co2, lwdnp)
1325          CALL histwrite_phy(o_rsdcs4co2, swdn0p)
1326          CALL histwrite_phy(o_rldcs4co2, lwdn0p)
1327       ENDIF
1328!!!!!!!!!!!! Sorties niveaux de pression NMC !!!!!!!!!!!!!!!!!!!!
1329       DO iff=7, nfiles
1330
1331          CALL histwrite_phy(o_tnondef,tnondef(:,:,iff-6),iff)
1332          CALL histwrite_phy(o_ta,twriteSTD(:,:,iff-6),iff)
1333          CALL histwrite_phy(o_zg,phiwriteSTD(:,:,iff-6),iff)
1334          CALL histwrite_phy(o_hus,qwriteSTD(:,:,iff-6),iff)
1335          CALL histwrite_phy(o_hur,rhwriteSTD(:,:,iff-6),iff)
1336          CALL histwrite_phy(o_ua,uwriteSTD(:,:,iff-6),iff)
1337          CALL histwrite_phy(o_va,vwriteSTD(:,:,iff-6),iff)
1338          CALL histwrite_phy(o_wap,wwriteSTD(:,:,iff-6),iff)
1339          IF(vars_defined) THEN
1340             DO k=1, nlevSTD
1341                DO i=1, klon
1342                   IF(tnondef(i,k,iff-6).NE.missing_val) THEN
1343                      IF(freq_outNMC(iff-6).LT.0) THEN
1344                         freq_moyNMC(iff-6)=(mth_len*un_jour)/freq_calNMC(iff-6)
1345                      ELSE
1346                         freq_moyNMC(iff-6)=freq_outNMC(iff-6)/freq_calNMC(iff-6)
1347                      ENDIF
1348                      zx_tmp_fi3d_STD(i,k) = (100.*tnondef(i,k,iff-6))/freq_moyNMC(iff-6)
1349                   ELSE
1350                      zx_tmp_fi3d_STD(i,k) = missing_val
1351                   ENDIF
1352                ENDDO
1353             ENDDO
1354          ENDIF
1355          CALL histwrite_phy(o_psbg,zx_tmp_fi3d_STD,iff)
1356          IF(vars_defined) THEN
1357             DO k=1, nlevSTD
1358                DO i=1, klon
1359                   IF(O3sumSTD(i,k,iff-6).NE.missing_val) THEN
1360                      zx_tmp_fi3d_STD(i,k) = O3sumSTD(i,k,iff-6) * 1.e+9
1361                   ELSE
1362                      zx_tmp_fi3d_STD(i,k) = missing_val
1363                   ENDIF
1364                ENDDO
1365             ENDDO !k=1, nlevSTD
1366          ENDIF
1367          CALL histwrite_phy(o_tro3,zx_tmp_fi3d_STD,iff)
1368          if (read_climoz == 2) THEN
1369             IF(vars_defined) THEN
1370                DO k=1, nlevSTD
1371                   DO i=1, klon
1372                      IF(O3daysumSTD(i,k,iff-6).NE.missing_val) THEN
1373                         zx_tmp_fi3d_STD(i,k) = O3daysumSTD(i,k,iff-6) * 1.e+9
1374                      ELSE
1375                         zx_tmp_fi3d_STD(i,k) = missing_val
1376                      ENDIF
1377                   ENDDO
1378                ENDDO !k=1, nlevSTD
1379             ENDIF
1380             CALL histwrite_phy(o_tro3_daylight,zx_tmp_fi3d_STD,iff)
1381          endif
1382          CALL histwrite_phy(o_uxv,uvsumSTD(:,:,iff-6),iff)
1383          CALL histwrite_phy(o_vxq,vqsumSTD(:,:,iff-6),iff)
1384          CALL histwrite_phy(o_vxT,vTsumSTD(:,:,iff-6),iff)
1385          CALL histwrite_phy(o_wxq,wqsumSTD(:,:,iff-6),iff)
1386          CALL histwrite_phy(o_vxphi,vphisumSTD(:,:,iff-6),iff)
1387          CALL histwrite_phy(o_wxT,wTsumSTD(:,:,iff-6),iff)
1388          CALL histwrite_phy(o_uxu,u2sumSTD(:,:,iff-6),iff)
1389          CALL histwrite_phy(o_vxv,v2sumSTD(:,:,iff-6),iff)
1390          CALL histwrite_phy(o_TxT,T2sumSTD(:,:,iff-6),iff)
1391       ENDDO !nfiles
1392!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
1393       IF (nqtot.GE.3) THEN
1394          DO iq=3,nqtot
1395             CALL histwrite_phy(o_trac(iq-2), qx(:,:,iq))
1396             CALL histwrite_phy(o_dtr_vdf(iq-2),d_tr_cl(:,:,iq-2))
1397             CALL histwrite_phy(o_dtr_the(iq-2),d_tr_th(:,:,iq-2))
1398             CALL histwrite_phy(o_dtr_con(iq-2),d_tr_cv(:,:,iq-2))
1399             CALL histwrite_phy(o_dtr_lessi_impa(iq-2),d_tr_lessi_impa(:,:,iq-2))
1400             CALL histwrite_phy(o_dtr_lessi_nucl(iq-2),d_tr_lessi_nucl(:,:,iq-2))
1401             CALL histwrite_phy(o_dtr_insc(iq-2),d_tr_insc(:,:,iq-2))
1402             CALL histwrite_phy(o_dtr_bcscav(iq-2),d_tr_bcscav(:,:,iq-2))
1403             CALL histwrite_phy(o_dtr_evapls(iq-2),d_tr_evapls(:,:,iq-2))
1404             CALL histwrite_phy(o_dtr_ls(iq-2),d_tr_ls(:,:,iq-2))
1405             CALL histwrite_phy(o_dtr_trsp(iq-2),d_tr_trsp(:,:,iq-2))
1406             CALL histwrite_phy(o_dtr_sscav(iq-2),d_tr_sscav(:,:,iq-2))
1407             CALL histwrite_phy(o_dtr_sat(iq-2),d_tr_sat(:,:,iq-2))
1408             CALL histwrite_phy(o_dtr_uscav(iq-2),d_tr_uscav(:,:,iq-2))
1409             zx_tmp_fi2d=0.
1410             IF(vars_defined) THEN
1411                DO k=1,klev
1412                   zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+zmasse(:,k)*qx(:,k,iq)
1413                ENDDO
1414             ENDIF
1415             CALL histwrite_phy(o_trac_cum(iq-2), zx_tmp_fi2d)
1416          ENDDO
1417       ENDIF
1418
1419       IF(.NOT.vars_defined) THEN
1420          !$OMP MASTER
1421#ifndef CPP_NO_IOIPSL
1422          DO iff=1,nfiles
1423             IF (clef_files(iff)) THEN
1424                CALL histend(nid_files(iff))
1425                ndex2d = 0
1426                ndex3d = 0
1427
1428             ENDIF ! clef_files
1429          ENDDO !  iff
1430#endif
1431#ifdef CPP_XIOS
1432          !On finalise l'initialisation:
1433          CALL wxios_closedef()
1434#endif
1435
1436          !$OMP END MASTER
1437          !$OMP BARRIER
1438          vars_defined = .TRUE.
1439
1440       END IF
1441
1442    END DO
1443
1444    IF(vars_defined) THEN
1445       ! On synchronise les fichiers pour IOIPSL
1446#ifndef CPP_NO_IOIPSL
1447       !$OMP MASTER
1448       DO iff=1,nfiles
1449          IF (ok_sync .AND. clef_files(iff)) THEN
1450             CALL histsync(nid_files(iff))
1451          ENDIF
1452       END DO
1453       !$OMP END MASTER
1454#endif
1455    ENDIF
1456
1457  END SUBROUTINE phys_output_write
1458
1459END MODULE phys_output_write_mod
Note: See TracBrowser for help on using the repository browser.