source: LMDZ4/branches/LMDZ4_AR5/libf/phylmd/phys_output_write.h @ 1636

Last change on this file since 1636 was 1636, checked in by idelkadi, 12 years ago

Correction (lev_histday -> lev_files)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 69.8 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),clef_stations(iff),
12     $                  o_phis%name,itau_w,pphis)
13       ENDIF
14
15       IF (.NOT.clef_stations(iff)) THEN
16       IF (o_aire%flag(iff)<=lev_files(iff)) THEN
17       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
18     $o_aire%name,itau_w,airephy)
19       ENDIF
20
21       IF (o_contfracATM%flag(iff)<=lev_files(iff)) THEN
22      DO i=1, klon
23       zx_tmp_fi2d(i)=pctsrf(i,is_ter)+pctsrf(i,is_lic)
24      ENDDO
25      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
26     $             o_contfracATM%name,itau_w,zx_tmp_fi2d)
27       ENDIF
28       ENDIF
29
30       IF (o_contfracOR%flag(iff)<=lev_files(iff)) THEN
31      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
32     $                  o_contfracOR%name,itau_w,pctsrf(:,is_ter))
33       ENDIF
34
35       IF (o_aireTER%flag(iff)<=lev_files(iff)) THEN
36      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
37     $                  o_aireTER%name,itau_w,paire_ter)
38       ENDIF
39
40!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
41
42       IF (o_flat%flag(iff)<=lev_files(iff)) THEN
43      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
44     $                  o_flat%name,itau_w,zxfluxlat)
45       ENDIF
46
47       IF (o_slp%flag(iff)<=lev_files(iff)) THEN
48      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
49     $                  o_slp%name,itau_w,slp)
50       ENDIF
51
52       IF (o_tsol%flag(iff)<=lev_files(iff)) THEN
53      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
54     $                  o_tsol%name,itau_w,zxtsol)
55       ENDIF
56
57       IF (o_t2m%flag(iff)<=lev_files(iff)) THEN
58      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
59     $                  o_t2m%name,itau_w,zt2m)
60       ENDIF
61
62      IF (.NOT.clef_stations(iff)) THEN
63       IF (o_t2m_min%flag(iff)<=lev_files(iff)) THEN
64      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
65     $o_t2m_min%name,itau_w,zt2m)
66       ENDIF
67
68       IF (o_t2m_max%flag(iff)<=lev_files(iff)) THEN
69      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
70     $o_t2m_max%name,itau_w,zt2m)
71       ENDIF
72       ENDIF
73
74       IF (o_wind10m%flag(iff)<=lev_files(iff)) THEN
75      DO i=1, klon
76       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
77      ENDDO
78      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
79     s                  o_wind10m%name,itau_w,zx_tmp_fi2d)
80       ENDIF
81
82      IF (.NOT.clef_stations(iff)) THEN
83       IF (o_wind10max%flag(iff)<=lev_files(iff)) THEN
84      DO i=1, klon
85       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
86      ENDDO
87      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
88     $o_wind10max%name,itau_w,zx_tmp_fi2d)
89       ENDIF
90      ENDIF
91
92       IF (o_sicf%flag(iff)<=lev_files(iff)) THEN
93      DO i = 1, klon
94         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
95      ENDDO
96      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
97     $                   o_sicf%name,itau_w,zx_tmp_fi2d)
98       ENDIF
99
100       IF (o_q2m%flag(iff)<=lev_files(iff)) THEN
101      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
102     $o_q2m%name,itau_w,zq2m)
103       ENDIF
104
105       IF (o_u10m%flag(iff)<=lev_files(iff)) THEN
106      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
107     $o_u10m%name,itau_w,zu10m)
108       ENDIF
109
110       IF (o_v10m%flag(iff)<=lev_files(iff)) THEN
111      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
112     $o_v10m%name,itau_w,zv10m)
113       ENDIF
114
115       IF (o_psol%flag(iff)<=lev_files(iff)) THEN
116      DO i = 1, klon
117         zx_tmp_fi2d(i) = paprs(i,1)
118      ENDDO
119      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
120     s                   o_psol%name,itau_w,zx_tmp_fi2d)
121       ENDIF
122
123       IF (o_qsurf%flag(iff)<=lev_files(iff)) THEN
124      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
125     $o_qsurf%name,itau_w,zxqsurf)
126       ENDIF
127
128       if (.not. ok_veget) then
129         IF (o_qsol%flag(iff)<=lev_files(iff)) THEN
130        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
131     $o_qsol%name,itau_w,qsol)
132         ENDIF
133       endif
134
135      IF (o_precip%flag(iff)<=lev_files(iff)) THEN
136       DO i = 1, klon
137         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
138       ENDDO
139      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
140     $o_precip%name,itau_w,zx_tmp_fi2d)
141      ENDIF
142
143       IF (o_ndayrain%flag(iff)<=lev_files(iff)) THEN
144      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
145     $o_ndayrain%name,itau_w,nday_rain)
146       ENDIF
147
148      IF (o_plul%flag(iff)<=lev_files(iff)) THEN
149       DO i = 1, klon
150         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
151       ENDDO
152      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
153     $o_plul%name,itau_w,zx_tmp_fi2d)
154      ENDIF
155
156      IF (o_pluc%flag(iff)<=lev_files(iff)) THEN
157      DO i = 1, klon
158         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
159      ENDDO
160      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
161     $o_pluc%name,itau_w,zx_tmp_fi2d)
162      ENDIF
163
164       IF (o_snow%flag(iff)<=lev_files(iff)) THEN
165      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
166     $o_snow%name,itau_w,snow_fall)
167       ENDIF
168
169       IF (o_msnow%flag(iff)<=lev_files(iff)) THEN
170      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
171     $o_msnow%name,itau_w,snow_o)
172       ENDIF
173
174       IF (o_fsnow%flag(iff)<=lev_files(iff)) THEN
175      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
176     $o_fsnow%name,itau_w,zfra_o)
177       ENDIF
178
179       IF (o_evap%flag(iff)<=lev_files(iff)) THEN
180      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
181     $o_evap%name,itau_w,evap)
182       ENDIF
183
184       IF (o_tops%flag(iff)<=lev_files(iff)) THEN
185      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
186     $o_tops%name,itau_w,topsw)
187       ENDIF
188
189       IF (o_tops0%flag(iff)<=lev_files(iff)) THEN
190      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
191     $o_tops0%name,itau_w,topsw0)
192       ENDIF
193
194       IF (o_topl%flag(iff)<=lev_files(iff)) THEN
195      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
196     $o_topl%name,itau_w,toplw)
197       ENDIF
198
199       IF (o_topl0%flag(iff)<=lev_files(iff)) THEN
200      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
201     $o_topl0%name,itau_w,toplw0)
202       ENDIF
203
204       IF (o_SWupTOA%flag(iff)<=lev_files(iff)) THEN
205      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
206      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
207     $o_SWupTOA%name,itau_w,zx_tmp_fi2d)
208       ENDIF
209
210       IF (o_SWupTOAclr%flag(iff)<=lev_files(iff)) THEN
211      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
212      CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
213     $                  o_SWupTOAclr%name,itau_w,zx_tmp_fi2d)
214       ENDIF
215
216       IF (o_SWdnTOA%flag(iff)<=lev_files(iff)) THEN
217      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
218      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
219     s                  o_SWdnTOA%name,itau_w,zx_tmp_fi2d)
220       ENDIF
221
222       IF (o_SWdnTOAclr%flag(iff)<=lev_files(iff)) THEN
223      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
224      CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
225     $                  o_SWdnTOAclr%name,itau_w,zx_tmp_fi2d)
226       ENDIF
227
228       IF (o_nettop%flag(iff)<=lev_files(iff)) THEN
229      zx_tmp_fi2d(:) = topsw(:)-toplw(:)
230      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
231     $                  o_nettop%name,itau_w,zx_tmp_fi2d)
232       ENDIF
233
234       IF (o_SWup200%flag(iff)<=lev_files(iff)) THEN
235      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
236     $o_SWup200%name,itau_w,SWup200)
237       ENDIF
238
239       IF (o_SWup200clr%flag(iff)<=lev_files(iff)) THEN
240      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
241     s                   o_SWup200clr%name,itau_w,SWup200clr)
242       ENDIF
243
244       IF (o_SWdn200%flag(iff)<=lev_files(iff)) THEN
245      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
246     $o_SWdn200%name,itau_w,SWdn200)
247       ENDIF
248
249       IF (o_SWdn200clr%flag(iff)<=lev_files(iff)) THEN
250      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
251     s                o_SWdn200clr%name,itau_w,SWdn200clr)
252       ENDIF
253
254       IF (o_LWup200%flag(iff)<=lev_files(iff)) THEN
255      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
256     $o_LWup200%name,itau_w,LWup200)
257       ENDIF
258
259       IF (o_LWup200clr%flag(iff)<=lev_files(iff)) THEN
260      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
261     s                   o_LWup200clr%name,itau_w,LWup200clr)
262       ENDIF
263
264       IF (o_LWdn200%flag(iff)<=lev_files(iff)) THEN
265      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
266     s                   o_LWdn200%name,itau_w,LWdn200)
267       ENDIF
268
269       IF (o_LWdn200clr%flag(iff)<=lev_files(iff)) THEN
270      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
271     s                  o_LWdn200clr%name,itau_w,LWdn200clr)
272       ENDIF
273
274       IF (o_sols%flag(iff)<=lev_files(iff)) THEN
275      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
276     $o_sols%name,itau_w,solsw)
277       ENDIF
278
279       IF (o_sols0%flag(iff)<=lev_files(iff)) THEN
280      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
281     $o_sols0%name,itau_w,solsw0)
282       ENDIF
283
284       IF (o_soll%flag(iff)<=lev_files(iff)) THEN
285      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
286     $o_soll%name,itau_w,sollw)
287       ENDIF
288
289       IF (o_radsol%flag(iff)<=lev_files(iff)) THEN
290      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
291     $o_radsol%name,itau_w,radsol)
292       ENDIF
293
294       IF (o_soll0%flag(iff)<=lev_files(iff)) THEN
295      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
296     $o_soll0%name,itau_w,sollw0)
297       ENDIF
298
299       IF (o_SWupSFC%flag(iff)<=lev_files(iff)) THEN
300      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
301      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
302     s               o_SWupSFC%name,itau_w,zx_tmp_fi2d)
303       ENDIF
304
305       IF (o_SWupSFCclr%flag(iff)<=lev_files(iff)) THEN
306      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
307      CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
308     $                   o_SWupSFCclr%name,itau_w,zx_tmp_fi2d)
309       ENDIF
310
311       IF (o_SWdnSFC%flag(iff)<=lev_files(iff)) THEN
312      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
313      CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
314     $                   o_SWdnSFC%name,itau_w,zx_tmp_fi2d)
315       ENDIF
316
317       IF (o_SWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
318      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
319      CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
320     $                  o_SWdnSFCclr%name,itau_w,zx_tmp_fi2d)
321       ENDIF
322
323       IF (o_LWupSFC%flag(iff)<=lev_files(iff)) THEN
324      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
325      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
326     $                    o_LWupSFC%name,itau_w,zx_tmp_fi2d)
327       ENDIF
328
329       IF (o_LWdnSFC%flag(iff)<=lev_files(iff)) THEN
330      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
331     $                   o_LWdnSFC%name,itau_w,sollwdown)
332       ENDIF
333
334       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
335       IF (o_LWupSFCclr%flag(iff)<=lev_files(iff)) THEN
336      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
337      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
338     $                   o_LWupSFCclr%name,itau_w,zx_tmp_fi2d)
339       ENDIF
340
341       IF (o_LWdnSFCclr%flag(iff)<=lev_files(iff)) THEN
342      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
343     $                   o_LWdnSFCclr%name,itau_w,sollwdownclr)
344       ENDIF
345
346       IF (o_bils%flag(iff)<=lev_files(iff)) THEN
347      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
348     $o_bils%name,itau_w,bils)
349       ENDIF
350
351       IF (o_sens%flag(iff)<=lev_files(iff)) THEN
352      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
353      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
354     $o_sens%name,itau_w,zx_tmp_fi2d)
355       ENDIF
356
357       IF (o_fder%flag(iff)<=lev_files(iff)) THEN
358      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
359     $o_fder%name,itau_w,fder)
360       ENDIF
361
362       IF (o_ffonte%flag(iff)<=lev_files(iff)) THEN
363       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
364     $o_ffonte%name,itau_w,zxffonte)
365       ENDIF
366
367       IF (o_fqcalving%flag(iff)<=lev_files(iff)) THEN
368       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
369     $                    o_fqcalving%name,itau_w,zxfqcalving)
370       ENDIF
371
372       IF (o_fqfonte%flag(iff)<=lev_files(iff)) THEN
373       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
374     $                   o_fqfonte%name,itau_w,zxfqfonte)
375       ENDIF
376
377       IF (o_taux%flag(iff)<=lev_files(iff)) THEN
378         zx_tmp_fi2d=0.
379         do nsrf=1,nbsrf
380          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxu(:,1,nsrf)
381         enddo
382         CALL histwrite_phy(nid_files(iff),clef_stations(iff),
383     $                   o_taux%name,itau_w,zx_tmp_fi2d)
384       ENDIF
385
386       IF (o_tauy%flag(iff)<=lev_files(iff)) THEN
387         zx_tmp_fi2d=0.
388         do nsrf=1,nbsrf
389          zx_tmp_fi2d(:)=zx_tmp_fi2d(:)+pctsrf(:,nsrf)*fluxv(:,1,nsrf)
390         enddo
391         CALL histwrite_phy(nid_files(iff),clef_stations(iff),
392     $                   o_tauy%name,itau_w,zx_tmp_fi2d)
393       ENDIF
394
395         DO nsrf = 1, nbsrf
396!           IF(nsrf.GE.2) THEN
397            IF (o_pourc_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
398            zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
399            CALL histwrite_phy(nid_files(iff),
400     $                     clef_stations(iff),
401     $                     o_pourc_srf(nsrf)%name,itau_w,
402     $                     zx_tmp_fi2d)
403            ENDIF
404
405          IF (o_fract_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
406          zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
407          CALL histwrite_phy(nid_files(iff),clef_stations(iff),
408     $                  o_fract_srf(nsrf)%name,itau_w,
409     $                  zx_tmp_fi2d)
410          ENDIF
411!         ENDIF !nsrf.GT.2
412
413        IF (o_taux_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
414        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
415        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
416     $                     o_taux_srf(nsrf)%name,itau_w,
417     $                     zx_tmp_fi2d)
418        ENDIF
419
420        IF (o_tauy_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN           
421        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
422        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
423     $                    o_tauy_srf(nsrf)%name,itau_w,
424     $                    zx_tmp_fi2d)
425        ENDIF
426
427        IF (o_tsol_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
428        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
429        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
430     $                   o_tsol_srf(nsrf)%name,itau_w,
431     $      zx_tmp_fi2d)
432        ENDIF
433
434      IF (o_u10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
435      zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
436      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
437     $o_u10m_srf(nsrf)%name,
438     $                 itau_w,zx_tmp_fi2d)
439      ENDIF
440
441      IF (o_v10m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
442      zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
443      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
444     $o_v10m_srf(nsrf)%name,
445     $              itau_w,zx_tmp_fi2d)
446      ENDIF
447 
448      IF (o_t2m_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
449      zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
450      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
451     $o_t2m_srf(nsrf)%name,
452     $           itau_w,zx_tmp_fi2d)
453      ENDIF
454
455      IF (o_evap_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
456      zx_tmp_fi2d(1 : klon) = fevap(1 : klon, nsrf)
457      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
458     $o_evap_srf(nsrf)%name,
459     $           itau_w,zx_tmp_fi2d)
460      ENDIF
461
462       IF (o_sens_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
463       zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
464       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
465     $                    o_sens_srf(nsrf)%name,itau_w,
466     $      zx_tmp_fi2d)
467       ENDIF
468
469        IF (o_lat_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
470        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
471        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
472     $                 o_lat_srf(nsrf)%name,itau_w,
473     $                                   zx_tmp_fi2d)
474          ENDIF
475
476        IF (o_flw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
477        zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
478        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
479     $                     o_flw_srf(nsrf)%name,itau_w,
480     $      zx_tmp_fi2d)
481        ENDIF
482
483        IF (o_fsw_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
484        zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
485        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
486     $                   o_fsw_srf(nsrf)%name,itau_w,
487     $      zx_tmp_fi2d)
488        ENDIF
489
490        IF (o_wbils_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
491        zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
492        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
493     $                   o_wbils_srf(nsrf)%name,itau_w,
494     $      zx_tmp_fi2d)
495        ENDIF
496
497        IF (o_wbilo_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
498        zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
499        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
500     $                    o_wbilo_srf(nsrf)%name,itau_w,
501     $      zx_tmp_fi2d)
502        ENDIF
503
504       if (iflag_pbl>1 .and. lev_files(iff).gt.10 ) then
505        IF (o_tke_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
506        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
507     $                   o_tke_srf(nsrf)%name,itau_w,
508     $                    pbl_tke(:,1:klev,nsrf))
509       ENDIF
510
511      IF (.NOT.clef_stations(iff)) THEN
512        IF (o_tke_max_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
513        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
514     $                    o_tke_max_srf(nsrf)%name,itau_w,
515     $      pbl_tke(:,1:klev,nsrf))
516        ENDIF
517      ENDIF
518       endif
519      ENDDO
520
521        IF (o_cdrm%flag(iff)<=lev_files(iff)) THEN
522      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
523     $o_cdrm%name,itau_w,cdragm)
524        ENDIF
525
526        IF (o_cdrh%flag(iff)<=lev_files(iff)) THEN
527      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
528     $o_cdrh%name,itau_w,cdragh)
529        ENDIF
530
531        IF (o_cldl%flag(iff)<=lev_files(iff)) THEN
532      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
533     $o_cldl%name,itau_w,cldl)
534        ENDIF
535
536        IF (o_cldm%flag(iff)<=lev_files(iff)) THEN
537      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
538     $o_cldm%name,itau_w,cldm)
539        ENDIF
540
541        IF (o_cldh%flag(iff)<=lev_files(iff)) THEN
542      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
543     $o_cldh%name,itau_w,cldh)
544        ENDIF
545
546        IF (o_cldt%flag(iff)<=lev_files(iff)) THEN
547      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
548     $o_cldt%name, 
549     &                   itau_w,cldt)
550        ENDIF
551
552        IF (o_cldq%flag(iff)<=lev_files(iff)) THEN
553      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
554     $o_cldq%name,itau_w,cldq)
555        ENDIF
556
557        IF (o_lwp%flag(iff)<=lev_files(iff)) THEN
558      zx_tmp_fi2d(1:klon) = flwp(1:klon)
559      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
560     s                   o_lwp%name,itau_w,zx_tmp_fi2d)
561        ENDIF
562
563        IF (o_iwp%flag(iff)<=lev_files(iff)) THEN
564      zx_tmp_fi2d(1:klon) = fiwp(1:klon)
565      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
566     s                    o_iwp%name,itau_w,zx_tmp_fi2d)
567        ENDIF
568
569        IF (o_ue%flag(iff)<=lev_files(iff)) THEN
570      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
571     $o_ue%name,itau_w,ue)
572        ENDIF
573
574        IF (o_ve%flag(iff)<=lev_files(iff)) THEN
575      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
576     $o_ve%name,itau_w,ve)
577        ENDIF
578
579        IF (o_uq%flag(iff)<=lev_files(iff)) THEN
580      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
581     $o_uq%name,itau_w,uq)
582        ENDIF
583
584        IF (o_vq%flag(iff)<=lev_files(iff)) THEN
585      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
586     $o_vq%name,itau_w,vq)
587        ENDIF
588
589      IF(iflag_con.GE.3) THEN ! sb
590        IF (o_cape%flag(iff)<=lev_files(iff)) THEN
591      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
592     $o_cape%name,itau_w,cape)
593        ENDIF
594
595        IF (o_pbase%flag(iff)<=lev_files(iff)) THEN
596      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
597     $o_pbase%name,itau_w,ema_pcb)
598        ENDIF
599
600        IF (o_ptop%flag(iff)<=lev_files(iff)) THEN
601      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
602     $o_ptop%name,itau_w,ema_pct)
603        ENDIF
604
605        IF (o_fbase%flag(iff)<=lev_files(iff)) THEN
606      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
607     $o_fbase%name,itau_w,ema_cbmf)
608        ENDIF
609
610        IF (o_prw%flag(iff)<=lev_files(iff)) THEN
611      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
612     $o_prw%name,itau_w,prw)
613        ENDIF
614
615      IF (.NOT.clef_stations(iff)) THEN
616      IF (o_cape_max%flag(iff)<=lev_files(iff)) THEN
617      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
618     $o_cape_max%name,itau_w,cape)
619      ENDIF
620      ENDIF
621
622       IF (o_upwd%flag(iff)<=lev_files(iff)) THEN
623      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
624     $o_upwd%name,itau_w,upwd)
625       ENDIF
626
627       IF (o_Ma%flag(iff)<=lev_files(iff)) THEN
628      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
629     $o_Ma%name,itau_w,Ma)
630       ENDIF
631
632       IF (o_dnwd%flag(iff)<=lev_files(iff)) THEN
633      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
634     $o_dnwd%name,itau_w,dnwd)
635       ENDIF
636
637       IF (o_dnwd0%flag(iff)<=lev_files(iff)) THEN
638      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
639     $o_dnwd0%name,itau_w,dnwd0)
640       ENDIF
641
642       IF (o_ftime_con%flag(iff)<=lev_files(iff)) THEN
643        zx_tmp_fi2d=float(itau_con)/float(itap)
644      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
645     $o_ftime_con%name,
646     s                   itau_w,zx_tmp_fi2d)
647       ENDIF
648
649       IF (o_mc%flag(iff)<=lev_files(iff)) THEN
650        if(iflag_thermals.gt.1)then
651         zx_tmp_fi3d=dnwd+dnwd0+upwd+fm_therm
652        else
653         zx_tmp_fi3d=dnwd+dnwd0+upwd
654        endif
655      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
656     $o_mc%name,itau_w,zx_tmp_fi3d)
657       ENDIF
658     
659      ENDIF !iflag_con .GE. 3
660
661        IF (o_s_pblh%flag(iff)<=lev_files(iff)) THEN
662      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
663     $o_s_pblh%name,itau_w,s_pblh)
664        ENDIF
665
666        IF (o_s_pblt%flag(iff)<=lev_files(iff)) THEN
667      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
668     $o_s_pblt%name,itau_w,s_pblt)
669        ENDIF
670
671        IF (o_s_lcl%flag(iff)<=lev_files(iff)) THEN
672      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
673     $o_s_lcl%name,itau_w,s_lcl)
674        ENDIF
675
676        IF (o_s_therm%flag(iff)<=lev_files(iff)) THEN
677      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
678     $o_s_therm%name,itau_w,s_therm)
679        ENDIF
680
681!IM : Les champs suivants (s_capCL, s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
682!       IF (o_s_capCL%flag(iff)<=lev_files(iff)) THEN
683!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
684!    $o_s_capCL%name,itau_w,s_capCL)
685!       ENDIF
686
687!       IF (o_s_oliqCL%flag(iff)<=lev_files(iff)) THEN
688!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
689!    $o_s_oliqCL%name,itau_w,s_oliqCL)
690!       ENDIF
691
692!       IF (o_s_cteiCL%flag(iff)<=lev_files(iff)) THEN
693!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
694!    $o_s_cteiCL%name,itau_w,s_cteiCL)
695!       ENDIF
696
697!       IF (o_s_trmb1%flag(iff)<=lev_files(iff)) THEN
698!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
699!    $o_s_trmb1%name,itau_w,s_trmb1)
700!       ENDIF
701
702!       IF (o_s_trmb2%flag(iff)<=lev_files(iff)) THEN
703!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
704!    $o_s_trmb2%name,itau_w,s_trmb2)
705!       ENDIF
706
707!       IF (o_s_trmb3%flag(iff)<=lev_files(iff)) THEN
708!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
709!    $o_s_trmb3%name,itau_w,s_trmb3)
710!       ENDIF
711
712! Champs interpolles sur des niveaux de pression
713
714        ll=0
715        DO k=1, nlevSTD
716         bb2=clevSTD(k) 
717         IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
718     $      bb2.EQ."500".OR.bb2.EQ."200".OR.
719     $      bb2.EQ."100".OR.
720     $      bb2.EQ."50".OR.bb2.EQ."10") THEN
721
722! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
723          ll=ll+1
724       IF (o_uSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
725       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
726     $o_uSTDlevs(ll)%name,
727     &                    itau_w,uwriteSTD(:,k,iff))
728       ENDIF
729
730       IF (o_vSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
731      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
732     $o_vSTDlevs(ll)%name, 
733     &                   itau_w,vwriteSTD(:,k,iff))
734       ENDIF
735
736       IF (o_wSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
737      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
738     $o_wSTDlevs(ll)%name,
739     &                    itau_w,wwriteSTD(:,k,iff))
740       ENDIF
741
742       IF (o_zSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
743      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
744     $o_zSTDlevs(ll)%name,
745     &               itau_w,phiwriteSTD(:,k,iff))
746       ENDIF
747
748       IF (o_qSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
749      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
750     $o_qSTDlevs(ll)%name,
751     &                   itau_w, qwriteSTD(:,k,iff))
752       ENDIF
753
754       IF (o_tSTDlevs(ll)%flag(iff)<=lev_files(iff)) THEN
755      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
756     $o_tSTDlevs(ll)%name,
757     &                   itau_w, twriteSTD(:,k,iff))
758       ENDIF
759
760       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
761       ENDDO
762
763      IF (o_t_oce_sic%flag(iff)<=lev_files(iff)) THEN
764      DO i=1, klon
765       IF (pctsrf(i,is_oce).GT.epsfra.OR.
766     $     pctsrf(i,is_sic).GT.epsfra) THEN
767        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+
768     $                   ftsol(i, is_sic) * pctsrf(i,is_sic))/
769     $                   (pctsrf(i,is_oce)+pctsrf(i,is_sic))
770       ELSE
771        zx_tmp_fi2d(i) = 273.15
772       ENDIF
773      ENDDO
774      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
775     s                   o_t_oce_sic%name,itau_w,zx_tmp_fi2d)
776      ENDIF
777
778! Couplage convection-couche limite
779      IF (iflag_con.GE.3) THEN
780      IF (iflag_coupl.EQ.1) THEN
781       IF (o_ale_bl%flag(iff)<=lev_files(iff)) THEN
782       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
783     $o_ale_bl%name,itau_w,ale_bl)
784       ENDIF
785       IF (o_alp_bl%flag(iff)<=lev_files(iff)) THEN
786       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
787     $o_alp_bl%name,itau_w,alp_bl)
788       ENDIF
789      ENDIF !iflag_coupl.EQ.1
790      ENDIF !(iflag_con.GE.3)
791
792! Wakes
793      IF (iflag_con.EQ.3) THEN
794      IF (iflag_wake.EQ.1) THEN
795       IF (o_ale_wk%flag(iff)<=lev_files(iff)) THEN
796       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
797     $o_ale_wk%name,itau_w,ale_wake)
798       ENDIF
799       IF (o_alp_wk%flag(iff)<=lev_files(iff)) THEN
800       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
801     $o_alp_wk%name,itau_w,alp_wake)
802       ENDIF
803
804       IF (o_ale%flag(iff)<=lev_files(iff)) THEN
805       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
806     $o_ale%name,itau_w,ale)
807       ENDIF
808       IF (o_alp%flag(iff)<=lev_files(iff)) THEN
809       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
810     $o_alp%name,itau_w,alp)
811       ENDIF
812       IF (o_cin%flag(iff)<=lev_files(iff)) THEN
813       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
814     $o_cin%name,itau_w,cin)
815       ENDIF
816       IF (o_wape%flag(iff)<=lev_files(iff)) THEN
817       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
818     $o_WAPE%name,itau_w,wake_pe)
819       ENDIF
820       IF (o_wake_h%flag(iff)<=lev_files(iff)) THEN
821      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
822     $o_wake_h%name,itau_w,wake_h)
823       ENDIF
824
825       IF (o_wake_s%flag(iff)<=lev_files(iff)) THEN
826      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
827     $o_wake_s%name,itau_w,wake_s)
828       ENDIF
829
830        IF (o_wake_deltat%flag(iff)<=lev_files(iff)) THEN
831       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
832     $o_wake_deltat%name,
833     $                     itau_w,wake_deltat)
834        ENDIF
835
836        IF (o_wake_deltaq%flag(iff)<=lev_files(iff)) THEN
837       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
838     $o_wake_deltaq%name,
839     $                    itau_w,wake_deltaq)
840        ENDIF
841
842        IF (o_wake_omg%flag(iff)<=lev_files(iff)) THEN
843       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
844     s                    o_wake_omg%name,itau_w,wake_omg)
845        ENDIF
846
847         IF (o_dtwak%flag(iff)<=lev_files(iff)) THEN
848           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)
849     &                                        /pdtphys
850           CALL histwrite_phy(nid_files(iff),
851     $clef_stations(iff),
852     &                       o_dtwak%name,itau_w,zx_tmp_fi3d)
853         ENDIF
854
855        IF (o_dqwak%flag(iff)<=lev_files(iff)) THEN
856        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
857        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
858     &                     o_dqwak%name,itau_w,zx_tmp_fi3d)
859        ENDIF
860      ENDIF ! iflag_wake.EQ.1
861
862        IF (o_Vprecip%flag(iff)<=lev_files(iff)) THEN
863       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
864     $o_Vprecip%name,itau_w,Vprecip)
865        ENDIF
866
867        IF (o_ftd%flag(iff)<=lev_files(iff)) THEN
868       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
869     $o_ftd%name,itau_w,ftd)
870        ENDIF
871
872        IF (o_fqd%flag(iff)<=lev_files(iff)) THEN
873       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
874     $o_fqd%name,itau_w,fqd)
875        ENDIF
876      ENDIF !(iflag_con.EQ.3) 
877 
878      IF (type_ocean=='slab ') THEN
879      IF ( o_slab_bils%flag(iff)<=lev_files(iff)) 
880     $     CALL histwrite_phy(
881     $     nid_files(iff),clef_stations(iff),
882     $o_slab_bils%name,itau_w,slab_wfbils)
883
884      ENDIF !type_ocean == force/slab
885
886      IF (o_weakinv%flag(iff)<=lev_files(iff)) THEN
887      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
888     s                  o_weakinv%name,itau_w,weak_inversion)
889      ENDIF
890
891!     IF (o_dthmin%flag(iff)<=lev_files(iff)) THEN
892!     CALL histwrite_phy(nid_files(iff),clef_stations(iff),
893!    $o_dthmin%name,itau_w,dthmin)
894!     ENDIF
895
896       IF (o_cldtau%flag(iff)<=lev_files(iff)) THEN
897       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
898     $o_cldtau%name,itau_w,cldtau)
899       ENDIF
900
901       IF (o_cldemi%flag(iff)<=lev_files(iff)) THEN
902       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
903     $o_cldemi%name,itau_w,cldemi)
904       ENDIF
905
906      IF (o_pr_con_l%flag(iff)<=lev_files(iff)) THEN
907      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
908     s         o_pr_con_l%name,itau_w,pmflxr(:,1:klev))
909      ENDIF
910
911      IF (o_pr_con_i%flag(iff)<=lev_files(iff)) THEN
912      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
913     s         o_pr_con_i%name,itau_w,pmflxs(:,1:klev))
914      ENDIF
915
916      IF (o_pr_lsc_l%flag(iff)<=lev_files(iff)) THEN
917      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
918     s        o_pr_lsc_l%name,itau_w,prfl(:,1:klev))
919      ENDIF
920
921      IF (o_pr_lsc_i%flag(iff)<=lev_files(iff)) THEN
922      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
923     s        o_pr_lsc_i%name,itau_w,psfl(:,1:klev))
924      ENDIF
925
926      IF (o_re%flag(iff)<=lev_files(iff)) THEN
927      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
928     $o_re%name,itau_w,re)
929      ENDIF
930
931      IF (o_fl%flag(iff)<=lev_files(iff)) THEN
932      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
933     $o_fl%name,itau_w,fl)
934      ENDIF
935
936
937
938      IF (o_rh2m%flag(iff)<=lev_files(iff)) THEN
939      DO i=1, klon
940       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
941      ENDDO
942      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
943     $o_rh2m%name,itau_w,zx_tmp_fi2d)
944      ENDIF
945
946      IF (.NOT.clef_stations(iff)) THEN
947      IF (o_rh2m_min%flag(iff)<=lev_files(iff)) THEN
948      DO i=1, klon
949       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
950      ENDDO
951      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
952     $o_rh2m_min%name,
953     s               itau_w,zx_tmp_fi2d)
954      ENDIF
955
956      IF (o_rh2m_max%flag(iff)<=lev_files(iff)) THEN
957      DO i=1, klon
958       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
959      ENDDO
960      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
961     $o_rh2m_max%name,
962     s              itau_w,zx_tmp_fi2d)
963      ENDIF
964      ENDIF
965
966
967      IF (o_qsat2m%flag(iff)<=lev_files(iff)) THEN
968      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
969     $o_qsat2m%name,itau_w,qsat2m)
970      ENDIF
971
972      IF (o_tpot%flag(iff)<=lev_files(iff)) THEN
973      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
974     $o_tpot%name,itau_w,tpot)
975      ENDIF
976
977       IF (o_tpote%flag(iff)<=lev_files(iff)) THEN
978      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
979     $o_tpote%name,itau_w,tpote)
980       ENDIF
981
982      IF (o_SWnetOR%flag(iff)<=lev_files(iff)) THEN
983      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
984      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
985     s                   o_SWnetOR%name,itau_w, zx_tmp_fi2d)
986      ENDIF
987
988      IF (o_SWdownOR%flag(iff)<=lev_files(iff)) THEN
989      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
990      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
991     s                   o_SWdownOR%name,itau_w, zx_tmp_fi2d)
992      ENDIF
993
994      IF (o_LWdownOR%flag(iff)<=lev_files(iff)) THEN
995      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
996     s                  o_LWdownOR%name,itau_w,sollwdown)
997      ENDIF
998
999      IF (o_snowl%flag(iff)<=lev_files(iff)) THEN
1000      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1001     $o_snowl%name,itau_w,snow_lsc)
1002      ENDIF
1003
1004      IF (o_solldown%flag(iff)<=lev_files(iff)) THEN
1005      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1006     s                   o_solldown%name,itau_w,sollwdown)
1007      ENDIF
1008
1009      IF (o_dtsvdfo%flag(iff)<=lev_files(iff)) THEN
1010      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1011     s                 o_dtsvdfo%name,itau_w,d_ts(:,is_oce))
1012      ENDIF
1013
1014      IF (o_dtsvdft%flag(iff)<=lev_files(iff)) THEN
1015      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1016     s                   o_dtsvdft%name,itau_w,d_ts(:,is_ter))
1017      ENDIF
1018
1019       IF (o_dtsvdfg%flag(iff)<=lev_files(iff)) THEN
1020        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1021     $                   o_dtsvdfg%name,itau_w, d_ts(:,is_lic))
1022       ENDIF
1023
1024       IF (o_dtsvdfi%flag(iff)<=lev_files(iff)) THEN
1025      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1026     s                   o_dtsvdfi%name,itau_w,d_ts(:,is_sic))
1027       ENDIF
1028
1029       IF (o_rugs%flag(iff)<=lev_files(iff)) THEN
1030      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1031     $o_rugs%name,itau_w,zxrugs)
1032       ENDIF
1033
1034! OD550 per species
1035      IF (new_aod .and. (.not. aerosol_couple)) THEN
1036          IF (ok_ade.OR.ok_aie) THEN
1037
1038          IF (o_od550aer%flag(iff)<=lev_files(iff)) THEN
1039             CALL histwrite_phy(nid_files(iff),
1040     $clef_stations(iff),
1041     $o_od550aer%name,itau_w,
1042     $            od550aer)
1043          ENDIF
1044          IF (o_od865aer%flag(iff)<=lev_files(iff)) THEN
1045             CALL histwrite_phy(nid_files(iff),
1046     $clef_stations(iff),
1047     $o_od865aer%name,itau_w,
1048     $            od865aer)
1049          ENDIF
1050          IF (o_absvisaer%flag(iff)<=lev_files(iff)) THEN
1051             CALL histwrite_phy(nid_files(iff),
1052     $clef_stations(iff),
1053     $o_absvisaer%name,itau_w,
1054     $            absvisaer)
1055          ENDIF
1056          IF (o_od550lt1aer%flag(iff)<=lev_files(iff)) THEN
1057            CALL histwrite_phy(nid_files(iff),
1058     $clef_stations(iff),
1059     $o_od550lt1aer%name,itau_w,
1060     $            od550lt1aer)
1061          ENDIF
1062
1063          IF (o_sconcso4%flag(iff)<=lev_files(iff)) THEN
1064              CALL histwrite_phy(nid_files(iff),
1065     $clef_stations(iff),
1066     $o_sconcso4%name,itau_w,
1067     $            sconcso4)
1068          ENDIF
1069          IF (o_sconcoa%flag(iff)<=lev_files(iff)) THEN
1070              CALL histwrite_phy(nid_files(iff),
1071     $clef_stations(iff),
1072     $o_sconcoa%name,itau_w,
1073     $            sconcoa)
1074          ENDIF
1075          IF (o_sconcbc%flag(iff)<=lev_files(iff)) THEN
1076              CALL histwrite_phy(nid_files(iff),
1077     $clef_stations(iff),
1078     $o_sconcbc%name,itau_w,
1079     $            sconcbc)
1080          ENDIF
1081          IF (o_sconcss%flag(iff)<=lev_files(iff)) THEN
1082              CALL histwrite_phy(nid_files(iff),
1083     $clef_stations(iff),
1084     $o_sconcss%name,itau_w,
1085     $            sconcss)
1086          ENDIF
1087          IF (o_sconcdust%flag(iff)<=lev_files(iff)) THEN
1088              CALL histwrite_phy(nid_files(iff),
1089     $clef_stations(iff),
1090     $o_sconcdust%name,itau_w,
1091     $            sconcdust)
1092          ENDIF
1093         
1094          IF (o_concso4%flag(iff)<=lev_files(iff)) THEN
1095              CALL histwrite_phy(nid_files(iff),
1096     $clef_stations(iff),
1097     $o_concso4%name,itau_w,
1098     $            concso4)
1099          ENDIF
1100          IF (o_concoa%flag(iff)<=lev_files(iff)) THEN
1101              CALL histwrite_phy(nid_files(iff),
1102     $clef_stations(iff),
1103     $o_concoa%name,itau_w,
1104     $            concoa)
1105          ENDIF
1106          IF (o_concbc%flag(iff)<=lev_files(iff)) THEN
1107              CALL histwrite_phy(nid_files(iff),
1108     $clef_stations(iff),
1109     $o_concbc%name,itau_w,
1110     $            concbc)
1111          ENDIF
1112          IF (o_concss%flag(iff)<=lev_files(iff)) THEN
1113              CALL histwrite_phy(nid_files(iff),
1114     $clef_stations(iff),
1115     $o_concss%name,itau_w,
1116     $            concss)
1117          ENDIF
1118          IF (o_concdust%flag(iff)<=lev_files(iff)) THEN
1119              CALL histwrite_phy(nid_files(iff),
1120     $clef_stations(iff),
1121     $o_concdust%name,itau_w,
1122     $            concdust)
1123          ENDIF
1124         
1125          IF (o_loadso4%flag(iff)<=lev_files(iff)) THEN
1126              CALL histwrite_phy(nid_files(iff),
1127     $clef_stations(iff),
1128     $o_loadso4%name,itau_w,
1129     $            loadso4)
1130          ENDIF
1131          IF (o_loadoa%flag(iff)<=lev_files(iff)) THEN
1132              CALL histwrite_phy(nid_files(iff),
1133     $clef_stations(iff),
1134     $o_loadoa%name,itau_w,
1135     $            loadoa)
1136          ENDIF
1137          IF (o_loadbc%flag(iff)<=lev_files(iff)) THEN
1138              CALL histwrite_phy(nid_files(iff),
1139     $clef_stations(iff),
1140     $o_loadbc%name,itau_w,
1141     $            loadbc)
1142          ENDIF
1143          IF (o_loadss%flag(iff)<=lev_files(iff)) THEN
1144              CALL histwrite_phy(nid_files(iff),
1145     $clef_stations(iff),
1146     $o_loadss%name,itau_w,
1147     $            loadss)
1148          ENDIF
1149          IF (o_loaddust%flag(iff)<=lev_files(iff)) THEN
1150              CALL histwrite_phy(nid_files(iff),
1151     $clef_stations(iff),
1152     $o_loaddust%name,itau_w,
1153     $            loaddust)
1154          ENDIF
1155         
1156          DO naero = 1, naero_spc
1157            IF (o_tausumaero(naero)%flag(iff)<=lev_files(iff)) THEN
1158                CALL histwrite_phy(nid_files(iff),
1159     $clef_stations(iff),
1160     $              o_tausumaero(naero)%name,itau_w,
1161     $              tausum_aero(:,2,naero) )
1162            ENDIF
1163          END DO
1164          endif
1165      ENDIF
1166     
1167       IF (ok_ade) THEN
1168          IF (o_topswad%flag(iff)<=lev_files(iff)) THEN
1169             CALL histwrite_phy(nid_files(iff),
1170     $clef_stations(iff),
1171     $o_topswad%name,itau_w,
1172     $            topswad_aero)
1173          ENDIF
1174          IF (o_solswad%flag(iff)<=lev_files(iff)) THEN
1175             CALL histwrite_phy(nid_files(iff),
1176     $clef_stations(iff),
1177     $o_solswad%name,itau_w,
1178     $            solswad_aero)
1179          ENDIF
1180
1181!====MS forcing diagnostics
1182        if (new_aod) then             
1183        IF (o_swtoaas_nat%flag(iff)<=lev_files(iff)) THEN
1184        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1185     $o_swtoaas_nat%name,itau_w,
1186     $      topsw_aero(:,1))
1187        ENDIF
1188
1189        IF (o_swsrfas_nat%flag(iff)<=lev_files(iff)) THEN
1190        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1191     $o_swsrfas_nat%name,itau_w,
1192     $      solsw_aero(:,1))
1193        ENDIF
1194
1195        IF (o_swtoacs_nat%flag(iff)<=lev_files(iff)) THEN
1196        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1197     $o_swtoacs_nat%name,itau_w,
1198     $      topsw0_aero(:,1))
1199        ENDIF
1200
1201        IF (o_swsrfcs_nat%flag(iff)<=lev_files(iff)) THEN
1202        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1203     $o_swsrfcs_nat%name,itau_w,
1204     $      solsw0_aero(:,1))
1205        ENDIF
1206 
1207!ant
1208        IF (o_swtoaas_ant%flag(iff)<=lev_files(iff)) THEN
1209        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1210     $o_swtoaas_ant%name,itau_w,
1211     $      topsw_aero(:,2))
1212        ENDIF
1213
1214        IF (o_swsrfas_ant%flag(iff)<=lev_files(iff)) THEN
1215        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1216     $o_swsrfas_ant%name,itau_w,
1217     $      solsw_aero(:,2))
1218        ENDIF
1219
1220        IF (o_swtoacs_ant%flag(iff)<=lev_files(iff)) THEN
1221        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1222     $o_swtoacs_ant%name,itau_w,
1223     $      topsw0_aero(:,2))
1224        ENDIF
1225
1226        IF (o_swsrfcs_ant%flag(iff)<=lev_files(iff)) THEN
1227        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1228     $o_swsrfcs_ant%name,itau_w,
1229     $      solsw0_aero(:,2))
1230        ENDIF
1231
1232!cf
1233
1234        if (.not. aerosol_couple) then
1235        IF (o_swtoacf_nat%flag(iff)<=lev_files(iff)) THEN
1236        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1237     $o_swtoacf_nat%name,itau_w,
1238     $      topswcf_aero(:,1))
1239        ENDIF
1240
1241        IF (o_swsrfcf_nat%flag(iff)<=lev_files(iff)) THEN
1242        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1243     $o_swsrfcf_nat%name,itau_w,
1244     $      solswcf_aero(:,1))
1245        ENDIF
1246
1247        IF (o_swtoacf_ant%flag(iff)<=lev_files(iff)) THEN
1248        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1249     $o_swtoacf_ant%name,itau_w,
1250     $      topswcf_aero(:,2))
1251        ENDIF
1252
1253        IF (o_swsrfcf_ant%flag(iff)<=lev_files(iff)) THEN
1254        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1255     $o_swsrfcf_ant%name,itau_w,
1256     $      solswcf_aero(:,2))
1257        ENDIF
1258
1259        IF (o_swtoacf_zero%flag(iff)<=lev_files(iff)) THEN
1260        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1261     $o_swtoacf_zero%name,itau_w,
1262     $      topswcf_aero(:,3))
1263        ENDIF
1264
1265        IF (o_swsrfcf_zero%flag(iff)<=lev_files(iff)) THEN
1266        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1267     $o_swsrfcf_zero%name,itau_w,
1268     $      solswcf_aero(:,3))
1269        ENDIF
1270        endif
1271
1272        endif ! new_aod
1273!====MS forcing diagnostics
1274
1275       ENDIF
1276
1277       IF (ok_aie) THEN
1278          IF (o_topswai%flag(iff)<=lev_files(iff)) THEN
1279             CALL histwrite_phy(nid_files(iff),
1280     $clef_stations(iff),
1281     $o_topswai%name,itau_w,
1282     $            topswai_aero)
1283          ENDIF
1284          IF (o_solswai%flag(iff)<=lev_files(iff)) THEN
1285             CALL histwrite_phy(nid_files(iff),
1286     $clef_stations(iff),
1287     $o_solswai%name,itau_w,
1288     $            solswai_aero)
1289          ENDIF
1290          IF (o_scdnc%flag(iff)<=lev_files(iff)) THEN
1291             CALL histwrite_phy(nid_files(iff),
1292     $clef_stations(iff),
1293     $o_scdnc%name,itau_w,
1294     $            scdnc)
1295          ENDIF
1296          IF (o_cldncl%flag(iff)<=lev_files(iff)) THEN
1297             CALL histwrite_phy(nid_files(iff),
1298     $clef_stations(iff),
1299     $o_cldncl%name,itau_w,
1300     $            cldncl)
1301          ENDIF
1302         IF (o_reffclws%flag(iff)<=lev_files(iff)) THEN
1303            CALL histwrite_phy(nid_files(iff),
1304     $clef_stations(iff),
1305     $o_reffclws%name,itau_w,
1306     $            reffclws)
1307         ENDIF
1308         IF (o_reffclwc%flag(iff)<=lev_files(iff)) THEN
1309            CALL histwrite_phy(nid_files(iff),
1310     $clef_stations(iff),
1311     $o_reffclwc%name,itau_w,
1312     $            reffclwc)
1313         ENDIF
1314          IF (o_cldnvi%flag(iff)<=lev_files(iff)) THEN
1315             CALL histwrite_phy(nid_files(iff),
1316     $clef_stations(iff),
1317     $o_cldnvi%name,itau_w,
1318     $            cldnvi)
1319          ENDIF
1320          IF (o_lcc%flag(iff)<=lev_files(iff)) THEN
1321             CALL histwrite_phy(nid_files(iff),
1322     $clef_stations(iff),
1323     $o_lcc%name,itau_w,
1324     $            lcc)
1325          ENDIF
1326          IF (o_lcc3d%flag(iff)<=lev_files(iff)) THEN
1327             CALL histwrite_phy(nid_files(iff),
1328     $clef_stations(iff),
1329     $o_lcc3d%name,itau_w,
1330     $            lcc3d)
1331          ENDIF
1332          IF (o_lcc3dcon%flag(iff)<=lev_files(iff)) THEN
1333             CALL histwrite_phy(nid_files(iff),
1334     $clef_stations(iff),
1335     $o_lcc3dcon%name,itau_w,
1336     $            lcc3dcon)
1337          ENDIF
1338          IF (o_lcc3dstra%flag(iff)<=lev_files(iff)) THEN
1339             CALL histwrite_phy(nid_files(iff),
1340     $clef_stations(iff),
1341     $o_lcc3dstra%name,itau_w,
1342     $            lcc3dstra)
1343          ENDIF
1344          IF (o_reffclwtop%flag(iff)<=lev_files(iff)) THEN
1345             CALL histwrite_phy(nid_files(iff),
1346     $clef_stations(iff),
1347     $o_reffclwtop%name,itau_w,
1348     $            reffclwtop)
1349          ENDIF
1350       ENDIF
1351
1352! Champs 3D:
1353       IF (ok_ade .OR. ok_aie) then
1354          IF (o_ec550aer%flag(iff)<=lev_files(iff)) THEN
1355             CALL histwrite_phy(nid_files(iff),
1356     $clef_stations(iff),
1357     $o_ec550aer%name,itau_w,
1358     &            ec550aer)
1359          ENDIF
1360       ENDIF
1361
1362       IF (o_lwcon%flag(iff)<=lev_files(iff)) THEN
1363      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1364     $o_lwcon%name,itau_w,flwc)
1365       ENDIF
1366
1367       IF (o_iwcon%flag(iff)<=lev_files(iff)) THEN
1368      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1369     $o_iwcon%name,itau_w,fiwc)
1370       ENDIF
1371
1372       IF (o_temp%flag(iff)<=lev_files(iff)) THEN
1373      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1374     $o_temp%name,itau_w,t_seri)
1375       ENDIF
1376
1377       IF (o_theta%flag(iff)<=lev_files(iff)) THEN
1378      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1379     $o_theta%name,itau_w,theta)
1380       ENDIF
1381
1382       IF (o_ovapinit%flag(iff)<=lev_files(iff)) THEN
1383      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1384     $o_ovapinit%name,itau_w,
1385     $ qx(:,:,ivap))
1386       ENDIF
1387
1388       IF (o_ovap%flag(iff)<=lev_files(iff)) THEN
1389      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1390     $                   o_ovap%name,itau_w,q_seri)
1391       ENDIF
1392
1393       IF (o_geop%flag(iff)<=lev_files(iff)) THEN
1394      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1395     $o_geop%name,itau_w,zphi)
1396       ENDIF
1397
1398       IF (o_vitu%flag(iff)<=lev_files(iff)) THEN
1399      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1400     $o_vitu%name,itau_w,u_seri)
1401       ENDIF
1402
1403       IF (o_vitv%flag(iff)<=lev_files(iff)) THEN
1404      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1405     $o_vitv%name,itau_w,v_seri)
1406       ENDIF
1407
1408       IF (o_vitw%flag(iff)<=lev_files(iff)) THEN
1409      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1410     $o_vitw%name,itau_w,omega)
1411       ENDIF
1412
1413        IF (o_pres%flag(iff)<=lev_files(iff)) THEN
1414      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1415     $o_pres%name,itau_w,pplay)
1416        ENDIF
1417
1418        IF (o_paprs%flag(iff)<=lev_files(iff)) THEN
1419      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1420     $o_paprs%name,
1421     s                    itau_w,paprs(:,1:klev))
1422        ENDIF
1423
1424        IF (o_zfull%flag(iff)<=lev_files(iff)) THEN
1425         DO i=1, klon
1426          zx_tmp_fi3d1(i,1)= pphis(i)/RG
1427!020611   zx_tmp_fi3d(i,1)= pphis(i)/RG
1428         ENDDO
1429         DO k=1, klev
1430!020611        DO k=1, klev-1
1431         DO i=1, klon
1432!020611         zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (t_seri(i,k) *RD * 
1433          zx_tmp_fi3d1(i,k+1)= zx_tmp_fi3d1(i,k) - (t_seri(i,k) *RD * 
1434     $    (paprs(i,k+1) - paprs(i,k))) / ( pplay(i,k) * RG ) 
1435         ENDDO
1436         ENDDO
1437      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1438     $o_zfull%name,itau_w,zx_tmp_fi3d1(:,2:klevp1))
1439!020611    $o_zfull%name,itau_w,zx_tmp_fi3d)
1440        ENDIF
1441
1442        IF (o_zhalf%flag(iff)<=lev_files(iff)) THEN
1443         DO i=1, klon
1444          zx_tmp_fi3d(i,1)= pphis(i)/RG - (
1445     $    (t_seri(i,1)+zxtsol(i))/2. *RD *
1446     $    (pplay(i,1) - paprs(i,1)))/( (paprs(i,1)+pplay(i,1))/2. * RG)
1447         ENDDO
1448         DO k=1, klev-1
1449         DO i=1, klon
1450          zx_tmp_fi3d(i,k+1)= zx_tmp_fi3d(i,k) - (
1451     $    (t_seri(i,k)+t_seri(i,k+1))/2. *RD * 
1452     $    (pplay(i,k+1) - pplay(i,k))) / ( paprs(i,k) * RG ) 
1453         ENDDO
1454         ENDDO
1455      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1456     $o_zhalf%name,itau_w,zx_tmp_fi3d)
1457        ENDIF
1458
1459       IF (o_rneb%flag(iff)<=lev_files(iff)) THEN
1460      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1461     $o_rneb%name,itau_w,cldfra)
1462       ENDIF
1463
1464       IF (o_rnebcon%flag(iff)<=lev_files(iff)) THEN
1465      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1466     $o_rnebcon%name,itau_w,rnebcon)
1467       ENDIF
1468
1469       IF (o_rhum%flag(iff)<=lev_files(iff)) THEN
1470      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1471     $o_rhum%name,itau_w,zx_rh)
1472       ENDIF
1473
1474      IF (o_ozone%flag(iff)<=lev_files(iff)) THEN
1475         CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
1476     $o_ozone%name, itau_w,
1477     $        wo(:, :, 1) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1478      ENDIF
1479
1480      IF (o_ozone_light%flag(iff)<=lev_files(iff) .and.
1481     $     read_climoz == 2) THEN
1482         CALL histwrite_phy(nid_files(iff),clef_stations(iff), 
1483     $o_ozone_light%name, itau_w,
1484     $        wo(:, :, 2) * dobson_u * 1e3 / zmasse / rmo3 * rmd)
1485      ENDIF
1486
1487       IF (o_dtphy%flag(iff)<=lev_files(iff)) THEN
1488      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1489     $o_dtphy%name,itau_w,d_t)
1490       ENDIF
1491
1492       IF (o_dqphy%flag(iff)<=lev_files(iff)) THEN
1493      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1494     s                  o_dqphy%name,itau_w, d_qx(:,:,ivap))
1495       ENDIF
1496
1497        DO nsrf=1, nbsrf
1498        IF (o_albe_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1499        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
1500        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1501     s                    o_albe_srf(nsrf)%name,itau_w,
1502     $                     zx_tmp_fi2d)
1503        ENDIF
1504
1505        IF (o_rugs_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN 
1506        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
1507        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1508     s                     o_rugs_srf(nsrf)%name,itau_w,
1509     $      zx_tmp_fi2d)
1510        ENDIF
1511
1512        IF (o_ages_srf(nsrf)%flag(iff)<=lev_files(iff)) THEN
1513        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
1514        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1515     s                     o_ages_srf(nsrf)%name,itau_w
1516     $    ,zx_tmp_fi2d)
1517        ENDIF
1518        ENDDO !nsrf=1, nbsrf
1519
1520       IF (o_alb1%flag(iff)<=lev_files(iff)) THEN
1521      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1522     $o_alb1%name,itau_w,albsol1)
1523       ENDIF
1524
1525       IF (o_alb2%flag(iff)<=lev_files(iff)) THEN
1526      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1527     $o_alb2%name,itau_w,albsol2)
1528       ENDIF
1529
1530!FH Sorties pour la couche limite
1531      if (iflag_pbl>1) then
1532      zx_tmp_fi3d=0.
1533      do nsrf=1,nbsrf
1534         do k=1,klev
1535          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k)
1536     $    +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
1537         enddo
1538      enddo
1539       IF (o_tke%flag(iff)<=lev_files(iff)) THEN
1540      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1541     $o_tke%name,itau_w,zx_tmp_fi3d)
1542       ENDIF
1543
1544      IF (.NOT.clef_stations(iff)) THEN
1545       IF (o_tke_max%flag(iff)<=lev_files(iff)) THEN
1546      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1547     s                   o_tke_max%name,itau_w,zx_tmp_fi3d)
1548       ENDIF
1549      ENDIF
1550      endif
1551
1552       IF (o_kz%flag(iff)<=lev_files(iff)) THEN
1553      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1554     $o_kz%name,itau_w,coefh)
1555       ENDIF
1556
1557      IF (.NOT.clef_stations(iff)) THEN
1558       IF (o_kz_max%flag(iff)<=lev_files(iff)) THEN
1559      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1560     $o_kz_max%name,itau_w,coefh)
1561       ENDIF
1562      ENDIF
1563
1564       IF (o_clwcon%flag(iff)<=lev_files(iff)) THEN
1565      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1566     $o_clwcon%name,itau_w,clwcon0)
1567       ENDIF
1568
1569       IF (o_dtdyn%flag(iff)<=lev_files(iff)) THEN
1570      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1571     $o_dtdyn%name,itau_w,d_t_dyn)
1572       ENDIF
1573
1574       IF (o_dqdyn%flag(iff)<=lev_files(iff)) THEN
1575      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1576     $o_dqdyn%name,itau_w,d_q_dyn)
1577       ENDIF
1578
1579       IF (o_dudyn%flag(iff)<=lev_files(iff)) THEN
1580      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1581     $o_dudyn%name,itau_w,d_u_dyn)
1582       ENDIF                                                   
1583
1584       IF (o_dvdyn%flag(iff)<=lev_files(iff)) THEN                 
1585      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1586     $o_dvdyn%name,itau_w,d_v_dyn) 
1587       ENDIF                                                     
1588
1589      IF (o_dtcon%flag(iff)<=lev_files(iff)) THEN
1590      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
1591      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1592     $o_dtcon%name,itau_w,zx_tmp_fi3d)
1593      ENDIF                                                     
1594
1595      if(iflag_thermals.eq.1)then
1596      IF (o_tntc%flag(iff)<=lev_files(iff)) THEN
1597      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys +
1598     $                           d_t_ajsb(1:klon,1:klev)/pdtphys
1599      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1600     $o_tntc%name,itau_w,zx_tmp_fi3d)
1601      ENDIF
1602      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
1603      IF (o_tntc%flag(iff)<=lev_files(iff)) THEN
1604      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys +
1605     $                           d_t_ajs(1:klon,1:klev)/pdtphys +
1606     $                           d_t_wake(1:klon,1:klev)/pdtphys
1607      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1608     $o_tntc%name,itau_w,zx_tmp_fi3d)
1609      ENDIF
1610      endif
1611
1612       IF (o_ducon%flag(iff)<=lev_files(iff)) THEN
1613      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
1614      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1615     $o_ducon%name,itau_w,zx_tmp_fi3d)
1616       ENDIF
1617
1618       IF (o_dqcon%flag(iff)<=lev_files(iff)) THEN
1619      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1620      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1621     $o_dqcon%name,itau_w,zx_tmp_fi3d)
1622       ENDIF
1623
1624      if(iflag_thermals.eq.1)then
1625       IF (o_tnhusc%flag(iff)<=lev_files(iff)) THEN
1626      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
1627      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1628     $o_tnhusc%name,itau_w,zx_tmp_fi3d)
1629       ENDIF
1630      else if(iflag_thermals.gt.1.and.iflag_wake.EQ.1)then
1631      IF (o_tnhusc%flag(iff)<=lev_files(iff)) THEN
1632      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys +
1633     $                           d_q_ajs(1:klon,1:klev)/pdtphys +
1634     $                           d_q_wake(1:klon,1:klev)/pdtphys
1635      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1636     $o_tnhusc%name,itau_w,zx_tmp_fi3d)
1637      ENDIF
1638      endif
1639
1640       IF (o_dtlsc%flag(iff)<=lev_files(iff)) THEN
1641      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
1642      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1643     $o_dtlsc%name,itau_w,zx_tmp_fi3d)
1644       ENDIF
1645
1646       IF (o_dtlschr%flag(iff)<=lev_files(iff)) THEN
1647      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
1648     $                           d_t_eva(1:klon,1:klev))/pdtphys
1649      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1650     s                   o_dtlschr%name,itau_w,zx_tmp_fi3d)
1651       ENDIF
1652
1653       IF (o_dqlsc%flag(iff)<=lev_files(iff)) THEN
1654      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
1655      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1656     $o_dqlsc%name,itau_w,zx_tmp_fi3d)
1657       ENDIF
1658
1659       IF (o_dtvdf%flag(iff)<=lev_files(iff)) THEN
1660      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
1661      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1662     $o_dtvdf%name,itau_w,zx_tmp_fi3d)
1663       ENDIF
1664
1665       IF (o_dqvdf%flag(iff)<=lev_files(iff)) THEN
1666      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1667      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1668     $o_dqvdf%name,itau_w,zx_tmp_fi3d)
1669       ENDIF
1670
1671       IF (o_dteva%flag(iff)<=lev_files(iff)) THEN
1672      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1673      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1674     $o_dteva%name,itau_w,zx_tmp_fi3d)
1675       ENDIF
1676
1677       IF (o_dqeva%flag(iff)<=lev_files(iff)) THEN
1678      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1679      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1680     $o_dqeva%name,itau_w,zx_tmp_fi3d)
1681       ENDIF
1682
1683       IF (o_ptconv%flag(iff)<=lev_files(iff)) THEN
1684      zpt_conv = 0.
1685      where (ptconv) zpt_conv = 1.
1686      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1687     $o_ptconv%name,itau_w,zpt_conv)
1688       ENDIF
1689
1690       IF (o_ratqs%flag(iff)<=lev_files(iff)) THEN
1691      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1692     $o_ratqs%name,itau_w,ratqs)
1693       ENDIF
1694
1695       IF (o_dtthe%flag(iff)<=lev_files(iff)) THEN
1696      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys -
1697     $                           d_t_ajsb(1:klon,1:klev)/pdtphys
1698      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1699     $o_dtthe%name,itau_w,zx_tmp_fi3d)
1700       ENDIF
1701
1702       IF (iflag_thermals.gt.1) THEN
1703        IF (o_ftime_th%flag(iff)<=lev_files(iff)) THEN
1704! Pour l instant 0 a y reflichir pour les thermiques
1705         zx_tmp_fi2d=0. 
1706        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1707     $o_ftime_th%name,
1708     s                     itau_w,zx_tmp_fi2d)
1709        ENDIF
1710
1711        IF (o_f_th%flag(iff)<=lev_files(iff)) THEN
1712        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1713     $o_f_th%name,itau_w,fm_therm)
1714        ENDIF
1715
1716        IF (o_e_th%flag(iff)<=lev_files(iff)) THEN
1717        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1718     $o_e_th%name,itau_w,entr_therm)
1719        ENDIF
1720
1721        IF (o_w_th%flag(iff)<=lev_files(iff)) THEN
1722        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1723     $o_w_th%name,itau_w,zw2)
1724        ENDIF
1725
1726        IF (o_q_th%flag(iff)<=lev_files(iff)) THEN
1727        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1728     $o_q_th%name,itau_w,zqasc)
1729        ENDIF
1730
1731        IF (o_lambda_th%flag(iff)<=lev_files(iff)) THEN
1732        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1733     s                     o_lambda_th%name,itau_w,lambda_th)
1734        ENDIF
1735
1736        IF (o_a_th%flag(iff)<=lev_files(iff)) THEN
1737        CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1738     $o_a_th%name,itau_w,fraca)
1739        ENDIF
1740
1741       IF (o_d_th%flag(iff)<=lev_files(iff)) THEN
1742       CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1743     $o_d_th%name,itau_w,detr_therm)
1744       ENDIF
1745
1746       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1747      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1748     $o_f0_th%name,itau_w,f0)
1749       ENDIF
1750
1751       IF (o_f0_th%flag(iff)<=lev_files(iff)) THEN
1752      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1753     $o_zmax_th%name,itau_w,zmax0)
1754       ENDIF
1755
1756       IF (o_dqthe%flag(iff)<=lev_files(iff)) THEN
1757      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys -
1758     $                           d_q_ajsb(1:klon,1:klev)/pdtphys
1759      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1760     $o_dqthe%name,itau_w,zx_tmp_fi3d)
1761       ENDIF
1762
1763      ENDIF !iflag_thermals
1764
1765       IF (o_dtajs%flag(iff)<=lev_files(iff)) THEN
1766      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
1767      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1768     $o_dtajs%name,itau_w,zx_tmp_fi3d)
1769       ENDIF
1770
1771       IF (o_dqajs%flag(iff)<=lev_files(iff)) THEN
1772      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
1773      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1774     $o_dqajs%name,itau_w,zx_tmp_fi3d)
1775       ENDIF
1776
1777       IF (o_dtswr%flag(iff)<=lev_files(iff)) THEN
1778      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
1779      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1780     $o_dtswr%name,itau_w,zx_tmp_fi3d)
1781       ENDIF
1782
1783       IF (o_dtsw0%flag(iff)<=lev_files(iff)) THEN
1784      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
1785      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1786     $o_dtsw0%name,itau_w,zx_tmp_fi3d)
1787       ENDIF
1788
1789       IF (o_dtlwr%flag(iff)<=lev_files(iff)) THEN
1790      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
1791      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1792     $o_dtlwr%name,itau_w,zx_tmp_fi3d)
1793       ENDIF
1794
1795       IF (o_dtlw0%flag(iff)<=lev_files(iff)) THEN
1796      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
1797      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1798     $o_dtlw0%name,itau_w,zx_tmp_fi3d)
1799       ENDIF
1800
1801       IF (o_dtec%flag(iff)<=lev_files(iff)) THEN
1802      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
1803      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1804     $o_dtec%name,itau_w,zx_tmp_fi3d)
1805       ENDIF
1806
1807       IF (o_duvdf%flag(iff)<=lev_files(iff)) THEN
1808      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
1809      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1810     $o_duvdf%name,itau_w,zx_tmp_fi3d)
1811       ENDIF
1812
1813       IF (o_dvvdf%flag(iff)<=lev_files(iff)) THEN
1814      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
1815      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1816     $o_dvvdf%name,itau_w,zx_tmp_fi3d)
1817       ENDIF
1818
1819       IF (ok_orodr) THEN
1820      IF (o_duoro%flag(iff)<=lev_files(iff)) THEN
1821      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
1822      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1823     $o_duoro%name,itau_w,zx_tmp_fi3d)
1824       ENDIF
1825
1826      IF (o_dvoro%flag(iff)<=lev_files(iff)) THEN
1827      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
1828      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1829     $o_dvoro%name,itau_w,zx_tmp_fi3d)
1830      ENDIF
1831
1832      IF (o_dtoro%flag(iff)<=lev_files(iff)) THEN
1833      zx_tmp_fi3d(1:klon,1:klev)=d_t_oro(1:klon,1:klev)/pdtphys
1834      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1835     $o_dtoro%name,itau_w,zx_tmp_fi3d)
1836      ENDIF
1837       ENDIF
1838
1839        IF (ok_orolf) THEN
1840       IF (o_dulif%flag(iff)<=lev_files(iff)) THEN
1841      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
1842      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1843     $o_dulif%name,itau_w,zx_tmp_fi3d)
1844       ENDIF
1845
1846        IF (o_dvlif%flag(iff)<=lev_files(iff)) THEN
1847      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
1848      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1849     $o_dvlif%name,itau_w,zx_tmp_fi3d)
1850       ENDIF
1851
1852        IF (o_dtlif%flag(iff)<=lev_files(iff)) THEN
1853      zx_tmp_fi3d(1:klon,1:klev)=d_t_lif(1:klon,1:klev)/pdtphys
1854      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1855     $o_dtlif%name,itau_w,zx_tmp_fi3d)
1856       ENDIF
1857        ENDIF
1858
1859       IF (ok_hines) THEN
1860       IF (o_duhin%flag(iff)<=lev_files(iff)) THEN
1861      zx_tmp_fi3d(1:klon,1:klev)=d_u_hin(1:klon,1:klev)/pdtphys
1862      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1863     $o_duhin%name,itau_w,zx_tmp_fi3d)
1864       ENDIF
1865
1866        IF (o_dvhin%flag(iff)<=lev_files(iff)) THEN
1867      zx_tmp_fi3d(1:klon,1:klev)=d_v_hin(1:klon,1:klev)/pdtphys
1868      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1869     $o_dvhin%name,itau_w,zx_tmp_fi3d)
1870       ENDIF
1871
1872        IF (o_dthin%flag(iff)<=lev_files(iff)) THEN
1873      zx_tmp_fi3d(1:klon,1:klev)=d_t_hin(1:klon,1:klev)/pdtphys
1874      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1875     $o_dthin%name,itau_w,zx_tmp_fi3d)
1876       ENDIF
1877        ENDIF
1878
1879       IF (o_rsu%flag(iff)<=lev_files(iff)) THEN
1880      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1881     $o_rsu%name,itau_w,swup)
1882       ENDIF
1883       IF (o_rsd%flag(iff)<=lev_files(iff)) THEN
1884      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1885     $o_rsd%name,itau_w,swdn)
1886       ENDIF
1887       IF (o_rlu%flag(iff)<=lev_files(iff)) THEN
1888      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1889     $o_rlu%name,itau_w,lwup)
1890       ENDIF
1891       IF (o_rld%flag(iff)<=lev_files(iff)) THEN
1892      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1893     $o_rld%name,itau_w,lwdn)
1894       ENDIF
1895
1896       IF (o_rsucs%flag(iff)<=lev_files(iff)) THEN
1897      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1898     $o_rsucs%name,itau_w,swup0)
1899       ENDIF
1900       IF (o_rsdcs%flag(iff)<=lev_files(iff)) THEN
1901      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1902     $o_rsdcs%name,itau_w,swdn0)
1903       ENDIF
1904       IF (o_rlucs%flag(iff)<=lev_files(iff)) THEN
1905      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1906     $o_rlucs%name,itau_w,lwup0)
1907       ENDIF
1908       IF (o_rldcs%flag(iff)<=lev_files(iff)) THEN
1909      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1910     $o_rldcs%name,itau_w,lwdn0)
1911       ENDIF
1912
1913       IF (o_tnt%flag(iff)<=lev_files(iff)) THEN
1914      zx_tmp_fi3d(1:klon,1:klev)=d_t(1:klon,1:klev)+
1915     $d_t_dyn(1:klon,1:klev)
1916      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1917     $o_tnt%name,itau_w,zx_tmp_fi3d)
1918       ENDIF
1919
1920       IF (o_tntr%flag(iff)<=lev_files(iff)) THEN
1921      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY -
1922     $cool(1:klon,1:klev)/RDAY
1923      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1924     $o_tntr%name,itau_w,zx_tmp_fi3d)
1925       ENDIF
1926
1927       IF (o_tntscpbl%flag(iff)<=lev_files(iff)) THEN
1928      zx_tmp_fi3d(1:klon,1:klev)= (d_t_lsc(1:klon,1:klev)+
1929     $                             d_t_eva(1:klon,1:klev)+
1930     $                             d_t_vdf(1:klon,1:klev))/pdtphys
1931      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1932     $o_tntscpbl%name,itau_w,zx_tmp_fi3d)
1933       ENDIF
1934
1935       IF (o_tnhus%flag(iff)<=lev_files(iff)) THEN
1936      zx_tmp_fi3d(1:klon,1:klev)=d_qx(1:klon,1:klev,ivap)+
1937     $d_q_dyn(1:klon,1:klev)
1938      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1939     $o_tnhus%name,itau_w,zx_tmp_fi3d)
1940       ENDIF
1941
1942       IF (o_tnhusscpbl%flag(iff)<=lev_files(iff)) THEN
1943      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys+
1944     $                           d_q_eva(1:klon,1:klev)/pdtphys
1945      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1946     $o_tnhusscpbl%name,itau_w,zx_tmp_fi3d)
1947       ENDIF
1948
1949       IF (o_evu%flag(iff)<=lev_files(iff)) THEN
1950      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1951     $o_evu%name,itau_w,coefm)
1952       ENDIF
1953
1954       IF (o_h2o%flag(iff)<=lev_files(iff)) THEN
1955      zx_tmp_fi3d(1:klon,1:klev)=q_seri(1:klon,1:klev)+
1956     $                           ql_seri(1:klon,1:klev) 
1957      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1958     $o_h2o%name,itau_w,zx_tmp_fi3d)
1959       ENDIF
1960
1961       IF (o_mcd%flag(iff)<=lev_files(iff)) THEN
1962      zx_tmp_fi3d(1:klon,1:klev)=-1 * (dnwd(1:klon,1:klev)+
1963     $                                 dnwd0(1:klon,1:klev)) 
1964      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1965     $o_mcd%name,itau_w,zx_tmp_fi3d)
1966       ENDIF
1967
1968       IF (o_dmc%flag(iff)<=lev_files(iff)) THEN
1969      zx_tmp_fi3d(1:klon,1:klev)=upwd(1:klon,1:klev) +
1970     $  dnwd(1:klon,1:klev)+ dnwd0(1:klon,1:klev) 
1971      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1972     $o_dmc%name,itau_w,zx_tmp_fi3d)
1973       ENDIF
1974
1975       IF (o_ref_liq%flag(iff)<=lev_files(iff)) THEN
1976      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1977     $o_ref_liq%name,itau_w,ref_liq)
1978       ENDIF
1979
1980       IF (o_ref_ice%flag(iff)<=lev_files(iff)) THEN
1981      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1982     $o_ref_ice%name,itau_w,ref_ice)
1983       ENDIF
1984
1985      if (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR.
1986     $ RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR.
1987     $ RCFC12_per.NE.RCFC12_act) THEN
1988
1989       IF (o_rsut4co2%flag(iff)<=lev_files(iff)) THEN
1990      zx_tmp_fi2d(1 : klon) = swupp ( 1 : klon, klevp1 )
1991      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1992     $o_rsut4co2%name,itau_w,zx_tmp_fi2d)
1993       ENDIF
1994
1995       IF (o_rlut4co2%flag(iff)<=lev_files(iff)) THEN
1996      zx_tmp_fi2d(1 : klon) = lwupp ( 1 : klon, klevp1 )
1997      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
1998     $o_rlut4co2%name,itau_w,zx_tmp_fi2d)
1999       ENDIF
2000
2001       IF (o_rsutcs4co2%flag(iff)<=lev_files(iff)) THEN
2002      zx_tmp_fi2d(1 : klon) = swup0p ( 1 : klon, klevp1 )
2003      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2004     $o_rsutcs4co2%name,itau_w,zx_tmp_fi2d)
2005       ENDIF
2006
2007       IF (o_rlutcs4co2%flag(iff)<=lev_files(iff)) THEN
2008      zx_tmp_fi2d(1 : klon) = lwup0p ( 1 : klon, klevp1 )
2009      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2010     $o_rlutcs4co2%name,itau_w,zx_tmp_fi2d)
2011       ENDIF
2012
2013       IF (o_rsu4co2%flag(iff)<=lev_files(iff)) THEN
2014      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2015     $o_rsu4co2%name,itau_w,swupp)
2016       ENDIF
2017
2018       IF (o_rlu4co2%flag(iff)<=lev_files(iff)) THEN
2019      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2020     $o_rlu4co2%name,itau_w,lwupp)
2021       ENDIF
2022
2023       IF (o_rsucs4co2%flag(iff)<=lev_files(iff)) THEN
2024      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2025     $o_rsucs4co2%name,itau_w,swup0p)
2026       ENDIF
2027
2028       IF (o_rlucs4co2%flag(iff)<=lev_files(iff)) THEN
2029      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2030     $o_rlucs4co2%name,itau_w,lwup0p)
2031       ENDIF
2032
2033       IF (o_rsd4co2%flag(iff)<=lev_files(iff)) THEN
2034      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2035     $o_rsd4co2%name,itau_w,swdnp)
2036       ENDIF
2037
2038       IF (o_rld4co2%flag(iff)<=lev_files(iff)) THEN
2039      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2040     $o_rld4co2%name,itau_w,lwdnp)
2041       ENDIF
2042
2043       IF (o_rsdcs4co2%flag(iff)<=lev_files(iff)) THEN
2044      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2045     $o_rsdcs4co2%name,itau_w,swdn0p)
2046       ENDIF
2047
2048       IF (o_rldcs4co2%flag(iff)<=lev_files(iff)) THEN
2049      CALL histwrite_phy(nid_files(iff),clef_stations(iff),
2050     $o_rldcs4co2%name,itau_w,lwdn0p)
2051       ENDIF
2052
2053      endif
2054
2055        IF (nqtot.GE.3 .AND. o_trac(1)%flag(iff)<=lev_files(iff)) THEN
2056           CALL histwrite_phy(nid_files(iff),
2057     $clef_stations(iff),
2058     s          o_trac(1)%name,itau_w,qx(:,:,3))
2059        ENDIF
2060
2061        IF (nqtot.GE.4 .AND. o_trac(2)%flag(iff)<=lev_files(iff)) THEN
2062           CALL histwrite_phy(nid_files(iff),
2063     $clef_stations(iff),
2064     s          o_trac(2)%name,itau_w,qx(:,:,4))
2065        ENDIF
2066
2067
2068
2069      if (ok_sync) then
2070c$OMP MASTER
2071      call histsync(nid_files(iff))
2072c$OMP END MASTER
2073      endif
2074
2075       ENDIF ! clef_files
2076
2077      ENDDO ! iff=1,nfiles
Note: See TracBrowser for help on using the repository browser.