source: LMDZ4/branches/LMDZ4V5.0-dev/libf/phylmd/phys_output_write.h @ 1366

Last change on this file since 1366 was 1366, checked in by Ehouarn Millour, 15 years ago

Bug fix: line introduced in previous revision was too long (for fixed format).

EM

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 52.0 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,pbase)
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_capCL%flag(iff)<=lev_files(iff)) THEN
602      CALL histwrite_phy(nid_files(iff),o_s_capCL%name,itau_w,s_capCL)
603        ENDIF
604
605        IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
606      CALL histwrite_phy(nid_files(iff),o_s_oliqCL%name,itau_w,s_oliqCL)
607        ENDIF
608
609        IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
610      CALL histwrite_phy(nid_files(iff),o_s_cteiCL%name,itau_w,s_cteiCL)
611        ENDIF
612
613        IF (o_s_therm%flag(iff)<=lev_files(iff)) THEN
614      CALL histwrite_phy(nid_files(iff),o_s_therm%name,itau_w,s_therm)
615        ENDIF
616
617        IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
618      CALL histwrite_phy(nid_files(iff),o_s_trmb1%name,itau_w,s_trmb1)
619        ENDIF
620
621        IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
622      CALL histwrite_phy(nid_files(iff),o_s_trmb2%name,itau_w,s_trmb2)
623        ENDIF
624
625        IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
626      CALL histwrite_phy(nid_files(iff),o_s_trmb3%name,itau_w,s_trmb3)
627        ENDIF
628
629! Champs interpolles sur des niveaux de pression
630
631        ll=0
632        DO k=1, nlevSTD
633!         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
634!         IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
635         bb2=clevSTD(k) 
636         IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
637     $      bb2.EQ."500".OR.bb2.EQ."200".OR.
638     $      bb2.EQ."50".OR.bb2.EQ."10") THEN
639
640! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
641          ll=ll+1
642       IF (o_uSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
643       CALL histwrite_phy(nid_files(iff),o_uSTDlevs(ll)%name,
644     &                    itau_w,uwriteSTD(:,k,iff))
645       ENDIF
646
647       IF (o_vSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
648      CALL histwrite_phy(nid_files(iff),o_vSTDlevs(ll)%name, 
649     &                   itau_w,vwriteSTD(:,k,iff))
650       ENDIF
651
652       IF (o_wSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
653      CALL histwrite_phy(nid_files(iff),o_wSTDlevs(ll)%name,
654     &                    itau_w,wwriteSTD(:,k,iff))
655       ENDIF
656
657       IF (o_phiSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
658      CALL histwrite_phy(nid_files(iff),o_phiSTDlevs(ll)%name,
659     &               itau_w,phiwriteSTD(:,k,iff))
660       ENDIF
661
662       IF (o_qSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
663      CALL histwrite_phy(nid_files(iff),o_qSTDlevs(ll)%name,
664     &                   itau_w, qwriteSTD(:,k,iff))
665       ENDIF
666
667       IF (o_tSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
668      CALL histwrite_phy(nid_files(iff),o_tSTDlevs(ll)%name,
669     &                   itau_w, twriteSTD(:,k,iff))
670       ENDIF
671
672       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
673       ENDDO
674
675      IF (o_t_oce_sic%flag(iff)<=lev_files(iff)) THEN
676      DO i=1, klon
677       IF (pctsrf(i,is_oce).GT.epsfra.OR.
678     $     pctsrf(i,is_sic).GT.epsfra) THEN
679        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+
680     $                   ftsol(i, is_sic) * pctsrf(i,is_sic))/
681     $                   (pctsrf(i,is_oce)+pctsrf(i,is_sic))
682       ELSE
683        zx_tmp_fi2d(i) = 273.15
684       ENDIF
685      ENDDO
686      CALL histwrite_phy(nid_files(iff),
687     s                   o_t_oce_sic%name,itau_w,zx_tmp_fi2d)
688      ENDIF
689
690! Couplage convection-couche limite
691      IF (iflag_con.GE.3) THEN
692      IF (iflag_coupl.EQ.1) THEN
693       IF (o_ale_bl%flag(iff)<=lev_files(iff)) THEN
694       CALL histwrite_phy(nid_files(iff),o_ale_bl%name,itau_w,ale_bl)
695       ENDIF
696       IF (o_alp_bl%flag(iff)<=lev_files(iff)) THEN
697       CALL histwrite_phy(nid_files(iff),o_alp_bl%name,itau_w,alp_bl)
698       ENDIF
699      ENDIF !iflag_coupl.EQ.1
700      ENDIF !(iflag_con.GE.3)
701
702! Wakes
703      IF (iflag_con.EQ.3) THEN
704      IF (iflag_wake.EQ.1) THEN
705       IF (o_ale_wk%flag(iff)<=lev_files(iff)) THEN
706       CALL histwrite_phy(nid_files(iff),o_ale_wk%name,itau_w,ale_wake)
707       ENDIF
708       IF (o_alp_wk%flag(iff)<=lev_files(iff)) THEN
709       CALL histwrite_phy(nid_files(iff),o_alp_wk%name,itau_w,alp_wake)
710       ENDIF
711
712       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
713       CALL histwrite_phy(nid_files(iff),o_ale%name,itau_w,ale)
714       ENDIF
715       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
716       CALL histwrite_phy(nid_files(iff),o_alp%name,itau_w,alp)
717       ENDIF
718       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
719       CALL histwrite_phy(nid_files(iff),o_cin%name,itau_w,cin)
720       ENDIF
721       IF (o_wape%flag(iff)<=lev_files(iff)) THEN
722       CALL histwrite_phy(nid_files(iff),o_WAPE%name,itau_w,wake_pe)
723       ENDIF
724       IF (o_wake_h%flag(iff)<=lev_files(iff)) THEN
725      CALL histwrite_phy(nid_files(iff),o_wake_h%name,itau_w,wake_h)
726       ENDIF
727
728       IF (o_wake_s%flag(iff)<=lev_files(iff)) THEN
729      CALL histwrite_phy(nid_files(iff),o_wake_s%name,itau_w,wake_s)
730       ENDIF
731
732        IF (o_wake_deltat%flag(iff)<=lev_files(iff)) THEN
733       CALL histwrite_phy(nid_files(iff),o_wake_deltat%name,
734     $                     itau_w,wake_deltat)
735        ENDIF
736
737        IF (o_wake_deltaq%flag(iff)<=lev_files(iff)) THEN
738       CALL histwrite_phy(nid_files(iff),o_wake_deltaq%name,
739     $                    itau_w,wake_deltaq)
740        ENDIF
741
742        IF (o_wake_omg%flag(iff)<=lev_files(iff)) THEN
743       CALL histwrite_phy(nid_files(iff),
744     s                    o_wake_omg%name,itau_w,wake_omg)
745        ENDIF
746
747         IF (o_dtwak%flag(iff)<=lev_files(iff)) THEN
748           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)
749     &                                        /pdtphys
750           CALL histwrite_phy(nid_files(iff),
751     &                       o_dtwak%name,itau_w,zx_tmp_fi3d)
752         ENDIF
753
754        IF (o_dqwak%flag(iff)<=lev_files(iff)) THEN
755        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
756        CALL histwrite_phy(nid_files(iff),
757     &                     o_dqwak%name,itau_w,zx_tmp_fi3d)
758        ENDIF
759      ENDIF ! iflag_wake.EQ.1
760
761        IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
762       CALL histwrite_phy(nid_files(iff),o_Vprecip%name,itau_w,Vprecip)
763        ENDIF
764
765        IF (o_ftd%flag(iff)<=lev_files(iff)) THEN
766       CALL histwrite_phy(nid_files(iff),o_ftd%name,itau_w,ftd)
767        ENDIF
768
769        IF (o_fqd%flag(iff)<=lev_files(iff)) THEN
770       CALL histwrite_phy(nid_files(iff),o_fqd%name,itau_w,fqd)
771        ENDIF
772      ENDIF !(iflag_con.EQ.3) 
773 
774      IF (type_ocean=='slab ') THEN
775      IF ( o_slab_bils%flag(iff)<=lev_files(iff)) 
776     $     CALL histwrite_phy(
777     $     nid_files(iff),o_slab_bils%name,itau_w,slab_wfbils)
778
779      ENDIF !type_ocean == force/slab
780
781      IF (o_weakinv%flag(iff)<=lev_files(iff)) THEN
782      CALL histwrite_phy(nid_files(iff),
783     s                  o_weakinv%name,itau_w,weak_inversion)
784      ENDIF
785
786      IF (o_dthmin%flag(iff)<=lev_files(iff)) THEN
787      CALL histwrite_phy(nid_files(iff),o_dthmin%name,itau_w,dthmin)
788      ENDIF
789
790       IF (o_cldtau%flag(iff)<=lev_files(iff)) THEN
791       CALL histwrite_phy(nid_files(iff),o_cldtau%name,itau_w,cldtau)
792       ENDIF
793
794       IF (o_cldemi%flag(iff)<=lev_files(iff)) THEN
795       CALL histwrite_phy(nid_files(iff),o_cldemi%name,itau_w,cldemi)
796       ENDIF
797
798      IF (o_pr_con_l%flag(iff)<=lev_files(iff)) THEN
799      CALL histwrite_phy(nid_files(iff),
800     s         o_pr_con_l%name,itau_w,pmflxr(:,1:klev))
801      ENDIF
802
803      IF (o_pr_con_i%flag(iff)<=lev_files(iff)) THEN
804      CALL histwrite_phy(nid_files(iff),
805     s         o_pr_con_i%name,itau_w,pmflxs(:,1:klev))
806      ENDIF
807
808      IF (o_pr_lsc_l%flag(iff)<=lev_files(iff)) THEN
809      CALL histwrite_phy(nid_files(iff),
810     s        o_pr_lsc_l%name,itau_w,prfl(:,1:klev))
811      ENDIF
812
813      IF (o_pr_lsc_i%flag(iff)<=lev_files(iff)) THEN
814      CALL histwrite_phy(nid_files(iff),
815     s        o_pr_lsc_i%name,itau_w,psfl(:,1:klev))
816      ENDIF
817
818      IF (o_re%flag(iff)<=lev_files(iff)) THEN
819      CALL histwrite_phy(nid_files(iff),o_re%name,itau_w,re)
820      ENDIF
821
822      IF (o_fl%flag(iff)<=lev_files(iff)) THEN
823      CALL histwrite_phy(nid_files(iff),o_fl%name,itau_w,fl)
824      ENDIF
825
826
827
828      IF (o_rh2m%flag(iff)<=lev_files(iff)) THEN
829      DO i=1, klon
830       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
831      ENDDO
832      CALL histwrite_phy(nid_files(iff),o_rh2m%name,itau_w,zx_tmp_fi2d)
833      ENDIF
834
835      IF (o_rh2m_min%flag(iff)<=lev_files(iff)) THEN
836      DO i=1, klon
837       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
838      ENDDO
839      CALL histwrite_phy(nid_files(iff),o_rh2m_min%name,
840     s               itau_w,zx_tmp_fi2d)
841      ENDIF
842
843      IF (o_rh2m_max%flag(iff)<=lev_files(iff)) THEN
844      DO i=1, klon
845       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
846      ENDDO
847      CALL histwrite_phy(nid_files(iff),o_rh2m_max%name,
848     s              itau_w,zx_tmp_fi2d)
849      ENDIF
850
851
852      IF (o_qsat2m%flag(iff)<=lev_files(iff)) THEN
853      CALL histwrite_phy(nid_files(iff),o_qsat2m%name,itau_w,qsat2m)
854      ENDIF
855
856      IF (o_tpot%flag(iff)<=lev_files(iff)) THEN
857      CALL histwrite_phy(nid_files(iff),o_tpot%name,itau_w,tpot)
858      ENDIF
859
860       IF (o_tpote%flag(iff)<=lev_files(iff)) THEN
861      CALL histwrite_phy(nid_files(iff),o_tpote%name,itau_w,tpote)
862       ENDIF
863
864      IF (o_SWnetOR%flag(iff)<=lev_files(iff)) THEN
865      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
866      CALL histwrite_phy(nid_files(iff),
867     s                   o_SWnetOR%name,itau_w, zx_tmp_fi2d)
868      ENDIF
869
870      IF (o_SWdownOR%flag(iff)<=lev_files(iff)) THEN
871      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
872      CALL histwrite_phy(nid_files(iff),
873     s                   o_SWdownOR%name,itau_w, zx_tmp_fi2d)
874      ENDIF
875
876      IF (o_LWdownOR%flag(iff)<=lev_files(iff)) THEN
877      CALL histwrite_phy(nid_files(iff),
878     s                  o_LWdownOR%name,itau_w,sollwdown)
879      ENDIF
880
881      IF (o_snowl%flag(iff)<=lev_files(iff)) THEN
882      CALL histwrite_phy(nid_files(iff),o_snowl%name,itau_w,snow_lsc)
883      ENDIF
884
885      IF (o_solldown%flag(iff)<=lev_files(iff)) THEN
886      CALL histwrite_phy(nid_files(iff),
887     s                   o_solldown%name,itau_w,sollwdown)
888      ENDIF
889
890      IF (o_dtsvdfo%flag(iff)<=lev_files(iff)) THEN
891      CALL histwrite_phy(nid_files(iff),
892     s                 o_dtsvdfo%name,itau_w,d_ts(:,is_oce))
893      ENDIF
894
895      IF (o_dtsvdft%flag(iff)<=lev_files(iff)) THEN
896      CALL histwrite_phy(nid_files(iff),
897     s                   o_dtsvdft%name,itau_w,d_ts(:,is_ter))
898      ENDIF
899
900       IF (o_dtsvdfg%flag(iff)<=lev_files(iff)) THEN
901        CALL histwrite_phy(nid_files(iff),
902     $                   o_dtsvdfg%name,itau_w, d_ts(:,is_lic))
903       ENDIF
904
905       IF (o_dtsvdfi%flag(iff)<=lev_files(iff)) THEN
906      CALL histwrite_phy(nid_files(iff),
907     s                   o_dtsvdfi%name,itau_w,d_ts(:,is_sic))
908       ENDIF
909
910       IF (o_rugs%flag(iff)<=lev_files(iff)) THEN
911      CALL histwrite_phy(nid_files(iff),o_rugs%name,itau_w,zxrugs)
912       ENDIF
913
914! OD550 per species
915      IF (new_aod .and. (.not. aerosol_couple)) THEN
916          IF (ok_ade.OR.ok_aie) THEN
917
918          IF (o_od550aer%flag(iff)<=lev_files(iff)) THEN
919             CALL histwrite_phy(nid_files(iff),o_od550aer%name,itau_w,
920     $            od550aer)
921          ENDIF
922          IF (o_od865aer%flag(iff)<=lev_files(iff)) THEN
923             CALL histwrite_phy(nid_files(iff),o_od865aer%name,itau_w,
924     $            od865aer)
925          ENDIF
926          IF (o_absvisaer%flag(iff)<=lev_files(iff)) THEN
927             CALL histwrite_phy(nid_files(iff),o_absvisaer%name,itau_w,
928     $            absvisaer)
929          ENDIF
930          IF (o_od550lt1aer%flag(iff)<=lev_files(iff)) THEN
931            CALL histwrite_phy(nid_files(iff),o_od550lt1aer%name,itau_w,
932     $            od550lt1aer)
933          ENDIF
934
935          IF (o_sconcso4%flag(iff)<=lev_files(iff)) THEN
936              CALL histwrite_phy(nid_files(iff),o_sconcso4%name,itau_w,
937     $            sconcso4)
938          ENDIF
939          IF (o_sconcoa%flag(iff)<=lev_files(iff)) THEN
940              CALL histwrite_phy(nid_files(iff),o_sconcoa%name,itau_w,
941     $            sconcoa)
942          ENDIF
943          IF (o_sconcbc%flag(iff)<=lev_files(iff)) THEN
944              CALL histwrite_phy(nid_files(iff),o_sconcbc%name,itau_w,
945     $            sconcbc)
946          ENDIF
947          IF (o_sconcss%flag(iff)<=lev_files(iff)) THEN
948              CALL histwrite_phy(nid_files(iff),o_sconcss%name,itau_w,
949     $            sconcss)
950          ENDIF
951          IF (o_sconcdust%flag(iff)<=lev_files(iff)) THEN
952              CALL histwrite_phy(nid_files(iff),o_sconcdust%name,itau_w,
953     $            sconcdust)
954          ENDIF
955         
956          IF (o_concso4%flag(iff)<=lev_files(iff)) THEN
957              CALL histwrite_phy(nid_files(iff),o_concso4%name,itau_w,
958     $            concso4)
959          ENDIF
960          IF (o_concoa%flag(iff)<=lev_files(iff)) THEN
961              CALL histwrite_phy(nid_files(iff),o_concoa%name,itau_w,
962     $            concoa)
963          ENDIF
964          IF (o_concbc%flag(iff)<=lev_files(iff)) THEN
965              CALL histwrite_phy(nid_files(iff),o_concbc%name,itau_w,
966     $            concbc)
967          ENDIF
968          IF (o_concss%flag(iff)<=lev_files(iff)) THEN
969              CALL histwrite_phy(nid_files(iff),o_concss%name,itau_w,
970     $            concss)
971          ENDIF
972          IF (o_concdust%flag(iff)<=lev_files(iff)) THEN
973              CALL histwrite_phy(nid_files(iff),o_concdust%name,itau_w,
974     $            concdust)
975          ENDIF
976         
977          IF (o_loadso4%flag(iff)<=lev_files(iff)) THEN
978              CALL histwrite_phy(nid_files(iff),o_loadso4%name,itau_w,
979     $            loadso4)
980          ENDIF
981          IF (o_loadoa%flag(iff)<=lev_files(iff)) THEN
982              CALL histwrite_phy(nid_files(iff),o_loadoa%name,itau_w,
983     $            loadoa)
984          ENDIF
985          IF (o_loadbc%flag(iff)<=lev_files(iff)) THEN
986              CALL histwrite_phy(nid_files(iff),o_loadbc%name,itau_w,
987     $            loadbc)
988          ENDIF
989          IF (o_loadss%flag(iff)<=lev_files(iff)) THEN
990              CALL histwrite_phy(nid_files(iff),o_loadss%name,itau_w,
991     $            loadss)
992          ENDIF
993          IF (o_loaddust%flag(iff)<=lev_files(iff)) THEN
994              CALL histwrite_phy(nid_files(iff),o_loaddust%name,itau_w,
995     $            loaddust)
996          ENDIF
997         
998          DO naero = 1, naero_spc
999            IF (o_tausumaero(naero)%flag(iff)<=lev_files(iff)) THEN
1000                CALL histwrite_phy(nid_files(iff),
1001     $              o_tausumaero(naero)%name,itau_w,
1002     $              tausum_aero(:,2,naero) )
1003            ENDIF
1004          END DO
1005          endif
1006      ENDIF
1007     
1008       IF (ok_ade) THEN
1009          IF (o_topswad%flag(iff)<=lev_files(iff)) THEN
1010             CALL histwrite_phy(nid_files(iff),o_topswad%name,itau_w,
1011     $            topswad_aero)
1012          ENDIF
1013          IF (o_solswad%flag(iff)<=lev_files(iff)) THEN
1014             CALL histwrite_phy(nid_files(iff),o_solswad%name,itau_w,
1015     $            solswad_aero)
1016          ENDIF
1017
1018!====MS forcing diagnostics
1019        if (new_aod) then             
1020        IF (o_swtoaas_nat%flag(iff)<=lev_files(iff)) THEN
1021        CALL histwrite_phy(nid_files(iff),o_swtoaas_nat%name,itau_w,
1022     $      topsw_aero(:,1))
1023        ENDIF
1024
1025        IF (o_swsrfas_nat%flag(iff)<=lev_files(iff)) THEN
1026        CALL histwrite_phy(nid_files(iff),o_swsrfas_nat%name,itau_w,
1027     $      solsw_aero(:,1))
1028        ENDIF
1029
1030        IF (o_swtoacs_nat%flag(iff)<=lev_files(iff)) THEN
1031        CALL histwrite_phy(nid_files(iff),o_swtoacs_nat%name,itau_w,
1032     $      topsw0_aero(:,1))
1033        ENDIF
1034
1035        IF (o_swsrfcs_nat%flag(iff)<=lev_files(iff)) THEN
1036        CALL histwrite_phy(nid_files(iff),o_swsrfcs_nat%name,itau_w,
1037     $      solsw0_aero(:,1))
1038        ENDIF
1039 
1040!ant
1041        IF (o_swtoaas_ant%flag(iff)<=lev_files(iff)) THEN
1042        CALL histwrite_phy(nid_files(iff),o_swtoaas_ant%name,itau_w,
1043     $      topsw_aero(:,2))
1044        ENDIF
1045
1046        IF (o_swsrfas_ant%flag(iff)<=lev_files(iff)) THEN
1047        CALL histwrite_phy(nid_files(iff),o_swsrfas_ant%name,itau_w,
1048     $      solsw_aero(:,2))
1049        ENDIF
1050
1051        IF (o_swtoacs_ant%flag(iff)<=lev_files(iff)) THEN
1052        CALL histwrite_phy(nid_files(iff),o_swtoacs_ant%name,itau_w,
1053     $      topsw0_aero(:,2))
1054        ENDIF
1055
1056        IF (o_swsrfcs_ant%flag(iff)<=lev_files(iff)) THEN
1057        CALL histwrite_phy(nid_files(iff),o_swsrfcs_ant%name,itau_w,
1058     $      solsw0_aero(:,2))
1059        ENDIF
1060
1061!cf
1062
1063        if (.not. aerosol_couple) then
1064        IF (o_swtoacf_nat%flag(iff)<=lev_files(iff)) THEN
1065        CALL histwrite_phy(nid_files(iff),o_swtoacf_nat%name,itau_w,
1066     $      topswcf_aero(:,1))
1067        ENDIF
1068
1069        IF (o_swsrfcf_nat%flag(iff)<=lev_files(iff)) THEN
1070        CALL histwrite_phy(nid_files(iff),o_swsrfcf_nat%name,itau_w,
1071     $      solswcf_aero(:,1))
1072        ENDIF
1073
1074        IF (o_swtoacf_ant%flag(iff)<=lev_files(iff)) THEN
1075        CALL histwrite_phy(nid_files(iff),o_swtoacf_ant%name,itau_w,
1076     $      topswcf_aero(:,2))
1077        ENDIF
1078
1079        IF (o_swsrfcf_ant%flag(iff)<=lev_files(iff)) THEN
1080        CALL histwrite_phy(nid_files(iff),o_swsrfcf_ant%name,itau_w,
1081     $      solswcf_aero(:,2))
1082        ENDIF
1083
1084        IF (o_swtoacf_zero%flag(iff)<=lev_files(iff)) THEN
1085        CALL histwrite_phy(nid_files(iff),o_swtoacf_zero%name,itau_w,
1086     $      topswcf_aero(:,3))
1087        ENDIF
1088
1089        IF (o_swsrfcf_zero%flag(iff)<=lev_files(iff)) THEN
1090        CALL histwrite_phy(nid_files(iff),o_swsrfcf_zero%name,itau_w,
1091     $      solswcf_aero(:,3))
1092        ENDIF
1093        endif
1094
1095        endif ! new_aod
1096!====MS forcing diagnostics
1097
1098       ENDIF
1099
1100       IF (ok_aie) THEN
1101          IF (o_topswai%flag(iff)<=lev_files(iff)) THEN
1102             CALL histwrite_phy(nid_files(iff),o_topswai%name,itau_w,
1103     $            topswai_aero)
1104          ENDIF
1105          IF (o_solswai%flag(iff)<=lev_files(iff)) THEN
1106             CALL histwrite_phy(nid_files(iff),o_solswai%name,itau_w,
1107     $            solswai_aero)
1108          ENDIF
1109          IF (o_scdnc%flag(iff)<=lev_files(iff)) THEN
1110             CALL histwrite_phy(nid_files(iff),o_scdnc%name,itau_w,
1111     $            scdnc)
1112          ENDIF
1113          IF (o_cldncl%flag(iff)<=lev_files(iff)) THEN
1114             CALL histwrite_phy(nid_files(iff),o_cldncl%name,itau_w,
1115     $            cldncl)
1116          ENDIF
1117          IF (o_reffclws%flag(iff)<=lev_files(iff)) THEN
1118             CALL histwrite_phy(nid_files(iff),o_reffclws%name,itau_w,
1119     $            reffclws)
1120          ENDIF
1121          IF (o_reffclwc%flag(iff)<=lev_files(iff)) THEN
1122             CALL histwrite_phy(nid_files(iff),o_reffclwc%name,itau_w,
1123     $            reffclwc)
1124          ENDIF
1125          IF (o_cldnvi%flag(iff)<=lev_files(iff)) THEN
1126             CALL histwrite_phy(nid_files(iff),o_cldnvi%name,itau_w,
1127     $            cldnvi)
1128          ENDIF
1129          IF (o_lcc%flag(iff)<=lev_files(iff)) THEN
1130             CALL histwrite_phy(nid_files(iff),o_lcc%name,itau_w,
1131     $            lcc)
1132          ENDIF
1133          IF (o_lcc3d%flag(iff)<=lev_files(iff)) THEN
1134             CALL histwrite_phy(nid_files(iff),o_lcc3d%name,itau_w,
1135     $            lcc3d)
1136          ENDIF
1137          IF (o_lcc3dcon%flag(iff)<=lev_files(iff)) THEN
1138             CALL histwrite_phy(nid_files(iff),o_lcc3dcon%name,itau_w,
1139     $            lcc3dcon)
1140          ENDIF
1141          IF (o_lcc3dstra%flag(iff)<=lev_files(iff)) THEN
1142             CALL histwrite_phy(nid_files(iff),o_lcc3dstra%name,itau_w,
1143     $            lcc3dstra)
1144          ENDIF
1145          IF (o_reffclwtop%flag(iff)<=lev_files(iff)) THEN
1146             CALL histwrite_phy(nid_files(iff),o_reffclwtop%name,itau_w,
1147     $            reffclwtop)
1148          ENDIF
1149       ENDIF
1150
1151! Champs 3D:
1152       IF (ok_ade .OR. ok_aie) then
1153          IF (o_ec550aer%flag(iff)<=lev_files(iff)) THEN
1154             CALL histwrite_phy(nid_files(iff),o_ec550aer%name,itau_w,
1155     &            ec550aer)
1156          ENDIF
1157       ENDIF
1158
1159       IF (o_lwcon%flag(iff)<=lev_files(iff)) THEN
1160      CALL histwrite_phy(nid_files(iff),o_lwcon%name,itau_w,flwc)
1161       ENDIF
1162
1163       IF (o_iwcon%flag(iff)<=lev_files(iff)) THEN
1164      CALL histwrite_phy(nid_files(iff),o_iwcon%name,itau_w,fiwc)
1165       ENDIF
1166
1167       IF (o_temp%flag(iff)<=lev_files(iff)) THEN
1168      CALL histwrite_phy(nid_files(iff),o_temp%name,itau_w,t_seri)
1169       ENDIF
1170
1171       IF (o_theta%flag(iff)<=lev_files(iff)) THEN
1172      CALL histwrite_phy(nid_files(iff),o_theta%name,itau_w,theta)
1173       ENDIF
1174
1175       IF (o_ovap%flag(iff)<=lev_files(iff)) THEN
1176      CALL histwrite_phy(nid_files(iff),o_ovap%name,itau_w,qx(:,:,ivap))
1177       ENDIF
1178
1179       IF (o_ovapinit%flag(iff)<=lev_files(iff)) THEN
1180      CALL histwrite_phy(nid_files(iff),
1181     $                   o_ovapinit%name,itau_w,q_seri)
1182       ENDIF
1183
1184       IF (o_geop%flag(iff)<=lev_files(iff)) THEN
1185      CALL histwrite_phy(nid_files(iff),o_geop%name,itau_w,zphi)
1186       ENDIF
1187
1188       IF (o_vitu%flag(iff)<=lev_files(iff)) THEN
1189      CALL histwrite_phy(nid_files(iff),o_vitu%name,itau_w,u_seri)
1190       ENDIF
1191
1192       IF (o_vitv%flag(iff)<=lev_files(iff)) THEN
1193      CALL histwrite_phy(nid_files(iff),o_vitv%name,itau_w,v_seri)
1194       ENDIF
1195
1196       IF (o_vitw%flag(iff)<=lev_files(iff)) THEN
1197      CALL histwrite_phy(nid_files(iff),o_vitw%name,itau_w,omega)
1198       ENDIF
1199
1200        IF (o_pres%flag(iff)<=lev_files(iff)) THEN
1201      CALL histwrite_phy(nid_files(iff),o_pres%name,itau_w,pplay)
1202        ENDIF
1203
1204        IF (o_paprs%flag(iff)<=lev_files(iff)) THEN
1205      CALL histwrite_phy(nid_files(iff),o_paprs%name,
1206     s                    itau_w,paprs(:,1:klev))
1207        ENDIF
1208
1209       IF (o_rneb%flag(iff)<=lev_files(iff)) THEN
1210      CALL histwrite_phy(nid_files(iff),o_rneb%name,itau_w,cldfra)
1211       ENDIF
1212
1213       IF (o_rnebcon%flag(iff)<=lev_files(iff)) THEN
1214      CALL histwrite_phy(nid_files(iff),o_rnebcon%name,itau_w,rnebcon)
1215       ENDIF
1216
1217       IF (o_rhum%flag(iff)<=lev_files(iff)) THEN
1218      CALL histwrite_phy(nid_files(iff),o_rhum%name,itau_w,zx_rh)
1219       ENDIF
1220
1221      IF (o_ozone%flag(iff)<=lev_files(iff)) THEN
1222         CALL histwrite_phy(nid_files(iff), o_ozone%name, itau_w,
1223     $        wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1224      ENDIF
1225
1226      IF (o_ozone_light%flag(iff)<=lev_files(iff) .and.
1227     $     read_climoz == 2) THEN
1228         CALL histwrite_phy(nid_files(iff), o_ozone_light%name, itau_w,
1229     $        wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1230      ENDIF
1231
1232       IF (o_dtphy%flag(iff)<=lev_files(iff)) THEN
1233      CALL histwrite_phy(nid_files(iff),o_dtphy%name,itau_w,d_t)
1234       ENDIF
1235
1236       IF (o_dqphy%flag(iff)<=lev_files(iff)) THEN
1237      CALL histwrite_phy(nid_files(iff),
1238     s                  o_dqphy%name,itau_w, d_qx(:,:,ivap))
1239       ENDIF
1240
1241        DO nsrf=1, nbsrf
1242        IF (o_albe_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1243        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
1244        CALL histwrite_phy(nid_files(iff),
1245     s                    o_albe_srf(nsrf)%name,itau_w,
1246     $                     zx_tmp_fi2d)
1247        ENDIF
1248
1249        IF (o_rugs_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN 
1250        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
1251        CALL histwrite_phy(nid_files(iff),
1252     s                     o_rugs_srf(nsrf)%name,itau_w,
1253     $      zx_tmp_fi2d)
1254        ENDIF
1255
1256        IF (o_ages_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1257        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
1258        CALL histwrite_phy(nid_files(iff),
1259     s                     o_ages_srf(nsrf)%name,itau_w
1260     $    ,zx_tmp_fi2d)
1261        ENDIF
1262        ENDDO !nsrf=1, nbsrf
1263
1264       IF (o_albs%flag(iff)<=lev_files(iff)) THEN
1265      CALL histwrite_phy(nid_files(iff),o_albs%name,itau_w,albsol1)
1266       ENDIF
1267
1268       IF (o_albslw%flag(iff)<=lev_files(iff)) THEN
1269      CALL histwrite_phy(nid_files(iff),o_albslw%name,itau_w,albsol2)
1270       ENDIF
1271
1272!FH Sorties pour la couche limite
1273      if (iflag_pbl>1) then
1274      zx_tmp_fi3d=0.
1275      do nsrf=1,nbsrf
1276         do k=1,klev
1277          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k)
1278     $    +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
1279         enddo
1280      enddo
1281       IF (o_tke%flag(iff)<=lev_files(iff)) THEN
1282      CALL histwrite_phy(nid_files(iff),o_tke%name,itau_w,zx_tmp_fi3d)
1283       ENDIF
1284
1285       IF (o_tke_max%flag(iff)<=lev_files(iff)) THEN
1286      CALL histwrite_phy(nid_files(iff),
1287     s                   o_tke_max%name,itau_w,zx_tmp_fi3d)
1288       ENDIF
1289      endif
1290
1291       IF (o_kz%flag(iff)<=lev_files(iff)) THEN
1292      CALL histwrite_phy(nid_files(iff),o_kz%name,itau_w,coefh)
1293       ENDIF
1294
1295       IF (o_kz_max%flag(iff)<=lev_files(iff)) THEN
1296      CALL histwrite_phy(nid_files(iff),o_kz_max%name,itau_w,coefh)
1297       ENDIF
1298
1299       IF (o_clwcon%flag(iff)<=lev_files(iff)) THEN
1300      CALL histwrite_phy(nid_files(iff),o_clwcon%name,itau_w,clwcon0)
1301       ENDIF
1302
1303       IF (o_dtdyn%flag(iff)<=lev_files(iff)) THEN
1304      CALL histwrite_phy(nid_files(iff),o_dtdyn%name,itau_w,d_t_dyn)
1305       ENDIF
1306
1307       IF (o_dqdyn%flag(iff)<=lev_files(iff)) THEN
1308      CALL histwrite_phy(nid_files(iff),o_dqdyn%name,itau_w,d_q_dyn)
1309       ENDIF
1310
1311       IF (o_dudyn%flag(iff)<=lev_files(iff)) THEN
1312      CALL histwrite_phy(nid_files(iff),o_dudyn%name,itau_w,d_u_dyn)
1313       ENDIF                                                   
1314
1315       IF (o_dvdyn%flag(iff)<=lev_files(iff)) THEN                 
1316      CALL histwrite_phy(nid_files(iff),o_dvdyn%name,itau_w,d_v_dyn) 
1317       ENDIF                                                     
1318
1319       IF (o_dtcon%flag(iff)<=lev_files(iff)) THEN
1320      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
1321      CALL histwrite_phy(nid_files(iff),o_dtcon%name,itau_w,zx_tmp_fi3d)
1322       ENDIF
1323
1324       IF (o_ducon%flag(iff)<=lev_files(iff)) THEN
1325      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
1326      CALL histwrite_phy(nid_files(iff),o_ducon%name,itau_w,zx_tmp_fi3d)
1327       ENDIF
1328
1329       IF (o_dqcon%flag(iff)<=lev_files(iff)) THEN
1330      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1331      CALL histwrite_phy(nid_files(iff),o_dqcon%name,itau_w,zx_tmp_fi3d)
1332       ENDIF
1333
1334       IF (o_dtlsc%flag(iff)<=lev_files(iff)) THEN
1335      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
1336      CALL histwrite_phy(nid_files(iff),o_dtlsc%name,itau_w,zx_tmp_fi3d)
1337       ENDIF
1338
1339       IF (o_dtlschr%flag(iff)<=lev_files(iff)) THEN
1340      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
1341     $                           d_t_eva(1:klon,1:klev))/pdtphys
1342      CALL histwrite_phy(nid_files(iff),
1343     s                   o_dtlschr%name,itau_w,zx_tmp_fi3d)
1344       ENDIF
1345
1346       IF (o_dqlsc%flag(iff)<=lev_files(iff)) THEN
1347      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
1348      CALL histwrite_phy(nid_files(iff),o_dqlsc%name,itau_w,zx_tmp_fi3d)
1349       ENDIF
1350
1351       IF (o_dtvdf%flag(iff)<=lev_files(iff)) THEN
1352      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
1353      CALL histwrite_phy(nid_files(iff),o_dtvdf%name,itau_w,zx_tmp_fi3d)
1354       ENDIF
1355
1356       IF (o_dqvdf%flag(iff)<=lev_files(iff)) THEN
1357      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1358      CALL histwrite_phy(nid_files(iff),o_dqvdf%name,itau_w,zx_tmp_fi3d)
1359       ENDIF
1360
1361       IF (o_dteva%flag(iff)<=lev_files(iff)) THEN
1362      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1363      CALL histwrite_phy(nid_files(iff),o_dteva%name,itau_w,zx_tmp_fi3d)
1364       ENDIF
1365
1366       IF (o_dqeva%flag(iff)<=lev_files(iff)) THEN
1367      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1368      CALL histwrite_phy(nid_files(iff),o_dqeva%name,itau_w,zx_tmp_fi3d)
1369       ENDIF
1370
1371       IF (o_ptconv%flag(iff)<=lev_files(iff)) THEN
1372      zpt_conv = 0.
1373      where (ptconv) zpt_conv = 1.
1374      CALL histwrite_phy(nid_files(iff),o_ptconv%name,itau_w,zpt_conv)
1375       ENDIF
1376
1377       IF (o_ratqs%flag(iff)<=lev_files(iff)) THEN
1378      CALL histwrite_phy(nid_files(iff),o_ratqs%name,itau_w,ratqs)
1379       ENDIF
1380
1381       IF (o_dtthe%flag(iff)<=lev_files(iff)) THEN
1382      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys
1383      CALL histwrite_phy(nid_files(iff),o_dtthe%name,itau_w,zx_tmp_fi3d)
1384       ENDIF
1385
1386       IF (iflag_thermals.gt.1) THEN
1387        IF (o_ftime_th%flag(iff)<=lev_files(iff)) THEN
1388! Pour l instant 0 a y reflichir pour les thermiques
1389         zx_tmp_fi2d=0. 
1390        CALL histwrite_phy(nid_files(iff),o_ftime_th%name,
1391     s                     itau_w,zx_tmp_fi2d)
1392        ENDIF
1393
1394        IF (o_f_th%flag(iff)<=lev_files(iff)) THEN
1395        CALL histwrite_phy(nid_files(iff),o_f_th%name,itau_w,fm_therm)
1396        ENDIF
1397
1398        IF (o_e_th%flag(iff)<=lev_files(iff)) THEN
1399        CALL histwrite_phy(nid_files(iff),o_e_th%name,itau_w,entr_therm)
1400        ENDIF
1401
1402        IF (o_w_th%flag(iff)<=lev_files(iff)) THEN
1403        CALL histwrite_phy(nid_files(iff),o_w_th%name,itau_w,zw2)
1404        ENDIF
1405
1406        IF (o_q_th%flag(iff)<=lev_files(iff)) THEN
1407        CALL histwrite_phy(nid_files(iff),o_q_th%name,itau_w,zqasc)
1408        ENDIF
1409
1410        IF (o_lambda_th%flag(iff)<=lev_files(iff)) THEN
1411        CALL histwrite_phy(nid_files(iff),
1412     s                     o_lambda_th%name,itau_w,lambda_th)
1413        ENDIF
1414
1415        IF (o_a_th%flag(iff)<=lev_files(iff)) THEN
1416        CALL histwrite_phy(nid_files(iff),o_a_th%name,itau_w,fraca)
1417        ENDIF
1418
1419       IF (o_d_th%flag(iff)<=lev_files(iff)) THEN
1420       CALL histwrite_phy(nid_files(iff),o_d_th%name,itau_w,detr_therm)
1421       ENDIF
1422
1423      ENDIF !iflag_thermals
1424
1425       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1426      CALL histwrite_phy(nid_files(iff),o_f0_th%name,itau_w,f0)
1427       ENDIF
1428
1429       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1430      CALL histwrite_phy(nid_files(iff),o_zmax_th%name,itau_w,zmax0)
1431       ENDIF
1432
1433       IF (o_dqthe%flag(iff)<=lev_files(iff)) THEN
1434      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
1435      CALL histwrite_phy(nid_files(iff),o_dqthe%name,itau_w,zx_tmp_fi3d)
1436       ENDIF
1437
1438       IF (o_dtajs%flag(iff)<=lev_files(iff)) THEN
1439      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
1440      CALL histwrite_phy(nid_files(iff),o_dtajs%name,itau_w,zx_tmp_fi3d)
1441       ENDIF
1442
1443       IF (o_dqajs%flag(iff)<=lev_files(iff)) THEN
1444      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
1445      CALL histwrite_phy(nid_files(iff),o_dqajs%name,itau_w,zx_tmp_fi3d)
1446       ENDIF
1447
1448       IF (o_dtswr%flag(iff)<=lev_files(iff)) THEN
1449      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
1450      CALL histwrite_phy(nid_files(iff),o_dtswr%name,itau_w,zx_tmp_fi3d)
1451       ENDIF
1452
1453       IF (o_dtsw0%flag(iff)<=lev_files(iff)) THEN
1454      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
1455      CALL histwrite_phy(nid_files(iff),o_dtsw0%name,itau_w,zx_tmp_fi3d)
1456       ENDIF
1457
1458       IF (o_dtlwr%flag(iff)<=lev_files(iff)) THEN
1459      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
1460      CALL histwrite_phy(nid_files(iff),o_dtlwr%name,itau_w,zx_tmp_fi3d)
1461       ENDIF
1462
1463       IF (o_dtlw0%flag(iff)<=lev_files(iff)) THEN
1464      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
1465      CALL histwrite_phy(nid_files(iff),o_dtlw0%name,itau_w,zx_tmp_fi3d)
1466       ENDIF
1467
1468       IF (o_dtec%flag(iff)<=lev_files(iff)) THEN
1469      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
1470      CALL histwrite_phy(nid_files(iff),o_dtec%name,itau_w,zx_tmp_fi3d)
1471       ENDIF
1472
1473       IF (o_duvdf%flag(iff)<=lev_files(iff)) THEN
1474      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
1475      CALL histwrite_phy(nid_files(iff),o_duvdf%name,itau_w,zx_tmp_fi3d)
1476       ENDIF
1477
1478       IF (o_dvvdf%flag(iff)<=lev_files(iff)) THEN
1479      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
1480      CALL histwrite_phy(nid_files(iff),o_dvvdf%name,itau_w,zx_tmp_fi3d)
1481       ENDIF
1482
1483       IF (ok_orodr) THEN
1484      IF (o_duoro%flag(iff)<=lev_files(iff)) THEN
1485      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
1486      CALL histwrite_phy(nid_files(iff),o_duoro%name,itau_w,zx_tmp_fi3d)
1487       ENDIF
1488
1489      IF (o_dvoro%flag(iff)<=lev_files(iff)) THEN
1490      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
1491      CALL histwrite_phy(nid_files(iff),o_dvoro%name,itau_w,zx_tmp_fi3d)
1492      ENDIF
1493       ENDIF
1494
1495        IF (ok_orolf) THEN
1496       IF (o_dulif%flag(iff)<=lev_files(iff)) THEN
1497      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
1498      CALL histwrite_phy(nid_files(iff),o_dulif%name,itau_w,zx_tmp_fi3d)
1499       ENDIF
1500
1501        IF (o_dvlif%flag(iff)<=lev_files(iff)) THEN
1502      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
1503      CALL histwrite_phy(nid_files(iff),o_dvlif%name,itau_w,zx_tmp_fi3d)
1504       ENDIF
1505        ENDIF
1506
1507!       IF (o_trac%flag(iff)<=lev_files(iff)) THEN
1508         if (nqtot.GE.3) THEN
1509!           DO iq=3,nqtot
1510           DO iq=3,4
1511       IF (o_trac(iq-2)%flag(iff)<=lev_files(iff)) THEN
1512         CALL histwrite_phy(nid_files(iff),
1513     s                  o_trac(iq-2)%name,itau_w,qx(:,:,iq))
1514       ENDIF
1515           ENDDO
1516         endif
1517
1518      if (ok_sync) then
1519c$OMP MASTER
1520        call histsync(nid_files(iff))
1521c$OMP END MASTER
1522      endif
1523
1524       ENDIF ! clef_files
1525
1526      ENDDO ! iff=1,nfiles
Note: See TracBrowser for help on using the repository browser.