35 implicit none ;
private 37 #include <MOM_memory.h> 47 real,
dimension(:),
allocatable :: coordinateresolution
54 real,
dimension(:),
allocatable :: target_density
55 logical :: target_density_set = .false.
59 real,
dimension(:),
allocatable :: max_interface_depths
63 real,
dimension(:),
allocatable :: max_layer_thickness
69 integer :: regridding_scheme
78 real :: ref_pressure = 2.e7
84 real :: old_grid_weight = 0.
87 real :: depth_of_time_filter_shallow = 0.
90 real :: depth_of_time_filter_deep = 0.
94 real :: compressibility_fraction = 0.
98 logical :: set_maximum_depths = .false.
102 real :: max_depth_index_scale = 2.0
106 logical :: integrate_downward_for_e = .true.
123 public build_rho_column
128 public default_coordinate_mode
133 " LAYER - Isopycnal or stacked shallow water layers\n"//&
134 " ZSTAR, Z* - stetched geopotential z*\n"//&
135 " SIGMA_SHELF_ZSTAR - stetched geopotential z* ignoring shelf\n"//&
136 " SIGMA - terrain following coordinates\n"//&
137 " RHO - continuous isopycnal\n"//&
138 " HYCOM1 - HyCOM-like hybrid coordinate\n"//&
139 " SLIGHT - stretched coordinates above continuous isopycnal\n"//&
140 " ADAPTIVE - optimize for smooth neutral density surfaces" 144 " P1M_H2 (2nd-order accurate)\n"//&
145 " P1M_H4 (2nd-order accurate)\n"//&
146 " P1M_IH4 (2nd-order accurate)\n"//&
147 " PLM (2nd-order accurate)\n"//&
148 " PPM_H4 (3rd-order accurate)\n"//&
149 " PPM_IH4 (3rd-order accurate)\n"//&
150 " P3M_IH4IH3 (4th-order accurate)\n"//&
151 " P3M_IH6IH5 (4th-order accurate)\n"//&
152 " PQM_IH4IH3 (4th-order accurate)\n"//&
153 " PQM_IH6IH5 (5th-order accurate)" 158 #undef __DO_SAFETY_CHECKS__ 163 subroutine initialize_regridding(CS, GV, max_depth, param_file, mod, coord_mode, param_prefix, param_suffix)
166 real,
intent(in) :: max_depth
168 character(len=*),
intent(in) :: mod
169 character(len=*),
intent(in) :: coord_mode
170 character(len=*),
intent(in) :: param_prefix
172 character(len=*),
intent(in) :: param_suffix
175 character(len=80) :: string, string2, varName
176 character(len=40) :: coord_units, param_name, coord_res_param
177 character(len=200) :: inputdir, fileName
178 character(len=320) :: message
179 character(len=12) :: expected_units
180 logical :: tmpLogical, fix_haloclines, set_max, do_sum, main_parameters
181 logical :: coord_is_state_dependent, ierr
182 real :: filt_len, strat_tol, index_scale, tmpReal
183 real :: dz_fixed_sfc, Rho_avg_depth, nlay_sfc_int
184 real :: adaptTimeRatio, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptAlpha
185 integer :: nz_fixed_sfc, k, nzf(4)
186 real,
dimension(:),
allocatable :: dz
187 real,
dimension(:),
allocatable :: h_max
188 real,
dimension(:),
allocatable :: dz_max
189 real,
dimension(:),
allocatable :: z_max
190 real,
dimension(:),
allocatable :: rho_target
192 real,
dimension(40) :: woa09_dz = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., &
193 37.5, 50., 50., 75., 100., 100., 100., 100., &
194 100., 100., 100., 100., 100., 100., 100., 175., &
195 250., 375., 500., 500., 500., 500., 500., 500., &
196 500., 500., 500., 500., 500., 500., 500., 500. /)
198 call get_param(param_file, mod,
"INPUTDIR", inputdir, default=
".")
199 inputdir = slasher(inputdir)
201 main_parameters=.false.
202 if (len_trim(param_prefix)==0) main_parameters=.true.
203 if (main_parameters .and. len_trim(param_suffix)>0)
call mom_error(fatal,trim(mod)//
', initialize_regridding: '// &
204 'Suffix provided without prefix for parameter names!')
207 cs%regridding_scheme = coordinatemode(coord_mode)
210 if (main_parameters)
then 212 call get_param(param_file, mod,
"REGRIDDING_COORDINATE_UNITS", coord_units, &
213 "Units of the regridding coordinuate.",&
219 if (coord_is_state_dependent)
then 220 if (main_parameters)
then 221 param_name =
"INTERPOLATION_SCHEME" 224 param_name = trim(param_prefix)//
"_INTERP_SCHEME_"//trim(param_suffix)
227 call get_param(param_file, mod,
"INTERPOLATION_SCHEME", string, &
228 "This sets the interpolation scheme to use to\n"//&
229 "determine the new grid. These parameters are\n"//&
230 "only relevant when REGRIDDING_COORDINATE_MODE is\n"//&
231 "set to a function of state. Otherwise, it is not\n"//&
232 "used. It can be one of the following schemes:\n"//&
237 if (main_parameters .and. coord_is_state_dependent)
then 238 call get_param(param_file, mod,
"BOUNDARY_EXTRAPOLATION", tmplogical, &
239 "When defined, a proper high-order reconstruction\n"//&
240 "scheme is used within boundary cells rather\n"//&
241 "than PCM. E.g., if PPM is used for remapping, a\n"//&
242 "PPM reconstruction will also be used within\n"//&
250 if (main_parameters)
then 251 param_name =
"ALE_COORDINATE_CONFIG" 252 coord_res_param =
"ALE_RESOLUTION" 255 param_name = trim(param_prefix)//
"_DEF_"//trim(param_suffix)
256 coord_res_param = trim(param_prefix)//
"_RES_"//trim(param_suffix)
258 if (max_depth>3000.) string2=
'WOA09' 260 call get_param(param_file, mod, param_name, string, &
261 "Determines how to specify the coordinate\n"//&
262 "resolution. Valid options are:\n"//&
263 " PARAM - use the vector-parameter "//trim(coord_res_param)//
"\n"//&
264 " UNIFORM[:N] - uniformly distributed\n"//&
265 " FILE:string - read from a file. The string specifies\n"//&
266 " the filename and variable name, separated\n"//&
267 " by a comma or space, e.g. FILE:lev.nc,dz\n"//&
268 " or FILE:lev.nc,interfaces=zw\n"//&
269 " WOA09[:N] - the WOA09 vertical grid (approximately)\n"//&
270 " FNC1:string - FNC1:dz_min,H_total,power,precision\n"//&
271 " HYBRID:string - read from a file. The string specifies\n"//&
272 " the filename and two variable names, separated\n"//&
273 " by a comma or space, for sigma-2 and dz. e.g.\n"//&
274 " HYBRID:vgrid.nc,sigma2,dz",&
275 default=trim(string2))
276 message =
"The distribution of vertical resolution for the target\n"//&
277 "grid used for Eulerian-like coordinates. For example,\n"//&
278 "in z-coordinate mode, the parameter is a list of level\n"//&
279 "thicknesses (in m). In sigma-coordinate mode, the list\n"//&
280 "is of non-dimensional fractions of the water column." 281 if (index(trim(string),
'UNIFORM')==1)
then 282 if (len_trim(string)==7)
then 285 elseif (index(trim(string),
'UNIFORM:')==1 .and. len_trim(string)>8)
then 288 tmpreal =
extract_real(string(9:len_trim(string)),
',',2,missing_value=max_depth)
290 call mom_error(fatal,trim(mod)//
', initialize_regridding: '// &
291 'Unable to interpret "'//trim(string)//
'".')
298 gv%Rlay(1)+0.5*(gv%Rlay(1)-gv%Rlay(2)), &
299 gv%Rlay(ke)+0.5*(gv%Rlay(ke)-gv%Rlay(ke-1)) )
301 if (main_parameters)
call log_param(param_file, mod,
"!"//coord_res_param, dz, &
302 trim(message), units=trim(coord_units))
303 elseif (trim(string)==
'PARAM')
then 307 call get_param(param_file, mod, coord_res_param, dz, &
308 trim(message), units=trim(coord_units), fail_if_missing=.true.)
309 elseif (index(trim(string),
'FILE:')==1)
then 312 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then 314 filename = trim(
extractword(trim(string(6:80)), 1) )
317 filename = trim(inputdir) // trim(
extractword(trim(string(6:80)), 1) )
319 if (.not.
file_exists(filename))
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
320 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
323 if (len_trim(varname)==0)
then 324 if (field_exists(filename,
'dz')) then; varname =
'dz' 325 elseif (field_exists(filename,
'dsigma')) then; varname =
'dsigma' 326 elseif (field_exists(filename,
'ztest')) then; varname =
'ztest' 327 else ;
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
328 "Coordinate variable not specified and none could be guessed.")
334 if (cs%regridding_scheme == regridding_sigma)
then 335 expected_units =
'nondim' 336 elseif (cs%regridding_scheme == regridding_rho)
then 337 expected_units =
'kg m-3' 339 expected_units =
'meters' 341 if (index(trim(varname),
'interfaces=')==1)
then 342 varname=trim(varname(12:))
343 call check_grid_def(filename, varname, expected_units, message, ierr)
344 if (ierr)
call mom_error(fatal,trim(mod)//
", initialize_regridding: "//&
345 "Unsupported format in grid definition '"//trim(filename)//
"'. Error message "//trim(message))
346 call field_size(trim(filename), trim(varname), nzf)
348 if (cs%regridding_scheme == regridding_rho)
then 349 allocate(rho_target(ke+1))
350 call mom_read_data(trim(filename), trim(varname), rho_target)
353 allocate(z_max(ke+1))
355 dz(:) = abs(z_max(1:ke) - z_max(2:ke+1))
360 call field_size(trim(filename), trim(varname), nzf)
365 if (main_parameters .and. ke/=gv%ke)
then 366 call mom_error(fatal,trim(mod)//
', initialize_regridding: '// &
367 'Mismatch in number of model levels and "'//trim(string)//
'".')
369 if (main_parameters)
call log_param(param_file, mod,
"!"//coord_res_param, dz, &
371 elseif (index(trim(string),
'FNC1:')==1)
then 372 ke = gv%ke;
allocate(dz(ke))
374 if (main_parameters)
call log_param(param_file, mod,
"!"//coord_res_param, dz, &
376 elseif (index(trim(string),
'HYBRID:')==1)
then 377 ke = gv%ke;
allocate(dz(ke))
379 allocate(rho_target(ke+1))
380 filename = trim(
extractword(trim(string(8:)), 1) )
381 if (filename(1:1)/=
'.' .and. filename(1:1)/=
'/') filename = trim(inputdir) // trim( filename )
382 if (.not.
file_exists(filename))
call mom_error(fatal,trim(mod)//
", initialize_regridding: HYBRID "// &
383 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
385 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mod)//
", initialize_regridding: HYBRID "// &
386 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
387 call mom_read_data(trim(filename), trim(varname), rho_target)
389 if (varname(1:5) ==
'FNC1:')
then 390 call dz_function1( trim(string((index(trim(string),
'FNC1:')+5):)), dz )
392 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mod)//
", initialize_regridding: HYBRID "// &
393 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
396 if (main_parameters)
then 397 call log_param(param_file, mod,
"!"//coord_res_param, dz, &
399 call log_param(param_file, mod,
"!TARGET_DENSITIES", rho_target, &
400 'HYBRID target densities for itnerfaces', units=
coordinateunits(coord_mode))
402 elseif (index(trim(string),
'WOA09')==1)
then 403 if (len_trim(string)==5)
then 404 tmpreal = 0. ; ke = 0
405 do while (tmpreal<max_depth)
407 tmpreal = tmpreal + woa09_dz(ke)
409 elseif (index(trim(string),
'WOA09:')==1)
then 410 if (len_trim(string)==6)
call mom_error(fatal,trim(mod)//
', initialize_regridding: '// &
411 'Expected string of form "WOA09:N" but got "'//trim(string)//
'".')
414 if (ke>40 .or. ke<1)
call mom_error(fatal,trim(mod)//
', initialize_regridding: '// &
415 'For "WOA05:N" N must 0<N<41 but got "'//trim(string)//
'".')
417 dz(1:ke) = woa09_dz(1:ke)
419 call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
420 "Unrecognized coordinate configuraiton"//trim(string))
423 if (main_parameters)
then 425 if (coordinatemode(coord_mode) == regridding_zstar .or. &
430 tmpreal = sum( dz(:) )
431 if (tmpreal < max_depth)
then 432 dz(ke) = dz(ke) + ( max_depth - tmpreal )
433 elseif (tmpreal > max_depth)
then 434 if ( dz(ke) + ( max_depth - tmpreal ) > 0. )
then 435 dz(ke) = dz(ke) + ( max_depth - tmpreal )
437 call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
438 "MAXIMUM_DEPTH was too shallow to adjust bottom layer of DZ!"//trim(string))
447 allocate( cs%coordinateResolution(cs%nk) ); cs%coordinateResolution(:) = -1.e30
450 allocate( cs%target_density(cs%nk+1) ); cs%target_density(:) = -1.e30
455 if (
allocated(rho_target))
then 457 deallocate(rho_target)
460 elseif (coordinatemode(coord_mode) == regridding_rho)
then 462 call log_param(param_file, mod,
"!TARGET_DENSITIES", cs%target_density, &
463 'RHO target densities for interfaces', units=
coordinateunits(coord_mode))
469 if (main_parameters .and. coord_is_state_dependent)
then 470 call get_param(param_file, mod,
"REGRID_COMPRESSIBILITY_FRACTION", tmpreal, &
471 "When interpolating potential density profiles we can add\n"//&
472 "some artificial compressibility solely to make homogenous\n"//&
473 "regions appear stratified.", default=0.)
477 if (main_parameters)
then 478 call get_param(param_file, mod,
"MIN_THICKNESS", tmpreal, &
479 "When regridding, this is the minimum layer\n"//&
480 "thickness allowed.", units=
"m",&
489 call get_param(param_file, mod,
"SLIGHT_DZ_SURFACE", dz_fixed_sfc, &
490 "The nominal thickness of fixed thickness near-surface\n"//&
491 "layers with the SLight coordinate.", units=
"m", default=1.0)
492 call get_param(param_file, mod,
"SLIGHT_NZ_SURFACE_FIXED", nz_fixed_sfc, &
493 "The number of fixed-depth surface layers with the SLight\n"//&
494 "coordinate.", units=
"nondimensional", default=2)
495 call get_param(param_file, mod,
"SLIGHT_SURFACE_AVG_DEPTH", rho_avg_depth, &
496 "The thickness of the surface region over which to average\n"//&
497 "when calculating the density to use to define the interior\n"//&
498 "with the SLight coordinate.", units=
"m", default=1.0)
499 call get_param(param_file, mod,
"SLIGHT_NLAY_TO_INTERIOR", nlay_sfc_int, &
500 "The number of layers to offset the surface density when\n"//&
501 "defining where the interior ocean starts with SLight.", &
502 units=
"nondimensional", default=2.0)
503 call get_param(param_file, mod,
"SLIGHT_FIX_HALOCLINES", fix_haloclines, &
504 "If true, identify regions above the reference pressure\n"//&
505 "where the reference pressure systematically underestimates\n"//&
506 "the stratification and use this in the definition of the\n"//&
507 "interior with the SLight coordinate.", default=.false.)
510 nz_fixed_surface=nz_fixed_sfc, rho_ml_avg_depth=rho_avg_depth, &
511 nlay_ml_to_interior=nlay_sfc_int, fix_haloclines=fix_haloclines)
512 if (fix_haloclines)
then 514 call get_param(param_file, mod,
"HALOCLINE_FILTER_LENGTH", filt_len, &
515 "A length scale over which to smooth the temperature and\n"//&
516 "salinity before identifying erroneously unstable haloclines.", &
517 units=
"m", default=2.0)
518 call get_param(param_file, mod,
"HALOCLINE_STRAT_TOL", strat_tol, &
519 "A tolerance for the ratio of the stratification of the\n"//&
520 "apparent coordinate stratification to the actual value\n"//&
521 "that is used to identify erroneously unstable haloclines.\n"//&
522 "This ratio is 1 when they are equal, and sensible values \n"//&
523 "are between 0 and 0.5.", units=
"nondimensional", default=0.2)
525 halocline_strat_tol=strat_tol)
531 call get_param(param_file, mod,
"ADAPT_TIME_RATIO", adapttimeratio, &
532 "Ratio of ALE timestep to grid timescale.", units=
"s", default=1e-1)
533 call get_param(param_file, mod,
"ADAPT_ZOOM_DEPTH", adaptzoom, &
534 "Depth of near-surface zooming region.", units=
"m", default=200.0)
535 call get_param(param_file, mod,
"ADAPT_ZOOM_COEFF", adaptzoomcoeff, &
536 "Coefficient of near-surface zooming diffusivity.", &
537 units=
"nondim", default=0.2)
538 call get_param(param_file, mod,
"ADAPT_BUOY_COEFF", adaptbuoycoeff, &
539 "Coefficient of buoyancy diffusivity.", &
540 units=
"nondim", default=0.8)
541 call get_param(param_file, mod,
"ADAPT_ALPHA", adaptalpha, &
542 "Scaling on optimization tendency.", &
543 units=
"nondim", default=1.0)
544 call get_param(param_file, mod,
"ADAPT_DO_MIN_DEPTH", tmplogical, &
545 "If true, make a HyCOM-like mixed layer by preventing interfaces\n"//&
546 "from being shallower than the depths specified by the regridding coordinate.", &
550 adaptzoomcoeff=adaptzoomcoeff, adaptbuoycoeff=adaptbuoycoeff, adaptalpha=adaptalpha, &
551 adaptdomin=tmplogical)
554 if (main_parameters .and. coord_is_state_dependent)
then 555 call get_param(param_file, mod,
"MAXIMUM_INT_DEPTH_CONFIG", string, &
556 "Determines how to specify the maximum interface depths.\n"//&
557 "Valid options are:\n"//&
558 " NONE - there are no maximum interface depths\n"//&
559 " PARAM - use the vector-parameter MAXIMUM_INTERFACE_DEPTHS\n"//&
560 " FILE:string - read from a file. The string specifies\n"//&
561 " the filename and variable name, separated\n"//&
562 " by a comma or space, e.g. FILE:lev.nc,Z\n"//&
563 " FNC1:string - FNC1:dz_min,H_total,power,precision",&
565 message =
"The list of maximum depths for each interface." 566 allocate(z_max(ke+1))
568 if ( trim(string) ==
"NONE")
then 570 elseif ( trim(string) ==
"PARAM")
then 571 call get_param(param_file, mod,
"MAXIMUM_INTERFACE_DEPTHS", z_max, &
572 trim(message), units=
"m", fail_if_missing=.true.)
574 elseif (index(trim(string),
'FILE:')==1)
then 575 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then 577 filename = trim(
extractword(trim(string(6:80)), 1) )
580 filename = trim(inputdir) // trim(
extractword(trim(string(6:80)), 1) )
582 if (.not.
file_exists(filename))
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
583 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
587 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
588 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
589 if (len_trim(varname)==0)
then 590 if (field_exists(filename,
'z_max')) then; varname =
'z_max' 591 elseif (field_exists(filename,
'dz')) then; varname =
'dz' ; do_sum = .true.
592 elseif (field_exists(filename,
'dz_max')) then; varname =
'dz_max' ; do_sum = .true.
593 else ;
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
594 "MAXIMUM_INT_DEPTHS variable not specified and none could be guessed.")
599 z_max(1) = 0.0 ;
do k=1,ke ; z_max(k+1) = z_max(k) + dz_max(k) ;
enddo 603 call log_param(param_file, mod,
"!MAXIMUM_INT_DEPTHS", z_max, &
606 elseif (index(trim(string),
'FNC1:')==1)
then 609 (dz_fixed_sfc > 0.0))
then 610 do k=1,nz_fixed_sfc ; dz_max(k) = dz_fixed_sfc ;
enddo 612 z_max(1) = 0.0 ;
do k=1,ke ; z_max(k+1) = z_max(k) + dz_max(k) ;
enddo 613 call log_param(param_file, mod,
"!MAXIMUM_INT_DEPTHS", z_max, &
617 call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
618 "Unrecognized MAXIMUM_INT_DEPTH_CONFIG "//trim(string))
625 call get_param(param_file, mod,
"MAX_LAYER_THICKNESS_CONFIG", string, &
626 "Determines how to specify the maximum layer thicknesses.\n"//&
627 "Valid options are:\n"//&
628 " NONE - there are no maximum layer thicknesses\n"//&
629 " PARAM - use the vector-parameter MAX_LAYER_THICKNESS\n"//&
630 " FILE:string - read from a file. The string specifies\n"//&
631 " the filename and variable name, separated\n"//&
632 " by a comma or space, e.g. FILE:lev.nc,Z\n"//&
633 " FNC1:string - FNC1:dz_min,H_total,power,precision",&
635 message =
"The list of maximum thickness for each layer." 637 if ( trim(string) ==
"NONE")
then 639 elseif ( trim(string) ==
"PARAM")
then 640 call get_param(param_file, mod,
"MAX_LAYER_THICKNESS", h_max, &
641 trim(message), units=
"m", fail_if_missing=.true.)
643 elseif (index(trim(string),
'FILE:')==1)
then 644 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then 646 filename = trim(
extractword(trim(string(6:80)), 1) )
649 filename = trim(inputdir) // trim(
extractword(trim(string(6:80)), 1) )
651 if (.not.
file_exists(filename))
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
652 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
655 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
656 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
657 if (len_trim(varname)==0)
then 658 if (field_exists(filename,
'h_max')) then; varname =
'h_max' 659 elseif (field_exists(filename,
'dz_max')) then; varname =
'dz_max' 660 else ;
call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
661 "MAXIMUM_INT_DEPTHS variable not specified and none could be guessed.")
665 call log_param(param_file, mod,
"!MAX_LAYER_THICKNESS", h_max, &
668 elseif (index(trim(string),
'FNC1:')==1)
then 670 call log_param(param_file, mod,
"!MAX_LAYER_THICKNESS", h_max, &
674 call mom_error(fatal,trim(mod)//
", initialize_regridding: "// &
675 "Unrecognized MAX_LAYER_THICKNESS_CONFIG "//trim(string))
680 if (
allocated(dz))
deallocate(dz)
684 subroutine check_grid_def(filename, varname, expected_units, msg, ierr)
685 character(len=*),
intent(in) :: filename
686 character(len=*),
intent(in) :: varname
687 character(len=*),
intent(in) :: expected_units
688 character(len=*),
intent(inout) :: msg
689 logical,
intent(out) :: ierr
691 character (len=200) :: units, long_name
692 integer :: ncid, status, intid, vid
696 status = nf90_open(trim(filename), nf90_nowrite, ncid);
697 if (status /= nf90_noerr)
then 699 msg =
'File not found: '//trim(filename)
703 status = nf90_inq_varid(ncid, trim(varname), vid)
704 if (status /= nf90_noerr)
then 706 msg =
'Var not found: '//trim(varname)
710 status = nf90_get_att(ncid, vid,
"units", units)
711 if (status /= nf90_noerr)
then 713 msg =
'Attribute not found: units' 719 do i=1,len_trim(units)
720 if (units(i:i) == char(0)) units(i:i) =
" " 723 if (trim(units) /= trim(expected_units))
then 724 if (trim(expected_units) ==
"meters")
then 725 if (trim(units) /=
"m")
then 734 msg =
'Units incorrect: '//trim(units)//
' /= '//trim(expected_units)
745 if (
associated(cs%rho_CS))
call end_coord_rho(cs%rho_CS)
750 deallocate( cs%coordinateResolution )
751 if (
allocated(cs%target_density))
deallocate( cs%target_density )
752 if (
allocated(cs%max_interface_depths) )
deallocate( cs%max_interface_depths )
753 if (
allocated(cs%max_layer_thickness) )
deallocate( cs%max_layer_thickness )
760 subroutine regridding_main( remapCS, CS, G, GV, h, tv, h_new, dzInterface, frac_shelf_h, conv_adjust)
781 type(ocean_grid_type),
intent(in) :: G
783 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)),
intent(inout) :: h
785 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)),
intent(inout) :: h_new
786 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)+1),
intent(inout) :: dzInterface
787 real,
dimension(:,:),
optional,
pointer :: frac_shelf_h
788 logical,
optional,
intent(in ) :: conv_adjust
790 real :: trickGnuCompiler
791 logical :: use_ice_shelf
792 logical :: do_convective_adjustment
794 do_convective_adjustment = .true.
795 if (
present(conv_adjust)) do_convective_adjustment = conv_adjust
797 use_ice_shelf = .false.
798 if (
present(frac_shelf_h))
then 799 if (
associated(frac_shelf_h)) use_ice_shelf = .true.
802 select case ( cs%regridding_scheme )
804 case ( regridding_zstar )
805 if (use_ice_shelf)
then 812 case ( regridding_sigma_shelf_zstar)
816 case ( regridding_sigma )
820 case ( regridding_rho )
825 case ( regridding_arbitrary )
842 call mom_error(fatal,
'MOM_regridding, regridding_main: '//&
843 'Unknown regridding scheme selected!')
847 #ifdef __DO_SAFETY_CHECKS__ 855 type(ocean_grid_type),
intent(in) :: G
857 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
858 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: dzInterface
859 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(inout) :: h_new
864 do j = g%jsc-1,g%jec+1
865 do i = g%isc-1,g%iec+1
866 if (g%mask2dT(i,j)>0.)
then 868 h_new(i,j,k) = max( 0., h(i,j,k) + ( dzinterface(i,j,k) - dzinterface(i,j,k+1) ) )
871 h_new(i,j,:) = h(i,j,:)
880 type(ocean_grid_type),
intent(in) :: G
882 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
883 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(in) :: dzInterface
884 character(len=*),
intent(in) :: msg
889 do j = g%jsc-1,g%jec+1
890 do i = g%isc-1,g%iec+1
891 if (g%mask2dT(i,j)>0.)
call check_grid_column( gv%ke, g%bathyT(i,j), h(i,j,:), dzinterface(i,j,:), msg )
899 integer,
intent(in) :: nk
900 real,
intent(in) :: depth
901 real,
dimension(nk),
intent(in) :: h
902 real,
dimension(nk+1),
intent(in) :: dzInterface
903 character(len=*),
intent(in) :: msg
906 real :: eps, total_h_old, total_h_new, h_new, z_old, z_new
908 eps =1. ; eps = epsilon(eps)
913 total_h_old = total_h_old + h(k)
918 if (depth == 0.) z_old = - total_h_old
922 z_new = z_old + dzinterface(k)
923 h_new = h(k) + ( dzinterface(k) - dzinterface(k+1) )
925 write(0,*)
'k,h,hnew=',k,h(k),h_new
926 write(0,*)
'dzI(k+1),dzI(k)=',dzinterface(k+1),dzinterface(k)
927 call mom_error( fatal,
'MOM_regridding, check_grid_column: '//&
928 'Negative layer thickness implied by re-gridding, '//trim(msg))
930 total_h_new = total_h_new + h_new
935 if (abs(total_h_new-total_h_old)>
real(nk-1)*0.5*(total_h_old+total_h_new)*eps) then
938 write(0,*)
'k,h,hnew=',k,h(k),h(k)+(dzinterface(k)-dzinterface(k+1))
940 write(0,*)
'Hold,Hnew,Hnew-Hold=',total_h_old,total_h_new,total_h_new-total_h_old
941 write(0,*)
'eps,(n)/2*eps*H=',eps,
real(nk-1)*0.5*(total_h_old+total_h_new)*eps
942 call mom_error( fatal,
'MOM_regridding, check_grid_column: '//&
943 'Re-gridding did NOT conserve total thickness to within roundoff '//trim(msg))
947 if (dzinterface(1) /= 0.)
call mom_error( fatal, &
948 'MOM_regridding, check_grid_column: Non-zero dzInterface at surface! '//trim(msg))
949 if (dzinterface(nk+1) /= 0.)
call mom_error( fatal, &
950 'MOM_regridding, check_grid_column: Non-zero dzInterface at bottom! '//trim(msg))
961 integer,
intent(in) :: nk
962 real,
dimension(nk+1),
intent(in) :: z_old
963 real,
dimension(nk+1),
intent(in) :: z_new
964 real,
dimension(nk+1),
intent(inout) :: dz_g
968 real :: Aq, Bq, dz0, z0, F0
969 real :: zs, zd, dzwt, Idzwt
971 real :: Int_zs, Int_zd, dInt_zs_zd
973 real,
dimension(nk+1) :: z_act
975 logical :: debug = .false.
978 if ((z_old(nk+1) - z_old(1)) * (z_new(nk+1) - z_new(1)) < 0.0)
then 979 call mom_error(fatal,
"filtered_grid_motion: z_old and z_new use different sign conventions.")
980 elseif ((z_old(nk+1) - z_old(1)) * (z_new(nk+1) - z_new(1)) == 0.0)
then 982 do k=1,nk+1 ; dz_g(k) = 0.0 ;
enddo ;
return 983 elseif ((z_old(nk+1) - z_old(1)) + (z_new(nk+1) - z_new(1)) > 0.0)
then 991 if (sgn*(z_new(k)-z_new(k-1)) < -5e-16*(abs(z_new(k))+abs(z_new(k-1))) ) &
992 call mom_error(fatal,
"filtered_grid_motion: z_new is tangled.")
993 if (sgn*(z_old(k)-z_old(k-1)) < -5e-16*(abs(z_old(k))+abs(z_old(k-1))) ) &
994 call mom_error(fatal,
"filtered_grid_motion: z_old is tangled.")
999 zs = cs%depth_of_time_filter_shallow
1000 zd = cs%depth_of_time_filter_deep
1001 wtd = 1.0 - cs%old_grid_weight
1005 idzwt = 0.0 ;
if (abs(zd - zs) > 0.0) idzwt = 1.0 / (zd - zs)
1006 dint_zs_zd = 0.5*(1.0 + iwtd) * (zd - zs)
1007 aq = 0.5*(iwtd - 1.0)
1012 dz_tgt = sgn*(z_new(k) - z_old(k))
1013 zr1 = sgn*(z_old(k) - z_old(1))
1017 if ((zr1 > zd) .and. (zr1 + wtd * dz_tgt > zd))
then 1018 dz_g(k) = sgn * wtd * dz_tgt
1019 elseif ((zr1 < zs) .and. (zr1 + dz_tgt < zs))
then 1020 dz_g(k) = sgn * dz_tgt
1029 int_zd = iwtd*(zd - zr1)
1030 int_zs = int_zd - dint_zs_zd
1031 elseif (zr1 <= zs)
then 1033 int_zd = dint_zs_zd + (zs - zr1)
1036 int_zd = (zd - zr1) * (iwtd*(0.5*(zd+zr1) - zs) + 0.5*(zd - zr1)) * idzwt
1037 int_zs = (zs - zr1) * (0.5*iwtd * ((zr1 - zs)) + (zd - 0.5*(zr1+zs))) * idzwt
1041 if (dz_tgt >= int_zd)
then 1042 dz_g(k) = sgn * ((zd-zr1) + wtd*(dz_tgt - int_zd))
1043 elseif (dz_tgt <= int_zs)
then 1044 dz_g(k) = sgn * ((zs-zr1) + (dz_tgt - int_zs))
1050 if (zr1 <= zs)
then ; dz0 = zs-zr1 ; z0 = zs ; f0 = dz_tgt - int_zs
1051 elseif (zr1 >= zd)
then ; dz0 = zd-zr1 ; z0 = zd ; f0 = dz_tgt - int_zd
1052 else ; dz0 = 0.0 ; z0 = zr1 ; f0 = dz_tgt ;
endif 1054 bq = (dzwt + 2.0*aq*(z0-zs))
1057 dz_g(k) = sgn * (dz0 + 2.0*f0*dzwt / (bq + sqrt(bq**2 + 4.0*aq*f0*dzwt) ))
1077 do k=1,nk+1 ; z_act(k) = z_old(k) + dz_g(k) ;
enddo 1079 if (sgn*((z_act(k))-z_act(k-1)) < -1e-15*(abs(z_act(k))+abs(z_act(k-1))) ) &
1080 call mom_error(fatal,
"filtered_grid_motion: z_output is tangled.")
1093 type(ocean_grid_type),
intent(in) :: G
1095 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1096 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)+1),
intent(inout) :: dzInterface
1097 real,
dimension(:,:),
optional,
pointer :: frac_shelf_h
1101 real :: nominalDepth, totalThickness, dh
1102 real,
dimension(SZK_(GV)+1) :: zOld, zNew
1103 real :: minThickness
1104 logical :: ice_shelf
1107 minthickness = cs%min_thickness
1109 if (
present(frac_shelf_h))
then 1110 if (
associated(frac_shelf_h)) ice_shelf = .true.
1117 do j = g%jsc-1,g%jec+1
1118 do i = g%isc-1,g%iec+1
1120 if (g%mask2dT(i,j)==0.)
then 1121 dzinterface(i,j,:) = 0.
1126 nominaldepth = g%bathyT(i,j)*gv%m_to_H
1129 totalthickness = 0.0
1131 totalthickness = totalthickness + h(i,j,k)
1134 zold(nz+1) = - nominaldepth
1136 zold(k) = zold(k+1) + h(i,j,k)
1140 if (frac_shelf_h(i,j) > 0.)
then 1142 z_rigid_top = totalthickness-nominaldepth, &
1154 #ifdef __DO_SAFETY_CHECKS__ 1155 dh=max(nominaldepth,totalthickness)
1156 if (abs(znew(1)-zold(1))>(nz-1)*0.5*epsilon(dh)*dh)
then 1157 write(0,*)
'min_thickness=',minthickness
1158 write(0,*)
'nominalDepth=',nominaldepth,
'totalThickness=',totalthickness
1159 write(0,*)
'dzInterface(1) = ',dzinterface(i,j,1),epsilon(dh),nz
1161 write(0,*) k,zold(k),znew(k)
1164 write(0,*) k,h(i,j,k),znew(k)-znew(k+1),cs%coordinateResolution(k)
1167 'MOM_regridding, build_zstar_grid(): top surface has moved!!!' )
1191 type(ocean_grid_type),
intent(in) :: G
1193 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1194 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)+1),
intent(inout) :: dzInterface
1199 real :: nominalDepth, totalThickness, dh
1200 real,
dimension(SZK_(GV)+1) :: zOld, zNew
1204 do i = g%isc-1,g%iec+1
1205 do j = g%jsc-1,g%jec+1
1207 if (g%mask2dT(i,j)==0.)
then 1208 dzinterface(i,j,:) = 0.
1213 nominaldepth = g%bathyT(i,j)*gv%m_to_H
1216 totalthickness = 0.0
1218 totalthickness = totalthickness + h(i,j,k)
1224 zold(nz+1) = -nominaldepth
1226 zold(k) = zold(k+1) + h(i, j, k)
1231 #ifdef __DO_SAFETY_CHECKS__ 1232 dh=max(nominaldepth,totalthickness)
1233 if (abs(znew(1)-zold(1))>(nz-1)*0.5*epsilon(dh)*dh)
then 1234 write(0,*)
'min_thickness=',cs%min_thickness
1235 write(0,*)
'nominalDepth=',nominaldepth,
'totalThickness=',totalthickness
1236 write(0,*)
'dzInterface(1) = ',dzinterface(i,j,1),epsilon(dh),nz
1238 write(0,*) k,zold(k),znew(k)
1241 write(0,*) k,h(i,j,k),znew(k)-znew(k+1),totalthickness*cs%coordinateResolution(k),cs%coordinateResolution(k)
1244 'MOM_regridding, build_sigma_grid: top surface has moved!!!' )
1246 dzinterface(i,j,1) = 0.
1247 dzinterface(i,j,nz+1) = 0.
1258 subroutine build_rho_grid( G, GV, h, tv, dzInterface, remapCS, CS )
1275 type(ocean_grid_type),
intent(in) :: G
1277 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1279 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)+1),
intent(inout) :: dzInterface
1286 real :: nominalDepth, totalThickness
1287 real,
dimension(SZK_(GV)+1) :: zOld, zNew
1288 #ifdef __DO_SAFETY_CHECKS__ 1294 if (.not.cs%target_density_set)
call mom_error(fatal,
"build_rho_grid: "//&
1295 "Target densities must be set before build_rho_grid is called.")
1298 do j = g%jsc-1,g%jec+1
1299 do i = g%isc-1,g%iec+1
1301 if (g%mask2dT(i,j)==0.)
then 1302 dzinterface(i,j,:) = 0.
1308 nominaldepth = g%bathyT(i,j)*gv%m_to_H
1310 call build_rho_column(cs%rho_CS, remapcs, nz, nominaldepth, h(i, j, :)*gv%H_to_m, &
1311 tv%T(i, j, :), tv%S(i, j, :), tv%eqn_of_state, znew)
1313 if (cs%integrate_downward_for_e)
then 1316 zold(k+1) = zold(k) - h(i,j,k)
1320 zold(nz+1) = - nominaldepth
1322 zold(k) = zold(k+1) + h(i,j,k)
1329 #ifdef __DO_SAFETY_CHECKS__ 1331 if (znew(k) > zold(1))
then 1332 write(0,*)
'zOld=',zold
1333 write(0,*)
'zNew=',znew
1334 call mom_error( fatal,
'MOM_regridding, build_rho_grid: '//&
1335 'interior interface above surface!' )
1337 if (znew(k) > znew(k-1))
then 1338 write(0,*)
'zOld=',zold
1339 write(0,*)
'zNew=',znew
1340 call mom_error( fatal,
'MOM_regridding, build_rho_grid: '//&
1341 'interior interfaces cross!' )
1345 totalthickness = 0.0
1347 totalthickness = totalthickness + h(i,j,k)
1350 dh=max(nominaldepth,totalthickness)
1351 if (abs(znew(1)-zold(1))>(nz-1)*0.5*epsilon(dh)*dh)
then 1352 write(0,*)
'min_thickness=',cs%min_thickness
1353 write(0,*)
'nominalDepth=',nominaldepth,
'totalThickness=',totalthickness
1354 write(0,*)
'zNew(1)-zOld(1) = ',znew(1)-zold(1),epsilon(dh),nz
1356 write(0,*) k,zold(k),znew(k)
1359 write(0,*) k,h(i,j,k),znew(k)-znew(k+1)
1362 'MOM_regridding, build_rho_grid: top surface has moved!!!' )
1382 type(ocean_grid_type),
intent(in) :: G
1384 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1386 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(inout) :: dzInterface
1390 real,
dimension(SZK_(GV)+1) :: z_col, z_col_new
1391 real,
dimension(SZK_(GV)+1) :: dz_col
1392 real,
dimension(SZK_(GV)) :: p_col
1393 integer :: i, j, k, nz
1398 if (.not.cs%target_density_set)
call mom_error(fatal,
"build_grid_HyCOM1 : "//&
1399 "Target densities must be set before build_grid_HyCOM1 is called.")
1402 do j = g%jsc-1,g%jec+1 ;
do i = g%isc-1,g%iec+1
1403 if (g%mask2dT(i,j)>0.)
then 1405 depth = g%bathyT(i,j) * gv%m_to_H
1409 z_col(k+1) = z_col(k) + h(i,j,k)
1410 p_col(k) = cs%ref_pressure + cs%compressibility_fraction * &
1411 ( 0.5 * ( z_col(k) + z_col(k+1) ) * gv%H_to_Pa - cs%ref_pressure )
1415 h(i, j, :), tv%T(i, j, :), tv%S(i, j, :), p_col, z_col, z_col_new)
1419 do k=1,nz+1 ; dzinterface(i,j,k) = -dz_col(k) ;
enddo 1425 dzinterface(i,j,:) = 0.
1432 type(ocean_grid_type),
intent(in) :: G
1433 type(verticalgrid_type),
intent(in) :: GV
1434 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1435 type(thermo_var_ptrs),
intent(in) :: tv
1436 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(inout) :: dzInterface
1437 type(remapping_cs),
intent(in) :: remapCS
1441 integer :: i, j, k, nz
1443 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: tInt, sInt
1446 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: zInt
1447 real,
dimension(SZK_(GV)+1) :: zNext
1455 do k = 2, nz ;
do j = g%jsc-2,g%jec+2 ;
do i = g%isc-2,g%iec+2
1456 tint(i,j,k) = 0.5 * (tv%T(i,j,k-1) + tv%T(i,j,k))
1457 sint(i,j,k) = 0.5 * (tv%S(i,j,k-1) + tv%S(i,j,k))
1458 zint(i,j,k) = zint(i,j,k-1) + h(i,j,k-1)
1459 enddo ;
enddo ;
enddo 1463 tint(:,:,1) = tv%T(:,:,1) ; tint(:,:,nz+1) = tv%T(:,:,nz)
1464 sint(:,:,1) = tv%S(:,:,1) ; sint(:,:,nz+1) = tv%S(:,:,nz)
1467 zint(:,:,nz+1) = zint(:,:,nz) + h(:,:,nz)
1471 do j = g%jsc-1,g%jec+1 ;
do i = g%isc-1,g%iec+1
1472 if (g%mask2dT(i,j) < 0.5)
then 1473 dzinterface(i,j,:) = 0.
1477 call build_adapt_column(cs%adapt_CS, g, gv, tv, i, j, zint, tint, sint, h, znext)
1481 do k = 1, nz+1 ; dzinterface(i,j,k) = -dzinterface(i,j,k) ;
enddo 1496 type(ocean_grid_type),
intent(in) :: G
1497 type(verticalgrid_type),
intent(in) :: GV
1498 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(in) :: h
1499 type(thermo_var_ptrs),
intent(in) :: tv
1500 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),
intent(inout) :: dzInterface
1503 real,
dimension(SZK_(GV)+1) :: z_col, z_col_new
1504 real,
dimension(SZK_(GV)+1) :: dz_col
1505 real,
dimension(SZK_(GV)) :: p_col
1507 integer :: i, j, k, nz
1511 if (.not.cs%target_density_set)
call mom_error(fatal,
"build_grid_SLight : "//&
1512 "Target densities must be set before build_grid_SLight is called.")
1515 do j = g%jsc-1,g%jec+1 ;
do i = g%isc-1,g%iec+1
1516 if (g%mask2dT(i,j)>0.)
then 1518 depth = g%bathyT(i,j) * gv%m_to_H
1521 z_col(k+1) = z_col(k) + h(i, j, k)
1522 p_col(k) = cs%ref_pressure + cs%compressibility_fraction * &
1523 ( 0.5 * ( z_col(k) + z_col(k+1) ) * gv%H_to_Pa - cs%ref_pressure )
1526 call build_slight_column(cs%slight_CS, tv%eqn_of_state, gv%H_to_Pa, gv%m_to_H, &
1527 gv%H_subroundoff, nz, depth, &
1528 h(i, j, :), tv%T(i, j, :), tv%S(i, j, :), p_col, z_col, z_col_new)
1532 do k=1,nz+1 ; dzinterface(i,j,k) = -dz_col(k) ;
enddo 1533 #ifdef __DO_SAFETY_CHECKS__ 1534 if (dzinterface(i,j,1) /= 0.) stop
'build_grid_SLight: Surface moved?!' 1535 if (dzinterface(i,j,nz+1) /= 0.) stop
'build_grid_SLight: Bottom moved?!' 1542 dzinterface(i,j,:) = 0.
1550 integer,
intent(in) :: nk
1551 real,
intent(in) :: min_thickness
1552 real,
dimension(nk),
intent(in) :: h_old
1553 real,
dimension(nk+1),
intent(inout) :: dz_int
1556 real :: h_new, eps, h_total, h_err
1558 eps = 1. ; eps = epsilon(eps)
1560 h_total = 0. ; h_err = 0.
1562 h_total = h_total + h_old(k)
1563 h_err = h_err + max( h_old(k), abs(dz_int(k)), abs(dz_int(k+1)) )*eps
1564 h_new = h_old(k) + ( dz_int(k) - dz_int(k+1) )
1565 if (h_new < -3.0*h_err)
then 1566 write(0,*)
'h<0 at k=',k,
'h_old=',h_old(k), &
1567 'wup=',dz_int(k),
'wdn=',dz_int(k+1),
'dw_dz=',dz_int(k) - dz_int(k+1), &
1568 'h_new=',h_new,
'h_err=',h_err
1569 call mom_error( fatal,
'MOM_regridding: adjust_interface_motion() - '//&
1570 'implied h<0 is larger than roundoff!')
1574 h_new = h_old(k) + ( dz_int(k) - dz_int(k+1) )
1575 if (h_new<min_thickness) dz_int(k) = ( dz_int(k+1) - h_old(k) ) + min_thickness
1576 h_new = h_old(k) + ( dz_int(k) - dz_int(k+1) )
1577 if (h_new<0.) dz_int(k) = ( 1. - eps ) * ( dz_int(k+1) - h_old(k) )
1578 h_new = h_old(k) + ( dz_int(k) - dz_int(k+1) )
1580 write(0,*)
'h<0 at k=',k,
'h_old=',h_old(k), &
1581 'wup=',dz_int(k),
'wdn=',dz_int(k+1),
'dw_dz=',dz_int(k) - dz_int(k+1), &
1583 stop
'Still did not work!' 1584 call mom_error( fatal,
'MOM_regridding: adjust_interface_motion() - '//&
1585 'Repeated adjustment for roundoff h<0 failed!')
1601 type(ocean_grid_type),
intent(in) :: G
1602 type(verticalgrid_type),
intent(in) :: GV
1603 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)),
intent(in) :: h
1604 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)+1),
intent(inout) :: dzInterface
1605 real,
intent(inout) :: h_new
1611 real :: z_inter(szk_(gv)+1)
1612 real :: total_height
1615 real :: min_thickness
1618 real :: x1, y1, x2, y2
1623 max_depth = g%max_depth
1624 min_thickness = cs%min_thickness
1626 do j = g%jsc-1,g%jec+1
1627 do i = g%isc-1,g%iec+1
1630 local_depth = g%bathyT(i,j)*gv%m_to_H
1635 total_height = total_height + h(i,j,k)
1638 eta = total_height - local_depth
1641 delta_h = (max_depth + eta) / nz
1646 z_inter(k+1) = z_inter(k) - delta_h
1651 x1 = 0.35; y1 = 0.45; x2 = 0.65; y2 = 0.55
1653 x = - ( z_inter(k) - eta ) / max_depth
1657 else if ( (x > x1 ) .and. ( x < x2 ))
then 1658 t = y1 + (y2-y1) * (x-x1) / (x2-x1)
1660 t = y2 + (1.0-y2) * (x-x2) / (1.0-x2)
1663 z_inter(k) = -t * max_depth + eta
1668 z_inter(nz+1) = - local_depth
1672 if ( z_inter(k) < (z_inter(k+1) + min_thickness) )
then 1673 z_inter(k) = z_inter(k+1) + min_thickness
1679 dzinterface(i,j,1) = 0.
1682 dzinterface(i,j,k) = z_inter(k) - x
1684 dzinterface(i,j,nz+1) = 0.
1710 type(ocean_grid_type),
intent(in) :: G
1711 type(verticalgrid_type),
intent(in) :: GV
1712 real,
dimension(SZI_(G),SZJ_(G), SZK_(GV)),
intent(inout) :: h
1718 do i = g%isc-1,g%iec+1
1719 do j = g%jsc-1,g%jec+1
1726 call old_inflate_layers_1d( cs%min_thickness, gv%ke, htmp )
1748 type(ocean_grid_type),
intent(in) :: G
1749 type(verticalgrid_type),
intent(in) :: GV
1750 real,
dimension(SZI_(G),SZJ_(G),SZK_(GV)),
intent(inout) :: h
1751 type(thermo_var_ptrs),
intent(inout) :: tv
1759 logical :: stratified
1760 real,
dimension(GV%ke) :: p_col, densities
1765 do j = g%jsc-1,g%jec+1 ;
do i = g%isc-1,g%iec+1
1768 call calculate_density( tv%T(i,j,:), tv%S(i,j,:), p_col, &
1769 densities, 1, gv%ke, tv%eqn_of_state )
1776 t0 = tv%T(i,j,k) ; t1 = tv%T(i,j,k+1)
1777 s0 = tv%S(i,j,k) ; s1 = tv%S(i,j,k+1)
1778 r0 = densities(k) ; r1 = densities(k+1)
1779 h0 = h(i,j,k) ; h1 = h(i,j,k+1)
1784 tv%T(i,j,k) = t1 ; tv%T(i,j,k+1) = t0
1785 tv%S(i,j,k) = s1 ; tv%S(i,j,k+1) = s0
1786 h(i,j,k) = h1 ; h(i,j,k+1) = h0
1788 call calculate_density( tv%T(i,j,k), tv%S(i,j,k), p_col(k), &
1789 densities(k), tv%eqn_of_state )
1790 call calculate_density( tv%T(i,j,k+1), tv%S(i,j,k+1), p_col(k+1), &
1791 densities(k+1), tv%eqn_of_state )
1792 stratified = .false.
1796 if ( stratified )
exit 1812 integer,
intent(in) :: nk
1813 character(len=*),
intent(in) :: coordMode
1814 real,
intent(in) :: maxDepth, rhoLight, rhoHeavy
1815 real :: uniformResolution(nk)
1820 scheme = coordinatemode(coordmode)
1821 select case ( scheme )
1823 case ( regridding_zstar, regridding_hycom1, regridding_slight, regridding_sigma_shelf_zstar, &
1824 regridding_adaptive )
1825 uniformresolution(:) = maxdepth /
real(nk)
1827 case ( regridding_rho )
1828 uniformresolution(:) = (rhoheavy - rholight) /
real(nk)
1830 case ( regridding_sigma )
1831 uniformresolution(:) = 1. /
real(nk)
1834 call mom_error(fatal,
"MOM_regridding, uniformResolution: "//&
1835 "Unrecognized choice for coordinate mode ("//trim(coordmode)//
").")
1843 character(len=*),
intent(in) :: coord_mode
1845 select case (coordinatemode(coord_mode))
1846 case (regridding_zstar)
1847 call init_coord_zlike(cs%zlike_CS, cs%nk, cs%coordinateResolution)
1848 case (regridding_sigma_shelf_zstar)
1849 call init_coord_zlike(cs%zlike_CS, cs%nk, cs%coordinateResolution)
1850 case (regridding_sigma)
1851 call init_coord_sigma(cs%sigma_CS, cs%nk, cs%coordinateResolution)
1852 case (regridding_rho)
1853 call init_coord_rho(cs%rho_CS, cs%nk, cs%ref_pressure, cs%target_density, cs%interp_CS)
1854 case (regridding_hycom1)
1855 call init_coord_hycom(cs%hycom_CS, cs%nk, cs%coordinateResolution, cs%target_density, cs%interp_CS)
1856 case (regridding_slight)
1857 call init_coord_slight(cs%slight_CS, cs%nk, cs%ref_pressure, cs%target_density, cs%interp_CS)
1858 case (regridding_adaptive)
1859 call init_coord_adapt(cs%adapt_CS, cs%nk, cs%coordinateResolution)
1867 real,
dimension(:),
intent(in) :: dz
1870 if (
size(dz)/=cs%nk)
call mom_error( fatal, &
1871 'setCoordinateResolution: inconsistent number of levels' )
1873 cs%coordinateResolution(:) = dz(:)
1879 type(verticalgrid_type),
intent(in) :: GV
1885 cs%target_density(1) = gv%Rlay(1)+0.5*(gv%Rlay(1)-gv%Rlay(2))
1886 cs%target_density(nz+1) = gv%Rlay(nz)+0.5*(gv%Rlay(nz)-gv%Rlay(nz-1))
1888 cs%target_density(k) = cs%target_density(k-1) + cs%coordinateResolution(k)
1890 cs%target_density_set = .true.
1897 real,
dimension(CS%nk+1),
intent(in) :: rho_int
1899 cs%target_density(:) = rho_int(:)
1900 cs%target_density_set = .true.
1907 real,
dimension(CS%nk+1),
intent(in) :: max_depths
1908 real,
optional,
intent(in) :: units_to_H
1913 if (.not.
allocated(cs%max_interface_depths))
allocate(cs%max_interface_depths(1:cs%nk+1))
1915 val_to_h = 1.0 ;
if (
present( units_to_h)) val_to_h = units_to_h
1916 if (max_depths(cs%nk+1) < max_depths(1)) val_to_h = -1.0*val_to_h
1919 if (max_depths(cs%nk+1) < max_depths(1))
then 1920 do k=1,cs%nk ;
if (max_depths(k+1) > max_depths(k)) &
1921 call mom_error(fatal,
"Unordered list of maximum depths sent to set_regrid_max_depths!")
1924 do k=1,cs%nk ;
if (max_depths(k+1) < max_depths(k)) &
1925 call mom_error(fatal,
"Unordered list of maximum depths sent to set_regrid_max_depths.")
1930 cs%max_interface_depths(k) = val_to_h * max_depths(k)
1934 select case (cs%regridding_scheme)
1935 case (regridding_hycom1)
1936 call set_hycom_params(cs%hycom_CS, max_interface_depths=cs%max_interface_depths)
1937 case (regridding_slight)
1938 call set_slight_params(cs%slight_CS, max_interface_depths=cs%max_interface_depths)
1945 real,
dimension(CS%nk+1),
intent(in) :: max_h
1946 real,
optional,
intent(in) :: units_to_H
1951 if (.not.
allocated(cs%max_layer_thickness))
allocate(cs%max_layer_thickness(1:cs%nk))
1953 val_to_h = 1.0 ;
if (
present( units_to_h)) val_to_h = units_to_h
1956 cs%max_layer_thickness(k) = val_to_h * max_h(k)
1960 select case (cs%regridding_scheme)
1961 case (regridding_hycom1)
1962 call set_hycom_params(cs%hycom_CS, max_layer_thickness=cs%max_layer_thickness)
1963 case (regridding_slight)
1964 call set_slight_params(cs%slight_CS, max_layer_thickness=cs%max_layer_thickness)
1974 real,
dimension(CS%nk) :: getCoordinateResolution
1976 getcoordinateresolution(:) = cs%coordinateResolution(:)
1983 real,
dimension(CS%nk+1) :: getCoordinateInterfaces
1989 if (cs%regridding_scheme == regridding_rho)
then 1990 if (.not. cs%target_density_set) &
1991 call mom_error(fatal,
'MOM_regridding, getCoordinateInterfaces: '//&
1992 'target densities not set!')
1994 getcoordinateinterfaces(:) = cs%target_density(:)
1996 getcoordinateinterfaces(1) = 0.
1998 getcoordinateinterfaces(k+1) = getcoordinateinterfaces(k) &
1999 -cs%coordinateResolution(k)
2003 getcoordinateinterfaces(:) = abs( getcoordinateinterfaces(:) )
2013 character(len=20) :: getCoordinateUnits
2015 select case ( cs%regridding_scheme )
2016 case ( regridding_zstar, regridding_hycom1, regridding_slight, regridding_adaptive )
2017 getcoordinateunits =
'meter' 2018 case ( regridding_sigma_shelf_zstar )
2019 getcoordinateunits =
'meter/fraction' 2020 case ( regridding_sigma )
2021 getcoordinateunits =
'fraction' 2022 case ( regridding_rho )
2023 getcoordinateunits =
'kg/m3' 2024 case ( regridding_arbitrary )
2025 getcoordinateunits =
'unknown' 2027 call mom_error(fatal,
'MOM_regridding, getCoordinateUnits: '//&
2028 'Unknown regridding scheme selected!')
2038 character(len=20) :: getCoordinateShortName
2040 select case ( cs%regridding_scheme )
2041 case ( regridding_zstar )
2044 getcoordinateshortname =
'pseudo-depth, -z*' 2045 case ( regridding_sigma_shelf_zstar )
2046 getcoordinateshortname =
'pseudo-depth, -z*/sigma' 2047 case ( regridding_sigma )
2048 getcoordinateshortname =
'sigma' 2049 case ( regridding_rho )
2050 getcoordinateshortname =
'rho' 2051 case ( regridding_arbitrary )
2052 getcoordinateshortname =
'coordinate' 2053 case ( regridding_hycom1 )
2054 getcoordinateshortname =
'z-rho' 2055 case ( regridding_slight )
2056 getcoordinateshortname =
's-rho' 2057 case ( regridding_adaptive )
2058 getcoordinateshortname =
'adaptive' 2060 call mom_error(fatal,
'MOM_regridding, getCoordinateShortName: '//&
2061 'Unknown regridding scheme selected!')
2067 subroutine set_regrid_params( CS, boundary_extrapolation, min_thickness, old_grid_weight, &
2068 interp_scheme, depth_of_time_filter_shallow, depth_of_time_filter_deep, &
2069 compress_fraction, dz_min_surface, nz_fixed_surface, Rho_ML_avg_depth, &
2070 nlay_ML_to_interior, fix_haloclines, halocline_filt_len, &
2071 halocline_strat_tol, integrate_downward_for_e, &
2072 adaptTimeRatio, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptAlpha, adaptDoMin)
2074 logical,
optional,
intent(in) :: boundary_extrapolation
2075 real,
optional,
intent(in) :: min_thickness
2076 real,
optional,
intent(in) :: old_grid_weight
2077 character(len=*),
optional,
intent(in) :: interp_scheme
2078 real,
optional,
intent(in) :: depth_of_time_filter_shallow
2079 real,
optional,
intent(in) :: depth_of_time_filter_deep
2080 real,
optional,
intent(in) :: compress_fraction
2081 real,
optional,
intent(in) :: dz_min_surface
2082 integer,
optional,
intent(in) :: nz_fixed_surface
2083 real,
optional,
intent(in) :: Rho_ml_avg_depth
2084 real,
optional,
intent(in) :: nlay_ML_to_interior
2085 logical,
optional,
intent(in) :: fix_haloclines
2086 real,
optional,
intent(in) :: halocline_filt_len
2087 real,
optional,
intent(in) :: halocline_strat_tol
2088 logical,
optional,
intent(in) :: integrate_downward_for_e
2089 real,
optional,
intent(in) :: adaptTimeRatio, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptAlpha
2090 logical,
optional,
intent(in) :: adaptDoMin
2092 if (
present(interp_scheme))
call set_interp_scheme(cs%interp_CS, interp_scheme)
2093 if (
present(boundary_extrapolation))
call set_interp_extrap(cs%interp_CS, boundary_extrapolation)
2095 if (
present(old_grid_weight))
then 2096 if (old_grid_weight<0. .or. old_grid_weight>1.) &
2097 call mom_error(fatal,
'MOM_regridding, set_regrid_params: Weight is out side the range 0..1!')
2098 cs%old_grid_weight = old_grid_weight
2100 if (
present(depth_of_time_filter_shallow)) cs%depth_of_time_filter_shallow = depth_of_time_filter_shallow
2101 if (
present(depth_of_time_filter_deep)) cs%depth_of_time_filter_deep = depth_of_time_filter_deep
2102 if (
present(depth_of_time_filter_shallow) .or.
present(depth_of_time_filter_deep))
then 2103 if (cs%depth_of_time_filter_deep<cs%depth_of_time_filter_shallow)
call mom_error(fatal,
'MOM_regridding, '//&
2104 'set_regrid_params: depth_of_time_filter_deep<depth_of_time_filter_shallow!')
2107 if (
present(min_thickness)) cs%min_thickness = min_thickness
2108 if (
present(compress_fraction)) cs%compressibility_fraction = compress_fraction
2109 if (
present(integrate_downward_for_e)) cs%integrate_downward_for_e = integrate_downward_for_e
2111 select case (cs%regridding_scheme)
2112 case (regridding_zstar)
2113 if (
present(min_thickness))
call set_zlike_params(cs%zlike_CS, min_thickness=min_thickness)
2114 case (regridding_sigma_shelf_zstar)
2115 if (
present(min_thickness))
call set_zlike_params(cs%zlike_CS, min_thickness=min_thickness)
2116 case (regridding_sigma)
2117 if (
present(min_thickness))
call set_sigma_params(cs%sigma_CS, min_thickness=min_thickness)
2118 case (regridding_rho)
2119 if (
present(min_thickness))
call set_rho_params(cs%rho_CS, min_thickness=min_thickness)
2120 if (
present(integrate_downward_for_e))
call set_rho_params(cs%rho_CS, integrate_downward_for_e=integrate_downward_for_e)
2121 if (
associated(cs%rho_CS) .and. (
present(interp_scheme) .or.
present(boundary_extrapolation))) &
2122 call set_rho_params(cs%rho_CS, interp_cs=cs%interp_CS)
2123 case (regridding_hycom1)
2124 if (
associated(cs%hycom_CS) .and. (
present(interp_scheme) .or.
present(boundary_extrapolation))) &
2125 call set_hycom_params(cs%hycom_CS, interp_cs=cs%interp_CS)
2126 case (regridding_slight)
2127 if (
present(min_thickness))
call set_slight_params(cs%slight_CS, min_thickness=min_thickness)
2128 if (
present(dz_min_surface))
call set_slight_params(cs%slight_CS, dz_ml_min=dz_min_surface)
2129 if (
present(nz_fixed_surface))
call set_slight_params(cs%slight_CS, nz_fixed_surface=nz_fixed_surface)
2130 if (
present(rho_ml_avg_depth))
call set_slight_params(cs%slight_CS, rho_ml_avg_depth=rho_ml_avg_depth)
2131 if (
present(nlay_ml_to_interior))
call set_slight_params(cs%slight_CS, nlay_ml_offset=nlay_ml_to_interior)
2132 if (
present(fix_haloclines))
call set_slight_params(cs%slight_CS, fix_haloclines=fix_haloclines)
2133 if (
present(halocline_filt_len))
call set_slight_params(cs%slight_CS, halocline_filter_length=halocline_filt_len)
2134 if (
present(halocline_strat_tol))
call set_slight_params(cs%slight_CS, halocline_strat_tol=halocline_strat_tol)
2135 if (
present(compress_fraction))
call set_slight_params(cs%slight_CS, compressibility_fraction=compress_fraction)
2136 if (
associated(cs%slight_CS) .and. (
present(interp_scheme) .or.
present(boundary_extrapolation))) &
2137 call set_slight_params(cs%slight_CS, interp_cs=cs%interp_CS)
2138 case (regridding_adaptive)
2139 if (
present(adapttimeratio))
call set_adapt_params(cs%adapt_CS, adapttimeratio=adapttimeratio)
2140 if (
present(adaptzoom))
call set_adapt_params(cs%adapt_CS, adaptzoom=adaptzoom)
2141 if (
present(adaptzoomcoeff))
call set_adapt_params(cs%adapt_CS, adaptzoomcoeff=adaptzoomcoeff)
2142 if (
present(adaptbuoycoeff))
call set_adapt_params(cs%adapt_CS, adaptbuoycoeff=adaptbuoycoeff)
2143 if (
present(adaptalpha))
call set_adapt_params(cs%adapt_CS, adaptalpha=adaptalpha)
2144 if (
present(adaptdomin))
call set_adapt_params(cs%adapt_CS, adaptdomin=adaptdomin)
2159 type(zlike_cs) :: get_zlike_CS
2161 get_zlike_cs = cs%zlike_CS
2166 type(sigma_cs) :: get_sigma_CS
2168 get_sigma_cs = cs%sigma_CS
2173 type(rho_cs) :: get_rho_CS
2175 get_rho_cs = cs%rho_CS
2183 real,
intent(in) :: SSH
2184 real,
intent(in) :: depth
2185 real,
dimension(CS%nk) :: getStaticThickness
2190 select case ( cs%regridding_scheme )
2191 case ( regridding_zstar, regridding_sigma_shelf_zstar, regridding_hycom1, regridding_slight, regridding_adaptive )
2195 dz = cs%coordinateResolution(k) * ( 1. + ssh/depth )
2197 dz = min(dz, depth - z)
2199 getstaticthickness(k) = dz
2202 getstaticthickness(:) = 0.
2204 case ( regridding_sigma )
2205 getstaticthickness(:) = cs%coordinateResolution(:) * ( depth + ssh )
2206 case ( regridding_rho )
2207 getstaticthickness(:) = 0.
2208 case ( regridding_arbitrary )
2209 getstaticthickness(:) = 0.
2211 call mom_error(fatal,
'MOM_regridding, getStaticThickness: '//&
2212 'Unknown regridding scheme selected!')
2219 character(len=*),
intent(in) :: string
2221 real,
dimension(:),
intent(inout) :: dz
2224 real :: dz_min, power, prec, H_total
2228 read( string, *) dz_min, h_total, power, prec
2229 if (prec == -1024.)
call mom_error(fatal,
"dz_function1: "// &
2230 "Problem reading FNC1: string ="//trim(string))
2233 dz(k) = (
real(k-1)/
real(nk-1))**power
2235 dz(:) = ( h_total -
real(nk) * dz_min ) * ( dz(:) / sum(dz) )
2236 dz(:) = anint( dz(:) / prec ) * prec
2237 dz(:) = ( h_total -
real(nk) * dz_min ) * ( dz(:) / sum(dz) )
2238 dz(:) = anint( dz(:) / prec ) * prec
2239 dz(nk) = dz(nk) + ( h_total - sum( dz(:) + dz_min ) )
2240 dz(:) = anint( dz(:) / prec ) * prec
2241 dz(:) = dz(:) + dz_min
integer, parameter regridding_layer
Layer mode.
subroutine, public set_regrid_max_depths(CS, max_depths, units_to_H)
Set maximum interface depths based on a vector of input values.
integer function coordinatemode(string)
Parse a string parameter specifying the coordinate mode and return the appropriate enumerated integer...
integer, parameter regridding_sigma
Sigma coordinates.
logical, parameter, public regriddingdefaultboundaryextrapolation
subroutine build_sigma_grid(CS, G, GV, h, dzInterface)
real function, dimension(nk), public uniformresolution(nk, coordMode, maxDepth, rhoLight, rhoHeavy)
type(vardesc) function, public var_desc(name, units, longname, hor_grid, z_grid, t_grid, cmor_field_name, cmor_units, conversion, caller)
Returns a vardesc type whose elements have been filled with the provided fields. The argument name is...
real, parameter, public regriddingdefaultminthickness
character(len=20) function, public getcoordinateunits(CS)
subroutine, public init_coord_sigma(CS, nk, coordinateResolution)
Initialise a sigma_CS with pointers to parameters.
subroutine, public build_hycom1_column(CS, eqn_of_state, nz, depth, h, T, S, p_col, z_col, z_col_new)
Build a HyCOM coordinate column.
subroutine, public end_coord_zlike(CS)
type(rho_cs) function, public get_rho_cs(CS)
subroutine, public adjust_interface_motion(nk, min_thickness, h_old, dz_int)
Adjust dz_Interface to ensure non-negative future thicknesses.
integer function, public extract_integer(string, separators, n, missing_value)
Returns the integer corresponding to the nth word in the argument.
Control structure containing required parameters for the rho coordinate.
subroutine, public end_coord_slight(CS)
subroutine, public old_inflate_layers_1d(minThickness, N, h)
subroutine build_grid_arbitrary(G, GV, h, dzInterface, h_new, CS)
subroutine, public build_adapt_column(CS, G, GV, tv, i, j, zInt, tInt, sInt, h, zNext)
Calculates density of sea water from T, S and P.
Control structure containing required parameters for the sigma coordinate.
subroutine calc_h_new_by_dz(G, GV, h, dzInterface, h_new)
Calculates h_new from h + delta_k dzInterface.
subroutine, public set_interp_scheme(CS, interp_scheme)
subroutine, public set_zlike_params(CS, min_thickness)
type(zlike_cs) function, public get_zlike_cs(CS)
real function, dimension(cs%nk), public getcoordinateresolution(CS)
subroutine, public inflate_vanished_layers_old(CS, G, GV, h)
Generates vertical grids as part of the ALE algorithm.
Provides column-wise vertical remapping functions.
character(len= *), parameter, public regriddingcoordinatemodedoc
Documentation for coordinate options.
subroutine, public end_coord_rho(CS)
subroutine, public set_rho_params(CS, min_thickness, integrate_downward_for_e, interp_CS)
character(len= *), parameter default_coordinate_mode
Default coordinate mode.
integer, parameter regridding_hycom1
Simple HyCOM coordinates without BBL.
This module contains I/O framework code.
subroutine, public set_hycom_params(CS, max_interface_depths, max_layer_thickness, interp_CS)
integer function, public get_regrid_size(CS)
Returns the number of levels/layers in the regridding control structure.
subroutine dz_function1(string, dz)
Parses a string and generates a dz(:) profile that goes like k**power.
subroutine, public check_grid_column(nk, depth, h, dzInterface, msg)
Check that the total thickness of new and old grids are consistent.
subroutine, public init_coord_zlike(CS, nk, coordinateResolution)
Initialise a zlike_CS with pointers to parameters.
Container for remapping parameters.
subroutine, public set_slight_params(CS, max_interface_depths, max_layer_thickness, min_thickness, compressibility_fraction, dz_ml_min, nz_fixed_surface, Rho_ML_avg_depth, nlay_ML_offset, fix_haloclines, halocline_filter_length, halocline_strat_tol, interp_CS)
subroutine, public init_coord_slight(CS, nk, ref_pressure, target_density, interp_CS)
Initialise a slight_CS with pointers to parameters.
subroutine initcoord(CS, coord_mode)
subroutine build_grid_slight(G, GV, h, tv, dzInterface, CS)
Builds a grid that tracks density interfaces for water that is denser than the surface density plus a...
character(len=20) function, public getcoordinateshortname(CS)
subroutine, public end_regridding(CS)
Deallocation of regridding memory.
subroutine, public set_sigma_params(CS, min_thickness)
subroutine, public build_rho_column(CS, remapCS, nz, depth, h, T, S, eqn_of_state, zInterface)
character(len=len(input_string)) function, public uppercase(input_string)
Regridding control structure.
Control structure containing required parameters for the SLight coordinate.
subroutine build_rho_grid(G, GV, h, tv, dzInterface, remapCS, CS)
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.
real function, dimension(cs%nk), public getstaticthickness(CS, SSH, depth)
subroutine, public set_target_densities_from_gv(GV, CS)
Set target densities based on the old Rlay variable.
Regrid columns for the HyCOM coordinate.
subroutine check_grid_def(filename, varname, expected_units, msg, ierr)
Do some basic checks on the vertical grid definition file, variable.
character(len=120) function, public extractword(string, n)
Returns the string corresponding to the nth word in the argument or "" if the string is not long enou...
Regrid columns for the sigma coordinate.
real function, dimension(cs%nk+1), public getcoordinateinterfaces(CS)
Query the target coordinate interface positions.
subroutine, public build_zstar_column(CS, nz, depth, total_thickness, zInterface, z_rigid_top, eta_orig)
Builds a z* coordinate with a minimum thickness.
Regrid columns for a z-like coordinate (z-star, z-level)
subroutine filtered_grid_motion(CS, nk, z_old, z_new, dz_g)
Returns the change in interface position motion after filtering and assuming the top and bottom inter...
integer, parameter regridding_adaptive
subroutine, public regridding_main(remapCS, CS, G, GV, h, tv, h_new, dzInterface, frac_shelf_h, conv_adjust)
type(sigma_cs) function, public get_sigma_cs(CS)
Provides subroutines for quantities specific to the equation of state.
Type for describing a variable, typically a tracer.
integer, parameter regridding_zstar
z* coordinates
character(len= *), parameter, public regriddinginterpschemedoc
subroutine, public check_remapping_grid(G, GV, h, dzInterface, msg)
Check that the total thickness of two grids match.
Regrid columns for the continuous isopycnal (rho) coordinate.
subroutine, public end_coord_sigma(CS)
subroutine, public setcoordinateresolution(dz, CS)
subroutine, public set_target_densities(CS, rho_int)
Set target densities based on vector of interface values.
subroutine, public set_adapt_params(CS, adaptTimeRatio, adaptAlpha, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptDrho0, adaptDoMin)
The thermo_var_ptrs structure contains pointers to an assortment of thermodynamic fields that may be ...
integer, parameter regridding_sigma_shelf_zstar
z* coordinates at the bottom, sigma-near the top lightest water, isopycnal below
subroutine build_grid_adaptive(G, GV, h, tv, dzInterface, remapCS, CS)
Contains constants for interpreting input parameters that control regridding.
Control structure containing required parameters for the HyCOM coordinate.
subroutine, public init_coord_hycom(CS, nk, coordinateResolution, target_density, interp_CS)
Initialise a hycom_CS with pointers to parameters.
subroutine, public end_coord_hycom(CS)
Control structure containing required parameters for a z-like coordinate.
Regrid columns for the SLight coordinate.
subroutine, public set_regrid_max_thickness(CS, max_h, units_to_H)
Set maximum layer thicknesses based on a vector of input values.
real function, public extract_real(string, separators, n, missing_value)
Returns the real corresponding to the nth word in the argument.
subroutine, public create_file(unit, filename, vars, novars, fields, threading, timeunit, G, dG, GV)
Routine creates a new NetCDF file. It also sets up structures that describe this file and variables t...
integer, parameter regridding_arbitrary
Arbitrary coordinates.
subroutine build_grid_hycom1(G, GV, h, tv, dzInterface, CS)
Builds a simple HyCOM-like grid with the deepest location of potential density interpolated from the ...
subroutine build_zstar_grid(CS, G, GV, h, dzInterface, frac_shelf_h)
Builds a z*-ccordinate grid with partial steps (Adcroft and Campin, 2004). z* is defined as z* = (z-e...
Regrid columns for the adaptive coordinate.
subroutine, public mom_error(level, message, all_print)
integer, parameter regridding_rho
Target interface densities.
subroutine, public set_interp_extrap(CS, extrapolation)
subroutine, public end_coord_adapt(CS)
Clean up the coordinate control structure.
subroutine, public build_sigma_column(CS, nz, depth, totalThickness, zInterface)
Build a sigma coordinate column.
subroutine, public build_slight_column(CS, eqn_of_state, H_to_Pa, m_to_H, H_subroundoff, nz, depth, h_col, T_col, S_col, p_col, z_col, z_col_new)
Build a SLight coordinate column.
subroutine, public init_coord_rho(CS, nk, ref_pressure, target_density, interp_CS)
Initialise a rho_CS with pointers to parameters.
subroutine, public init_coord_adapt(CS, nk, coordinateResolution)
Initialise an adapt_CS with parameters.
character(len= *), parameter, public regriddingdefaultinterpscheme
subroutine convective_adjustment(G, GV, h, tv)
subroutine, public initialize_regridding(CS, GV, max_depth, param_file, mod, coord_mode, param_prefix, param_suffix)
Initialization and configures a regridding control structure based on customizable run-time parameter...
A control structure for the equation of state.
integer, parameter regridding_slight
Stretched coordinates in the.