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

Last change on this file since 5451 was 5447, checked in by jyg, 3 days ago

output the convective wet deposit of tracers

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