source: LMDZ5/branches/LMDZ5_AR5/libf/phylmd/phys_output_write.h @ 5434

Last change on this file since 5434 was 1539, checked in by musat, 14 years ago

Ajouts CFMIP2/CMIP5

  • 6eme fichier de sortie "stations" histstn.nc qui necessite 2 fichiers (voir DefLists?): npCFMIP_param.data(_*) contenant le nombre de points (120 pour simulations AMIP, 73 pour aqua) pointlocations.txt(_*) contenant le numero, les coordonnees (lon,lat) et le nom de chaque station
  • flag LOGICAL dans tous les appels histwrite_phy pour pouvoir sortir le fichier histstn.nc

NB: 1) les flags de type phys_ que l'on met dans le physiq.def_L* pour ajouter plus de sorties

necessitent dorenavant 6 valeurs, la 6eme correspondant au fichier histstn.nc

2) par defaut le fichier histstn.nc ne sort pas; pour le sortir ajouter les lignes suivantes

dans physiq.def_L*

### Type de fichier : global (n) ou stations (y)
phys_out_filestations = n n n n n y

  • introduction de 2 jeux de flags pour les taux des GES; taux actuels avec suffixes _act, taux futurs avec "_per" avec 2 appels au rayonnement si taux "_per" different des taux "_act" (utiles pour diags. CFMIP 4CO2)
  • flags "betaCRF" pour calculs CRF pour experiences sensibilite proprietes optiques eau liquide nuageuse avec initialisations par defaut; sinon besoin de fichier beta_crf.data

Ajout flag LOGICAL lCOSP necessaire pour sortir un fichier stations
IM

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