8 use mom_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end
23 use mom_io, only : east_face, north_face
90 use mom_tracer_initialization_from_z
, only : horiz_interp_and_extrap_tracer
92 implicit none ;
private 94 #include <MOM_memory.h> 98 character(len=40) ::
mdl =
"MOM_state_initialization" 104 restart_CS, ALE_CSp, tracer_Reg, sponge_CSp, &
105 ALE_sponge_CSp, OBC, Time_in)
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)), &
119 type(time_type),
intent(inout) :: Time
126 type(
ale_cs),
pointer :: ALE_CSp
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")
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
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")
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))
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'")
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)
284 just_read_params=just_read)
286 pf, just_read_params=just_read)
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)
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 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))
334 eos, tv%P_Ref, just_read_params=just_read)
336 pf, just_read_params=just_read)
338 g, gv, pf, eos, tv%P_Ref, just_read_params=just_read)
340 g, pf, just_read_params=just_read)
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)
346 tv%S, h, g, gv, pf, eos, just_read_params=just_read)
348 tv%S, h, g, pf, eos, just_read_params=just_read)
350 tv%S, h, g, pf, just_read_params=just_read)
352 tv%S, h, g, pf, eos, just_read_params=just_read)
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)
358 tv%S, h, g, gv, pf, just_read_params=just_read)
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)
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))
389 just_read_params=just_read)
391 just_read_params=just_read)
393 just_read_params=just_read)
395 just_read_params=just_read)
396 case (
"phillips");
call phillips_initialize_velocity(u, v, g, gv, pf, &
397 just_read_params=just_read)
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))
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 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)
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.)
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)
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 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))
509 sponge_csp, ale_sponge_csp)
510 case (
"ISOMIP");
call isomip_initialize_sponges(g, gv, tv, pf, useale, &
511 sponge_csp, ale_sponge_csp)
519 sponge_csp, ale_sponge_csp)
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 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 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.")
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)
582 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
586 logical,
intent(in) :: file_has_thickness
589 logical,
optional,
intent(in) :: just_read_params
601 real :: eta(szi_(g),szj_(g),szk_(g)+1)
602 integer :: inconsistent = 0
605 logical :: correct_thickness
607 character(len=40) :: mdl =
"initialize_thickness_from_file" 608 character(len=200) :: filename, thickness_file, inputdir, mesg
609 integer :: i, j, k, is, ie, js, je, nz
611 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
613 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
615 if (.not.just_read) &
616 call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
618 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".", do_not_log=just_read)
619 inputdir = slasher(inputdir)
620 call get_param(param_file, mdl,
"THICKNESS_FILE", thickness_file, &
621 "The name of the thickness file.", &
622 fail_if_missing=.not.just_read, do_not_log=just_read)
624 filename = trim(inputdir)//trim(thickness_file)
625 if (.not.just_read)
call log_param(param_file, mdl,
"INPUTDIR/THICKNESS_FILE", filename)
627 if ((.not.just_read) .and. (.not.
file_exists(filename, g%Domain)))
call mom_error(fatal, &
628 " initialize_thickness_from_file: Unable to open "//trim(filename))
630 if (file_has_thickness)
then 631 if (just_read)
return 632 call read_data(filename,
"h",h(:,:,:),domain=g%Domain%mpp_domain)
634 call get_param(param_file, mdl,
"ADJUST_THICKNESS", correct_thickness, &
635 "If true, all mass below the bottom removed if the \n"//&
636 "topography is shallower than the thickness input file \n"//&
637 "would indicate.", default=.false., do_not_log=just_read)
638 if (just_read)
return 640 call read_data(filename,
"eta",eta(:,:,:),domain=g%Domain%mpp_domain)
642 if (correct_thickness)
then 645 do k=nz,1,-1 ;
do j=js,je ;
do i=is,ie
646 if (eta(i,j,k) < (eta(i,j,k+1) + gv%Angstrom_z))
then 647 eta(i,j,k) = eta(i,j,k+1) + gv%Angstrom_z
648 h(i,j,k) = gv%Angstrom_z
650 h(i,j,k) = eta(i,j,k) - eta(i,j,k+1)
652 enddo ;
enddo ;
enddo 654 do j=js,je ;
do i=is,ie
655 if (abs(eta(i,j,nz+1) + g%bathyT(i,j)) > 1.0) &
656 inconsistent = inconsistent + 1
658 call sum_across_pes(inconsistent)
660 if ((inconsistent > 0) .and. (is_root_pe()))
then 661 write(mesg,
'("Thickness initial conditions are inconsistent ",'// &
662 '"with topography in ",I8," places.")') inconsistent
663 call mom_error(warning, mesg)
686 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)+1),
intent(inout) :: eta
687 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)),
intent(inout) :: h
689 integer :: i, j, k, is, ie, js, je, nz, contractions, dilations
690 real,
parameter :: hTolerance = 0.1
691 real :: hTmp, eTmp, dilate
692 character(len=100) :: mesg
694 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
697 do j=js,je ;
do i=is,ie
698 if (-eta(i,j,nz+1) > g%bathyT(i,j) + htolerance)
then 699 eta(i,j,nz+1) = -g%bathyT(i,j)
700 contractions = contractions + 1
703 call sum_across_pes(contractions)
704 if ((contractions > 0) .and. (is_root_pe()))
then 705 write(mesg,
'("Thickness initial conditions were contracted ",'// &
706 '"to fit topography in ",I8," places.")') contractions
707 call mom_error(warning,
'adjustEtaToFitBathymetry: '//mesg)
710 do k=nz,1,-1 ;
do j=js,je ;
do i=is,ie
713 if (eta(i,j,k) < (eta(i,j,k+1) + gv%Angstrom_z))
then 714 eta(i,j,k) = eta(i,j,k+1) + gv%Angstrom_z
715 h(i,j,k) = gv%Angstrom_z
717 h(i,j,k) = eta(i,j,k) - eta(i,j,k+1)
719 enddo ;
enddo ;
enddo 722 do j=js,je ;
do i=is,ie
726 if (-eta(i,j,nz+1) < g%bathyT(i,j) - htolerance)
then 727 dilations = dilations + 1
728 if (eta(i,j,1) <= eta(i,j,nz+1))
then 729 do k=1,nz ; h(i,j,k) = (eta(i,j,1)+g%bathyT(i,j)) /
real(nz) ; enddo
731 dilate = (eta(i,j,1)+g%bathyT(i,j)) / (eta(i,j,1)-eta(i,j,nz+1))
732 do k=1,nz ; h(i,j,k) = h(i,j,k) * dilate ;
enddo 734 do k=nz, 2, -1; eta(i,j,k) = eta(i,j,k+1) + h(i,j,k);
enddo 737 call sum_across_pes(dilations)
738 if ((dilations > 0) .and. (is_root_pe()))
then 739 write(mesg,
'("Thickness initial conditions were dilated ",'// &
740 '"to fit topography in ",I8," places.")') dilations
741 call mom_error(warning,
'adjustEtaToFitBathymetry: '//mesg)
751 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)), &
755 logical,
optional,
intent(in) :: just_read_params
765 character(len=40) :: mdl =
"initialize_thickness_uniform" 766 real :: e0(szk_(g)+1)
768 real :: eta1D(szk_(g)+1)
771 integer :: i, j, k, is, ie, js, je, nz
773 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
775 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
777 if (just_read)
return 779 call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
781 if (g%max_depth<=0.)
call mom_error(fatal,
"initialize_thickness_uniform: "// &
782 "MAXIMUM_DEPTH has a non-sensical value! Was it set?")
785 e0(k) = -g%max_depth *
real(k-1) /
real(nz)
788 do j=js,je ;
do i=is,ie
794 eta1d(nz+1) = -1.0*g%bathyT(i,j)
797 if (eta1d(k) < (eta1d(k+1) + gv%Angstrom_z))
then 798 eta1d(k) = eta1d(k+1) + gv%Angstrom_z
799 h(i,j,k) = gv%Angstrom_z
801 h(i,j,k) = eta1d(k) - eta1d(k+1)
813 call mom_error(fatal,
" MOM_state_initialization.F90, initialize_thickness_search: NOT IMPLEMENTED")
820 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)), &
829 real,
dimension(SZI_(G),SZJ_(G)) :: &
831 real :: dz_geo(szi_(g),szj_(g))
835 logical :: Boussinesq
836 integer :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
837 integer :: itt, max_itt
839 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
840 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
842 boussinesq = gv%Boussinesq
843 i_gearth = 1.0 / gv%g_Earth
846 call mom_error(fatal,
"Not yet converting thickness with Boussinesq approx.")
848 if (
associated(tv%eqn_of_state))
then 849 do j=jsq,jeq+1 ;
do i=isq,ieq+1
850 p_bot(i,j) = 0.0 ; p_top(i,j) = 0.0
854 do i=is,ie ; p_top(i,j) = p_bot(i,j) ;
enddo 856 is, ie-is+1, tv%eqn_of_state)
858 p_bot(i,j) = p_top(i,j) + gv%g_Earth * h(i,j,k) * rho(i)
864 0.0, g%HI, tv%eqn_of_state, dz_geo)
865 if (itt < max_itt)
then ;
do j=js,je
867 is, ie-is+1, tv%eqn_of_state)
872 p_bot(i,j) = p_bot(i,j) + rho(i) * (gv%g_Earth*h(i,j,k) - dz_geo(i,j))
877 do j=js,je ;
do i=is,ie
878 h(i,j,k) = (p_bot(i,j) - p_top(i,j)) * gv%kg_m2_to_H * i_gearth
882 do k=1,nz ;
do j=js,je ;
do i=is,ie
883 h(i,j,k) = h(i,j,k) * gv%Rlay(k) * gv%kg_m2_to_H
884 enddo ;
enddo ;
enddo 893 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)), &
897 logical,
optional,
intent(in) :: just_read_params
905 real,
dimension(SZI_(G),SZJ_(G)) :: &
907 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1) :: &
912 character(len=40) :: mdl =
"depress_surface" 913 character(len=200) :: inputdir, eta_srf_file
914 character(len=200) :: filename, eta_srf_var
916 integer :: i, j, k, is, ie, js, je, nz
917 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
919 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
923 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
924 inputdir = slasher(inputdir)
925 call get_param(param_file, mdl,
"SURFACE_HEIGHT_IC_FILE", eta_srf_file,&
926 "The initial condition file for the surface height.", &
927 fail_if_missing=.not.just_read, do_not_log=just_read)
928 call get_param(param_file, mdl,
"SURFACE_HEIGHT_IC_VAR", eta_srf_var, &
929 "The initial condition variable for the surface height.",&
930 default=
"SSH", do_not_log=just_read)
931 filename = trim(inputdir)//trim(eta_srf_file)
932 if (.not.just_read) &
933 call log_param(param_file, mdl,
"INPUTDIR/SURFACE_HEIGHT_IC_FILE", filename)
935 call get_param(param_file, mdl,
"SURFACE_HEIGHT_IC_SCALE", scale_factor, &
936 "A scaling factor to convert SURFACE_HEIGHT_IC_VAR into \n"//&
937 "units of m", units=
"variable", default=1.0, do_not_log=just_read)
939 if (just_read)
return 941 call read_data(filename,eta_srf_var,eta_sfc,domain=g%Domain%mpp_domain)
943 if (scale_factor /= 1.0)
then ;
do j=js,je ;
do i=is,ie
944 eta_sfc(i,j) = eta_sfc(i,j) * scale_factor
945 enddo ;
enddo ;
endif 948 call find_eta(h, tv, gv%g_Earth, g, gv, eta)
950 do j=js,je ;
do i=is,ie ;
if (g%mask2dT(i,j) > 0.0)
then 954 if (eta_sfc(i,j) > eta(i,j,1))
then 956 if (eta_sfc(i,j) - eta(i,j,nz+1) > 10.0*(eta(i,j,1) - eta(i,j,nz+1)))
then 958 call mom_error(warning,
"Free surface height dilation attempted "//&
959 "to exceed 10-fold.", all_print=.true.)
961 dilate = (eta_sfc(i,j) - eta(i,j,nz+1)) / (eta(i,j,1) - eta(i,j,nz+1))
963 do k=1,nz ; h(i,j,k) = h(i,j,k) * dilate ;
enddo 964 elseif (eta(i,j,1) > eta_sfc(i,j))
then 967 if (eta(i,j,k) <= eta_sfc(i,j))
exit 968 if (eta(i,j,k+1) >= eta_sfc(i,j))
then 969 h(i,j,k) = gv%Angstrom
971 h(i,j,k) = max(gv%Angstrom, h(i,j,k) * &
972 (eta_sfc(i,j) - eta(i,j,k+1)) / (eta(i,j,k) - eta(i,j,k+1)) )
976 endif ;
enddo ;
enddo 982 subroutine trim_for_ice(PF, G, GV, ALE_CSp, tv, h, just_read_params)
986 type(
ale_cs),
pointer :: ALE_CSp
988 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
990 logical,
optional,
intent(in) :: just_read_params
994 character(len=200) :: mdl =
"trim_for_ice" 995 real,
dimension(SZI_(G),SZJ_(G)) :: p_surf
996 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)) :: S_t, S_b, T_t, T_b
998 character(len=200) :: inputdir, filename, p_surf_file, p_surf_var
999 real :: scale_factor, min_thickness
1001 logical :: just_read
1002 logical :: use_remapping
1005 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1007 call get_param(pf, mdl,
"SURFACE_PRESSURE_FILE", p_surf_file, &
1008 "The initial condition file for the surface height.", &
1009 fail_if_missing=.not.just_read, do_not_log=just_read)
1010 call get_param(pf, mdl,
"SURFACE_PRESSURE_VAR", p_surf_var, &
1011 "The initial condition variable for the surface height.", &
1012 units=
"kg m-2", default=
"", do_not_log=just_read)
1013 call get_param(pf, mdl,
"INPUTDIR", inputdir, default=
".", do_not_log=.true.)
1014 filename = trim(slasher(inputdir))//trim(p_surf_file)
1015 if (.not.just_read)
call log_param(pf, mdl,
"!INPUTDIR/SURFACE_HEIGHT_IC_FILE", filename)
1017 call get_param(pf, mdl,
"SURFACE_PRESSURE_SCALE", scale_factor, &
1018 "A scaling factor to convert SURFACE_PRESSURE_VAR from\n"//&
1019 "file SURFACE_PRESSURE_FILE into a surface pressure.", &
1020 units=
"file dependent", default=1., do_not_log=just_read)
1021 call get_param(pf, mdl,
"MIN_THICKNESS", min_thickness,
'Minimum layer thickness', &
1022 units=
'm', default=1.e-3, do_not_log=just_read)
1023 call get_param(pf, mdl,
"TRIMMING_USES_REMAPPING", use_remapping, &
1024 'When trimming the column, also remap T and S.', &
1025 default=.false., do_not_log=just_read)
1027 if (just_read)
return 1029 call read_data(filename, p_surf_var, p_surf, domain=g%Domain%mpp_domain)
1030 if (scale_factor /= 1.) p_surf(:,:) = scale_factor * p_surf(:,:)
1032 if (use_remapping)
then 1034 call initialize_remapping(remap_cs,
'PLM', boundary_extrapolation=.true.)
1038 if (
associated(ale_csp) )
then 1040 call pressure_gradient_plm(ale_csp, s_t, s_b, t_t, t_b, g, gv, tv, h)
1046 do k=1,g%ke ;
do j=g%jsc,g%jec ;
do i=g%isc,g%iec
1047 t_t(i,j,k) = tv%T(i,j,k) ; t_b(i,j,k) = tv%T(i,j,k)
1048 s_t(i,j,k) = tv%S(i,j,k) ; s_b(i,j,k) = tv%S(i,j,k)
1049 enddo ;
enddo ;
enddo 1052 do j=g%jsc,g%jec ;
do i=g%isc,g%iec
1053 call cut_off_column_top(gv%ke, tv, gv%Rho0, gv%g_Earth, g%bathyT(i,j), min_thickness, &
1054 tv%T(i,j,:), t_t(i,j,:), t_b(i,j,:), tv%S(i,j,:), s_t(i,j,:), s_b(i,j,:), &
1055 p_surf(i,j), h(i,j,:), remap_cs)
1063 T, T_t, T_b, S, S_t, S_b, p_surf, h, remap_CS)
1064 integer,
intent(in) :: nk
1066 real,
intent(in) :: Rho0
1067 real,
intent(in) :: G_earth
1068 real,
intent(in) :: depth
1069 real,
intent(in) :: min_thickness
1070 real,
dimension(nk),
intent(inout) :: T
1071 real,
dimension(nk),
intent(in) :: T_t
1072 real,
dimension(nk),
intent(in) :: T_b
1073 real,
dimension(nk),
intent(inout) :: S
1074 real,
dimension(nk),
intent(in) :: S_t
1075 real,
dimension(nk),
intent(in) :: S_b
1076 real,
intent(in) :: p_surf
1077 real,
dimension(nk),
intent(inout) :: h
1080 real,
dimension(nk+1) :: e
1081 real,
dimension(nk) :: h0, S0, T0, h1, S1, T1
1082 real :: P_t, P_b, z_out, e_top
1088 e(k) = e(k+1) + h(k)
1095 call find_depth_of_pressure_in_cell(t_t(k), t_b(k), s_t(k), s_b(k), e(k), e(k+1), &
1096 p_t, p_surf, rho0, g_earth, tv%eqn_of_state, p_b, z_out)
1097 if (z_out>=e(k))
then 1100 elseif (z_out<=e(k+1))
then 1110 if (e_top<e(1))
then 1113 if (e(k)>e_top)
then 1116 e_top = e_top - min_thickness
1119 h(k) = max( min_thickness, e(k) - e(k+1) )
1120 if (e(k)<e_top)
exit 1126 if (
associated(remap_cs))
then 1145 real,
dimension(SZIB_(G),SZJ_(G), SZK_(G)),
intent(out) :: u
1146 real,
dimension(SZI_(G),SZJB_(G), SZK_(G)),
intent(out) :: v
1149 logical,
optional,
intent(in) :: just_read_params
1157 character(len=40) :: mdl =
"initialize_velocity_from_file" 1158 character(len=200) :: filename,velocity_file,inputdir
1159 logical :: just_read
1161 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1163 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1165 call get_param(param_file, mdl,
"VELOCITY_FILE", velocity_file, &
1166 "The name of the velocity initial condition file.", &
1167 fail_if_missing=.not.just_read, do_not_log=just_read)
1168 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
1169 inputdir = slasher(inputdir)
1171 if (just_read)
return 1173 filename = trim(inputdir)//trim(velocity_file)
1174 call log_param(param_file, mdl,
"INPUTDIR/VELOCITY_FILE", filename)
1176 if (.not.
file_exists(filename, g%Domain))
call mom_error(fatal, &
1177 " initialize_velocity_from_file: Unable to open "//trim(filename))
1180 call read_data(filename,
"u",u(:,:,:),domain=g%Domain%mpp_domain,position=east_face)
1181 call read_data(filename,
"v",v(:,:,:),domain=g%Domain%mpp_domain,position=north_face)
1190 real,
dimension(SZIB_(G),SZJ_(G), SZK_(G)),
intent(out) :: u
1191 real,
dimension(SZI_(G),SZJB_(G), SZK_(G)),
intent(out) :: v
1194 logical,
optional,
intent(in) :: just_read_params
1202 character(len=200) :: mdl =
"initialize_velocity_zero" 1203 logical :: just_read
1204 integer :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
1205 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1206 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
1208 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1210 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1212 if (just_read)
return 1214 do k=1,nz ;
do j=js,je ;
do i=isq,ieq
1216 enddo ;
enddo ;
enddo 1217 do k=1,nz ;
do j=jsq,jeq ;
do i=is,ie
1219 enddo ;
enddo ;
enddo 1228 real,
dimension(SZIB_(G),SZJ_(G), SZK_(G)),
intent(out) :: u
1229 real,
dimension(SZI_(G),SZJB_(G), SZK_(G)),
intent(out) :: v
1232 logical,
optional,
intent(in) :: just_read_params
1240 integer :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
1241 real :: initial_u_const, initial_v_const
1242 logical :: just_read
1243 character(len=200) :: mdl =
"initialize_velocity_uniform" 1244 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1245 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
1247 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1249 call get_param(param_file, mdl,
"INITIAL_U_CONST", initial_u_const, &
1250 "A initial uniform value for the zonal flow.", &
1251 units=
"m s-1", fail_if_missing=.not.just_read, do_not_log=just_read)
1252 call get_param(param_file, mdl,
"INITIAL_V_CONST", initial_v_const, &
1253 "A initial uniform value for the meridional flow.", &
1254 units=
"m s-1", fail_if_missing=.not.just_read, do_not_log=just_read)
1256 if (just_read)
return 1258 do k=1,nz ;
do j=js,je ;
do i=isq,ieq
1259 u(i,j,k) = initial_u_const
1260 enddo ;
enddo ;
enddo 1261 do k=1,nz ;
do j=jsq,jeq ;
do i=is,ie
1262 v(i,j,k) = initial_v_const
1263 enddo ;
enddo ;
enddo 1271 real,
dimension(SZIB_(G),SZJ_(G), SZK_(G)),
intent(out) :: u
1272 real,
dimension(SZI_(G),SZJB_(G), SZK_(G)),
intent(out) :: v
1275 logical,
optional,
intent(in) :: just_read_params
1284 character(len=200) :: mdl =
"initialize_velocity_circular" 1285 real :: circular_max_u
1286 real :: dpi, psi1, psi2
1287 logical :: just_read
1288 integer :: i, j, k, is, ie, js, je, Isq, Ieq, Jsq, Jeq, nz
1289 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1290 isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
1292 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1294 call get_param(param_file, mdl,
"CIRCULAR_MAX_U", circular_max_u, &
1295 "The amplitude of zonal flow from which to scale the\n"// &
1296 "circular stream function (m/s).", &
1297 units=
"m s-1", default=0., do_not_log=just_read)
1299 if (just_read)
return 1303 do k=1,nz ;
do j=js,je ;
do i=isq,ieq
1306 u(i,j,k) = (psi1-psi2)/g%dy_Cu(i,j)
1307 enddo ;
enddo ;
enddo 1308 do k=1,nz ;
do j=jsq,jeq ;
do i=is,ie
1311 v(i,j,k) = (psi2-psi1)/g%dx_Cv(i,j)
1312 enddo ;
enddo ;
enddo 1316 real function my_psi(ig,jg)
1319 x = 2.0*(g%geoLonBu(ig,jg)-g%west_lon)/g%len_lon-1.0
1320 y = 2.0*(g%geoLatBu(ig,jg)-g%south_lat)/g%len_lat-1.0
1321 r = sqrt( x**2 + y**2 )
1323 my_psi = 0.5*(1.0 - cos(dpi*r))
1333 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)),
intent(out) :: T
1334 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)),
intent(out) :: S
1336 logical,
optional,
intent(in) :: just_read_params
1349 logical :: just_read
1350 character(len=200) :: filename, salt_filename
1351 character(len=200) :: ts_file, salt_file, inputdir
1352 character(len=40) :: mdl =
"initialize_temp_salt_from_file" 1353 character(len=64) :: temp_var, salt_var
1355 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1357 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1359 call get_param(param_file, mdl,
"TS_FILE", ts_file, &
1360 "The initial condition file for temperature.", &
1361 fail_if_missing=.not.just_read, do_not_log=just_read)
1362 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
1363 inputdir = slasher(inputdir)
1365 filename = trim(inputdir)//trim(ts_file)
1366 if (.not.just_read)
call log_param(param_file, mdl,
"INPUTDIR/TS_FILE", filename)
1367 call get_param(param_file, mdl,
"TEMP_IC_VAR", temp_var, &
1368 "The initial condition variable for potential temperature.", &
1369 default=
"PTEMP", do_not_log=just_read)
1370 call get_param(param_file, mdl,
"SALT_IC_VAR", salt_var, &
1371 "The initial condition variable for salinity.", &
1372 default=
"SALT", do_not_log=just_read)
1373 call get_param(param_file, mdl,
"SALT_FILE", salt_file, &
1374 "The initial condition file for salinity.", &
1375 default=trim(ts_file), do_not_log=just_read)
1377 if (just_read)
return 1379 if (.not.
file_exists(filename, g%Domain))
call mom_error(fatal, &
1380 " initialize_temp_salt_from_file: Unable to open "//trim(filename))
1383 call read_data(filename, temp_var, t(:,:,:), domain=g%Domain%mpp_domain)
1385 salt_filename = trim(inputdir)//trim(salt_file)
1386 if (.not.
file_exists(salt_filename, g%Domain))
call mom_error(fatal, &
1387 " initialize_temp_salt_from_file: Unable to open "//trim(salt_filename))
1389 call read_data(salt_filename, salt_var, s(:,:,:), domain=g%Domain%mpp_domain)
1398 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)),
intent(out) :: T, S
1400 logical,
optional,
intent(in) :: just_read_params
1413 real,
dimension(SZK_(G)) :: T0, S0
1415 logical :: just_read
1416 character(len=200) :: filename, ts_file, inputdir
1417 character(len=40) :: mdl =
"initialize_temp_salt_from_profile" 1419 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1421 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1423 call get_param(param_file, mdl,
"TS_FILE", ts_file, &
1424 "The file with the reference profiles for temperature \n"//&
1425 "and salinity.", fail_if_missing=.not.just_read, do_not_log=just_read)
1427 if (just_read)
return 1429 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
1430 inputdir = slasher(inputdir)
1431 filename = trim(inputdir)//trim(ts_file)
1432 call log_param(param_file, mdl,
"INPUTDIR/TS_FILE", filename)
1433 if (.not.
file_exists(filename))
call mom_error(fatal, &
1434 " initialize_temp_salt_from_profile: Unable to open "//trim(filename))
1437 call read_data(filename,
"PTEMP",t0(:),domain=g%Domain%mpp_domain)
1438 call read_data(filename,
"SALT", s0(:),domain=g%Domain%mpp_domain)
1440 do k=1,g%ke ;
do j=g%jsc,g%jec ;
do i=g%isc,g%iec
1441 t(i,j,k) = t0(k) ; s(i,j,k) = s0(k)
1442 enddo ;
enddo ;
enddo 1453 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)), &
1456 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)), &
1460 type(
eos_type),
pointer :: eqn_of_state
1461 real,
intent(in) :: P_Ref
1463 logical,
optional,
intent(in) :: just_read_params
1476 real :: T0(szk_(g)), S0(szk_(g))
1479 real :: pres(szk_(g))
1480 real :: drho_dT(szk_(g))
1481 real :: drho_dS(szk_(g))
1482 real :: rho_guess(szk_(g))
1483 logical :: fit_salin
1484 logical :: just_read
1485 character(len=40) :: mdl =
"initialize_temp_salt_fit" 1486 integer :: i, j, k, itt, nz
1489 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1491 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1493 call get_param(param_file, mdl,
"T_REF", t_ref, &
1494 "A reference temperature used in initialization.", &
1495 units=
"degC", fail_if_missing=.not.just_read, do_not_log=just_read)
1496 call get_param(param_file, mdl,
"S_REF", s_ref, &
1497 "A reference salinity used in initialization.", units=
"PSU", &
1498 default=35.0, do_not_log=just_read)
1499 call get_param(param_file, mdl,
"FIT_SALINITY", fit_salin, &
1500 "If true, accept the prescribed temperature and fit the \n"//&
1501 "salinity; otherwise take salinity and fit temperature.", &
1502 default=.false., do_not_log=just_read)
1504 if (just_read)
return 1507 pres(k) = p_ref ; s0(k) = s_ref
1512 call calculate_density_derivs(t0,s0,pres,drho_dt,drho_ds,1,1,eqn_of_state)
1517 s0(k) = max(0.0, s0(1) + (gv%Rlay(k) - rho_guess(1)) / drho_ds(1))
1522 call calculate_density_derivs(t0,s0,pres,drho_dt,drho_ds,1,nz,eqn_of_state)
1524 s0(k) = max(0.0, s0(k) + (gv%Rlay(k) - rho_guess(k)) / drho_ds(k))
1530 t0(k) = t0(1) + (gv%Rlay(k) - rho_guess(1)) / drho_dt(1)
1534 call calculate_density_derivs(t0,s0,pres,drho_dt,drho_ds,1,nz,eqn_of_state)
1536 t0(k) = t0(k) + (gv%Rlay(k) - rho_guess(k)) / drho_dt(k)
1541 do k=1,nz ;
do j=g%jsd,g%jed ;
do i=g%isd,g%ied
1542 t(i,j,k) = t0(k) ; s(i,j,k) = s0(k)
1543 enddo ;
enddo ;
enddo 1552 real,
dimension(SZI_(G),SZJ_(G), SZK_(G)),
intent(out) :: T, S
1555 logical,
optional,
intent(in) :: just_read_params
1565 real :: delta_S, delta_T
1566 real :: S_top, T_top
1567 real :: S_range, T_range
1569 logical :: just_read
1570 character(len=40) :: mdl =
"initialize_temp_salt_linear" 1572 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1574 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1575 call get_param(param_file, mdl,
"T_TOP", t_top, &
1576 "Initial temperature of the top surface.", &
1577 units=
"degC", fail_if_missing=.not.just_read, do_not_log=just_read)
1578 call get_param(param_file, mdl,
"T_RANGE", t_range, &
1579 "Initial temperature difference (top-bottom).", &
1580 units=
"degC", fail_if_missing=.not.just_read, do_not_log=just_read)
1581 call get_param(param_file, mdl,
"S_TOP", s_top, &
1582 "Initial salinity of the top surface.", &
1583 units=
"PSU", fail_if_missing=.not.just_read, do_not_log=just_read)
1584 call get_param(param_file, mdl,
"S_RANGE", s_range, &
1585 "Initial salinity difference (top-bottom).", &
1586 units=
"PSU", fail_if_missing=.not.just_read, do_not_log=just_read)
1588 if (just_read)
return 1597 s(:,:,k) = s_top - s_range*((
real(k)-0.5)/
real(G%ke))
1598 t(:,:,k) = t_top - t_range*((
real(k)-0.5)/
real(G%ke))
1623 logical,
intent(in) :: use_temperature
1652 real :: eta(szi_(g),szj_(g),szk_(g)+1)
1653 real,
dimension (SZI_(G),SZJ_(G),SZK_(G)) :: &
1655 real,
dimension (SZI_(G),SZJ_(G)) :: &
1658 real :: Idamp(szi_(g),szj_(g))
1659 real :: pres(szi_(g))
1661 integer :: i, j, k, is, ie, js, je, nz
1662 character(len=40) :: potemp_var, salin_var, Idamp_var, eta_var
1663 character(len=40) :: mdl =
"initialize_sponges_file" 1664 character(len=200) :: damping_file, state_file
1665 character(len=200) :: filename, inputdir
1666 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1668 pres(:) = 0.0 ; eta(:,:,:) = 0.0 ; tmp(:,:,:) = 0.0 ; idamp(:,:) = 0.0
1670 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
1671 inputdir = slasher(inputdir)
1672 call get_param(param_file, mdl,
"SPONGE_DAMPING_FILE", damping_file, &
1673 "The name of the file with the sponge damping rates.", &
1674 fail_if_missing=.true.)
1675 call get_param(param_file, mdl,
"SPONGE_STATE_FILE", state_file, &
1676 "The name of the file with the state to damp toward.", &
1677 default=damping_file)
1679 call get_param(param_file, mdl,
"SPONGE_PTEMP_VAR", potemp_var, &
1680 "The name of the potential temperature variable in \n"//&
1681 "SPONGE_STATE_FILE.", default=
"PTEMP")
1682 call get_param(param_file, mdl,
"SPONGE_SALT_VAR", salin_var, &
1683 "The name of the salinity variable in \n"//&
1684 "SPONGE_STATE_FILE.", default=
"SALT")
1685 call get_param(param_file, mdl,
"SPONGE_ETA_VAR", eta_var, &
1686 "The name of the interface height variable in \n"//&
1687 "SPONGE_STATE_FILE.", default=
"ETA")
1688 call get_param(param_file, mdl,
"SPONGE_IDAMP_VAR", idamp_var, &
1689 "The name of the inverse damping rate variable in \n"//&
1690 "SPONGE_DAMPING_FILE.", default=
"IDAMP")
1692 filename = trim(inputdir)//trim(damping_file)
1693 call log_param(param_file, mdl,
"INPUTDIR/SPONGE_DAMPING_FILE", filename)
1695 call mom_error(fatal,
" initialize_sponges: Unable to open "//trim(filename))
1698 call read_data(filename,
"Idamp",idamp(:,:), domain=g%Domain%mpp_domain)
1704 filename = trim(inputdir)//trim(state_file)
1705 call log_param(param_file, mdl,
"INPUTDIR/SPONGE_STATE_FILE", filename)
1707 call mom_error(fatal,
" initialize_sponges: Unable to open "//trim(filename))
1711 call read_data(filename, eta_var, eta(:,:,:), domain=g%Domain%mpp_domain)
1713 do j=js,je ;
do i=is,ie
1714 eta(i,j,nz+1) = -g%bathyT(i,j)
1716 do k=nz,1,-1 ;
do j=js,je ;
do i=is,ie
1717 if (eta(i,j,k) < (eta(i,j,k+1) + gv%Angstrom_z)) &
1718 eta(i,j,k) = eta(i,j,k+1) + gv%Angstrom_z
1719 enddo ;
enddo ;
enddo 1728 if ( gv%nkml>0 )
then 1732 do i=is-1,ie ; pres(i) = tv%P_Ref ;
enddo 1734 call read_data(filename, potemp_var, tmp(:,:,:), domain=g%Domain%mpp_domain)
1735 call read_data(filename, salin_var, tmp2(:,:,:), domain=g%Domain%mpp_domain)
1739 is, ie-is+1, tv%eqn_of_state)
1742 call set_up_sponge_ml_density(tmp_2d, g, csp)
1746 if ( use_temperature )
then 1747 call read_data(filename, potemp_var, tmp(:,:,:), domain=g%Domain%mpp_domain)
1748 call set_up_sponge_field(tmp, tv%T, g, nz, csp)
1749 call read_data(filename, salin_var, tmp(:,:,:), domain=g%Domain%mpp_domain)
1750 call set_up_sponge_field(tmp, tv%S, g, nz, csp)
1764 do i=g%isd,g%ied-1 ;
do j=g%jsd,g%jed
1765 g%Dblock_u(i,j) = g%mask2dCu(i,j) * max(g%bathyT(i,j), g%bathyT(i+1,j))
1766 g%Dopen_u(i,j) = g%Dblock_u(i,j)
1768 do i=g%isd,g%ied ;
do j=g%jsd,g%jed-1
1769 g%Dblock_v(i,j) = g%mask2dCv(i,j) * max(g%bathyT(i,j), g%bathyT(i,j+1))
1770 g%Dopen_v(i,j) = g%Dblock_v(i,j)
1780 real,
dimension(G%isc:G%iec, G%jsc:G%jec) :: tmpForSumming
1783 tmpforsumming(:,:) = 0.
1784 g%areaT_global = 0.0 ; g%IareaT_global = 0.0
1785 do j=g%jsc,g%jec ;
do i=g%isc,g%iec
1786 tmpforsumming(i,j) = g%areaT(i,j) * g%mask2dT(i,j)
1789 g%IareaT_global = 1. / g%areaT_global
1799 do i=g%isd,g%ied-1 ;
do j=g%jsd,g%jed
1800 g%Dblock_u(i,j) = g%mask2dCu(i,j) * min(g%bathyT(i,j), g%bathyT(i+1,j))
1801 g%Dopen_u(i,j) = g%Dblock_u(i,j)
1803 do i=g%isd,g%ied ;
do j=g%jsd,g%jed-1
1804 g%Dblock_v(i,j) = g%mask2dCv(i,j) * min(g%bathyT(i,j), g%bathyT(i,j+1))
1805 g%Dopen_v(i,j) = g%Dblock_v(i,j)
1828 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)), &
1835 logical,
optional,
intent(in) :: just_read_params
1838 character(len=200) :: filename
1840 character(len=200) :: shelf_file
1841 character(len=200) :: inputdir
1842 character(len=200) :: mesg, area_varname, ice_shelf_file
1844 type(
eos_type),
pointer :: eos => null()
1847 #include "version_variable.h" 1848 character(len=40) :: mdl =
"MOM_initialize_layers_from_Z" 1850 integer :: is, ie, js, je, nz
1851 integer :: isc,iec,jsc,jec
1852 integer :: isg, ieg, jsg, jeg
1853 integer :: isd, ied, jsd, jed
1855 integer :: i, j, k, ks, np, ni, nj
1856 integer :: idbg, jdbg
1857 integer :: nkml, nkbl
1859 integer :: kd, inconsistent
1862 real,
dimension(:,:),
pointer :: shelf_area
1865 real :: missing_value_temp, missing_value_salt
1866 logical :: correct_thickness
1867 character(len=40) :: potemp_var, salin_var
1868 character(len=8) :: laynum
1870 integer,
parameter :: niter=10
1871 logical :: just_read
1872 logical :: adjust_temperature = .true.
1873 real,
parameter :: missing_value = -1.e20
1874 real,
parameter :: temp_land_fill = 0.0, salt_land_fill = 35.0
1875 logical :: reentrant_x, tripolar_n,dbg
1876 logical :: debug = .false.
1879 real,
dimension(:),
allocatable :: z_edges_in, z_in, Rb
1880 real,
dimension(:,:,:),
allocatable,
target :: temp_z, salt_z, mask_z
1881 real,
dimension(:,:,:),
allocatable :: rho_z
1882 real,
dimension(SZI_(G),SZJ_(G),SZK_(G)+1) :: zi
1883 real,
dimension(SZI_(G),SZJ_(G)) :: nlevs
1884 real,
dimension(SZI_(G)) :: press
1888 real,
dimension(:),
allocatable :: hTarget
1889 real,
dimension(:,:),
allocatable :: area_shelf_h
1890 real,
dimension(:,:),
allocatable,
target :: frac_shelf_h
1891 real,
dimension(:,:,:),
allocatable :: tmpT1dIn, tmpS1dIn, h1, tmp_mask_in
1892 real :: zTopOfCell, zBottomOfCell
1896 logical :: homogenize, useALEremapping, remap_full_column, remap_general, remap_old_alg
1897 logical :: use_ice_shelf
1898 character(len=10) :: remappingScheme
1899 real :: tempAvg, saltAvg
1900 integer :: nPoints, ans
1901 integer :: id_clock_routine, id_clock_read, id_clock_interp, id_clock_fill, id_clock_ALE
1903 id_clock_routine = cpu_clock_id(
'(Initialize from Z)', grain=clock_routine)
1904 id_clock_ale = cpu_clock_id(
'(Initialize from Z) ALE', grain=clock_loop)
1906 call cpu_clock_begin(id_clock_routine)
1908 is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
1909 isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
1910 isg = g%isg ; ieg = g%ieg ; jsg = g%jsg ; jeg = g%jeg
1912 pi_180=atan(1.0)/45.
1914 just_read = .false. ;
if (
present(just_read_params)) just_read = just_read_params
1916 if (.not.just_read)
call calltree_enter(trim(mdl)//
"(), MOM_state_initialization.F90")
1917 if (.not.just_read)
call log_version(pf, mdl, version,
"")
1919 inputdir =
"." ;
call get_param(pf, mdl,
"INPUTDIR", inputdir)
1920 inputdir = slasher(inputdir)
1922 eos => tv%eqn_of_state
1926 reentrant_x = .false. ;
call get_param(pf, mdl,
"REENTRANT_X", reentrant_x,default=.true.)
1927 tripolar_n = .false. ;
call get_param(pf, mdl,
"TRIPOLAR_N", tripolar_n, default=.false.)
1928 call get_param(pf, mdl,
"MINIMUM_DEPTH", min_depth, default=0.0)
1930 call get_param(pf, mdl,
"NKML",nkml,default=0)
1931 call get_param(pf, mdl,
"NKBL",nkbl,default=0)
1933 call get_param(pf, mdl,
"TEMP_SALT_Z_INIT_FILE",filename, &
1934 "The name of the z-space input file used to initialize \n"//&
1935 "the layer thicknesses, temperatures and salinities.", &
1936 default=
"temp_salt_z.nc", do_not_log=just_read)
1937 filename = trim(inputdir)//trim(filename)
1938 call get_param(pf, mdl,
"Z_INIT_FILE_PTEMP_VAR", potemp_var, &
1939 "The name of the potential temperature variable in \n"//&
1940 "TEMP_SALT_Z_INIT_FILE.", default=
"ptemp", do_not_log=just_read)
1941 call get_param(pf, mdl,
"Z_INIT_FILE_SALT_VAR", salin_var, &
1942 "The name of the salinity variable in \n"//&
1943 "TEMP_SALT_Z_INIT_FILE.", default=
"salt", do_not_log=just_read)
1944 call get_param(pf, mdl,
"Z_INIT_HOMOGENIZE", homogenize, &
1945 "If True, then horizontally homogenize the interpolated \n"//&
1946 "initial conditions.", default=.false., do_not_log=just_read)
1947 call get_param(pf, mdl,
"Z_INIT_ALE_REMAPPING", usealeremapping, &
1948 "If True, then remap straight to model coordinate from file.",&
1949 default=.false., do_not_log=just_read)
1950 call get_param(pf, mdl,
"Z_INIT_REMAPPING_SCHEME", remappingscheme, &
1951 "The remapping scheme to use if using Z_INIT_ALE_REMAPPING\n"//&
1952 "is True.", default=
"PPM_IH4", do_not_log=just_read)
1953 call get_param(pf, mdl,
"Z_INIT_REMAP_GENERAL", remap_general, &
1954 "If false, only initializes to z* coordinates.\n"//&
1955 "If true, allows initialization directly to general coordinates.",&
1956 default=.false., do_not_log=just_read)
1957 call get_param(pf, mdl,
"Z_INIT_REMAP_FULL_COLUMN", remap_full_column, &
1958 "If false, only reconstructs profiles for valid data points.\n"//&
1959 "If true, inserts vanished layers below the valid data.",&
1960 default=remap_general, do_not_log=just_read)
1961 call get_param(pf, mdl,
"Z_INIT_REMAP_OLD_ALG", remap_old_alg, &
1962 "If false, uses the preferred remapping algorithm for initialization.\n"//&
1963 "If true, use an older, less robust algorithm for remapping.",&
1964 default=.true., do_not_log=just_read)
1965 call get_param(pf, mdl,
"ICE_SHELF", use_ice_shelf, default=.false.)
1966 if (use_ice_shelf)
then 1967 call get_param(pf, mdl,
"ICE_THICKNESS_FILE", ice_shelf_file, &
1968 "The file from which the ice bathymetry and area are read.", &
1969 fail_if_missing=.not.just_read, do_not_log=just_read)
1970 shelf_file = trim(inputdir)//trim(ice_shelf_file)
1971 if (.not.just_read)
call log_param(pf, mdl,
"INPUTDIR/THICKNESS_FILE", shelf_file)
1972 call get_param(pf, mdl,
"ICE_AREA_VARNAME", area_varname, &
1973 "The name of the area variable in ICE_THICKNESS_FILE.", &
1974 fail_if_missing=.not.just_read, do_not_log=just_read)
1976 if (.not.usealeremapping)
then 1977 call get_param(pf, mdl,
"ADJUST_THICKNESS", correct_thickness, &
1978 "If true, all mass below the bottom removed if the \n"//&
1979 "topography is shallower than the thickness input file \n"//&
1980 "would indicate.", default=.false., do_not_log=just_read)
1982 call get_param(pf, mdl,
"FIT_TO_TARGET_DENSITY_IC", adjust_temperature, &
1983 "If true, all the interior layers are adjusted to \n"//&
1984 "their target densities using mostly temperature \n"//&
1985 "This approach can be problematic, particularly in the \n"//&
1986 "high latitudes.", default=.true., do_not_log=just_read)
1989 call cpu_clock_end(id_clock_routine)
2008 call horiz_interp_and_extrap_tracer(filename, potemp_var,1.0,1, &
2009 g, temp_z, mask_z, z_in, z_edges_in, missing_value_temp, reentrant_x, tripolar_n, homogenize)
2011 call horiz_interp_and_extrap_tracer(filename, salin_var,1.0,1, &
2012 g, salt_z, mask_z, z_in, z_edges_in, missing_value_salt, reentrant_x, tripolar_n, homogenize)
2016 allocate(rho_z(isd:ied,jsd:jed,kd))
2017 allocate(area_shelf_h(isd:ied,jsd:jed))
2018 allocate(frac_shelf_h(isd:ied,jsd:jed))
2027 call calculate_density(temp_z(:,j,k),salt_z(:,j,k), press, rho_z(:,j,k), is, ie, eos)
2037 if (use_ice_shelf)
then 2038 if (.not.
file_exists(shelf_file, g%Domain))
call mom_error(fatal, &
2039 "MOM_temp_salt_initialize_from_Z: Unable to open shelf file "//trim(shelf_file))
2041 call read_data(shelf_file,trim(area_varname),area_shelf_h,domain=g%Domain%mpp_domain)
2044 frac_shelf_h(:,:) = 0.0
2046 do j=jsd,jed ;
do i=isd,ied
2047 if (g%areaT(i,j) > 0.0) &
2048 frac_shelf_h(i,j) = area_shelf_h(i,j) / g%areaT(i,j)
2051 shelf_area => frac_shelf_h
2057 if (usealeremapping)
then 2058 call cpu_clock_begin(id_clock_ale)
2062 if (kd>nz)
call mom_error(fatal,
"MOM_initialize_state, MOM_temp_salt_initialize_from_Z(): "//&
2063 "Data has more levels than the model - this has not been coded yet!")
2065 allocate( tmp_mask_in(isd:ied,jsd:jed,nz) ) ; tmp_mask_in(:,:,:) = 0.
2066 allocate( h1(isd:ied,jsd:jed,nz) ) ; h1(:,:,:) = 0.
2067 allocate( tmpt1din(isd:ied,jsd:jed,nz) ) ; tmpt1din(:,:,:) = 0.
2068 allocate( tmps1din(isd:ied,jsd:jed,nz) ) ; tmps1din(:,:,:) = 0.
2069 do j = js, je ;
do i = is, ie
2070 if (g%mask2dT(i,j)>0.)
then 2071 ztopofcell = 0. ; zbottomofcell = 0. ; npoints = 0
2072 tmp_mask_in(i,j,1:kd) = mask_z(i,j,:)
2074 if (tmp_mask_in(i,j,k)>0. .and. k<=kd)
then 2075 zbottomofcell = -min( z_edges_in(k+1), g%bathyT(i,j) )
2076 tmpt1din(i,j,k) = temp_z(i,j,k)
2077 tmps1din(i,j,k) = salt_z(i,j,k)
2079 zbottomofcell = -g%bathyT(i,j)
2080 tmpt1din(i,j,k) = tmpt1din(i,j,k-1)
2081 tmps1din(i,j,k) = tmps1din(i,j,k-1)
2083 tmpt1din(i,j,k) = -99.9
2084 tmps1din(i,j,k) = -99.9
2086 h1(i,j,k) = ztopofcell - zbottomofcell
2087 if (h1(i,j,k)>0.) npoints = npoints + 1
2088 ztopofcell = zbottomofcell
2090 h1(i,j,kd) = h1(i,j,kd) + ( ztopofcell + g%bathyT(i,j) )
2093 deallocate( tmp_mask_in )
2100 call ale_initregridding( gv, g%max_depth, pf, mdl, regridcs )
2102 if (.not. remap_general)
then 2104 allocate( htarget(nz) )
2106 do j = js, je ;
do i = is, ie
2108 if (g%mask2dT(i,j)>0.)
then 2110 ztopofcell = 0. ; zbottomofcell = 0.
2112 zbottomofcell = max( ztopofcell - htarget(k), -g%bathyT(i,j) )
2113 h(i,j,k) = ztopofcell - zbottomofcell
2114 ztopofcell = zbottomofcell
2121 deallocate( htarget )
2125 call initialize_remapping( remapcs, remappingscheme, boundary_extrapolation=.false. )
2126 if (remap_general)
then 2128 h(:,:,:) = h1(:,:,:) ; tv%T(:,:,:) = tmpt1din(:,:,:) ; tv%S(:,:,:) = tmps1din(:,:,:)
2129 do j = js, je ;
do i = is, ie
2130 if (g%mask2dT(i,j)==0.)
then 2131 h(i,j,:) = 0. ; tv%T(i,j,:) = 0. ; tv%S(i,j,:) = 0.
2138 if (use_ice_shelf)
then 2139 call ale_build_grid( g, gv, regridcs, remapcs, h, tv, .true., shelf_area)
2144 call ale_remap_scalar( remapcs, g, gv, nz, h1, tmpt1din, h, tv%T, all_cells=remap_full_column, old_remap=remap_old_alg )
2145 call ale_remap_scalar( remapcs, g, gv, nz, h1, tmps1din, h, tv%S, all_cells=remap_full_column, old_remap=remap_old_alg )
2147 deallocate( tmpt1din )
2148 deallocate( tmps1din )
2150 call cpu_clock_end(id_clock_ale)
2156 nlevs = sum(mask_z,dim=3)
2160 do k=2,nz ; rb(k)=0.5*(gv%Rlay(k-1)+gv%Rlay(k)) ;
enddo 2161 rb(1) = 0.0 ; rb(nz+1) = 2.0*gv%Rlay(nz) - gv%Rlay(nz-1)
2163 zi(is:ie,js:je,:) = find_interfaces(rho_z(is:ie,js:je,:), z_in, rb, g%bathyT(is:ie,js:je), &
2164 nlevs(is:ie,js:je), nkml, nkbl, min_depth)
2166 if (correct_thickness)
then 2169 do k=nz,1,-1 ;
do j=js,je ;
do i=is,ie
2170 if (zi(i,j,k) < (zi(i,j,k+1) + gv%Angstrom_z))
then 2171 zi(i,j,k) = zi(i,j,k+1) + gv%Angstrom_z
2172 h(i,j,k) = gv%Angstrom_z
2174 h(i,j,k) = zi(i,j,k) - zi(i,j,k+1)
2176 enddo ;
enddo ;
enddo 2178 do j=js,je ;
do i=is,ie
2179 if (abs(zi(i,j,nz+1) + g%bathyT(i,j)) > 1.0) &
2180 inconsistent = inconsistent + 1
2182 call sum_across_pes(inconsistent)
2184 if ((inconsistent > 0) .and. (is_root_pe()))
then 2185 write(mesg,
'("Thickness initial conditions are inconsistent ",'// &
2186 '"with topography in ",I5," places.")') inconsistent
2187 call mom_error(warning, mesg)
2191 tv%T(is:ie,js:je,:) = tracer_z_init(temp_z(is:ie,js:je,:),-1.0*z_edges_in,zi(is:ie,js:je,:), &
2192 nkml,nkbl,missing_value,g%mask2dT(is:ie,js:je),nz, &
2193 nlevs(is:ie,js:je),dbg,idbg,jdbg)
2194 tv%S(is:ie,js:je,:) = tracer_z_init(salt_z(is:ie,js:je,:),-1.0*z_edges_in,zi(is:ie,js:je,:), &
2195 nkml,nkbl,missing_value,g%mask2dT(is:ie,js:je),nz, &
2199 npoints = 0 ; tempavg = 0. ; saltavg = 0.
2200 do j=js,je ;
do i=is,ie ;
if (g%mask2dT(i,j) >= 1.0)
then 2201 npoints = npoints + 1
2202 tempavg = tempavg + tv%T(i,j,k)
2203 saltavg =saltavg + tv%S(i,j,k)
2204 endif ;
enddo ;
enddo 2207 if (homogenize)
then 2208 call sum_across_pes(npoints)
2209 call sum_across_pes(tempavg)
2210 call sum_across_pes(saltavg)
2212 tempavg = tempavg/
real(npoints)
2213 saltavg = saltavg/
real(npoints)
2215 tv%T(:,:,k) = tempavg
2216 tv%S(:,:,k) = saltavg
2223 do k=1,nz ;
do j=js,je ;
do i=is,ie
2224 if (tv%T(i,j,k) == missing_value)
then 2225 tv%T(i,j,k)=temp_land_fill
2226 tv%S(i,j,k)=salt_land_fill
2228 enddo ;
enddo ;
enddo 2231 ks=max(0,nkml)+max(0,nkbl)+1
2233 if (adjust_temperature .and. .not. usealeremapping)
then 2235 gv%Rlay(1:nz), tv%p_ref, niter, missing_value, h(is:ie,js:je,:), ks, eos)
2239 deallocate(z_in,z_edges_in,temp_z,salt_z,mask_z)
2246 call cpu_clock_end(id_clock_routine)
2256 integer,
parameter :: nk=5
2257 real,
dimension(nk) :: T, T_t, T_b, S, S_t, S_b, rho, h, z
2258 real,
dimension(nk+1) :: e
2260 real :: P_tot, P_t, P_b, z_out
2268 e(k+1) = e(k) - h(k)
2272 z(k) = 0.5 * ( e(k) + e(k+1) )
2273 t_t(k) = 20.+(0./500.)*e(k)
2274 t(k) = 20.+(0./500.)*z(k)
2275 t_b(k) = 20.+(0./500.)*e(k+1)
2276 s_t(k) = 35.-(0./500.)*e(k)
2277 s(k) = 35.+(0./500.)*z(k)
2278 s_b(k) = 35.-(0./500.)*e(k+1)
2279 call calculate_density(0.5*(t_t(k)+t_b(k)), 0.5*(s_t(k)+s_b(k)), -gv%Rho0*gv%g_Earth*z(k), rho(k), tv%eqn_of_state)
2280 p_tot = p_tot + gv%g_Earth * rho(k) * h(k)
2285 call find_depth_of_pressure_in_cell(t_t(k), t_b(k), s_t(k), s_b(k), e(k), e(k+1), &
2286 p_t, 0.5*p_tot, gv%Rho0, gv%g_Earth, tv%eqn_of_state, p_b, z_out)
2287 write(0,*) k,p_t,p_b,0.5*p_tot,e(k),e(k+1),z_out
2290 write(0,*) p_b,p_tot
2293 write(0,*)
' ==================================================================== ' 2297 t, t_t, t_b, s, s_t, s_b, 0.5*p_tot, h, remap_cs)
The module configures the model for the "external_gwave" experiment. external_gwave = External Gravit...
subroutine, public read_axis_data(filename, axis_name, var)
subroutine, public user_initialize_sponges(G, use_temperature, tv, param_file, CSp, h)
Set up the sponges.
subroutine adjustetatofitbathymetry(G, GV, eta, h)
Adjust interface heights to fit the bathymetry and diagnose layer thickness. If the bottom most inter...
subroutine set_velocity_depth_min(G)
subroutine, public soliton_initialize_thickness(h, G)
Initialization of thicknesses in Equatorial Rossby soliton test.
real function, dimension(size(tr_in, 1), size(tr_in, 2), nlay), public tracer_z_init(tr_in, z_edges, e, nkml, nkbl, land_fill, wet, nlay, nlevs, debug, i_debug, j_debug)
subroutine mom_state_init_tests(G, GV, tv)
Run simple unit tests.
subroutine, public circle_obcs_initialize_thickness(h, G, GV, param_file, just_read_params)
This subroutine initializes layer thicknesses for the circle_obcs experiment.
subroutine initialize_temp_salt_from_file(T, S, G, param_file, just_read_params)
subroutine depress_surface(h, G, GV, param_file, tv, just_read_params)
This module contains the main regridding routines. Regridding comprises two steps: (1) Interpolation ...
logical function, public ispointincell(G, i, j, x, y)
Returns true if the coordinates (x,y) are within the h-cell (i,j)
subroutine, public benchmark_init_temperature_salinity(T, S, G, GV, param_file, eqn_of_state, P_Ref, just_read_params)
This function puts the initial layer temperatures and salinities into T(:,:,:) and S(:...
subroutine initialize_temp_salt_fit(T, S, G, GV, param_file, eqn_of_state, P_Ref, just_read_params)
subroutine, public isomip_initialize_temperature_salinity(T, S, h, G, GV, param_file, eqn_of_state, just_read_params)
Initial values for temperature and salinity.
subroutine, public isomip_initialize_thickness(h, G, GV, param_file, tv, just_read_params)
Initialization of thicknesses.
subroutine, public scm_cvmix_tests_ts_init(T, S, h, G, GV, param_file, just_read_params)
Initializes temperature and salinity for the SCM CVmix test example.
subroutine, public int_specific_vol_dp(T, S, p_t, p_b, alpha_ref, HI, EOS, dza, intp_dza, intx_dza, inty_dza, halo_size)
Calls the appropriate subroutine to alculate analytical and nearly-analytical integrals in pressure a...
subroutine, public initialize_masks(G, PF)
initialize_masks initializes the grid masks and any metrics that come with masks already applied...
subroutine, public ale_build_grid(G, GV, regridCS, remapCS, h, tv, debug, frac_shelf_h)
Generates new grid.
subroutine initialize_velocity_zero(u, v, G, param_file, just_read_params)
integer, parameter, public to_all
The module calculates interface heights, including free surface height.
Ocean grid type. See mom_grid for details.
subroutine, public user_init_temperature_salinity(T, S, G, param_file, eqn_of_state, just_read_params)
This function puts the initial layer temperatures and salinities into T(:,:,:) and S(:...
Calculates density of sea water from T, S and P.
subroutine initialize_thickness_uniform(h, G, GV, param_file, just_read_params)
Provides the ocean grid type.
real function, dimension(cs%nk), public getcoordinateresolution(CS)
subroutine trim_for_ice(PF, G, GV, ALE_CSp, tv, h, just_read_params)
Adjust the layer thicknesses by cutting away the top of each model column at the depth where the hydr...
Generates vertical grids as part of the ALE algorithm.
Provides column-wise vertical remapping functions.
subroutine, public mom_initialize_state(u, v, h, tv, Time, G, GV, PF, dirs, restart_CS, ALE_CSp, tracer_Reg, sponge_CSp, ALE_sponge_CSp, OBC, Time_in)
subroutine, public ale_initthicknesstocoord(CS, G, GV, h)
Set h to coordinate values for fixed coordinate systems.
By Robert Hallberg, April 1994 - June 2002 *This subroutine initializes the fields for the simulation...
subroutine initialize_temp_salt_from_profile(T, S, G, param_file, just_read_params)
subroutine, public calltree_leave(mesg)
Writes a message about leaving a subroutine if call tree reporting is active.
The module configures the model for the geostrophic adjustment test case.
The module configures the ISOMIP test case.
subroutine convert_thickness(h, G, GV, tv)
real function my_psi(ig, jg)
This module contains I/O framework code.
subroutine, public ale_regrid_accelerated(CS, G, GV, h_orig, tv, n, h_new, u, v)
For a state-based coordinate, accelerate the process of regridding by repeatedly applying the grid ca...
subroutine initialize_velocity_uniform(u, v, G, param_file, just_read_params)
subroutine, public find_depth_of_pressure_in_cell(T_t, T_b, S_t, S_b, z_t, z_b, P_t, P_tgt, rho_ref, G_e, EOS, P_b, z_out)
Find the depth at which the reconstructed pressure matches P_tgt.
logical function, public open_boundary_query(OBC, apply_open_OBC, apply_specified_OBC, apply_Flather_OBC, apply_nudged_OBC, needs_ext_seg_data)
Initial conditions for the 2D Rossby front test.
subroutine, public set_up_ale_sponge_field(sp_val, G, f_ptr, CS)
This subroutine stores the reference profile at h points for the variable.
This module contains the routines used to apply sponge layers when using the ALE mode. Applying sponges requires the following: (1) initialize_ALE_sponge (2) set_up_ALE_sponge_field (tracers) and set_up_ALE_sponge_vel_field (vel) (3) apply_ALE_sponge (4) init_ALE_sponge_diags (not being used for now) (5) ALE_sponge_end (not being used for now)
subroutine, public adjustment_initialize_temperature_salinity(T, S, h, G, param_file, eqn_of_state, just_read_params)
Initialization of temperature and salinity.
SPONGE control structure.
By Robert Hallberg, April 1994 - June 2002 *This subroutine initializes the fields for the simulation...
subroutine, public setverticalgridaxes(Rlay, GV)
This sets the coordinate data for the "layer mode" of the isopycnal model.
Initial conditions for the Equatorial Rossby soliton test (Boyd).
subroutine, public phillips_initialize_sponges(G, use_temperature, tv, param_file, CSp, h)
Sets up the the inverse restoration time (Idamp), and.
subroutine, public dome_initialize_thickness(h, G, GV, param_file, just_read_params)
This subroutine initializes layer thicknesses for the DOME experiment.
Container for remapping parameters.
integer, parameter, public obc_simple
subroutine, public phillips_initialize_velocity(u, v, G, GV, param_file, just_read_params)
Initialize velocity fields.
character(len=len(input_string)) function, public lowercase(input_string)
subroutine, public dome2d_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialize thicknesses according to coordinate mode.
subroutine cut_off_column_top(nk, tv, Rho0, G_earth, depth, min_thickness, T, T_t, T_b, S, S_t, S_b, p_surf, h, remap_CS)
Adjust the layer thicknesses by cutting away the top at the depth where the hydrostatic pressure matc...
subroutine, public phillips_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialize thickness field.
subroutine, public sloshing_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialization of thicknesses This routine is called when THICKNESS_CONFIG is set to 'sloshing'...
subroutine compute_global_grid_integrals(G)
subroutine, public convert_temp_salt_for_teos10(T, S, press, G, kd, mask_z, EOS)
Convert T&S to Absolute Salinity and Conservative Temperature if using TEOS10.
subroutine, public lock_exchange_initialize_thickness(h, G, GV, param_file, just_read_params)
This subroutine initializes layer thicknesses for the lock_exchange experiment.
subroutine, public calltree_waypoint(mesg, n)
Writes a message about reaching a milestone if call tree reporting is active.
subroutine set_velocity_depth_max(G)
This module contains the tracer_registry_type and the subroutines that handle registration of tracers...
subroutine, public rossby_front_initialize_velocity(u, v, h, G, GV, param_file, just_read_params)
Initialization of u and v in the Rossby front test.
subroutine, public calculate_density_derivs(T, S, pressure, drho_dT, drho_dS, start, npts, EOS)
Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.
character(len=len(input_string)) function, public uppercase(input_string)
Initial conditions for an idealized baroclinic zone.
Regridding control structure.
subroutine, public initialize_sponge(Iresttime, int_height, G, param_file, CS, Iresttime_i_mean, int_height_i_mean)
subroutine, public set_regrid_params(CS, boundary_extrapolation, min_thickness, old_grid_weight, interp_scheme, depth_of_time_filter_shallow, depth_of_time_filter_deep, compress_fraction, dz_min_surface, nz_fixed_surface, Rho_ML_avg_depth, nlay_ML_to_interior, fix_haloclines, halocline_filt_len, halocline_strat_tol, integrate_downward_for_e, adaptTimeRatio, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptAlpha, adaptDoMin)
Can be used to set any of the parameters for MOM_regridding.
subroutine, public sloshing_initialize_temperature_salinity(T, S, h, G, param_file, eqn_of_state, just_read_params)
Initialization of temperature and salinity.
subroutine, public set_up_sponge_field(sp_val, f_ptr, G, nlay, CS, sp_val_i_mean)
Type to carry basic tracer information.
subroutine, public scm_idealized_hurricane_ts_init(T, S, h, G, GV, param_file, just_read_params)
Initializes temperature and salinity for the SCM idealized hurricane example.
subroutine, public user_set_obc_data(OBC, tv, G, param_file, tr_Reg)
This subroutine sets the properties of flow at open boundary conditions.
subroutine, public seamount_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialization of thicknesses. This subroutine initializes the layer thicknesses to be uniform...
subroutine, public open_boundary_init(G, param_file, OBC)
Initialize open boundary control structure.
logical function, public is_root_pe()
subroutine, public dense_water_initialize_ts(G, GV, param_file, eqn_of_state, T, S, h, just_read_params)
Initialize the temperature and salinity for the dense water experiment.
subroutine, public set_grid_metrics(G, param_file)
set_grid_metrics is used to set the primary values in the model's horizontal grid. The bathymetry, land-sea mask and any restricted channel widths are not known yet, so these are set later.
subroutine, public dome2d_initialize_sponges(G, GV, tv, param_file, use_ALE, CSp, ACSp)
Set up sponges in 2d DOME configuration.
subroutine, public add_tracer_obc_values(name, Reg, OBC_inflow, OBC_in_u, OBC_in_v)
This subroutine adds open boundary condition concentrations for a tracer that has previously been reg...
subroutine, public rossby_front_initialize_temperature_salinity(T, S, h, G, param_file, eqn_of_state, just_read_params)
Initialization of temperature and salinity in the Rossby front test.
subroutine initialize_thickness_from_file(h, G, GV, param_file, file_has_thickness, just_read_params)
This subroutine reads the layer thicknesses or interface heights from a file.
The module configures the model for the "lock_exchange" experiment. lock_exchange = A 2-d density dri...
subroutine, public rossby_front_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialization of thicknesses in 2D Rossby front test.
subroutine, public soliton_initialize_velocity(u, v, h, G)
Initialization of u and v in the equatorial Rossby soliton test.
subroutine, public baroclinic_zone_init_temperature_salinity(T, S, h, G, param_file, just_read_params)
Initialization of temperature and salinity with the baroclinic zone initial conditions.
The module configures the model for the "circle_obcs" experiment. circle_obcs = Test of Open Boundary...
The module configures the model for the non-rotating sloshing test case.
subroutine, public dome_initialize_sponges(G, GV, tv, PF, CSp)
This subroutine sets the inverse restoration time (Idamp), and ! the values towards which the interfa...
subroutine initialize_velocity_circular(u, v, G, param_file, just_read_params)
subroutine, public initialize_ale_sponge(Iresttime, data_h, nz_data, G, param_file, CS)
This subroutine determines the number of points which are within.
subroutine, public mom_mesg(message, verb, all_print)
Provides subroutines for quantities specific to the equation of state.
Type for describing a variable, typically a tracer.
subroutine, public user_initialize_thickness(h, G, param_file, T, just_read_params)
initialize thicknesses.
subroutine, public isomip_initialize_sponges(G, GV, tv, PF, use_ALE, CSp, ACSp)
Sets up the the inverse restoration time (Idamp), and.
subroutine, public remapping_core_h(CS, n0, h0, u0, n1, h1, u1)
Remaps column of values u0 on grid h0 to grid h1 assuming the top edge is aligned.
subroutine, public ale_initregridding(GV, max_depth, param_file, mdl, regridCS)
Initializes regridding for the main ALE algorithm.
Initialize state variables, u, v, h, T and S.
subroutine, public supercritical_set_obc_data(OBC, G, param_file)
This subroutine sets the properties of flow at open boundary conditions.
subroutine initialize_thickness_search
subroutine mom_temp_salt_initialize_from_z(h, tv, G, GV, PF, just_read_params)
This subroutine determines the isopycnal or other coordinate interfaces and layer potential temperatu...
subroutine initialize_sponges_file(G, GV, use_temperature, tv, param_file, CSp)
This subroutine sets the inverse restoration time (Idamp), and the values towards which the interface...
The thermo_var_ptrs structure contains pointers to an assortment of thermodynamic fields that may be ...
subroutine, public external_gwave_initialize_thickness(h, G, param_file, just_read_params)
This subroutine initializes layer thicknesses for the external_gwave experiment.
real function, dimension(size(rho, 1), size(rho, 2), size(rb, 1)), public find_interfaces(rho, zin, Rb, depth, nlevs, nkml, nkbl, hml, debug)
Initial conditions and forcing for the single column model (SCM) CVmix test set.
Initialization routines for the dense water formation and overflow experiment.
integer, parameter, public obc_none
subroutine, public pressure_gradient_plm(CS, S_t, S_b, T_t, T_b, G, GV, tv, h)
Use plm reconstruction for pressure gradient (determine edge values) By using a PLM (limited piecewis...
Controls where open boundary conditions are applied.
subroutine, public dome2d_initialize_temperature_salinity(T, S, h, G, param_file, eqn_of_state, just_read_params)
Initialize temperature and salinity in the 2d DOME configuration.
subroutine, public benchmark_initialize_thickness(h, G, GV, param_file, eqn_of_state, P_ref, just_read_params)
This subroutine initializes layer thicknesses for the benchmark test case, by finding the depths of i...
subroutine, public initialize_remapping(CS, remapping_scheme, boundary_extrapolation, check_reconstruction, check_remapping, force_bounds_in_subcell)
Constructor for remapping control structure.
subroutine, public adjustment_initialize_thickness(h, G, GV, param_file, just_read_params)
Initialization of thicknesses. This subroutine initializes the layer thicknesses to be uniform...
subroutine, public set_up_sponge_ml_density(sp_val, G, CS, sp_val_i_mean)
subroutine, public dome_set_obc_data(OBC, tv, G, GV, param_file, tr_Reg)
This subroutine sets the properties of flow at open boundary conditions. This particular example is f...
The module configures the model for the "DOME" experiment. DOME = Dynamics of Overflows and Mixing Ex...
subroutine, public set_tracer_data(OBC, tv, h, G, PF, tracer_Reg)
Sets the initial values of the tracer and h open boundary conditions. Also allocates and fills the se...
subroutine, public ale_remap_scalar(CS, G, GV, nk_src, h_src, s_src, h_dst, s_dst, all_cells, old_remap)
Remaps a single scalar between grids described by thicknesses h_src and h_dst. h_dst must be dimensio...
subroutine, public dense_water_initialize_sponges(G, GV, tv, param_file, use_ALE, CSp, ACSp)
Initialize the restoring sponges for the dense water experiment.
subroutine initialize_velocity_from_file(u, v, G, param_file, just_read_params)
subroutine, public determine_temperature(temp, salt, R, p_ref, niter, land_fill, h, k_start, eos)
subroutine, public mom_error(level, message, all_print)
Initial conditions and forcing for the single column model (SCM) idealized hurricane example...
subroutine, public seamount_initialize_temperature_salinity(T, S, h, G, GV, param_file, eqn_of_state, just_read_params)
Initial values for temperature and salinity.
subroutine initialize_temp_salt_linear(T, S, G, param_file, just_read_params)
The module configures the model for the idealized seamount test case.
subroutine, public restore_state(filename, directory, day, G, CS)
subroutine, public bfb_initialize_sponges_southonly(G, use_temperature, tv, param_file, CSp, h)
subroutine, public user_initialize_velocity(u, v, G, param_file, just_read_params)
initialize velocities.
The module configures the model for the "supercritical" experiment. https://marine.rutgers.edu/po/index.php?model=test-problems&title=supercritical.
A control structure for the equation of state.
subroutine, public calltree_enter(mesg, n)
Writes a message about entering a subroutine if call tree reporting is active.