source: LMDZ5/trunk/libf/phylmd/phys_output_write.h @ 1628

Last change on this file since 1628 was 1628, checked in by Laurent Fairhead, 13 years ago

Modifications concerning ALE and ALP.

  1. new default values for the prescribed boundary layer values alp_bl_prescr=0.1 and ale_bl_prescr=4.
  2. iflag_coupl=0 -> ale/p_bl=ale/p_bl_prescr

phys_output_mod.F90 and phys_output_write.h

Slight changes in the control of ALE and ALP outputs
(in particular ale_bl is in the outputs even with iflag_coupl=0.)

FH

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