source: LMDZ5/branches/LMDZ5V1.0-dev/libf/phylmd/phys_output_write.h @ 2930

Last change on this file since 2930 was 1403, checked in by Laurent Fairhead, 14 years ago

Merged LMDZ4V5.0-dev branch changes r1292:r1399 to trunk.

Validation:
Validation consisted in compiling the HEAD revision of the trunk,
LMDZ4V5.0-dev branch and the merged sources and running different
configurations on local and SX8 machines comparing results.

Local machine: bench configuration, 32x24x11, gfortran

  • IPSLCM5A configuration (comparison between trunk and merged sources):
    • numerical convergence on dynamical fields over 3 days
    • start files are equivalent (except for RN and PB fields)
    • daily history files equivalent
  • MH07 configuration, new physics package (comparison between LMDZ4V5.0-dev branch and merged sources):
    • numerical convergence on dynamical fields over 3 days
    • start files are equivalent (except for RN and PB fields)
    • daily history files equivalent

SX8 machine (brodie), 96x95x39 on 4 processors:

  • IPSLCM5A configuration:
    • start files are equivalent (except for RN and PB fields)
    • monthly history files equivalent
  • MH07 configuration:
    • start files are equivalent (except for RN and PB fields)
    • monthly history files equivalent

Changes to the makegcm and create_make_gcm scripts to take into account
main programs in F90 files


Fusion de la branche LMDZ4V5.0-dev (r1292:r1399) au tronc principal

Validation:
La validation a consisté à compiler la HEAD de le trunk et de la banche
LMDZ4V5.0-dev et les sources fusionnées et de faire tourner le modéle selon
différentes configurations en local et sur SX8 et de comparer les résultats

En local: 32x24x11, config bench/gfortran

  • pour une config IPSLCM5A (comparaison tronc/fusion):
    • convergence numérique sur les champs dynamiques après 3 jours
    • restart et restartphy égaux (à part sur RN et Pb)
    • fichiers histoire égaux
  • pour une config nlle physique (MH07) (comparaison LMDZ4v5.0-dev/fusion):
    • convergence numérique sur les champs dynamiques après 3 jours
    • restart et restartphy égaux
    • fichiers histoire équivalents

Sur brodie, 96x95x39 sur 4 proc:

  • pour une config IPSLCM5A:
    • restart et restartphy égaux (à part sur RN et PB)
    • pas de différence dans les fichiers histmth.nc
  • pour une config MH07
    • restart et restartphy égaux (à part sur RN et PB)
    • pas de différence dans les fichiers histmth.nc

Changement sur makegcm et create_make-gcm pour pouvoir prendre en compte des
programmes principaux en *F90

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 52.1 KB
Line 
1      itau_w = itau_phy + itap
2
3      DO iff=1,nfiles
4
5       IF (clef_files(iff)) THEN
6             ndex2d = 0
7             ndex3d = 0
8
9!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10       IF (o_phis%flag(iff)<=lev_files(iff)) THEN
11         CALL histwrite_phy(nid_files(iff),
12     $                      o_phis%name,itau_w,pphis)
13       ENDIF
14
15       IF (o_aire%flag(iff)<=lev_files(iff)) THEN
16       CALL histwrite_phy(nid_files(iff),o_aire%name,itau_w,airephy)
17       ENDIF
18
19       IF (o_contfracATM%flag(iff)<=lev_files(iff)) THEN
20      DO i=1, klon
21       zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
22      ENDDO
23      CALL histwrite_phy(nid_files(iff),
24     $             o_contfracATM%name,itau_w,zx_tmp_fi2d)
25       ENDIF
26
27       IF (o_contfracOR%flag(iff)<=lev_files(iff)) THEN
28      CALL histwrite_phy(nid_files(iff),o_contfracOR%name,itau_w,
29     $                   pctsrf(:,is_ter))
30       ENDIF
31
32       IF (o_aireTER%flag(iff)<=lev_files(iff)) THEN
33      CALL histwrite_phy(nid_files(iff),
34     $                  o_aireTER%name,itau_w,paire_ter)
35       ENDIF
36
37!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
39       IF (o_flat%flag(iff)<=lev_files(iff)) THEN
40      CALL histwrite_phy(nid_files(iff),o_flat%name,itau_w,zxfluxlat)
41       ENDIF
42
43       IF (o_slp%flag(iff)<=lev_files(iff)) THEN
44      CALL histwrite_phy(nid_files(iff),o_slp%name,itau_w,slp)
45       ENDIF
46
47       IF (o_tsol%flag(iff)<=lev_files(iff)) THEN
48      CALL histwrite_phy(nid_files(iff),o_tsol%name,itau_w,zxtsol)
49       ENDIF
50
51       IF (o_t2m%flag(iff)<=lev_files(iff)) THEN
52      CALL histwrite_phy(nid_files(iff),o_t2m%name,itau_w,zt2m)
53       ENDIF
54
55       IF (o_t2m_min%flag(iff)<=lev_files(iff)) THEN
56      CALL histwrite_phy(nid_files(iff),o_t2m_min%name,itau_w,zt2m)
57       ENDIF
58
59       IF (o_t2m_max%flag(iff)<=lev_files(iff)) THEN
60      CALL histwrite_phy(nid_files(iff),o_t2m_max%name,itau_w,zt2m)
61       ENDIF
62
63       IF (o_wind10m%flag(iff)<=lev_files(iff)) THEN
64      DO i=1, klon
65       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
66      ENDDO
67      CALL histwrite_phy(nid_files(iff),
68     s                  o_wind10m%name,itau_w,zx_tmp_fi2d)
69       ENDIF
70
71       IF (o_wind10max%flag(iff)<=lev_files(iff)) THEN
72      DO i=1, klon
73       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
74      ENDDO
75      CALL histwrite_phy(nid_files(iff),o_wind10max%name, 
76     $                   itau_w,zx_tmp_fi2d)
77       ENDIF
78
79       IF (o_sicf%flag(iff)<=lev_files(iff)) THEN
80      DO i = 1, klon
81         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
82      ENDDO
83      CALL histwrite_phy(nid_files(iff),
84     $                   o_sicf%name,itau_w,zx_tmp_fi2d)
85       ENDIF
86
87       IF (o_q2m%flag(iff)<=lev_files(iff)) THEN
88      CALL histwrite_phy(nid_files(iff),o_q2m%name,itau_w,zq2m)
89       ENDIF
90
91       IF (o_u10m%flag(iff)<=lev_files(iff)) THEN
92      CALL histwrite_phy(nid_files(iff),o_u10m%name,itau_w,zu10m)
93       ENDIF
94
95       IF (o_v10m%flag(iff)<=lev_files(iff)) THEN
96      CALL histwrite_phy(nid_files(iff),o_v10m%name,itau_w,zv10m)
97       ENDIF
98
99       IF (o_psol%flag(iff)<=lev_files(iff)) THEN
100      DO i = 1, klon
101         zx_tmp_fi2d(i) = paprs(i,1)
102      ENDDO
103      CALL histwrite_phy(nid_files(iff),
104     s                   o_psol%name,itau_w,zx_tmp_fi2d)
105       ENDIF
106
107       IF (o_qsurf%flag(iff)<=lev_files(iff)) THEN
108      CALL histwrite_phy(nid_files(iff),o_qsurf%name,itau_w,zxqsurf)
109       ENDIF
110
111       if (.not. ok_veget) then
112         IF (o_qsol%flag(iff)<=lev_files(iff)) THEN
113        CALL histwrite_phy(nid_files(iff),o_qsol%name,itau_w,qsol)
114         ENDIF
115       endif
116
117      IF (o_precip%flag(iff)<=lev_files(iff)) THEN
118       DO i = 1, klon
119         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
120       ENDDO
121      CALL histwrite_phy(nid_files(iff),o_precip%name,
122     s                   itau_w,zx_tmp_fi2d)
123      ENDIF
124
125       IF (o_ndayrain%flag(iff)<=lev_files(iff)) THEN
126      CALL histwrite_phy(nid_files(iff),o_ndayrain%name,
127     s                   itau_w,nday_rain)
128       ENDIF
129
130      IF (o_plul%flag(iff)<=lev_files(iff)) THEN
131       DO i = 1, klon
132         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
133       ENDDO
134      CALL histwrite_phy(nid_files(iff),o_plul%name,itau_w,zx_tmp_fi2d)
135      ENDIF
136
137      IF (o_pluc%flag(iff)<=lev_files(iff)) THEN
138      DO i = 1, klon
139         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
140      ENDDO
141      CALL histwrite_phy(nid_files(iff),o_pluc%name,itau_w,zx_tmp_fi2d)
142      ENDIF
143
144       IF (o_snow%flag(iff)<=lev_files(iff)) THEN
145      CALL histwrite_phy(nid_files(iff),o_snow%name,itau_w,snow_fall)
146       ENDIF
147
148       IF (o_msnow%flag(iff)<=lev_files(iff)) THEN
149      CALL histwrite_phy(nid_files(iff),o_msnow%name,itau_w,snow_o)
150       ENDIF
151
152       IF (o_fsnow%flag(iff)<=lev_files(iff)) THEN
153      CALL histwrite_phy(nid_files(iff),o_fsnow%name,itau_w,zfra_o)
154       ENDIF
155
156       IF (o_evap%flag(iff)<=lev_files(iff)) THEN
157      CALL histwrite_phy(nid_files(iff),o_evap%name,itau_w,evap)
158       ENDIF
159
160       IF (o_tops%flag(iff)<=lev_files(iff)) THEN
161      CALL histwrite_phy(nid_files(iff),o_tops%name,itau_w,topsw)
162       ENDIF
163
164       IF (o_tops0%flag(iff)<=lev_files(iff)) THEN
165      CALL histwrite_phy(nid_files(iff),o_tops0%name,itau_w,topsw0)
166       ENDIF
167
168       IF (o_topl%flag(iff)<=lev_files(iff)) THEN
169      CALL histwrite_phy(nid_files(iff),o_topl%name,itau_w,toplw)
170       ENDIF
171
172       IF (o_topl0%flag(iff)<=lev_files(iff)) THEN
173      CALL histwrite_phy(nid_files(iff),o_topl0%name,itau_w,toplw0)
174       ENDIF
175
176       IF (o_SWupTOA%flag(iff)<=lev_files(iff)) THEN
177      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
178      CALL histwrite_phy(nid_files(iff),o_SWupTOA%name,
179     s                     itau_w,zx_tmp_fi2d)
180       ENDIF
181
182       IF (o_SWupTOAclr%flag(iff)<=lev_files(iff)) THEN
183      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
184      CALL histwrite_phy(nid_files(iff), 
185     $                  o_SWupTOAclr%name,itau_w,zx_tmp_fi2d)
186       ENDIF
187
188       IF (o_SWdnTOA%flag(iff)<=lev_files(iff)) THEN
189      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
190      CALL histwrite_phy(nid_files(iff),
191     s                  o_SWdnTOA%name,itau_w,zx_tmp_fi2d)
192       ENDIF
193
194       IF (o_SWdnTOAclr%flag(iff)<=lev_files(iff)) THEN
195      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
196      CALL histwrite_phy(nid_files(iff), 
197     $                  o_SWdnTOAclr%name,itau_w,zx_tmp_fi2d)
198       ENDIF
199
200       IF (o_nettop%flag(iff)<=lev_files(iff)) THEN
201      zx_tmp_fi2d(:) = topsw(:)-toplw(:)
202      CALL histwrite_phy(nid_files(iff),
203     $                  o_nettop%name,itau_w,zx_tmp_fi2d)
204       ENDIF
205
206       IF (o_SWup200%flag(iff)<=lev_files(iff)) THEN
207      CALL histwrite_phy(nid_files(iff),o_SWup200%name,itau_w,SWup200)
208       ENDIF
209
210       IF (o_SWup200clr%flag(iff)<=lev_files(iff)) THEN
211      CALL histwrite_phy(nid_files(iff),
212     s                   o_SWup200clr%name,itau_w,SWup200clr)
213       ENDIF
214
215       IF (o_SWdn200%flag(iff)<=lev_files(iff)) THEN
216      CALL histwrite_phy(nid_files(iff),o_SWdn200%name,itau_w,SWdn200)
217       ENDIF
218
219       IF (o_SWdn200clr%flag(iff)<=lev_files(iff)) THEN
220      CALL histwrite_phy(nid_files(iff),
221     s                o_SWdn200clr%name,itau_w,SWdn200clr)
222       ENDIF
223
224       IF (o_LWup200%flag(iff)<=lev_files(iff)) THEN
225      CALL histwrite_phy(nid_files(iff),o_LWup200%name,itau_w,LWup200)
226       ENDIF
227
228       IF (o_LWup200clr%flag(iff)<=lev_files(iff)) THEN
229      CALL histwrite_phy(nid_files(iff),
230     s                   o_LWup200clr%name,itau_w,LWup200clr)
231       ENDIF
232
233       IF (o_LWdn200%flag(iff)<=lev_files(iff)) THEN
234      CALL histwrite_phy(nid_files(iff),
235     s                   o_LWdn200%name,itau_w,LWdn200)
236       ENDIF
237
238       IF (o_LWdn200clr%flag(iff)<=lev_files(iff)) THEN
239      CALL histwrite_phy(nid_files(iff),
240     s                  o_LWdn200clr%name,itau_w,LWdn200clr)
241       ENDIF
242
243       IF (o_sols%flag(iff)<=lev_files(iff)) THEN
244      CALL histwrite_phy(nid_files(iff),o_sols%name,itau_w,solsw)
245       ENDIF
246
247       IF (o_sols0%flag(iff)<=lev_files(iff)) THEN
248      CALL histwrite_phy(nid_files(iff),o_sols0%name,itau_w,solsw0)
249       ENDIF
250
251       IF (o_soll%flag(iff)<=lev_files(iff)) THEN
252      CALL histwrite_phy(nid_files(iff),o_soll%name,itau_w,sollw)
253       ENDIF
254
255       IF (o_radsol%flag(iff)<=lev_files(iff)) THEN
256      CALL histwrite_phy(nid_files(iff),o_radsol%name,itau_w,radsol)
257       ENDIF
258
259       IF (o_soll0%flag(iff)<=lev_files(iff)) THEN
260      CALL histwrite_phy(nid_files(iff),o_soll0%name,itau_w,sollw0)
261       ENDIF
262
263       IF (o_SWupSFC%flag(iff)<=lev_files(iff)) THEN
264      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
265      CALL histwrite_phy(nid_files(iff),
266     s               o_SWupSFC%name,itau_w,zx_tmp_fi2d)
267       ENDIF
268
269       IF (o_SWupSFCclr%flag(iff)<=lev_files(iff)) THEN
270      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
271      CALL histwrite_phy(nid_files(iff), 
272     $                   o_SWupSFCclr%name,itau_w,zx_tmp_fi2d)
273       ENDIF
274
275       IF (o_SWdnSFC%flag(iff)<=lev_files(iff)) THEN
276      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
277      CALL histwrite_phy(nid_files(iff), 
278     $                   o_SWdnSFC%name,itau_w,zx_tmp_fi2d)
279       ENDIF
280
281       IF (o_SWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
282      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
283      CALL histwrite_phy(nid_files(iff), 
284     $                  o_SWdnSFCclr%name,itau_w,zx_tmp_fi2d)
285       ENDIF
286
287       IF (o_LWupSFC%flag(iff)<=lev_files(iff)) THEN
288      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
289      CALL histwrite_phy(nid_files(iff),
290     $                    o_LWupSFC%name,itau_w,zx_tmp_fi2d)
291       ENDIF
292
293       IF (o_LWdnSFC%flag(iff)<=lev_files(iff)) THEN
294      CALL histwrite_phy(nid_files(iff),
295     $                   o_LWdnSFC%name,itau_w,sollwdown)
296       ENDIF
297
298       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
299       IF (o_LWupSFCclr%flag(iff)<=lev_files(iff)) THEN
300      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
301      CALL histwrite_phy(nid_files(iff),
302     $                   o_LWupSFCclr%name,itau_w,zx_tmp_fi2d)
303       ENDIF
304
305       IF (o_LWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
306      CALL histwrite_phy(nid_files(iff),
307     $                   o_LWdnSFCclr%name,itau_w,sollwdownclr)
308       ENDIF
309
310       IF (o_bils%flag(iff)<=lev_files(iff)) THEN
311      CALL histwrite_phy(nid_files(iff),o_bils%name,itau_w,bils)
312       ENDIF
313
314       IF (o_sens%flag(iff)<=lev_files(iff)) THEN
315      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
316      CALL histwrite_phy(nid_files(iff),o_sens%name,itau_w,zx_tmp_fi2d)
317       ENDIF
318
319       IF (o_fder%flag(iff)<=lev_files(iff)) THEN
320      CALL histwrite_phy(nid_files(iff),o_fder%name,itau_w,fder)
321       ENDIF
322
323       IF (o_ffonte%flag(iff)<=lev_files(iff)) THEN
324       CALL histwrite_phy(nid_files(iff),o_ffonte%name,itau_w,zxffonte)
325       ENDIF
326
327       IF (o_fqcalving%flag(iff)<=lev_files(iff)) THEN
328       CALL histwrite_phy(nid_files(iff),
329     $                    o_fqcalving%name,itau_w,zxfqcalving)
330       ENDIF
331
332       IF (o_fqfonte%flag(iff)<=lev_files(iff)) THEN
333       CALL histwrite_phy(nid_files(iff),
334     $                   o_fqfonte%name,itau_w,zxfqfonte)
335       ENDIF
336
337       IF (o_taux%flag(iff)<=lev_files(iff)) THEN
338         zx_tmp_fi2d=0.
339         do nsrf=1,nbsrf
340          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
341         enddo
342         CALL histwrite_phy(nid_files(iff),
343     $                   o_taux%name,itau_w,zx_tmp_fi2d)
344       ENDIF
345
346       IF (o_tauy%flag(iff)<=lev_files(iff)) THEN
347         zx_tmp_fi2d=0.
348         do nsrf=1,nbsrf
349          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
350         enddo
351         CALL histwrite_phy(nid_files(iff),
352     $                   o_tauy%name,itau_w,zx_tmp_fi2d)
353       ENDIF
354
355         DO nsrf = 1, nbsrf
356!           IF(nsrf.GE.2) THEN
357            IF (o_pourc_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
358            zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
359            CALL histwrite_phy(nid_files(iff),
360     $                     o_pourc_srf(nsrf)%name,itau_w,
361     $                     zx_tmp_fi2d)
362            ENDIF
363
364          IF (o_fract_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
365          zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
366          CALL histwrite_phy(nid_files(iff),
367     $                  o_fract_srf(nsrf)%name,itau_w,
368     $                  zx_tmp_fi2d)
369          ENDIF
370!         ENDIF !nsrf.GT.2
371
372        IF (o_taux_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
373        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
374        CALL histwrite_phy(nid_files(iff),
375     $                     o_taux_srf(nsrf)%name,itau_w,
376     $                     zx_tmp_fi2d)
377        ENDIF
378
379        IF (o_tauy_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN           
380        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
381        CALL histwrite_phy(nid_files(iff),
382     $                    o_tauy_srf(nsrf)%name,itau_w,
383     $                    zx_tmp_fi2d)
384        ENDIF
385
386        IF (o_tsol_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
387        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
388        CALL histwrite_phy(nid_files(iff),
389     $                   o_tsol_srf(nsrf)%name,itau_w,
390     $      zx_tmp_fi2d)
391        ENDIF
392
393      IF (o_u10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
394      zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
395      CALL histwrite_phy(nid_files(iff),o_u10m_srf(nsrf)%name,
396     $                 itau_w,zx_tmp_fi2d)
397      ENDIF
398
399      IF (o_v10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
400      zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
401      CALL histwrite_phy(nid_files(iff),o_v10m_srf(nsrf)%name,
402     $              itau_w,zx_tmp_fi2d)
403      ENDIF
404 
405      IF (o_t2m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
406      zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
407      CALL histwrite_phy(nid_files(iff),o_t2m_srf(nsrf)%name,
408     $           itau_w,zx_tmp_fi2d)
409      ENDIF
410
411      IF (o_evap_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
412      zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
413      CALL histwrite_phy(nid_files(iff),o_evap_srf(nsrf)%name,
414     $           itau_w,zx_tmp_fi2d)
415      ENDIF
416
417       IF (o_sens_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
418       zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
419       CALL histwrite_phy(nid_files(iff),
420     $                    o_sens_srf(nsrf)%name,itau_w,
421     $      zx_tmp_fi2d)
422       ENDIF
423
424        IF (o_lat_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
425        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
426        CALL histwrite_phy(nid_files(iff),
427     $                 o_lat_srf(nsrf)%name,itau_w,
428     $                                   zx_tmp_fi2d)
429          ENDIF
430
431        IF (o_flw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
432        zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
433        CALL histwrite_phy(nid_files(iff),
434     $                     o_flw_srf(nsrf)%name,itau_w,
435     $      zx_tmp_fi2d)
436        ENDIF
437
438        IF (o_fsw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
439        zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
440        CALL histwrite_phy(nid_files(iff),
441     $                   o_fsw_srf(nsrf)%name,itau_w,
442     $      zx_tmp_fi2d)
443        ENDIF
444
445        IF (o_wbils_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
446        zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
447        CALL histwrite_phy(nid_files(iff),
448     $                   o_wbils_srf(nsrf)%name,itau_w,
449     $      zx_tmp_fi2d)
450        ENDIF
451
452        IF (o_wbilo_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
453        zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
454        CALL histwrite_phy(nid_files(iff),
455     $                    o_wbilo_srf(nsrf)%name,itau_w,
456     $      zx_tmp_fi2d)
457        ENDIF
458
459       if (iflag_pbl>1 .and. lev_histday.gt.10 ) then
460        IF (o_tke_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
461        CALL histwrite_phy(nid_files(iff),
462     $                   o_tke_srf(nsrf)%name,itau_w,
463     $                    pbl_tke(:,1:klev,nsrf))
464       ENDIF
465
466        IF (o_tke_max_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
467        CALL histwrite_phy(nid_files(iff),
468     $                    o_tke_max_srf(nsrf)%name,itau_w,
469     $      pbl_tke(:,1:klev,nsrf))
470        ENDIF
471       endif
472      ENDDO
473
474        IF (o_cdrm%flag(iff)<=lev_files(iff)) THEN
475      CALL histwrite_phy(nid_files(iff),o_cdrm%name,itau_w,cdragm)
476        ENDIF
477
478        IF (o_cdrh%flag(iff)<=lev_files(iff)) THEN
479      CALL histwrite_phy(nid_files(iff),o_cdrh%name,itau_w,cdragh)
480        ENDIF
481
482        IF (o_cldl%flag(iff)<=lev_files(iff)) THEN
483      CALL histwrite_phy(nid_files(iff),o_cldl%name,itau_w,cldl)
484        ENDIF
485
486        IF (o_cldm%flag(iff)<=lev_files(iff)) THEN
487      CALL histwrite_phy(nid_files(iff),o_cldm%name,itau_w,cldm)
488        ENDIF
489
490        IF (o_cldh%flag(iff)<=lev_files(iff)) THEN
491      CALL histwrite_phy(nid_files(iff),o_cldh%name,itau_w,cldh)
492        ENDIF
493
494        IF (o_cldt%flag(iff)<=lev_files(iff)) THEN
495      CALL histwrite_phy(nid_files(iff),o_cldt%name, 
496     &                   itau_w,cldt)
497        ENDIF
498
499        IF (o_cldq%flag(iff)<=lev_files(iff)) THEN
500      CALL histwrite_phy(nid_files(iff),o_cldq%name,itau_w,cldq)
501        ENDIF
502
503        IF (o_lwp%flag(iff)<=lev_files(iff)) THEN
504      zx_tmp_fi2d(1:klon) = flwp(1:klon)
505      CALL histwrite_phy(nid_files(iff),
506     s                   o_lwp%name,itau_w,zx_tmp_fi2d)
507        ENDIF
508
509        IF (o_iwp%flag(iff)<=lev_files(iff)) THEN
510      zx_tmp_fi2d(1:klon) = fiwp(1:klon)
511      CALL histwrite_phy(nid_files(iff),
512     s                    o_iwp%name,itau_w,zx_tmp_fi2d)
513        ENDIF
514
515        IF (o_ue%flag(iff)<=lev_files(iff)) THEN
516      CALL histwrite_phy(nid_files(iff),o_ue%name,itau_w,ue)
517        ENDIF
518
519        IF (o_ve%flag(iff)<=lev_files(iff)) THEN
520      CALL histwrite_phy(nid_files(iff),o_ve%name,itau_w,ve)
521        ENDIF
522
523        IF (o_uq%flag(iff)<=lev_files(iff)) THEN
524      CALL histwrite_phy(nid_files(iff),o_uq%name,itau_w,uq)
525        ENDIF
526
527        IF (o_vq%flag(iff)<=lev_files(iff)) THEN
528      CALL histwrite_phy(nid_files(iff),o_vq%name,itau_w,vq)
529        ENDIF
530
531      IF(iflag_con.GE.3) THEN ! sb
532        IF (o_cape%flag(iff)<=lev_files(iff)) THEN
533      CALL histwrite_phy(nid_files(iff),o_cape%name,itau_w,cape)
534        ENDIF
535
536        IF (o_pbase%flag(iff)<=lev_files(iff)) THEN
537      CALL histwrite_phy(nid_files(iff),o_pbase%name,itau_w,ema_pcb)
538        ENDIF
539
540        IF (o_ptop%flag(iff)<=lev_files(iff)) THEN
541      CALL histwrite_phy(nid_files(iff),o_ptop%name,itau_w,ema_pct)
542        ENDIF
543
544        IF (o_fbase%flag(iff)<=lev_files(iff)) THEN
545      CALL histwrite_phy(nid_files(iff),o_fbase%name,itau_w,ema_cbmf)
546        ENDIF
547
548        IF (o_prw%flag(iff)<=lev_files(iff)) THEN
549      CALL histwrite_phy(nid_files(iff),o_prw%name,itau_w,prw)
550        ENDIF
551
552      IF (o_cape_max%flag(iff)<=lev_files(iff)) THEN
553      CALL histwrite_phy(nid_files(iff),o_cape_max%name,itau_w,cape)
554      ENDIF
555
556       IF (o_upwd%flag(iff)<=lev_files(iff)) THEN
557      CALL histwrite_phy(nid_files(iff),o_upwd%name,itau_w,upwd)
558       ENDIF
559
560       IF (o_Ma%flag(iff)<=lev_files(iff)) THEN
561      CALL histwrite_phy(nid_files(iff),o_Ma%name,itau_w,Ma)
562       ENDIF
563
564       IF (o_dnwd%flag(iff)<=lev_files(iff)) THEN
565      CALL histwrite_phy(nid_files(iff),o_dnwd%name,itau_w,dnwd)
566       ENDIF
567
568       IF (o_dnwd0%flag(iff)<=lev_files(iff)) THEN
569      CALL histwrite_phy(nid_files(iff),o_dnwd0%name,itau_w,dnwd0)
570       ENDIF
571
572       IF (o_ftime_con%flag(iff)<=lev_files(iff)) THEN
573        zx_tmp_fi2d=float(itau_con)/float(itap)
574      CALL histwrite_phy(nid_files(iff),o_ftime_con%name,
575     s                   itau_w,zx_tmp_fi2d)
576       ENDIF
577
578       IF (o_mc%flag(iff)<=lev_files(iff)) THEN
579        if(iflag_thermals.gt.1)then
580         zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm
581        else
582         zx_tmp_fi3d=dnwd+dnwd0+upwd
583        endif
584      CALL histwrite_phy(nid_files(iff),o_mc%name,itau_w,zx_tmp_fi3d)
585       ENDIF
586     
587      ENDIF !iflag_con .GE. 3
588
589        IF (o_s_pblh%flag(iff)<=lev_files(iff)) THEN
590      CALL histwrite_phy(nid_files(iff),o_s_pblh%name,itau_w,s_pblh)
591        ENDIF
592
593        IF (o_s_pblt%flag(iff)<=lev_files(iff)) THEN
594      CALL histwrite_phy(nid_files(iff),o_s_pblt%name,itau_w,s_pblt)
595        ENDIF
596
597        IF (o_s_lcl%flag(iff)<=lev_files(iff)) THEN
598      CALL histwrite_phy(nid_files(iff),o_s_lcl%name,itau_w,s_lcl)
599        ENDIF
600
601        IF (o_s_therm%flag(iff)<=lev_files(iff)) THEN
602      CALL histwrite_phy(nid_files(iff),o_s_therm%name,itau_w,s_therm)
603        ENDIF
604
605!IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
606!       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
607!     CALL histwrite_phy(nid_files(iff),o_s_capCL%name,itau_w,s_capCL)
608!       ENDIF
609
610!       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
611!     CALL histwrite_phy(nid_files(iff),o_s_oliqCL%name,itau_w,s_oliqCL)
612!       ENDIF
613
614!       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
615!     CALL histwrite_phy(nid_files(iff),o_s_cteiCL%name,itau_w,s_cteiCL)
616!       ENDIF
617
618!       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
619!     CALL histwrite_phy(nid_files(iff),o_s_trmb1%name,itau_w,s_trmb1)
620!       ENDIF
621
622!       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
623!     CALL histwrite_phy(nid_files(iff),o_s_trmb2%name,itau_w,s_trmb2)
624!       ENDIF
625
626!       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
627!     CALL histwrite_phy(nid_files(iff),o_s_trmb3%name,itau_w,s_trmb3)
628!       ENDIF
629
630! Champs interpolles sur des niveaux de pression
631
632        ll=0
633        DO k=1, nlevSTD
634!         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
635!         IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
636         bb2=clevSTD(k) 
637         IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
638     $      bb2.EQ."500".OR.bb2.EQ."200".OR.
639     $      bb2.EQ."50".OR.bb2.EQ."10") THEN
640
641! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
642          ll=ll+1
643       IF (o_uSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
644       CALL histwrite_phy(nid_files(iff),o_uSTDlevs(ll)%name,
645     &                    itau_w,uwriteSTD(:,k,iff))
646       ENDIF
647
648       IF (o_vSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
649      CALL histwrite_phy(nid_files(iff),o_vSTDlevs(ll)%name, 
650     &                   itau_w,vwriteSTD(:,k,iff))
651       ENDIF
652
653       IF (o_wSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
654      CALL histwrite_phy(nid_files(iff),o_wSTDlevs(ll)%name,
655     &                    itau_w,wwriteSTD(:,k,iff))
656       ENDIF
657
658       IF (o_zSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
659      CALL histwrite_phy(nid_files(iff),o_zSTDlevs(ll)%name,
660     &               itau_w,phiwriteSTD(:,k,iff))
661       ENDIF
662
663       IF (o_qSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
664      CALL histwrite_phy(nid_files(iff),o_qSTDlevs(ll)%name,
665     &                   itau_w, qwriteSTD(:,k,iff))
666       ENDIF
667
668       IF (o_tSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
669      CALL histwrite_phy(nid_files(iff),o_tSTDlevs(ll)%name,
670     &                   itau_w, twriteSTD(:,k,iff))
671       ENDIF
672
673       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
674       ENDDO
675
676      IF (o_t_oce_sic%flag(iff)<=lev_files(iff)) THEN
677      DO i=1, klon
678       IF (pctsrf(i,is_oce).GT.epsfra.OR.
679     $     pctsrf(i,is_sic).GT.epsfra) THEN
680        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+
681     $                   ftsol(i, is_sic) * pctsrf(i,is_sic))/
682     $                   (pctsrf(i,is_oce)+pctsrf(i,is_sic))
683       ELSE
684        zx_tmp_fi2d(i) = 273.15
685       ENDIF
686      ENDDO
687      CALL histwrite_phy(nid_files(iff),
688     s                   o_t_oce_sic%name,itau_w,zx_tmp_fi2d)
689      ENDIF
690
691! Couplage convection-couche limite
692      IF (iflag_con.GE.3) THEN
693      IF (iflag_coupl.EQ.1) THEN
694       IF (o_ale_bl%flag(iff)<=lev_files(iff)) THEN
695       CALL histwrite_phy(nid_files(iff),o_ale_bl%name,itau_w,ale_bl)
696       ENDIF
697       IF (o_alp_bl%flag(iff)<=lev_files(iff)) THEN
698       CALL histwrite_phy(nid_files(iff),o_alp_bl%name,itau_w,alp_bl)
699       ENDIF
700      ENDIF !iflag_coupl.EQ.1
701      ENDIF !(iflag_con.GE.3)
702
703! Wakes
704      IF (iflag_con.EQ.3) THEN
705      IF (iflag_wake.EQ.1) THEN
706       IF (o_ale_wk%flag(iff)<=lev_files(iff)) THEN
707       CALL histwrite_phy(nid_files(iff),o_ale_wk%name,itau_w,ale_wake)
708       ENDIF
709       IF (o_alp_wk%flag(iff)<=lev_files(iff)) THEN
710       CALL histwrite_phy(nid_files(iff),o_alp_wk%name,itau_w,alp_wake)
711       ENDIF
712
713       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
714       CALL histwrite_phy(nid_files(iff),o_ale%name,itau_w,ale)
715       ENDIF
716       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
717       CALL histwrite_phy(nid_files(iff),o_alp%name,itau_w,alp)
718       ENDIF
719       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
720       CALL histwrite_phy(nid_files(iff),o_cin%name,itau_w,cin)
721       ENDIF
722       IF (o_wape%flag(iff)<=lev_files(iff)) THEN
723       CALL histwrite_phy(nid_files(iff),o_WAPE%name,itau_w,wake_pe)
724       ENDIF
725       IF (o_wake_h%flag(iff)<=lev_files(iff)) THEN
726      CALL histwrite_phy(nid_files(iff),o_wake_h%name,itau_w,wake_h)
727       ENDIF
728
729       IF (o_wake_s%flag(iff)<=lev_files(iff)) THEN
730      CALL histwrite_phy(nid_files(iff),o_wake_s%name,itau_w,wake_s)
731       ENDIF
732
733        IF (o_wake_deltat%flag(iff)<=lev_files(iff)) THEN
734       CALL histwrite_phy(nid_files(iff),o_wake_deltat%name,
735     $                     itau_w,wake_deltat)
736        ENDIF
737
738        IF (o_wake_deltaq%flag(iff)<=lev_files(iff)) THEN
739       CALL histwrite_phy(nid_files(iff),o_wake_deltaq%name,
740     $                    itau_w,wake_deltaq)
741        ENDIF
742
743        IF (o_wake_omg%flag(iff)<=lev_files(iff)) THEN
744       CALL histwrite_phy(nid_files(iff),
745     s                    o_wake_omg%name,itau_w,wake_omg)
746        ENDIF
747
748         IF (o_dtwak%flag(iff)<=lev_files(iff)) THEN
749           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)
750     &                                        /pdtphys
751           CALL histwrite_phy(nid_files(iff),
752     &                       o_dtwak%name,itau_w,zx_tmp_fi3d)
753         ENDIF
754
755        IF (o_dqwak%flag(iff)<=lev_files(iff)) THEN
756        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
757        CALL histwrite_phy(nid_files(iff),
758     &                     o_dqwak%name,itau_w,zx_tmp_fi3d)
759        ENDIF
760      ENDIF ! iflag_wake.EQ.1
761
762        IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
763       CALL histwrite_phy(nid_files(iff),o_Vprecip%name,itau_w,Vprecip)
764        ENDIF
765
766        IF (o_ftd%flag(iff)<=lev_files(iff)) THEN
767       CALL histwrite_phy(nid_files(iff),o_ftd%name,itau_w,ftd)
768        ENDIF
769
770        IF (o_fqd%flag(iff)<=lev_files(iff)) THEN
771       CALL histwrite_phy(nid_files(iff),o_fqd%name,itau_w,fqd)
772        ENDIF
773      ENDIF !(iflag_con.EQ.3) 
774 
775      IF (type_ocean=='slab ') THEN
776      IF ( o_slab_bils%flag(iff)<=lev_files(iff)) 
777     $     CALL histwrite_phy(
778     $     nid_files(iff),o_slab_bils%name,itau_w,slab_wfbils)
779
780      ENDIF !type_ocean == force/slab
781
782      IF (o_weakinv%flag(iff)<=lev_files(iff)) THEN
783      CALL histwrite_phy(nid_files(iff),
784     s                  o_weakinv%name,itau_w,weak_inversion)
785      ENDIF
786
787      IF (o_dthmin%flag(iff)<=lev_files(iff)) THEN
788      CALL histwrite_phy(nid_files(iff),o_dthmin%name,itau_w,dthmin)
789      ENDIF
790
791       IF (o_cldtau%flag(iff)<=lev_files(iff)) THEN
792       CALL histwrite_phy(nid_files(iff),o_cldtau%name,itau_w,cldtau)
793       ENDIF
794
795       IF (o_cldemi%flag(iff)<=lev_files(iff)) THEN
796       CALL histwrite_phy(nid_files(iff),o_cldemi%name,itau_w,cldemi)
797       ENDIF
798
799      IF (o_pr_con_l%flag(iff)<=lev_files(iff)) THEN
800      CALL histwrite_phy(nid_files(iff),
801     s         o_pr_con_l%name,itau_w,pmflxr(:,1:klev))
802      ENDIF
803
804      IF (o_pr_con_i%flag(iff)<=lev_files(iff)) THEN
805      CALL histwrite_phy(nid_files(iff),
806     s         o_pr_con_i%name,itau_w,pmflxs(:,1:klev))
807      ENDIF
808
809      IF (o_pr_lsc_l%flag(iff)<=lev_files(iff)) THEN
810      CALL histwrite_phy(nid_files(iff),
811     s        o_pr_lsc_l%name,itau_w,prfl(:,1:klev))
812      ENDIF
813
814      IF (o_pr_lsc_i%flag(iff)<=lev_files(iff)) THEN
815      CALL histwrite_phy(nid_files(iff),
816     s        o_pr_lsc_i%name,itau_w,psfl(:,1:klev))
817      ENDIF
818
819      IF (o_re%flag(iff)<=lev_files(iff)) THEN
820      CALL histwrite_phy(nid_files(iff),o_re%name,itau_w,re)
821      ENDIF
822
823      IF (o_fl%flag(iff)<=lev_files(iff)) THEN
824      CALL histwrite_phy(nid_files(iff),o_fl%name,itau_w,fl)
825      ENDIF
826
827
828
829      IF (o_rh2m%flag(iff)<=lev_files(iff)) THEN
830      DO i=1, klon
831       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
832      ENDDO
833      CALL histwrite_phy(nid_files(iff),o_rh2m%name,itau_w,zx_tmp_fi2d)
834      ENDIF
835
836      IF (o_rh2m_min%flag(iff)<=lev_files(iff)) THEN
837      DO i=1, klon
838       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
839      ENDDO
840      CALL histwrite_phy(nid_files(iff),o_rh2m_min%name,
841     s               itau_w,zx_tmp_fi2d)
842      ENDIF
843
844      IF (o_rh2m_max%flag(iff)<=lev_files(iff)) THEN
845      DO i=1, klon
846       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
847      ENDDO
848      CALL histwrite_phy(nid_files(iff),o_rh2m_max%name,
849     s              itau_w,zx_tmp_fi2d)
850      ENDIF
851
852
853      IF (o_qsat2m%flag(iff)<=lev_files(iff)) THEN
854      CALL histwrite_phy(nid_files(iff),o_qsat2m%name,itau_w,qsat2m)
855      ENDIF
856
857      IF (o_tpot%flag(iff)<=lev_files(iff)) THEN
858      CALL histwrite_phy(nid_files(iff),o_tpot%name,itau_w,tpot)
859      ENDIF
860
861       IF (o_tpote%flag(iff)<=lev_files(iff)) THEN
862      CALL histwrite_phy(nid_files(iff),o_tpote%name,itau_w,tpote)
863       ENDIF
864
865      IF (o_SWnetOR%flag(iff)<=lev_files(iff)) THEN
866      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
867      CALL histwrite_phy(nid_files(iff),
868     s                   o_SWnetOR%name,itau_w, zx_tmp_fi2d)
869      ENDIF
870
871      IF (o_SWdownOR%flag(iff)<=lev_files(iff)) THEN
872      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
873      CALL histwrite_phy(nid_files(iff),
874     s                   o_SWdownOR%name,itau_w, zx_tmp_fi2d)
875      ENDIF
876
877      IF (o_LWdownOR%flag(iff)<=lev_files(iff)) THEN
878      CALL histwrite_phy(nid_files(iff),
879     s                  o_LWdownOR%name,itau_w,sollwdown)
880      ENDIF
881
882      IF (o_snowl%flag(iff)<=lev_files(iff)) THEN
883      CALL histwrite_phy(nid_files(iff),o_snowl%name,itau_w,snow_lsc)
884      ENDIF
885
886      IF (o_solldown%flag(iff)<=lev_files(iff)) THEN
887      CALL histwrite_phy(nid_files(iff),
888     s                   o_solldown%name,itau_w,sollwdown)
889      ENDIF
890
891      IF (o_dtsvdfo%flag(iff)<=lev_files(iff)) THEN
892      CALL histwrite_phy(nid_files(iff),
893     s                 o_dtsvdfo%name,itau_w,d_ts(:,is_oce))
894      ENDIF
895
896      IF (o_dtsvdft%flag(iff)<=lev_files(iff)) THEN
897      CALL histwrite_phy(nid_files(iff),
898     s                   o_dtsvdft%name,itau_w,d_ts(:,is_ter))
899      ENDIF
900
901       IF (o_dtsvdfg%flag(iff)<=lev_files(iff)) THEN
902        CALL histwrite_phy(nid_files(iff),
903     $                   o_dtsvdfg%name,itau_w, d_ts(:,is_lic))
904       ENDIF
905
906       IF (o_dtsvdfi%flag(iff)<=lev_files(iff)) THEN
907      CALL histwrite_phy(nid_files(iff),
908     s                   o_dtsvdfi%name,itau_w,d_ts(:,is_sic))
909       ENDIF
910
911       IF (o_rugs%flag(iff)<=lev_files(iff)) THEN
912      CALL histwrite_phy(nid_files(iff),o_rugs%name,itau_w,zxrugs)
913       ENDIF
914
915! OD550 per species
916      IF (new_aod .and. (.not. aerosol_couple)) THEN
917          IF (ok_ade.OR.ok_aie) THEN
918
919          IF (o_od550aer%flag(iff)<=lev_files(iff)) THEN
920             CALL histwrite_phy(nid_files(iff),o_od550aer%name,itau_w,
921     $            od550aer)
922          ENDIF
923          IF (o_od865aer%flag(iff)<=lev_files(iff)) THEN
924             CALL histwrite_phy(nid_files(iff),o_od865aer%name,itau_w,
925     $            od865aer)
926          ENDIF
927          IF (o_absvisaer%flag(iff)<=lev_files(iff)) THEN
928             CALL histwrite_phy(nid_files(iff),o_absvisaer%name,itau_w,
929     $            absvisaer)
930          ENDIF
931          IF (o_od550lt1aer%flag(iff)<=lev_files(iff)) THEN
932            CALL histwrite_phy(nid_files(iff),o_od550lt1aer%name,itau_w,
933     $            od550lt1aer)
934          ENDIF
935
936          IF (o_sconcso4%flag(iff)<=lev_files(iff)) THEN
937              CALL histwrite_phy(nid_files(iff),o_sconcso4%name,itau_w,
938     $            sconcso4)
939          ENDIF
940          IF (o_sconcoa%flag(iff)<=lev_files(iff)) THEN
941              CALL histwrite_phy(nid_files(iff),o_sconcoa%name,itau_w,
942     $            sconcoa)
943          ENDIF
944          IF (o_sconcbc%flag(iff)<=lev_files(iff)) THEN
945              CALL histwrite_phy(nid_files(iff),o_sconcbc%name,itau_w,
946     $            sconcbc)
947          ENDIF
948          IF (o_sconcss%flag(iff)<=lev_files(iff)) THEN
949              CALL histwrite_phy(nid_files(iff),o_sconcss%name,itau_w,
950     $            sconcss)
951          ENDIF
952          IF (o_sconcdust%flag(iff)<=lev_files(iff)) THEN
953              CALL histwrite_phy(nid_files(iff),o_sconcdust%name,itau_w,
954     $            sconcdust)
955          ENDIF
956         
957          IF (o_concso4%flag(iff)<=lev_files(iff)) THEN
958              CALL histwrite_phy(nid_files(iff),o_concso4%name,itau_w,
959     $            concso4)
960          ENDIF
961          IF (o_concoa%flag(iff)<=lev_files(iff)) THEN
962              CALL histwrite_phy(nid_files(iff),o_concoa%name,itau_w,
963     $            concoa)
964          ENDIF
965          IF (o_concbc%flag(iff)<=lev_files(iff)) THEN
966              CALL histwrite_phy(nid_files(iff),o_concbc%name,itau_w,
967     $            concbc)
968          ENDIF
969          IF (o_concss%flag(iff)<=lev_files(iff)) THEN
970              CALL histwrite_phy(nid_files(iff),o_concss%name,itau_w,
971     $            concss)
972          ENDIF
973          IF (o_concdust%flag(iff)<=lev_files(iff)) THEN
974              CALL histwrite_phy(nid_files(iff),o_concdust%name,itau_w,
975     $            concdust)
976          ENDIF
977         
978          IF (o_loadso4%flag(iff)<=lev_files(iff)) THEN
979              CALL histwrite_phy(nid_files(iff),o_loadso4%name,itau_w,
980     $            loadso4)
981          ENDIF
982          IF (o_loadoa%flag(iff)<=lev_files(iff)) THEN
983              CALL histwrite_phy(nid_files(iff),o_loadoa%name,itau_w,
984     $            loadoa)
985          ENDIF
986          IF (o_loadbc%flag(iff)<=lev_files(iff)) THEN
987              CALL histwrite_phy(nid_files(iff),o_loadbc%name,itau_w,
988     $            loadbc)
989          ENDIF
990          IF (o_loadss%flag(iff)<=lev_files(iff)) THEN
991              CALL histwrite_phy(nid_files(iff),o_loadss%name,itau_w,
992     $            loadss)
993          ENDIF
994          IF (o_loaddust%flag(iff)<=lev_files(iff)) THEN
995              CALL histwrite_phy(nid_files(iff),o_loaddust%name,itau_w,
996     $            loaddust)
997          ENDIF
998         
999          DO naero = 1, naero_spc
1000            IF (o_tausumaero(naero)%flag(iff)<=lev_files(iff)) THEN
1001                CALL histwrite_phy(nid_files(iff),
1002     $              o_tausumaero(naero)%name,itau_w,
1003     $              tausum_aero(:,2,naero) )
1004            ENDIF
1005          END DO
1006          endif
1007      ENDIF
1008     
1009       IF (ok_ade) THEN
1010          IF (o_topswad%flag(iff)<=lev_files(iff)) THEN
1011             CALL histwrite_phy(nid_files(iff),o_topswad%name,itau_w,
1012     $            topswad_aero)
1013          ENDIF
1014          IF (o_solswad%flag(iff)<=lev_files(iff)) THEN
1015             CALL histwrite_phy(nid_files(iff),o_solswad%name,itau_w,
1016     $            solswad_aero)
1017          ENDIF
1018
1019!====MS forcing diagnostics
1020        if (new_aod) then             
1021        IF (o_swtoaas_nat%flag(iff)<=lev_files(iff)) THEN
1022        CALL histwrite_phy(nid_files(iff),o_swtoaas_nat%name,itau_w,
1023     $      topsw_aero(:,1))
1024        ENDIF
1025
1026        IF (o_swsrfas_nat%flag(iff)<=lev_files(iff)) THEN
1027        CALL histwrite_phy(nid_files(iff),o_swsrfas_nat%name,itau_w,
1028     $      solsw_aero(:,1))
1029        ENDIF
1030
1031        IF (o_swtoacs_nat%flag(iff)<=lev_files(iff)) THEN
1032        CALL histwrite_phy(nid_files(iff),o_swtoacs_nat%name,itau_w,
1033     $      topsw0_aero(:,1))
1034        ENDIF
1035
1036        IF (o_swsrfcs_nat%flag(iff)<=lev_files(iff)) THEN
1037        CALL histwrite_phy(nid_files(iff),o_swsrfcs_nat%name,itau_w,
1038     $      solsw0_aero(:,1))
1039        ENDIF
1040 
1041!ant
1042        IF (o_swtoaas_ant%flag(iff)<=lev_files(iff)) THEN
1043        CALL histwrite_phy(nid_files(iff),o_swtoaas_ant%name,itau_w,
1044     $      topsw_aero(:,2))
1045        ENDIF
1046
1047        IF (o_swsrfas_ant%flag(iff)<=lev_files(iff)) THEN
1048        CALL histwrite_phy(nid_files(iff),o_swsrfas_ant%name,itau_w,
1049     $      solsw_aero(:,2))
1050        ENDIF
1051
1052        IF (o_swtoacs_ant%flag(iff)<=lev_files(iff)) THEN
1053        CALL histwrite_phy(nid_files(iff),o_swtoacs_ant%name,itau_w,
1054     $      topsw0_aero(:,2))
1055        ENDIF
1056
1057        IF (o_swsrfcs_ant%flag(iff)<=lev_files(iff)) THEN
1058        CALL histwrite_phy(nid_files(iff),o_swsrfcs_ant%name,itau_w,
1059     $      solsw0_aero(:,2))
1060        ENDIF
1061
1062!cf
1063
1064        if (.not. aerosol_couple) then
1065        IF (o_swtoacf_nat%flag(iff)<=lev_files(iff)) THEN
1066        CALL histwrite_phy(nid_files(iff),o_swtoacf_nat%name,itau_w,
1067     $      topswcf_aero(:,1))
1068        ENDIF
1069
1070        IF (o_swsrfcf_nat%flag(iff)<=lev_files(iff)) THEN
1071        CALL histwrite_phy(nid_files(iff),o_swsrfcf_nat%name,itau_w,
1072     $      solswcf_aero(:,1))
1073        ENDIF
1074
1075        IF (o_swtoacf_ant%flag(iff)<=lev_files(iff)) THEN
1076        CALL histwrite_phy(nid_files(iff),o_swtoacf_ant%name,itau_w,
1077     $      topswcf_aero(:,2))
1078        ENDIF
1079
1080        IF (o_swsrfcf_ant%flag(iff)<=lev_files(iff)) THEN
1081        CALL histwrite_phy(nid_files(iff),o_swsrfcf_ant%name,itau_w,
1082     $      solswcf_aero(:,2))
1083        ENDIF
1084
1085        IF (o_swtoacf_zero%flag(iff)<=lev_files(iff)) THEN
1086        CALL histwrite_phy(nid_files(iff),o_swtoacf_zero%name,itau_w,
1087     $      topswcf_aero(:,3))
1088        ENDIF
1089
1090        IF (o_swsrfcf_zero%flag(iff)<=lev_files(iff)) THEN
1091        CALL histwrite_phy(nid_files(iff),o_swsrfcf_zero%name,itau_w,
1092     $      solswcf_aero(:,3))
1093        ENDIF
1094        endif
1095
1096        endif ! new_aod
1097!====MS forcing diagnostics
1098
1099       ENDIF
1100
1101       IF (ok_aie) THEN
1102          IF (o_topswai%flag(iff)<=lev_files(iff)) THEN
1103             CALL histwrite_phy(nid_files(iff),o_topswai%name,itau_w,
1104     $            topswai_aero)
1105          ENDIF
1106          IF (o_solswai%flag(iff)<=lev_files(iff)) THEN
1107             CALL histwrite_phy(nid_files(iff),o_solswai%name,itau_w,
1108     $            solswai_aero)
1109          ENDIF
1110          IF (o_scdnc%flag(iff)<=lev_files(iff)) THEN
1111             CALL histwrite_phy(nid_files(iff),o_scdnc%name,itau_w,
1112     $            scdnc)
1113          ENDIF
1114          IF (o_cldncl%flag(iff)<=lev_files(iff)) THEN
1115             CALL histwrite_phy(nid_files(iff),o_cldncl%name,itau_w,
1116     $            cldncl)
1117          ENDIF
1118          IF (o_reffclws%flag(iff)<=lev_files(iff)) THEN
1119             CALL histwrite_phy(nid_files(iff),o_reffclws%name,itau_w,
1120     $            reffclws)
1121          ENDIF
1122          IF (o_reffclwc%flag(iff)<=lev_files(iff)) THEN
1123             CALL histwrite_phy(nid_files(iff),o_reffclwc%name,itau_w,
1124     $            reffclwc)
1125          ENDIF
1126          IF (o_cldnvi%flag(iff)<=lev_files(iff)) THEN
1127             CALL histwrite_phy(nid_files(iff),o_cldnvi%name,itau_w,
1128     $            cldnvi)
1129          ENDIF
1130          IF (o_lcc%flag(iff)<=lev_files(iff)) THEN
1131             CALL histwrite_phy(nid_files(iff),o_lcc%name,itau_w,
1132     $            lcc)
1133          ENDIF
1134          IF (o_lcc3d%flag(iff)<=lev_files(iff)) THEN
1135             CALL histwrite_phy(nid_files(iff),o_lcc3d%name,itau_w,
1136     $            lcc3d)
1137          ENDIF
1138          IF (o_lcc3dcon%flag(iff)<=lev_files(iff)) THEN
1139             CALL histwrite_phy(nid_files(iff),o_lcc3dcon%name,itau_w,
1140     $            lcc3dcon)
1141          ENDIF
1142          IF (o_lcc3dstra%flag(iff)<=lev_files(iff)) THEN
1143             CALL histwrite_phy(nid_files(iff),o_lcc3dstra%name,itau_w,
1144     $            lcc3dstra)
1145          ENDIF
1146          IF (o_reffclwtop%flag(iff)<=lev_files(iff)) THEN
1147             CALL histwrite_phy(nid_files(iff),o_reffclwtop%name,itau_w,
1148     $            reffclwtop)
1149          ENDIF
1150       ENDIF
1151
1152! Champs 3D:
1153       IF (ok_ade .OR. ok_aie) then
1154          IF (o_ec550aer%flag(iff)<=lev_files(iff)) THEN
1155             CALL histwrite_phy(nid_files(iff),o_ec550aer%name,itau_w,
1156     &            ec550aer)
1157          ENDIF
1158       ENDIF
1159
1160       IF (o_lwcon%flag(iff)<=lev_files(iff)) THEN
1161      CALL histwrite_phy(nid_files(iff),o_lwcon%name,itau_w,flwc)
1162       ENDIF
1163
1164       IF (o_iwcon%flag(iff)<=lev_files(iff)) THEN
1165      CALL histwrite_phy(nid_files(iff),o_iwcon%name,itau_w,fiwc)
1166       ENDIF
1167
1168       IF (o_temp%flag(iff)<=lev_files(iff)) THEN
1169      CALL histwrite_phy(nid_files(iff),o_temp%name,itau_w,t_seri)
1170       ENDIF
1171
1172       IF (o_theta%flag(iff)<=lev_files(iff)) THEN
1173      CALL histwrite_phy(nid_files(iff),o_theta%name,itau_w,theta)
1174       ENDIF
1175
1176       IF (o_ovapinit%flag(iff)<=lev_files(iff)) THEN
1177      CALL histwrite_phy(nid_files(iff),o_ovapinit%name,itau_w,
1178     $ qx(:,:,ivap))
1179       ENDIF
1180
1181       IF (o_ovap%flag(iff)<=lev_files(iff)) THEN
1182      CALL histwrite_phy(nid_files(iff),
1183     $                   o_ovap%name,itau_w,q_seri)
1184       ENDIF
1185
1186       IF (o_geop%flag(iff)<=lev_files(iff)) THEN
1187      CALL histwrite_phy(nid_files(iff),o_geop%name,itau_w,zphi)
1188       ENDIF
1189
1190       IF (o_vitu%flag(iff)<=lev_files(iff)) THEN
1191      CALL histwrite_phy(nid_files(iff),o_vitu%name,itau_w,u_seri)
1192       ENDIF
1193
1194       IF (o_vitv%flag(iff)<=lev_files(iff)) THEN
1195      CALL histwrite_phy(nid_files(iff),o_vitv%name,itau_w,v_seri)
1196       ENDIF
1197
1198       IF (o_vitw%flag(iff)<=lev_files(iff)) THEN
1199      CALL histwrite_phy(nid_files(iff),o_vitw%name,itau_w,omega)
1200       ENDIF
1201
1202        IF (o_pres%flag(iff)<=lev_files(iff)) THEN
1203      CALL histwrite_phy(nid_files(iff),o_pres%name,itau_w,pplay)
1204        ENDIF
1205
1206        IF (o_paprs%flag(iff)<=lev_files(iff)) THEN
1207      CALL histwrite_phy(nid_files(iff),o_paprs%name,
1208     s                    itau_w,paprs(:,1:klev))
1209        ENDIF
1210
1211       IF (o_rneb%flag(iff)<=lev_files(iff)) THEN
1212      CALL histwrite_phy(nid_files(iff),o_rneb%name,itau_w,cldfra)
1213       ENDIF
1214
1215       IF (o_rnebcon%flag(iff)<=lev_files(iff)) THEN
1216      CALL histwrite_phy(nid_files(iff),o_rnebcon%name,itau_w,rnebcon)
1217       ENDIF
1218
1219       IF (o_rhum%flag(iff)<=lev_files(iff)) THEN
1220      CALL histwrite_phy(nid_files(iff),o_rhum%name,itau_w,zx_rh)
1221       ENDIF
1222
1223      IF (o_ozone%flag(iff)<=lev_files(iff)) THEN
1224         CALL histwrite_phy(nid_files(iff), o_ozone%name, itau_w,
1225     $        wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1226      ENDIF
1227
1228      IF (o_ozone_light%flag(iff)<=lev_files(iff) .and.
1229     $     read_climoz == 2) THEN
1230         CALL histwrite_phy(nid_files(iff), o_ozone_light%name, itau_w,
1231     $        wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1232      ENDIF
1233
1234       IF (o_dtphy%flag(iff)<=lev_files(iff)) THEN
1235      CALL histwrite_phy(nid_files(iff),o_dtphy%name,itau_w,d_t)
1236       ENDIF
1237
1238       IF (o_dqphy%flag(iff)<=lev_files(iff)) THEN
1239      CALL histwrite_phy(nid_files(iff),
1240     s                  o_dqphy%name,itau_w, d_qx(:,:,ivap))
1241       ENDIF
1242
1243        DO nsrf=1, nbsrf
1244        IF (o_albe_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1245        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
1246        CALL histwrite_phy(nid_files(iff),
1247     s                    o_albe_srf(nsrf)%name,itau_w,
1248     $                     zx_tmp_fi2d)
1249        ENDIF
1250
1251        IF (o_rugs_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN 
1252        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
1253        CALL histwrite_phy(nid_files(iff),
1254     s                     o_rugs_srf(nsrf)%name,itau_w,
1255     $      zx_tmp_fi2d)
1256        ENDIF
1257
1258        IF (o_ages_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1259        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
1260        CALL histwrite_phy(nid_files(iff),
1261     s                     o_ages_srf(nsrf)%name,itau_w
1262     $    ,zx_tmp_fi2d)
1263        ENDIF
1264        ENDDO !nsrf=1, nbsrf
1265
1266       IF (o_alb1%flag(iff)<=lev_files(iff)) THEN
1267      CALL histwrite_phy(nid_files(iff),o_alb1%name,itau_w,albsol1)
1268       ENDIF
1269
1270       IF (o_alb2%flag(iff)<=lev_files(iff)) THEN
1271      CALL histwrite_phy(nid_files(iff),o_alb2%name,itau_w,albsol2)
1272       ENDIF
1273
1274!FH Sorties pour la couche limite
1275      if (iflag_pbl>1) then
1276      zx_tmp_fi3d=0.
1277      do nsrf=1,nbsrf
1278         do k=1,klev
1279          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k)
1280     $    +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
1281         enddo
1282      enddo
1283       IF (o_tke%flag(iff)<=lev_files(iff)) THEN
1284      CALL histwrite_phy(nid_files(iff),o_tke%name,itau_w,zx_tmp_fi3d)
1285       ENDIF
1286
1287       IF (o_tke_max%flag(iff)<=lev_files(iff)) THEN
1288      CALL histwrite_phy(nid_files(iff),
1289     s                   o_tke_max%name,itau_w,zx_tmp_fi3d)
1290       ENDIF
1291      endif
1292
1293       IF (o_kz%flag(iff)<=lev_files(iff)) THEN
1294      CALL histwrite_phy(nid_files(iff),o_kz%name,itau_w,coefh)
1295       ENDIF
1296
1297       IF (o_kz_max%flag(iff)<=lev_files(iff)) THEN
1298      CALL histwrite_phy(nid_files(iff),o_kz_max%name,itau_w,coefh)
1299       ENDIF
1300
1301       IF (o_clwcon%flag(iff)<=lev_files(iff)) THEN
1302      CALL histwrite_phy(nid_files(iff),o_clwcon%name,itau_w,clwcon0)
1303       ENDIF
1304
1305       IF (o_dtdyn%flag(iff)<=lev_files(iff)) THEN
1306      CALL histwrite_phy(nid_files(iff),o_dtdyn%name,itau_w,d_t_dyn)
1307       ENDIF
1308
1309       IF (o_dqdyn%flag(iff)<=lev_files(iff)) THEN
1310      CALL histwrite_phy(nid_files(iff),o_dqdyn%name,itau_w,d_q_dyn)
1311       ENDIF
1312
1313       IF (o_dudyn%flag(iff)<=lev_files(iff)) THEN
1314      CALL histwrite_phy(nid_files(iff),o_dudyn%name,itau_w,d_u_dyn)
1315       ENDIF                                                   
1316
1317       IF (o_dvdyn%flag(iff)<=lev_files(iff)) THEN                 
1318      CALL histwrite_phy(nid_files(iff),o_dvdyn%name,itau_w,d_v_dyn) 
1319       ENDIF                                                     
1320
1321       IF (o_dtcon%flag(iff)<=lev_files(iff)) THEN
1322      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
1323      CALL histwrite_phy(nid_files(iff),o_dtcon%name,itau_w,zx_tmp_fi3d)
1324       ENDIF
1325
1326       IF (o_ducon%flag(iff)<=lev_files(iff)) THEN
1327      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
1328      CALL histwrite_phy(nid_files(iff),o_ducon%name,itau_w,zx_tmp_fi3d)
1329       ENDIF
1330
1331       IF (o_dqcon%flag(iff)<=lev_files(iff)) THEN
1332      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1333      CALL histwrite_phy(nid_files(iff),o_dqcon%name,itau_w,zx_tmp_fi3d)
1334       ENDIF
1335
1336       IF (o_dtlsc%flag(iff)<=lev_files(iff)) THEN
1337      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
1338      CALL histwrite_phy(nid_files(iff),o_dtlsc%name,itau_w,zx_tmp_fi3d)
1339       ENDIF
1340
1341       IF (o_dtlschr%flag(iff)<=lev_files(iff)) THEN
1342      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
1343     $                           d_t_eva(1:klon,1:klev))/pdtphys
1344      CALL histwrite_phy(nid_files(iff),
1345     s                   o_dtlschr%name,itau_w,zx_tmp_fi3d)
1346       ENDIF
1347
1348       IF (o_dqlsc%flag(iff)<=lev_files(iff)) THEN
1349      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
1350      CALL histwrite_phy(nid_files(iff),o_dqlsc%name,itau_w,zx_tmp_fi3d)
1351       ENDIF
1352
1353       IF (o_dtvdf%flag(iff)<=lev_files(iff)) THEN
1354      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
1355      CALL histwrite_phy(nid_files(iff),o_dtvdf%name,itau_w,zx_tmp_fi3d)
1356       ENDIF
1357
1358       IF (o_dqvdf%flag(iff)<=lev_files(iff)) THEN
1359      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1360      CALL histwrite_phy(nid_files(iff),o_dqvdf%name,itau_w,zx_tmp_fi3d)
1361       ENDIF
1362
1363       IF (o_dteva%flag(iff)<=lev_files(iff)) THEN
1364      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1365      CALL histwrite_phy(nid_files(iff),o_dteva%name,itau_w,zx_tmp_fi3d)
1366       ENDIF
1367
1368       IF (o_dqeva%flag(iff)<=lev_files(iff)) THEN
1369      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1370      CALL histwrite_phy(nid_files(iff),o_dqeva%name,itau_w,zx_tmp_fi3d)
1371       ENDIF
1372
1373       IF (o_ptconv%flag(iff)<=lev_files(iff)) THEN
1374      zpt_conv = 0.
1375      where (ptconv) zpt_conv = 1.
1376      CALL histwrite_phy(nid_files(iff),o_ptconv%name,itau_w,zpt_conv)
1377       ENDIF
1378
1379       IF (o_ratqs%flag(iff)<=lev_files(iff)) THEN
1380      CALL histwrite_phy(nid_files(iff),o_ratqs%name,itau_w,ratqs)
1381       ENDIF
1382
1383       IF (o_dtthe%flag(iff)<=lev_files(iff)) THEN
1384      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys
1385      CALL histwrite_phy(nid_files(iff),o_dtthe%name,itau_w,zx_tmp_fi3d)
1386       ENDIF
1387
1388       IF (iflag_thermals.gt.1) THEN
1389        IF (o_ftime_th%flag(iff)<=lev_files(iff)) THEN
1390! Pour l instant 0 a y reflichir pour les thermiques
1391         zx_tmp_fi2d=0. 
1392        CALL histwrite_phy(nid_files(iff),o_ftime_th%name,
1393     s                     itau_w,zx_tmp_fi2d)
1394        ENDIF
1395
1396        IF (o_f_th%flag(iff)<=lev_files(iff)) THEN
1397        CALL histwrite_phy(nid_files(iff),o_f_th%name,itau_w,fm_therm)
1398        ENDIF
1399
1400        IF (o_e_th%flag(iff)<=lev_files(iff)) THEN
1401        CALL histwrite_phy(nid_files(iff),o_e_th%name,itau_w,entr_therm)
1402        ENDIF
1403
1404        IF (o_w_th%flag(iff)<=lev_files(iff)) THEN
1405        CALL histwrite_phy(nid_files(iff),o_w_th%name,itau_w,zw2)
1406        ENDIF
1407
1408        IF (o_q_th%flag(iff)<=lev_files(iff)) THEN
1409        CALL histwrite_phy(nid_files(iff),o_q_th%name,itau_w,zqasc)
1410        ENDIF
1411
1412        IF (o_lambda_th%flag(iff)<=lev_files(iff)) THEN
1413        CALL histwrite_phy(nid_files(iff),
1414     s                     o_lambda_th%name,itau_w,lambda_th)
1415        ENDIF
1416
1417        IF (o_a_th%flag(iff)<=lev_files(iff)) THEN
1418        CALL histwrite_phy(nid_files(iff),o_a_th%name,itau_w,fraca)
1419        ENDIF
1420
1421       IF (o_d_th%flag(iff)<=lev_files(iff)) THEN
1422       CALL histwrite_phy(nid_files(iff),o_d_th%name,itau_w,detr_therm)
1423       ENDIF
1424
1425
1426       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1427      CALL histwrite_phy(nid_files(iff),o_f0_th%name,itau_w,f0)
1428       ENDIF
1429
1430       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1431      CALL histwrite_phy(nid_files(iff),o_zmax_th%name,itau_w,zmax0)
1432       ENDIF
1433
1434       IF (o_dqthe%flag(iff)<=lev_files(iff)) THEN
1435      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
1436      CALL histwrite_phy(nid_files(iff),o_dqthe%name,itau_w,zx_tmp_fi3d)
1437       ENDIF
1438
1439      ENDIF !iflag_thermals
1440
1441       IF (o_dtajs%flag(iff)<=lev_files(iff)) THEN
1442      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
1443      CALL histwrite_phy(nid_files(iff),o_dtajs%name,itau_w,zx_tmp_fi3d)
1444       ENDIF
1445
1446       IF (o_dqajs%flag(iff)<=lev_files(iff)) THEN
1447      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
1448      CALL histwrite_phy(nid_files(iff),o_dqajs%name,itau_w,zx_tmp_fi3d)
1449       ENDIF
1450
1451       IF (o_dtswr%flag(iff)<=lev_files(iff)) THEN
1452      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
1453      CALL histwrite_phy(nid_files(iff),o_dtswr%name,itau_w,zx_tmp_fi3d)
1454       ENDIF
1455
1456       IF (o_dtsw0%flag(iff)<=lev_files(iff)) THEN
1457      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
1458      CALL histwrite_phy(nid_files(iff),o_dtsw0%name,itau_w,zx_tmp_fi3d)
1459       ENDIF
1460
1461       IF (o_dtlwr%flag(iff)<=lev_files(iff)) THEN
1462      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
1463      CALL histwrite_phy(nid_files(iff),o_dtlwr%name,itau_w,zx_tmp_fi3d)
1464       ENDIF
1465
1466       IF (o_dtlw0%flag(iff)<=lev_files(iff)) THEN
1467      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
1468      CALL histwrite_phy(nid_files(iff),o_dtlw0%name,itau_w,zx_tmp_fi3d)
1469       ENDIF
1470
1471       IF (o_dtec%flag(iff)<=lev_files(iff)) THEN
1472      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
1473      CALL histwrite_phy(nid_files(iff),o_dtec%name,itau_w,zx_tmp_fi3d)
1474       ENDIF
1475
1476       IF (o_duvdf%flag(iff)<=lev_files(iff)) THEN
1477      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
1478      CALL histwrite_phy(nid_files(iff),o_duvdf%name,itau_w,zx_tmp_fi3d)
1479       ENDIF
1480
1481       IF (o_dvvdf%flag(iff)<=lev_files(iff)) THEN
1482      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
1483      CALL histwrite_phy(nid_files(iff),o_dvvdf%name,itau_w,zx_tmp_fi3d)
1484       ENDIF
1485
1486       IF (ok_orodr) THEN
1487      IF (o_duoro%flag(iff)<=lev_files(iff)) THEN
1488      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
1489      CALL histwrite_phy(nid_files(iff),o_duoro%name,itau_w,zx_tmp_fi3d)
1490       ENDIF
1491
1492      IF (o_dvoro%flag(iff)<=lev_files(iff)) THEN
1493      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
1494      CALL histwrite_phy(nid_files(iff),o_dvoro%name,itau_w,zx_tmp_fi3d)
1495      ENDIF
1496       ENDIF
1497
1498        IF (ok_orolf) THEN
1499       IF (o_dulif%flag(iff)<=lev_files(iff)) THEN
1500      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
1501      CALL histwrite_phy(nid_files(iff),o_dulif%name,itau_w,zx_tmp_fi3d)
1502       ENDIF
1503
1504        IF (o_dvlif%flag(iff)<=lev_files(iff)) THEN
1505      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
1506      CALL histwrite_phy(nid_files(iff),o_dvlif%name,itau_w,zx_tmp_fi3d)
1507       ENDIF
1508        ENDIF
1509
1510        if (nqtot.GE.3) THEN
1511         DO iq=3,nqtot
1512       IF (o_trac(iq-2)%flag(iff)<=lev_files(iff)) THEN
1513         CALL histwrite_phy(nid_files(iff),
1514     s                  o_trac(iq-2)%name,itau_w,qx(:,:,iq))
1515       ENDIF
1516         ENDDO
1517        endif
1518
1519      if (ok_sync) then
1520c$OMP MASTER
1521        call histsync(nid_files(iff))
1522c$OMP END MASTER
1523      endif
1524
1525       ENDIF ! clef_files
1526
1527      ENDDO ! iff=1,nfiles
Note: See TracBrowser for help on using the repository browser.