source: LMDZ5/trunk/libf/phylmd/phys_output_write.h @ 1675

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

Modifications for inclusion of chimere dust emission module :
u* is passed from the boundary layer parameterization to the physics
main routine (physiq.F) and then to phytrac, traclmdz and change_srf_frac.
The interface of traclmdz is enriched with 4 other variables.
Also u* and the vertically cumulated amount of tracers is added in the
outputs.

Modifications pour l'inclusion du module d'émission de poussière de Chimere :
u* est passé depuis la couche limite vers le programme principal de la
physique (physiq.F) et ensuite à phytrac, traclmdz et change_srf_frac.
L'interface de traclmdz est enrichie avec 4 autres variables.
Les variables u* et les cumuls verticaux des traceurs sont ajoutés
dans les sorties.

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