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

Last change on this file since 5491 was 5483, checked in by evignon, 2 weeks ago

ajout de omp_threadprivate manquants

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