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

Last change on this file since 1915 was 1915, checked in by musat, 11 years ago

D'autres oublis pour les sorties annuelles
IM

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