source: LMDZ4/trunk/libf/phylmd/phys_output_write.h @ 964

Last change on this file since 964 was 964, checked in by Laurent Fairhead, 16 years ago

Sorties de certaines variables que quand elles sont bien activees
LF

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 37.0 KB
Line 
1      itau_w = itau_phy + itap
2
3      DO iff=1,nfiles
4
5       IF (clef_files(iff)) THEN
6             ndex2d = 0
7             ndex3d = 0
8
9!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
10       IF (flag_phis(iff)<=lev_files(iff)) THEN
11         CALL histwrite_phy(nid_files(iff),
12     $                      "phis",itau_w,pphis)
13       ENDIF
14
15       IF (flag_aire(iff)<=lev_files(iff)) THEN
16       CALL histwrite_phy(nid_files(iff),"aire",itau_w,airephy)
17       ENDIF
18
19       IF (flag_contfracATM(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     $                   "contfracATM",itau_w,zx_tmp_fi2d)
25       ENDIF
26
27       IF (flag_contfracOR(iff)<=lev_files(iff)) THEN
28      CALL histwrite_phy(nid_files(iff),"contfracOR",itau_w,
29     $                   pctsrf_new(:,is_ter))
30       ENDIF
31
32       IF (flag_aireTER(iff)<=lev_files(iff)) THEN
33      CALL histwrite_phy(nid_files(iff),
34     $                  "aireTER",itau_w,paire_ter)
35       ENDIF
36
37!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
38
39       IF (flag_flat(iff)<=lev_files(iff)) THEN
40      CALL histwrite_phy(nid_files(iff),"flat",itau_w,zxfluxlat)
41       ENDIF
42
43       IF (flag_slp(iff)<=lev_files(iff)) THEN
44      CALL histwrite_phy(nid_files(iff),"slp",itau_w,slp)
45       ENDIF
46
47       IF (flag_tsol(iff)<=lev_files(iff)) THEN
48      CALL histwrite_phy(nid_files(iff),"tsol",itau_w,zxtsol)
49       ENDIF
50
51       IF (flag_t2m(iff)<=lev_files(iff)) THEN
52      CALL histwrite_phy(nid_files(iff),"t2m",itau_w,zt2m)
53       ENDIF
54
55       IF (flag_t2m_min(iff)<=lev_files(iff)) THEN
56      CALL histwrite_phy(nid_files(iff),"t2m_min",itau_w,zt2m)
57       ENDIF
58
59       IF (flag_t2m_max(iff)<=lev_files(iff)) THEN
60      CALL histwrite_phy(nid_files(iff),"t2m_max",itau_w,zt2m)
61       ENDIF
62
63       IF (flag_wind10m(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),"wind10m",itau_w,zx_tmp_fi2d)
68       ENDIF
69
70       IF (flag_wind10max(iff)<=lev_files(iff)) THEN
71      DO i=1, klon
72       zx_tmp_fi2d(i)=SQRT(zu10m(i)*zu10m(i)+zv10m(i)*zv10m(i))
73      ENDDO
74      CALL histwrite_phy(nid_files(iff),"wind10max", 
75     $                   itau_w,zx_tmp_fi2d)
76       ENDIF
77
78       IF (flag_sicf(iff)<=lev_files(iff)) THEN
79      DO i = 1, klon
80         zx_tmp_fi2d(i) = pctsrf(i,is_sic)
81      ENDDO
82      CALL histwrite_phy(nid_files(iff),"sicf",itau_w,zx_tmp_fi2d)
83       ENDIF
84
85       IF (flag_q2m(iff)<=lev_files(iff)) THEN
86      CALL histwrite_phy(nid_files(iff),"q2m",itau_w,zq2m)
87       ENDIF
88
89       IF (flag_u10m(iff)<=lev_files(iff)) THEN
90      CALL histwrite_phy(nid_files(iff),"u10m",itau_w,zu10m)
91       ENDIF
92
93       IF (flag_v10m(iff)<=lev_files(iff)) THEN
94      CALL histwrite_phy(nid_files(iff),"v10m",itau_w,zv10m)
95       ENDIF
96
97       IF (flag_psol(iff)<=lev_files(iff)) THEN
98      DO i = 1, klon
99         zx_tmp_fi2d(i) = paprs(i,1)
100      ENDDO
101      CALL histwrite_phy(nid_files(iff),"psol",itau_w,zx_tmp_fi2d)
102       ENDIF
103
104       IF (flag_qsurf(iff)<=lev_files(iff)) THEN
105      CALL histwrite_phy(nid_files(iff),"qsurf",itau_w,zxqsurf)
106       ENDIF
107
108       if (.not. ok_veget) then
109         IF (flag_qsol(iff)<=lev_files(iff)) THEN
110        CALL histwrite_phy(nid_files(iff),"qsol",itau_w,qsol)
111         ENDIF
112       endif
113
114      IF (flag_precip(iff)<=lev_files(iff)) THEN
115       DO i = 1, klon
116         zx_tmp_fi2d(i) = rain_fall(i) + snow_fall(i)
117       ENDDO
118      CALL histwrite_phy(nid_files(iff),"precip",itau_w,zx_tmp_fi2d)
119      ENDIF
120
121       IF (flag_ndayrain(iff)<=lev_files(iff)) THEN
122      CALL histwrite_phy(nid_files(iff),"ndayrain",itau_w,nday_rain)
123       ENDIF
124
125      IF (flag_plul(iff)<=lev_files(iff)) THEN
126       DO i = 1, klon
127         zx_tmp_fi2d(i) = rain_lsc(i) + snow_lsc(i)
128       ENDDO
129      CALL histwrite_phy(nid_files(iff),"plul",itau_w,zx_tmp_fi2d)
130      ENDIF
131
132      IF (flag_pluc(iff)<=lev_files(iff)) THEN
133      DO i = 1, klon
134         zx_tmp_fi2d(i) = rain_con(i) + snow_con(i)
135      ENDDO
136      CALL histwrite_phy(nid_files(iff),"pluc",itau_w,zx_tmp_fi2d)
137      ENDIF
138
139       IF (flag_snow(iff)<=lev_files(iff)) THEN
140      CALL histwrite_phy(nid_files(iff),"snow",itau_w,snow_fall)
141       ENDIF
142
143       IF (flag_evap(iff)<=lev_files(iff)) THEN
144      CALL histwrite_phy(nid_files(iff),"evap",itau_w,evap)
145       ENDIF
146
147       IF (flag_tops(iff)<=lev_files(iff)) THEN
148      CALL histwrite_phy(nid_files(iff),"tops",itau_w,topsw)
149       ENDIF
150
151       IF (flag_tops0(iff)<=lev_files(iff)) THEN
152      CALL histwrite_phy(nid_files(iff),"tops0",itau_w,topsw0)
153       ENDIF
154
155       IF (flag_topl(iff)<=lev_files(iff)) THEN
156      CALL histwrite_phy(nid_files(iff),"topl",itau_w,toplw)
157       ENDIF
158
159       IF (flag_topl0(iff)<=lev_files(iff)) THEN
160      CALL histwrite_phy(nid_files(iff),"topl0",itau_w,toplw0)
161       ENDIF
162
163       IF (flag_SWupTOA(iff)<=lev_files(iff)) THEN
164      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, klevp1 )
165      CALL histwrite_phy(nid_files(iff), "SWupTOA",itau_w,zx_tmp_fi2d)
166       ENDIF
167
168       IF (flag_SWupTOAclr(iff)<=lev_files(iff)) THEN
169      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, klevp1 )
170      CALL histwrite_phy(nid_files(iff), 
171     $                  "SWupTOAclr",itau_w,zx_tmp_fi2d)
172       ENDIF
173
174       IF (flag_SWdnTOA(iff)<=lev_files(iff)) THEN
175      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, klevp1 )
176      CALL histwrite_phy(nid_files(iff), "SWdnTOA",itau_w,zx_tmp_fi2d)
177       ENDIF
178
179       IF (flag_SWdnTOAclr(iff)<=lev_files(iff)) THEN
180      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, klevp1 )
181      CALL histwrite_phy(nid_files(iff), 
182     $                  "SWdnTOAclr",itau_w,zx_tmp_fi2d)
183       ENDIF
184
185       IF (flag_SWup200(iff)<=lev_files(iff)) THEN
186      CALL histwrite_phy(nid_files(iff),"SWup200",itau_w,SWup200)
187       ENDIF
188
189       IF (flag_SWup200clr(iff)<=lev_files(iff)) THEN
190      CALL histwrite_phy(nid_files(iff),"SWup200clr",itau_w,SWup200clr)
191       ENDIF
192
193       IF (flag_SWdn200(iff)<=lev_files(iff)) THEN
194      CALL histwrite_phy(nid_files(iff),"SWdn200",itau_w,SWdn200)
195       ENDIF
196
197       IF (flag_SWdn200clr(iff)<=lev_files(iff)) THEN
198      CALL histwrite_phy(nid_files(iff),"SWdn200clr",itau_w,SWdn200clr)
199       ENDIF
200
201       IF (flag_LWup200(iff)<=lev_files(iff)) THEN
202      CALL histwrite_phy(nid_files(iff),"LWup200",itau_w,LWup200)
203       ENDIF
204
205       IF (flag_LWup200clr(iff)<=lev_files(iff)) THEN
206      CALL histwrite_phy(nid_files(iff),"LWup200clr",itau_w,LWup200clr)
207       ENDIF
208
209       IF (flag_LWdn200(iff)<=lev_files(iff)) THEN
210      CALL histwrite_phy(nid_files(iff),"LWdn200",itau_w,zx_tmp_fi2d)
211       ENDIF
212
213       IF (flag_LWdn200clr(iff)<=lev_files(iff)) THEN
214      CALL histwrite_phy(nid_files(iff),"LWdn200clr",itau_w,zx_tmp_fi2d)
215       ENDIF
216
217       IF (flag_sols(iff)<=lev_files(iff)) THEN
218      CALL histwrite_phy(nid_files(iff),"sols",itau_w,solsw)
219       ENDIF
220
221       IF (flag_sols0(iff)<=lev_files(iff)) THEN
222      CALL histwrite_phy(nid_files(iff),"sols0",itau_w,solsw0)
223       ENDIF
224
225       IF (flag_soll(iff)<=lev_files(iff)) THEN
226      CALL histwrite_phy(nid_files(iff),"soll",itau_w,sollw)
227       ENDIF
228
229       IF (flag_radsol(iff)<=lev_files(iff)) THEN
230      CALL histwrite_phy(nid_files(iff),"radsol",itau_w,radsol)
231       ENDIF
232
233       IF (flag_soll0(iff)<=lev_files(iff)) THEN
234      CALL histwrite_phy(nid_files(iff),"soll0",itau_w,sollw0)
235       ENDIF
236
237       IF (flag_SWupSFC(iff)<=lev_files(iff)) THEN
238      zx_tmp_fi2d(1 : klon) = swup ( 1 : klon, 1 )
239      CALL histwrite_phy(nid_files(iff), "SWupSFC",itau_w,zx_tmp_fi2d)
240       ENDIF
241
242       IF (flag_SWupSFCclr(iff)<=lev_files(iff)) THEN
243      zx_tmp_fi2d(1 : klon) = swup0 ( 1 : klon, 1 )
244      CALL histwrite_phy(nid_files(iff), 
245     $                   "SWupSFCclr",itau_w,zx_tmp_fi2d)
246       ENDIF
247
248       IF (flag_SWdnSFC(iff)<=lev_files(iff)) THEN
249      zx_tmp_fi2d(1 : klon) = swdn ( 1 : klon, 1 )
250      CALL histwrite_phy(nid_files(iff), 
251     $                   "SWdnSFC",itau_w,zx_tmp_fi2d)
252       ENDIF
253
254       IF (flag_SWdnSFCclr(iff)<=lev_files(iff)) THEN
255      zx_tmp_fi2d(1 : klon) = swdn0 ( 1 : klon, 1 )
256      CALL histwrite_phy(nid_files(iff), 
257     $                  "SWdnSFCclr",itau_w,zx_tmp_fi2d)
258       ENDIF
259
260       IF (flag_LWupSFC(iff)<=lev_files(iff)) THEN
261      zx_tmp_fi2d(1:klon)=sollwdown(1:klon)-sollw(1:klon)
262      CALL histwrite_phy(nid_files(iff),
263     $                    "LWupSFC",itau_w,zx_tmp_fi2d)
264       ENDIF
265
266       IF (flag_LWdnSFC(iff)<=lev_files(iff)) THEN
267      CALL histwrite_phy(nid_files(iff),
268     $                   "LWdnSFC",itau_w,sollwdown)
269       ENDIF
270
271       sollwdownclr(1:klon) = -1.*lwdn0(1:klon,1)
272       IF (flag_LWupSFCclr(iff)<=lev_files(iff)) THEN
273      zx_tmp_fi2d(1:klon)=sollwdownclr(1:klon)-sollw0(1:klon)
274      CALL histwrite_phy(nid_files(iff),
275     $                   "LWupSFCclr",itau_w,zx_tmp_fi2d)
276       ENDIF
277
278       IF (flag_LWdnSFCclr(iff)<=lev_files(iff)) THEN
279      CALL histwrite_phy(nid_files(iff),
280     $                   "LWdnSFCclr",itau_w,sollwdownclr)
281       ENDIF
282
283       IF (flag_bils(iff)<=lev_files(iff)) THEN
284      CALL histwrite_phy(nid_files(iff),"bils",itau_w,bils)
285       ENDIF
286
287       IF (flag_sens(iff)<=lev_files(iff)) THEN
288      zx_tmp_fi2d(1:klon)=-1*sens(1:klon)
289      CALL histwrite_phy(nid_files(iff),"sens",itau_w,zx_tmp_fi2d)
290       ENDIF
291
292       IF (flag_fder(iff)<=lev_files(iff)) THEN
293      CALL histwrite_phy(nid_files(iff),"fder",itau_w,fder)
294       ENDIF
295
296       IF (flag_ffonte(iff)<=lev_files(iff)) THEN
297       CALL histwrite_phy(nid_files(iff),"ffonte",itau_w,zxffonte)
298       ENDIF
299
300       IF (flag_fqcalving(iff)<=lev_files(iff)) THEN
301       CALL histwrite_phy(nid_files(iff),
302     $                    "fqcalving",itau_w,zxfqcalving)
303       ENDIF
304
305       IF (flag_fqfonte(iff)<=lev_files(iff)) THEN
306       CALL histwrite_phy(nid_files(iff),
307     $                    "fqfonte",itau_w,zxfqfonte)
308       ENDIF
309
310         DO nsrf = 1, nbsrf
311            IF (flag_pourc_sol(iff)<=lev_files(iff)) THEN
312            zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)*100.
313            CALL histwrite_phy(nid_files(iff),
314     $                     "pourc_"//clnsurf(nsrf),itau_w,
315     $                     zx_tmp_fi2d)
316            ENDIF
317
318          IF (flag_fract_sol(iff)<=lev_files(iff)) THEN
319          zx_tmp_fi2d(1 : klon) = pctsrf( 1 : klon, nsrf)
320          CALL histwrite_phy(nid_files(iff),
321     $                    "fract_"//clnsurf(nsrf),itau_w,
322     $      zx_tmp_fi2d)
323          ENDIF
324
325        IF (flag_taux_sol(iff)<=lev_files(iff)) THEN
326        zx_tmp_fi2d(1 : klon) = fluxu( 1 : klon, 1, nsrf)
327        CALL histwrite_phy(nid_files(iff),
328     $                     "taux_"//clnsurf(nsrf),itau_w,
329     $      zx_tmp_fi2d)
330        ENDIF
331
332        IF (flag_tauy_sol(iff)<=lev_files(iff)) THEN           
333        zx_tmp_fi2d(1 : klon) = fluxv( 1 : klon, 1, nsrf)
334        CALL histwrite_phy(nid_files(iff),
335     $                    "tauy_"//clnsurf(nsrf),itau_w,
336     $      zx_tmp_fi2d)
337        ENDIF
338
339        IF (flag_tsol_sol(iff)<=lev_files(iff)) THEN
340        zx_tmp_fi2d(1 : klon) = ftsol( 1 : klon, nsrf)
341        CALL histwrite_phy(nid_files(iff),
342     $                   "tsol_"//clnsurf(nsrf),itau_w,
343     $      zx_tmp_fi2d)
344        ENDIF
345
346      IF (flag_u10m_sol(iff)<=lev_files(iff)) THEN
347      zx_tmp_fi2d(1 : klon) = u10m(1 : klon, nsrf)
348      CALL histwrite_phy(nid_files(iff),"u10m_"//clnsurf(nsrf),
349     $                 itau_w,zx_tmp_fi2d)
350      ENDIF
351
352      IF (flag_v10m_sol(iff)<=lev_files(iff)) THEN
353      zx_tmp_fi2d(1 : klon) = v10m(1 : klon, nsrf)
354      CALL histwrite_phy(nid_files(iff),"v10m_"//clnsurf(nsrf),
355     $              itau_w,zx_tmp_fi2d)
356      ENDIF
357 
358      IF (flag_t2m_sol(iff)<=lev_files(iff)) THEN
359      zx_tmp_fi2d(1 : klon) = t2m(1 : klon, nsrf)
360      CALL histwrite_phy(nid_files(iff),"t2m_"//clnsurf(nsrf),
361     $           itau_w,zx_tmp_fi2d)
362      ENDIF
363
364       IF (flag_sens_sol(iff)<=lev_files(iff)) THEN
365       zx_tmp_fi2d(1 : klon) = fluxt( 1 : klon, 1, nsrf)
366       CALL histwrite_phy(nid_files(iff),
367     $                     "sens_"//clnsurf(nsrf),itau_w,
368     $      zx_tmp_fi2d)
369       ENDIF
370
371        IF (flag_lat_sol(iff)<=lev_files(iff)) THEN
372        zx_tmp_fi2d(1 : klon) = fluxlat( 1 : klon, nsrf)
373        CALL histwrite_phy(nid_files(iff),
374     $                 "lat_"//clnsurf(nsrf),itau_w,
375     $                                   zx_tmp_fi2d)
376          ENDIF
377
378        IF (flag_flw_sol(iff)<=lev_files(iff)) THEN
379        zx_tmp_fi2d(1 : klon) = fsollw( 1 : klon, nsrf)
380        CALL histwrite_phy(nid_files(iff),
381     $                     "flw_"//clnsurf(nsrf),itau_w,
382     $      zx_tmp_fi2d)
383        ENDIF
384
385        IF (flag_fsw_sol(iff)<=lev_files(iff)) THEN
386        zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, nsrf)
387        CALL histwrite_phy(nid_files(iff),
388     $                     "fsw_"//clnsurf(nsrf),itau_w,
389     $      zx_tmp_fi2d)
390        ENDIF
391
392        IF (flag_wbils_sol(iff)<=lev_files(iff)) THEN
393        zx_tmp_fi2d(1 : klon) = wfbils( 1 : klon, nsrf)
394        CALL histwrite_phy(nid_files(iff),
395     $                     "wbils_"//clnsurf(nsrf),itau_w,
396     $      zx_tmp_fi2d)
397        ENDIF
398
399        IF (flag_wbilo_sol(iff)<=lev_files(iff)) THEN
400        zx_tmp_fi2d(1 : klon) = wfbilo( 1 : klon, nsrf)
401        CALL histwrite_phy(nid_files(iff),
402     $                    "wbilo_"//clnsurf(nsrf),itau_w,
403     $      zx_tmp_fi2d)
404        ENDIF
405
406       if (iflag_pbl>1 .and. lev_histday.gt.10 ) then
407        IF (flag_tke_sol(iff)<=lev_files(iff)) THEN
408        CALL histwrite_phy(nid_files(iff),
409     $                    "tke_"//clnsurf(nsrf),itau_w,
410     $      pbl_tke(:,1:klev,nsrf))
411       ENDIF
412
413        IF (flag_tke_max_sol(iff)<=lev_files(iff)) THEN
414        CALL histwrite_phy(nid_files(iff),
415     $                    "tke_max_"//clnsurf(nsrf),itau_w,
416     $      pbl_tke(:,1:klev,nsrf))
417        ENDIF
418       endif
419      ENDDO
420
421        IF (flag_cdrm(iff)<=lev_files(iff)) THEN
422      CALL histwrite_phy(nid_files(iff),"cdrm",itau_w,cdragm)
423        ENDIF
424
425        IF (flag_cdrh(iff)<=lev_files(iff)) THEN
426      CALL histwrite_phy(nid_files(iff),"cdrh",itau_w,cdragh)
427        ENDIF
428
429        IF (flag_cldl(iff)<=lev_files(iff)) THEN
430      CALL histwrite_phy(nid_files(iff),"cldl",itau_w,cldl)
431        ENDIF
432
433        IF (flag_cldm(iff)<=lev_files(iff)) THEN
434      CALL histwrite_phy(nid_files(iff),"cldm",itau_w,cldm)
435        ENDIF
436
437        IF (flag_cldh(iff)<=lev_files(iff)) THEN
438      CALL histwrite_phy(nid_files(iff),"cldh",itau_w,cldh)
439        ENDIF
440
441        IF (flag_cldt(iff)<=lev_files(iff)) THEN
442      CALL histwrite_phy(nid_files(iff),"cldt", 
443     &                   itau_w,cldt*100)
444        ENDIF
445
446        IF (flag_cldq(iff)<=lev_files(iff)) THEN
447      CALL histwrite_phy(nid_files(iff),"cldq",itau_w,cldq)
448        ENDIF
449
450        IF (flag_lwp(iff)<=lev_files(iff)) THEN
451      zx_tmp_fi2d(1:klon) = flwp(1:klon)
452      CALL histwrite_phy(nid_files(iff),"lwp",itau_w,zx_tmp_fi2d)
453        ENDIF
454
455        IF (flag_iwp(iff)<=lev_files(iff)) THEN
456      zx_tmp_fi2d(1:klon) = fiwp(1:klon)
457      CALL histwrite_phy(nid_files(iff),"iwp",itau_w,zx_tmp_fi2d)
458        ENDIF
459
460        IF (flag_ue(iff)<=lev_files(iff)) THEN
461      CALL histwrite_phy(nid_files(iff),"ue",itau_w,ue)
462        ENDIF
463
464        IF (flag_ve(iff)<=lev_files(iff)) THEN
465      CALL histwrite_phy(nid_files(iff),"ve",itau_w,ve)
466        ENDIF
467
468        IF (flag_uq(iff)<=lev_files(iff)) THEN
469      CALL histwrite_phy(nid_files(iff),"uq",itau_w,uq)
470        ENDIF
471
472        IF (flag_vq(iff)<=lev_files(iff)) THEN
473      CALL histwrite_phy(nid_files(iff),"vq",itau_w,vq)
474        ENDIF
475
476      IF(iflag_con.GE.3) THEN ! sb
477        IF (flag_cape(iff)<=lev_files(iff)) THEN
478      CALL histwrite_phy(nid_files(iff),"cape",itau_w,cape)
479        ENDIF
480
481        IF (flag_pbase(iff)<=lev_files(iff)) THEN
482      CALL histwrite_phy(nid_files(iff),"pbase",itau_w,pbase)
483        ENDIF
484
485        IF (flag_ptop(iff)<=lev_files(iff)) THEN
486      CALL histwrite_phy(nid_files(iff),"ptop",itau_w,ema_pct)
487        ENDIF
488
489        IF (flag_fbase(iff)<=lev_files(iff)) THEN
490      CALL histwrite_phy(nid_files(iff),"fbase",itau_w,ema_cbmf)
491        ENDIF
492
493        IF (flag_prw(iff)<=lev_files(iff)) THEN
494      CALL histwrite_phy(nid_files(iff),"prw",itau_w,prw)
495        ENDIF
496      ENDIF !iflag_con .GE. 3
497
498        IF (flag_s_pblh(iff)<=lev_files(iff)) THEN
499      CALL histwrite_phy(nid_files(iff),"s_pblh",itau_w,s_pblh)
500        ENDIF
501
502        IF (flag_s_pblt(iff)<=lev_files(iff)) THEN
503      CALL histwrite_phy(nid_files(iff),"s_pblt",itau_w,s_pblt)
504        ENDIF
505
506        IF (flag_s_lcl(iff)<=lev_files(iff)) THEN
507      CALL histwrite_phy(nid_files(iff),"s_lcl",itau_w,s_lcl)
508        ENDIF
509
510        IF (flag_s_capCL(iff)<=lev_files(iff)) THEN
511      CALL histwrite_phy(nid_files(iff),"s_capCL",itau_w,s_capCL)
512        ENDIF
513
514        IF (flag_s_oliqCL(iff)<=lev_files(iff)) THEN
515      CALL histwrite_phy(nid_files(iff),"s_oliqCL",itau_w,s_oliqCL)
516        ENDIF
517
518        IF (flag_s_cteiCL(iff)<=lev_files(iff)) THEN
519      CALL histwrite_phy(nid_files(iff),"s_cteiCL",itau_w,s_cteiCL)
520        ENDIF
521
522        IF (flag_s_therm(iff)<=lev_files(iff)) THEN
523      CALL histwrite_phy(nid_files(iff),"s_therm",itau_w,s_therm)
524        ENDIF
525
526        IF (flag_s_trmb1(iff)<=lev_files(iff)) THEN
527      CALL histwrite_phy(nid_files(iff),"s_trmb1",itau_w,s_trmb1)
528        ENDIF
529
530        IF (flag_s_trmb2(iff)<=lev_files(iff)) THEN
531      CALL histwrite_phy(nid_files(iff),"s_trmb2",itau_w,s_trmb2)
532        ENDIF
533
534        IF (flag_s_trmb3(iff)<=lev_files(iff)) THEN
535      CALL histwrite_phy(nid_files(iff),"s_trmb3",itau_w,s_trmb3)
536        ENDIF
537
538! Champs interpolles sur des niveaux de pression
539! if=1 on ecrit u v w phi sur 850 700 500 200 au niv 1
540! if=2 on ecrit w et ph 500 seulement au niv 1
541!        et u v sur 850 700 500 200
542! if=3 on ecrit ph a 500 seulement au niv 1
543!      on ecrit u v t q a 850 700 500 200 au niv 3
544
545        DO k=1, nlevSTD
546         IF(k.GE.2.AND.k.LE.12) bb2=clevSTD(k)
547         IF(k.GE.13.AND.k.LE.17) bb3=clevSTD(k)
548         IF(bb2.EQ."850".OR.bb2.EQ."700".OR.
549     $      bb2.EQ."500".OR.bb2.EQ."200") THEN
550
551! a refaire correctement !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
552       IF (flag_ulevsSTD(iff)<=lev_files(iff)) THEN
553       CALL histwrite_phy(nid_files(iff),"u"//bb2, 
554     & itau_w,ulevSTD(:,k))
555       ENDIF
556
557       IF (flag_vlevsSTD(iff)<=lev_files(iff)) THEN
558      CALL histwrite_phy(nid_files(iff),"v"//bb2, 
559     & itau_w,vlevSTD(:,k))
560       ENDIF
561
562       IF (flag_wlevsSTD(iff)<=lev_files(iff)) THEN
563      CALL histwrite_phy(nid_files(iff),"w"//bb2, 
564     & itau_w,wlevSTD(:,k))
565       ENDIF
566
567       IF (flag_philevsSTD(iff)<=lev_files(iff)) THEN
568      CALL histwrite_phy(nid_files(iff),
569     $                  "phi"//bb2, 
570     &               itau_w,philevSTD(:,k))
571       ENDIF
572
573       IF (flag_qlevsSTD(iff)<=lev_files(iff)) THEN
574      CALL histwrite_phy(nid_files(iff),"q"//bb2, 
575     & itau_w, qlevSTD(:,k))
576       ENDIF
577
578       IF (flag_tlevsSTD(iff)<=lev_files(iff)) THEN
579      CALL histwrite_phy(nid_files(iff),"t"//bb2, 
580     & itau_w, tlevSTD(:,k))
581       ENDIF
582
583       ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR.
584       ENDDO
585
586!IM diagnostiques flux ocean-atm ou ocean-glace de mer
587!IM pour utilisation dans un modele de "slab" ocean
588
589      IF (flag_fluxo(iff)<=lev_files(iff)) THEN
590      DO i=1, klon
591       IF (pctsrf(i,is_oce).GT.epsfra) THEN
592        zx_tmp_fi2d(i) = fluxo(i)
593       ELSE
594        zx_tmp_fi2d(i) = 0.
595       ENDIF
596      ENDDO
597      CALL histwrite_phy(nid_files(iff),"fluxo",itau_w,zx_tmp_fi2d)
598      ENDIF
599
600      IF (flag_fluxg(iff)<=lev_files(iff)) THEN
601      DO i=1, klon
602       IF (pctsrf(i,is_sic).GT.epsfra) THEN
603        zx_tmp_fi2d(i) = fluxg(i)
604       ELSE
605        zx_tmp_fi2d(i) = 0.
606       ENDIF
607      ENDDO
608      CALL histwrite_phy(nid_files(iff),"fluxg",itau_w,zx_tmp_fi2d)
609      ENDIF
610
611      IF (flag_t_oce_sic(iff)<=lev_files(iff)) THEN
612      DO i=1, klon
613       IF (pctsrf(i,is_oce).GT.epsfra.OR.
614     $     pctsrf(i,is_sic).GT.epsfra) THEN
615        zx_tmp_fi2d(i) = (ftsol(i, is_oce) * pctsrf(i,is_oce)+
616     $                   ftsol(i, is_sic) * pctsrf(i,is_sic))/
617     $                   (pctsrf(i,is_oce)+pctsrf(i,is_sic))
618       ELSE
619        zx_tmp_fi2d(i) = 273.15
620       ENDIF
621      ENDDO
622      CALL histwrite_phy(nid_files(iff),"t_oce_sic",itau_w,zx_tmp_fi2d)
623      ENDIF
624
625      IF (OCEAN.EQ.'force ') THEN
626      IF (flag_lmt_bils(iff)<=lev_files(iff)) THEN
627      DO i=1, klon
628      IF((pctsrf(i,is_oce).GT.epsfra).OR.
629     $   (pctsrf(i,is_sic).GT.epsfra)) THEN
630       zx_tmp_fi2d(i) = (radsol(i) + fluxo(i))*pctsrf(i,is_oce)+
631     $                  fluxg(i)*pctsrf(i,is_sic)
632      ELSE
633       zx_tmp_fi2d(i) = 1.E+20
634      ENDIF
635      ENDDO
636      CALL histwrite_phy(nid_files(iff),"lmt_bils",itau_w,zx_tmp_fi2d)
637      ENDIF
638
639      IF (iflag_coupl.EQ.1) THEN
640       IF (flag_ale_bl(iff)<=lev_files(iff)) THEN
641       CALL histwrite_phy(nid_files(iff),"ale_bl",itau_w,ale_bl)
642       ENDIF
643       IF (flag_alp_bl(iff)<=lev_files(iff)) THEN
644       CALL histwrite_phy(nid_files(iff),"alp_bl",itau_w,alp_bl)
645       ENDIF
646      ENDIF !iflag_coupl.EQ.1
647
648      IF (iflag_wake.EQ.1) THEN
649       IF (flag_ale_wk(iff)<=lev_files(iff)) THEN
650       CALL histwrite_phy(nid_files(iff),"ale_wk",itau_w,ale_wake)
651       ENDIF
652       IF (flag_alp_wk(iff)<=lev_files(iff)) THEN
653       CALL histwrite_phy(nid_files(iff),"alp_wk",itau_w,alp_wake)
654       ENDIF
655      ENDIF
656
657      ELSE IF (OCEAN.EQ.'slab  ') THEN
658
659      IF (flag_slab_bils(iff)<=lev_files(iff)) THEN
660      DO i=1, klon
661      IF((pctsrf(i,is_oce).GT.epsfra).OR.
662     $   (pctsrf(i,is_sic).GT.epsfra)) THEN
663       zx_tmp_fi2d(i) = (radsol(i) + fluxo(i))*pctsrf(i,is_oce)+
664     $                  fluxg(i)*pctsrf(i,is_sic)
665      ELSE
666       zx_tmp_fi2d(i) = 1.E+20
667      ENDIF
668      ENDDO
669      CALL histwrite_phy(nid_files(iff),"slab_bils",itau_w,zx_tmp_fi2d)
670      ENDIF
671
672      IF (flag_tslab(iff)<=lev_files(iff)) THEN
673      DO i=1, klon
674       IF(pctsrf(i,is_oce).GT.epsfra.OR.
675     $    pctsrf(i,is_sic).GT.epsfra) THEN
676        zx_tmp_fi2d(i)=tslab(i)
677       ELSE
678        zx_tmp_fi2d(i) = 1.E+20
679       ENDIF
680      ENDDO !i=1, klon
681      CALL histwrite_phy(nid_files(iff),"tslab",itau_w,zx_tmp_fi2d)
682      ENDIF
683
684      IF (flag_seaice(iff)<=lev_files(iff)) THEN
685      CALL histwrite_phy(nid_files(iff),"seaice",itau_w,seaice)
686      ENDIF
687
688      IF (flag_siceh(iff)<=lev_files(iff)) THEN
689      CALL histwrite_phy(nid_files(iff),"siceh",itau_w, seaice/1000.)
690      ENDIF
691      ENDIF !OCEAN.EQ.force/slab
692
693      IF (flag_weakinv(iff)<=lev_files(iff)) THEN
694      CALL histwrite_phy(nid_files(iff),"weakinv",itau_w,weak_inversion)
695      ENDIF
696
697      IF (flag_dthmin(iff)<=lev_files(iff)) THEN
698      CALL histwrite_phy(nid_files(iff),"dthmin",itau_w,dthmin)
699      ENDIF
700
701#ifdef histISCCP
702      IF(ok_isccp) THEN
703       IF (flag_meantaucld(iff)<=lev_files(iff)) THEN
704       CALL histwrite_phy(nid_files(iff),"meantaucld",itau_w,meantaucld)
705       ENDIF
706      ENDIF !(ok_isccp)
707#endif
708
709       IF (flag_cldtau(iff)<=lev_files(iff)) THEN
710       CALL histwrite_phy(nid_files(iff),"cldtau",itau_w,cldtau)
711       ENDIF
712
713       IF (flag_cldemi(iff)<=lev_files(iff)) THEN
714       CALL histwrite_phy(nid_files(iff),"cldemi",itau_w,cldemi)
715       ENDIF
716
717       IF (flag_pr_con_l(iff)<=lev_files(iff)) THEN
718       CALL histwrite_phy(nid_files(iff),"pmflxr",itau_w,pmflxr)
719       ENDIF
720
721       IF (flag_pr_con_i(iff)<=lev_files(iff)) THEN
722       CALL histwrite_phy(nid_files(iff),"pmflxs",itau_w,pmflxs)
723       ENDIF
724
725       IF (flag_pr_lsc_l(iff)<=lev_files(iff)) THEN
726       CALL histwrite_phy(nid_files(iff),"prfl",itau_w,prfl)
727       ENDIF
728
729       IF (flag_pr_lsc_i(iff)<=lev_files(iff)) THEN
730       CALL histwrite_phy(nid_files(iff),"psfl",itau_w,psfl)
731       ENDIF
732
733      IF (flag_rh2m(iff)<=lev_files(iff)) THEN
734      DO i=1, klon
735       zx_tmp_fi2d(i)=MIN(100.,rh2m(i)*100.)
736      ENDDO
737      CALL histwrite_phy(nid_files(iff),"rh2m",itau_w,zx_tmp_fi2d)
738      ENDIF
739
740      IF (flag_qsat2m(iff)<=lev_files(iff)) THEN
741      CALL histwrite_phy(nid_files(iff),"qsat2m",itau_w,qsat2m)
742      ENDIF
743
744      IF (flag_tpot(iff)<=lev_files(iff)) THEN
745      CALL histwrite_phy(nid_files(iff),"tpot",itau_w,tpot)
746      ENDIF
747
748       IF (flag_tpote(iff)<=lev_files(iff)) THEN
749      CALL histwrite_phy(nid_files(iff),"tpote",itau_w,tpote)
750       ENDIF
751
752      IF (flag_SWnetOR(iff)<=lev_files(iff)) THEN
753      zx_tmp_fi2d(1 : klon) = fsolsw( 1 : klon, is_ter)
754      CALL histwrite_phy(nid_files(iff),"SWnetOR",itau_w, zx_tmp_fi2d)
755      ENDIF
756
757      IF (flag_SWdownOR(iff)<=lev_files(iff)) THEN
758      zx_tmp_fi2d(1:klon) = solsw(1:klon)/(1.-albsol1(1:klon))
759      CALL histwrite_phy(nid_files(iff),"SWdownOR",itau_w, zx_tmp_fi2d)
760      ENDIF
761
762      IF (flag_LWdownOR(iff)<=lev_files(iff)) THEN
763      CALL histwrite_phy(nid_files(iff),"LWdownOR",itau_w,sollwdown)
764      ENDIF
765
766      IF (flag_snowl(iff)<=lev_files(iff)) THEN
767      CALL histwrite_phy(nid_files(iff),"snowl",itau_w,snow_lsc)
768      ENDIF
769
770      IF (flag_cape_max(iff)<=lev_files(iff)) THEN
771      CALL histwrite_phy(nid_files(iff),"cape_max",itau_w,cape)
772      ENDIF
773
774      IF (flag_solldown(iff)<=lev_files(iff)) THEN
775      CALL histwrite_phy(nid_files(iff),"solldown",itau_w,sollwdown)
776      ENDIF
777
778      IF (flag_dtsvdfo(iff)<=lev_files(iff)) THEN
779      CALL histwrite_phy(nid_files(iff),"dtsvdfo",itau_w,d_ts(:,is_oce))
780      ENDIF
781
782      IF (flag_dtsvdft(iff)<=lev_files(iff)) THEN
783      CALL histwrite_phy(nid_files(iff),"dtsvdft",itau_w,d_ts(:,is_ter))
784      ENDIF
785
786       IF (flag_dtsvdfg(iff)<=lev_files(iff)) THEN
787        CALL histwrite_phy(nid_files(iff),
788     $                     "dtsvdfg",itau_w, d_ts(:,is_lic))
789       ENDIF
790
791       IF (flag_dtsvdfi(iff)<=lev_files(iff)) THEN
792      CALL histwrite_phy(nid_files(iff),"dtsvdfi",itau_w,d_ts(:,is_sic))
793       ENDIF
794
795       IF (flag_rugs(iff)<=lev_files(iff)) THEN
796      CALL histwrite_phy(nid_files(iff),"rugs",itau_w,zxrugs)
797       ENDIF
798
799! Champs 3D:
800       IF (flag_lwcon(iff)<=lev_files(iff)) THEN
801      CALL histwrite_phy(nid_files(iff),"lwcon",itau_w,flwc)
802       ENDIF
803
804       IF (flag_iwcon(iff)<=lev_files(iff)) THEN
805      CALL histwrite_phy(nid_files(iff),"iwcon",itau_w,fiwc)
806       ENDIF
807
808       IF (flag_temp(iff)<=lev_files(iff)) THEN
809      CALL histwrite_phy(nid_files(iff),"temp",itau_w,t_seri)
810       ENDIF
811
812       IF (flag_theta(iff)<=lev_files(iff)) THEN
813      CALL histwrite_phy(nid_files(iff),"theta",itau_w,theta)
814       ENDIF
815
816       IF (flag_ovap(iff)<=lev_files(iff)) THEN
817      CALL histwrite_phy(nid_files(iff),"ovap",itau_w,qx(:,:,ivap))
818       ENDIF
819
820       IF (flag_geop(iff)<=lev_files(iff)) THEN
821      CALL histwrite_phy(nid_files(iff),"geop",itau_w,zphi)
822       ENDIF
823
824       IF (flag_vitu(iff)<=lev_files(iff)) THEN
825      CALL histwrite_phy(nid_files(iff),"vitu",itau_w,u_seri)
826       ENDIF
827
828       IF (flag_vitv(iff)<=lev_files(iff)) THEN
829      CALL histwrite_phy(nid_files(iff),"vitv",itau_w,v_seri)
830       ENDIF
831
832       IF (flag_vitw(iff)<=lev_files(iff)) THEN
833      CALL histwrite_phy(nid_files(iff),"vitw",itau_w,omega)
834       ENDIF
835
836        IF (flag_pres(iff)<=lev_files(iff)) THEN
837      CALL histwrite_phy(nid_files(iff),"pres",itau_w,pplay)
838        ENDIF
839
840       IF (flag_rneb(iff)<=lev_files(iff)) THEN
841      CALL histwrite_phy(nid_files(iff),"rneb",itau_w,cldfra)
842       ENDIF
843
844       IF (flag_rnebcon(iff)<=lev_files(iff)) THEN
845      CALL histwrite_phy(nid_files(iff),"rnebcon",itau_w,rnebcon)
846       ENDIF
847
848       IF (flag_rhum(iff)<=lev_files(iff)) THEN
849      CALL histwrite_phy(nid_files(iff),"rhum",itau_w,zx_rh)
850       ENDIF
851
852      IF (flag_ozone(iff)<=lev_files(iff)) THEN
853      DO k=1, klev
854       DO i=1, klon
855         zx_tmp_fi3d(i,k)=wo(i,k)*RG/46.6968
856     $                    /(paprs(i,k)-paprs(i,k+1))
857     $                    *(paprs(i,1)/101325.0)
858       ENDDO !i
859      ENDDO !k
860      CALL histwrite_phy(nid_files(iff),"ozone",itau_w,zx_tmp_fi3d)
861      ENDIF
862
863       IF (flag_upwd(iff)<=lev_files(iff)) THEN
864      CALL histwrite_phy(nid_files(iff),"upwd",itau_w,upwd)
865       ENDIF
866
867       IF (flag_dtphy(iff)<=lev_files(iff)) THEN
868      CALL histwrite_phy(nid_files(iff),"dtphy",itau_w,d_t)
869       ENDIF
870
871       IF (flag_dqphy(iff)<=lev_files(iff)) THEN
872      CALL histwrite_phy(nid_files(iff),"dqphy",itau_w, d_qx(:,:,ivap))
873       ENDIF
874
875        DO nsrf=1, nbsrf
876        IF (flag_albe_sol(iff)<=lev_files(iff)) THEN
877        zx_tmp_fi2d(1 : klon) = falb1( 1 : klon, nsrf)
878        CALL histwrite_phy(nid_files(iff),"albe_"//clnsurf(nsrf),itau_w,
879     $      zx_tmp_fi2d)
880        ENDIF
881
882        IF (flag_rugs_sol(iff)<=lev_files(iff)) THEN 
883        zx_tmp_fi2d(1 : klon) = frugs( 1 : klon, nsrf)
884        CALL histwrite_phy(nid_files(iff),"rugs_"//clnsurf(nsrf),itau_w,
885     $      zx_tmp_fi2d)
886        ENDIF
887
888        IF (flag_ages_sol(iff)<=lev_files(iff)) THEN
889        zx_tmp_fi2d(1 : klon) = agesno( 1 : klon, nsrf)
890        CALL histwrite_phy(nid_files(iff),"ages_"//clnsurf(nsrf),itau_w
891     $    ,zx_tmp_fi2d)
892        ENDIF
893        ENDDO !nsrf=1, nbsrf
894
895       IF (flag_albs(iff)<=lev_files(iff)) THEN
896      CALL histwrite_phy(nid_files(iff),"albs",itau_w,albsol1)
897       ENDIF
898
899       IF (flag_albslw(iff)<=lev_files(iff)) THEN
900      CALL histwrite_phy(nid_files(iff),"albslw",itau_w,albsol2)
901       ENDIF
902
903!FH Sorties pour la couche limite
904      if (iflag_pbl>1) then
905      zx_tmp_fi3d=0.
906      do nsrf=1,nbsrf
907         do k=1,klev
908          zx_tmp_fi3d(:,k)=zx_tmp_fi3d(:,k)
909     $    +pctsrf(:,nsrf)*pbl_tke(:,k,nsrf)
910         enddo
911      enddo
912       IF (flag_tke(iff)<=lev_files(iff)) THEN
913      CALL histwrite_phy(nid_files(iff),"tke",itau_w,zx_tmp_fi3d)
914       ENDIF
915
916       IF (flag_tke_max(iff)<=lev_files(iff)) THEN
917      CALL histwrite_phy(nid_files(iff),"tke_max",itau_w,zx_tmp_fi3d)
918       ENDIF
919      endif
920
921       IF (flag_kz(iff)<=lev_files(iff)) THEN
922      CALL histwrite_phy(nid_files(iff),"kz",itau_w,ycoefh)
923       ENDIF
924
925       IF (flag_kz_max(iff)<=lev_files(iff)) THEN
926      CALL histwrite_phy(nid_files(iff),"kz_max",itau_w,ycoefh)
927       ENDIF
928
929       IF (flag_clwcon(iff)<=lev_files(iff)) THEN
930      CALL histwrite_phy(nid_files(iff),"clwcon",itau_w,clwcon0)
931       ENDIF
932
933       IF (flag_Ma(iff)<=lev_files(iff)) THEN
934      CALL histwrite_phy(nid_files(iff),"Ma",itau_w,Ma)
935       ENDIF
936
937       IF (flag_dnwd(iff)<=lev_files(iff)) THEN
938      CALL histwrite_phy(nid_files(iff),"dnwd",itau_w,dnwd)
939       ENDIF
940
941       IF (flag_dnwd0(iff)<=lev_files(iff)) THEN
942      CALL histwrite_phy(nid_files(iff),"dnwd0",itau_w,dnwd0)
943       ENDIF
944
945       IF (flag_dtdyn(iff)<=lev_files(iff)) THEN
946      CALL histwrite_phy(nid_files(iff),"dtdyn",itau_w,d_t_dyn)
947       ENDIF
948
949       IF (flag_dqdyn(iff)<=lev_files(iff)) THEN
950      CALL histwrite_phy(nid_files(iff),"dqdyn",itau_w,d_q_dyn)
951       ENDIF
952
953       IF (flag_dtcon(iff)<=lev_files(iff)) THEN
954      zx_tmp_fi3d(1:klon,1:klev)=d_t_con(1:klon,1:klev)/pdtphys
955      CALL histwrite_phy(nid_files(iff),"dtcon",itau_w,zx_tmp_fi3d)
956       ENDIF
957
958       IF (flag_ducon(iff)<=lev_files(iff)) THEN
959      zx_tmp_fi3d(1:klon,1:klev)=d_u_con(1:klon,1:klev)/pdtphys
960      CALL histwrite_phy(nid_files(iff),"ducon",itau_w,zx_tmp_fi3d)
961       ENDIF
962
963       IF (flag_dqcon(iff)<=lev_files(iff)) THEN
964      zx_tmp_fi3d(1:klon,1:klev)=d_q_con(1:klon,1:klev)/pdtphys
965      CALL histwrite_phy(nid_files(iff),"dqcon",itau_w,zx_tmp_fi3d)
966       ENDIF
967
968       IF (iflag_wake == 1) THEN
969         IF (flag_dtwak(iff)<=lev_files(iff)) THEN
970           zx_tmp_fi3d(1:klon,1:klev)=d_t_wake(1:klon,1:klev)           &
971     &                                        /pdtphys
972           CALL histwrite_phy(nid_files(iff),"dtwak",itau_w,zx_tmp_fi3d)
973         ENDIF
974
975        IF (flag_dqwak(iff)<=lev_files(iff)) THEN
976        zx_tmp_fi3d(1:klon,1:klev)=d_q_wake(1:klon,1:klev)/pdtphys
977        CALL histwrite_phy(nid_files(iff),"dqwak",itau_w,zx_tmp_fi3d)
978        ENDIF
979       ENDIF
980
981       IF (flag_dtlsc(iff)<=lev_files(iff)) THEN
982      zx_tmp_fi3d(1:klon,1:klev)=d_t_lsc(1:klon,1:klev)/pdtphys
983      CALL histwrite_phy(nid_files(iff),"dtlsc",itau_w,zx_tmp_fi3d)
984       ENDIF
985
986       IF (flag_dtlschr(iff)<=lev_files(iff)) THEN
987      zx_tmp_fi3d(1:klon, 1:klev)=(d_t_lsc(1:klon,1:klev)+
988     $                           d_t_eva(1:klon,1:klev))/pdtphys
989      CALL histwrite_phy(nid_files(iff),"dtlschr",itau_w,zx_tmp_fi3d)
990       ENDIF
991
992       IF (flag_dqlsc(iff)<=lev_files(iff)) THEN
993      zx_tmp_fi3d(1:klon,1:klev)=d_q_lsc(1:klon,1:klev)/pdtphys
994      CALL histwrite_phy(nid_files(iff),"dqlsc",itau_w,zx_tmp_fi3d)
995       ENDIF
996
997       IF (flag_dtvdf(iff)<=lev_files(iff)) THEN
998      zx_tmp_fi3d(1:klon,1:klev)=d_t_vdf(1:klon,1:klev)/pdtphys
999      CALL histwrite_phy(nid_files(iff),"dtvdf",itau_w,zx_tmp_fi3d)
1000       ENDIF
1001
1002       IF (flag_dqvdf(iff)<=lev_files(iff)) THEN
1003      zx_tmp_fi3d(1:klon,1:klev)=d_q_vdf(1:klon,1:klev)/pdtphys
1004      CALL histwrite_phy(nid_files(iff),"dqvdf",itau_w,zx_tmp_fi3d)
1005       ENDIF
1006
1007       IF (flag_dteva(iff)<=lev_files(iff)) THEN
1008      zx_tmp_fi3d(1:klon,1:klev)=d_t_eva(1:klon,1:klev)/pdtphys
1009      CALL histwrite_phy(nid_files(iff),"dteva",itau_w,zx_tmp_fi3d)
1010       ENDIF
1011
1012       IF (flag_dqeva(iff)<=lev_files(iff)) THEN
1013      zx_tmp_fi3d(1:klon,1:klev)=d_q_eva(1:klon,1:klev)/pdtphys
1014      CALL histwrite_phy(nid_files(iff),"dqeva",itau_w,zx_tmp_fi3d)
1015       ENDIF
1016
1017       IF (flag_ptconv(iff)<=lev_files(iff)) THEN
1018      zpt_conv = 0.
1019      where (ptconv) zpt_conv = 1.
1020      CALL histwrite_phy(nid_files(iff),"ptconv",itau_w,zpt_conv)
1021       ENDIF
1022
1023       IF (flag_ratqs(iff)<=lev_files(iff)) THEN
1024      CALL histwrite_phy(nid_files(iff),"ratqs",itau_w,ratqs)
1025       ENDIF
1026
1027       IF (flag_dtthe(iff)<=lev_files(iff)) THEN
1028      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajs(1:klon,1:klev)/pdtphys
1029      CALL histwrite_phy(nid_files(iff),"dtthe",itau_w,zx_tmp_fi3d)
1030       ENDIF
1031
1032       IF (iflag_thermals.ge.1) THEN
1033        IF (flag_f_th(iff)<=lev_files(iff)) THEN
1034        CALL histwrite_phy(nid_files(iff),"f_th",itau_w,fm_therm)
1035        ENDIF
1036
1037        IF (flag_e_th(iff)<=lev_files(iff)) THEN
1038        CALL histwrite_phy(nid_files(iff),"e_th",itau_w,entr_therm)
1039        ENDIF
1040
1041!       IF (flag_d_th(iff)<=lev_files(iff)) THEN
1042!       CALL histwrite_phy(nid_files(iff),"d_th",itau_w,detr_therm)
1043!       ENDIF
1044       ENDIF !iflag_thermals
1045
1046       IF (flag_f0_th(iff)<=lev_files(iff)) THEN
1047      CALL histwrite_phy(nid_files(iff),"f0_th",itau_w,f0)
1048       ENDIF
1049
1050       IF (flag_f0_th(iff)<=lev_files(iff)) THEN
1051      CALL histwrite_phy(nid_files(iff),"zmax_th",itau_w,zmax0)
1052       ENDIF
1053
1054       IF (flag_dqthe(iff)<=lev_files(iff)) THEN
1055      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajs(1:klon,1:klev)/pdtphys
1056      CALL histwrite_phy(nid_files(iff),"dqthe",itau_w,zx_tmp_fi3d)
1057       ENDIF
1058
1059       IF (flag_dtajs(iff)<=lev_files(iff)) THEN
1060      zx_tmp_fi3d(1:klon,1:klev)=d_t_ajsb(1:klon,1:klev)/pdtphys
1061      CALL histwrite_phy(nid_files(iff),"dtajs",itau_w,zx_tmp_fi3d)
1062       ENDIF
1063
1064       IF (flag_dqajs(iff)<=lev_files(iff)) THEN
1065      zx_tmp_fi3d(1:klon,1:klev)=d_q_ajsb(1:klon,1:klev)/pdtphys
1066      CALL histwrite_phy(nid_files(iff),"dqajs",itau_w,zx_tmp_fi3d)
1067       ENDIF
1068
1069       IF (flag_dtswr(iff)<=lev_files(iff)) THEN
1070      zx_tmp_fi3d(1:klon,1:klev)=heat(1:klon,1:klev)/RDAY
1071      CALL histwrite_phy(nid_files(iff),"dtswr",itau_w,zx_tmp_fi3d)
1072       ENDIF
1073
1074       IF (flag_dtsw0(iff)<=lev_files(iff)) THEN
1075      zx_tmp_fi3d(1:klon,1:klev)=heat0(1:klon,1:klev)/RDAY
1076      CALL histwrite_phy(nid_files(iff),"dtsw0",itau_w,zx_tmp_fi3d)
1077       ENDIF
1078
1079       IF (flag_dtlwr(iff)<=lev_files(iff)) THEN
1080      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool(1:klon,1:klev)/RDAY
1081      CALL histwrite_phy(nid_files(iff),"dtlwr",itau_w,zx_tmp_fi3d)
1082       ENDIF
1083
1084       IF (flag_dtlw0(iff)<=lev_files(iff)) THEN
1085      zx_tmp_fi3d(1:klon,1:klev)=-1.*cool0(1:klon,1:klev)/RDAY
1086      CALL histwrite_phy(nid_files(iff),"dtlw0",itau_w,zx_tmp_fi3d)
1087       ENDIF
1088
1089       IF (flag_dtec(iff)<=lev_files(iff)) THEN
1090      zx_tmp_fi3d(1:klon,1:klev)=d_t_ec(1:klon,1:klev)
1091      CALL histwrite_phy(nid_files(iff),"dtec",itau_w,zx_tmp_fi3d)
1092       ENDIF
1093
1094       IF (flag_duvdf(iff)<=lev_files(iff)) THEN
1095      zx_tmp_fi3d(1:klon,1:klev)=d_u_vdf(1:klon,1:klev)/pdtphys
1096      CALL histwrite_phy(nid_files(iff),"duvdf",itau_w,zx_tmp_fi3d)
1097       ENDIF
1098
1099       IF (flag_dvvdf(iff)<=lev_files(iff)) THEN
1100      zx_tmp_fi3d(1:klon,1:klev)=d_v_vdf(1:klon,1:klev)/pdtphys
1101      CALL histwrite_phy(nid_files(iff),"dvvdf",itau_w,zx_tmp_fi3d)
1102       ENDIF
1103
1104       IF (ok_orodr) THEN
1105      IF (flag_duoro(iff)<=lev_files(iff)) THEN
1106      zx_tmp_fi3d(1:klon,1:klev)=d_u_oro(1:klon,1:klev)/pdtphys
1107      CALL histwrite_phy(nid_files(iff),"duoro",itau_w,zx_tmp_fi3d)
1108       ENDIF
1109
1110      IF (flag_dvoro(iff)<=lev_files(iff)) THEN
1111      zx_tmp_fi3d(1:klon,1:klev)=d_v_oro(1:klon,1:klev)/pdtphys
1112      CALL histwrite_phy(nid_files(iff),"dvoro",itau_w,zx_tmp_fi3d)
1113      ENDIF
1114       ENDIF
1115
1116        IF (ok_orolf) THEN
1117       IF (flag_dulif(iff)<=lev_files(iff)) THEN
1118      zx_tmp_fi3d(1:klon,1:klev)=d_u_lif(1:klon,1:klev)/pdtphys
1119      CALL histwrite_phy(nid_files(iff),"dulif",itau_w,zx_tmp_fi3d)
1120       ENDIF
1121
1122        IF (flag_dvlif(iff)<=lev_files(iff)) THEN
1123      zx_tmp_fi3d(1:klon,1:klev)=d_v_lif(1:klon,1:klev)/pdtphys
1124      CALL histwrite_phy(nid_files(iff),"dvlif",itau_w,zx_tmp_fi3d)
1125       ENDIF
1126        ENDIF
1127
1128       IF (flag_trac(iff)<=lev_files(iff)) THEN
1129         if (nqmax.GE.3) THEN
1130           DO iq=3,nqmax
1131         CALL histwrite_phy(nid_files(iff),tnom(iq),itau_w,qx(:,:,iq))
1132           ENDDO
1133          endif
1134
1135       ENDIF
1136      if (ok_sync) then
1137c$OMP MASTER
1138        call histsync(nid_files(iff))
1139c$OMP END MASTER
1140      endif
1141
1142       ENDIF ! clef_files
1143
1144      ENDDO ! iff=1,nfiles
Note: See TracBrowser for help on using the repository browser.