source: LMDZ6/trunk/libf/phylmdiso/phys_output_mod.F90 @ 4050

Last change on this file since 4050 was 4050, checked in by dcugnet, 2 years ago

Second commit for new tracers.

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