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

Last change on this file since 1826 was 1825, checked in by Ehouarn Millour, 13 years ago

Première étape de l'implémentation de XIOS. Modifications isolées dans des flags CPP_XIOS. Sorties opérationnelles (sauf stations et régionalisation) en modes séquentiel et omp, pas mpi.
UG
...........................................
First step of the XIOS implementation. Modifications are confined into CPP_XIOS flags. Output is operationnal (except for stations and regionalization) in sequential and omp modes (not mpi).
UG

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