1 | MODULE init_testphys1d_mod |
---|
2 | |
---|
3 | implicit none |
---|
4 | |
---|
5 | contains |
---|
6 | |
---|
7 | SUBROUTINE init_testphys1d(pem1d,ngrid,nlayer,odpref,nq,q,time,psurf,u,v,temp,startfiles_1D,therestart1D, & |
---|
8 | therestartfi,ndt,ptif,pks,dttestphys,zqsat,dq,dqdyn,day0,day,gru,grv,w, & |
---|
9 | play,plev,latitude,longitude,cell_area,atm_wat_profile,atm_wat_tau) |
---|
10 | |
---|
11 | use ioipsl_getincom, only: getin ! To use 'getin' |
---|
12 | use comcstfi_h, only: pi, rad, omeg, g, mugaz, rcp, r, cpp |
---|
13 | use time_phylmdz_mod, only: daysec, day_step, ecritphy, iphysiq |
---|
14 | use planete_h, only: year_day, periheli, aphelie, peri_day, obliquit, emin_turb, lmixmin |
---|
15 | use surfdat_h, only: albedodat, z0_default, z0, emissiv, emisice, albedice, iceradius, dtemisice, & |
---|
16 | zmea, zstd, zsig, zgam, zthe, hmons, summit, base, phisfi, watercaptag, watercap, & |
---|
17 | tsurf, emis, qsurf |
---|
18 | use infotrac, only: nqtot, tname, nqperes, nqfils |
---|
19 | use read_profile_mod, only: read_profile |
---|
20 | use iostart, only: open_startphy, get_var, close_startphy |
---|
21 | use physics_distribution_mod, only: init_physics_distribution |
---|
22 | use comsoil_h, only: volcapa, nsoilmx, inertiesoil, inertiedat, layer, mlayer, flux_geo, tsoil |
---|
23 | use comvert_mod, only: ap, bp, aps, bps, pa, preff, presnivs, pseudoalt, scaleheight |
---|
24 | use dimradmars_mod, only: tauvis, totcloudfrac, albedo |
---|
25 | use regular_lonlat_mod, only: init_regular_lonlat |
---|
26 | use mod_interface_dyn_phys, only: init_interface_dyn_phys |
---|
27 | use geometry_mod, only: init_geometry, init_geometry_cell_area_for_outputs |
---|
28 | use dimphy, only: init_dimphy |
---|
29 | use comgeomfi_h, only: sinlat, ini_fillgeom |
---|
30 | use slope_mod, only: theta_sl, psi_sl |
---|
31 | use comslope_mod, only: def_slope, subslope_dist |
---|
32 | use dust_param_mod, only: tauscaling |
---|
33 | use tracer_mod, only: igcm_co2 |
---|
34 | use logic_mod, only: hybrid |
---|
35 | use vertical_layers_mod, only: init_vertical_layers |
---|
36 | use inichim_newstart_mod, only: inichim_newstart |
---|
37 | use mod_grid_phy_lmdz, only: regular_lonlat |
---|
38 | use phys_state_var_init_mod, only: phys_state_var_init |
---|
39 | use turb_mod, only: q2 |
---|
40 | use nonoro_gwd_ran_mod, only: du_nonoro_gwd, dv_nonoro_gwd |
---|
41 | use conf_phys_mod, only: conf_phys |
---|
42 | ! Mostly for XIOS outputs: |
---|
43 | use mod_const_mpi, only: COMM_LMDZ |
---|
44 | |
---|
45 | implicit none |
---|
46 | |
---|
47 | include "dimensions.h" |
---|
48 | include "callkeys.h" |
---|
49 | |
---|
50 | !======================================================================= |
---|
51 | ! Arguments |
---|
52 | !======================================================================= |
---|
53 | integer, intent(in) :: ngrid, nlayer |
---|
54 | real, intent(in) :: odpref ! DOD reference pressure (Pa) |
---|
55 | logical, intent(in) :: pem1d ! If initialization for the 1D PEM |
---|
56 | |
---|
57 | integer, intent(inout) :: nq |
---|
58 | |
---|
59 | real, dimension(:,:,:), allocatable, intent(out) :: q ! tracer mixing ratio (e.g. kg/kg) |
---|
60 | real, intent(out) :: time ! time (0<time<1; time=0.5 at noon) |
---|
61 | real, intent(out) :: psurf ! Surface pressure |
---|
62 | real, dimension(nlayer), intent(out) :: u, v ! zonal, meridional wind |
---|
63 | real, dimension(nlayer), intent(out) :: temp ! temperature at the middle of the layers |
---|
64 | logical, intent(out) :: startfiles_1D, therestart1D, therestartfi ! Use of starting files for 1D |
---|
65 | integer, intent(out) :: ndt |
---|
66 | real, intent(out) :: ptif, pks |
---|
67 | real, intent(out) :: dttestphys ! testphys1d timestep |
---|
68 | real, dimension(:), allocatable, intent(out) :: zqsat ! useful for (atm_wat_profile=2) |
---|
69 | real, dimension(:,:,:), allocatable, intent(out) :: dq, dqdyn ! Physical and dynamical tandencies |
---|
70 | integer, intent(out) :: day0 ! initial (sol ; =0 at Ls=0) and final date |
---|
71 | real, intent(out) :: day ! date during the run |
---|
72 | real, intent(out) :: gru, grv ! prescribed "geostrophic" background wind |
---|
73 | real, dimension(nlayer), intent(out) :: w ! "Dummy wind" in 1D |
---|
74 | real, dimension(nlayer), intent(out) :: play ! Pressure at the middle of the layers (Pa) |
---|
75 | real, dimension(nlayer + 1), intent(out) :: plev ! intermediate pressure levels (pa) |
---|
76 | real, dimension(1), intent(out) :: latitude, longitude, cell_area |
---|
77 | real, intent(out) :: atm_wat_profile, atm_wat_tau ! Force atmospheric water profiles |
---|
78 | |
---|
79 | !======================================================================= |
---|
80 | ! Local variables |
---|
81 | !======================================================================= |
---|
82 | integer :: ierr, iq, j, ilayer, isoil, nlevel, nsoil, flagthermo, flagh2o |
---|
83 | integer :: dayn ! Final date |
---|
84 | real, dimension(nlayer) :: zlay ! altitude estimee dans les couches (km) |
---|
85 | real, dimension(0:nlayer) :: tmp1, tmp2 |
---|
86 | |
---|
87 | ! Dummy variables along "dynamics scalar grid" |
---|
88 | real, dimension(:,:,:,:), allocatable :: qdyn |
---|
89 | real, dimension(:,:), allocatable :: psdyn |
---|
90 | |
---|
91 | ! RV & JBC: Use of starting files for 1D |
---|
92 | logical :: found |
---|
93 | character(len = 30) :: header |
---|
94 | real, dimension(100) :: tab_cntrl |
---|
95 | real, dimension(1,2,1) :: albedo_read ! surface albedo |
---|
96 | |
---|
97 | ! New flag to compute paleo orbital configurations + few variables JN |
---|
98 | logical :: paleomars |
---|
99 | real :: halfaxe, eccentric, Lsperi |
---|
100 | |
---|
101 | ! MVals: isotopes as in the dynamics (CRisi) |
---|
102 | integer :: ifils, ipere, generation, ierr0 |
---|
103 | character(len = 30), dimension(:), allocatable :: tnom_transp ! transporting fluid short name |
---|
104 | character(len = 80) :: line ! to store a line of text |
---|
105 | logical :: continu, there |
---|
106 | |
---|
107 | ! LL: Possibility to add subsurface ice |
---|
108 | real :: ice_depth ! depth of the ice table, ice_depth < 0. means no ice |
---|
109 | real :: inertieice = 2100. ! ice thermal inertia |
---|
110 | integer :: iref |
---|
111 | |
---|
112 | ! LL: Subsurface geothermal flux |
---|
113 | real :: flux_geo_tmp |
---|
114 | |
---|
115 | ! JBC: To initialize the 1D PEM |
---|
116 | character(:), allocatable :: start1Dname, startfiname ! Name of starting files for 1D |
---|
117 | |
---|
118 | !======================================================================= |
---|
119 | ! Code |
---|
120 | !======================================================================= |
---|
121 | if (.not. pem1d) then |
---|
122 | start1Dname = 'start1D.txt' |
---|
123 | startfiname = 'startfi.nc' |
---|
124 | startfiles_1D = .false. |
---|
125 | !------------------------------------------------------ |
---|
126 | ! Loading run parameters from "run.def" file |
---|
127 | !------------------------------------------------------ |
---|
128 | ! check if 'run.def' file is around. Otherwise reading parameters |
---|
129 | ! from callphys.def via getin() routine won't work. |
---|
130 | inquire(file = 'run.def',exist = there) |
---|
131 | if (.not. there) then |
---|
132 | write(*,*) 'Cannot find required file "run.def"' |
---|
133 | write(*,*) ' (which should contain some input parameters along with the following line: INCLUDEDEF=callphys.def)' |
---|
134 | write(*,*) ' ... might as well stop here ...' |
---|
135 | error stop |
---|
136 | endif |
---|
137 | |
---|
138 | write(*,*)'Do you want to use starting files?' |
---|
139 | call getin("startfiles_1D",startfiles_1D) |
---|
140 | write(*,*) " startfiles_1D = ", startfiles_1D |
---|
141 | else |
---|
142 | start1dname = 'start1D_evol.txt' |
---|
143 | startfiname = 'startfi_evol.nc' |
---|
144 | startfiles_1D = .true. |
---|
145 | endif |
---|
146 | |
---|
147 | therestart1D = .false. |
---|
148 | therestartfi = .false. |
---|
149 | inquire(file = start1Dname,exist = therestart1D) |
---|
150 | if (startfiles_1D .and. .not. therestart1D) then |
---|
151 | write(*,*) 'There is no "'//start1Dname//'" file!' |
---|
152 | if (.not. pem1d) then |
---|
153 | write(*,*) 'Initialization is done with default values.' |
---|
154 | else |
---|
155 | error stop 'Initialization cannot be done for the 1D PEM.' |
---|
156 | endif |
---|
157 | endif |
---|
158 | inquire(file = startfiname,exist = therestartfi) |
---|
159 | if (.not. therestartfi) then |
---|
160 | write(*,*) 'There is no "'//startfiname//'" file!' |
---|
161 | if (.not. pem1d) then |
---|
162 | write(*,*) 'Initialization is done with default values.' |
---|
163 | else |
---|
164 | error stop 'Initialization cannot be done for the 1D PEM.' |
---|
165 | endif |
---|
166 | endif |
---|
167 | |
---|
168 | !------------------------------------------------------ |
---|
169 | ! Prescribed constants to be set here |
---|
170 | !------------------------------------------------------ |
---|
171 | pi = 2.*asin(1.) |
---|
172 | |
---|
173 | ! Mars planetary constants |
---|
174 | ! ------------------------ |
---|
175 | rad = 3397200. ! mars radius (m) ~3397200 m |
---|
176 | daysec = 88775. ! length of a sol (s) ~88775 s |
---|
177 | omeg = 4.*asin(1.)/daysec ! rotation rate (rad.s-1) |
---|
178 | g = 3.72 ! gravity (m.s-2) ~3.72 |
---|
179 | mugaz = 43.49 ! atmosphere mola mass (g.mol-1) ~43.49 |
---|
180 | rcp = .256793 ! = r/cp ~0.256793 |
---|
181 | r = 8.314511*1000./mugaz |
---|
182 | cpp = r/rcp |
---|
183 | year_day = 669 ! length of year (sols) ~668.6 |
---|
184 | periheli = 206.66 ! minimum sun-mars distance (Mkm) ~206.66 |
---|
185 | aphelie = 249.22 ! maximum sun-mars distance (Mkm) ~249.22 |
---|
186 | halfaxe = 227.94 ! demi-grand axe de l'ellipse |
---|
187 | peri_day = 485. ! perihelion date (sols since N. Spring) |
---|
188 | obliquit = 25.2 ! Obliquity (deg) ~25.2 |
---|
189 | eccentric = 0.0934 ! Eccentricity (0.0934) |
---|
190 | |
---|
191 | ! Planetary Boundary Layer and Turbulence parameters |
---|
192 | ! -------------------------------------------------- |
---|
193 | z0_default = 1.e-2 ! surface roughness (m) ~0.01 |
---|
194 | emin_turb = 1.e-6 ! minimal turbulent energy ~1.e-8 |
---|
195 | lmixmin = 30 ! mixing length ~100 |
---|
196 | |
---|
197 | ! cap properties and surface emissivities |
---|
198 | ! --------------------------------------- |
---|
199 | emissiv = 0.95 ! Bare ground emissivity ~.95 |
---|
200 | emisice(1) = 0.95 ! Northern cap emissivity |
---|
201 | emisice(2) = 0.95 ! Southern cap emisssivity |
---|
202 | albedice(1) = 0.5 ! Northern cap albedo |
---|
203 | albedice(2) = 0.5 ! Southern cap albedo |
---|
204 | iceradius(1) = 100.e-6 ! mean scat radius of CO2 snow (north) |
---|
205 | iceradius(2) = 100.e-6 ! mean scat radius of CO2 snow (south) |
---|
206 | dtemisice(1) = 2. ! time scale for snow metamorphism (north) |
---|
207 | dtemisice(2) = 2. ! time scale for snow metamorphism (south) |
---|
208 | |
---|
209 | ! mesh surface (not a very usefull quantity in 1D) |
---|
210 | ! ------------------------------------------------ |
---|
211 | cell_area(1) = 1. |
---|
212 | |
---|
213 | ! check if there is a 'traceur.def' file and process it |
---|
214 | ! load tracer names from file 'traceur.def' |
---|
215 | open(90,file = 'traceur.def',status = 'old',form = 'formatted',iostat = ierr) |
---|
216 | if (ierr /= 0) then |
---|
217 | write(*,*) 'Cannot find required file "traceur.def"' |
---|
218 | write(*,*) ' If you want to run with tracers, I need it' |
---|
219 | write(*,*) ' ... might as well stop here ...' |
---|
220 | error stop |
---|
221 | else |
---|
222 | write(*,*) "init_testphys1d: Reading file traceur.def" |
---|
223 | ! read number of tracers: |
---|
224 | read(90,*,iostat = ierr) nq |
---|
225 | nqtot = nq ! set value of nqtot (in infotrac module) as nq |
---|
226 | if (ierr /= 0) then |
---|
227 | write(*,*) "init_testphys1d: error reading number of tracers" |
---|
228 | write(*,*) " (first line of traceur.def) " |
---|
229 | error stop |
---|
230 | endif |
---|
231 | if (nq < 1) then |
---|
232 | write(*,*) "init_testphys1d: error number of tracers" |
---|
233 | write(*,*) "is nq=",nq," but must be >=1!" |
---|
234 | error stop |
---|
235 | endif |
---|
236 | endif |
---|
237 | |
---|
238 | ! allocate arrays: |
---|
239 | allocate(tname(nq),q(1,nlayer,nq),zqsat(nlayer)) |
---|
240 | allocate(dq(1,nlayer,nq),dqdyn(1,nlayer,nq),tnom_transp(nq)) |
---|
241 | |
---|
242 | ! read tracer names from file traceur.def |
---|
243 | do iq = 1,nq |
---|
244 | read(90,'(80a)',iostat = ierr) line ! store the line from traceur.def |
---|
245 | if (ierr /= 0) then |
---|
246 | error stop 'init_testphys1d: error reading tracer names...' |
---|
247 | endif |
---|
248 | ! if format is tnom_0, tnom_transp (isotopes) |
---|
249 | read(line,*,iostat = ierr0) tname(iq),tnom_transp(iq) |
---|
250 | if (ierr0 /= 0) then |
---|
251 | read(line,*) tname(iq) |
---|
252 | tnom_transp(iq) = 'air' |
---|
253 | endif |
---|
254 | enddo |
---|
255 | close(90) |
---|
256 | |
---|
257 | ! Isotopes: as in the 3D case we have to determine father/son relations for isotopes and carrying fluid |
---|
258 | allocate(nqfils(nqtot)) |
---|
259 | nqperes = 0 |
---|
260 | nqfils(:) = 0 |
---|
261 | do iq = 1,nqtot |
---|
262 | if (tnom_transp(iq) == 'air') then |
---|
263 | ! ceci est un traceur père |
---|
264 | write(*,*) 'Le traceur',iq,', appele ',trim(tname(iq)),', est un pere' |
---|
265 | nqperes = nqperes + 1 |
---|
266 | else !if (tnom_transp(iq) == 'air') then |
---|
267 | ! ceci est un fils. Qui est son père? |
---|
268 | write(*,*) 'Le traceur',iq,', appele ',trim(tname(iq)),', est un fils' |
---|
269 | continu = .true. |
---|
270 | ipere = 1 |
---|
271 | do while (continu) |
---|
272 | if (tnom_transp(iq) == tname(ipere)) then |
---|
273 | ! Son père est ipere |
---|
274 | write(*,*) 'Le traceur',iq,'appele ',trim(tname(iq)),' est le fils de ',ipere,'appele ',trim(tname(ipere)) |
---|
275 | nqfils(ipere) = nqfils(ipere) + 1 |
---|
276 | continu = .false. |
---|
277 | else !if (tnom_transp(iq) == tnom_0(ipere)) then |
---|
278 | ipere = ipere + 1 |
---|
279 | if (ipere > nqtot) then |
---|
280 | write(*,*) 'Le traceur',iq,'appele ',trim(tname(iq)),', est orpelin.' |
---|
281 | call abort_gcm('infotrac_init','Un traceur est orphelin',1) |
---|
282 | endif !if (ipere > nqtot) then |
---|
283 | endif !if (tnom_transp(iq) == tnom_0(ipere)) then |
---|
284 | enddo !do while (continu) |
---|
285 | endif !if (tnom_transp(iq) == 'air') then |
---|
286 | enddo !do iq=1,nqtot |
---|
287 | write(*,*) 'nqperes=',nqperes |
---|
288 | write(*,*) 'nqfils=',nqfils |
---|
289 | |
---|
290 | #ifdef CPP_XIOS |
---|
291 | call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,COMM_LMDZ) |
---|
292 | #else |
---|
293 | call init_physics_distribution(regular_lonlat,4,1,1,1,nlayer,1) |
---|
294 | #endif |
---|
295 | |
---|
296 | ! Date and local time at beginning of run |
---|
297 | ! --------------------------------------- |
---|
298 | if (.not. startfiles_1D) then |
---|
299 | ! Date (in sols since spring solstice) at beginning of run |
---|
300 | day0 = 0 ! default value for day0 |
---|
301 | write(*,*) 'Initial date (in martian sols; =0 at Ls=0)?' |
---|
302 | call getin("day0",day0) |
---|
303 | day = float(day0) |
---|
304 | write(*,*) " day0 = ",day0 |
---|
305 | ! Local time at beginning of run |
---|
306 | time = 0 ! default value for time |
---|
307 | write(*,*)'Initial local time (in hours, between 0 and 24)?' |
---|
308 | call getin("time",time) |
---|
309 | write(*,*)" time = ",time |
---|
310 | time = time/24. ! convert time (hours) to fraction of sol |
---|
311 | else |
---|
312 | call open_startphy(startfiname) |
---|
313 | call get_var("controle",tab_cntrl,found) |
---|
314 | if (.not. found) then |
---|
315 | call abort_physic("open_startphy","tabfi: Failed reading <controle> array",1) |
---|
316 | else |
---|
317 | write(*,*)'tabfi: tab_cntrl',tab_cntrl |
---|
318 | endif |
---|
319 | day0 = tab_cntrl(3) |
---|
320 | day = float(day0) |
---|
321 | |
---|
322 | call get_var("Time",time,found) |
---|
323 | call close_startphy |
---|
324 | endif !startfiles_1D |
---|
325 | |
---|
326 | ! Discretization (Definition of grid and time steps) |
---|
327 | ! -------------------------------------------------- |
---|
328 | nlevel = nlayer + 1 |
---|
329 | nsoil = nsoilmx |
---|
330 | |
---|
331 | day_step = 48 ! default value for day_step |
---|
332 | write(*,*)'Number of time steps per sol?' |
---|
333 | call getin("day_step",day_step) |
---|
334 | write(*,*) " day_step = ",day_step |
---|
335 | |
---|
336 | ecritphy = day_step ! default value for ecritphy, output every time step |
---|
337 | |
---|
338 | ndt = 10 ! default value for ndt |
---|
339 | write(*,*)'Number of sols to run?' |
---|
340 | call getin("ndt",ndt) |
---|
341 | write(*,*) " ndt = ",ndt |
---|
342 | |
---|
343 | dayn = day0 + ndt |
---|
344 | ndt = ndt*day_step |
---|
345 | dttestphys = daysec/day_step |
---|
346 | |
---|
347 | ! Imposed surface pressure |
---|
348 | ! ------------------------ |
---|
349 | psurf = 610. ! Default value for psurf |
---|
350 | write(*,*) 'Surface pressure (Pa)?' |
---|
351 | if (.not. therestart1D) then |
---|
352 | call getin("psurf",psurf) |
---|
353 | else |
---|
354 | open(3,file = start1Dname,status = "old",action = "read") |
---|
355 | read(3,*) header, psurf |
---|
356 | endif |
---|
357 | write(*,*) " psurf = ",psurf |
---|
358 | |
---|
359 | ! Reference pressures |
---|
360 | pa = 20. ! transition pressure (for hybrid coord.) |
---|
361 | preff = 610. ! reference surface pressure |
---|
362 | |
---|
363 | ! Aerosol properties |
---|
364 | ! ------------------ |
---|
365 | tauvis = 0.2 ! default value for tauvis (dust opacity) |
---|
366 | write(*,'("Reference dust opacity at ",f4.0," Pa?")')odpref |
---|
367 | call getin("tauvis",tauvis) |
---|
368 | write(*,*) " tauvis = ",tauvis |
---|
369 | |
---|
370 | ! Orbital parameters |
---|
371 | ! ------------------ |
---|
372 | if (.not. startfiles_1D) then |
---|
373 | paleomars = .false. ! Default: no water ice reservoir |
---|
374 | call getin("paleomars",paleomars) |
---|
375 | if (paleomars) then |
---|
376 | write(*,*) "paleomars=", paleomars |
---|
377 | write(*,*) "Orbital parameters from callphys.def" |
---|
378 | write(*,*) "Enter eccentricity & Lsperi" |
---|
379 | write(*,*) 'Martian eccentricity (0<e<1)?' |
---|
380 | call getin('eccentric ',eccentric) |
---|
381 | write(*,*)"eccentric =",eccentric |
---|
382 | write(*,*) 'Solar longitude of perihelion (0<Ls<360)?' |
---|
383 | call getin('Lsperi',Lsperi ) |
---|
384 | write(*,*)"Lsperi=",Lsperi |
---|
385 | Lsperi = Lsperi*pi/180.0 ! Put it in rad for peri_day |
---|
386 | periheli = halfaxe*(1 - eccentric) |
---|
387 | aphelie = halfaxe*(1 + eccentric) |
---|
388 | call call_dayperi(Lsperi,eccentric,peri_day,year_day) |
---|
389 | write(*,*) "Corresponding orbital params for GCM" |
---|
390 | write(*,*) " periheli = ",periheli |
---|
391 | write(*,*) " aphelie = ",aphelie |
---|
392 | write(*,*) "date of perihelion (sol)",peri_day |
---|
393 | else |
---|
394 | write(*,*) "paleomars=", paleomars |
---|
395 | write(*,*) "Default present-day orbital parameters" |
---|
396 | write(*,*) "Unless specified otherwise" |
---|
397 | write(*,*)'Min. distance Sun-Mars (Mkm)?' |
---|
398 | call getin("periheli",periheli) |
---|
399 | write(*,*) " periheli = ",periheli |
---|
400 | |
---|
401 | write(*,*)'Max. distance Sun-Mars (Mkm)?' |
---|
402 | call getin("aphelie",aphelie) |
---|
403 | write(*,*) " aphelie = ",aphelie |
---|
404 | |
---|
405 | write(*,*)'Day of perihelion?' |
---|
406 | call getin("periday",peri_day) |
---|
407 | write(*,*) " periday = ",peri_day |
---|
408 | |
---|
409 | write(*,*)'Obliquity?' |
---|
410 | call getin("obliquit",obliquit) |
---|
411 | write(*,*) " obliquit = ",obliquit |
---|
412 | endif |
---|
413 | endif !(.not. startfiles_1D ) |
---|
414 | |
---|
415 | ! Latitude/longitude |
---|
416 | ! ------------------ |
---|
417 | latitude = 0. ! default value for latitude |
---|
418 | write(*,*)'latitude (in degrees)?' |
---|
419 | call getin("latitude",latitude(1)) |
---|
420 | write(*,*) " latitude = ",latitude |
---|
421 | latitude = latitude*pi/180. |
---|
422 | longitude = 0. |
---|
423 | longitude = longitude*pi/180. |
---|
424 | |
---|
425 | ! Some initializations (some of which have already been |
---|
426 | ! done above!) and loads parameters set in callphys.def |
---|
427 | ! and allocates some arrays |
---|
428 | ! Mars possible matter with dttestphys in input and include!!! |
---|
429 | ! Initializations below should mimick what is done in iniphysiq for 3D GCM |
---|
430 | call init_interface_dyn_phys |
---|
431 | call init_regular_lonlat(1,1,longitude,latitude,(/0.,0./),(/0.,0./)) |
---|
432 | call init_geometry(1,longitude,latitude,(/0.,0.,0.,0./),(/0.,0.,0.,0./),cell_area) |
---|
433 | call init_geometry_cell_area_for_outputs(1,cell_area) |
---|
434 | ! Ehouarn: init_vertial_layers called later (because disvert not called yet) |
---|
435 | ! call init_vertical_layers(nlayer,preff,scaleheight, |
---|
436 | ! & ap,bp,aps,bps,presnivs,pseudoalt) |
---|
437 | call init_dimphy(1,nlayer) ! Initialize dimphy module |
---|
438 | call phys_state_var_init(1,llm,nq,tname,day0,dayn,time,daysec,dttestphys,rad,g,r,cpp,nqperes,nqfils)! MVals: variables isotopes |
---|
439 | call ini_fillgeom(1,latitude,longitude,(/1.0/)) |
---|
440 | call conf_phys(1,llm,nq) |
---|
441 | |
---|
442 | ! In 1D model physics are called every time step |
---|
443 | ! ovverride iphysiq value that has been set by conf_phys |
---|
444 | if (iphysiq /= 1) then |
---|
445 | write(*,*) "init_testphys1d: setting iphysiq=1" |
---|
446 | iphysiq = 1 |
---|
447 | endif |
---|
448 | |
---|
449 | ! Initialize tracers (surface and atmosphere) here: |
---|
450 | write(*,*) "init_testphys1d: initializing tracers" |
---|
451 | if (.not. therestart1D) then |
---|
452 | call read_profile(nq,nlayer,qsurf(1,:,1),q) |
---|
453 | else |
---|
454 | do iq = 1,nq |
---|
455 | read(3,*) header, (qsurf(1,iq,j), j = 1,size(qsurf,3)), (q(1,ilayer,iq), ilayer = 1,nlayer) |
---|
456 | if (trim(tname(iq)) /= trim(header)) then |
---|
457 | write(*,*) 'Tracer names not compatible for initialization with "'//trim(start1Dname)//'"!' |
---|
458 | error stop |
---|
459 | endif |
---|
460 | enddo |
---|
461 | endif |
---|
462 | |
---|
463 | ! Initialize albedo / soil thermal inertia |
---|
464 | ! ---------------------------------------- |
---|
465 | if (.not. startfiles_1D) then |
---|
466 | albedodat(1) = 0.2 ! default value for albedodat |
---|
467 | write(*,*)'Albedo of bare ground?' |
---|
468 | call getin("albedo",albedodat(1)) |
---|
469 | write(*,*) " albedo = ",albedodat(1) |
---|
470 | albedo(1,:,1) = albedodat(1) |
---|
471 | |
---|
472 | inertiedat(1,1) = 400 ! default value for inertiedat |
---|
473 | write(*,*)'Soil thermal inertia (SI)?' |
---|
474 | call getin("inertia",inertiedat(1,1)) |
---|
475 | write(*,*) " inertia = ",inertiedat(1,1) |
---|
476 | |
---|
477 | ice_depth = -1 ! default value: no ice |
---|
478 | call getin("subsurface_ice_depth",ice_depth) |
---|
479 | |
---|
480 | z0(1) = z0_default ! default value for roughness |
---|
481 | write(*,*) 'Surface roughness length z0 (m)?' |
---|
482 | call getin("z0",z0(1)) |
---|
483 | write(*,*) " z0 = ",z0(1) |
---|
484 | endif !(.not. startfiles_1D ) |
---|
485 | |
---|
486 | ! Initialize local slope parameters (only matters if "callslope" |
---|
487 | ! is .true. in callphys.def) |
---|
488 | ! slope inclination angle (deg) 0: horizontal, 90: vertical |
---|
489 | theta_sl(1) = 0. ! default: no inclination |
---|
490 | call getin("slope_inclination",theta_sl(1)) |
---|
491 | ! slope orientation (deg) |
---|
492 | ! 0 == Northward, 90 == Eastward, 180 == Southward, 270 == Westward |
---|
493 | psi_sl(1) = 0. ! default value |
---|
494 | call getin("slope_orientation",psi_sl(1)) |
---|
495 | |
---|
496 | ! Sub-slopes parameters (assuming no sub-slopes distribution for now). |
---|
497 | def_slope(1) = -90 ! minimum slope angle |
---|
498 | def_slope(2) = 90 ! maximum slope angle |
---|
499 | subslope_dist(1,1) = 1 ! fraction of subslopes in mesh |
---|
500 | |
---|
501 | ! For the gravity wave scheme |
---|
502 | ! --------------------------- |
---|
503 | zmea(1) = 0. |
---|
504 | zstd(1) = 0. |
---|
505 | zsig(1) = 0. |
---|
506 | zgam(1) = 0. |
---|
507 | zthe(1) = 0. |
---|
508 | |
---|
509 | ! For the non-orographic gravity waves scheme |
---|
510 | du_nonoro_gwd(1,:)=0 |
---|
511 | dv_nonoro_gwd(1,:)=0 |
---|
512 | |
---|
513 | ! For the slope wind scheme |
---|
514 | ! ------------------------- |
---|
515 | hmons(1) = 0. |
---|
516 | write(*,*)'hmons is initialized to ',hmons(1) |
---|
517 | summit(1) = 0. |
---|
518 | write(*,*)'summit is initialized to ',summit(1) |
---|
519 | base(1) = 0. |
---|
520 | |
---|
521 | ! Default values initializing the coefficients calculated later |
---|
522 | ! ------------------------------------------------------------- |
---|
523 | tauscaling(1) = 1. ! calculated in aeropacity_mod.F |
---|
524 | totcloudfrac(1) = 1. ! calculated in watercloud_mod.F |
---|
525 | |
---|
526 | ! Specific initializations for "physiq" |
---|
527 | ! ------------------------------------- |
---|
528 | ! surface geopotential is not used (or useful) since in 1D |
---|
529 | ! everything is controled by surface pressure |
---|
530 | phisfi(1) = 0. |
---|
531 | |
---|
532 | ! Initialization to take into account prescribed winds |
---|
533 | ! ---------------------------------------------------- |
---|
534 | ptif = 2.*omeg*sinlat(1) |
---|
535 | |
---|
536 | ! Geostrophic wind |
---|
537 | gru = 10. ! default value for gru |
---|
538 | write(*,*)'zonal eastward component of the geostrophic wind (m/s)?' |
---|
539 | call getin("u",gru) |
---|
540 | write(*,*) " u = ",gru |
---|
541 | grv = 0. !default value for grv |
---|
542 | write(*,*)'meridional northward component of the geostrophic wind (m/s)?' |
---|
543 | call getin("v",grv) |
---|
544 | write(*,*) " v = ",grv |
---|
545 | |
---|
546 | ! Initialize winds for first time step |
---|
547 | if (.not. therestart1D) then |
---|
548 | u(:) = gru |
---|
549 | v(:) = grv |
---|
550 | else |
---|
551 | read(3,*) header, (u(ilayer), ilayer = 1,nlayer) |
---|
552 | read(3,*) header, (v(ilayer), ilayer = 1,nlayer) |
---|
553 | endif |
---|
554 | w = 0. ! default: no vertical wind |
---|
555 | |
---|
556 | ! Initialize turbulent kinetic energy |
---|
557 | q2 = 0. |
---|
558 | |
---|
559 | ! CO2 ice on the surface |
---|
560 | ! ---------------------- |
---|
561 | ! get the index of co2 tracer (not known at this stage) |
---|
562 | igcm_co2 = 0 |
---|
563 | do iq = 1,nq |
---|
564 | if (trim(tname(iq)) == "co2") igcm_co2 = iq |
---|
565 | enddo |
---|
566 | if (igcm_co2 == 0) error stop "init_testphys1d error, missing co2 tracer!" |
---|
567 | |
---|
568 | if (.not. startfiles_1D) then |
---|
569 | qsurf(1,igcm_co2,1) = 0. ! default value for co2ice |
---|
570 | write(*,*)'Initial CO2 ice on the surface (kg.m-2)' |
---|
571 | call getin("co2ice",qsurf(1,igcm_co2,1)) |
---|
572 | write(*,*) " co2ice = ",qsurf(1,igcm_co2,1) |
---|
573 | endif !(.not. startfiles_1D ) |
---|
574 | |
---|
575 | ! emissivity |
---|
576 | ! ---------- |
---|
577 | if (.not. startfiles_1D) then |
---|
578 | emis(:,1) = emissiv |
---|
579 | if (qsurf(1,igcm_co2,1) == 1.) then |
---|
580 | emis(:,1) = emisice(1) ! northern hemisphere |
---|
581 | if (latitude(1) < 0) emis(:,1) = emisice(2) ! southern hemisphere |
---|
582 | endif |
---|
583 | endif !(.not. startfiles_1D ) |
---|
584 | |
---|
585 | ! Compute pressures and altitudes of atmospheric levels |
---|
586 | ! ----------------------------------------------------- |
---|
587 | ! Vertical Coordinates |
---|
588 | ! """""""""""""""""""" |
---|
589 | hybrid = .true. |
---|
590 | write(*,*)'Hybrid coordinates?' |
---|
591 | call getin("hybrid",hybrid) |
---|
592 | write(*,*) " hybrid = ", hybrid |
---|
593 | |
---|
594 | call disvert_noterre |
---|
595 | ! Now that disvert has been called, initialize module vertical_layers_mod |
---|
596 | call init_vertical_layers(nlayer,preff,scaleheight,ap,bp,aps,bps,presnivs,pseudoalt) |
---|
597 | |
---|
598 | plev(:) = ap(:) + psurf*bp(:) |
---|
599 | play(:) = aps(:) + psurf*bps(:) |
---|
600 | zlay(:) = -200.*r*log(play(:)/plev(1))/g |
---|
601 | |
---|
602 | ! Initialize temperature profile |
---|
603 | ! ------------------------------ |
---|
604 | pks = psurf**rcp |
---|
605 | |
---|
606 | ! Altitude in km in profile: divide zlay by 1000 |
---|
607 | tmp1(0) = 0. |
---|
608 | tmp1(1:) = zlay(:)/1000. |
---|
609 | |
---|
610 | call profile(nlayer + 1,tmp1,tmp2) |
---|
611 | |
---|
612 | if (.not. therestart1D) then |
---|
613 | tsurf(:,1) = tmp2(0) |
---|
614 | temp(:) = tmp2(1:) |
---|
615 | else |
---|
616 | read(3,*) header, (tsurf(1,:), j = 1,size(tsurf,2)), (temp(ilayer), ilayer = 1,nlayer) |
---|
617 | close(3) |
---|
618 | endif |
---|
619 | |
---|
620 | ! Initialize soil properties and temperature |
---|
621 | ! ------------------------------------------ |
---|
622 | volcapa = 1.e6 ! volumetric heat capacity |
---|
623 | |
---|
624 | if (.not. startfiles_1D) then |
---|
625 | ! Initialize depths |
---|
626 | ! ----------------- |
---|
627 | do isoil = 1,nsoil |
---|
628 | layer(isoil) = 2.e-4*(2.**(isoil - 1)) ! layer depth |
---|
629 | enddo |
---|
630 | |
---|
631 | ! Creating the new soil inertia table if there is subsurface ice: |
---|
632 | if (ice_depth > 0) then |
---|
633 | iref = 1 ! ice/regolith boundary index |
---|
634 | if (ice_depth < layer(1)) then |
---|
635 | inertiedat(1,1) = sqrt(layer(1)/((ice_depth/inertiedat(1,1)**2) + ((layer(1) - ice_depth)/inertieice**2))) |
---|
636 | inertiedat(1,2:) = inertieice |
---|
637 | else ! searching for the ice/regolith boundary: |
---|
638 | do isoil = 1,nsoil |
---|
639 | if ((ice_depth >= layer(isoil)) .and. (ice_depth < layer(isoil + 1))) then |
---|
640 | iref = isoil + 1 |
---|
641 | exit |
---|
642 | endif |
---|
643 | enddo |
---|
644 | ! We then change the soil inertia table: |
---|
645 | inertiedat(1,:iref - 1) = inertiedat(1,1) |
---|
646 | ! We compute the transition in layer(iref) |
---|
647 | inertiedat(1,iref) = sqrt((layer(iref) - layer(iref - 1))/(((ice_depth - layer(iref - 1))/inertiedat(1,1)**2) + ((layer(iref) - ice_depth)/inertieice**2))) |
---|
648 | ! Finally, we compute the underlying ice: |
---|
649 | inertiedat(1,iref + 1:) = inertieice |
---|
650 | endif ! (ice_depth < layer(1)) |
---|
651 | else ! ice_depth < 0 all is set to surface thermal inertia |
---|
652 | inertiedat(1,:) = inertiedat(1,1) ! soil thermal inertia |
---|
653 | endif ! ice_depth > 0 |
---|
654 | |
---|
655 | inertiesoil(1,:,1) = inertiedat(1,:) |
---|
656 | |
---|
657 | tsoil(:,:,1) = tsurf(1,1) ! soil temperature |
---|
658 | endif !(.not. startfiles_1D) |
---|
659 | |
---|
660 | flux_geo_tmp = 0. |
---|
661 | call getin("flux_geo",flux_geo_tmp) |
---|
662 | flux_geo(:,:) = flux_geo_tmp |
---|
663 | |
---|
664 | ! Initialize depths |
---|
665 | ! ----------------- |
---|
666 | do isoil = 0,nsoil - 1 |
---|
667 | mlayer(isoil) = 2.e-4*(2.**(isoil - 0.5)) ! mid-layer depth |
---|
668 | layer(isoil + 1) = 2.e-4*(2.**isoil) ! layer depth |
---|
669 | enddo |
---|
670 | |
---|
671 | ! Initialize traceurs |
---|
672 | ! ------------------- |
---|
673 | if (photochem .or. callthermos) then |
---|
674 | write(*,*) 'Initializing chemical species' |
---|
675 | ! flagthermo=0: initialize over all atmospheric layers |
---|
676 | flagthermo = 0 |
---|
677 | ! check if "h2o_vap" has already been initialized |
---|
678 | ! (it has been if there is a "profile_h2o_vap" file around) |
---|
679 | inquire(file = "profile_h2o_vap",exist = there) |
---|
680 | if (there) then |
---|
681 | flagh2o = 0 ! 0: do not initialize h2o_vap |
---|
682 | else |
---|
683 | flagh2o = 1 ! 1: initialize h2o_vap in inichim_newstart |
---|
684 | endif |
---|
685 | |
---|
686 | ! hack to accomodate that inichim_newstart assumes that |
---|
687 | ! q & psurf arrays are on the dynamics scalar grid |
---|
688 | allocate(qdyn(2,1,llm,nq),psdyn(2,1)) |
---|
689 | qdyn(1,1,1:llm,1:nq) = q(1,1:llm,1:nq) |
---|
690 | psdyn(1:2,1) = psurf |
---|
691 | call inichim_newstart(ngrid,nq,qdyn,qsurf(1,:,1),psdyn,flagh2o,flagthermo) |
---|
692 | q(1,1:llm,1:nq) = qdyn(1,1,1:llm,1:nq) |
---|
693 | endif |
---|
694 | |
---|
695 | ! Check if the surface is a water ice reservoir |
---|
696 | ! --------------------------------------------- |
---|
697 | if (.not. startfiles_1D) watercap(1,:) = 0 ! Initialize watercap |
---|
698 | watercaptag(1) = .false. ! Default: no water ice reservoir |
---|
699 | write(*,*)'Water ice cap on ground?' |
---|
700 | call getin("watercaptag",watercaptag) |
---|
701 | write(*,*) " watercaptag = ",watercaptag |
---|
702 | |
---|
703 | ! Check if the atmospheric water profile is specified |
---|
704 | ! --------------------------------------------------- |
---|
705 | ! Adding an option to force atmospheric water values JN |
---|
706 | atm_wat_profile = -1. ! Default: free atm wat profile |
---|
707 | if (water) then |
---|
708 | write(*,*)'Force atmospheric water vapor profile?' |
---|
709 | call getin('atm_wat_profile',atm_wat_profile) |
---|
710 | write(*,*) 'atm_wat_profile = ', atm_wat_profile |
---|
711 | if (abs(atm_wat_profile + 1.) < 1.e-15) then ! if == -1. |
---|
712 | write(*,*) 'Free atmospheric water vapor profile' |
---|
713 | write(*,*) 'Total water is conserved in the column' |
---|
714 | else if (abs(atm_wat_profile) < 1.e-15) then ! if == 0. |
---|
715 | write(*,*) 'Dry atmospheric water vapor profile' |
---|
716 | else if (0. < atm_wat_profile .and. atm_wat_profile <= 1.) then |
---|
717 | write(*,*) 'Prescribed atmospheric water vapor profile' |
---|
718 | write(*,*) 'Unless it reaches saturation (maximal value)' |
---|
719 | else |
---|
720 | error stop 'Water vapor profile value not correct!' |
---|
721 | endif |
---|
722 | endif |
---|
723 | |
---|
724 | ! Check if the atmospheric water profile relaxation is specified |
---|
725 | ! -------------------------------------------------------------- |
---|
726 | ! Adding an option to relax atmospheric water values JBC |
---|
727 | atm_wat_tau = -1. ! Default: no time relaxation |
---|
728 | if (water) then |
---|
729 | write(*,*) 'Relax atmospheric water vapor profile?' |
---|
730 | call getin('atm_wat_tau',atm_wat_tau) |
---|
731 | write(*,*) 'atm_wat_tau = ', atm_wat_tau |
---|
732 | if (atm_wat_tau < 0.) then |
---|
733 | write(*,*) 'Atmospheric water vapor profile is not relaxed.' |
---|
734 | else |
---|
735 | if (0. <= atm_wat_profile .and. atm_wat_profile <= 1.) then |
---|
736 | write(*,*) 'Relaxed atmospheric water vapor profile towards ', atm_wat_profile |
---|
737 | write(*,*) 'Unless it reaches saturation (maximal value)' |
---|
738 | else |
---|
739 | write(*,*) 'Reference atmospheric water vapor profile not known!' |
---|
740 | error stop 'Please, specify atm_wat_profile' |
---|
741 | endif |
---|
742 | endif |
---|
743 | endif |
---|
744 | |
---|
745 | END SUBROUTINE init_testphys1d |
---|
746 | |
---|
747 | END MODULE init_testphys1d_mod |
---|