source: LMDZ4/branches/LMDZ4V5.0-LF/libf/phylmd/phys_output_write.h @ 3603

Last change on this file since 3603 was 1285, checked in by Laurent Fairhead, 15 years ago

On sort les nuages totaux entre (0-1) comme les autres nuages
IM

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