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

Last change on this file since 5282 was 5282, checked in by abarral, 6 hours ago

Turn iniprint.h clesphys.h into modules
Remove unused description.h

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