107 type(verticalgrid_type),
intent(in) :: gv
108 real,
dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
111 real,
dimension(SZI_(G),SZJB_(G),SZK_(G)), &
114 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
117 type(thermo_var_ptrs),
intent(inout) :: tv
119 type(time_type),
intent(inout) :: time
120 type(param_file_type),
intent(in) :: pf
122 type(directories),
intent(in) :: dirs
124 type(mom_restart_cs),
pointer :: restart_cs
126 type(ale_cs),
pointer :: ale_csp
127 type(tracer_registry_type),
pointer :: tracer_reg
128 type(sponge_cs),
pointer :: sponge_csp
129 type(ale_sponge_cs),
pointer :: ale_sponge_csp
130 type(ocean_obc_type),
pointer :: obc
131 type(time_type),
optional,
intent(in) :: time_in
150 character(len=200) :: filename
151 character(len=200) :: filename2
152 character(len=200) :: inputdir
153 character(len=200) :: config
154 logical :: from_z_file, useale
156 integer :: write_geom
157 logical :: use_temperature, use_sponge
160 logical :: depress_sfc
162 logical :: trim_ic_for_p_surf
164 logical :: regrid_accelerate
165 integer :: regrid_iterations
166 logical :: analytic_fv_pgf, obsol_test
171 type(eos_type),
pointer :: eos => null()
174 #include "version_variable.h" 175 integer :: i, j, k, is, ie, js, je, isq, ieq, jsq, jeq, nz
176 integer :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
178 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
179 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
180 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
181 isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
183 call calltree_enter(
"MOM_initialize_state(), MOM_state_initialization.F90")
184 call log_version(pf, mdl, version,
"")
185 call get_param(pf, mdl,
"DEBUG", debug, default=.false.)
188 if ((dirs%input_filename(1:1) ==
'n') .and. &
189 (len_trim(dirs%input_filename) == 1)) new_sim = .true.
191 just_read = .not.new_sim
193 call get_param(pf, mdl,
"INPUTDIR", inputdir, &
194 "The directory in which input files are found.", default=
".")
195 inputdir = slasher(inputdir)
197 use_temperature =
ASSOCIATED(tv%T)
198 useale =
associated(ale_csp)
199 use_eos =
associated(tv%eqn_of_state)
200 if (use_eos) eos => tv%eqn_of_state
208 call mom_mesg(
"Run initialized internally.", 3)
210 if (
present(time_in)) time = time_in
225 call get_param(pf, mdl,
"INIT_LAYERS_FROM_Z_FILE", from_z_file, &
226 "If true, intialize the layer thicknesses, temperatures, \n"//&
227 "and salnities from a Z-space file on a latitude- \n"//&
228 "longitude grid.", default=.false., do_not_log=just_read)
230 if (from_z_file)
then 232 if (.NOT.use_temperature)
call mom_error(fatal,
"MOM_initialize_state : "//&
233 "use_temperature must be true if INIT_LAYERS_FROM_Z_FILE is true")
235 call mom_temp_salt_initialize_from_z(h, tv, g, gv, pf, just_read_params=just_read)
239 call get_param(pf, mdl,
"THICKNESS_CONFIG", config, &
240 "A string that determines how the initial layer \n"//&
241 "thicknesses are specified for a new run: \n"//&
242 " \t file - read interface heights from the file specified \n"//&
243 " \t thickness_file - read thicknesses from the file specified \n"//&
244 " \t\t by (THICKNESS_FILE).\n"//&
245 " \t coord - determined by ALE coordinate.\n"//&
246 " \t uniform - uniform thickness layers evenly distributed \n"//&
247 " \t\t between the surface and MAXIMUM_DEPTH. \n"//&
248 " \t DOME - use a slope and channel configuration for the \n"//&
249 " \t\t DOME sill-overflow test case. \n"//&
250 " \t ISOMIP - use a configuration for the \n"//&
251 " \t\t ISOMIP test case. \n"//&
252 " \t benchmark - use the benchmark test case thicknesses. \n"//&
253 " \t search - search a density profile for the interface \n"//&
254 " \t\t densities. This is not yet implemented. \n"//&
255 " \t circle_obcs - the circle_obcs test case is used. \n"//&
256 " \t DOME2D - 2D version of DOME initialization. \n"//&
257 " \t adjustment2d - TBD AJA. \n"//&
258 " \t sloshing - TBD AJA. \n"//&
259 " \t seamount - TBD AJA. \n"//&
260 " \t soliton - Equatorial Rossby soliton. \n"//&
261 " \t rossby_front - a mixed layer front in thermal wind balance.\n"//&
262 " \t USER - call a user modified routine.", &
263 fail_if_missing=new_sim, do_not_log=just_read)
264 select case (trim(config))
265 case (
"file");
call initialize_thickness_from_file(h, g, gv, pf, .false., just_read_params=just_read)
266 case (
"thickness_file");
call initialize_thickness_from_file(h, g, gv, pf, .true., just_read_params=just_read)
268 if (new_sim .and. useale)
then 269 call ale_initthicknesstocoord( ale_csp, g, gv, h )
270 elseif (new_sim)
then 271 call mom_error(fatal,
"MOM_initialize_state: USE_REGRIDDING must be True "//&
272 "for THICKNESS_CONFIG of 'coord'")
274 case (
"uniform");
call initialize_thickness_uniform(h, g, gv, pf, &
275 just_read_params=just_read)
276 case (
"DOME");
call dome_initialize_thickness(h, g, gv, pf, &
277 just_read_params=just_read)
278 case (
"ISOMIP");
call isomip_initialize_thickness(h, g, gv, pf, tv, &
279 just_read_params=just_read)
280 case (
"benchmark");
call benchmark_initialize_thickness(h, g, gv, pf, &
281 tv%eqn_of_state, tv%P_Ref, just_read_params=just_read)
282 case (
"search");
call initialize_thickness_search
283 case (
"circle_obcs");
call circle_obcs_initialize_thickness(h, g, gv, pf, &
284 just_read_params=just_read)
285 case (
"lock_exchange");
call lock_exchange_initialize_thickness(h, g, gv, &
286 pf, just_read_params=just_read)
287 case (
"external_gwave");
call external_gwave_initialize_thickness(h, g, &
288 pf, just_read_params=just_read)
289 case (
"DOME2D");
call dome2d_initialize_thickness(h, g, gv, pf, &
290 just_read_params=just_read)
291 case (
"adjustment2d");
call adjustment_initialize_thickness(h, g, gv, &
292 pf, just_read_params=just_read)
293 case (
"sloshing");
call sloshing_initialize_thickness(h, g, gv, pf, &
294 just_read_params=just_read)
295 case (
"seamount");
call seamount_initialize_thickness(h, g, gv, pf, &
296 just_read_params=just_read)
297 case (
"soliton");
call soliton_initialize_thickness(h, g)
298 case (
"phillips");
call phillips_initialize_thickness(h, g, gv, pf, &
299 just_read_params=just_read)
300 case (
"rossby_front");
call rossby_front_initialize_thickness(h, g, gv, &
301 pf, just_read_params=just_read)
302 case (
"USER");
call user_initialize_thickness(h, g, pf, tv%T, &
303 just_read_params=just_read)
304 case default ;
call mom_error(fatal,
"MOM_initialize_state: "//&
305 "Unrecognized layer thickness configuration "//trim(config))
309 if ( use_temperature )
then 310 call get_param(pf, mdl,
"TS_CONFIG", config, &
311 "A string that determines how the initial tempertures \n"//&
312 "and salinities are specified for a new run: \n"//&
313 " \t file - read velocities from the file specified \n"//&
314 " \t\t by (TS_FILE). \n"//&
315 " \t fit - find the temperatures that are consistent with \n"//&
316 " \t\t the layer densities and salinity S_REF. \n"//&
317 " \t TS_profile - use temperature and salinity profiles \n"//&
318 " \t\t (read from TS_FILE) to set layer densities. \n"//&
319 " \t benchmark - use the benchmark test case T & S. \n"//&
320 " \t linear - linear in logical layer space. \n"//&
321 " \t DOME2D - 2D DOME initialization. \n"//&
322 " \t ISOMIP - ISOMIP initialization. \n"//&
323 " \t adjustment2d - TBD AJA. \n"//&
324 " \t sloshing - TBD AJA. \n"//&
325 " \t seamount - TBD AJA. \n"//&
326 " \t rossby_front - a mixed layer front in thermal wind balance.\n"//&
327 " \t SCM_ideal_hurr - used in the SCM idealized hurricane test.\n"//&
328 " \t SCM_CVmix_tests - used in the SCM CVmix tests.\n"//&
329 " \t USER - call a user modified routine.", &
330 fail_if_missing=new_sim, do_not_log=just_read)
332 select case (trim(config))
333 case (
"fit");
call initialize_temp_salt_fit(tv%T, tv%S, g, gv, pf, &
334 eos, tv%P_Ref, just_read_params=just_read)
335 case (
"file");
call initialize_temp_salt_from_file(tv%T, tv%S, g, &
336 pf, just_read_params=just_read)
337 case (
"benchmark");
call benchmark_init_temperature_salinity(tv%T, tv%S, &
338 g, gv, pf, eos, tv%P_Ref, just_read_params=just_read)
339 case (
"TS_profile") ;
call initialize_temp_salt_from_profile(tv%T, tv%S, &
340 g, pf, just_read_params=just_read)
341 case (
"linear");
call initialize_temp_salt_linear(tv%T, tv%S, g, pf, &
342 just_read_params=just_read)
343 case (
"DOME2D");
call dome2d_initialize_temperature_salinity ( tv%T, &
344 tv%S, h, g, pf, eos, just_read_params=just_read)
345 case (
"ISOMIP");
call isomip_initialize_temperature_salinity ( tv%T, &
346 tv%S, h, g, gv, pf, eos, just_read_params=just_read)
347 case (
"adjustment2d");
call adjustment_initialize_temperature_salinity ( tv%T, &
348 tv%S, h, g, pf, eos, just_read_params=just_read)
349 case (
"baroclinic_zone");
call baroclinic_zone_init_temperature_salinity( tv%T, &
350 tv%S, h, g, pf, just_read_params=just_read)
351 case (
"sloshing");
call sloshing_initialize_temperature_salinity(tv%T, &
352 tv%S, h, g, pf, eos, just_read_params=just_read)
353 case (
"seamount");
call seamount_initialize_temperature_salinity(tv%T, &
354 tv%S, h, g, gv, pf, eos, just_read_params=just_read)
355 case (
"rossby_front");
call rossby_front_initialize_temperature_salinity ( tv%T, &
356 tv%S, h, g, pf, eos, just_read_params=just_read)
357 case (
"SCM_ideal_hurr");
call scm_idealized_hurricane_ts_init ( tv%T, &
358 tv%S, h, g, gv, pf, just_read_params=just_read)
359 case (
"SCM_CVmix_tests");
call scm_cvmix_tests_ts_init (tv%T, &
360 tv%S, h, g, gv, pf, just_read_params=just_read)
361 case (
"dense");
call dense_water_initialize_ts(g, gv, pf, eos, tv%T, tv%S, &
362 h, just_read_params=just_read)
363 case (
"USER");
call user_init_temperature_salinity(tv%T, tv%S, g, pf, eos, &
364 just_read_params=just_read)
365 case default ;
call mom_error(fatal,
"MOM_initialize_state: "//&
366 "Unrecognized Temp & salt configuration "//trim(config))
372 if (new_sim)
call pass_var(h, g%Domain)
375 call get_param(pf, mdl,
"VELOCITY_CONFIG", config, &
376 "A string that determines how the initial velocities \n"//&
377 "are specified for a new run: \n"//&
378 " \t file - read velocities from the file specified \n"//&
379 " \t\t by (VELOCITY_FILE). \n"//&
380 " \t zero - the fluid is initially at rest. \n"//&
381 " \t uniform - the flow is uniform (determined by\n"//&
382 " \t\t parameters INITIAL_U_CONST and INITIAL_V_CONST).\n"//&
383 " \t rossby_front - a mixed layer front in thermal wind balance.\n"//&
384 " \t soliton - Equatorial Rossby soliton.\n"//&
385 " \t USER - call a user modified routine.", default=
"zero", &
386 do_not_log=just_read)
387 select case (trim(config))
388 case (
"file");
call initialize_velocity_from_file(u, v, g, pf, &
389 just_read_params=just_read)
390 case (
"zero");
call initialize_velocity_zero(u, v, g, pf, &
391 just_read_params=just_read)
392 case (
"uniform");
call initialize_velocity_uniform(u, v, g, pf, &
393 just_read_params=just_read)
394 case (
"circular");
call initialize_velocity_circular(u, v, g, pf, &
395 just_read_params=just_read)
396 case (
"phillips");
call phillips_initialize_velocity(u, v, g, gv, pf, &
397 just_read_params=just_read)
398 case (
"rossby_front");
call rossby_front_initialize_velocity(u, v, h, &
399 g, gv, pf, just_read_params=just_read)
400 case (
"soliton");
call soliton_initialize_velocity(u, v, h, g)
401 case (
"USER");
call user_initialize_velocity(u, v, g, pf, &
402 just_read_params=just_read)
403 case default ;
call mom_error(fatal,
"MOM_initialize_state: "//&
404 "Unrecognized velocity configuration "//trim(config))
407 if (new_sim)
call pass_vector(u, v, g%Domain)
408 if (debug .and. new_sim)
then 409 call uvchksum(
"MOM_initialize_state [uv]", u, v, g%HI, haloshift=1)
414 call get_param(pf, mdl,
"CONVERT_THICKNESS_UNITS", convert, &
415 "If true, convert the thickness initial conditions from \n"//&
416 "units of m to kg m-2 or vice versa, depending on whether \n"//&
417 "BOUSSINESQ is defined. This does not apply if a restart \n"//&
418 "file is read.", default=.false., do_not_log=just_read)
420 if (convert .and. .not. gv%Boussinesq)
then 422 call convert_thickness(h, g, gv, tv)
423 elseif (gv%Boussinesq)
then 425 do k = 1, nz;
do j = js, je;
do i = is, ie
426 h(i,j,k) = h(i,j,k)*gv%m_to_H
427 enddo ;
enddo ;
enddo 429 do k = 1, nz;
do j = js, je;
do i = is, ie
430 h(i,j,k) = h(i,j,k)*gv%kg_m2_to_H
431 enddo ;
enddo ;
enddo 436 call get_param(pf, mdl,
"DEPRESS_INITIAL_SURFACE", depress_sfc, &
437 "If true, depress the initial surface to avoid huge \n"//&
438 "tsunamis when a large surface pressure is applied.", &
439 default=.false., do_not_log=just_read)
440 call get_param(pf, mdl,
"TRIM_IC_FOR_P_SURF", trim_ic_for_p_surf, &
441 "If true, cuts way the top of the column for initial conditions\n"//&
442 "at the depth where the hydrostatic presure matches the imposed\n"//&
443 "surface pressure which is read from file.", default=.false., &
444 do_not_log=just_read)
445 if (depress_sfc .and. trim_ic_for_p_surf)
call mom_error(fatal,
"MOM_initialize_state: "//&
446 "DEPRESS_INITIAL_SURFACE and TRIM_IC_FOR_P_SURF are exclusive and cannot both be True")
447 if (depress_sfc)
call depress_surface(h, g, gv, pf, tv, just_read_params=just_read)
448 if (trim_ic_for_p_surf)
call trim_for_ice(pf, g, gv, ale_csp, tv, h, just_read_params=just_read)
453 call get_param(pf, mdl,
"REGRID_ACCELERATE_INIT", regrid_accelerate, &
454 "If true, runs REGRID_ACCELERATE_ITERATIONS iterations of the regridding\n"//&
455 "algorithm to push the initial grid to be consistent with the initial\n"//&
456 "condition. Useful only for state-based and iterative coordinates.", &
457 default=.false., do_not_log=just_read)
458 if (regrid_accelerate)
then 459 call get_param(pf, mdl,
"REGRID_ACCELERATE_ITERATIONS", regrid_iterations, &
460 "The number of regridding iterations to perform to generate\n"//&
461 "an initial grid that is consistent with the initial conditions.", &
462 default=1, do_not_log=just_read)
465 call ale_regrid_accelerated(ale_csp, g, gv, h, tv, regrid_iterations, h, u, v)
471 if (.not.new_sim)
then 474 call restore_state(dirs%input_filename, dirs%restart_input_dir, time, &
476 if (
present(time_in)) time = time_in
479 if ( use_temperature )
then 480 call pass_var(tv%T, g%Domain, complete=.false.)
481 call pass_var(tv%S, g%Domain, complete=.false.)
483 call pass_var(h, g%Domain)
486 call hchksum(h,
"MOM_initialize_state: h ", g%HI, haloshift=1, scale=gv%H_to_m)
487 if ( use_temperature )
call hchksum(tv%T,
"MOM_initialize_state: T ", g%HI, haloshift=1)
488 if ( use_temperature )
call hchksum(tv%S,
"MOM_initialize_state: S ", g%HI, haloshift=1)
491 call get_param(pf, mdl,
"SPONGE", use_sponge, &
492 "If true, sponges may be applied anywhere in the domain. \n"//&
493 "The exact location and properties of those sponges are \n"//&
494 "specified via SPONGE_CONFIG.", default=.false.)
495 if ( use_sponge )
then 496 call get_param(pf, mdl,
"SPONGE_CONFIG", config, &
497 "A string that sets how the sponges are configured: \n"//&
498 " \t file - read sponge properties from the file \n"//&
499 " \t\t specified by (SPONGE_FILE).\n"//&
500 " \t ISOMIP - apply ale sponge in the ISOMIP case \n"//&
501 " \t DOME - use a slope and channel configuration for the \n"//&
502 " \t\t DOME sill-overflow test case. \n"//&
503 " \t BFB - Sponge at the southern boundary of the domain\n"//&
504 " \t\t for buoyancy-forced basin case.\n"//&
505 " \t USER - call a user modified routine.", default=
"file")
506 select case (trim(config))
507 case (
"DOME");
call dome_initialize_sponges(g, gv, tv, pf, sponge_csp)
508 case (
"DOME2D");
call dome2d_initialize_sponges(g, gv, tv, pf, useale, &
509 sponge_csp, ale_sponge_csp)
510 case (
"ISOMIP");
call isomip_initialize_sponges(g, gv, tv, pf, useale, &
511 sponge_csp, ale_sponge_csp)
512 case (
"USER");
call user_initialize_sponges(g, use_temperature, tv, &
514 case (
"BFB");
call bfb_initialize_sponges_southonly(g, use_temperature, tv, &
516 case (
"phillips");
call phillips_initialize_sponges(g, use_temperature, tv, &
518 case (
"dense");
call dense_water_initialize_sponges(g, gv, tv, pf, useale, &
519 sponge_csp, ale_sponge_csp)
520 case (
"file");
call initialize_sponges_file(g, gv, use_temperature, tv, &
522 case default ;
call mom_error(fatal,
"MOM_initialize_state: "//&
523 "Unrecognized sponge configuration "//trim(config))
528 call open_boundary_init(g, pf, obc)
531 if (
associated(obc))
then 532 call get_param(pf, mdl,
"OBC_USER_CONFIG", config, &
533 "A string that sets how the user code is invoked to set open\n"//&
534 " boundary data: \n"//&
535 " DOME - specified inflow on northern boundary\n"//&
536 " tidal_bay - Flather with tidal forcing on eastern boundary\n"//&
537 " supercritical - now only needed here for the allocations\n"//&
538 " Kelvin - barotropic Kelvin wave forcing on the western boundary\n"//&
539 " shelfwave - Flather with shelf wave forcing on western boundary\n"//&
540 " USER - user specified", default=
"none")
541 if (trim(config) ==
"DOME")
then 542 call dome_set_obc_data(obc, tv, g, gv, pf, tracer_reg)
543 elseif (lowercase(trim(config)) ==
"supercritical")
then 544 call supercritical_set_obc_data(obc, g, pf)
545 elseif (trim(config) ==
"tidal_bay")
then 546 obc%update_OBC = .true.
547 elseif (trim(config) ==
"Kelvin")
then 548 obc%update_OBC = .true.
549 elseif (trim(config) ==
"shelfwave")
then 550 obc%update_OBC = .true.
551 elseif (trim(config) ==
"USER")
then 552 call user_set_obc_data(obc, tv, g, pf, tracer_reg)
553 elseif (.not. trim(config) ==
"none")
then 554 call mom_error(fatal,
"The open boundary conditions specified by "//&
555 "OBC_USER_CONFIG = "//trim(config)//
" have not been fully implemented.")
557 if (open_boundary_query(obc, apply_open_obc=.true.))
then 558 call set_tracer_data(obc, tv, h, g, pf, tracer_reg)
565 if (debug.and.
associated(obc))
then 566 call hchksum(g%mask2dT,
'MOM_initialize_state: mask2dT ', g%HI)
567 call uvchksum(
'MOM_initialize_state: mask2dC[uv]', g%mask2dCu, &
569 call qchksum(g%mask2dBu,
'MOM_initialize_state: mask2dBu ', g%HI)
572 call calltree_leave(
'MOM_initialize_state()')
Ocean grid type. See mom_grid for details.