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

Last change on this file since 5715 was 5685, checked in by fhourdin, 4 weeks ago

Correction/nettoyage sorties en pression

  • 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: 31.2 KB
Line 
1! $Id: phys_output_mod.F90 5685 2025-05-27 11:07:44Z ymeurdesoif $
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
9  REAL, DIMENSION(nfiles),SAVE :: ecrit_files
10  LOGICAL, DIMENSION(nfiles)   :: phys_out_filekeys
11
12
13! Abderrahmane 12 2007
14!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
15!!! Ecreture des Sorties du modele dans les fichiers Netcdf :
16! histmth.nc : moyennes mensuelles
17! histday.nc : moyennes journalieres
18! histhf.nc  : moyennes toutes les 3 heures
19! histins.nc : valeurs instantanees
20! AI. nov 2024 : Modifs pour rajouter plus de choix pour la frequence temporelle d'archivage
21!                dans les fichiers de sorties (avec IOIPSL) :
22!                month(s),m,mth,mois,m,day(s),d,jour(s),j, ...
23!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
24
25CONTAINS
26
27!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
28!!!!!!!!! Ouverture des fichier et definition des variable de sortie !!!!!!!!
29  !! histbeg, histvert et histdef
30!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
31
32  SUBROUTINE phys_output_open(rlon,rlat,pim,tabij,ipt,jpt,plon,plat, &
33       jjmp1,nlevSTD,clevSTD,rlevSTD, dtime, ok_veget, &
34       type_ocean, iflag_pbl,iflag_pbl_split,ok_mensuel,ok_journe, &
35       ok_hf,ok_instan,ok_LES,ok_ade,ok_aie, read_climoz, &
36       phys_out_filestations, &
37       aerosol_couple, flag_aerosol_strat, &
38       pdtphys, paprs, pphis, pplay, lmax_th, ptconv, ptconvth, ivap, &
39       d_u, d_t, qx, d_qx, zmasse, ok_sync)   
40
41    USE iophy
42    USE dimphy
43    USE infotrac_phy, ONLY: nqtot, tracers, niso, ntraciso=>ntiso
44    USE strings_mod,  ONLY: maxlen
45    USE ioipsl
46    USE phys_cal_mod, only : hour, calend
47    USE mod_phys_lmdz_para
48    !Martin
49    USE surface_data, ONLY : landice_opt
50    USE phys_output_ctrlout_mod
51    USE mod_grid_phy_lmdz, only: klon_glo,nbp_lon,nbp_lat
52    USE print_control_mod, ONLY: prt_level,lunout
53    USE vertical_layers_mod, ONLY: ap,bp,preff,presnivs, aps, bps, pseudoalt, presinter
54    USE time_phylmdz_mod, ONLY: day_ini, itau_phy, start_time, annee_ref, day_ref
55
56    USE AERO_MOD, ONLY : nbands_lw_rrtm !FC
57
58    ! ug Pour les sorties XIOS
59    use wxios_mod
60   USE infotrac_phy, ONLY: nbtr_bin
61#ifdef ISO
62    USE isotopes_mod, ONLY: isoName,iso_HTO
63#ifdef ISOTRAC
64    use isotrac_mod, only: index_zone,index_iso,strtrac
65#endif
66#endif
67
68    USE clesphys_mod_h
69    USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_STRATAER
70
71    USE yomcst_mod_h
72IMPLICIT NONE
73
74
75    ! ug Nouveaux arguments n\'ecessaires au histwrite_mod:
76    INTEGER, INTENT(IN)                         :: ivap
77    INTEGER, DIMENSION(klon), INTENT(IN)        :: lmax_th
78    LOGICAL, INTENT(IN)                         :: ok_sync
79    LOGICAL, DIMENSION(klon, klev), INTENT(IN)  :: ptconv, ptconvth
80    REAL, INTENT(IN)                            :: pdtphys
81    REAL, DIMENSION(klon), INTENT(IN)           :: pphis
82    REAL, DIMENSION(klon, klev), INTENT(IN)     :: pplay, d_u, d_t
83    REAL, DIMENSION(klon, klev+1), INTENT(IN)   :: paprs
84    REAL, DIMENSION(klon,klev,nqtot), INTENT(IN):: qx, d_qx
85    REAL, DIMENSION(klon, klev), INTENT(IN)      :: zmasse
86
87
88    REAL,DIMENSION(klon),INTENT(IN) :: rlon
89    REAL,DIMENSION(klon),INTENT(IN) :: rlat
90    INTEGER, INTENT(IN)             :: pim
91    INTEGER, DIMENSION(pim)            :: tabij
92    INTEGER,DIMENSION(pim), INTENT(IN) :: ipt, jpt
93    REAL,DIMENSION(pim), INTENT(IN) :: plat, plon
94    REAL,DIMENSION(pim,2) :: plat_bounds, plon_bounds
95
96    INTEGER                               :: jjmp1
97    INTEGER                               :: nlevSTD, radpas
98    LOGICAL                               :: ok_mensuel, ok_journe, ok_hf, ok_instan
99    LOGICAL                               :: ok_LES,ok_ade,ok_aie
100    INTEGER                               :: flag_aerosol_strat
101    LOGICAL                               :: aerosol_couple
102    INTEGER, INTENT(IN)::  read_climoz ! read ozone climatology
103    !     Allowed values are 0, 1 and 2
104    !     0: do not read an ozone climatology
105    !     1: read a single ozone climatology that will be used day and night
106    !     2: read two ozone climatologies, the average day and night
107    !     climatology and the daylight climatology
108
109    REAL                                  :: dtime
110    INTEGER                               :: idayref
111    REAL                                  :: zjulian_start, zjulian
112    CHARACTER(LEN=4), DIMENSION(nlevSTD)  :: clevSTD
113    REAL, DIMENSION(nlevSTD)              :: rlevSTD
114    INTEGER                               :: nsrf, k, iq, iff, i, j, ilev, itr, itrb, ixt, iiso, izone
115    INTEGER                               :: naero
116    LOGICAL                               :: ok_veget
117    INTEGER                               :: iflag_pbl
118    INTEGER                               :: iflag_pbl_split
119    CHARACTER(LEN=4)                      :: bb2
120    CHARACTER(LEN=2)                      :: bb3
121    CHARACTER(LEN=6)                      :: type_ocean
122    INTEGER, DIMENSION(nbp_lon*jjmp1)         ::  ndex2d
123    INTEGER, DIMENSION(nbp_lon*jjmp1*klev)    :: ndex3d
124    INTEGER                               :: imin_ins, imax_ins
125    INTEGER                               :: jmin_ins, jmax_ins
126    INTEGER, DIMENSION(nfiles)            :: phys_out_levmin, phys_out_levmax
127    INTEGER, DIMENSION(nfiles)            :: phys_out_filelevels
128    CHARACTER(LEN=20), DIMENSION(nfiles)  :: chtimestep = (/ 'Default', 'Default', 'Default', 'Default', 'Default', &
129                                                             'Default', 'Default', 'Default', 'Default', 'Default' /)
130    LOGICAL, DIMENSION(nfiles)            :: phys_out_filestations
131
132#ifdef ISO
133    CHARACTER(LEN=maxlen) :: outiso
134    CHARACTER(LEN=20) :: unit
135#endif
136    CHARACTER(LEN=maxlen) :: tnam, lnam, dn
137    INTEGER :: flag(nfiles)
138
139!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
140    !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
141    LOGICAL, DIMENSION(nfiles), SAVE :: phys_out_regfkey = [.FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., .FALSE.]
142    REAL, DIMENSION(nfiles), SAVE ::  phys_out_lonmin  = [  -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.,   -180.]
143    REAL, DIMENSION(nfiles), SAVE ::  phys_out_lonmax  = [   180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.,    180.]
144    REAL, DIMENSION(nfiles), SAVE ::  phys_out_latmin  = [   -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.,    -90.]
145    REAL, DIMENSION(nfiles), SAVE ::  phys_out_latmax  = [    90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.,     90.]
146
147    REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
148    REAL, DIMENSION(klev+1)   :: lev_index
149               
150    ! ug Variables utilis\'ees pour r\'ecup\'erer le calendrier pour xios
151    INTEGER :: x_an, x_mois, x_jour
152    REAL :: x_heure
153    INTEGER :: ini_an, ini_mois, ini_jour
154    REAL :: ini_heure
155
156    INTEGER                         :: ISW
157    REAL, DIMENSION(NSW)            :: wl1_sun, wl2_sun !wavelength bounds (in um) for SW
158    REAL, DIMENSION(NSW)            :: wn1_sun, wn2_sun !wavenumber bounds (in m-1) for SW
159    REAL, DIMENSION(NSW)            :: spectband  !mean wavenumb. of each sp.band
160    REAL, DIMENSION(NSW,2)          :: spbnds_sun !bounds of spectband
161!FC
162    INTEGER                         :: ILW
163    REAL,  DIMENSION(nbands_lw_rrtm)  :: wl1_lw, wl2_lw
164
165    WRITE(lunout,*) 'Debut phys_output_mod.F90'
166! Initialisations (Valeurs par defaut
167!FC
168       wl1_lw = [ 10., 250., 500., 630., 700., 820., 980.,1080. &
169     & ,1180.,1390.,1480.,1800.,2080.,2250.,2380.,2600.]
170       wl2_lw = [250., 500., 630., 700., 820., 980.,1080.,1180. &
171     & ,1390.,1480.,1800.,2080.,2250.,2380.,2600.,3000.]
172!         print*, 'avant boucle', nbands_lw_rrtm
173!        DO ILW=1,nbands_lw_rrtm
174!        spectbandLW(ILW)= (wl1_lw(ilw) + wl2_lw(ILW) )/2
175!        print*, 'on a les canaux ? ',ILW,spectbandLW(ILW),wl1_lw(ILW),wl2_lw(ilw)
176!        enddo
177!        print*, 'spectbandLW',spectbandLW
178
179!FC
180
181
182    DO ilev=1,klev
183      Ahyb_bounds(ilev,1) = ap(ilev)
184      Ahyb_bounds(ilev,2) = ap(ilev+1)
185      Bhyb_bounds(ilev,1) = bp(ilev)
186      Bhyb_bounds(ilev,2) = bp(ilev+1)
187      lev_index(ilev) = REAL(ilev)
188    END DO
189      lev_index(klev+1) = REAL(klev+1)
190
191    IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
192    IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
193    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
194    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
195    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
196    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
197    ALLOCATE(o_dtr_wet_cv(nqtot), o_dtr_wet(nqtot))
198    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
199IF (CPPKEY_STRATAER) THEN
200    ALLOCATE(o_nd_mode(nbtr_bin),o_sulfmmr_mode(nbtr_bin))
201END IF
202#ifdef ISO
203    ALLOCATE(o_xtprecip(ntraciso))
204    ALLOCATE(o_xtplul(ntraciso))
205    ALLOCATE(o_xtpluc(ntraciso))
206    ALLOCATE(o_xtevap(ntraciso))
207    ALLOCATE(o_xtevap_srf(ntraciso,4))
208    ALLOCATE(o_xtovap(ntraciso))
209    ALLOCATE(o_xtoliq(ntraciso))
210    ALLOCATE(o_xtcond(ntraciso))
211    ALLOCATE(o_xtrunoff_diag(ntraciso))
212    ALLOCATE(o_dxtdyn(ntraciso))
213    ALLOCATE(o_dxtldyn(ntraciso))
214    ALLOCATE(o_dxtcon(ntraciso))
215    ALLOCATE(o_dxtlsc(ntraciso))
216    ALLOCATE(o_dxteva(ntraciso))
217    ALLOCATE(o_dxtajs(ntraciso))
218    ALLOCATE(o_dxtvdf(ntraciso))
219    ALLOCATE(o_dxtthe(ntraciso))
220    ALLOCATE(o_dxtch4(ntraciso))
221    if (iso_HTO.gt.0) then
222      ALLOCATE(o_dxtprod_nucl(ntraciso))
223      ALLOCATE(o_dxtcosmo(ntraciso))
224      ALLOCATE(o_dxtdecroiss(ntraciso))
225    endif
226#endif
227
228    levmax = [klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev]
229
230    phys_out_filenames(1) = 'histmth'
231    phys_out_filenames(2) = 'histday'
232    phys_out_filenames(3) = 'histhf6h'
233    phys_out_filenames(4) = 'histhf3h'
234    phys_out_filenames(5) = 'histhf3hm'
235    phys_out_filenames(6) = 'histstn'
236    phys_out_filenames(7) = 'histmthNMC'
237    phys_out_filenames(8) = 'histdayNMC'
238    phys_out_filenames(9) = 'histhfNMC'
239    phys_out_filenames(10)= 'histstrataer'
240
241    type_ecri(1) = 'ave(X)'
242    type_ecri(2) = 'ave(X)'
243    type_ecri(3) = 'inst(X)'
244    type_ecri(4) = 'inst(X)'
245    type_ecri(5) = 'ave(X)'
246    type_ecri(6) = 'inst(X)'
247    type_ecri(7) = 'inst(X)'
248    type_ecri(8) = 'inst(X)'
249    type_ecri(9) = 'inst(X)'
250    type_ecri(10)= 'ave(X)'
251
252    clef_files(1:3) = .TRUE.
253    clef_files(4:10) = .FALSE.
254    IF (CPPKEY_STRATAER) THEN
255      clef_files(10)= .TRUE.
256    ELSE
257      clef_files(10)= .FALSE.
258    END IF
259
260    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
261    clef_stations(1:10) = .FALSE.
262    lev_files(1:10) = 5
263
264    print*,'A ecrit_mth=',ecrit_mth
265    ! Frequencies of the history files;
266    ! Defaut
267    ! overwritten by chtimestep given to convers_timesteps
268    ecrit_files(1) = ecrit_mth
269    ecrit_files(2) = ecrit_day
270    ecrit_files(3) = ecrit_hf
271    ecrit_files(4) = ecrit_ins
272    ecrit_files(5) = ecrit_LES
273    ecrit_files(6:10) = ecrit_ins
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      print*,'Dans phys_output_open, iff=',iff,' ecrit_files=',ecrit_files(iff)
365      ENDIF
366      ! ecrit_files contains frequency of file iif in seconds
367
368
369       WRITE(lunout,*)'ecrit_files(',iff,')= ',ecrit_files(iff)
370       zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
371
372
373    IF (using_xios) THEN
374      !!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
375      IF (.not. ok_all_xml) THEN
376        IF (prt_level >= 10) THEN
377         print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))   
378        ENDIF
379        CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff)) 
380      ENDIF
381
382      !!! Declaration des axes verticaux de chaque fichier:
383      IF (prt_level >= 10) THEN
384        print*,'phys_output_open: Declare vertical axes for each file'
385      ENDIF
386
387      IF (iff.LE.6.OR.iff.EQ.10) THEN
388        CALL wxios_add_vaxis("presnivs", &
389              levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
390        CALL wxios_add_vaxis("presinter", &
391              klev + 1, presinter(1:klev+1))
392        CALL wxios_add_vaxis("Ahyb", &
393              levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
394              bnds=Ahyb_bounds(levmin(iff):levmax(iff),:))
395        CALL wxios_add_vaxis("Bhyb", &
396              levmax(iff) - levmin(iff) + 1, bps(levmin(iff):levmax(iff)), positif='down', &
397              bnds=Bhyb_bounds(levmin(iff):levmax(iff),:))
398        CALL wxios_add_vaxis("klev", levmax(iff) - levmin(iff) + 1, &
399                              lev_index(levmin(iff):levmax(iff)))
400        CALL wxios_add_vaxis("klevp1", klev+1, &
401                              lev_index(1:klev+1))
402        CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
403 
404        CALL wxios_add_vaxis("Alt", &
405                levmax(iff) - levmin(iff) + 1, pseudoalt)
406
407        ! wl1_sun/wl2_sun: minimum/maximum bound of wavelength (in um)
408        SELECT CASE(NSW)
409          CASE(6)
410            wl1_sun(1:6) = [0.180, 0.250, 0.440, 0.690, 1.190, 2.380]
411            wl2_sun(1:6) = [0.250, 0.440, 0.690, 1.190, 2.380, 4.000]
412          CASE(2)
413            wl1_sun(1:2) = [0.250, 0.690]
414            wl2_sun(1:2) = [0.690, 4.000]
415        END SELECT
416
417        DO ISW=1, NSW
418          wn1_sun(ISW)=1.e+6/wl1_sun(ISW)
419          wn2_sun(ISW)=1.e+6/wl2_sun(ISW)
420          spbnds_sun(ISW,1)=wn2_sun(ISW)
421          spbnds_sun(ISW,2)=wn1_sun(ISW)
422          spectband(ISW)=(wn1_sun(ISW)+wn2_sun(ISW))/2
423        ENDDO
424!
425!!! ajout axe vertical spectband : solar band number
426        CALL wxios_add_vaxis("spectband", NSW, spectband, positif='down')
427      ELSE
428        ! NMC files
429        CALL wxios_add_vaxis("plev", &
430                levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
431      ENDIF
432    ENDIF !using_xios
433
434        IF (clef_files(iff)) THEN
435!!!!!!!!!!!!!!!!! Traitement dans le cas ou l'on veut stocker sur un domaine limite !!
436!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
437          IF (phys_out_regfkey(iff)) THEN
438             imin_ins=1
439             imax_ins=nbp_lon
440             jmin_ins=1
441             jmax_ins=jjmp1
442
443             ! correction abderr       
444             DO i=1,nbp_lon
445                WRITE(lunout,*)'io_lon(i)=',io_lon(i)
446                IF (io_lon(i).le.phys_out_lonmin(iff)) imin_ins=i
447                IF (io_lon(i).le.phys_out_lonmax(iff)) imax_ins=i+1
448             ENDDO
449
450             DO j=1,jjmp1
451                WRITE(lunout,*)'io_lat(j)=',io_lat(j)
452                IF (io_lat(j).ge.phys_out_latmin(iff)) jmax_ins=j+1
453                IF (io_lat(j).ge.phys_out_latmax(iff)) jmin_ins=j
454             ENDDO
455
456             WRITE(lunout,*)'On stoke le fichier histoire numero ',iff,' sur ', &
457                  imin_ins,imax_ins,jmin_ins,jmax_ins
458             WRITE(lunout,*)'longitudes : ', &
459                  io_lon(imin_ins),io_lon(imax_ins), &
460                  'latitudes : ', &
461                  io_lat(jmax_ins),io_lat(jmin_ins)
462
463             CALL histbeg(phys_out_filenames(iff),nbp_lon,io_lon,jjmp1,io_lat, &
464                  imin_ins,imax_ins-imin_ins+1, &
465                  jmin_ins,jmax_ins-jmin_ins+1, &
466                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
467!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
468             !IM fichiers stations
469          ELSE IF (clef_stations(iff)) THEN
470
471             IF (prt_level >= 10) THEN
472             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
473             ENDIF
474             
475             CALL histbeg_phy_all(rlon,rlat,pim,tabij,ipt,jpt,plon,plat,plon_bounds,plat_bounds, &
476                  phys_out_filenames(iff), &
477                  itau_phy,zjulian,dtime,nhorim(iff),nid_files(iff))
478          ELSE
479
480             IF (prt_level >= 10) THEN
481             WRITE(lunout,*)'phys_output_open: iff=',iff,'  phys_out_filenames(iff)=',phys_out_filenames(iff)
482             ENDIF
483
484             CALL histbeg_phy_all(phys_out_filenames(iff),itau_phy,zjulian,&
485                 dtime,nhorim(iff),nid_files(iff))
486          ENDIF
487
488#ifndef CPP_IOIPSL_NO_OUTPUT
489          IF (iff.LE.6.OR.iff.EQ.10) THEN
490             CALL histvert(nid_files(iff), "presnivs", "Vertical levels", "Pa", & 
491               levmax(iff) - levmin(iff) + 1, &
492               presnivs(levmin(iff):levmax(iff)), nvertm(iff),"down")
493!!!! Composantes de la coordonnee sigma-hybride
494          CALL histvert(nid_files(iff), "Ahyb","Ahyb comp of Hyb Cord ", "Pa", &
495               levmax(iff) - levmin(iff) + 1,aps,nvertap(iff))
496
497          CALL histvert(nid_files(iff), "Bhyb","Bhyb comp of Hyb Cord", " ", &
498               levmax(iff) - levmin(iff) + 1,bps,nvertbp(iff))
499
500          CALL histvert(nid_files(iff), "Alt","Height approx for scale heigh of 8km at levels", "Km", &                       
501               levmax(iff) - levmin(iff) + 1,pseudoalt,nvertAlt(iff))
502!FC
503!          CALL histvert(nid_files(iff), "spectbandLW"," LW bands ", "cm-1", &
504!                  nbands_lw_rrtm ,wl1_lw, ncanaux(iff))
505!          print *, ' apres ncanaux = ' , ncanaux(iff),iff
506!FC
507
508
509          ELSE
510          ! NMC files
511             CALL histvert(nid_files(iff), "plev", "pressure", "Pa", &
512               levmax(iff) - levmin(iff) + 1, &
513              rlevSTD(levmin(iff):levmax(iff)), nvertm(iff), "down")
514          ENDIF
515#endif
516
517     ENDIF ! clef_files
518
519          itr = 0; itrb = 0
520          DO iq = 1, nqtot
521            IF(.NOT.tracers(iq)%isInPhysics) CYCLE
522            itr = itr + 1
523            dn = 'd'//TRIM(tracers(iq)%name)//'_'
524
525            flag = [1, 5, 5, 5, 10, 10, 11, 11, 11, 11]
526            lnam = 'Tracer '//TRIM(tracers(iq)%longName)
527            tnam = TRIM(tracers(iq)%name);  o_trac          (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
528
529            flag = [4, 7, 7, 7, 10, 10, 11, 11, 11, 11]
530            lnam = 'Tendance tracer '//TRIM(tracers(iq)%longName)
531            tnam = TRIM(dn)//'vdf';         o_dtr_vdf       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
532
533            flag = [5, 7, 7, 7, 10, 10, 11, 11, 11, 11]
534            tnam = TRIM(dn)//'the';         o_dtr_the       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
535            tnam = TRIM(dn)//'con';         o_dtr_con       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
536
537            flag = [7, 7, 7, 7, 10, 10, 11, 11, 11, 11]
538            tnam = TRIM(dn)//'lessi_impa';  o_dtr_lessi_impa(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
539            tnam = TRIM(dn)//'lessi_nucl';  o_dtr_lessi_nucl(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
540            tnam = TRIM(dn)//'insc';        o_dtr_insc      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
541            tnam = TRIM(dn)//'bcscav';      o_dtr_bcscav    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
542            tnam = TRIM(dn)//'evapls';      o_dtr_evapls    (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
543            tnam = TRIM(dn)//'ls';          o_dtr_ls        (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
544            tnam = TRIM(dn)//'trsp';        o_dtr_trsp      (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
545            tnam = TRIM(dn)//'sscav';       o_dtr_sscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
546            tnam = TRIM(dn)//'sat';         o_dtr_sat       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
547            tnam = TRIM(dn)//'uscav';       o_dtr_uscav     (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
548
549            lnam = 'tracer convective wet deposition'//TRIM(tracers(iq)%longName)
550            tnam = TRIM(dn)//'wet_cv';       o_dtr_wet_cv       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
551            lnam = 'tracer total wet deposition'//TRIM(tracers(iq)%longName)
552            tnam = TRIM(dn)//'wet';       o_dtr_wet       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
553            lnam = 'tracer tendency dry deposition'//TRIM(tracers(iq)%longName)
554            tnam = 'cum'//TRIM(dn)//'dry';  o_dtr_dry       (itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
555
556            flag = [1, 4, 10, 10, 10, 10, 11, 11, 11, 11]
557            lnam = 'Cumulated tracer '//TRIM(tracers(iq)%longName)
558            tnam = 'cum'//TRIM(tracers(iq)%name); o_trac_cum(itr) = ctrl_out(flag, tnam, lnam, "-", [('',i=1,nfiles)])
559           
560IF (CPPKEY_STRATAER) THEN
561            if(tracers(iq)%name(1:3)=='BIN') then
562               itrb = itrb + 1
563               flag = [11, 11, 11, 11, 11, 11, 11, 11, 11, 1]
564               lnam = 'Dry particle concentration in '//TRIM(tracers(iq)%longName)
565               tnam = TRIM(tracers(iq)%name)//'_nd_mode';     o_nd_mode       (itrb) = ctrl_out(flag, tnam, lnam, "part/m3", [('',i=1,nfiles)])
566               lnam = 'Sulfate MMR in '//TRIM(tracers(iq)%longName)
567               tnam = TRIM(tracers(iq)%name)//'_sulfmmr_mode';o_sulfmmr_mode  (itrb) = ctrl_out(flag, tnam, lnam, "kg(H2SO4)/kg(air)", [('',i=1,nfiles)])
568            endif
569END IF
570         ENDDO
571
572   ENDDO !  iff
573
574#ifdef ISO
575    write(*,*) 'phys_output_mid 589'
576    do ixt=1,ntraciso
577      outiso = TRIM(isoName(ixt))
578      i = INDEX(outiso, '_', .TRUE.)
579      outiso = outiso(1:i-1)//outiso(i+1:LEN_TRIM(outiso))
580
581      flag = [1,  1,  1, 10,  5, 10, 11, 11, 11, 11]; unit = 'kg/(s*m2)'
582      o_xtprecip(ixt)=ctrl_out(flag, 'precip'//TRIM(outiso), 'Precip Totale liq+sol', unit, [('',i=1,nfiles)])
583      o_xtpluc  (ixt)=ctrl_out(flag,   'pluc'//TRIM(outiso),    'Convective Precip.', unit, [('',i=1,nfiles)])
584
585      flag = [1,  1,  1, 10, 10, 10, 11, 11, 11, 11]
586      o_xtplul  (ixt)=ctrl_out(flag,   'plul'//TRIM(outiso),   'Large-scale Precip.', unit, [('',i=1,nfiles)])
587      o_xtevap  (ixt)=ctrl_out(flag,   'evap'//TRIM(outiso),             'Evaporat.', unit, [('',i=1,nfiles)])
588
589      ! ajout Camille 8 mai 2023
590      flag = [1, 6, 10, 10, 10, 10, 11, 11, 11, 11]
591      o_xtevap_srf (ixt,1)=ctrl_out(flag,   'evap_ter'//TRIM(outiso), 'Evap sfc'//clnsurf(1), unit, [('',i=1,nfiles)])
592      o_xtevap_srf (ixt,2)=ctrl_out(flag,   'evap_lic'//TRIM(outiso), 'Evap sfc'//clnsurf(2), unit, [('',i=1,nfiles)])
593      o_xtevap_srf (ixt,3)=ctrl_out(flag,   'evap_oce'//TRIM(outiso), 'Evap sfc'//clnsurf(3), unit, [('',i=1,nfiles)])
594      o_xtevap_srf (ixt,4)=ctrl_out(flag,   'evap_sic'//TRIM(outiso), 'Evap sfc'//clnsurf(4), unit, [('',i=1,nfiles)])
595
596      flag = [2,  3,  4, 10, 10, 10, 11, 11, 11, 11]; unit = 'kg/kg'
597      o_xtovap  (ixt)=ctrl_out(flag,   'ovap'//TRIM(outiso),     'Specific humidity', unit, [('',i=1,nfiles)])
598      o_xtoliq  (ixt)=ctrl_out(flag,   'oliq'//TRIM(outiso),          'Liquid water', unit, [('',i=1,nfiles)])
599      o_xtcond  (ixt)=ctrl_out(flag,  'ocond'//TRIM(outiso),       'Condensed water', unit, [('',i=1,nfiles)])
600
601      flag = [1,  1,  1, 10, 5, 10, 11, 11, 11, 11]; unit = 'kg/m2/s'
602      o_xtrunoff_diag  (ixt)=ctrl_out(flag, 'runoffland'//TRIM(outiso), 'Run-off rate land for bucket', unit, [('',i=1,nfiles)])
603
604      flag = [4, 10, 10, 10, 10, 10, 11, 11, 11, 11]; unit = '(kg/kg)/s'
605      o_dxtdyn  (ixt)=ctrl_out(flag,  'dqdyn'//TRIM(outiso),           'Dynamics dQ', unit, [('',i=1,nfiles)])
606      o_dxtldyn (ixt)=ctrl_out(flag, 'dqldyn'//TRIM(outiso),          'Dynamics dQL', unit, [('',i=1,nfiles)])
607      o_dxtcon  (ixt)=ctrl_out(flag,  'dqcon'//TRIM(outiso),         'Convection dQ', unit, [('',i=1,nfiles)])
608      o_dxteva  (ixt)=ctrl_out(flag,  'dqeva'//TRIM(outiso),      'Reevaporation dQ', unit, [('',i=1,nfiles)])
609      o_dxtlsc  (ixt)=ctrl_out(flag,  'dqlsc'//TRIM(outiso),       'Condensation dQ', unit, [('',i=1,nfiles)])
610      o_dxtajs  (ixt)=ctrl_out(flag,  'dqajs'//TRIM(outiso),        'Dry adjust. dQ', unit, [('',i=1,nfiles)])
611      o_dxtvdf  (ixt)=ctrl_out(flag,  'dqvdf'//TRIM(outiso),     'Boundary-layer dQ', unit, [('',i=1,nfiles)])
612      o_dxtthe  (ixt)=ctrl_out(flag,  'dqthe'//TRIM(outiso),            'Thermal dQ', unit, [('',i=1,nfiles)])
613
614      IF(ok_qch4) o_dxtch4(ixt)=ctrl_out(flag, 'dqch4'//TRIM(outiso), 'H2O due to CH4 oxidation & photolysis', &
615                                                                                      unit, [('',i=1,nfiles)])
616      IF(ixt == iso_HTO) THEN
617      o_dxtprod_nucl(ixt)=ctrl_out(flag, 'dqprodnucl'//TRIM(outiso), 'dHTO/dt due to nuclear production',      &
618                                                                                      unit, [('',i=1,nfiles)])
619      o_dxtcosmo    (ixt)=ctrl_out(flag,    'dqcosmo'//TRIM(outiso), 'dHTO/dt due to cosmogenic production',   &
620                                                                                      unit, [('',i=1,nfiles)])
621      o_dxtdecroiss (ixt)=ctrl_out(flag, 'dqdecroiss'//TRIM(outiso), 'dHTO/dt due to radiative destruction',   &
622                                                                                      unit, [('',i=1,nfiles)])
623      END IF
624    enddo !do ixt=1,niso
625    write(*,*) 'phys_output_mid 596'
626#endif
627
628   ! Updated write frequencies due to phys_out_filetimesteps.
629    ! Write frequencies are now in seconds. 
630! WHY CHANGING ecrit_mth ?
631! For Cosp ?
632!    ecrit_mth = ecrit_files(1)
633!    print*,'B ecrit_mth=',ecrit_mth
634!    ecrit_day = ecrit_files(2)
635!    ecrit_hf  = ecrit_files(3)
636!    ecrit_ins = ecrit_files(4)
637!    ecrit_LES = ecrit_files(5)
638!    ecrit_ins = ecrit_files(6)
639
640    IF (prt_level >= 10) THEN
641      WRITE(lunout,*)'swaerofree_diag=',swaerofree_diag
642      WRITE(lunout,*)'swaero_diag=',swaero_diag
643      WRITE(lunout,*)'dryaod_diag=',dryaod_diag
644      WRITE(lunout,*)'ok_4xCO2atm=',ok_4xCO2atm
645      WRITE(lunout,*)'phys_output_open: ends here'
646    ENDIF
647    print*,'Dans phys_output_open,ecrit_files B',ecrit_files(1:6)
648
649!  DO iq=1,nqtot
650!    IF(.NOT.tracers(iq)%isInPhysics) CYCLE
651!    WRITE(*,'(a,i1,a,10i3)')'trac(',iq,')%flag = ',o_trac(iq)%flag
652!    WRITE(*,'(a,i1,a)')'trac(',iq,')%name = '//TRIM(o_trac(iq)%name)
653!    WRITE(*,'(a,i1,a)')'trac(',iq,')%description = '//TRIM(o_trac(iq)%description)
654!  END DO
655
656  END SUBROUTINE phys_output_open
657
658  SUBROUTINE convers_timesteps(str,dtime,timestep)
659
660    use ioipsl
661    USE phys_cal_mod
662    USE time_phylmdz_mod, ONLY: day_ref, annee_ref
663    USE print_control_mod, ONLY: lunout
664
665    IMPLICIT NONE
666
667    CHARACTER(LEN=20)   :: str
668    CHARACTER(LEN=10)   :: type
669    INTEGER             :: ipos,il
670    real                :: ttt,xxx,timestep,dayseconde,dtime
671    parameter (dayseconde=86400.)
672
673    ipos=scan(str,'0123456789.',.TRUE.)
674    ! 
675    il=len_trim(str)
676    WRITE(lunout,*) "ipos = ", ipos
677    WRITE(lunout,*) "il = ", il
678    IF (ipos == 0) CALL abort_physic("convers_timesteps", "bad str", 1)
679    read(str(1:ipos),*) ttt
680    WRITE(lunout,*)ttt
681    type=str(ipos+1:il)
682
683    IF ( il == ipos ) THEN
684       type='day'
685    ENDIF
686
687    IF ( type == 'day'.or.type == 'days'.or.type == 'd'.or.type == 'jours'.or.type == 'jour'.or.type == 'j' )&
688           &  timestep = ttt * dayseconde
689    IF ( type == 'months'.or.type == 'month'.or.type == 'mth'.or.type == 'mois'.or.type == 'm' .or.type == 'mo' ) THEN
690       WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
691       timestep = ttt * dayseconde * mth_len
692    ENDIF
693    IF ( type == 'hours'.or.type == 'hour'.or.type == 'hr'.or.type == 'heures'.or.type == 'heure'.or.type =='h' )&
694           &  timestep = ttt * dayseconde / 24.
695    IF ( type == 'mn'.or.type == 'minutes'.or.type == 'minute'.or.type == 'm' ) timestep = ttt * 60.
696    IF ( type == 's'.or.type == 'sec'.or.type == 'secondes'.or.type =='seconde'   ) timestep = ttt
697    IF ( type == 'TS' .or. type == 'ts' ) timestep = ttt * dtime
698
699    WRITE(lunout,*)'type =      ',type
700    WRITE(lunout,*)'nb j/h/m =  ',ttt
701    WRITE(lunout,*)'timestep(s)=',timestep
702
703  END SUBROUTINE convers_timesteps
704
705END MODULE phys_output_mod
Note: See TracBrowser for help on using the repository browser.