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