source: LMDZ5/branches/LMDZ5-DOFOCO/libf/phylmd/phys_output_mod.F90 @ 1940

Last change on this file since 1940 was 1791, checked in by Ehouarn Millour, 11 years ago

Enrichissement et organisation en module de la structure ctrl_out des variables de sortie: ajout des champs description, unité et type_ecrit. Adaptation en conséquence des routines histdef et histwrite.
UG
...................................................

Improvement and transformation into a module of the ctrl_out structure describing output vars. New fields: description, unit and type_ecrit. Creation of new routines histwrite and histdef to take advantage of this structure.
UG

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 39.0 KB
Line 
1! $Id: phys_output_mod.F90 1791 2013-07-17 10:20:19Z jghattas $
2!
3! Abderrahmane 12 2007
4!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
5!!! Ecreture des Sorties du modele dans les fichiers Netcdf :
6! histmth.nc : moyennes mensuelles
7! histday.nc : moyennes journalieres
8! histhf.nc  : moyennes toutes les 3 heures
9! histins.nc : valeurs instantanees
10!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11
12MODULE phys_output_mod
13  USE indice_sol_mod
14  USE phys_output_var_mod
15  USE phys_output_ctrlout_mod
16  USE aero_mod, only : naero_spc,name_aero
17
18  IMPLICIT NONE
19
20  PRIVATE histdef2d, histdef3d, conf_physoutputs
21
22  REAL, PRIVATE, SAVE                :: zdtime
23  !$OMP THREADPRIVATE(zdtime)
24
25
26
27CONTAINS
28
29!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
30!!!!!!!!! Ouverture des fichier et definition des variable de sortie !!!!!!!!
31  !! histbeg, histvert et histdef
32!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
33
34  SUBROUTINE phys_output_open(rlon,rlat,pim,tabij,ipt,jpt,plon,plat, &
35       jjmp1,nlevSTD,clevSTD,nbteta, &
36       ctetaSTD, dtime, ok_veget, &
37       type_ocean, iflag_pbl,ok_mensuel,ok_journe, &
38       ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz, &
39       phys_out_filestations, &
40       new_aod, aerosol_couple, flag_aerosol_strat)   
41
42    USE iophy
43    USE dimphy
44    USE infotrac
45    USE ioipsl
46    USE phys_cal_mod, only : hour
47    USE mod_phys_lmdz_para
48    USE aero_mod, only : naero_spc,name_aero
49
50    IMPLICIT NONE
51    include "dimensions.h"
52    include "temps.h"
53    include "clesphys.h"
54    include "thermcell.h"
55    include "comvert.h"
56    include "iniprint.h"
57
58    real,dimension(klon),intent(in) :: rlon
59    real,dimension(klon),intent(in) :: rlat
60    INTEGER, intent(in)             :: pim
61    INTEGER, DIMENSION(pim)            :: tabij
62    INTEGER,dimension(pim), intent(in) :: ipt, jpt
63    REAL,dimension(pim), intent(in) :: plat, plon
64    REAL,dimension(pim,2) :: plat_bounds, plon_bounds
65
66    INTEGER                               :: jjmp1
67    INTEGER                               :: nbteta, nlevSTD, radpas
68    LOGICAL                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
69    LOGICAL                               :: ok_LES,ok_ade,ok_aie,flag_aerosol_strat
70    LOGICAL                               :: new_aod, aerosol_couple
71    INTEGER, intent(in)::  read_climoz ! read ozone climatology
72    !     Allowed values are 0, 1 and 2
73    !     0: do not read an ozone climatology
74    !     1: read a single ozone climatology that will be used day and night
75    !     2: read two ozone climatologies, the average day and night
76    !     climatology and the daylight climatology
77
78    REAL                                  :: dtime
79    INTEGER                               :: idayref
80    REAL                                  :: zjulian
81    REAL, DIMENSION(klev)                 :: Ahyb, Bhyb, Alt
82    CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
83    INTEGER                               :: nsrf, k, iq, iiq, iff, i, j, ilev
84    INTEGER                               :: naero
85    LOGICAL                               :: ok_veget
86    INTEGER                               :: iflag_pbl
87    CHARACTER(LEN=4)                      :: bb2
88    CHARACTER(LEN=2)                      :: bb3
89    CHARACTER(LEN=6)                      :: type_ocean
90    CHARACTER(LEN=3)                      :: ctetaSTD(nbteta)
91    REAL, DIMENSION(nfiles)               :: ecrit_files
92    CHARACTER(LEN=20), DIMENSION(nfiles)  :: phys_out_filenames
93    INTEGER, DIMENSION(iim*jjmp1)         ::  ndex2d
94    INTEGER, DIMENSION(iim*jjmp1*klev)    :: ndex3d
95    INTEGER                               :: imin_ins, imax_ins
96    INTEGER                               :: jmin_ins, jmax_ins
97    INTEGER, DIMENSION(nfiles)            :: phys_out_levmin, phys_out_levmax
98    INTEGER, DIMENSION(nfiles)            :: phys_out_filelevels
99    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep   = (/ 'DefFreq', 'DefFreq','DefFreq', 'DefFreq', 'DefFreq', 'DefFreq' /)
100    LOGICAL, DIMENSION(nfiles)            :: phys_out_filekeys
101    LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
102
103!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
104    !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
105
106    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE.,  .FALSE., .FALSE., .FALSE. /)
107    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/   -180.,   -180.,   -180.,    -180.,   -180.,   -180. /)
108    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/    180.,    180.,    180.,     180.,    180.,    180. /)
109    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/    -90.,    -90.,    -90.,     -90.,    -90.,    -90. /)
110    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/     90.,     90.,     90.,     90.,     90.,     90. /)
111
112    WRITE(lunout,*) 'Debut phys_output_mod.F90'
113    ! Initialisations (Valeurs par defaut
114
115    IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
116    IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
117
118    levmax = (/ klev, klev, klev, klev, klev, klev /)
119
120    phys_out_filenames(1) = 'histmth'
121    phys_out_filenames(2) = 'histday'
122    phys_out_filenames(3) = 'histhf'
123    phys_out_filenames(4) = 'histins'
124    phys_out_filenames(5) = 'histLES'
125    phys_out_filenames(6) = 'histstn'
126
127    type_ecri(1) = 'ave(X)'
128    type_ecri(2) = 'ave(X)'
129    type_ecri(3) = 'ave(X)'
130    type_ecri(4) = 'inst(X)'
131    type_ecri(5) = 'ave(X)'
132    type_ecri(6) = 'inst(X)'
133
134    clef_files(1) = ok_mensuel
135    clef_files(2) = ok_journe
136    clef_files(3) = ok_hf
137    clef_files(4) = ok_instan
138    clef_files(5) = ok_LES
139    clef_files(6) = ok_instan
140
141    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
142    clef_stations(1) = .FALSE.
143    clef_stations(2) = .FALSE.
144    clef_stations(3) = .FALSE.
145    clef_stations(4) = .FALSE.
146    clef_stations(5) = .FALSE.
147    clef_stations(6) = .FALSE.
148
149    lev_files(1) = lev_histmth
150    lev_files(2) = lev_histday
151    lev_files(3) = lev_histhf
152    lev_files(4) = lev_histins
153    lev_files(5) = lev_histLES
154    lev_files(6) = lev_histins
155
156    ecrit_files(1) = ecrit_mth
157    ecrit_files(2) = ecrit_day
158    ecrit_files(3) = ecrit_hf
159    ecrit_files(4) = ecrit_ins
160    ecrit_files(5) = ecrit_LES
161    ecrit_files(6) = ecrit_ins
162
163    !! Lectures des parametres de sorties dans physiq.def
164
165    CALL getin('phys_out_regfkey',phys_out_regfkey)
166    CALL getin('phys_out_lonmin',phys_out_lonmin)
167    CALL getin('phys_out_lonmax',phys_out_lonmax)
168    CALL getin('phys_out_latmin',phys_out_latmin)
169    CALL getin('phys_out_latmax',phys_out_latmax)
170    phys_out_levmin(:)=levmin(:)
171    CALL getin('phys_out_levmin',levmin)
172    phys_out_levmax(:)=levmax(:)
173    CALL getin('phys_out_levmax',levmax)
174    CALL getin('phys_out_filenames',phys_out_filenames)
175    phys_out_filekeys(:)=clef_files(:)
176    CALL getin('phys_out_filekeys',clef_files)
177    phys_out_filestations(:)=clef_stations(:)
178    CALL getin('phys_out_filestations',clef_stations)
179    phys_out_filelevels(:)=lev_files(:)
180    CALL getin('phys_out_filelevels',lev_files)
181    CALL getin('phys_out_filetimesteps',chtimestep)
182    phys_out_filetypes(:)=type_ecri(:)
183    CALL getin('phys_out_filetypes',type_ecri)
184
185    type_ecri_files(:)=type_ecri(:)
186
187    WRITE(lunout,*)'phys_out_lonmin=',phys_out_lonmin
188    WRITE(lunout,*)'phys_out_lonmax=',phys_out_lonmax
189    WRITE(lunout,*)'phys_out_latmin=',phys_out_latmin
190    WRITE(lunout,*)'phys_out_latmax=',phys_out_latmax
191    WRITE(lunout,*)'phys_out_filenames=',phys_out_filenames
192    WRITE(lunout,*)'phys_out_filetypes=',type_ecri
193    WRITE(lunout,*)'phys_out_filekeys=',clef_files
194    WRITE(lunout,*)'phys_out_filestations=',clef_stations
195    WRITE(lunout,*)'phys_out_filelevels=',lev_files
196
197!!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
198    ! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
199    ! Appel des histbeg pour definir les variables (nom, moy ou inst, freq de sortie ..
200!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
201
202    zdtime = dtime         ! Frequence ou l on moyenne
203
204    ! Calcul des Ahyb, Bhyb et Alt
205    DO k=1,klev
206       Ahyb(k)=(ap(k)+ap(k+1))/2.
207       Bhyb(k)=(bp(k)+bp(k+1))/2.
208       Alt(k)=log(preff/presnivs(k))*8.
209    ENDDO
210    !          if(prt_level.ge.1) then
211    WRITE(lunout,*)'Ap Hybrid = ',Ahyb(1:klev)
212    WRITE(lunout,*)'Bp Hybrid = ',Bhyb(1:klev)
213    WRITE(lunout,*)'Alt approx des couches pour une haut d echelle de 8km = ',Alt(1:klev)
214    !          endif
215    DO iff=1,nfiles
216
217       ! Calculate ecrit_files for all files
218       IF ( chtimestep(iff).eq.'DefFreq' ) then
219          ! Par defaut ecrit_files = (ecrit_mensuel ecrit_jour ecrit_hf ...)*86400.
220          ecrit_files(iff)=ecrit_files(iff)*86400.
221       ELSE
222          CALL convers_timesteps(chtimestep(iff),dtime,ecrit_files(iff))
223       ENDIF
224       WRITE(lunout,*)'ecrit_files(',iff,')= ',ecrit_files(iff)
225
226       zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
227
228       IF (clef_files(iff)) THEN
229
230          idayref = day_ref
231!          CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)       
232! correction pour l heure initiale                               !jyg
233!                                                                !jyg
234          CALL ymds2ju(annee_ref, 1, idayref, hour, zjulian)         !jyg
235! correction pour l heure initiale                               !jyg
236!                                                                !jyg
237!!!      CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)       !jyg
238! correction pour l heure initiale                               !jyg
239!                                                                !jyg
240!      CALL ymds2ju(annee_ref, 1, idayref, hour, zjulian)         !jyg
241
242!!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
243!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
244          IF (phys_out_regfkey(iff)) then
245
246             imin_ins=1
247             imax_ins=iim
248             jmin_ins=1
249             jmax_ins=jjmp1
250
251             ! correction abderr       
252             do i=1,iim
253                WRITE(lunout,*)'io_lon(i)=',io_lon(i)
254                IF (io_lon(i).le.phys_out_lonmin(iff)) imin_ins=i
255                IF (io_lon(i).le.phys_out_lonmax(iff)) imax_ins=i+1
256             enddo
257
258             do j=1,jjmp1
259                WRITE(lunout,*)'io_lat(j)=',io_lat(j)
260                IF (io_lat(j).ge.phys_out_latmin(iff)) jmax_ins=j+1
261                IF (io_lat(j).ge.phys_out_latmax(iff)) jmin_ins=j
262             enddo
263
264             WRITE(lunout,*)'On stoke le fichier histoire numero ',iff,' sur ', &
265                  imin_ins,imax_ins,jmin_ins,jmax_ins
266             WRITE(lunout,*)'longitudes : ', &
267                  io_lon(imin_ins),io_lon(imax_ins), &
268                  'latitudes : ', &
269                  io_lat(jmax_ins),io_lat(jmin_ins)
270
271             CALL histbeg(phys_out_filenames(iff),iim,io_lon,jjmp1,io_lat, &
272                  imin_ins,imax_ins-imin_ins+1, &
273                  jmin_ins,jmax_ins-jmin_ins+1, &
274                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
275!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
276             !IM fichiers stations
277          else IF (clef_stations(iff)) THEN
278
279             WRITE(lunout,*)'phys_output_mod phys_out_filenames=',phys_out_filenames(iff)
280
281             CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
282                  phys_out_filenames(iff), &
283                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
284          else
285             CALL histbeg_phy(phys_out_filenames(iff),itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
286          endif
287
288          CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", &
289               levmax(iff) - levmin(iff) + 1, &
290               presnivs(levmin(iff):levmax(iff)), nvertm(iff),"down")
291
292!!!!!!!!!!!!! Traitement des champs 3D pour histhf !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
293!!!!!!!!!!!!!!! A Revoir plus tard !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
294          !          IF (iff.eq.3.and.lev_files(iff).ge.4) THEN
295          !          CALL histbeg_phy("histhf3d",itau_phy, &
296          !     &                     zjulian, dtime, &
297          !     &                     nhorim, nid_hf3d)
298
299          !         CALL histvert(nid_hf3d, "presnivs", &
300          !     &                 "Vertical levels", "mb", &
301          !     &                 klev, presnivs/100., nvertm)
302          !          ENDIF
303          !
304!!!! Composentes de la coordonnee sigma-hybride
305          CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
306               levmax(iff) - levmin(iff) + 1,Ahyb,nvertap(iff))
307
308          CALL histvert(nid_files(iff), "Bhyb","Bhyb comp of Hyb Cord", " ", &
309               levmax(iff) - levmin(iff) + 1,Bhyb,nvertbp(iff))
310
311          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &
312               levmax(iff) - levmin(iff) + 1,Alt,nvertAlt(iff))
313
314          !   CALL histvert(nid_files(iff), "preff","Reference pressure", "Pa", &
315          !                 1,preff,nvertp0(iff))
316!!! Champs 1D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
317    CALL histdef2d(iff,o_aire)
318    CALL histdef2d(iff,o_contfracATM)
319
320!!! Champs 2D !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
321    CALL histdef2d(iff,o_phis)
322    CALL histdef2d(iff,o_contfracOR)
323    CALL histdef2d(iff,o_aireTER)
324    CALL histdef2d(iff,o_flat)
325    CALL histdef2d(iff,o_slp)
326    CALL histdef2d(iff,o_tsol)
327    CALL histdef2d(iff,o_t2m)
328    CALL histdef2d(iff,o_t2m_min)
329    CALL histdef2d(iff,o_t2m_max)
330    CALL histdef2d(iff,o_wind10m)
331    CALL histdef2d(iff,o_wind10max)
332    CALL histdef2d(iff,o_sicf)
333    CALL histdef2d(iff,o_q2m)
334    CALL histdef2d(iff,o_ustar)
335    CALL histdef2d(iff,o_u10m)
336    CALL histdef2d(iff,o_v10m)
337    CALL histdef2d(iff,o_psol)
338    CALL histdef2d(iff,o_qsurf)
339
340    IF (.NOT. ok_veget) THEN
341      CALL histdef2d(iff,o_qsol)
342    ENDIF
343    CALL histdef2d(iff,o_ndayrain)
344    CALL histdef2d(iff,o_precip)
345    CALL histdef2d(iff,o_plul)
346    CALL histdef2d(iff,o_pluc)
347    CALL histdef2d(iff,o_snow)
348    CALL histdef2d(iff,o_msnow)
349    CALL histdef2d(iff,o_fsnow)
350    CALL histdef2d(iff,o_evap)
351    CALL histdef2d(iff,o_tops)
352    CALL histdef2d(iff,o_tops0)
353    CALL histdef2d(iff,o_topl)
354    CALL histdef2d(iff,o_topl0)
355    CALL histdef2d(iff,o_SWupTOA)
356    CALL histdef2d(iff,o_SWupTOAclr)
357    CALL histdef2d(iff,o_SWdnTOA)
358    CALL histdef2d(iff,o_SWdnTOAclr)
359    CALL histdef2d(iff,o_nettop)
360    CALL histdef2d(iff,o_SWup200)
361    CALL histdef2d(iff,o_SWup200clr)
362    CALL histdef2d(iff,o_SWdn200)
363    CALL histdef2d(iff,o_SWdn200clr)
364    CALL histdef2d(iff,o_LWup200)
365    CALL histdef2d(iff,o_LWup200clr)
366    CALL histdef2d(iff,o_LWdn200)
367    CALL histdef2d(iff,o_LWdn200clr)
368    CALL histdef2d(iff,o_sols)
369    CALL histdef2d(iff,o_sols0)
370    CALL histdef2d(iff,o_soll)
371    CALL histdef2d(iff,o_radsol)
372    CALL histdef2d(iff,o_soll0)
373    CALL histdef2d(iff,o_SWupSFC)
374    CALL histdef2d(iff,o_SWupSFCclr)
375    CALL histdef2d(iff,o_SWdnSFC)
376    CALL histdef2d(iff,o_SWdnSFCclr)
377    CALL histdef2d(iff,o_LWupSFC)
378    CALL histdef2d(iff,o_LWdnSFC)
379    CALL histdef2d(iff,o_LWupSFCclr)
380    CALL histdef2d(iff,o_LWdnSFCclr)
381    CALL histdef2d(iff,o_bils)
382    CALL histdef2d(iff,o_bils_ec)
383    CALL histdef2d(iff,o_bils_tke)
384    CALL histdef2d(iff,o_bils_diss)
385    CALL histdef2d(iff,o_bils_kinetic)
386    CALL histdef2d(iff,o_bils_enthalp)
387    CALL histdef2d(iff,o_bils_latent)
388    CALL histdef2d(iff,o_sens)
389    CALL histdef2d(iff,o_fder)
390    CALL histdef2d(iff,o_ffonte)
391    CALL histdef2d(iff,o_fqcalving)
392    CALL histdef2d(iff,o_fqfonte)
393    CALL histdef2d(iff,o_taux)
394    CALL histdef2d(iff,o_tauy)
395
396    DO nsrf = 1, nbsrf
397      CALL histdef2d(iff,o_pourc_srf(nsrf))
398      CALL histdef2d(iff,o_fract_srf(nsrf))
399      CALL histdef2d(iff, o_taux_srf(nsrf))
400      CALL histdef2d(iff, o_tauy_srf(nsrf))
401      CALL histdef2d(iff, o_tsol_srf(nsrf))
402      CALL histdef2d(iff, o_evappot_srf(nsrf))
403      CALL histdef2d(iff, o_ustar_srf(nsrf))
404      CALL histdef2d(iff, o_u10m_srf(nsrf))
405      CALL histdef2d(iff, o_evap_srf(nsrf))
406      CALL histdef2d(iff, o_v10m_srf(nsrf))
407      CALL histdef2d(iff, o_t2m_srf(nsrf))
408      CALL histdef2d(iff, o_sens_srf(nsrf))
409      CALL histdef2d(iff, o_lat_srf(nsrf))
410      CALL histdef2d(iff, o_flw_srf(nsrf))
411      CALL histdef2d(iff, o_fsw_srf(nsrf))
412      CALL histdef2d(iff, o_wbils_srf(nsrf))
413      CALL histdef2d(iff, o_wbilo_srf(nsrf))
414      IF (iflag_pbl>1 ) then
415            CALL histdef2d(iff, o_tke_srf(nsrf))
416            CALL histdef2d(iff, o_tke_max_srf(nsrf))
417      ENDIF
418
419      CALL histdef2d(iff, o_albe_srf(nsrf))
420      CALL histdef2d(iff, o_rugs_srf(nsrf))
421      CALL histdef2d(iff, o_ages_srf(nsrf))
422    END DO
423
424    IF (new_aod .AND. (.NOT. aerosol_couple)) THEN
425      IF (ok_ade.OR.ok_aie) THEN
426          CALL histdef2d(iff,o_od550aer)
427          CALL histdef2d(iff,o_od865aer)
428          CALL histdef2d(iff,o_absvisaer)
429          CALL histdef2d(iff,o_od550lt1aer)
430          CALL histdef2d(iff,o_sconcso4)
431          CALL histdef2d(iff,o_sconcoa)
432          CALL histdef2d(iff,o_sconcbc)
433          CALL histdef2d(iff,o_sconcss)
434          CALL histdef2d(iff,o_sconcdust)
435          CALL histdef3d(iff,o_concso4)
436          CALL histdef3d(iff,o_concoa)
437          CALL histdef3d(iff,o_concbc)
438          CALL histdef3d(iff,o_concss)
439          CALL histdef3d(iff,o_concdust)
440          CALL histdef2d(iff,o_loadso4)
441          CALL histdef2d(iff,o_loadoa)
442          CALL histdef2d(iff,o_loadbc)
443          CALL histdef2d(iff,o_loadss)
444          CALL histdef2d(iff,o_loaddust)
445!--STRAT AER
446      ENDIF
447      IF (ok_ade.OR.ok_aie.OR.flag_aerosol_strat) THEN
448        DO naero = 1, naero_spc
449          CALL histdef2d(iff, o_tausumaero(naero))
450        END DO
451      ENDIF
452    ENDIF
453
454    IF (ok_ade) THEN
455      CALL histdef2d(iff,o_topswad)
456      CALL histdef2d(iff,o_topswad0)
457      CALL histdef2d(iff,o_solswad)
458      CALL histdef2d(iff,o_solswad0)
459      CALL histdef2d(iff,o_swtoaas_nat)
460      CALL histdef2d(iff,o_swsrfas_nat)
461      CALL histdef2d(iff,o_swtoacs_nat)
462      CALL histdef2d(iff,o_swsrfcs_nat)
463      CALL histdef2d(iff,o_swtoaas_ant)
464      CALL histdef2d(iff,o_swsrfas_ant)
465      CALL histdef2d(iff,o_swtoacs_ant)
466      CALL histdef2d(iff,o_swsrfcs_ant)
467
468      IF (.NOT. aerosol_couple) THEN
469            CALL histdef2d(iff,o_swtoacf_nat)
470            CALL histdef2d(iff,o_swsrfcf_nat)
471            CALL histdef2d(iff,o_swtoacf_ant)
472            CALL histdef2d(iff,o_swsrfcf_ant)
473            CALL histdef2d(iff,o_swtoacf_zero)
474            CALL histdef2d(iff,o_swsrfcf_zero)
475      ENDIF
476    ENDIF
477
478    IF (ok_aie) THEN
479      CALL histdef2d(iff,o_topswai)
480      CALL histdef2d(iff,o_solswai)
481                  !Cloud droplet number concentration
482      CALL histdef3d(iff,o_scdnc)
483      CALL histdef2d(iff,o_cldncl)
484      CALL histdef3d(iff,o_reffclws)
485      CALL histdef3d(iff,o_reffclwc)
486      CALL histdef2d(iff,o_cldnvi)
487      CALL histdef3d(iff,o_lcc3d)
488      CALL histdef3d(iff,o_lcc3dcon)
489      CALL histdef3d(iff,o_lcc3dstra)
490      CALL histdef2d(iff,o_lcc)
491      CALL histdef2d(iff,o_reffclwtop)
492    ENDIF
493    CALL histdef2d(iff,o_alb1)
494    CALL histdef2d(iff,o_alb2)
495    CALL histdef2d(iff,o_cdrm)
496    CALL histdef2d(iff,o_cdrh)
497    CALL histdef2d(iff,o_cldl)
498    CALL histdef2d(iff,o_cldm)
499    CALL histdef2d(iff,o_cldh)
500    CALL histdef2d(iff,o_cldt)
501    CALL histdef2d(iff,o_cldq)
502    CALL histdef2d(iff,o_lwp)
503    CALL histdef2d(iff,o_iwp)
504    CALL histdef2d(iff,o_ue)
505    CALL histdef2d(iff,o_ve)
506    CALL histdef2d(iff,o_uq)
507    CALL histdef2d(iff,o_vq)
508
509    IF(iflag_con.GE.3) THEN ! sb
510      CALL histdef2d(iff,o_cape)
511      CALL histdef2d(iff,o_pbase)
512      CALL histdef2d(iff,o_ptop)
513      CALL histdef2d(iff,o_fbase)
514      IF (iflag_con /= 30) THEN
515            CALL histdef2d(iff,o_plcl)
516            CALL histdef2d(iff,o_plfc)
517            CALL histdef2d(iff,o_wbeff)
518      ENDIF
519      CALL histdef2d(iff,o_cape_max)
520      CALL histdef3d(iff,o_upwd)
521      CALL histdef3d(iff,o_Ma)
522      CALL histdef3d(iff,o_dnwd)
523      CALL histdef3d(iff,o_dnwd0)
524      CALL histdef3d(iff,o_mc)
525      CALL histdef2d(iff,o_ftime_con)
526    ENDIF !iflag_con .GE. 3
527    CALL histdef2d(iff,o_prw)
528    CALL histdef2d(iff,o_s_pblh)
529    CALL histdef2d(iff,o_s_pblt)
530    CALL histdef2d(iff,o_s_lcl)
531    CALL histdef2d(iff,o_s_therm)
532          !IM : Les champs suivants (s_oliqCL, s_cteiCL, s_trmb1, s_trmb2, s_trmb3) ne sont pas definis dans HBTM.F
533          !CALL histdef2d(iff, &
534          !o_s_capCL%flag,o_s_capCL%name, "Conv avlbl pot enerfor ABL", "J/m2" )
535          !CALL histdef2d(iff, &
536          !o_s_oliqCL%flag,o_s_oliqCL%name, "Liq Water in BL", "kg/m2")
537          !CALL histdef2d(iff, &
538          !o_s_cteiCL%flag,o_s_cteiCL%name, "Instability criteria(ABL)", "K")
539          !CALL histdef2d(iff, &
540          !o_s_trmb1%flag,o_s_trmb1%name, "deep_cape(HBTM2)", "J/m2")
541          !CALL histdef2d(iff, &
542          !o_s_trmb2%flag,o_s_trmb2%name, "inhibition (HBTM2)", "J/m2")
543          !CALL histdef2d(iff, &
544          !o_s_trmb3%flag,o_s_trmb3%name, "Point Omega (HBTM2)", "m")
545
546          ! Champs interpolles sur des niveaux de pression
547
548          ! Attention a reverifier
549
550    ilev=0       
551    DO k=1, nlevSTD
552      bb2=clevSTD(k)
553      IF(bb2.EQ."850".OR.bb2.EQ."700".OR.bb2.EQ."500".OR.bb2.EQ."200" &
554                  .OR.bb2.EQ."100".OR.bb2.EQ."50".OR.bb2.EQ."10")THEN
555            ilev=ilev+1
556            !     print*,'ilev k bb2 flag name ',ilev,k, bb2,o_uSTDlevs(ilev)%flag,o_uSTDlevs(ilev)%name
557            CALL histdef2d(iff,o_uSTDlevs(ilev))
558            CALL histdef2d(iff,o_vSTDlevs(ilev))
559            CALL histdef2d(iff,o_wSTDlevs(ilev))
560            CALL histdef2d(iff,o_zSTDlevs(ilev))
561            CALL histdef2d(iff,o_qSTDlevs(ilev))
562            CALL histdef2d(iff,o_tSTDlevs(ilev))
563      ENDIF !(bb2.EQ."850".OR.bb2.EQ."700".OR."500".OR.bb2.EQ."200".OR.bb2.EQ."50".OR.bb2.EQ."10")
564    ENDDO
565
566    CALL histdef2d(iff,o_t_oce_sic)
567
568    IF (type_ocean=='slab') THEN
569      CALL histdef2d(iff,o_slab_bils)
570    ENDIF
571
572    ! Couplage conv-CL
573    IF (iflag_con.GE.3) THEN
574      IF (iflag_coupl>=1) THEN
575            CALL histdef2d(iff,o_ale_bl)
576            CALL histdef2d(iff,o_alp_bl)
577      ENDIF
578    ENDIF !(iflag_con.GE.3)
579
580    CALL histdef2d(iff,o_weakinv)
581    CALL histdef2d(iff,o_dthmin)
582
583    CALL histdef2d(iff,o_rh2m)
584    CALL histdef2d(iff,o_rh2m_min)
585    CALL histdef2d(iff,o_rh2m_max)
586
587    CALL histdef2d(iff,o_qsat2m)
588    CALL histdef2d(iff,o_tpot)
589    CALL histdef2d(iff,o_tpote)
590    CALL histdef2d(iff,o_SWnetOR)
591    CALL histdef2d(iff,o_SWdownOR)
592    CALL histdef2d(iff,o_LWdownOR)
593    CALL histdef2d(iff,o_snowl)
594    CALL histdef2d(iff,o_solldown)
595    CALL histdef2d(iff,o_dtsvdfo)
596    CALL histdef2d(iff,o_dtsvdft)
597    CALL histdef2d(iff,o_dtsvdfg)
598    CALL histdef2d(iff,o_dtsvdfi)
599    CALL histdef2d(iff,o_rugs)
600
601          ! Champs 3D:
602    CALL histdef3d(iff,o_ec550aer)
603    CALL histdef3d(iff,o_lwcon)
604    CALL histdef3d(iff,o_iwcon)
605    CALL histdef3d(iff,o_temp)
606    CALL histdef3d(iff,o_theta)
607    CALL histdef3d(iff,o_ovap)
608    CALL histdef3d(iff,o_oliq)
609    CALL histdef3d(iff,o_ovapinit)
610    CALL histdef3d(iff,o_geop)
611    CALL histdef3d(iff,o_vitu)
612    CALL histdef3d(iff,o_vitv)
613    CALL histdef3d(iff,o_vitw)
614    CALL histdef3d(iff,o_pres)
615    CALL histdef3d(iff,o_paprs)
616    CALL histdef3d(iff,o_mass)
617    CALL histdef3d(iff,o_zfull)
618    CALL histdef3d(iff,o_zhalf)
619    CALL histdef3d(iff,o_rneb)
620    CALL histdef3d(iff,o_rnebcon)
621    CALL histdef3d(iff,o_rnebls)
622    CALL histdef3d(iff,o_rhum)
623    CALL histdef3d(iff,o_ozone)
624
625    IF (read_climoz == 2) THEN
626      CALL histdef3d(iff,o_ozone_light)
627    END IF
628
629    CALL histdef3d(iff,o_dtphy)
630    CALL histdef3d(iff,o_dqphy)
631    CALL histdef3d(iff,o_cldtau)
632    CALL histdef3d(iff,o_cldemi)
633!IM: bug ?? dimensionnement variables (klon,klev+1) pmflxr, pmflxs, prfl, psfl
634    CALL histdef3d(iff,o_pr_con_l)
635    CALL histdef3d(iff,o_pr_con_i)
636    CALL histdef3d(iff,o_pr_lsc_l)
637    CALL histdef3d(iff,o_pr_lsc_i)
638!Cloud droplet effective radius
639    CALL histdef3d(iff,o_re)
640    CALL histdef3d(iff,o_fl)
641!FH Sorties pour la couche limite
642    IF (iflag_pbl>1) THEN
643      CALL histdef3d(iff,o_tke)
644      CALL histdef3d(iff,o_tke_max)
645    ENDIF
646    CALL histdef3d(iff,o_kz)
647    CALL histdef3d(iff,o_kz_max)
648    CALL histdef3d(iff,o_clwcon)
649    CALL histdef3d(iff,o_dtdyn)
650    CALL histdef3d(iff,o_dqdyn)
651    CALL histdef3d(iff,o_dudyn)
652    CALL histdef3d(iff,o_dvdyn)
653    CALL histdef3d(iff,o_dtcon)
654    CALL histdef3d(iff,o_ducon)
655    CALL histdef3d(iff,o_dvcon)
656    CALL histdef3d(iff,o_dqcon)
657
658! Wakes
659    IF(iflag_con.EQ.3) THEN
660      IF (iflag_wake >= 1) THEN
661            CALL histdef2d(iff,o_ale_wk)
662            CALL histdef2d(iff,o_alp_wk)
663            CALL histdef2d(iff,o_ale)
664            CALL histdef2d(iff,o_alp)
665            CALL histdef2d(iff,o_cin)
666            CALL histdef2d(iff,o_wape)
667            CALL histdef2d(iff,o_wake_h)
668            CALL histdef2d(iff,o_wake_s)
669            CALL histdef3d(iff,o_dtwak)
670            CALL histdef3d(iff,o_dqwak)
671            CALL histdef3d(iff,o_wake_deltat)
672            CALL histdef3d(iff,o_wake_deltaq)
673            CALL histdef3d(iff,o_wake_omg)
674      ENDIF
675!!! RomP             CALL histdef3d(iff,o_Vprecip%flag,o_Vprecip%name, "precipitation vertical profile", "-")
676      CALL histdef3d(iff,o_ftd)
677      CALL histdef3d(iff,o_fqd)
678    ENDIF !(iflag_con.EQ.3)
679
680    IF(iflag_con.GE.3) THEN   !  RomP >>>
681      CALL histdef3d(iff,o_wdtrainA)
682      CALL histdef3d(iff,o_wdtrainM)
683      CALL histdef3d(iff,o_Vprecip)
684    ENDIF !(iflag_con.GE.3)   ! <<< RomP
685
686!!! nrlmd le 10/04/2012
687
688    IF (iflag_trig_bl>=1) THEN
689      CALL histdef2d(iff,o_n2)
690      CALL histdef2d(iff,o_s2)
691      CALL histdef2d(iff,o_proba_notrig)
692      CALL histdef2d(iff,o_random_notrig)
693      CALL histdef2d(iff,o_ale_bl_trig)
694      CALL histdef2d(iff,o_ale_bl_stat)
695    ENDIF  !(iflag_trig_bl>=1)
696
697    IF (iflag_clos_bl>=1) THEN
698      CALL histdef2d(iff,o_alp_bl_det)
699      CALL histdef2d(iff,o_alp_bl_fluct_m)
700      CALL histdef2d(iff,o_alp_bl_fluct_tke)
701      CALL histdef2d(iff,o_alp_bl_conv)
702      CALL histdef2d(iff,o_alp_bl_stat)
703    ENDIF  !(iflag_clos_bl>=1)
704
705!!! fin nrlmd le 10/04/2012
706    CALL histdef3d(iff,o_dtlsc)
707    CALL histdef3d(iff,o_dtlschr)
708    CALL histdef3d(iff,o_dqlsc)
709    CALL histdef3d(iff,o_beta_prec)
710    CALL histdef3d(iff,o_dtvdf)
711    CALL histdef3d(iff,o_dtdis)
712    CALL histdef3d(iff,o_dqvdf)
713    CALL histdef3d(iff,o_dteva)
714    CALL histdef3d(iff,o_dqeva)
715    CALL histdef3d(iff,o_ptconv)
716    CALL histdef3d(iff,o_ratqs)
717    CALL histdef3d(iff,o_dtthe)
718
719    IF (iflag_thermals.ge.1) THEN
720      CALL histdef3d(iff,o_dqlscth)
721      CALL histdef3d(iff,o_dqlscst)
722      CALL histdef3d(iff,o_dtlscth)
723      CALL histdef3d(iff,o_dtlscst)
724      CALL histdef2d(iff,o_plulth)
725      CALL histdef2d(iff,o_plulst)
726      CALL histdef2d(iff,o_lmaxth)
727      CALL histdef3d(iff,o_ptconvth)
728      CALL histdef3d(iff,o_f_th)
729      CALL histdef3d(iff,o_e_th)
730      CALL histdef3d(iff,o_w_th)
731      CALL histdef3d(iff,o_lambda_th)
732      CALL histdef2d(iff,o_ftime_th)
733      CALL histdef3d(iff,o_q_th)
734      CALL histdef3d(iff,o_a_th)
735      CALL histdef3d(iff,o_d_th)
736      CALL histdef2d(iff,o_f0_th)
737      CALL histdef2d(iff,o_zmax_th)
738      CALL histdef3d(iff,o_dqthe)
739    ENDIF !iflag_thermals.ge.1
740
741    CALL histdef3d(iff,o_dtajs)
742    CALL histdef3d(iff,o_dqajs)
743    CALL histdef3d(iff,o_dtswr)
744    CALL histdef3d(iff,o_dtsw0)
745    CALL histdef3d(iff,o_dtlwr)
746    CALL histdef3d(iff,o_dtlw0)
747    CALL histdef3d(iff,o_dtec)
748    CALL histdef3d(iff,o_duvdf)
749    CALL histdef3d(iff,o_dvvdf)
750
751    IF (ok_orodr) THEN
752      CALL histdef3d(iff,o_duoro)
753      CALL histdef3d(iff,o_dvoro)
754      CALL histdef3d(iff,o_dtoro)
755    ENDIF
756
757    IF (ok_orolf) THEN
758      CALL histdef3d(iff,o_dulif)
759      CALL histdef3d(iff,o_dvlif)
760      CALL histdef3d(iff,o_dtlif)
761    ENDIF
762
763    IF (ok_hines) then
764      CALL histdef3d(iff,o_duhin)
765      CALL histdef3d(iff,o_dvhin)
766      CALL histdef3d(iff,o_dthin)
767    ENDIF
768
769    CALL histdef3d(iff,o_rsu)
770    CALL histdef3d(iff,o_rsd)
771    CALL histdef3d(iff,o_rlu)
772    CALL histdef3d(iff,o_rld)
773    CALL histdef3d(iff,o_rsucs)
774    CALL histdef3d(iff,o_rsdcs)
775    CALL histdef3d(iff,o_rlucs)
776    CALL histdef3d(iff,o_rldcs)
777    CALL histdef3d(iff,o_tnt)
778    CALL histdef3d(iff,o_tntc)
779    CALL histdef3d(iff,o_tntr)
780    CALL histdef3d(iff,o_tntscpbl)
781    CALL histdef3d(iff,o_tnhus)
782    CALL histdef3d(iff,o_tnhusc)
783    CALL histdef3d(iff,o_tnhusscpbl)
784    CALL histdef3d(iff,o_evu)
785    CALL histdef3d(iff,o_h2o)
786    CALL histdef3d(iff,o_mcd)
787    CALL histdef3d(iff,o_dmc)
788    CALL histdef3d(iff,o_ref_liq)
789    CALL histdef3d(iff,o_ref_ice)
790
791    IF (RCO2_per.NE.RCO2_act.OR.RCH4_per.NE.RCH4_act.OR. &
792               RN2O_per.NE.RN2O_act.OR.RCFC11_per.NE.RCFC11_act.OR. &
793               RCFC12_per.NE.RCFC12_act) THEN
794      CALL histdef2d(iff,o_rsut4co2)
795      CALL histdef2d(iff,o_rlut4co2)
796      CALL histdef2d(iff,o_rsutcs4co2)
797      CALL histdef2d(iff,o_rlutcs4co2)
798      CALL histdef3d(iff,o_rsu4co2)
799      CALL histdef3d(iff,o_rlu4co2)
800      CALL histdef3d(iff,o_rsucs4co2)
801      CALL histdef3d(iff,o_rlucs4co2)
802      CALL histdef3d(iff,o_rsd4co2)
803      CALL histdef3d(iff,o_rld4co2)
804      CALL histdef3d(iff,o_rsdcs4co2)
805      CALL histdef3d(iff,o_rldcs4co2)
806
807    ENDIF
808
809
810      IF (nqtot>=3) THEN
811            DO iq=3,nqtot 
812            iiq=niadv(iq)
813            o_trac(iq-2) = ctrl_out((/ 4, 5, 1, 1, 1, 10 /),tname(iiq),'Tracer '//ttext(iiq), "-",&
814                  (/ '', '', '', '', '', '' /))
815            CALL histdef3d(iff, o_trac(iq-2))
816            o_trac_cum(iq-2) = ctrl_out((/ 3, 4, 10, 10, 10, 10 /),'cum'//tname(iiq),&
817                  'Cumulated tracer '//ttext(iiq), "-", (/ '', '', '', '', '', '' /))
818            CALL histdef2d(iff, o_trac_cum(iq-2))
819            ENDDO
820      ENDIF
821
822      CALL histend(nid_files(iff))
823
824      ndex2d = 0
825      ndex3d = 0
826
827    ENDIF ! clef_files
828
829    ENDDO !  iff
830
831    ! Updated write frequencies due to phys_out_filetimesteps.
832    ! Write frequencies are now in seconds. 
833    ecrit_mth = ecrit_files(1)
834    ecrit_day = ecrit_files(2)
835    ecrit_hf  = ecrit_files(3)
836    ecrit_ins = ecrit_files(4)
837    ecrit_LES = ecrit_files(5)
838    ecrit_ins = ecrit_files(6)
839
840    WRITE(lunout,*)'swaero_diag=',swaero_diag
841    WRITE(lunout,*)'Fin phys_output_mod.F90'
842  end SUBROUTINE phys_output_open
843
844  SUBROUTINE histdef2d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
845
846    USE ioipsl
847    USE dimphy
848    USE mod_phys_lmdz_para
849    USE iophy
850
851    IMPLICIT NONE
852
853    INCLUDE "dimensions.h"
854    INCLUDE "temps.h"
855    INCLUDE "clesphys.h"
856
857    INTEGER                          :: iff
858    LOGICAL                          :: lpoint
859    INTEGER, DIMENSION(nfiles)       :: flag_var
860    CHARACTER(LEN=20)                 :: nomvar
861    CHARACTER(LEN=*)                 :: titrevar
862    CHARACTER(LEN=*)                 :: unitvar
863
864    REAL zstophym
865
866    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
867       zstophym=zoutm(iff)
868    ELSE
869       zstophym=zdtime
870    ENDIF
871
872    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
873    CALL conf_physoutputs(nomvar,flag_var)
874
875    IF(.NOT.lpoint) THEN 
876       IF ( flag_var(iff)<=lev_files(iff) ) THEN
877          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
878               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
879               type_ecri(iff), zstophym,zoutm(iff))               
880       ENDIF
881    ELSE
882       IF ( flag_var(iff)<=lev_files(iff) ) THEN
883          CALL histdef (nid_files(iff),nomvar,titrevar,unitvar, &
884               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
885               type_ecri(iff), zstophym,zoutm(iff))               
886       ENDIF
887    ENDIF
888
889    ! Set swaero_diag=true if at least one of the concerned variables are defined
890    IF (nomvar=='topswad' .OR. nomvar=='topswai' .OR. nomvar=='solswad' .OR. nomvar=='solswai' ) THEN
891       IF  ( flag_var(iff)<=lev_files(iff) ) THEN
892          swaero_diag=.TRUE.
893       END IF
894    END IF
895  END SUBROUTINE histdef2d_old
896
897  SUBROUTINE histdef2d (iff,var)
898
899    USE ioipsl
900    USE dimphy
901    USE mod_phys_lmdz_para
902    USE iophy
903
904    IMPLICIT NONE
905
906    INCLUDE "dimensions.h"
907    INCLUDE "temps.h"
908    INCLUDE "clesphys.h"
909
910    INTEGER                          :: iff
911    TYPE(ctrl_out)                   :: var
912
913    REAL zstophym
914    CHARACTER(LEN=20) :: typeecrit
915
916    ! ug On récupère le type écrit de la structure:
917    !       Assez moche, à refaire si meilleure méthode...
918    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
919       typeecrit = 'once'
920    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
921       typeecrit = 't_min(X)'
922    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
923       typeecrit = 't_max(X)'
924    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
925       typeecrit = 'inst(X)'
926    ELSE
927       typeecrit = type_ecri_files(iff)
928    ENDIF
929
930    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
931       zstophym=zoutm(iff)
932    ELSE
933       zstophym=zdtime
934    ENDIF
935
936    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
937    CALL conf_physoutputs(var%name, var%flag)
938
939    IF(.NOT.clef_stations(iff)) THEN 
940       IF ( var%flag(iff)<=lev_files(iff) ) THEN
941          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
942               iim,jj_nb,nhorim(iff), 1,1,1, -99, 32, &
943               typeecrit, zstophym,zoutm(iff))               
944       ENDIF
945    ELSE
946       IF ( var%flag(iff)<=lev_files(iff)) THEN
947          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
948               npstn,1,nhorim(iff), 1,1,1, -99, 32, &
949               typeecrit, zstophym,zoutm(iff))               
950       ENDIF
951    ENDIF
952
953    ! Set swaero_diag=true if at least one of the concerned variables are defined
954    IF (var%name=='topswad' .OR. var%name=='topswai' .OR. var%name=='solswad' .OR. var%name=='solswai' ) THEN
955       IF  ( var%flag(iff)<=lev_files(iff) ) THEN
956          swaero_diag=.TRUE.
957       END IF
958    END IF
959  END SUBROUTINE histdef2d
960
961  SUBROUTINE histdef3d_old (iff,lpoint,flag_var,nomvar,titrevar,unitvar)
962
963    USE ioipsl
964    USE dimphy
965    USE mod_phys_lmdz_para
966    USE iophy
967
968    IMPLICIT NONE
969
970    INCLUDE "dimensions.h"
971    INCLUDE "temps.h"
972!    INCLUDE "indicesol.h"
973    INCLUDE "clesphys.h"
974
975    INTEGER                          :: iff
976    LOGICAL                          :: lpoint
977    INTEGER, DIMENSION(nfiles)       :: flag_var
978    CHARACTER(LEN=20)                 :: nomvar
979    CHARACTER(LEN=*)                 :: titrevar
980    CHARACTER(LEN=*)                 :: unitvar
981
982    REAL zstophym
983
984    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
985    CALL conf_physoutputs(nomvar,flag_var)
986
987    IF (type_ecri(iff)=='inst(X)'.OR.type_ecri(iff)=='once') THEN
988       zstophym=zoutm(iff)
989    ELSE
990       zstophym=zdtime
991    ENDIF
992
993    IF(.NOT.lpoint) THEN
994       IF ( flag_var(iff)<=lev_files(iff) ) THEN
995          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
996               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
997               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, type_ecri(iff), &
998               zstophym, zoutm(iff))
999       ENDIF
1000    ELSE
1001       IF ( flag_var(iff)<=lev_files(iff) ) THEN
1002          CALL histdef (nid_files(iff), nomvar, titrevar, unitvar, &
1003               npstn,1,nhorim(iff), klev, levmin(iff), &
1004               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
1005               type_ecri(iff), zstophym,zoutm(iff))
1006       ENDIF
1007    ENDIF
1008  END SUBROUTINE histdef3d_old
1009
1010  SUBROUTINE histdef3d (iff,var)
1011
1012    USE ioipsl
1013    USE dimphy
1014    USE mod_phys_lmdz_para
1015    USE iophy
1016
1017    IMPLICIT NONE
1018
1019    INCLUDE "dimensions.h"
1020    INCLUDE "temps.h"
1021    INCLUDE "clesphys.h"
1022
1023    INTEGER                          :: iff
1024    TYPE(ctrl_out)                   :: var
1025
1026    REAL zstophym
1027    CHARACTER(LEN=20) :: typeecrit
1028
1029    ! ug On récupère le type écrit de la structure:
1030    !       Assez moche, à refaire si meilleure méthode...
1031    IF (INDEX(var%type_ecrit(iff), "once") > 0) THEN
1032       typeecrit = 'once'
1033    ELSE IF(INDEX(var%type_ecrit(iff), "t_min") > 0) THEN
1034       typeecrit = 't_min(X)'
1035    ELSE IF(INDEX(var%type_ecrit(iff), "t_max") > 0) THEN
1036       typeecrit = 't_max(X)'
1037    ELSE IF(INDEX(var%type_ecrit(iff), "inst") > 0) THEN
1038       typeecrit = 'inst(X)'
1039    ELSE
1040       typeecrit = type_ecri_files(iff)
1041    ENDIF
1042
1043
1044    ! Appel a la lecture des noms et niveau d'ecriture des variables dans output.def
1045    CALL conf_physoutputs(var%name,var%flag)
1046
1047    IF (typeecrit=='inst(X)'.OR.typeecrit=='once') THEN
1048       zstophym=zoutm(iff)
1049    ELSE
1050       zstophym=zdtime
1051    ENDIF
1052
1053    IF(.NOT.clef_stations(iff)) THEN
1054       IF ( var%flag(iff)<=lev_files(iff) ) THEN
1055          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
1056               iim, jj_nb, nhorim(iff), klev, levmin(iff), &
1057               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, typeecrit, &
1058               zstophym, zoutm(iff))
1059       ENDIF
1060    ELSE
1061       IF ( var%flag(iff)<=lev_files(iff)) THEN
1062          CALL histdef (nid_files(iff), var%name, var%description, var%unit, &
1063               npstn,1,nhorim(iff), klev, levmin(iff), &
1064               levmax(iff)-levmin(iff)+1, nvertm(iff), 32, &
1065               typeecrit, zstophym,zoutm(iff))
1066       ENDIF
1067    ENDIF
1068  END SUBROUTINE histdef3d
1069
1070  SUBROUTINE conf_physoutputs(nam_var,flag_var)
1071!!! Lecture des noms et niveau de sortie des variables dans output.def
1072    !   en utilisant les routines getin de IOIPSL 
1073    use ioipsl
1074
1075    IMPLICIT NONE
1076
1077    include 'iniprint.h'
1078
1079    CHARACTER(LEN=20)                :: nam_var
1080    INTEGER, DIMENSION(nfiles)      :: flag_var
1081
1082    IF(prt_level>10) WRITE(lunout,*)'Avant getin: nam_var flag_var ',nam_var,flag_var(:)
1083    CALL getin('flag_'//nam_var,flag_var)
1084    CALL getin('name_'//nam_var,nam_var)
1085    IF(prt_level>10) WRITE(lunout,*)'Apres getin: nam_var flag_var ',nam_var,flag_var(:)
1086
1087  END SUBROUTINE conf_physoutputs
1088
1089  SUBROUTINE convers_timesteps(str,dtime,timestep)
1090
1091    use ioipsl
1092    USE phys_cal_mod
1093
1094    IMPLICIT NONE
1095
1096    CHARACTER(LEN=20)   :: str
1097    CHARACTER(LEN=10)   :: type
1098    INTEGER             :: ipos,il
1099    real                :: ttt,xxx,timestep,dayseconde,dtime
1100    parameter (dayseconde=86400.)
1101    include "temps.h"
1102    include "comconst.h"
1103    include "iniprint.h"
1104
1105    ipos=scan(str,'0123456789.',.TRUE.)
1106    ! 
1107    il=len_trim(str)
1108    WRITE(lunout,*)ipos,il
1109    read(str(1:ipos),*) ttt
1110    WRITE(lunout,*)ttt
1111    type=str(ipos+1:il)
1112
1113
1114    IF ( il == ipos ) then
1115       type='day'
1116    endif
1117
1118    IF ( type == 'day'.or.type == 'days'.or.type == 'jours'.or.type == 'jour' ) timestep = ttt * dayseconde
1119    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) then
1120       WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
1121       timestep = ttt * dayseconde * mth_len
1122    endif
1123    IF ( type == 'hours'.or.type == 'hr'.or.type == 'heurs') timestep = ttt * dayseconde / 24.
1124    IF ( type == 'mn'.or.type == 'minutes'  ) timestep = ttt * 60.
1125    IF ( type == 's'.or.type == 'sec'.or.type == 'secondes'   ) timestep = ttt
1126    IF ( type == 'TS' ) timestep = ttt * dtime
1127
1128    WRITE(lunout,*)'type =      ',type
1129    WRITE(lunout,*)'nb j/h/m =  ',ttt
1130    WRITE(lunout,*)'timestep(s)=',timestep
1131
1132  END SUBROUTINE convers_timesteps
1133
1134END MODULE phys_output_mod
1135
Note: See TracBrowser for help on using the repository browser.