source: LMDZ6/trunk/libf/phylmd/phys_output_mod.F90 @ 5056

Last change on this file since 5056 was 5056, checked in by Sebastien Nguyen, 8 weeks ago

convergence of phylmdiso and phylmd

  • 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 Id
File size: 29.9 KB
Line 
1! $Id: phys_output_mod.F90 5056 2024-07-16 09:45:07Z snguyen $
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, ntraciso=>ntiso
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, presinter
48    USE time_phylmdz_mod, ONLY: day_ini, itau_phy, start_time, annee_ref, day_ref
49    ! ug Pour les sorties XIOS
50    USE wxios
51#ifdef CPP_StratAer
52   USE infotrac_phy, ONLY: nbtr_bin
53#endif
54#ifdef ISO
55    USE isotopes_mod, ONLY: isoName,iso_HTO
56#ifdef ISOTRAC
57    use isotrac_mod, only: index_zone,index_iso,strtrac
58#endif
59#endif
60
61    IMPLICIT NONE
62    include "clesphys.h"
63    include "YOMCST.h"
64
65    ! ug Nouveaux arguments n\'ecessaires au histwrite_mod:
66    INTEGER, INTENT(IN)                         :: ivap
67    INTEGER, DIMENSION(klon), INTENT(IN)        :: lmax_th
68    LOGICAL, INTENT(IN)                         :: ok_sync
69    LOGICAL, DIMENSION(klon, klev), INTENT(IN)  :: ptconv, ptconvth
70    REAL, INTENT(IN)                            :: pdtphys
71    REAL, DIMENSION(klon), INTENT(IN)           :: pphis
72    REAL, DIMENSION(klon, klev), INTENT(IN)     :: pplay, d_u, d_t
73    REAL, DIMENSION(klon, klev+1), INTENT(IN)   :: paprs
74    REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx, d_qx
75    REAL, DIMENSION(klon, klev), INTENT(IN)      :: zmasse
76
77
78    REAL,DIMENSION(klon),INTENT(IN) :: rlon
79    REAL,DIMENSION(klon),INTENT(IN) :: rlat
80    INTEGER, INTENT(IN)             :: pim
81    INTEGER, DIMENSION(pim)            :: tabij
82    INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt
83    REAL,DIMENSION(pim), INTENT(IN) :: plat, plon
84    REAL,DIMENSION(pim,2) :: plat_bounds, plon_bounds
85
86    INTEGER                               :: jjmp1
87    INTEGER                               :: nlevSTD, radpas
88    LOGICAL                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
89    LOGICAL                               :: ok_LES,ok_ade,ok_aie
90    INTEGER                               :: flag_aerosol_strat
91    LOGICAL                               :: aerosol_couple
92    INTEGER, INTENT(IN)::  read_climoz ! read ozone climatology
93    !     Allowed values are 0, 1 and 2
94    !     0: do not read an ozone climatology
95    !     1: read a single ozone climatology that will be used day and night
96    !     2: read two ozone climatologies, the average day and night
97    !     climatology and the daylight climatology
98
99    REAL                                  :: dtime
100    INTEGER                               :: idayref
101    REAL                                  :: zjulian_start, zjulian
102    CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
103    REAL, DIMENSION(nlevSTD)              :: rlevSTD
104    INTEGER                               :: nsrf, k, iq, iff, i, j, ilev, itr, itrb, ixt, iiso, izone
105    INTEGER                               :: naero
106    LOGICAL                               :: ok_veget
107    INTEGER                               :: iflag_pbl
108    INTEGER                               :: iflag_pbl_split
109    CHARACTER(LEN=4)                      :: bb2
110    CHARACTER(LEN=2)                      :: bb3
111    CHARACTER(LEN=6)                      :: type_ocean
112    INTEGER, DIMENSION(nbp_lon*jjmp1)         ::  ndex2d
113    INTEGER, DIMENSION(nbp_lon*jjmp1*klev)    :: ndex3d
114    INTEGER                               :: imin_ins, imax_ins
115    INTEGER                               :: jmin_ins, jmax_ins
116    INTEGER, DIMENSION(nfiles)            :: phys_out_levmin, phys_out_levmax
117    INTEGER, DIMENSION(nfiles)            :: phys_out_filelevels
118    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep = (/ 'Default', 'Default', 'Default', 'Default', 'Default', &
119                                                             'Default', 'Default', 'Default', 'Default', 'Default' /)
120    LOGICAL, DIMENSION(nfiles)            :: phys_out_filekeys
121    LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
122
123#ifdef ISO
124    CHARACTER(LEN=maxlen) :: outiso
125    CHARACTER(LEN=20) :: unit
126#endif
127    CHARACTER(LEN=maxlen) :: tnam, lnam, dn
128    INTEGER :: flag(nfiles)
129
130!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
131    !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
132    LOGICAL, DIMENSION(nfiles), SAVE :: &
133      phys_out_regfkey = [.FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE.]
134    REAL,    DIMENSION(nfiles), SAVE :: &
135      phys_out_lonmin  = [  -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.], &
136      phys_out_lonmax  = [   180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.], &
137      phys_out_latmin  = [   -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.], &
138      phys_out_latmax  = [    90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.]
139    REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
140    REAL, DIMENSION(klev+1)   :: lev_index
141               
142    ! ug Variables utilis\'ees pour r\'ecup\'erer le calendrier pour xios
143    INTEGER :: x_an, x_mois, x_jour
144    REAL :: x_heure
145    INTEGER :: ini_an, ini_mois, ini_jour
146    REAL :: ini_heure
147
148    INTEGER                         :: ISW
149    REAL, DIMENSION(NSW)            :: wl1_sun, wl2_sun !wavelength bounds (in um) for SW
150    REAL, DIMENSION(NSW)            :: wn1_sun, wn2_sun !wavenumber bounds (in m-1) for SW
151    REAL, DIMENSION(NSW)            :: spectband  !mean wavenumb. of each sp.band
152    REAL, DIMENSION(NSW,2)          :: spbnds_sun !bounds of spectband
153
154    WRITE(lunout,*) 'Debut phys_output_mod.F90'
155    ! Initialisations (Valeurs par defaut
156
157    DO ilev=1,klev
158      Ahyb_bounds(ilev,1) = ap(ilev)
159      Ahyb_bounds(ilev,2) = ap(ilev+1)
160      Bhyb_bounds(ilev,1) = bp(ilev)
161      Bhyb_bounds(ilev,2) = bp(ilev+1)
162      lev_index(ilev) = REAL(ilev)
163    END DO
164      lev_index(klev+1) = REAL(klev+1)
165
166    IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
167    IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
168    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
169    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
170    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
171    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
172    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
173#ifdef CPP_StratAer
174    ALLOCATE(o_nd_mode(nbtr_bin),o_sulfmmr_mode(nbtr_bin))
175#endif
176#ifdef ISO
177    ALLOCATE(o_xtprecip(ntraciso))
178    ALLOCATE(o_xtplul(ntraciso))
179    ALLOCATE(o_xtpluc(ntraciso))
180    ALLOCATE(o_xtevap(ntraciso))
181    ALLOCATE(o_xtevap_srf(ntraciso,4))
182    ALLOCATE(o_xtovap(ntraciso))
183    ALLOCATE(o_xtoliq(ntraciso))
184    ALLOCATE(o_xtcond(ntraciso))
185    ALLOCATE(o_xtrunoff_diag(ntraciso))
186    ALLOCATE(o_dxtdyn(ntraciso))
187    ALLOCATE(o_dxtldyn(ntraciso))
188    ALLOCATE(o_dxtcon(ntraciso))
189    ALLOCATE(o_dxtlsc(ntraciso))
190    ALLOCATE(o_dxteva(ntraciso))
191    ALLOCATE(o_dxtajs(ntraciso))
192    ALLOCATE(o_dxtvdf(ntraciso))
193    ALLOCATE(o_dxtthe(ntraciso))
194    ALLOCATE(o_dxtch4(ntraciso))
195    if (iso_HTO.gt.0) then
196      ALLOCATE(o_dxtprod_nucl(ntraciso))
197      ALLOCATE(o_dxtcosmo(ntraciso))
198      ALLOCATE(o_dxtdecroiss(ntraciso))
199    endif
200#endif
201
202    levmax = [klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev]
203
204    phys_out_filenames(1) = 'histmth'
205    phys_out_filenames(2) = 'histday'
206    phys_out_filenames(3) = 'histhf6h'
207    phys_out_filenames(4) = 'histhf3h'
208    phys_out_filenames(5) = 'histhf3hm'
209    phys_out_filenames(6) = 'histstn'
210    phys_out_filenames(7) = 'histmthNMC'
211    phys_out_filenames(8) = 'histdayNMC'
212    phys_out_filenames(9) = 'histhfNMC'
213    phys_out_filenames(10)= 'histstrataer'
214
215    type_ecri(1) = 'ave(X)'
216    type_ecri(2) = 'ave(X)'
217    type_ecri(3) = 'inst(X)'
218    type_ecri(4) = 'inst(X)'
219    type_ecri(5) = 'ave(X)'
220    type_ecri(6) = 'inst(X)'
221    type_ecri(7) = 'inst(X)'
222    type_ecri(8) = 'inst(X)'
223    type_ecri(9) = 'inst(X)'
224    type_ecri(10)= 'ave(X)'
225
226    clef_files(1) = ok_mensuel
227    clef_files(2) = ok_journe
228    clef_files(3) = ok_hf
229    clef_files(4) = ok_instan
230    clef_files(5) = ok_LES
231    clef_files(6) = ok_instan
232    clef_files(7) = ok_histNMC(1)
233    clef_files(8) = ok_histNMC(2)
234    clef_files(9) = ok_histNMC(3)
235#ifdef CPP_StratAer
236    clef_files(10)= .TRUE.
237#else
238    clef_files(10)= .FALSE.
239#endif
240
241    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
242    clef_stations(1) = .FALSE.
243    clef_stations(2) = .FALSE.
244    clef_stations(3) = .FALSE.
245    clef_stations(4) = .FALSE.
246    clef_stations(5) = .FALSE.
247    clef_stations(6) = .FALSE.
248    clef_stations(7) = .FALSE.
249    clef_stations(8) = .FALSE.
250    clef_stations(9) = .FALSE.
251    clef_stations(10)= .FALSE.
252
253    lev_files(1) = lev_histmth
254    lev_files(2) = lev_histday
255    lev_files(3) = lev_histhf
256    lev_files(4) = lev_histins
257    lev_files(5) = lev_histLES
258    lev_files(6) = lev_histins
259    lev_files(7) = levout_histNMC(1)
260    lev_files(8) = levout_histNMC(2)
261    lev_files(9) = levout_histNMC(3)
262    lev_files(10)= 5
263
264    ecrit_files(1) = ecrit_mth
265    ecrit_files(2) = ecrit_day
266    ecrit_files(3) = ecrit_hf
267    ecrit_files(4) = ecrit_ins
268    ecrit_files(5) = ecrit_LES
269    ecrit_files(6) = ecrit_ins
270    ecrit_files(7) = freq_outNMC(1)
271    ecrit_files(8) = freq_outNMC(2)
272    ecrit_files(9) = freq_outNMC(3)
273    ecrit_files(10)= ecrit_mth
274
275    !! Lectures des parametres de sorties dans physiq.def
276
277    CALL getin('phys_out_regfkey',phys_out_regfkey)
278    CALL getin('phys_out_lonmin',phys_out_lonmin)
279    CALL getin('phys_out_lonmax',phys_out_lonmax)
280    CALL getin('phys_out_latmin',phys_out_latmin)
281    CALL getin('phys_out_latmax',phys_out_latmax)
282    phys_out_levmin(:)=levmin(:)
283    CALL getin('phys_out_levmin',levmin)
284    phys_out_levmax(:)=levmax(:)
285    CALL getin('phys_out_levmax',levmax)
286    CALL getin('phys_out_filenames',phys_out_filenames)
287    phys_out_filekeys(:)=clef_files(:)
288    CALL getin('phys_out_filekeys',clef_files)
289    phys_out_filestations(:)=clef_stations(:)
290    CALL getin('phys_out_filestations',clef_stations)
291    phys_out_filelevels(:)=lev_files(:)
292    CALL getin('phys_out_filelevels',lev_files)
293    CALL getin('phys_out_filetimesteps',chtimestep)
294    phys_out_filetypes(:)=type_ecri(:)
295    CALL getin('phys_out_filetypes',type_ecri)
296
297    type_ecri_files(:)=type_ecri(:)
298
299!    if (ok_all_xml) phys_out_filelevels = 999
300
301    WRITE(lunout,*)'phys_out_lonmin=',phys_out_lonmin
302    WRITE(lunout,*)'phys_out_lonmax=',phys_out_lonmax
303    WRITE(lunout,*)'phys_out_latmin=',phys_out_latmin
304    WRITE(lunout,*)'phys_out_latmax=',phys_out_latmax
305    WRITE(lunout,*)'phys_out_filenames=',phys_out_filenames
306    WRITE(lunout,*)'phys_out_filetypes=',type_ecri
307    WRITE(lunout,*)'phys_out_filekeys=',clef_files
308    WRITE(lunout,*)'phys_out_filestations=',clef_stations
309    WRITE(lunout,*)'phys_out_filelevels=',lev_files
310    WRITE(lunout,*)'phys_out_regfkey=',phys_out_regfkey
311
312! A noter pour
313! l heure initiale - dans les fichiers histoire hist* - on met comme 
314! heure de debut soit la vraie heure (pour le 1D) soit 0h (pour le 3D)
315! afin d avoir une seule sortie mensuelle par mois lorsque l on tourne
316! par annee (IM).
317!
318     idayref = day_ref
319     IF (klon_glo==1) THEN
320       ! current_time (used to compute hour) is updated at the begining of
321       ! the physics; to set the correct outputs "initial time" we thus
322       ! have to use (hour-dtphys).
323         CALL ymds2ju(annee_ref, 1, idayref, hour-pdtphys, zjulian)
324         print *,'phys_output_mod: annee,iday,hour,zjulian=',annee_ref,idayref, hour, zjulian
325     ELSE
326         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
327         CALL ymds2ju(annee_ref, 1, day_ini, start_time*rday, zjulian_start)
328     ENDIF
329
330    IF (using_xios) THEN
331      ! ug R\'eglage du calendrier xios
332      !Temps julian => an, mois, jour, heure
333      CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
334      CALL ju2ymds(zjulian_start, ini_an, ini_mois, ini_jour, ini_heure)
335      CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure, ini_an, &
336                         ini_mois, ini_jour, ini_heure )
337    ENDIF
338
339!!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
340    ! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
341    ! Appel des histbeg pour definir les variables (nom, moy ou inst, freq de sortie ..
342!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
343
344    zdtime_moy = dtime         ! Frequence ou l on moyenne
345
346
347  ecrit_files(7) = ecrit_files(1)
348  ecrit_files(8) = ecrit_files(2)
349  ecrit_files(9) = ecrit_files(3)
350
351  DO iff=1,nfiles
352
353       ! Calculate ecrit_files for all files
354      IF ( chtimestep(iff).eq.'Default' ) THEN
355          ! Par defaut ecrit_files = (ecrit_mensuel ecrit_jour ecrit_hf
356          ! ...)*86400.
357          ecrit_files(iff)=ecrit_files(iff)*86400.
358      ELSE IF (chtimestep(iff).eq.'-1') THEN
359          PRINT*,'ecrit_files(',iff,') < 0 so IOIPSL work on different'
360          PRINT*,'months length'
361          ecrit_files(iff)=-1.
362      ELSE
363       CALL convers_timesteps(chtimestep(iff),dtime,ecrit_files(iff))
364      ENDIF
365
366       WRITE(lunout,*)'ecrit_files(',iff,')= ',ecrit_files(iff)
367       zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
368
369
370    IF (using_xios) THEN
371      !!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
372      IF (.not. ok_all_xml) THEN
373        IF (prt_level >= 10) THEN
374         print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))   
375        ENDIF
376        CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff)) 
377      ENDIF
378
379      !!! Declaration des axes verticaux de chaque fichier:
380      IF (prt_level >= 10) THEN
381        print*,'phys_output_open: Declare vertical axes for each file'
382      ENDIF
383
384      IF (iff.LE.6.OR.iff.EQ.10) THEN
385        CALL wxios_add_vaxis("presnivs", &
386              levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
387        CALL wxios_add_vaxis("presinter", &
388              klev + 1, presinter(1:klev+1))
389        CALL wxios_add_vaxis("Ahyb", &
390              levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
391              bnds=Ahyb_bounds(levmin(iff):levmax(iff),:))
392        CALL wxios_add_vaxis("Bhyb", &
393              levmax(iff) - levmin(iff) + 1, bps(levmin(iff):levmax(iff)), positif='down', &
394              bnds=Bhyb_bounds(levmin(iff):levmax(iff),:))
395        CALL wxios_add_vaxis("klev", levmax(iff) - levmin(iff) + 1, &
396                              lev_index(levmin(iff):levmax(iff)))
397        CALL wxios_add_vaxis("klevp1", klev+1, &
398                              lev_index(1:klev+1))
399        CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
400 
401        CALL wxios_add_vaxis("Alt", &
402                levmax(iff) - levmin(iff) + 1, pseudoalt)
403
404        ! wl1_sun/wl2_sun: minimum/maximum bound of wavelength (in um)
405        SELECT CASE(NSW)
406          CASE(6)
407            wl1_sun(1:6) = [0.180, 0.250, 0.440, 0.690, 1.190, 2.380]
408            wl2_sun(1:6) = [0.250, 0.440, 0.690, 1.190, 2.380, 4.000]
409          CASE(2)
410            wl1_sun(1:2) = [0.250, 0.690]
411            wl2_sun(1:2) = [0.690, 4.000]
412        END SELECT
413
414        DO ISW=1, NSW
415          wn1_sun(ISW)=1.e+6/wl1_sun(ISW)
416          wn2_sun(ISW)=1.e+6/wl2_sun(ISW)
417          spbnds_sun(ISW,1)=wn2_sun(ISW)
418          spbnds_sun(ISW,2)=wn1_sun(ISW)
419          spectband(ISW)=(wn1_sun(ISW)+wn2_sun(ISW))/2
420        ENDDO
421!
422!!! ajout axe vertical spectband : solar band number
423        CALL wxios_add_vaxis("spectband", NSW, spectband, positif='down')
424      ELSE
425        ! NMC files
426        CALL wxios_add_vaxis("plev", &
427                levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
428      ENDIF
429    ENDIF !using_xios
430
431        IF (clef_files(iff)) THEN
432!!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
433!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
434          IF (phys_out_regfkey(iff)) THEN
435             imin_ins=1
436             imax_ins=nbp_lon
437             jmin_ins=1
438             jmax_ins=jjmp1
439
440             ! correction abderr       
441             DO i=1,nbp_lon
442                WRITE(lunout,*)'io_lon(i)=',io_lon(i)
443                IF (io_lon(i).le.phys_out_lonmin(iff)) imin_ins=i
444                IF (io_lon(i).le.phys_out_lonmax(iff)) imax_ins=i+1
445             ENDDO
446
447             DO j=1,jjmp1
448                WRITE(lunout,*)'io_lat(j)=',io_lat(j)
449                IF (io_lat(j).ge.phys_out_latmin(iff)) jmax_ins=j+1
450                IF (io_lat(j).ge.phys_out_latmax(iff)) jmin_ins=j
451             ENDDO
452
453             WRITE(lunout,*)'On stoke le fichier histoire numero ',iff,' sur ', &
454                  imin_ins,imax_ins,jmin_ins,jmax_ins
455             WRITE(lunout,*)'longitudes : ', &
456                  io_lon(imin_ins),io_lon(imax_ins), &
457                  'latitudes : ', &
458                  io_lat(jmax_ins),io_lat(jmin_ins)
459
460             CALL histbeg(phys_out_filenames(iff),nbp_lon,io_lon,jjmp1,io_lat, &
461                  imin_ins,imax_ins-imin_ins+1, &
462                  jmin_ins,jmax_ins-jmin_ins+1, &
463                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
464!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
465             !IM fichiers stations
466          ELSE IF (clef_stations(iff)) THEN
467
468             IF (prt_level >= 10) THEN
469             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
470             ENDIF
471             
472             CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
473                  phys_out_filenames(iff), &
474                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
475          ELSE
476
477             IF (prt_level >= 10) THEN
478             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
479             ENDIF
480
481             CALL histbeg_phy_all(phys_out_filenames(iff),itau_phy,zjulian,&
482                 dtime,nhorim(iff),nid_files(iff))
483          ENDIF
484
485#ifndef CPP_IOIPSL_NO_OUTPUT
486          IF (iff.LE.6.OR.iff.EQ.10) THEN
487             CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", & 
488               levmax(iff) - levmin(iff) + 1, &
489               presnivs(levmin(iff):levmax(iff)), nvertm(iff),"down")
490!!!! Composantes de la coordonnee sigma-hybride
491          CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
492               levmax(iff) - levmin(iff) + 1,aps,nvertap(iff))
493
494          CALL histvert(nid_files(iff), "Bhyb","Bhyb comp of Hyb Cord", " ", &
495               levmax(iff) - levmin(iff) + 1,bps,nvertbp(iff))
496
497          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &                       
498               levmax(iff) - levmin(iff) + 1,pseudoalt,nvertAlt(iff))
499
500          ELSE
501          ! NMC files
502             CALL histvert(nid_files(iff), "plev", "pressure", "Pa", &
503               levmax(iff) - levmin(iff) + 1, &
504              rlevSTD(levmin(iff):levmax(iff)), nvertm(iff), "down")
505          ENDIF
506#endif
507
508     ENDIF ! clef_files
509
510          itr = 0; itrb = 0
511          DO iq = 1, nqtot
512            IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
513            itr = itr + 1
514            dn = 'd'//TRIM(tracers(iq)%name)//'_'
515
516            flag = [1, 5, 5, 5, 10, 10, 11, 11, 11, 11]
517            lnam = 'Tracer '//TRIM(tracers(iq)%longName)
518            tnam = TRIM(tracers(iq)%name);  o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
519
520            flag = [4, 7, 7, 7, 10, 10, 11, 11, 11, 11]
521            lnam = 'Tendance tracer '//TRIM(tracers(iq)%longName)
522            tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
523
524            flag = [5, 7, 7, 7, 10, 10, 11, 11, 11, 11]
525            tnam = TRIM(dn)//'the';         o_dtr_the       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
526            tnam = TRIM(dn)//'con';         o_dtr_con       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
527
528            flag = [7, 7, 7, 7, 10, 10, 11, 11, 11, 11]
529            tnam = TRIM(dn)//'lessi_impa';  o_dtr_lessi_impa(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
530            tnam = TRIM(dn)//'lessi_nucl';  o_dtr_lessi_nucl(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
531            tnam = TRIM(dn)//'insc';        o_dtr_insc      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
532            tnam = TRIM(dn)//'bcscav';      o_dtr_bcscav    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
533            tnam = TRIM(dn)//'evapls';      o_dtr_evapls    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
534            tnam = TRIM(dn)//'ls';          o_dtr_ls        (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
535            tnam = TRIM(dn)//'trsp';        o_dtr_trsp      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
536            tnam = TRIM(dn)//'sscav';       o_dtr_sscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
537            tnam = TRIM(dn)//'sat';         o_dtr_sat       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
538            tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
539
540            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iq)%longName)
541            tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
542
543            flag = [1, 4, 10, 10, 10, 10, 11, 11, 11, 11]
544            lnam = 'Cumulated tracer '//TRIM(tracers(iq)%longName)
545            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
546           
547#ifdef CPP_StratAer
548            if(tracers(iq)%name(1:3)=='BIN') then
549               itrb = itrb + 1
550               flag = [11, 11, 11, 11, 11, 11, 11, 11, 11, 1]
551               lnam = 'Dry particle concentration in '//TRIM(tracers(iq)%longName)
552               tnam = TRIM(tracers(iq)%name)//'_nd_mode';     o_nd_mode       (itrb) = ctrl_out(flag, tnam, lnam, "part/m3", [('',i=1,nfiles)])
553               lnam = 'Sulfate MMR in '//TRIM(tracers(iq)%longName)
554               tnam = TRIM(tracers(iq)%name)//'_sulfmmr_mode';o_sulfmmr_mode  (itrb) = ctrl_out(flag, tnam, lnam, "kg(H2SO4)/kg(air)", [('',i=1,nfiles)])
555            endif
556#endif
557         ENDDO
558
559   ENDDO !  iff
560
561#ifdef ISO
562    write(*,*) 'phys_output_mid 589'
563    do ixt=1,ntraciso
564      outiso = TRIM(isoName(ixt))
565      i = INDEX(outiso, '_', .TRUE.)
566      outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
567
568      flag = [1,  1,  1, 10,  5, 10, 11, 11, 11, 11]; unit = 'kg/(s*m2)'
569      o_xtprecip(ixt)=ctrl_out(flag, 'precip'//TRIM(outiso), 'Precip Totale liq+sol', unit, [('',i=1,nfiles)])
570      o_xtpluc  (ixt)=ctrl_out(flag,   'pluc'//TRIM(outiso),    'Convective Precip.', unit, [('',i=1,nfiles)])
571
572      flag = [1,  1,  1, 10, 10, 10, 11, 11, 11, 11]
573      o_xtplul  (ixt)=ctrl_out(flag,   'plul'//TRIM(outiso),   'Large-scale Precip.', unit, [('',i=1,nfiles)])
574      o_xtevap  (ixt)=ctrl_out(flag,   'evap'//TRIM(outiso),             'Evaporat.', unit, [('',i=1,nfiles)])
575
576      ! ajout Camille 8 mai 2023
577      flag = [1, 6, 10, 10, 10, 10, 11, 11, 11, 11]
578      o_xtevap_srf (ixt,1)=ctrl_out(flag,   'evap_ter'//TRIM(outiso), 'Evap sfc'//clnsurf(1), unit, [('',i=1,nfiles)])
579      o_xtevap_srf (ixt,2)=ctrl_out(flag,   'evap_lic'//TRIM(outiso), 'Evap sfc'//clnsurf(2), unit, [('',i=1,nfiles)])
580      o_xtevap_srf (ixt,3)=ctrl_out(flag,   'evap_oce'//TRIM(outiso), 'Evap sfc'//clnsurf(3), unit, [('',i=1,nfiles)])
581      o_xtevap_srf (ixt,4)=ctrl_out(flag,   'evap_sic'//TRIM(outiso), 'Evap sfc'//clnsurf(4), unit, [('',i=1,nfiles)])
582
583      flag = [2,  3,  4, 10, 10, 10, 11, 11, 11, 11]; unit = 'kg/kg'
584      o_xtovap  (ixt)=ctrl_out(flag,   'ovap'//TRIM(outiso),     'Specific humidity', unit, [('',i=1,nfiles)])
585      o_xtoliq  (ixt)=ctrl_out(flag,   'oliq'//TRIM(outiso),          'Liquid water', unit, [('',i=1,nfiles)])
586      o_xtcond  (ixt)=ctrl_out(flag,  'ocond'//TRIM(outiso),       'Condensed water', unit, [('',i=1,nfiles)])
587
588      flag = [1,  1,  1, 10, 5, 10, 11, 11, 11, 11]; unit = 'kg/m2/s'
589      o_xtrunoff_diag  (ixt)=ctrl_out(flag, 'runoffland'//TRIM(outiso), 'Run-off rate land for bucket', unit, [('',i=1,nfiles)])
590
591      flag = [4, 10, 10, 10, 10, 10, 11, 11, 11, 11]; unit = '(kg/kg)/s'
592      o_dxtdyn  (ixt)=ctrl_out(flag,  'dqdyn'//TRIM(outiso),           'Dynamics dQ', unit, [('',i=1,nfiles)])
593      o_dxtldyn (ixt)=ctrl_out(flag, 'dqldyn'//TRIM(outiso),          'Dynamics dQL', unit, [('',i=1,nfiles)])
594      o_dxtcon  (ixt)=ctrl_out(flag,  'dqcon'//TRIM(outiso),         'Convection dQ', unit, [('',i=1,nfiles)])
595      o_dxteva  (ixt)=ctrl_out(flag,  'dqeva'//TRIM(outiso),      'Reevaporation dQ', unit, [('',i=1,nfiles)])
596      o_dxtlsc  (ixt)=ctrl_out(flag,  'dqlsc'//TRIM(outiso),       'Condensation dQ', unit, [('',i=1,nfiles)])
597      o_dxtajs  (ixt)=ctrl_out(flag,  'dqajs'//TRIM(outiso),        'Dry adjust. dQ', unit, [('',i=1,nfiles)])
598      o_dxtvdf  (ixt)=ctrl_out(flag,  'dqvdf'//TRIM(outiso),     'Boundary-layer dQ', unit, [('',i=1,nfiles)])
599      o_dxtthe  (ixt)=ctrl_out(flag,  'dqthe'//TRIM(outiso),            'Thermal dQ', unit, [('',i=1,nfiles)])
600
601      IF(ok_qch4) o_dxtch4(ixt)=ctrl_out(flag, 'dqch4'//TRIM(outiso), 'H2O due to CH4 oxidation & photolysis', &
602                                                                                      unit, [('',i=1,nfiles)])
603      IF(ixt == iso_HTO) THEN
604      o_dxtprod_nucl(ixt)=ctrl_out(flag, 'dqprodnucl'//TRIM(outiso), 'dHTO/dt due to nuclear production',      &
605                                                                                      unit, [('',i=1,nfiles)])
606      o_dxtcosmo    (ixt)=ctrl_out(flag,    'dqcosmo'//TRIM(outiso), 'dHTO/dt due to cosmogenic production',   &
607                                                                                      unit, [('',i=1,nfiles)])
608      o_dxtdecroiss (ixt)=ctrl_out(flag, 'dqdecroiss'//TRIM(outiso), 'dHTO/dt due to radiative destruction',   &
609                                                                                      unit, [('',i=1,nfiles)])
610      END IF
611    enddo !do ixt=1,niso
612    write(*,*) 'phys_output_mid 596'
613#endif
614
615   ! Updated write frequencies due to phys_out_filetimesteps.
616    ! Write frequencies are now in seconds. 
617    ecrit_mth = ecrit_files(1)
618    ecrit_day = ecrit_files(2)
619    ecrit_hf  = ecrit_files(3)
620    ecrit_ins = ecrit_files(4)
621    ecrit_LES = ecrit_files(5)
622    ecrit_ins = ecrit_files(6)
623
624    IF (prt_level >= 10) THEN
625      WRITE(lunout,*)'swaerofree_diag=',swaerofree_diag
626      WRITE(lunout,*)'swaero_diag=',swaero_diag
627      WRITE(lunout,*)'dryaod_diag=',dryaod_diag
628      WRITE(lunout,*)'ok_4xCO2atm=',ok_4xCO2atm
629      WRITE(lunout,*)'phys_output_open: ends here'
630    ENDIF
631
632!  DO iq=1,nqtot
633!    IF(.NOT.(tracers(iq)%isAdvected .AND. tracers(iq)%isInPhysics)) CYCLE
634!    WRITE(*,'(a,i1,a,10i3)')'trac(',iq,')%flag = ',o_trac(iq)%flag
635!    WRITE(*,'(a,i1,a)')'trac(',iq,')%name = '//TRIM(o_trac(iq)%name)
636!    WRITE(*,'(a,i1,a)')'trac(',iq,')%description = '//TRIM(o_trac(iq)%description)
637!  END DO
638
639  END SUBROUTINE phys_output_open
640
641  SUBROUTINE convers_timesteps(str,dtime,timestep)
642
643    use ioipsl
644    USE phys_cal_mod
645    USE time_phylmdz_mod, ONLY: day_ref, annee_ref
646    USE print_control_mod, ONLY: lunout
647
648    IMPLICIT NONE
649
650    CHARACTER(LEN=20)   :: str
651    CHARACTER(LEN=10)   :: type
652    INTEGER             :: ipos,il
653    real                :: ttt,xxx,timestep,dayseconde,dtime
654    parameter (dayseconde=86400.)
655
656    ipos=scan(str,'0123456789.',.TRUE.)
657    ! 
658    il=len_trim(str)
659    WRITE(lunout,*) "ipos = ", ipos
660    WRITE(lunout,*) "il = ", il
661    IF (ipos == 0) CALL abort_physic("convers_timesteps", "bad str", 1)
662    read(str(1:ipos),*) ttt
663    WRITE(lunout,*)ttt
664    type=str(ipos+1:il)
665
666    IF ( il == ipos ) THEN
667       type='day'
668    ENDIF
669
670    IF ( type == 'day'.or.type == 'days'.or.type == 'jours'.or.type == 'jour' ) timestep = ttt * dayseconde
671    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) THEN
672       WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
673       timestep = ttt * dayseconde * mth_len
674    ENDIF
675    IF ( type == 'hours'.or.type == 'hr'.or.type == 'heurs') timestep = ttt * dayseconde / 24.
676    IF ( type == 'mn'.or.type == 'minutes'  ) timestep = ttt * 60.
677    IF ( type == 's'.or.type == 'sec'.or.type == 'secondes'   ) timestep = ttt
678    IF ( type == 'TS' ) timestep = ttt * dtime
679
680    WRITE(lunout,*)'type =      ',type
681    WRITE(lunout,*)'nb j/h/m =  ',ttt
682    WRITE(lunout,*)'timestep(s)=',timestep
683
684  END SUBROUTINE convers_timesteps
685
686END MODULE phys_output_mod
Note: See TracBrowser for help on using the repository browser.