Initialization and configures a regridding control structure based on customizable run-time parameters.
181 type(regridding_CS),
intent(inout) :: CS
182 type(verticalGrid_type),
intent(in) :: GV
183 type(unit_scale_type),
intent(in) :: US
184 real,
intent(in) :: max_depth
185 type(param_file_type),
intent(in) :: param_file
186 character(len=*),
intent(in) :: mdl
187 character(len=*),
intent(in) :: coord_mode
188 character(len=*),
intent(in) :: param_prefix
190 character(len=*),
intent(in) :: param_suffix
194 character(len=80) :: string, string2, varName
195 character(len=40) :: coord_units, param_name, coord_res_param
196 character(len=200) :: inputdir, fileName
197 character(len=320) :: message
198 character(len=12) :: expected_units
199 logical :: tmpLogical, fix_haloclines, set_max, do_sum, main_parameters
200 logical :: coord_is_state_dependent, ierr
201 logical :: default_2018_answers, remap_answers_2018
202 real :: filt_len, strat_tol, index_scale, tmpReal, P_Ref
203 real :: maximum_depth
204 real :: dz_fixed_sfc, Rho_avg_depth, nlay_sfc_int
205 real :: adaptTimeRatio, adaptZoom, adaptZoomCoeff, adaptBuoyCoeff, adaptAlpha
207 integer :: nz_fixed_sfc, k, nzf(4)
208 real,
dimension(:),
allocatable :: dz
210 real,
dimension(:),
allocatable :: h_max
211 real,
dimension(:),
allocatable :: z_max
213 real,
dimension(:),
allocatable :: dz_max
215 real,
dimension(:),
allocatable :: rho_target
217 real,
dimension(40) :: woa09_dz = (/ 5., 10., 10., 15., 22.5, 25., 25., 25., &
218 37.5, 50., 50., 75., 100., 100., 100., 100., &
219 100., 100., 100., 100., 100., 100., 100., 175., &
220 250., 375., 500., 500., 500., 500., 500., 500., &
221 500., 500., 500., 500., 500., 500., 500., 500. /)
223 call get_param(param_file, mdl,
"INPUTDIR", inputdir, default=
".")
224 inputdir = slasher(inputdir)
226 main_parameters=.false.
227 if (len_trim(param_prefix)==0) main_parameters=.true.
228 if (main_parameters .and. len_trim(param_suffix)>0)
call mom_error(fatal,trim(mdl)//
', initialize_regridding: '// &
229 'Suffix provided without prefix for parameter names!')
232 cs%regridding_scheme = coordinatemode(coord_mode)
233 coord_is_state_dependent = state_dependent(coord_mode)
234 maximum_depth = us%Z_to_m*max_depth
236 if (main_parameters)
then
238 call get_param(param_file, mdl,
"REGRIDDING_COORDINATE_UNITS", coord_units, &
239 "Units of the regridding coordinate.", default=coordinateunits(coord_mode))
241 coord_units=coordinateunits(coord_mode)
244 if (coord_is_state_dependent)
then
245 if (main_parameters)
then
246 param_name =
"INTERPOLATION_SCHEME"
247 string2 = regriddingdefaultinterpscheme
249 param_name = trim(param_prefix)//
"_INTERP_SCHEME_"//trim(param_suffix)
252 call get_param(param_file, mdl,
"INTERPOLATION_SCHEME", string, &
253 "This sets the interpolation scheme to use to "//&
254 "determine the new grid. These parameters are "//&
255 "only relevant when REGRIDDING_COORDINATE_MODE is "//&
256 "set to a function of state. Otherwise, it is not "//&
257 "used. It can be one of the following schemes: "//&
258 trim(regriddinginterpschemedoc), default=trim(string2))
259 call set_regrid_params(cs, interp_scheme=string)
261 call get_param(param_file, mdl,
"DEFAULT_2018_ANSWERS", default_2018_answers, &
262 "This sets the default value for the various _2018_ANSWERS parameters.", &
264 call get_param(param_file, mdl,
"REMAPPING_2018_ANSWERS", remap_answers_2018, &
265 "If true, use the order of arithmetic and expressions that recover the "//&
266 "answers from the end of 2018. Otherwise, use updated and more robust "//&
267 "forms of the same expressions.", default=default_2018_answers)
268 call set_regrid_params(cs, remap_answers_2018=remap_answers_2018)
271 if (main_parameters .and. coord_is_state_dependent)
then
272 call get_param(param_file, mdl,
"BOUNDARY_EXTRAPOLATION", tmplogical, &
273 "When defined, a proper high-order reconstruction "//&
274 "scheme is used within boundary cells rather "//&
275 "than PCM. E.g., if PPM is used for remapping, a "//&
276 "PPM reconstruction will also be used within "//&
277 "boundary cells.", default=regriddingdefaultboundaryextrapolation)
278 call set_regrid_params(cs, boundary_extrapolation=tmplogical)
280 call set_regrid_params(cs, boundary_extrapolation=.false.)
284 if (main_parameters)
then
285 param_name =
"ALE_COORDINATE_CONFIG"
286 coord_res_param =
"ALE_RESOLUTION"
289 param_name = trim(param_prefix)//
"_DEF_"//trim(param_suffix)
290 coord_res_param = trim(param_prefix)//
"_RES_"//trim(param_suffix)
292 if (maximum_depth>3000.) string2=
'WOA09'
294 call get_param(param_file, mdl, param_name, string, &
295 "Determines how to specify the coordinate "//&
296 "resolution. Valid options are:\n"//&
297 " PARAM - use the vector-parameter "//trim(coord_res_param)//
"\n"//&
298 " UNIFORM[:N] - uniformly distributed\n"//&
299 " FILE:string - read from a file. The string specifies\n"//&
300 " the filename and variable name, separated\n"//&
301 " by a comma or space, e.g. FILE:lev.nc,dz\n"//&
302 " or FILE:lev.nc,interfaces=zw\n"//&
303 " WOA09[:N] - the WOA09 vertical grid (approximately)\n"//&
304 " FNC1:string - FNC1:dz_min,H_total,power,precision\n"//&
305 " HYBRID:string - read from a file. The string specifies\n"//&
306 " the filename and two variable names, separated\n"//&
307 " by a comma or space, for sigma-2 and dz. e.g.\n"//&
308 " HYBRID:vgrid.nc,sigma2,dz",&
309 default=trim(string2))
310 message =
"The distribution of vertical resolution for the target\n"//&
311 "grid used for Eulerian-like coordinates. For example,\n"//&
312 "in z-coordinate mode, the parameter is a list of level\n"//&
313 "thicknesses (in m). In sigma-coordinate mode, the list\n"//&
314 "is of non-dimensional fractions of the water column."
315 if (index(trim(string),
'UNIFORM')==1)
then
316 if (len_trim(string)==7)
then
318 tmpreal = maximum_depth
319 elseif (index(trim(string),
'UNIFORM:')==1 .and. len_trim(string)>8)
then
321 ke = extract_integer(string(9:len_trim(string)),
'',1)
322 tmpreal = extract_real(string(9:len_trim(string)),
',',2,missing_value=maximum_depth)
324 call mom_error(fatal,trim(mdl)//
', initialize_regridding: '// &
325 'Unable to interpret "'//trim(string)//
'".')
328 dz(:) = uniformresolution(ke, coord_mode, tmpreal, &
329 us%R_to_kg_m3*(gv%Rlay(1) + 0.5*(gv%Rlay(1)-gv%Rlay(min(2,ke)))), &
330 us%R_to_kg_m3*(gv%Rlay(ke) + 0.5*(gv%Rlay(ke)-gv%Rlay(max(ke-1,1)))) )
331 if (main_parameters)
call log_param(param_file, mdl,
"!"//coord_res_param, dz, &
332 trim(message), units=trim(coord_units))
333 elseif (trim(string)==
'PARAM')
then
337 call get_param(param_file, mdl, coord_res_param, dz, &
338 trim(message), units=trim(coord_units), fail_if_missing=.true.)
339 elseif (index(trim(string),
'FILE:')==1)
then
342 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then
344 filename = trim( extractword(trim(string(6:80)), 1) )
347 filename = trim(inputdir) // trim( extractword(trim(string(6:80)), 1) )
349 if (.not. file_exists(filename))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
350 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
352 varname = trim( extractword(trim(string(6:)), 2) )
353 if (len_trim(varname)==0)
then
354 if (field_exists(filename,
'dz')) then; varname =
'dz'
355 elseif (field_exists(filename,
'dsigma')) then; varname =
'dsigma'
356 elseif (field_exists(filename,
'ztest')) then; varname =
'ztest'
357 else ;
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
358 "Coordinate variable not specified and none could be guessed.")
364 if (cs%regridding_scheme == regridding_sigma)
then
365 expected_units =
'nondim'
366 elseif (cs%regridding_scheme == regridding_rho)
then
367 expected_units =
'kg m-3'
369 expected_units =
'meters'
371 if (index(trim(varname),
'interfaces=')==1)
then
372 varname=trim(varname(12:))
373 call check_grid_def(filename, varname, expected_units, message, ierr)
374 if (ierr)
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "//&
375 "Unsupported format in grid definition '"//trim(filename)//
"'. Error message "//trim(message))
376 call field_size(trim(filename), trim(varname), nzf)
378 if (ke < 1)
call mom_error(fatal, trim(mdl)//
" initialize_regridding via Var "//trim(varname)//&
379 "in FILE "//trim(filename)//
" requires at least 2 target interface values.")
380 if (cs%regridding_scheme == regridding_rho)
then
381 allocate(rho_target(ke+1))
382 call mom_read_data(trim(filename), trim(varname), rho_target)
385 allocate(z_max(ke+1))
386 call mom_read_data(trim(filename), trim(varname), z_max)
387 dz(:) = abs(z_max(1:ke) - z_max(2:ke+1))
392 call field_size(trim(filename), trim(varname), nzf)
395 call mom_read_data(trim(filename), trim(varname), dz)
397 if (main_parameters .and. (ke/=gv%ke))
then
398 call mom_error(fatal,trim(mdl)//
', initialize_regridding: '// &
399 'Mismatch in number of model levels and "'//trim(string)//
'".')
401 if (main_parameters)
call log_param(param_file, mdl,
"!"//coord_res_param, dz, &
402 trim(message), units=coordinateunits(coord_mode))
403 elseif (index(trim(string),
'FNC1:')==1)
then
404 ke = gv%ke;
allocate(dz(ke))
405 call dz_function1( trim(string(6:)), dz )
406 if (main_parameters)
call log_param(param_file, mdl,
"!"//coord_res_param, dz, &
407 trim(message), units=coordinateunits(coord_mode))
408 elseif (index(trim(string),
'RFNC1:')==1)
then
410 ke = rho_function1( trim(string(7:)), rho_target )
411 elseif (index(trim(string),
'HYBRID:')==1)
then
412 ke = gv%ke;
allocate(dz(ke))
414 allocate(rho_target(ke+1))
415 filename = trim( extractword(trim(string(8:)), 1) )
416 if (filename(1:1)/=
'.' .and. filename(1:1)/=
'/') filename = trim(inputdir) // trim( filename )
417 if (.not. file_exists(filename))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: HYBRID "// &
418 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
419 varname = trim( extractword(trim(string(8:)), 2) )
420 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: HYBRID "// &
421 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
422 call mom_read_data(trim(filename), trim(varname), rho_target)
423 varname = trim( extractword(trim(string(8:)), 3) )
424 if (varname(1:5) ==
'FNC1:')
then
425 call dz_function1( trim(string((index(trim(string),
'FNC1:')+5):)), dz )
427 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: HYBRID "// &
428 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
429 call mom_read_data(trim(filename), trim(varname), dz)
431 if (main_parameters)
then
432 call log_param(param_file, mdl,
"!"//coord_res_param, dz, &
433 trim(message), units=coordinateunits(coord_mode))
434 call log_param(param_file, mdl,
"!TARGET_DENSITIES", rho_target, &
435 'HYBRID target densities for interfaces', units=coordinateunits(coord_mode))
437 elseif (index(trim(string),
'WOA09')==1)
then
438 if (len_trim(string)==5)
then
439 tmpreal = 0. ; ke = 0
440 do while (tmpreal<maximum_depth)
442 tmpreal = tmpreal + woa09_dz(ke)
444 elseif (index(trim(string),
'WOA09:')==1)
then
445 if (len_trim(string)==6)
call mom_error(fatal,trim(mdl)//
', initialize_regridding: '// &
446 'Expected string of form "WOA09:N" but got "'//trim(string)//
'".')
447 ke = extract_integer(string(7:len_trim(string)),
'',1)
449 if (ke>40 .or. ke<1)
call mom_error(fatal,trim(mdl)//
', initialize_regridding: '// &
450 'For "WOA05:N" N must 0<N<41 but got "'//trim(string)//
'".')
452 dz(1:ke) = woa09_dz(1:ke)
454 call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
455 "Unrecognized coordinate configuration"//trim(string))
458 if (main_parameters)
then
460 if (coordinatemode(coord_mode) == regridding_zstar .or. &
461 coordinatemode(coord_mode) == regridding_hycom1 .or. &
462 coordinatemode(coord_mode) == regridding_slight .or. &
463 coordinatemode(coord_mode) == regridding_adaptive)
then
465 tmpreal = sum( dz(:) )
466 if (tmpreal < maximum_depth)
then
467 dz(ke) = dz(ke) + ( maximum_depth - tmpreal )
468 elseif (tmpreal > maximum_depth)
then
469 if ( dz(ke) + ( maximum_depth - tmpreal ) > 0. )
then
470 dz(ke) = dz(ke) + ( maximum_depth - tmpreal )
472 call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
473 "MAXIMUM_DEPTH was too shallow to adjust bottom layer of DZ!"//trim(string))
482 allocate( cs%coordinateResolution(cs%nk) ); cs%coordinateResolution(:) = -1.e30
483 if (state_dependent(cs%regridding_scheme))
then
485 allocate( cs%target_density(cs%nk+1) ); cs%target_density(:) = -1.e30*us%kg_m3_to_R
488 if (
allocated(dz))
then
489 if (coordinatemode(coord_mode) == regridding_sigma)
then
490 call setcoordinateresolution(dz, cs, scale=1.0)
491 elseif (coordinatemode(coord_mode) == regridding_rho)
then
492 call setcoordinateresolution(dz, cs, scale=us%kg_m3_to_R)
493 cs%coord_scale = us%R_to_kg_m3
494 elseif (coordinatemode(coord_mode) == regridding_adaptive)
then
495 call setcoordinateresolution(dz, cs, scale=gv%m_to_H)
496 cs%coord_scale = gv%H_to_m
498 call setcoordinateresolution(dz, cs, scale=us%m_to_Z)
499 cs%coord_scale = us%Z_to_m
503 if (
allocated(rho_target))
then
504 call set_target_densities(cs, us%kg_m3_to_R*rho_target)
505 deallocate(rho_target)
508 elseif (coordinatemode(coord_mode) == regridding_rho)
then
509 call set_target_densities_from_gv(gv, us, cs)
510 call log_param(param_file, mdl,
"!TARGET_DENSITIES", us%R_to_kg_m3*cs%target_density(:), &
511 'RHO target densities for interfaces', units=coordinateunits(coord_mode))
515 call initcoord(cs, gv, us, coord_mode)
517 if (main_parameters .and. coord_is_state_dependent)
then
518 call get_param(param_file, mdl,
"P_REF", p_ref, &
519 "The pressure that is used for calculating the coordinate "//&
520 "density. (1 Pa = 1e4 dbar, so 2e7 is commonly used.) "//&
521 "This is only used if USE_EOS and ENABLE_THERMODYNAMICS are true.", &
522 units=
"Pa", default=2.0e7, scale=us%kg_m3_to_R*us%m_s_to_L_T**2)
523 call get_param(param_file, mdl,
"REGRID_COMPRESSIBILITY_FRACTION", tmpreal, &
524 "When interpolating potential density profiles we can add "//&
525 "some artificial compressibility solely to make homogeneous "//&
526 "regions appear stratified.", units=
"nondim", default=0.)
527 call set_regrid_params(cs, compress_fraction=tmpreal, ref_pressure=p_ref)
530 if (main_parameters)
then
531 call get_param(param_file, mdl,
"MIN_THICKNESS", tmpreal, &
532 "When regridding, this is the minimum layer "//&
533 "thickness allowed.", units=
"m", scale=gv%m_to_H, &
534 default=regriddingdefaultminthickness )
535 call set_regrid_params(cs, min_thickness=tmpreal)
537 call set_regrid_params(cs, min_thickness=0.)
540 if (coordinatemode(coord_mode) == regridding_slight)
then
542 call get_param(param_file, mdl,
"SLIGHT_DZ_SURFACE", dz_fixed_sfc, &
543 "The nominal thickness of fixed thickness near-surface "//&
544 "layers with the SLight coordinate.", units=
"m", default=1.0, scale=gv%m_to_H)
545 call get_param(param_file, mdl,
"SLIGHT_NZ_SURFACE_FIXED", nz_fixed_sfc, &
546 "The number of fixed-depth surface layers with the SLight "//&
547 "coordinate.", units=
"nondimensional", default=2)
548 call get_param(param_file, mdl,
"SLIGHT_SURFACE_AVG_DEPTH", rho_avg_depth, &
549 "The thickness of the surface region over which to average "//&
550 "when calculating the density to use to define the interior "//&
551 "with the SLight coordinate.", units=
"m", default=1.0, scale=gv%m_to_H)
552 call get_param(param_file, mdl,
"SLIGHT_NLAY_TO_INTERIOR", nlay_sfc_int, &
553 "The number of layers to offset the surface density when "//&
554 "defining where the interior ocean starts with SLight.", &
555 units=
"nondimensional", default=2.0)
556 call get_param(param_file, mdl,
"SLIGHT_FIX_HALOCLINES", fix_haloclines, &
557 "If true, identify regions above the reference pressure "//&
558 "where the reference pressure systematically underestimates "//&
559 "the stratification and use this in the definition of the "//&
560 "interior with the SLight coordinate.", default=.false.)
562 call set_regrid_params(cs, dz_min_surface=dz_fixed_sfc, &
563 nz_fixed_surface=nz_fixed_sfc, rho_ml_avg_depth=rho_avg_depth, &
564 nlay_ml_to_interior=nlay_sfc_int, fix_haloclines=fix_haloclines)
565 if (fix_haloclines)
then
567 call get_param(param_file, mdl,
"HALOCLINE_FILTER_LENGTH", filt_len, &
568 "A length scale over which to smooth the temperature and "//&
569 "salinity before identifying erroneously unstable haloclines.", &
570 units=
"m", default=2.0, scale=gv%m_to_H)
571 call get_param(param_file, mdl,
"HALOCLINE_STRAT_TOL", strat_tol, &
572 "A tolerance for the ratio of the stratification of the "//&
573 "apparent coordinate stratification to the actual value "//&
574 "that is used to identify erroneously unstable haloclines. "//&
575 "This ratio is 1 when they are equal, and sensible values "//&
576 "are between 0 and 0.5.", units=
"nondimensional", default=0.2)
577 call set_regrid_params(cs, halocline_filt_len=filt_len, &
578 halocline_strat_tol=strat_tol)
583 if (coordinatemode(coord_mode) == regridding_adaptive)
then
584 call get_param(param_file, mdl,
"ADAPT_TIME_RATIO", adapttimeratio, &
585 "Ratio of ALE timestep to grid timescale.", units=
"nondim", default=1.0e-1)
586 call get_param(param_file, mdl,
"ADAPT_ZOOM_DEPTH", adaptzoom, &
587 "Depth of near-surface zooming region.", units=
"m", default=200.0, scale=gv%m_to_H)
588 call get_param(param_file, mdl,
"ADAPT_ZOOM_COEFF", adaptzoomcoeff, &
589 "Coefficient of near-surface zooming diffusivity.", units=
"nondim", default=0.2)
590 call get_param(param_file, mdl,
"ADAPT_BUOY_COEFF", adaptbuoycoeff, &
591 "Coefficient of buoyancy diffusivity.", units=
"nondim", default=0.8)
592 call get_param(param_file, mdl,
"ADAPT_ALPHA", adaptalpha, &
593 "Scaling on optimization tendency.", units=
"nondim", default=1.0)
594 call get_param(param_file, mdl,
"ADAPT_DO_MIN_DEPTH", tmplogical, &
595 "If true, make a HyCOM-like mixed layer by preventing interfaces "//&
596 "from being shallower than the depths specified by the regridding coordinate.", &
598 call get_param(param_file, mdl,
"ADAPT_DRHO0", adaptdrho0, &
599 "Reference density difference for stratification-dependent diffusion.", &
600 units=
"kg m-3", default=0.5, scale=us%kg_m3_to_R)
602 call set_regrid_params(cs, adapttimeratio=adapttimeratio, adaptzoom=adaptzoom, &
603 adaptzoomcoeff=adaptzoomcoeff, adaptbuoycoeff=adaptbuoycoeff, adaptalpha=adaptalpha, &
604 adaptdomin=tmplogical, adaptdrho0=adaptdrho0)
607 if (main_parameters .and. coord_is_state_dependent)
then
608 call get_param(param_file, mdl,
"MAXIMUM_INT_DEPTH_CONFIG", string, &
609 "Determines how to specify the maximum interface depths.\n"//&
610 "Valid options are:\n"//&
611 " NONE - there are no maximum interface depths\n"//&
612 " PARAM - use the vector-parameter MAXIMUM_INTERFACE_DEPTHS\n"//&
613 " FILE:string - read from a file. The string specifies\n"//&
614 " the filename and variable name, separated\n"//&
615 " by a comma or space, e.g. FILE:lev.nc,Z\n"//&
616 " FNC1:string - FNC1:dz_min,H_total,power,precision",&
618 message =
"The list of maximum depths for each interface."
619 allocate(z_max(ke+1))
621 if ( trim(string) ==
"NONE")
then
623 elseif ( trim(string) ==
"PARAM")
then
624 call get_param(param_file, mdl,
"MAXIMUM_INTERFACE_DEPTHS", z_max, &
625 trim(message), units=
"m", scale=gv%m_to_H, fail_if_missing=.true.)
626 call set_regrid_max_depths(cs, z_max)
627 elseif (index(trim(string),
'FILE:')==1)
then
628 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then
630 filename = trim( extractword(trim(string(6:80)), 1) )
633 filename = trim(inputdir) // trim( extractword(trim(string(6:80)), 1) )
635 if (.not. file_exists(filename))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
636 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
639 varname = trim( extractword(trim(string(6:)), 2) )
640 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
641 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
642 if (len_trim(varname)==0)
then
643 if (field_exists(filename,
'z_max')) then; varname =
'z_max'
644 elseif (field_exists(filename,
'dz')) then; varname =
'dz' ; do_sum = .true.
645 elseif (field_exists(filename,
'dz_max')) then; varname =
'dz_max' ; do_sum = .true.
646 else ;
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
647 "MAXIMUM_INT_DEPTHS variable not specified and none could be guessed.")
651 call mom_read_data(trim(filename), trim(varname), dz_max)
652 z_max(1) = 0.0 ;
do k=1,ke ; z_max(k+1) = z_max(k) + dz_max(k) ;
enddo
654 call mom_read_data(trim(filename), trim(varname), z_max)
656 call log_param(param_file, mdl,
"!MAXIMUM_INT_DEPTHS", z_max, &
657 trim(message), units=coordinateunits(coord_mode))
658 call set_regrid_max_depths(cs, z_max, gv%m_to_H)
659 elseif (index(trim(string),
'FNC1:')==1)
then
660 call dz_function1( trim(string(6:)), dz_max )
661 if ((coordinatemode(coord_mode) == regridding_slight) .and. &
662 (dz_fixed_sfc > 0.0))
then
663 do k=1,nz_fixed_sfc ; dz_max(k) = dz_fixed_sfc ;
enddo
665 z_max(1) = 0.0 ;
do k=1,ke ; z_max(k+1) = z_max(k) + dz_max(k) ;
enddo
666 call log_param(param_file, mdl,
"!MAXIMUM_INT_DEPTHS", z_max, &
667 trim(message), units=coordinateunits(coord_mode))
668 call set_regrid_max_depths(cs, z_max, gv%m_to_H)
670 call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
671 "Unrecognized MAXIMUM_INT_DEPTH_CONFIG "//trim(string))
678 call get_param(param_file, mdl,
"MAX_LAYER_THICKNESS_CONFIG", string, &
679 "Determines how to specify the maximum layer thicknesses.\n"//&
680 "Valid options are:\n"//&
681 " NONE - there are no maximum layer thicknesses\n"//&
682 " PARAM - use the vector-parameter MAX_LAYER_THICKNESS\n"//&
683 " FILE:string - read from a file. The string specifies\n"//&
684 " the filename and variable name, separated\n"//&
685 " by a comma or space, e.g. FILE:lev.nc,Z\n"//&
686 " FNC1:string - FNC1:dz_min,H_total,power,precision",&
688 message =
"The list of maximum thickness for each layer."
690 if ( trim(string) ==
"NONE")
then
692 elseif ( trim(string) ==
"PARAM")
then
693 call get_param(param_file, mdl,
"MAX_LAYER_THICKNESS", h_max, &
694 trim(message), units=
"m", fail_if_missing=.true., scale=gv%m_to_H)
695 call set_regrid_max_thickness(cs, h_max)
696 elseif (index(trim(string),
'FILE:')==1)
then
697 if (string(6:6)==
'.' .or. string(6:6)==
'/')
then
699 filename = trim( extractword(trim(string(6:80)), 1) )
702 filename = trim(inputdir) // trim( extractword(trim(string(6:80)), 1) )
704 if (.not. file_exists(filename))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
705 "Specified file not found: Looking for '"//trim(filename)//
"' ("//trim(string)//
")")
707 varname = trim( extractword(trim(string(6:)), 2) )
708 if (.not. field_exists(filename,varname))
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
709 "Specified field not found: Looking for '"//trim(varname)//
"' ("//trim(string)//
")")
710 if (len_trim(varname)==0)
then
711 if (field_exists(filename,
'h_max')) then; varname =
'h_max'
712 elseif (field_exists(filename,
'dz_max')) then; varname =
'dz_max'
713 else ;
call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
714 "MAXIMUM_INT_DEPTHS variable not specified and none could be guessed.")
717 call mom_read_data(trim(filename), trim(varname), h_max)
718 call log_param(param_file, mdl,
"!MAX_LAYER_THICKNESS", h_max, &
719 trim(message), units=coordinateunits(coord_mode))
720 call set_regrid_max_thickness(cs, h_max, gv%m_to_H)
721 elseif (index(trim(string),
'FNC1:')==1)
then
722 call dz_function1( trim(string(6:)), h_max )
723 call log_param(param_file, mdl,
"!MAX_LAYER_THICKNESS", h_max, &
724 trim(message), units=coordinateunits(coord_mode))
725 call set_regrid_max_thickness(cs, h_max, gv%m_to_H)
727 call mom_error(fatal,trim(mdl)//
", initialize_regridding: "// &
728 "Unrecognized MAX_LAYER_THICKNESS_CONFIG "//trim(string))
733 if (
allocated(dz))
deallocate(dz)