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

Last change on this file since 1005 was 996, checked in by lsce, 16 years ago
  • Modifications liées au calcul des nouveau sous-fractions
  • Nettoyage de ocean slab : il reste uniquement la version avec glace de mer forcé
  • Nouveaux variables pour distiguer la version et type d'ocean : type_ocean=force/slab/couple, version_ocean=opa8/nemo pour couplé ou version_ocean=sicOBS pour slab

JG

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