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

Last change on this file since 5442 was 1403, checked in by Laurent Fairhead, 14 years ago

Merged LMDZ4V5.0-dev branch changes r1292:r1399 to trunk.

Validation:
Validation consisted in compiling the HEAD revision of the trunk,
LMDZ4V5.0-dev branch and the merged sources and running different
configurations on local and SX8 machines comparing results.

Local machine: bench configuration, 32x24x11, gfortran

  • IPSLCM5A configuration (comparison between trunk and merged sources):
    • numerical convergence on dynamical fields over 3 days
    • start files are equivalent (except for RN and PB fields)
    • daily history files equivalent
  • MH07 configuration, new physics package (comparison between LMDZ4V5.0-dev branch and merged sources):
    • numerical convergence on dynamical fields over 3 days
    • start files are equivalent (except for RN and PB fields)
    • daily history files equivalent

SX8 machine (brodie), 96x95x39 on 4 processors:

  • IPSLCM5A configuration:
    • start files are equivalent (except for RN and PB fields)
    • monthly history files equivalent
  • MH07 configuration:
    • start files are equivalent (except for RN and PB fields)
    • monthly history files equivalent

Changes to the makegcm and create_make_gcm scripts to take into account
main programs in F90 files


Fusion de la branche LMDZ4V5.0-dev (r1292:r1399) au tronc principal

Validation:
La validation a consisté à compiler la HEAD de le trunk et de la banche
LMDZ4V5.0-dev et les sources fusionnées et de faire tourner le modéle selon
différentes configurations en local et sur SX8 et de comparer les résultats

En local: 32x24x11, config bench/gfortran

  • pour une config IPSLCM5A (comparaison tronc/fusion):
    • convergence numérique sur les champs dynamiques après 3 jours
    • restart et restartphy égaux (à part sur RN et Pb)
    • fichiers histoire égaux
  • pour une config nlle physique (MH07) (comparaison LMDZ4v5.0-dev/fusion):
    • convergence numérique sur les champs dynamiques après 3 jours
    • restart et restartphy égaux
    • fichiers histoire équivalents

Sur brodie, 96x95x39 sur 4 proc:

  • pour une config IPSLCM5A:
    • restart et restartphy égaux (à part sur RN et PB)
    • pas de différence dans les fichiers histmth.nc
  • pour une config MH07
    • restart et restartphy égaux (à part sur RN et PB)
    • pas de différence dans les fichiers histmth.nc

Changement sur makegcm et create_make-gcm pour pouvoir prendre en compte des
programmes principaux en *F90

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