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

Last change on this file since 3927 was 3927, checked in by Laurent Fairhead, 3 years ago

Initial import of the physics wih isotopes from Camille Risi
CR

File size: 32.1 KB
Line 
1! $Id: phys_output_mod.F90 3666 2020-04-20 10:13:34Z lfalletti $
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, tname, ttext, type_trac, &
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 : ok_snow
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*50 :: striso_sortie
128      integer :: lnblnk
129#endif
130
131!!!!!!!!!! stockage dans une region limitee pour chaque fichier !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
132    !                 entre [phys_out_lonmin,phys_out_lonmax] et [phys_out_latmin,phys_out_latmax]
133
134    LOGICAL, DIMENSION(nfiles), SAVE  :: phys_out_regfkey       = (/ .FALSE., .FALSE., .FALSE., .FALSE., .FALSE., &
135                                                                     .FALSE., .FALSE., .FALSE., .FALSE., .FALSE. /)
136    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmin        = (/ -180., -180., -180., -180., -180., &
137                                                                     -180., -180., -180., -180., -180. /)
138    REAL, DIMENSION(nfiles), SAVE     :: phys_out_lonmax        = (/  180.,  180.,  180.,  180.,  180., &
139                                                                      180.,  180.,  180.,  180.,  180. /)
140    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmin        = (/  -90.,  -90.,  -90.,  -90.,  -90., &
141                                                                      -90.,  -90.,  -90.,  -90.,  -90. /)
142    REAL, DIMENSION(nfiles), SAVE     :: phys_out_latmax        = (/   90.,   90.,   90.,   90.,   90., &
143                                                                       90.,   90.,   90.,   90.,   90. /)
144    REAL, DIMENSION(klev,2) :: Ahyb_bounds, Bhyb_bounds
145    REAL, DIMENSION(klev+1)   :: lev_index
146               
147#ifdef CPP_XIOS
148    ! ug Variables utilis\'ees pour r\'ecup\'erer le calendrier pour xios
149    INTEGER :: x_an, x_mois, x_jour
150    REAL :: x_heure
151    INTEGER :: ini_an, ini_mois, ini_jour
152    REAL :: ini_heure
153#endif
154    INTEGER                         :: ISW
155    REAL, DIMENSION(NSW)            :: wl1_sun, wl2_sun !wavelength bounds (in um) for SW
156    REAL, DIMENSION(NSW)            :: wn1_sun, wn2_sun !wavenumber bounds (in m-1) for SW
157    REAL, DIMENSION(NSW)            :: spectband  !mean wavenumb. of each sp.band
158    REAL, DIMENSION(NSW,2)          :: spbnds_sun !bounds of spectband
159
160    WRITE(lunout,*) 'Debut phys_output_mod.F90'
161    ! Initialisations (Valeurs par defaut
162
163    DO ilev=1,klev
164      Ahyb_bounds(ilev,1) = ap(ilev)
165      Ahyb_bounds(ilev,2) = ap(ilev+1)
166      Bhyb_bounds(ilev,1) = bp(ilev)
167      Bhyb_bounds(ilev,2) = bp(ilev+1)
168      lev_index(ilev) = REAL(ilev)
169    END DO
170      lev_index(klev+1) = REAL(klev+1)
171
172    IF (.NOT. ALLOCATED(o_trac)) ALLOCATE(o_trac(nqtot))
173    IF (.NOT. ALLOCATED(o_trac_cum)) ALLOCATE(o_trac_cum(nqtot))
174    ALLOCATE(o_dtr_the(nqtot),o_dtr_con(nqtot),o_dtr_lessi_impa(nqtot))
175    ALLOCATE(o_dtr_lessi_nucl(nqtot),o_dtr_insc(nqtot),o_dtr_bcscav(nqtot))
176    ALLOCATE(o_dtr_evapls(nqtot),o_dtr_ls(nqtot),o_dtr_trsp(nqtot))
177    ALLOCATE(o_dtr_sscav(nqtot),o_dtr_sat(nqtot),o_dtr_uscav(nqtot))
178    ALLOCATE(o_dtr_dry(nqtot),o_dtr_vdf(nqtot))
179
180#ifdef ISO
181    ALLOCATE(o_xtprecip(ntraciso))
182    ALLOCATE(o_xtplul(ntraciso))
183    ALLOCATE(o_xtpluc(ntraciso))
184    ALLOCATE(o_xtevap(ntraciso))
185    ALLOCATE(o_xtovap(ntraciso))
186    ALLOCATE(o_xtoliq(ntraciso))
187    ALLOCATE(o_xtcond(ntraciso))
188    ALLOCATE(o_dxtdyn(ntraciso))
189    ALLOCATE(o_dxtldyn(ntraciso))
190    ALLOCATE(o_dxtcon(ntraciso))
191    ALLOCATE(o_dxtlsc(ntraciso))
192    ALLOCATE(o_dxteva(ntraciso))
193    ALLOCATE(o_dxtajs(ntraciso))
194    ALLOCATE(o_dxtvdf(ntraciso))
195    ALLOCATE(o_dxtthe(ntraciso))
196    ALLOCATE(o_dxtch4(ntraciso))
197    if (iso_HTO.gt.0) then
198      ALLOCATE(o_dxtprod_nucl(ntraciso))
199      ALLOCATE(o_dxtcosmo(ntraciso))
200      ALLOCATE(o_dxtdecroiss(ntraciso))
201    endif
202#endif
203
204    levmax = (/ klev, klev, klev, klev, klev, klev, nlevSTD, nlevSTD, nlevSTD, klev /)
205
206    phys_out_filenames(1) = 'histmth'
207    phys_out_filenames(2) = 'histday'
208    phys_out_filenames(3) = 'histhf6h'
209    phys_out_filenames(4) = 'histhf3h'
210    phys_out_filenames(5) = 'histhf3hm'
211    phys_out_filenames(6) = 'histstn'
212    phys_out_filenames(7) = 'histmthNMC'
213    phys_out_filenames(8) = 'histdayNMC'
214    phys_out_filenames(9) = 'histhfNMC'
215    phys_out_filenames(10)= 'histstrataer'
216
217    type_ecri(1) = 'ave(X)'
218    type_ecri(2) = 'ave(X)'
219    type_ecri(3) = 'inst(X)'
220    type_ecri(4) = 'inst(X)'
221    type_ecri(5) = 'ave(X)'
222    type_ecri(6) = 'inst(X)'
223    type_ecri(7) = 'inst(X)'
224    type_ecri(8) = 'inst(X)'
225    type_ecri(9) = 'inst(X)'
226    type_ecri(10)= 'ave(X)'
227
228    clef_files(1) = ok_mensuel
229    clef_files(2) = ok_journe
230    clef_files(3) = ok_hf
231    clef_files(4) = ok_instan
232    clef_files(5) = ok_LES
233    clef_files(6) = ok_instan
234    clef_files(7) = ok_histNMC(1)
235    clef_files(8) = ok_histNMC(2)
236    clef_files(9) = ok_histNMC(3)
237#ifdef CPP_StratAer
238    clef_files(10)= .TRUE.
239#else
240    clef_files(10)= .FALSE.
241#endif
242
243    !sortir des fichiers "stations" si clef_stations(:)=.TRUE.
244    clef_stations(1) = .FALSE.
245    clef_stations(2) = .FALSE.
246    clef_stations(3) = .FALSE.
247    clef_stations(4) = .FALSE.
248    clef_stations(5) = .FALSE.
249    clef_stations(6) = .FALSE.
250    clef_stations(7) = .FALSE.
251    clef_stations(8) = .FALSE.
252    clef_stations(9) = .FALSE.
253    clef_stations(10)= .FALSE.
254
255    lev_files(1) = lev_histmth
256    lev_files(2) = lev_histday
257    lev_files(3) = lev_histhf
258    lev_files(4) = lev_histins
259    lev_files(5) = lev_histLES
260    lev_files(6) = lev_histins
261    lev_files(7) = levout_histNMC(1)
262    lev_files(8) = levout_histNMC(2)
263    lev_files(9) = levout_histNMC(3)
264    lev_files(10)= 5
265
266    ecrit_files(1) = ecrit_mth
267    ecrit_files(2) = ecrit_day
268    ecrit_files(3) = ecrit_hf
269    ecrit_files(4) = ecrit_ins
270    ecrit_files(5) = ecrit_LES
271    ecrit_files(6) = ecrit_ins
272    ecrit_files(7) = freq_outNMC(1)
273    ecrit_files(8) = freq_outNMC(2)
274    ecrit_files(9) = freq_outNMC(3)
275    ecrit_files(10)= ecrit_mth
276
277    !! Lectures des parametres de sorties dans physiq.def
278
279    CALL getin('phys_out_regfkey',phys_out_regfkey)
280    CALL getin('phys_out_lonmin',phys_out_lonmin)
281    CALL getin('phys_out_lonmax',phys_out_lonmax)
282    CALL getin('phys_out_latmin',phys_out_latmin)
283    CALL getin('phys_out_latmax',phys_out_latmax)
284    phys_out_levmin(:)=levmin(:)
285    CALL getin('phys_out_levmin',levmin)
286    phys_out_levmax(:)=levmax(:)
287    CALL getin('phys_out_levmax',levmax)
288    CALL getin('phys_out_filenames',phys_out_filenames)
289    phys_out_filekeys(:)=clef_files(:)
290    CALL getin('phys_out_filekeys',clef_files)
291    phys_out_filestations(:)=clef_stations(:)
292    CALL getin('phys_out_filestations',clef_stations)
293    phys_out_filelevels(:)=lev_files(:)
294    CALL getin('phys_out_filelevels',lev_files)
295    CALL getin('phys_out_filetimesteps',chtimestep)
296    phys_out_filetypes(:)=type_ecri(:)
297    CALL getin('phys_out_filetypes',type_ecri)
298
299    type_ecri_files(:)=type_ecri(:)
300
301!    if (ok_all_xml) phys_out_filelevels = 999
302
303    WRITE(lunout,*)'phys_out_lonmin=',phys_out_lonmin
304    WRITE(lunout,*)'phys_out_lonmax=',phys_out_lonmax
305    WRITE(lunout,*)'phys_out_latmin=',phys_out_latmin
306    WRITE(lunout,*)'phys_out_latmax=',phys_out_latmax
307    WRITE(lunout,*)'phys_out_filenames=',phys_out_filenames
308    WRITE(lunout,*)'phys_out_filetypes=',type_ecri
309    WRITE(lunout,*)'phys_out_filekeys=',clef_files
310    WRITE(lunout,*)'phys_out_filestations=',clef_stations
311    WRITE(lunout,*)'phys_out_filelevels=',lev_files
312    WRITE(lunout,*)'phys_out_regfkey=',phys_out_regfkey
313
314! A noter pour
315! l heure initiale - dans les fichiers histoire hist* - on met comme 
316! heure de debut soit la vraie heure (pour le 1D) soit 0h (pour le 3D)
317! afin d avoir une seule sortie mensuelle par mois lorsque l on tourne
318! par annee (IM).
319!
320     idayref = day_ref
321     IF (klon_glo==1) THEN
322       ! current_time (used to compute hour) is updated at the begining of
323       ! the physics; to set the correct outputs "initial time" we thus
324       ! have to use (hour-dtphys).
325         CALL ymds2ju(annee_ref, 1, idayref, hour-pdtphys, zjulian)
326         print *,'phys_output_mod: annee,iday,hour,zjulian=',annee_ref,idayref, hour, zjulian
327     ELSE
328         CALL ymds2ju(annee_ref, 1, idayref, 0.0, zjulian)
329         CALL ymds2ju(annee_ref, 1, day_ini, start_time*rday, zjulian_start)
330     ENDIF
331
332#ifdef CPP_XIOS
333    ! ug R\'eglage du calendrier xios
334    !Temps julian => an, mois, jour, heure
335    CALL ju2ymds(zjulian, x_an, x_mois, x_jour, x_heure)
336    CALL ju2ymds(zjulian_start, ini_an, ini_mois, ini_jour, ini_heure)
337    CALL wxios_set_cal(dtime, calend, x_an, x_mois, x_jour, x_heure, ini_an, &
338                       ini_mois, ini_jour, ini_heure )
339#endif
340
341!!!!!!!!!!!!!!!!!!!!!!! Boucle sur les fichiers !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
342    ! Appel de histbeg et histvert pour creer le fichier et les niveaux verticaux !!
343    ! Appel des histbeg pour definir les variables (nom, moy ou inst, freq de sortie ..
344!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
345
346    zdtime_moy = dtime         ! Frequence ou l on moyenne
347
348
349  ecrit_files(7) = ecrit_files(1)
350  ecrit_files(8) = ecrit_files(2)
351  ecrit_files(9) = ecrit_files(3)
352
353  DO iff=1,nfiles
354
355       ! Calculate ecrit_files for all files
356      IF ( chtimestep(iff).eq.'Default' ) THEN
357          ! Par defaut ecrit_files = (ecrit_mensuel ecrit_jour ecrit_hf
358          ! ...)*86400.
359          ecrit_files(iff)=ecrit_files(iff)*86400.
360      ELSE IF (chtimestep(iff).eq.'-1') THEN
361          PRINT*,'ecrit_files(',iff,') < 0 so IOIPSL work on different'
362          PRINT*,'months length'
363          ecrit_files(iff)=-1.
364      ELSE
365       CALL convers_timesteps(chtimestep(iff),dtime,ecrit_files(iff))
366      ENDIF
367
368       WRITE(lunout,*)'ecrit_files(',iff,')= ',ecrit_files(iff)
369       zoutm(iff) = ecrit_files(iff) ! Frequence ou l on ecrit en seconde
370
371
372#ifdef CPP_XIOS
373!!! Ouverture de chaque fichier XIOS !!!!!!!!!!!
374    IF (.not. ok_all_xml) THEN
375      IF (prt_level >= 10) THEN
376        print*,'phys_output_open: call wxios_add_file with phys_out_filenames(iff)=',trim(phys_out_filenames(iff))   
377      ENDIF
378      CALL wxios_add_file(phys_out_filenames(iff),chtimestep(iff),lev_files(iff)) 
379    ENDIF
380
381        write(*,*) 'phys_output_mid 344'
382!!! Declaration des axes verticaux de chaque fichier:
383    IF (prt_level >= 10) THEN
384      print*,'phys_output_open: Declare vertical axes for each file'
385    ENDIF
386
387   IF (iff.LE.6.OR.iff.EQ.10) THEN
388    CALL wxios_add_vaxis("presnivs", &
389            levmax(iff) - levmin(iff) + 1, presnivs(levmin(iff):levmax(iff)))
390    CALL wxios_add_vaxis("Ahyb", &
391            levmax(iff) - levmin(iff) + 1, aps(levmin(iff):levmax(iff)), positif='down', &
392            bnds=Ahyb_bounds(levmin(iff):levmax(iff),:))
393    CALL wxios_add_vaxis("Bhyb", &
394            levmax(iff) - levmin(iff) + 1, bps(levmin(iff):levmax(iff)), positif='down', &
395            bnds=Bhyb_bounds(levmin(iff):levmax(iff),:))
396    CALL wxios_add_vaxis("klev", levmax(iff) - levmin(iff) + 1, &
397                          lev_index(levmin(iff):levmax(iff)))
398    CALL wxios_add_vaxis("klevp1", klev+1, &
399                          lev_index(1:klev+1))
400    CALL wxios_add_vaxis("bnds", 2, (/1.,2./))
401
402     CALL wxios_add_vaxis("Alt", &
403            levmax(iff) - levmin(iff) + 1, pseudoalt)
404
405    IF (NSW.EQ.6) THEN
406!
407!wl1_sun: minimum bound of wavelength (in um)
408!
409      wl1_sun(1)=0.180
410      wl1_sun(2)=0.250
411      wl1_sun(3)=0.440
412      wl1_sun(4)=0.690
413      wl1_sun(5)=1.190
414      wl1_sun(6)=2.380
415!
416!wl2_sun: maximum bound of wavelength (in um)
417!
418      wl2_sun(1)=0.250
419      wl2_sun(2)=0.440
420      wl2_sun(3)=0.690
421      wl2_sun(4)=1.190
422      wl2_sun(5)=2.380
423      wl2_sun(6)=4.000
424!
425    ELSE IF(NSW.EQ.2) THEN
426!
427!wl1_sun: minimum bound of wavelength (in um)
428!
429      wl1_sun(1)=0.250
430      wl1_sun(2)=0.690
431!
432!wl2_sun: maximum bound of wavelength (in um)
433!
434      wl2_sun(1)=0.690
435      wl2_sun(2)=4.000
436    ENDIF
437
438    DO ISW=1, NSW
439     wn1_sun(ISW)=1.e+6/wl1_sun(ISW)
440     wn2_sun(ISW)=1.e+6/wl2_sun(ISW)
441     spbnds_sun(ISW,1)=wn2_sun(ISW)
442     spbnds_sun(ISW,2)=wn1_sun(ISW)
443     spectband(ISW)=(wn1_sun(ISW)+wn2_sun(ISW))/2
444    ENDDO
445!
446!!! ajout axe vertical spectband : solar band number
447    CALL wxios_add_vaxis("spectband", NSW, spectband, positif='down')
448   ELSE
449    ! NMC files
450    CALL wxios_add_vaxis("plev", &
451            levmax(iff) - levmin(iff) + 1, rlevSTD(levmin(iff):levmax(iff)))
452   ENDIF
453#endif
454        write(*,*) 'phys_output_mid 416'
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        IF (nqtottr>=1) THEN
539!
540            !DO iq=nqo+1,nqtot
541            ! C Risi: on modifie la boucle
542            do itr=1,nqtottr ! C Risi
543            iq=itr_indice(itr)  ! C Risi
544            write(*,*) 'phys_output_mid 503: itr=',itr
545 
546            iiq=niadv(iq)
547            o_trac(itr) = ctrl_out((/ 1, 5, 5, 5, 10, 10, 11, 11, 11, 11 /), &
548                           tname(iiq),'Tracer '//ttext(iiq), "-",  &
549                           (/ '', '', '', '', '', '', '', '', '', '' /))
550            o_dtr_vdf(itr) = ctrl_out((/ 4, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
551                              'd'//trim(tname(iq))//'_vdf',  &
552                              'Tendance tracer '//ttext(iiq), "-" , &
553                              (/ '', '', '', '', '', '', '', '', '', '' /))
554
555            o_dtr_the(itr) = ctrl_out((/ 5, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
556                              'd'//trim(tname(iq))//'_the', &
557                              'Tendance tracer '//ttext(iiq), "-", &
558                              (/ '', '', '', '', '', '', '', '', '', '' /))
559
560            o_dtr_con(itr) = ctrl_out((/ 5, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
561                              'd'//trim(tname(iq))//'_con', &
562                              'Tendance tracer '//ttext(iiq), "-", &
563                              (/ '', '', '', '', '', '', '', '', '', '' /))
564
565            o_dtr_lessi_impa(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
566                                     'd'//trim(tname(iq))//'_lessi_impa', &
567                                     'Tendance tracer '//ttext(iiq), "-", &
568                                     (/ '', '', '', '', '', '', '', '', '', '' /))
569
570            o_dtr_lessi_nucl(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
571                                     'd'//trim(tname(iq))//'_lessi_nucl', &
572                                     'Tendance tracer '//ttext(iiq), "-", &
573                                     (/ '', '', '', '', '', '', '', '', '', '' /))
574
575            o_dtr_insc(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
576                               'd'//trim(tname(iq))//'_insc', &
577                               'Tendance tracer '//ttext(iiq), "-", &
578                               (/ '', '', '', '', '', '', '', '', '', '' /))
579
580            o_dtr_bcscav(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
581                                 'd'//trim(tname(iq))//'_bcscav', &
582                                 'Tendance tracer '//ttext(iiq), "-", &
583                                 (/ '', '', '', '', '', '', '', '', '', '' /))
584
585            o_dtr_evapls(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
586                                 'd'//trim(tname(iq))//'_evapls', &
587                                 'Tendance tracer '//ttext(iiq), "-", &
588                                 (/ '', '', '', '', '', '', '', '', '', '' /))
589
590            o_dtr_ls(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
591                             'd'//trim(tname(iq))//'_ls', &
592                             'Tendance tracer '//ttext(iiq), "-", &
593                             (/ '', '', '', '', '', '', '', '', '', '' /))
594
595            o_dtr_trsp(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
596                               'd'//trim(tname(iq))//'_trsp', &
597                               'Tendance tracer '//ttext(iiq), "-", &
598                               (/ '', '', '', '', '', '', '', '', '', '' /))
599
600            o_dtr_sscav(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
601                                'd'//trim(tname(iq))//'_sscav', &
602                                'Tendance tracer '//ttext(iiq), "-", &
603                                (/ '', '', '', '', '', '', '', '', '', '' /))
604
605            o_dtr_sat(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
606                               'd'//trim(tname(iq))//'_sat', &
607                               'Tendance tracer '//ttext(iiq), "-", &
608                               (/ '', '', '', '', '', '', '', '', '', '' /))
609
610            o_dtr_uscav(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
611                                'd'//trim(tname(iq))//'_uscav', &
612                                'Tendance tracer '//ttext(iiq), "-", &
613                                 (/ '', '', '', '', '', '', '', '', '', '' /))
614
615            o_dtr_dry(itr) = ctrl_out((/ 7, 7, 7, 7, 10, 10, 11, 11, 11, 11 /), &
616                              'cum'//'d'//trim(tname(iq))//'_dry', &
617                              'tracer tendency dry deposition'//ttext(iiq), "-", &
618                              (/ '', '', '', '', '', '', '', '', '', '' /))
619
620            o_trac_cum(itr) = ctrl_out((/ 1, 4, 10, 10, 10, 10, 11, 11, 11, 11 /), &
621                               'cum'//tname(iiq),&
622                               'Cumulated tracer '//ttext(iiq), "-", &
623                               (/ '', '', '', '', '', '', '', '', '', '' /))
624            ENDDO
625      ENDIF
626
627   ENDDO !  iff
628
629        write(*,*) 'phys_output_mid 589'
630#ifdef ISO
631  do ixt=1,ntraciso
632     if (ixt.le.niso) then
633        striso_sortie=striso(ixt)
634     else
635#ifdef ISOTRAC
636        iiso=index_iso(ixt)
637        izone=index_zone(ixt)       
638        striso_sortie=striso(iiso)//strtrac(izone)
639#else
640        write(*,*) 'phys_output_mod 546: ixt,ntraciso=', ixt,ntraciso
641        stop
642#endif
643     endif
644
645   o_xtprecip(ixt)=ctrl_out((/ 1, 1, 1, 10, 5, 10, 11, 11, 11, 11/), &
646    'precip'//striso_sortie(1:lnblnk(striso_sortie)),  &
647    'Precip Totale liq+sol', 'kg/(s*m2)', (/ ('', i=1, 10) /))   
648   o_xtplul(ixt) = ctrl_out((/ 1, 1, 1, 10, 10, 10, 11, 11, 11, 11/), &
649    'plul'//striso_sortie(1:lnblnk(striso_sortie)),  &
650    'Large-scale Precip.', 'kg/(s*m2)', (/ ('', i=1, 10) /))
651   o_xtpluc(ixt) = ctrl_out((/ 1, 1, 1, 10, 5, 10, 11, 11, 11, 11/), &
652    'pluc'//striso_sortie(1:lnblnk(striso_sortie)),  &
653    'Convective Precip.', 'kg/(s*m2)', (/ ('', i=1, 10) /))
654   o_xtevap(ixt) = ctrl_out((/ 1, 1, 10, 10, 10, 10, 11, 11, 11, 11/), &
655    'evap'//striso_sortie(1:lnblnk(striso_sortie)),  &
656    'Evaporat', 'kg/(s*m2)', (/ ('', i=1, 10) /))
657   o_xtovap(ixt) = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11, 11/), &
658    'ovap'//striso_sortie(1:lnblnk(striso_sortie)),  &
659    'Specific humidity', 'kg/kg', (/ ('', i=1, 10) /))
660   o_xtoliq(ixt) = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11, 11/), &
661    'oliq'//striso_sortie(1:lnblnk(striso_sortie)),  &
662    'Liquid water', 'kg/kg', (/ ('', i=1, 10) /))
663   o_xtcond(ixt) = ctrl_out((/ 2, 3, 4, 10, 10, 10, 11, 11, 11, 11/), &
664    'ocond'//striso_sortie(1:lnblnk(striso_sortie)),  &
665    'Condensed water', 'kg/kg', (/ ('', i=1, 10) /))     
666   o_dxtdyn(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
667    'dqdyn'//striso_sortie(1:lnblnk(striso_sortie)),  &
668    'Dynamics dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
669   o_dxtldyn(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
670    'dqldyn'//striso_sortie(1:lnblnk(striso_sortie)),  &
671    'Dynamics dQL', '(kg/kg)/s', (/ ('', i=1, 10) /))
672   o_dxtcon(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
673    'dqcon'//striso_sortie(1:lnblnk(striso_sortie)),  &
674    'Convection dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
675   o_dxteva(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
676    'dqeva'//striso_sortie(1:lnblnk(striso_sortie)),  &
677    'Reevaporation dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
678   o_dxtlsc(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
679    'dqlsc'//striso_sortie(1:lnblnk(striso_sortie)),  &
680    'Condensation dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
681   o_dxtajs(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
682    'dqajs'//striso_sortie(1:lnblnk(striso_sortie)),  &
683    'Dry adjust. dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
684   o_dxtvdf(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
685    'dqvdf'//striso_sortie(1:lnblnk(striso_sortie)),  &
686    'Boundary-layer dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
687   o_dxtthe(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
688    'dqthe'//striso_sortie(1:lnblnk(striso_sortie)),  &
689    'Thermal dQ', '(kg/kg)/s', (/ ('', i=1, 10) /))
690
691   IF (ok_qch4) then
692     o_dxtch4(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
693        'dqch4'//striso_sortie(1:lnblnk(striso_sortie)),  &
694    'H2O due to CH4 oxidation & photolysis', '(kg/kg)/s', (/ ('', i=1, 10) /))
695   endif ! IF (ok_qch4) then
696
697   if (ixt.eq.iso_HTO) then
698      o_dxtprod_nucl(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
699        'dqprodnucl'//striso_sortie(1:lnblnk(striso_sortie)),  &
700        'dHTO/dt due to nuclear production', '(kg/kg)/s', (/ ('', i=1, 10) /))
701      o_dxtcosmo(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
702        'dqcosmo'//striso_sortie(1:lnblnk(striso_sortie)),  &
703        'dHTO/dt due to cosmogenic production', '(kg/kg)/s', (/ ('', i=1, 10) /))
704      o_dxtdecroiss(ixt) = ctrl_out((/ 4, 10, 10, 10, 10, 10, 11, 11, 11, 11/), &
705        'dqdecroiss'//striso_sortie(1:lnblnk(striso_sortie)),  &
706        'dHTO/dt due to radiative destruction', '(kg/kg)/s', (/ ('', i=1, 10) /))
707   endif !if (ixt.eq.iso_HTO) then
708  enddo !do ixt=1,niso
709#endif
710        write(*,*) 'phys_output_mid 596'
711
712
713    ! Updated write frequencies due to phys_out_filetimesteps.
714    ! Write frequencies are now in seconds. 
715    ecrit_mth = ecrit_files(1)
716    ecrit_day = ecrit_files(2)
717    ecrit_hf  = ecrit_files(3)
718    ecrit_ins = ecrit_files(4)
719    ecrit_LES = ecrit_files(5)
720    ecrit_ins = ecrit_files(6)
721
722    IF (prt_level >= 10) THEN
723      WRITE(lunout,*)'swaerofree_diag=',swaerofree_diag
724      WRITE(lunout,*)'swaero_diag=',swaero_diag
725      WRITE(lunout,*)'dryaod_diag=',dryaod_diag
726      WRITE(lunout,*)'ok_4xCO2atm=',ok_4xCO2atm
727      WRITE(lunout,*)'phys_output_open: ends here'
728    ENDIF
729
730  END SUBROUTINE phys_output_open
731
732  SUBROUTINE convers_timesteps(str,dtime,timestep)
733
734    use ioipsl
735    USE phys_cal_mod
736    USE time_phylmdz_mod, ONLY: day_ref, annee_ref
737    USE print_control_mod, ONLY: lunout
738
739    IMPLICIT NONE
740
741    CHARACTER(LEN=20)   :: str
742    CHARACTER(LEN=10)   :: type
743    INTEGER             :: ipos,il
744    real                :: ttt,xxx,timestep,dayseconde,dtime
745    parameter (dayseconde=86400.)
746
747    ipos=scan(str,'0123456789.',.TRUE.)
748    ! 
749    il=len_trim(str)
750    WRITE(lunout,*) "ipos = ", ipos
751    WRITE(lunout,*) "il = ", il
752    IF (ipos == 0) CALL abort_physic("convers_timesteps", "bad str", 1)
753    read(str(1:ipos),*) ttt
754    WRITE(lunout,*)ttt
755    type=str(ipos+1:il)
756
757    IF ( il == ipos ) THEN
758       type='day'
759    ENDIF
760
761    IF ( type == 'day'.or.type == 'days'.or.type == 'jours'.or.type == 'jour' ) timestep = ttt * dayseconde
762    IF ( type == 'mounths'.or.type == 'mth'.or.type == 'mois' ) THEN
763       WRITE(lunout,*)'annee_ref,day_ref mon_len',annee_ref,day_ref,mth_len
764       timestep = ttt * dayseconde * mth_len
765    ENDIF
766    IF ( type == 'hours'.or.type == 'hr'.or.type == 'heurs') timestep = ttt * dayseconde / 24.
767    IF ( type == 'mn'.or.type == 'minutes'  ) timestep = ttt * 60.
768    IF ( type == 's'.or.type == 'sec'.or.type == 'secondes'   ) timestep = ttt
769    IF ( type == 'TS' ) timestep = ttt * dtime
770
771    WRITE(lunout,*)'type =      ',type
772    WRITE(lunout,*)'nb j/h/m =  ',ttt
773    WRITE(lunout,*)'timestep(s)=',timestep
774
775  END SUBROUTINE convers_timesteps
776
777END MODULE phys_output_mod
Note: See TracBrowser for help on using the repository browser.