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

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

Corrections to fix the isotopic version compilation.

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