source: LMDZ6/branches/LMDZ_ECRad/libf/phylmd/phys_output_mod.F90 @ 4203

Last change on this file since 4203 was 4170, checked in by dcugnet, 2 years ago

The variable "types_trac" is the equivalent of "type_trac" in case multiple sections must be read
and used in "tracer.def" file.
Tests on the "type_trac" were replaced with tests on the vector "types_trac".
Most of the time, there are two components: 'lmdz' and a second one. The later has priority on 'lmdz'
and must be used for the tests. For more components, care must be taken to execute specific parts
of the code on the right tracers ; the tracers(:)%component has been created in that respect.

  • Property copyright set to
    Name of program: LMDZ
    Creation date: 1984
    Version: LMDZ5
    License: CeCILL version 2
    Holder: Laboratoire de m\'et\'eorologie dynamique, CNRS, UMR 8539
    See the license file in the root directory
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 24.0 KB
Line 
1! $Id: phys_output_mod.F90 4170 2022-06-16 18:16:59Z lguez $
2!
3
4MODULE phys_output_mod
5  USE indice_sol_mod
6  USE phys_output_var_mod
7  USE phys_output_write_mod, ONLY : phys_output_write
8  REAL, DIMENSION(nfiles),SAVE :: ecrit_files
9
10! Abderrahmane 12 2007
11!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
12!!! Ecreture des Sorties du modele dans les fichiers Netcdf :
13! histmth.nc : moyennes mensuelles
14! histday.nc : moyennes journalieres
15! histhf.nc  : moyennes toutes les 3 heures
16! histins.nc : valeurs instantanees
17!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
18
19CONTAINS
20
21!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
22!!!!!!!!! Ouverture des fichier et definition des variable de sortie !!!!!!!!
23  !! histbeg, histvert et histdef
24!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
25
26  SUBROUTINE phys_output_open(rlon,rlat,pim,tabij,ipt,jpt,plon,plat, &
27       jjmp1,nlevSTD,clevSTD,rlevSTD, dtime, ok_veget, &
28       type_ocean, iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
29       ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz, &
30       phys_out_filestations, &
31       aerosol_couple, flag_aerosol_strat, &
32       pdtphys, paprs, pphis, pplay, lmax_th, ptconv, ptconvth, ivap, &
33       d_u, d_t, qx, d_qx, zmasse, ok_sync)   
34
35    USE iophy
36    USE dimphy
37    USE infotrac_phy, ONLY: nqtot, tracers, niso
38    USE strings_mod,  ONLY: maxlen
39    USE ioipsl
40    USE phys_cal_mod, only : hour, calend
41    USE mod_phys_lmdz_para
42    !Martin
43    USE surface_data, ONLY : landice_opt
44    USE phys_output_ctrlout_mod
45    USE mod_grid_phy_lmdz, only: klon_glo,nbp_lon,nbp_lat
46    USE print_control_mod, ONLY: prt_level,lunout
47    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, aps, bps, pseudoalt
48    USE time_phylmdz_mod, ONLY: day_ini, itau_phy, start_time, annee_ref, day_ref
49#ifdef CPP_XIOS
50    ! ug Pour les sorties XIOS
51    USE wxios
52#endif
53
54    IMPLICIT NONE
55    include "clesphys.h"
56    include "YOMCST.h"
57
58    ! ug Nouveaux arguments n\'ecessaires au histwrite_mod:
59    INTEGER, INTENT(IN)                         :: ivap
60    INTEGER, DIMENSION(klon), INTENT(IN)        :: lmax_th
61    LOGICAL, INTENT(IN)                         :: ok_sync
62    LOGICAL, DIMENSION(klon, klev), INTENT(IN)  :: ptconv, ptconvth
63    REAL, INTENT(IN)                            :: pdtphys
64    REAL, DIMENSION(klon), INTENT(IN)           :: pphis
65    REAL, DIMENSION(klon, klev), INTENT(IN)     :: pplay, d_u, d_t
66    REAL, DIMENSION(klon, klev+1), INTENT(IN)   :: paprs
67    REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx, d_qx
68    REAL, DIMENSION(klon, klev), INTENT(IN)      :: zmasse
69
70
71    REAL,DIMENSION(klon),INTENT(IN) :: rlon
72    REAL,DIMENSION(klon),INTENT(IN) :: rlat
73    INTEGER, INTENT(IN)             :: pim
74    INTEGER, DIMENSION(pim)            :: tabij
75    INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt
76    REAL,DIMENSION(pim), INTENT(IN) :: plat, plon
77    REAL,DIMENSION(pim,2) :: plat_bounds, plon_bounds
78
79    INTEGER                               :: jjmp1
80    INTEGER                               :: nlevSTD, radpas
81    LOGICAL                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
82    LOGICAL                               :: ok_LES,ok_ade,ok_aie
83    INTEGER                               :: flag_aerosol_strat
84    LOGICAL                               :: aerosol_couple
85    INTEGER, INTENT(IN)::  read_climoz ! read ozone climatology
86    !     Allowed values are 0, 1 and 2
87    !     0: do not read an ozone climatology
88    !     1: read a single ozone climatology that will be used day and night
89    !     2: read two ozone climatologies, the average day and night
90    !     climatology and the daylight climatology
91
92    REAL                                  :: dtime
93    INTEGER                               :: idayref
94    REAL                                  :: zjulian_start, zjulian
95    CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
96    REAL, DIMENSION(nlevSTD)              :: rlevSTD
97    INTEGER                               :: nsrf, k, iq, iff, i, j, ilev, itr, ixt, iiso, izone
98    INTEGER                               :: naero
99    LOGICAL                               :: ok_veget
100    INTEGER                               :: iflag_pbl
101    INTEGER                               :: iflag_pbl_split
102    CHARACTER(LEN=4)                      :: bb2
103    CHARACTER(LEN=2)                      :: bb3
104    CHARACTER(LEN=6)                      :: type_ocean
105    INTEGER, DIMENSION(nbp_lon*jjmp1)         ::  ndex2d
106    INTEGER, DIMENSION(nbp_lon*jjmp1*klev)    :: ndex3d
107    INTEGER                               :: imin_ins, imax_ins
108    INTEGER                               :: jmin_ins, jmax_ins
109    INTEGER, DIMENSION(nfiles)            :: phys_out_levmin, phys_out_levmax
110    INTEGER, DIMENSION(nfiles)            :: phys_out_filelevels
111    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep = (/ 'Default', 'Default', 'Default', 'Default', 'Default', &
112                                                             'Default', 'Default', 'Default', 'Default', 'Default' /)
113    LOGICAL, DIMENSION(nfiles)            :: phys_out_filekeys
114    LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
115
116    CHARACTER(LEN=maxlen) :: tnam, lnam, dn
117    INTEGER :: flag(nfiles)
118
119!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
120    !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
121    LOGICAL, DIMENSION(nfiles), SAVE :: &
122      phys_out_regfkey = [.FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE.]
123    REAL,    DIMENSION(nfiles), SAVE :: &
124      phys_out_lonmin  = [  -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.], &
125      phys_out_lonmax  = [   180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.], &
126      phys_out_latmin  = [   -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.], &
127      phys_out_latmax  = [    90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.]
128    REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
129    REAL, DIMENSION(klev+1)   :: lev_index
130               
131#ifdef CPP_XIOS
132    ! ug Variables utilis\'ees pour r\'ecup\'erer le calendrier pour xios
133    INTEGER :: x_an, x_mois, x_jour
134    REAL :: x_heure
135    INTEGER :: ini_an, ini_mois, ini_jour
136    REAL :: ini_heure
137#endif
138    INTEGER                         :: ISW
139    REAL, DIMENSION(NSW)            :: wl1_sun, wl2_sun !wavelength bounds (in um) for SW
140    REAL, DIMENSION(NSW)            :: wn1_sun, wn2_sun !wavenumber bounds (in m-1) for SW
141    REAL, DIMENSION(NSW)            :: spectband  !mean wavenumb. of each sp.band
142    REAL, DIMENSION(NSW,2)          :: spbnds_sun !bounds of spectband
143
144    WRITE(lunout,*) 'Debut phys_output_mod.F90'
145    ! Initialisations (Valeurs par defaut
146
147    DO ilev=1,klev
148      Ahyb_bounds(ilev,1) = ap(ilev)
149      Ahyb_bounds(ilev,2) = ap(ilev+1)
150      Bhyb_bounds(ilev,1) = bp(ilev)
151      Bhyb_bounds(ilev,2) = bp(ilev+1)
152      lev_index(ilev) = REAL(ilev)
153    END DO
154      lev_index(klev+1) = REAL(klev+1)
155
156    IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
157    IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
158    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
159    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
160    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
161    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
162    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
163
164    levmax = [klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev]
165
166    phys_out_filenames(1) = 'histmth'
167    phys_out_filenames(2) = 'histday'
168    phys_out_filenames(3) = 'histhf6h'
169    phys_out_filenames(4) = 'histhf3h'
170    phys_out_filenames(5) = 'histhf3hm'
171    phys_out_filenames(6) = 'histstn'
172    phys_out_filenames(7) = 'histmthNMC'
173    phys_out_filenames(8) = 'histdayNMC'
174    phys_out_filenames(9) = 'histhfNMC'
175    phys_out_filenames(10)= 'histstrataer'
176
177    type_ecri(1) = 'ave(X)'
178    type_ecri(2) = 'ave(X)'
179    type_ecri(3) = 'inst(X)'
180    type_ecri(4) = 'inst(X)'
181    type_ecri(5) = 'ave(X)'
182    type_ecri(6) = 'inst(X)'
183    type_ecri(7) = 'inst(X)'
184    type_ecri(8) = 'inst(X)'
185    type_ecri(9) = 'inst(X)'
186    type_ecri(10)= 'ave(X)'
187
188    clef_files(1) = ok_mensuel
189    clef_files(2) = ok_journe
190    clef_files(3) = ok_hf
191    clef_files(4) = ok_instan
192    clef_files(5) = ok_LES
193    clef_files(6) = ok_instan
194    clef_files(7) = ok_histNMC(1)
195    clef_files(8) = ok_histNMC(2)
196    clef_files(9) = ok_histNMC(3)
197#ifdef CPP_StratAer
198    clef_files(10)= .TRUE.
199#else
200    clef_files(10)= .FALSE.
201#endif
202
203    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
204    clef_stations(1) = .FALSE.
205    clef_stations(2) = .FALSE.
206    clef_stations(3) = .FALSE.
207    clef_stations(4) = .FALSE.
208    clef_stations(5) = .FALSE.
209    clef_stations(6) = .FALSE.
210    clef_stations(7) = .FALSE.
211    clef_stations(8) = .FALSE.
212    clef_stations(9) = .FALSE.
213    clef_stations(10)= .FALSE.
214
215    lev_files(1) = lev_histmth
216    lev_files(2) = lev_histday
217    lev_files(3) = lev_histhf
218    lev_files(4) = lev_histins
219    lev_files(5) = lev_histLES
220    lev_files(6) = lev_histins
221    lev_files(7) = levout_histNMC(1)
222    lev_files(8) = levout_histNMC(2)
223    lev_files(9) = levout_histNMC(3)
224    lev_files(10)= 5
225
226    ecrit_files(1) = ecrit_mth
227    ecrit_files(2) = ecrit_day
228    ecrit_files(3) = ecrit_hf
229    ecrit_files(4) = ecrit_ins
230    ecrit_files(5) = ecrit_LES
231    ecrit_files(6) = ecrit_ins
232    ecrit_files(7) = freq_outNMC(1)
233    ecrit_files(8) = freq_outNMC(2)
234    ecrit_files(9) = freq_outNMC(3)
235    ecrit_files(10)= ecrit_mth
236
237    !! Lectures des parametres de sorties dans physiq.def
238
239    CALL getin('phys_out_regfkey',phys_out_regfkey)
240    CALL getin('phys_out_lonmin',phys_out_lonmin)
241    CALL getin('phys_out_lonmax',phys_out_lonmax)
242    CALL getin('phys_out_latmin',phys_out_latmin)
243    CALL getin('phys_out_latmax',phys_out_latmax)
244    phys_out_levmin(:)=levmin(:)
245    CALL getin('phys_out_levmin',levmin)
246    phys_out_levmax(:)=levmax(:)
247    CALL getin('phys_out_levmax',levmax)
248    CALL getin('phys_out_filenames',phys_out_filenames)
249    phys_out_filekeys(:)=clef_files(:)
250    CALL getin('phys_out_filekeys',clef_files)
251    phys_out_filestations(:)=clef_stations(:)
252    CALL getin('phys_out_filestations',clef_stations)
253    phys_out_filelevels(:)=lev_files(:)
254    CALL getin('phys_out_filelevels',lev_files)
255    CALL getin('phys_out_filetimesteps',chtimestep)
256    phys_out_filetypes(:)=type_ecri(:)
257    CALL getin('phys_out_filetypes',type_ecri)
258
259    type_ecri_files(:)=type_ecri(:)
260
261!    if (ok_all_xml) phys_out_filelevels = 999
262
263    WRITE(lunout,*)'phys_out_lonmin=',phys_out_lonmin
264    WRITE(lunout,*)'phys_out_lonmax=',phys_out_lonmax
265    WRITE(lunout,*)'phys_out_latmin=',phys_out_latmin
266    WRITE(lunout,*)'phys_out_latmax=',phys_out_latmax
267    WRITE(lunout,*)'phys_out_filenames=',phys_out_filenames
268    WRITE(lunout,*)'phys_out_filetypes=',type_ecri
269    WRITE(lunout,*)'phys_out_filekeys=',clef_files
270    WRITE(lunout,*)'phys_out_filestations=',clef_stations
271    WRITE(lunout,*)'phys_out_filelevels=',lev_files
272    WRITE(lunout,*)'phys_out_regfkey=',phys_out_regfkey
273
274! A noter pour
275! l heure initiale - dans les fichiers histoire hist* - on met comme 
276! heure de debut soit la vraie heure (pour le 1D) soit 0h (pour le 3D)
277! afin d avoir une seule sortie mensuelle par mois lorsque l on tourne
278! par annee (IM).
279!
280     idayref = day_ref
281     IF (klon_glo==1) THEN
282       ! current_time (used to compute hour) is updated at the begining of
283       ! the physics; to set the correct outputs "initial time" we thus
284       ! have to use (hour-dtphys).
285         CALL ymds2ju(annee_ref, 1, idayref, hour-pdtphys, zjulian)
286         print *,'phys_output_mod: annee,iday,hour,zjulian=',annee_ref,idayref, hour, zjulian
287     ELSE
288         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
289         CALL ymds2ju(annee_ref, 1, day_ini, start_time*rday, zjulian_start)
290     ENDIF
291
292#ifdef CPP_XIOS
293    ! ug R\'eglage du calendrier xios
294    !Temps julian => an, mois, jour, heure
295    CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
296    CALL ju2ymds(zjulian_start, ini_an, ini_mois, ini_jour, ini_heure)
297    CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure, ini_an, &
298                       ini_mois, ini_jour, ini_heure )
299#endif
300
301!!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
302    ! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
303    ! Appel des histbeg pour definir les variables (nom, moy ou inst, freq de sortie ..
304!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
305
306    zdtime_moy = dtime         ! Frequence ou l on moyenne
307
308
309  ecrit_files(7) = ecrit_files(1)
310  ecrit_files(8) = ecrit_files(2)
311  ecrit_files(9) = ecrit_files(3)
312
313  DO iff=1,nfiles
314
315       ! Calculate ecrit_files for all files
316      IF ( chtimestep(iff).eq.'Default' ) THEN
317          ! Par defaut ecrit_files = (ecrit_mensuel ecrit_jour ecrit_hf
318          ! ...)*86400.
319          ecrit_files(iff)=ecrit_files(iff)*86400.
320      ELSE IF (chtimestep(iff).eq.'-1') THEN
321          PRINT*,'ecrit_files(',iff,') < 0 so IOIPSL work on different'
322          PRINT*,'months length'
323          ecrit_files(iff)=-1.
324      ELSE
325       CALL convers_timesteps(chtimestep(iff),dtime,ecrit_files(iff))
326      ENDIF
327
328       WRITE(lunout,*)'ecrit_files(',iff,')= ',ecrit_files(iff)
329       zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
330
331
332#ifdef CPP_XIOS
333!!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
334    IF (.not. ok_all_xml) THEN
335      IF (prt_level >= 10) THEN
336        print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))   
337      ENDIF
338      CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff)) 
339    ENDIF
340
341!!! Declaration des axes verticaux de chaque fichier:
342    IF (prt_level >= 10) THEN
343      print*,'phys_output_open: Declare vertical axes for each file'
344    ENDIF
345
346   IF (iff.LE.6.OR.iff.EQ.10) THEN
347    CALL wxios_add_vaxis("presnivs", &
348            levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
349    CALL wxios_add_vaxis("Ahyb", &
350            levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
351            bnds=Ahyb_bounds(levmin(iff):levmax(iff),:))
352    CALL wxios_add_vaxis("Bhyb", &
353            levmax(iff) - levmin(iff) + 1, bps(levmin(iff):levmax(iff)), positif='down', &
354            bnds=Bhyb_bounds(levmin(iff):levmax(iff),:))
355    CALL wxios_add_vaxis("klev", levmax(iff) - levmin(iff) + 1, &
356                          lev_index(levmin(iff):levmax(iff)))
357    CALL wxios_add_vaxis("klevp1", klev+1, &
358                          lev_index(1:klev+1))
359    CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
360
361    CALL wxios_add_vaxis("Alt", &
362            levmax(iff) - levmin(iff) + 1, pseudoalt)
363
364    ! wl1_sun/wl2_sun: minimum/maximum bound of wavelength (in um)
365    SELECT CASE(NSW)
366      CASE(6)
367        wl1_sun(1:6) = [0.180, 0.250, 0.440, 0.690, 1.190, 2.380]
368        wl2_sun(1:6) = [0.250, 0.440, 0.690, 1.190, 2.380, 4.000]
369      CASE(2)
370        wl1_sun(1:2) = [0.250, 0.690]
371        wl2_sun(1:2) = [0.690, 4.000]
372    END SELECT
373
374    DO ISW=1, NSW
375     wn1_sun(ISW)=1.e+6/wl1_sun(ISW)
376     wn2_sun(ISW)=1.e+6/wl2_sun(ISW)
377     spbnds_sun(ISW,1)=wn2_sun(ISW)
378     spbnds_sun(ISW,2)=wn1_sun(ISW)
379     spectband(ISW)=(wn1_sun(ISW)+wn2_sun(ISW))/2
380    ENDDO
381!
382!!! ajout axe vertical spectband : solar band number
383    CALL wxios_add_vaxis("spectband", NSW, spectband, positif='down')
384   ELSE
385    ! NMC files
386    CALL wxios_add_vaxis("plev", &
387            levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
388   ENDIF
389#endif
390
391        IF (clef_files(iff)) THEN
392!!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
393!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
394          IF (phys_out_regfkey(iff)) THEN
395             imin_ins=1
396             imax_ins=nbp_lon
397             jmin_ins=1
398             jmax_ins=jjmp1
399
400             ! correction abderr       
401             DO i=1,nbp_lon
402                WRITE(lunout,*)'io_lon(i)=',io_lon(i)
403                IF (io_lon(i).le.phys_out_lonmin(iff)) imin_ins=i
404                IF (io_lon(i).le.phys_out_lonmax(iff)) imax_ins=i+1
405             ENDDO
406
407             DO j=1,jjmp1
408                WRITE(lunout,*)'io_lat(j)=',io_lat(j)
409                IF (io_lat(j).ge.phys_out_latmin(iff)) jmax_ins=j+1
410                IF (io_lat(j).ge.phys_out_latmax(iff)) jmin_ins=j
411             ENDDO
412
413             WRITE(lunout,*)'On stoke le fichier histoire numero ',iff,' sur ', &
414                  imin_ins,imax_ins,jmin_ins,jmax_ins
415             WRITE(lunout,*)'longitudes : ', &
416                  io_lon(imin_ins),io_lon(imax_ins), &
417                  'latitudes : ', &
418                  io_lat(jmax_ins),io_lat(jmin_ins)
419
420             CALL histbeg(phys_out_filenames(iff),nbp_lon,io_lon,jjmp1,io_lat, &
421                  imin_ins,imax_ins-imin_ins+1, &
422                  jmin_ins,jmax_ins-jmin_ins+1, &
423                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
424!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
425             !IM fichiers stations
426          ELSE IF (clef_stations(iff)) THEN
427
428             IF (prt_level >= 10) THEN
429             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
430             ENDIF
431             
432             CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
433                  phys_out_filenames(iff), &
434                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
435          ELSE
436
437             IF (prt_level >= 10) THEN
438             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
439             ENDIF
440
441             CALL histbeg_phy_all(phys_out_filenames(iff),itau_phy,zjulian,&
442                 dtime,nhorim(iff),nid_files(iff))
443          ENDIF
444
445#ifndef CPP_IOIPSL_NO_OUTPUT
446          IF (iff.LE.6.OR.iff.EQ.10) THEN
447             CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", & 
448               levmax(iff) - levmin(iff) + 1, &
449               presnivs(levmin(iff):levmax(iff)), nvertm(iff),"down")
450!!!! Composantes de la coordonnee sigma-hybride
451          CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
452               levmax(iff) - levmin(iff) + 1,aps,nvertap(iff))
453
454          CALL histvert(nid_files(iff), "Bhyb","Bhyb comp of Hyb Cord", " ", &
455               levmax(iff) - levmin(iff) + 1,bps,nvertbp(iff))
456
457          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &                       
458               levmax(iff) - levmin(iff) + 1,pseudoalt,nvertAlt(iff))
459
460          ELSE
461          ! NMC files
462             CALL histvert(nid_files(iff), "plev", "pressure", "Pa", &
463               levmax(iff) - levmin(iff) + 1, &
464              rlevSTD(levmin(iff):levmax(iff)), nvertm(iff), "down")
465          ENDIF
466#endif
467
468     ENDIF ! clef_files
469
470          itr = 0
471          DO iq = 1, nqtot
472            IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
473            itr = itr + 1
474            dn = 'd'//TRIM(tracers(iq)%name)//'_'
475
476            flag = [1, 5, 5, 5, 10, 10, 11, 11, 11, 11]
477            lnam = 'Tracer '//TRIM(tracers(iq)%longName)
478            tnam = TRIM(tracers(iq)%name);  o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
479
480            flag = [4, 7, 7, 7, 10, 10, 11, 11, 11, 11]
481            lnam = 'Tendance tracer '//TRIM(tracers(iq)%longName)
482            tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
483
484            flag = [5, 7, 7, 7, 10, 10, 11, 11, 11, 11]
485            tnam = TRIM(dn)//'the';         o_dtr_the       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
486            tnam = TRIM(dn)//'con';         o_dtr_con       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
487
488            flag = [7, 7, 7, 7, 10, 10, 11, 11, 11, 11]
489            tnam = TRIM(dn)//'lessi_impa';  o_dtr_lessi_impa(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
490            tnam = TRIM(dn)//'lessi_nucl';  o_dtr_lessi_nucl(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
491            tnam = TRIM(dn)//'insc';        o_dtr_insc      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
492            tnam = TRIM(dn)//'bcscav';      o_dtr_bcscav    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
493            tnam = TRIM(dn)//'evapls';      o_dtr_evapls    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
494            tnam = TRIM(dn)//'ls';          o_dtr_ls        (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
495            tnam = TRIM(dn)//'trsp';        o_dtr_trsp      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
496            tnam = TRIM(dn)//'sscav';       o_dtr_sscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
497            tnam = TRIM(dn)//'sat';         o_dtr_sat       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
498            tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
499
500            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iq)%longName)
501            tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
502
503            flag = [1, 4, 10, 10, 10, 10, 11, 11, 11, 11]
504            lnam = 'Cumulated tracer '//TRIM(tracers(iq)%longName)
505            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
506          ENDDO
507
508   ENDDO !  iff
509
510    ! Updated write frequencies due to phys_out_filetimesteps.
511    ! Write frequencies are now in seconds. 
512    ecrit_mth = ecrit_files(1)
513    ecrit_day = ecrit_files(2)
514    ecrit_hf  = ecrit_files(3)
515    ecrit_ins = ecrit_files(4)
516    ecrit_LES = ecrit_files(5)
517    ecrit_ins = ecrit_files(6)
518
519    IF (prt_level >= 10) THEN
520      WRITE(lunout,*)'swaerofree_diag=',swaerofree_diag
521      WRITE(lunout,*)'swaero_diag=',swaero_diag
522      WRITE(lunout,*)'dryaod_diag=',dryaod_diag
523      WRITE(lunout,*)'ok_4xCO2atm=',ok_4xCO2atm
524      WRITE(lunout,*)'phys_output_open: ends here'
525    ENDIF
526
527!  DO iq=1,nqtot
528!    IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
529!    WRITE(*,'(a,i1,a,10i3)')'trac(',iq,')%flag = ',o_trac(iq)%flag
530!    WRITE(*,'(a,i1,a)')'trac(',iq,')%name = '//TRIM(o_trac(iq)%name)
531!    WRITE(*,'(a,i1,a)')'trac(',iq,')%description = '//TRIM(o_trac(iq)%description)
532!  END DO
533
534  END SUBROUTINE phys_output_open
535
536  SUBROUTINE convers_timesteps(str,dtime,timestep)
537
538    use ioipsl
539    USE phys_cal_mod
540    USE time_phylmdz_mod, ONLY: day_ref, annee_ref
541    USE print_control_mod, ONLY: lunout
542
543    IMPLICIT NONE
544
545    CHARACTER(LEN=20)   :: str
546    CHARACTER(LEN=10)   :: type
547    INTEGER             :: ipos,il
548    real                :: ttt,xxx,timestep,dayseconde,dtime
549    parameter (dayseconde=86400.)
550
551    ipos=scan(str,'0123456789.',.TRUE.)
552    ! 
553    il=len_trim(str)
554    WRITE(lunout,*) "ipos = ", ipos
555    WRITE(lunout,*) "il = ", il
556    IF (ipos == 0) CALL abort_physic("convers_timesteps", "bad str", 1)
557    read(str(1:ipos),*) ttt
558    WRITE(lunout,*)ttt
559    type=str(ipos+1:il)
560
561    IF ( il == ipos ) THEN
562       type='day'
563    ENDIF
564
565    IF ( type == 'day'.or.type == 'days'.or.type == 'jours'.or.type == 'jour' ) timestep = ttt * dayseconde
566    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) THEN
567       WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
568       timestep = ttt * dayseconde * mth_len
569    ENDIF
570    IF ( type == 'hours'.or.type == 'hr'.or.type == 'heurs') timestep = ttt * dayseconde / 24.
571    IF ( type == 'mn'.or.type == 'minutes'  ) timestep = ttt * 60.
572    IF ( type == 's'.or.type == 'sec'.or.type == 'secondes'   ) timestep = ttt
573    IF ( type == 'TS' ) timestep = ttt * dtime
574
575    WRITE(lunout,*)'type =      ',type
576    WRITE(lunout,*)'nb j/h/m =  ',ttt
577    WRITE(lunout,*)'timestep(s)=',timestep
578
579  END SUBROUTINE convers_timesteps
580
581END MODULE phys_output_mod
Note: See TracBrowser for help on using the repository browser.