source: LMDZ4/branches/LMDZ4-dev/libf/phylmd/phys_output_write.h @ 1083

Last change on this file since 1083 was 1083, checked in by lguez, 16 years ago

Évolution des entrées-sorties : lecture des noms et des niveaux de
sortie des variables à partir d'un fichier "outputs.def".
Abderrahmane IDELKADI

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