MOM6
mom_ale Module Reference

Detailed Description

This module contains the main regridding routines. Regridding comprises two steps: (1) Interpolation and creation of a new grid based on target interface densities (or any other criterion). (2) Remapping of quantities between old grid and new grid. Original module written by Laurent White, 2008.06.09.

Data Types

type  ale_cs
 ALE control structure. More...
 

Functions/Subroutines

subroutine, public ale_init (param_file, GV, max_depth, CS)
 This routine is typically called (from initialize_MOM in file MOM.F90) before the main time integration loop to initialize the regridding stuff. We read the MOM_input file to register the values of different regridding/remapping parameters. More...
 
subroutine, public ale_register_diags (Time, G, diag, C_p, Reg, CS)
 Initialize diagnostics for the ALE module. More...
 
subroutine, public adjustgridforintegrity (CS, G, GV, h)
 Crudely adjust (initial) grid for integrity. This routine is typically called (from initialize_MOM in file MOM.F90) before the main time integration loop to initialize the regridding stuff. We read the MOM_input file to register the values of different regridding/remapping parameters. More...
 
subroutine, public ale_end (CS)
 End of regridding (memory deallocation). This routine is typically called (from MOM_end in file MOM.F90) after the main time integration loop to deallocate the regridding stuff. More...
 
subroutine, public ale_main (G, GV, h, u, v, tv, Reg, CS, dt, frac_shelf_h)
 Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. More...
 
subroutine, public ale_main_offline (G, GV, h, tv, Reg, CS, dt)
 Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. More...
 
subroutine, public ale_offline_inputs (CS, G, GV, h, tv, Reg, uhtr, vhtr, Kd, debug)
 Regrid/remap stored fields used for offline tracer integrations. These input fields are assumed to have the same layer thicknesses at the end of the last offline interval (which should be a Zstar grid). This routine builds a grid on the runtime specified vertical coordinate. More...
 
subroutine, public ale_offline_tracer_final (G, GV, h, tv, h_target, Reg, CS)
 Remaps all tracers from h onto h_target. This is intended to be called when tracers are done offline. In the case where transports don't quite conserve, we still want to make sure that layer thicknesses offline do not drift too far away from the online model. More...
 
subroutine check_grid (G, GV, h, threshold)
 Check grid for negative thicknesses. More...
 
subroutine, public ale_build_grid (G, GV, regridCS, remapCS, h, tv, debug, frac_shelf_h)
 Generates new grid. More...
 
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 calculation algorithm. More...
 
subroutine remap_all_state_vars (CS_remapping, CS_ALE, G, GV, h_old, h_new, Reg, dxInterface, u, v, debug, dt)
 This routine takes care of remapping all variable between the old and the new grids. When velocity components need to be remapped, thicknesses at velocity points are taken to be arithmetic averages of tracer thicknesses. This routine is called during initialization of the model at time=0, to remap initiali conditions to the model grid. It is also called during a time step to update the state. More...
 
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 dimensioned as a model array with GVke layers while h_src can have an arbitrary number of layers specified by nk_src. More...
 
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 piecewise linear method) reconstruction, this routine determines the edge values for the salinity and temperature within each layer. These edge values are returned and are used to compute the pressure gradient (by computing the densities). More...
 
subroutine, public pressure_gradient_ppm (CS, S_t, S_b, T_t, T_b, G, GV, tv, h)
 Use ppm reconstruction for pressure gradient (determine edge values) By using a PPM (limited piecewise linear method) reconstruction, this routine determines the edge values for the salinity and temperature within each layer. These edge values are returned and are used to compute the pressure gradient (by computing the densities). More...
 
logical function, public usepressurereconstruction (CS)
 pressure reconstruction logical More...
 
integer function, public pressurereconstructionscheme (CS)
 pressure reconstruction integer More...
 
subroutine, public ale_initregridding (GV, max_depth, param_file, mdl, regridCS)
 Initializes regridding for the main ALE algorithm. More...
 
real function, dimension(cs%nk+1), public ale_getcoordinate (CS)
 Query the target coordinate interfaces positions. More...
 
character(len=20) function, public ale_getcoordinateunits (CS)
 Query the target coordinate units. More...
 
logical function, public ale_remap_init_conds (CS)
 Returns true if initial conditions should be regridded and remapped. More...
 
subroutine, public ale_update_regrid_weights (dt, CS)
 Updates the weights for time filtering the new grid generated in regridding. More...
 
subroutine, public ale_updateverticalgridtype (CS, GV)
 Update the vertical grid type with ALE information. This subroutine sets information in the verticalGrid_type to be consistent with the use of ALE mode. More...
 
subroutine, public ale_writecoordinatefile (CS, GV, directory)
 Write the vertical coordinate information into a file. This subroutine writes out a file containing any available data related to the vertical grid used by the MOM ocean model when in ALE mode. More...
 
subroutine, public ale_initthicknesstocoord (CS, G, GV, h)
 Set h to coordinate values for fixed coordinate systems. More...
 

Function/Subroutine Documentation

◆ adjustgridforintegrity()

subroutine, public mom_ale::adjustgridforintegrity ( type(ale_cs), pointer  CS,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(inout)  h 
)

Crudely adjust (initial) grid for integrity. This routine is typically called (from initialize_MOM in file MOM.F90) before the main time integration loop to initialize the regridding stuff. We read the MOM_input file to register the values of different regridding/remapping parameters.

Parameters
csRegridding parameters and options
[in]gOcean grid informations
[in]gvOcean vertical grid structure
[in,out]hCurrent 3D grid thickness that are to be adjusted (m or Pa)

Definition at line 347 of file MOM_ALE.F90.

347  type(ale_cs), pointer :: cs !< Regridding parameters and options
348  type(ocean_grid_type), intent(in) :: g !< Ocean grid informations
349  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
350  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Current 3D grid thickness that
351  !! are to be adjusted (m or Pa)
352  call inflate_vanished_layers_old( cs%regridCS, g, gv, h(:,:,:) )
353 

◆ ale_build_grid()

subroutine, public mom_ale::ale_build_grid ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(regridding_cs), intent(in)  regridCS,
type(remapping_cs), intent(in)  remapCS,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  h,
type(thermo_var_ptrs), intent(inout)  tv,
logical, intent(in), optional  debug,
real, dimension(:,:), optional, pointer  frac_shelf_h 
)

Generates new grid.

Parameters
[in]gOcean grid structure
[in]gvOcean vertical grid structure
[in]regridcsRegridding parameters and options
[in]remapcsRemapping parameters and options
[in,out]tvThermodynamical variable structure
[in,out]hCurrent 3D grid obtained after the last time step (m or Pa)
[in]debugIf true, show the call tree
frac_shelf_hFractional ice shelf coverage

Definition at line 648 of file MOM_ALE.F90.

References mom_error_handler::calltree_enter(), and mom_error_handler::calltree_leave().

Referenced by mom_state_initialization::mom_temp_salt_initialize_from_z().

648  type(ocean_grid_type), intent(in) :: g !< Ocean grid structure
649  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
650  type(regridding_cs), intent(in) :: regridcs !< Regridding parameters and options
651  type(remapping_cs), intent(in) :: remapcs !< Remapping parameters and options
652  type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamical variable structure
653  real, dimension(SZI_(G),SZJ_(G), SZK_(GV)), intent(inout) :: h !< Current 3D grid obtained after the last time step (m or Pa)
654  logical, optional, intent(in) :: debug !< If true, show the call tree
655  real, dimension(:,:), optional, pointer :: frac_shelf_h !< Fractional ice shelf coverage
656  ! Local variables
657  integer :: nk, i, j, k
658  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)+1) :: dzregrid ! The change in grid interface positions
659  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)) :: h_new ! The new grid thicknesses
660  logical :: show_call_tree, use_ice_shelf
661 
662  show_call_tree = .false.
663  if (present(debug)) show_call_tree = debug
664  if (show_call_tree) call calltree_enter("ALE_build_grid(), MOM_ALE.F90")
665  use_ice_shelf = .false.
666  if (present(frac_shelf_h)) then
667  if (associated(frac_shelf_h)) use_ice_shelf = .true.
668  endif
669 
670  ! Build new grid. The new grid is stored in h_new. The old grid is h.
671  ! Both are needed for the subsequent remapping of variables.
672  if (use_ice_shelf) then
673  call regridding_main( remapcs, regridcs, g, gv, h, tv, h_new, dzregrid, frac_shelf_h )
674  else
675  call regridding_main( remapcs, regridcs, g, gv, h, tv, h_new, dzregrid )
676  endif
677 
678  ! Override old grid with new one. The new grid 'h_new' is built in
679  ! one of the 'build_...' routines above.
680 !$OMP parallel do default(none) shared(G,h,h_new)
681  do j = g%jsc,g%jec ; do i = g%isc,g%iec
682  if (g%mask2dT(i,j)>0.) h(i,j,:) = h_new(i,j,:)
683  enddo ; enddo
684 
685  if (show_call_tree) call calltree_leave("ALE_build_grid()")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ale_end()

subroutine, public mom_ale::ale_end ( type(ale_cs), pointer  CS)

End of regridding (memory deallocation). This routine is typically called (from MOM_end in file MOM.F90) after the main time integration loop to deallocate the regridding stuff.

Parameters
csmodule control structure

Definition at line 361 of file MOM_ALE.F90.

361  type(ale_cs), pointer :: cs !< module control structure
362 
363  ! Deallocate memory used for the regridding
364  call end_remapping( cs%remapCS )
365  call end_regridding( cs%regridCS )
366 
367  deallocate(cs)
368 

◆ ale_getcoordinate()

real function, dimension(cs%nk+1), public mom_ale::ale_getcoordinate ( type(ale_cs), pointer  CS)

Query the target coordinate interfaces positions.

Parameters
csmodule control structure

Definition at line 1208 of file MOM_ALE.F90.

1208  type(ale_cs), pointer :: cs !< module control structure
1209 
1210  real, dimension(CS%nk+1) :: ale_getcoordinate
1211  ale_getcoordinate(:) = getcoordinateinterfaces( cs%regridCS )
1212 

◆ ale_getcoordinateunits()

character(len=20) function, public mom_ale::ale_getcoordinateunits ( type(ale_cs), pointer  CS)

Query the target coordinate units.

Parameters
csmodule control structure

Definition at line 1218 of file MOM_ALE.F90.

1218  type(ale_cs), pointer :: cs !< module control structure
1219 
1220  character(len=20) :: ale_getcoordinateunits
1221 
1222  ale_getcoordinateunits = getcoordinateunits( cs%regridCS )
1223 

◆ ale_init()

subroutine, public mom_ale::ale_init ( type(param_file_type), intent(in)  param_file,
type(verticalgrid_type), intent(in)  GV,
real, intent(in)  max_depth,
type(ale_cs), pointer  CS 
)

This routine is typically called (from initialize_MOM in file MOM.F90) before the main time integration loop to initialize the regridding stuff. We read the MOM_input file to register the values of different regridding/remapping parameters.

Parameters
[in]param_fileParameter file
[in]gvOcean vertical grid structure
[in]max_depthThe maximum depth of the ocean, in m.
csModule control structure

Definition at line 138 of file MOM_ALE.F90.

References ale_initregridding(), mom_error_handler::calltree_enter(), mom_error_handler::calltree_leave(), and regrid_defs::pressure_reconstruction_plm.

138  type(param_file_type), intent(in) :: param_file !< Parameter file
139  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
140  real, intent(in) :: max_depth !< The maximum depth of the ocean, in m.
141  type(ale_cs), pointer :: cs !< Module control structure
142 
143  ! Local variables
144  real, dimension(:), allocatable :: dz
145  character(len=40) :: mdl = "MOM_ALE" ! This module's name.
146  character(len=80) :: string ! Temporary strings
147  real :: filter_shallow_depth, filter_deep_depth
148  logical :: check_reconstruction
149  logical :: check_remapping
150  logical :: force_bounds_in_subcell
151  logical :: local_logical
152 
153  if (associated(cs)) then
154  call mom_error(warning, "ALE_init called with an associated "// &
155  "control structure.")
156  return
157  endif
158  allocate(cs)
159 
160  cs%show_call_tree = calltree_showquery()
161  if (cs%show_call_tree) call calltree_enter("ALE_init(), MOM_ALE.F90")
162 
163  ! --- BOUNDARY EXTRAPOLATION --
164  ! This sets whether high-order (rather than PCM) reconstruction schemes
165  ! should be used within boundary cells
166  call get_param(param_file, mdl, "BOUNDARY_EXTRAPOLATION_PRESSURE", &
167  cs%boundary_extrapolation_for_pressure, &
168  "When defined, the reconstruction is extrapolated\n"//&
169  "within boundary cells rather than assume PCM for the.\n"//&
170  "calculation of pressure. e.g. if PPM is used, a\n"//&
171  "PPM reconstruction will also be used within\n"//&
172  "boundary cells.", default=.true.)
173 
174  ! --- PRESSURE GRADIENT CALCULATION ---
175  call get_param(param_file, mdl, "RECONSTRUCT_FOR_PRESSURE", &
176  cs%reconstructForPressure , &
177  "If True, use vertical reconstruction of T/S within\n"//&
178  "the integrals of teh FV pressure gradient calculation.\n"//&
179  "If False, use the constant-by-layer algorithm.\n"//&
180  "By default, this is True when using ALE and False otherwise.", &
181  default=.true. )
182 
183  call get_param(param_file, mdl, "PRESSURE_RECONSTRUCTION_SCHEME", &
184  cs%pressureReconstructionScheme, &
185  "Type of vertical reconstruction of T/S to use in integrals\n"//&
186  "within the FV pressure gradient calculation."//&
187  " 1: PLM reconstruction.\n"//&
188  " 2: PPM reconstruction.", default=pressure_reconstruction_plm)
189 
190  call get_param(param_file, mdl, "REMAP_UV_USING_OLD_ALG", &
191  cs%remap_uv_using_old_alg, &
192  "If true, uses the old remapping-via-a-delta-z method for\n"//&
193  "remapping u and v. If false, uses the new method that remaps\n"//&
194  "between grids described by an old and new thickness.", &
195  default=.true.)
196 
197  ! Initialize and configure regridding
198  call ale_initregridding( gv, max_depth, param_file, mdl, cs%regridCS)
199 
200  ! Initialize and configure remapping
201  call get_param(param_file, mdl, "REMAPPING_SCHEME", string, &
202  "This sets the reconstruction scheme used\n"//&
203  "for vertical remapping for all variables.\n"//&
204  "It can be one of the following schemes:\n"//&
205  trim(remappingschemesdoc), default=remappingdefaultscheme)
206  call get_param(param_file, mdl, "FATAL_CHECK_RECONSTRUCTIONS", check_reconstruction, &
207  "If true, cell-by-cell reconstructions are checked for\n"//&
208  "consistency and if non-monotonicty or an inconsistency is\n"//&
209  "detected then a FATAL error is issued.", default=.false.)
210  call get_param(param_file, mdl, "FATAL_CHECK_REMAPPING", check_remapping, &
211  "If true, the results of remapping are checked for\n"//&
212  "conservation and new extrema and if an inconsistency is\n"//&
213  "detected then a FATAL error is issued.", default=.false.)
214  call get_param(param_file, mdl, "REMAP_BOUND_INTERMEDIATE_VALUES", force_bounds_in_subcell, &
215  "If true, the values on the intermediate grid used for remapping\n"//&
216  "are forced to be bounded, which might not be the case due to\n"//&
217  "round off.", default=.false.)
218  call initialize_remapping( cs%remapCS, string, &
219  boundary_extrapolation=.false., &
220  check_reconstruction=check_reconstruction, &
221  check_remapping=check_remapping, &
222  force_bounds_in_subcell=force_bounds_in_subcell)
223 
224  call get_param(param_file, mdl, "REMAP_AFTER_INITIALIZATION", cs%remap_after_initialization, &
225  "If true, applies regridding and remapping immediately after\n"//&
226  "initialization so that the state is ALE consistent. This is a\n"//&
227  "legacy step and should not be needed if the initialization is\n"//&
228  "consistent with the coordinate mode.", default=.true.)
229 
230  call get_param(param_file, mdl, "REGRID_TIME_SCALE", cs%regrid_time_scale, &
231  "The time-scale used in blending between the current (old) grid\n"//&
232  "and the target (new) grid. A short time-scale favors the target\n"//&
233  "grid (0. or anything less than DT_THERM) has no memory of the old\n"//&
234  "grid. A very long time-scale makes the model more Lagrangian.", &
235  units="s", default=0.)
236  call get_param(param_file, mdl, "REGRID_FILTER_SHALLOW_DEPTH", filter_shallow_depth, &
237  "The depth above which no time-filtering is applied. Above this depth\n"//&
238  "final grid exactly matches the target (new) grid.", units="m", default=0.)
239  call get_param(param_file, mdl, "REGRID_FILTER_DEEP_DEPTH", filter_deep_depth, &
240  "The depth below which full time-filtering is applied with time-scale\n"//&
241  "REGRID_TIME_SCALE. Between depths REGRID_FILTER_SHALLOW_DEPTH and\n"//&
242  "REGRID_FILTER_SHALLOW_DEPTH the filter wieghts adopt a cubic profile.", &
243  units="m", default=0.)
244  call set_regrid_params(cs%regridCS, depth_of_time_filter_shallow=filter_shallow_depth*gv%m_to_H, &
245  depth_of_time_filter_deep=filter_deep_depth*gv%m_to_H)
246  call get_param(param_file, mdl, "REGRID_USE_OLD_DIRECTION", local_logical, &
247  "If true, the regridding ntegrates upwards from the bottom for\n"//&
248  "interface positions, much as the main model does. If false\n"//&
249  "regridding integrates downward, consistant with the remapping\n"//&
250  "code.", default=.true., do_not_log=.true.)
251  call set_regrid_params(cs%regridCS, integrate_downward_for_e=.not.local_logical)
252 
253  ! Keep a record of values for subsequent queries
254  cs%nk = gv%ke
255 
256  if (cs%show_call_tree) call calltree_leave("ALE_init()")
Here is the call graph for this function:

◆ ale_initregridding()

subroutine, public mom_ale::ale_initregridding ( type(verticalgrid_type), intent(in)  GV,
real, intent(in)  max_depth,
type(param_file_type), intent(in)  param_file,
character(len=*), intent(in)  mdl,
type(regridding_cs), intent(out)  regridCS 
)

Initializes regridding for the main ALE algorithm.

Parameters
[in]gvOcean vertical grid structure
[in]max_depthThe maximum depth of the ocean, in m.
[in]param_fileparameter file
[in]mdlName of calling module
[out]regridcsRegridding parameters and work arrays

Definition at line 1188 of file MOM_ALE.F90.

Referenced by ale_init().

1188  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
1189  real, intent(in) :: max_depth !< The maximum depth of the ocean, in m.
1190  type(param_file_type), intent(in) :: param_file !< parameter file
1191  character(len=*), intent(in) :: mdl !< Name of calling module
1192  type(regridding_cs), intent(out) :: regridcs !< Regridding parameters and work arrays
1193  ! Local variables
1194  character(len=30) :: coord_mode
1195 
1196  call get_param(param_file, mdl, "REGRIDDING_COORDINATE_MODE", coord_mode, &
1197  "Coordinate mode for vertical regridding.\n"//&
1198  "Choose among the following possibilities:\n"//&
1199  trim(regriddingcoordinatemodedoc), &
1200  default=default_coordinate_mode, fail_if_missing=.true.)
1201 
1202  call initialize_regridding(regridcs, gv, max_depth, param_file, mdl, coord_mode, '', '')
1203 
Here is the caller graph for this function:

◆ ale_initthicknesstocoord()

subroutine, public mom_ale::ale_initthicknesstocoord ( type(ale_cs), intent(inout)  CS,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(out)  h 
)

Set h to coordinate values for fixed coordinate systems.

Parameters
[in,out]csmodule control structure
[in]gmodule grid structure
[in]gvOcean vertical grid structure
[out]hlayer thickness

Definition at line 1307 of file MOM_ALE.F90.

References mom_regridding::getstaticthickness().

1307  type(ale_cs), intent(inout) :: cs !< module control structure
1308  type(ocean_grid_type), intent(in) :: g !< module grid structure
1309  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
1310  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: h !< layer thickness
1311 
1312  ! Local variables
1313  integer :: i, j, k
1314 
1315  do j = g%jsd,g%jed ; do i = g%isd,g%ied
1316  h(i,j,:) = getstaticthickness( cs%regridCS, 0., g%bathyT(i,j) )
1317  enddo; enddo
1318 
Here is the call graph for this function:

◆ ale_main()

subroutine, public mom_ale::ale_main ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(inout)  h,
real, dimension(szib_(g),szj_(g),szk_(gv)), intent(inout)  u,
real, dimension(szi_(g),szjb_(g),szk_(gv)), intent(inout)  v,
type(thermo_var_ptrs), intent(inout)  tv,
type(tracer_registry_type), pointer  Reg,
type(ale_cs), pointer  CS,
real, intent(in), optional  dt,
real, dimension(:,:), optional, pointer  frac_shelf_h 
)

Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system.

Parameters
[in]gOcean grid informations
[in]gvOcean vertical grid structure
[in,out]hCurrent 3D grid obtained after last time step (m or Pa)
[in,out]uZonal velocity field (m/s)
[in,out]vMeridional velocity field (m/s)
[in,out]tvThermodynamic variable structure
regTracer registry structure
csRegridding parameters and options
[in]dtTime step between calls to ALE_main()
frac_shelf_hFractional ice shelf coverage

Definition at line 376 of file MOM_ALE.F90.

References ale_update_regrid_weights(), mom_error_handler::calltree_enter(), mom_error_handler::calltree_leave(), mom_error_handler::calltree_waypoint(), check_grid(), and remap_all_state_vars().

376  type(ocean_grid_type), intent(in) :: g !< Ocean grid informations
377  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
378  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Current 3D grid obtained after last time step (m or Pa)
379  real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), intent(inout) :: u !< Zonal velocity field (m/s)
380  real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), intent(inout) :: v !< Meridional velocity field (m/s)
381  type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamic variable structure
382  type(tracer_registry_type), pointer :: reg !< Tracer registry structure
383  type(ale_cs), pointer :: cs !< Regridding parameters and options
384  real, optional, intent(in) :: dt !< Time step between calls to ALE_main()
385  real, dimension(:,:), optional, pointer :: frac_shelf_h !< Fractional ice shelf coverage
386  ! Local variables
387  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)+1) :: dzregrid ! The change in grid interface positions
388  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h_new ! New 3D grid obtained after last time step (m or Pa)
389  integer :: nk, i, j, k, isc, iec, jsc, jec
390  logical :: ice_shelf
391 
392  nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
393 
394  ice_shelf = .false.
395  if (present(frac_shelf_h)) then
396  if (associated(frac_shelf_h)) ice_shelf = .true.
397  endif
398 
399  if (cs%show_call_tree) call calltree_enter("ALE_main(), MOM_ALE.F90")
400 
401  if (present(dt)) then
402  call ale_update_regrid_weights( dt, cs )
403  endif
404  dzregrid(:,:,:) = 0.0
405 
406  ! Build new grid. The new grid is stored in h_new. The old grid is h.
407  ! Both are needed for the subsequent remapping of variables.
408  if (ice_shelf) then
409  call regridding_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h_new, dzregrid, frac_shelf_h)
410  else
411  call regridding_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h_new, dzregrid)
412  endif
413 
414  call check_grid( g, gv, h, 0. )
415 
416  if (cs%show_call_tree) call calltree_waypoint("new grid generated (ALE_main)")
417 
418  ! Remap all variables from old grid h onto new grid h_new
419 
420  call remap_all_state_vars( cs%remapCS, cs, g, gv, h, h_new, reg, -dzregrid, &
421  u, v, cs%show_call_tree, dt )
422 
423  if (cs%show_call_tree) call calltree_waypoint("state remapped (ALE_main)")
424 
425  ! Override old grid with new one. The new grid 'h_new' is built in
426  ! one of the 'build_...' routines above.
427 !$OMP parallel do default(none) shared(isc,iec,jsc,jec,nk,h,h_new,CS)
428  do k = 1,nk
429  do j = jsc-1,jec+1 ; do i = isc-1,iec+1
430  h(i,j,k) = h_new(i,j,k)
431  enddo ; enddo
432  enddo
433 
434  if (cs%show_call_tree) call calltree_leave("ALE_main()")
435 
436  if (cs%id_dzRegrid>0 .and. present(dt)) call post_data(cs%id_dzRegrid, dzregrid, cs%diag)
437 
438 
Here is the call graph for this function:

◆ ale_main_offline()

subroutine, public mom_ale::ale_main_offline ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(inout)  h,
type(thermo_var_ptrs), intent(inout)  tv,
type(tracer_registry_type), pointer  Reg,
type(ale_cs), pointer  CS,
real, intent(in), optional  dt 
)

Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system.

Parameters
[in]gOcean grid informations
[in]gvOcean vertical grid structure
[in,out]hCurrent 3D grid obtained after last time step (m or Pa)
[in,out]tvThermodynamic variable structure
regTracer registry structure
csRegridding parameters and options
[in]dtTime step between calls to ALE_main()

Definition at line 446 of file MOM_ALE.F90.

References ale_update_regrid_weights(), mom_error_handler::calltree_enter(), mom_error_handler::calltree_leave(), mom_error_handler::calltree_waypoint(), check_grid(), and remap_all_state_vars().

Referenced by mom_offline_main::offline_advection_ale().

446  type(ocean_grid_type), intent(in) :: g !< Ocean grid informations
447  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
448  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Current 3D grid obtained after last time step (m or Pa)
449  type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamic variable structure
450  type(tracer_registry_type), pointer :: reg !< Tracer registry structure
451  type(ale_cs), pointer :: cs !< Regridding parameters and options
452  real, optional, intent(in) :: dt !< Time step between calls to ALE_main()
453  ! Local variables
454  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)+1) :: dzregrid ! The change in grid interface positions
455  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h_new ! New 3D grid obtained after last time step (m or Pa)
456  integer :: nk, i, j, k, isc, iec, jsc, jec
457 
458  nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
459 
460  if (cs%show_call_tree) call calltree_enter("ALE_main_offline(), MOM_ALE.F90")
461 
462  if (present(dt)) then
463  call ale_update_regrid_weights( dt, cs )
464  endif
465  dzregrid(:,:,:) = 0.0
466 
467  ! Build new grid. The new grid is stored in h_new. The old grid is h.
468  ! Both are needed for the subsequent remapping of variables.
469  call regridding_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h_new, dzregrid )
470 
471  call check_grid( g, gv, h, 0. )
472 
473  if (cs%show_call_tree) call calltree_waypoint("new grid generated (ALE_main)")
474 
475  ! Remap all variables from old grid h onto new grid h_new
476 
477  call remap_all_state_vars( cs%remapCS, cs, g, gv, h, h_new, reg, debug=cs%show_call_tree, dt=dt )
478 
479  if (cs%show_call_tree) call calltree_waypoint("state remapped (ALE_main)")
480 
481  ! Override old grid with new one. The new grid 'h_new' is built in
482  ! one of the 'build_...' routines above.
483 !$OMP parallel do default(none) shared(isc,iec,jsc,jec,nk,h,h_new,CS)
484  do k = 1,nk
485  do j = jsc-1,jec+1 ; do i = isc-1,iec+1
486  h(i,j,k) = h_new(i,j,k)
487  enddo ; enddo
488  enddo
489 
490  if (cs%show_call_tree) call calltree_leave("ALE_main()")
491  if (cs%id_dzRegrid>0 .and. present(dt)) call post_data(cs%id_dzRegrid, dzregrid, cs%diag)
492 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ale_offline_inputs()

subroutine, public mom_ale::ale_offline_inputs ( type(ale_cs), pointer  CS,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension(szi_(g),szj_(g),szk_(gv)), intent(inout)  h,
type(thermo_var_ptrs), intent(inout)  tv,
type(tracer_registry_type), pointer  Reg,
real, dimension(szib_(g),szj_(g),szk_(gv)), intent(inout)  uhtr,
real, dimension(szi_(g),szjb_(g),szk_(gv)), intent(inout)  vhtr,
real, dimension(szi_(g),szj_(g),szk_(gv)+1), intent(inout)  Kd,
logical, intent(in)  debug 
)

Regrid/remap stored fields used for offline tracer integrations. These input fields are assumed to have the same layer thicknesses at the end of the last offline interval (which should be a Zstar grid). This routine builds a grid on the runtime specified vertical coordinate.

Parameters
csRegridding parameters and options
[in]gOcean grid informations
[in]gvOcean vertical grid structure
[in,out]hLayer thicknesses
[in,out]tvThermodynamic variable structure
regTracer registry structure
[in,out]uhtrZonal mass fluxes
[in,out]vhtrMeridional mass fluxes
[in,out]kdInput diffusivites
[in]debugIf true, then turn checksums

Definition at line 499 of file MOM_ALE.F90.

References ale_remap_scalar(), mom_error_handler::calltree_leave(), mom_error_handler::calltree_waypoint(), mom_debugging::check_column_integrals(), check_grid(), mom_diag_vkernels::interpolate_column(), mom_tracer_registry::mom_tracer_chkinv(), mom_diag_vkernels::reintegrate_column(), and remap_all_state_vars().

499  type(ale_cs), pointer :: cs !< Regridding parameters and options
500  type(ocean_grid_type), intent(in ) :: g !< Ocean grid informations
501  type(verticalgrid_type), intent(in ) :: gv !< Ocean vertical grid structure
502  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Layer thicknesses
503  type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamic variable structure
504  type(tracer_registry_type), pointer :: reg !< Tracer registry structure
505  real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), intent(inout) :: uhtr !< Zonal mass fluxes
506  real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), intent(inout) :: vhtr !< Meridional mass fluxes
507  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1), intent(inout) :: kd !< Input diffusivites
508  logical, intent(in ) :: debug !< If true, then turn checksums
509  ! Local variables
510  integer :: nk, i, j, k, isc, iec, jsc, jec
511  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)) :: h_new ! Layer thicknesses after regridding
512  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)+1) :: dzregrid ! The change in grid interface positions
513  real, dimension(SZK_(GV)) :: h_src
514  real, dimension(SZK_(GV)) :: h_dest, uh_dest
515  real, dimension(SZK_(GV)) :: temp_vec
516 
517  nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
518  dzregrid(:,:,:) = 0.0
519  h_new(:,:,:) = 0.0
520 
521  if (debug) call mom_tracer_chkinv("Before ALE_offline_inputs", g, h, reg%Tr, reg%ntr)
522 
523  ! Build new grid from the Zstar state onto the requested vertical coordinate. The new grid is stored
524  ! in h_new. The old grid is h. Both are needed for the subsequent remapping of variables. Convective
525  ! adjustment right now is not used because it is unclear what to do with vanished layers
526  call regridding_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h_new, dzregrid, conv_adjust = .false. )
527  call check_grid( g, gv, h_new, 0. )
528  if (cs%show_call_tree) call calltree_waypoint("new grid generated (ALE_offline_inputs)")
529 
530  ! Remap all variables from old grid h onto new grid h_new
531  call remap_all_state_vars( cs%remapCS, cs, g, gv, h, h_new, reg, debug=cs%show_call_tree )
532  if (cs%show_call_tree) call calltree_waypoint("state remapped (ALE_inputs)")
533 
534  ! Reintegrate mass transports from Zstar to the offline vertical coordinate
535  do j=jsc,jec ; do i=g%iscB,g%iecB
536  if (g%mask2dCu(i,j)>0.) then
537  h_src(:) = 0.5 * (h(i,j,:) + h(i+1,j,:))
538  h_dest(:) = 0.5 * (h_new(i,j,:) + h_new(i+1,j,:))
539  call reintegrate_column(nk, h_src, uhtr(i,j,:), nk, h_dest, 0., temp_vec)
540  uhtr(i,j,:) = temp_vec
541  endif
542  enddo ; enddo
543  do j=g%jscB,g%jecB ; do i=isc,iec
544  if (g%mask2dCv(i,j)>0.) then
545  h_src(:) = 0.5 * (h(i,j,:) + h(i,j+1,:))
546  h_dest(:) = 0.5 * (h_new(i,j,:) + h_new(i,j+1,:))
547  call reintegrate_column(nk, h_src, vhtr(i,j,:), nk, h_dest, 0., temp_vec)
548  vhtr(i,j,:) = temp_vec
549  endif
550  enddo ; enddo
551 
552  do j = jsc,jec ; do i=isc,iec
553  if (g%mask2dT(i,j)>0.) then
554  if (check_column_integrals(nk, h_src, nk, h_dest)) then
555  call mom_error(fatal, "ALE_offline_inputs: Kd interpolation columns do not match")
556  endif
557  call interpolate_column(nk, h(i,j,:), kd(i,j,:), nk, h_new(i,j,:), 0., kd(i,j,:))
558  endif
559  enddo ; enddo;
560 
561  call ale_remap_scalar(cs%remapCS, g, gv, nk, h, tv%T, h_new, tv%T)
562  call ale_remap_scalar(cs%remapCS, g, gv, nk, h, tv%S, h_new, tv%S)
563 
564  if (debug) call mom_tracer_chkinv("After ALE_offline_inputs", g, h_new, reg%Tr, reg%ntr)
565 
566  ! Copy over the new layer thicknesses
567  do k = 1,nk ; do j = jsc-1,jec+1 ; do i = isc-1,iec+1
568  h(i,j,k) = h_new(i,j,k)
569  enddo ; enddo ; enddo
570 
571  if (cs%show_call_tree) call calltree_leave("ALE_offline_inputs()")
Here is the call graph for this function:

◆ ale_offline_tracer_final()

subroutine, public mom_ale::ale_offline_tracer_final ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  h,
type(thermo_var_ptrs), intent(inout)  tv,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  h_target,
type(tracer_registry_type), pointer  Reg,
type(ale_cs), pointer  CS 
)

Remaps all tracers from h onto h_target. This is intended to be called when tracers are done offline. In the case where transports don't quite conserve, we still want to make sure that layer thicknesses offline do not drift too far away from the online model.

Parameters
[in]gOcean grid informations
[in]gvOcean vertical grid structure
[in,out]hCurrent 3D grid obtained after last time step (m or Pa)
[in,out]tvThermodynamic variable structure
[in,out]h_targetCurrent 3D grid obtained after last time step (m or Pa)
regTracer registry structure
csRegridding parameters and options

Definition at line 579 of file MOM_ALE.F90.

References mom_error_handler::calltree_enter(), mom_error_handler::calltree_leave(), mom_error_handler::calltree_waypoint(), check_grid(), and remap_all_state_vars().

Referenced by mom::step_offline().

579  type(ocean_grid_type), intent(in) :: g !< Ocean grid informations
580  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
581  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h !< Current 3D grid obtained after
582  !! last time step (m or Pa)
583  type(thermo_var_ptrs), intent(inout) :: tv !< Thermodynamic variable structure
584  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: h_target !< Current 3D grid obtained after
585  !! last time step (m or Pa)
586  type(tracer_registry_type), pointer :: reg !< Tracer registry structure
587  type(ale_cs), pointer :: cs !< Regridding parameters and options
588  ! Local variables
589 
590  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)+1) :: dzregrid !< The change in grid interface positions
591  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)) :: h_new !< Regridded target thicknesses
592  integer :: nk, i, j, k, isc, iec, jsc, jec
593 
594  nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
595 
596  if (cs%show_call_tree) call calltree_enter("ALE_offline_tracer_final(), MOM_ALE.F90")
597  ! Need to make sure that h_target is consistent with the current offline ALE confiuration
598  call regridding_main( cs%remapCS, cs%regridCS, g, gv, h_target, tv, h_new, dzregrid )
599  call check_grid( g, gv, h_target, 0. )
600 
601 
602  if (cs%show_call_tree) call calltree_waypoint("Source and target grids checked (ALE_offline_tracer_final)")
603 
604  ! Remap all variables from old grid h onto new grid h_new
605 
606  call remap_all_state_vars( cs%remapCS, cs, g, gv, h, h_new, reg, debug=cs%show_call_tree )
607 
608  if (cs%show_call_tree) call calltree_waypoint("state remapped (ALE_offline_tracer_final)")
609 
610  ! Override old grid with new one. The new grid 'h_new' is built in
611  ! one of the 'build_...' routines above.
612  !$OMP parallel do default(shared)
613  do k = 1,nk
614  do j = jsc-1,jec+1 ; do i = isc-1,iec+1
615  h(i,j,k) = h_new(i,j,k)
616  enddo ; enddo
617  enddo
618  if (cs%show_call_tree) call calltree_leave("ALE_offline_tracer_final()")
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ale_register_diags()

subroutine, public mom_ale::ale_register_diags ( type(time_type), intent(in), target  Time,
type(ocean_grid_type), intent(in)  G,
type(diag_ctrl), intent(in), target  diag,
real, intent(in)  C_p,
type(tracer_registry_type), pointer  Reg,
type(ale_cs), pointer  CS 
)

Initialize diagnostics for the ALE module.

Parameters
[in]timeTime structure
[in]gGrid structure
[in]diagDiagnostics control structure
[in]c_pseawater heat capacity (J/(kg deg C))
regTracer registry
csModule control structure

Definition at line 261 of file MOM_ALE.F90.

References mom_diag_mediator::register_diag_field().

261  type(time_type),target, intent(in) :: time !< Time structure
262  type(ocean_grid_type), intent(in) :: g !< Grid structure
263  type(diag_ctrl), target, intent(in) :: diag !< Diagnostics control structure
264  real, intent(in) :: c_p !< seawater heat capacity (J/(kg deg C))
265  type(tracer_registry_type), pointer :: reg !< Tracer registry
266  type(ale_cs), pointer :: cs !< Module control structure
267 
268  integer :: m, ntr, nsize
269 
270  if (associated(reg)) then
271  ntr = reg%ntr
272  else
273  ntr = 0
274  endif
275  nsize = max(1,ntr)
276 
277  cs%diag => diag
278  cs%C_p = c_p
279 
280  allocate(cs%id_tracer_remap_tendency(nsize))
281  allocate(cs%id_Htracer_remap_tendency(nsize))
282  allocate(cs%id_Htracer_remap_tendency_2d(nsize))
283  allocate(cs%do_tendency_diag(nsize))
284  cs%do_tendency_diag(:) = .false.
285  cs%id_tracer_remap_tendency(:) = -1
286  cs%id_Htracer_remap_tendency(:) = -1
287  cs%id_Htracer_remap_tendency_2d(:) = -1
288 
289  cs%id_dzRegrid = register_diag_field('ocean_model','dzRegrid',diag%axesTi,time, &
290  'Change in interface height due to ALE regridding', 'meter')
291 
292  if(ntr > 0) then
293 
294  do m=1,ntr
295  if(trim(reg%Tr(m)%name) == 'T') then
296 
297  cs%id_tracer_remap_tendency(m) = register_diag_field('ocean_model', &
298  trim(reg%Tr(m)%name)//'_tendency_vert_remap', diag%axesTL, time, &
299  'Tendency from vertical remapping for tracer concentration '//trim(reg%Tr(m)%name),&
300  'degC/s')
301 
302  cs%id_Htracer_remap_tendency(m) = register_diag_field('ocean_model',&
303  trim(reg%Tr(m)%name)//'h_tendency_vert_remap', diag%axesTL, time, &
304  'Tendency from vertical remapping for heat', &
305  'W/m2',v_extensive=.true.)
306 
307  cs%id_Htracer_remap_tendency_2d(m) = register_diag_field('ocean_model',&
308  trim(reg%Tr(m)%name)//'h_tendency_vert_remap_2d', diag%axesT1, time, &
309  'Vertical sum of tendency from vertical remapping for heat', &
310  'W/m2')
311 
312  else
313 
314  cs%id_tracer_remap_tendency(m) = register_diag_field('ocean_model', &
315  trim(reg%Tr(m)%name)//'_tendency_vert_remap', diag%axesTL, time, &
316  'Tendency from vertical remapping for tracer concentration '//trim(reg%Tr(m)%name),&
317  'tracer conc / sec')
318 
319  cs%id_Htracer_remap_tendency(m) = register_diag_field('ocean_model', &
320  trim(reg%Tr(m)%name)//'h_tendency_vert_remap', diag%axesTL, time, &
321  'Tendency from vertical remapping for tracer content '//trim(reg%Tr(m)%name),&
322  'kg m-2 s-1',v_extensive=.true.)
323 
324  cs%id_Htracer_remap_tendency_2d(m) = register_diag_field('ocean_model', &
325  trim(reg%Tr(m)%name)//'h_tendency_vert_remap_2d', diag%axesT1, time, &
326  'Vertical sum of tendency from vertical remapping for tracer content '//trim(reg%Tr(m)%name),&
327  'kg m-2 s-1')
328 
329  endif
330 
331  if(cs%id_tracer_remap_tendency(m) > 0) cs%do_tendency_diag(m) = .true.
332  if(cs%id_Htracer_remap_tendency(m) > 0) cs%do_tendency_diag(m) = .true.
333  if(cs%id_Htracer_remap_tendency_2d(m) > 0) cs%do_tendency_diag(m) = .true.
334 
335  enddo ! m loop over tracers
336 
337  endif ! ntr > 0
338 
Here is the call graph for this function:

◆ ale_regrid_accelerated()

subroutine, public mom_ale::ale_regrid_accelerated ( type(ale_cs), intent(in)  CS,
type(ocean_grid_type), intent(inout)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h_orig,
type(thermo_var_ptrs), intent(inout)  tv,
integer, intent(in)  n,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(out)  h_new,
real, dimension( g %isdb: g %iedb, g %jsd: g %jed, gv %ke), intent(inout)  u,
real, dimension( g %isd: g %ied, g %jsdb: g %jedb, gv %ke), intent(inout)  v 
)

For a state-based coordinate, accelerate the process of regridding by repeatedly applying the grid calculation algorithm.

Parameters
[in]csALE control structure
[in,out]gOcean grid
[in]gvVertical grid
[in]h_origOriginal thicknesses
[in,out]tvThermo vars (T/S/EOS)
[in]nNumber of times to regrid
[out]h_newThicknesses after regridding
[in,out]uZonal velocity
[in,out]vMeridional velocity

Definition at line 691 of file MOM_ALE.F90.

References mom_domains::do_group_pass(), and remap_all_state_vars().

Referenced by mom_state_initialization::mom_initialize_state().

691  type(ale_cs), intent(in) :: cs !< ALE control structure
692  type(ocean_grid_type), intent(inout) :: g !< Ocean grid
693  type(verticalgrid_type), intent(in) :: gv !< Vertical grid
694  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_orig !< Original thicknesses
695  type(thermo_var_ptrs), intent(inout) :: tv !< Thermo vars (T/S/EOS)
696  integer, intent(in) :: n !< Number of times to regrid
697  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(out) :: h_new !< Thicknesses after regridding
698  real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), intent(inout) :: u !< Zonal velocity
699  real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), intent(inout) :: v !< Meridional velocity
700 
701  ! Local variables
702  integer :: i, j, k, nz
703  type(thermo_var_ptrs) :: tv_local ! local/intermediate temp/salt
704  type(group_pass_type) :: pass_t_s_h ! group pass if the coordinate has a stencil
705  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)) :: h ! A working copy of layer thickesses
706  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), target :: t, s ! temporary state
707  ! we have to keep track of the total dzInterface if for some reason
708  ! we're using the old remapping algorithm for u/v
709  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1) :: dzinterface, dzinttotal
710 
711  nz = gv%ke
712 
713  ! initial total interface displacement due to successive regridding
714  dzinttotal(:,:,:) = 0.
715 
716  call create_group_pass(pass_t_s_h, t, g%domain)
717  call create_group_pass(pass_t_s_h, s, g%domain)
718  call create_group_pass(pass_t_s_h, h, g%domain)
719 
720  ! copy original temp/salt and set our local tv_pointers to them
721  tv_local = tv
722  t(:,:,:) = tv%T(:,:,:)
723  s(:,:,:) = tv%S(:,:,:)
724  tv_local%T => t
725  tv_local%S => s
726 
727  ! get local copy of thickness
728  h(:,:,:) = h_orig(:,:,:)
729 
730  do k = 1, n
731  call do_group_pass(pass_t_s_h, g%domain)
732 
733  ! generate new grid
734  call regridding_main(cs%remapCS, cs%regridCS, g, gv, h, tv_local, h_new, dzinterface)
735  dzinttotal(:,:,:) = dzinttotal(:,:,:) + dzinterface(:,:,:)
736 
737  ! remap from original grid onto new grid
738  ! we need to use remapping_core because there isn't a tracer registry set up in
739  ! the state initialization routine
740  do j = g%jsc,g%jec ; do i = g%isc,g%iec
741  call remapping_core_h(cs%remapCS, nz, h_orig(i,j,:), tv%S(i,j,:), nz, h_new(i,j,:), tv_local%S(i,j,:))
742  call remapping_core_h(cs%remapCS, nz, h_orig(i,j,:), tv%T(i,j,:), nz, h_new(i,j,:), tv_local%T(i,j,:))
743  enddo ; enddo
744 
745 
746  h(:,:,:) = h_new(:,:,:)
747  enddo
748 
749  ! save the final temp/salt
750  tv%S(:,:,:) = s(:,:,:)
751  tv%T(:,:,:) = t(:,:,:)
752 
753  ! remap velocities
754  call remap_all_state_vars(cs%remapCS, cs, g, gv, h_orig, h_new, null(), dzinttotal, u, v)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ale_remap_init_conds()

logical function, public mom_ale::ale_remap_init_conds ( type(ale_cs), pointer  CS)

Returns true if initial conditions should be regridded and remapped.

Parameters
csmodule control structure

Definition at line 1229 of file MOM_ALE.F90.

1229  type(ale_cs), pointer :: cs !< module control structure
1230 
1231  ale_remap_init_conds = .false.
1232  if (associated(cs)) ale_remap_init_conds = cs%remap_after_initialization

◆ ale_remap_scalar()

subroutine, public mom_ale::ale_remap_scalar ( type(remapping_cs), intent(in)  CS,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
integer, intent(in)  nk_src,
real, dimension( g %isd: g %ied, g %jsd: g %jed,nk_src), intent(in)  h_src,
real, dimension( g %isd: g %ied, g %jsd: g %jed,nk_src), intent(in)  s_src,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h_dst,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  s_dst,
logical, intent(in), optional  all_cells,
logical, intent(in), optional  old_remap 
)

Remaps a single scalar between grids described by thicknesses h_src and h_dst. h_dst must be dimensioned as a model array with GVke layers while h_src can have an arbitrary number of layers specified by nk_src.

Parameters
[in]csRemapping control structure
[in]gOcean grid structure
[in]gvOcean vertical grid structure
[in]nk_srcNumber of levels on source grid
[in]h_srcLevel thickness of source grid (m or Pa)
[in]s_srcScalar on source grid
[in]h_dstLevel thickness of destination grid (m or Pa)
[in,out]s_dstScalar on destination grid
[in]all_cellsIf false, only reconstruct for non-vanished cells. Use all vanished layers otherwise (default).
[in]old_remapIf true, use the old "remapping_core_w" method, otherwise use "remapping_core_h".

Definition at line 970 of file MOM_ALE.F90.

References mom_remapping::dzfromh1h2().

Referenced by ale_offline_inputs(), and mom_state_initialization::mom_temp_salt_initialize_from_z().

970  type(remapping_cs), intent(in) :: cs !< Remapping control structure
971  type(ocean_grid_type), intent(in) :: g !< Ocean grid structure
972  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
973  integer, intent(in) :: nk_src !< Number of levels on source grid
974  real, dimension(SZI_(G),SZJ_(G),nk_src), intent(in) :: h_src !< Level thickness of source grid (m or Pa)
975  real, dimension(SZI_(G),SZJ_(G),nk_src), intent(in) :: s_src !< Scalar on source grid
976  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)),intent(in) :: h_dst !< Level thickness of destination grid (m or Pa)
977  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)),intent(inout) :: s_dst !< Scalar on destination grid
978  logical, optional, intent(in) :: all_cells !< If false, only reconstruct for
979  !! non-vanished cells. Use all vanished
980  !! layers otherwise (default).
981  logical, optional, intent(in) :: old_remap !< If true, use the old "remapping_core_w"
982  !! method, otherwise use "remapping_core_h".
983  ! Local variables
984  integer :: i, j, k, n_points
985  real :: dx(gv%ke+1)
986  logical :: ignore_vanished_layers, use_remapping_core_w
987 
988  ignore_vanished_layers = .false.
989  if (present(all_cells)) ignore_vanished_layers = .not. all_cells
990  use_remapping_core_w = .false.
991  if (present(old_remap)) use_remapping_core_w = old_remap
992  n_points = nk_src
993 
994 !$OMP parallel default(none) shared(CS,G,GV,h_src,s_src,h_dst,s_dst &
995 !$OMP ,ignore_vanished_layers, use_remapping_core_w, nk_src ) &
996 !$OMP firstprivate(n_points,dx)
997 !$OMP do
998  do j = g%jsc,g%jec
999  do i = g%isc,g%iec
1000  if (g%mask2dT(i,j)>0.) then
1001  if (ignore_vanished_layers) then
1002  n_points = 0
1003  do k = 1, nk_src
1004  if (h_src(i,j,k)>0.) n_points = n_points + 1
1005  enddo
1006  s_dst(i,j,:) = 0.
1007  endif
1008  if (use_remapping_core_w) then
1009  call dzfromh1h2( n_points, h_src(i,j,1:n_points), gv%ke, h_dst(i,j,:), dx )
1010  call remapping_core_w(cs, n_points, h_src(i,j,1:n_points), s_src(i,j,1:n_points), gv%ke, dx, s_dst(i,j,:))
1011  else
1012  call remapping_core_h(cs, n_points, h_src(i,j,1:n_points), s_src(i,j,1:n_points), gv%ke, h_dst(i,j,:), s_dst(i,j,:))
1013  endif
1014  else
1015  s_dst(i,j,:) = 0.
1016  endif
1017  enddo
1018  enddo
1019 !$OMP end parallel
1020 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ale_update_regrid_weights()

subroutine, public mom_ale::ale_update_regrid_weights ( real, intent(in)  dt,
type(ale_cs), pointer  CS 
)

Updates the weights for time filtering the new grid generated in regridding.

Parameters
[in]dtTime-step used between ALE calls
csALE control structure

Definition at line 1237 of file MOM_ALE.F90.

Referenced by ale_main(), and ale_main_offline().

1237  real, intent(in) :: dt !< Time-step used between ALE calls
1238  type(ale_cs), pointer :: cs !< ALE control structure
1239  ! Local variables
1240  real :: w ! An implicit weighting estimate.
1241 
1242  if (associated(cs)) then
1243  w = 0.0
1244  if (cs%regrid_time_scale > 0.0) then
1245  w = cs%regrid_time_scale / (cs%regrid_time_scale + dt)
1246  endif
1247  call set_regrid_params(cs%regridCS, old_grid_weight=w)
1248  endif
1249 
Here is the caller graph for this function:

◆ ale_updateverticalgridtype()

subroutine, public mom_ale::ale_updateverticalgridtype ( type(ale_cs), pointer  CS,
type(verticalgrid_type), pointer  GV 
)

Update the vertical grid type with ALE information. This subroutine sets information in the verticalGrid_type to be consistent with the use of ALE mode.

Definition at line 1256 of file MOM_ALE.F90.

1256  type(ale_cs), pointer :: cs ! module control structure
1257  type(verticalgrid_type), pointer :: gv ! vertical grid information
1258 
1259  integer :: nk
1260 
1261  nk = gv%ke
1262  gv%sInterface(1:nk+1) = getcoordinateinterfaces( cs%regridCS )
1263  gv%sLayer(1:nk) = 0.5*( gv%sInterface(1:nk) + gv%sInterface(2:nk+1) )
1264  gv%zAxisUnits = getcoordinateunits( cs%regridCS )
1265  gv%zAxisLongName = getcoordinateshortname( cs%regridCS )
1266  gv%direction = -1 ! Because of ferret in z* mode. Need method to set
1267  ! as function of coordinae mode.
1268 

◆ ale_writecoordinatefile()

subroutine, public mom_ale::ale_writecoordinatefile ( type(ale_cs), pointer  CS,
type(verticalgrid_type), intent(in)  GV,
character(len=*), intent(in)  directory 
)

Write the vertical coordinate information into a file. This subroutine writes out a file containing any available data related to the vertical grid used by the MOM ocean model when in ALE mode.

Parameters
csmodule control structure
[in]gvocean vertical grid structure
[in]directorydirectory for writing grid info

Definition at line 1276 of file MOM_ALE.F90.

References mom_io::create_file().

1276  type(ale_cs), pointer :: cs !< module control structure
1277  type(verticalgrid_type), intent(in) :: gv !< ocean vertical grid structure
1278  character(len=*), intent(in) :: directory !< directory for writing grid info
1279 
1280  character(len=240) :: filepath
1281  type(vardesc) :: vars(2)
1282  type(fieldtype) :: fields(2)
1283  integer :: unit
1284  real :: ds(gv%ke), dsi(gv%ke+1)
1285 
1286  filepath = trim(directory) // trim("Vertical_coordinate")
1287  ds(:) = getcoordinateresolution( cs%regridCS )
1288  dsi(1) = 0.5*ds(1)
1289  dsi(2:gv%ke) = 0.5*( ds(1:gv%ke-1) + ds(2:gv%ke) )
1290  dsi(gv%ke+1) = 0.5*ds(gv%ke)
1291 
1292  vars(1) = var_desc('ds', getcoordinateunits( cs%regridCS ), &
1293  'Layer Coordinate Thickness','1','L','1')
1294  vars(2) = var_desc('ds_interface', getcoordinateunits( cs%regridCS ), &
1295  'Layer Center Coordinate Separation','1','i','1')
1296 
1297  call create_file(unit, trim(filepath), vars, 2, fields, single_file, gv=gv)
1298  call write_field(unit, fields(1), ds)
1299  call write_field(unit, fields(2), dsi)
1300  call close_file(unit)
1301 
Here is the call graph for this function:

◆ check_grid()

subroutine mom_ale::check_grid ( type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h,
real, intent(in)  threshold 
)
private

Check grid for negative thicknesses.

Parameters
[in]gOcean grid structure
[in]gvOcean vertical grid structure
[in]hCurrent 3D grid obtained after the last time step (H units)
[in]thresholdValue below which to flag issues (H units)

Definition at line 623 of file MOM_ALE.F90.

Referenced by ale_main(), ale_main_offline(), ale_offline_inputs(), and ale_offline_tracer_final().

623  type(ocean_grid_type), intent(in) :: g !< Ocean grid structure
624  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
625  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< Current 3D grid obtained after the last time step (H units)
626  real, intent(in) :: threshold !< Value below which to flag issues (H units)
627  ! Local variables
628  integer :: i, j
629 
630  do j = g%jsc,g%jec ; do i = g%isc,g%iec
631  if (g%mask2dT(i,j)>0.) then
632  if (minval(h(i,j,:)) < threshold) then
633  write(0,*) 'check_grid: i,j=',i,j,'h(i,j,:)=',h(i,j,:)
634  if (threshold <= 0.) then
635  call mom_error(fatal,"MOM_ALE, check_grid: negative thickness encountered.")
636  else
637  call mom_error(fatal,"MOM_ALE, check_grid: too tiny thickness encountered.")
638  endif
639  endif
640  endif
641  enddo ; enddo
642 
643 
Here is the caller graph for this function:

◆ pressure_gradient_plm()

subroutine, public mom_ale::pressure_gradient_plm ( type(ale_cs), intent(inout)  CS,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  S_t,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  S_b,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  T_t,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  T_b,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(thermo_var_ptrs), intent(in)  tv,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h 
)

Use plm reconstruction for pressure gradient (determine edge values) By using a PLM (limited piecewise linear method) reconstruction, this routine determines the edge values for the salinity and temperature within each layer. These edge values are returned and are used to compute the pressure gradient (by computing the densities).

Parameters
[in]gocean grid structure
[in]gvOcean vertical grid structure
[in,out]csmodule control structure
[in,out]s_tSalinity at the top edge of each layer
[in,out]s_bSalinity at the bottom edge of each layer
[in,out]t_tTemperature at the top edge of each layer
[in,out]t_bTemperature at the bottom edge of each layer
[in]tvthermodynamics structure
[in]hlayer thickness

Definition at line 1030 of file MOM_ALE.F90.

References plm_functions::plm_boundary_extrapolation(), and plm_functions::plm_reconstruction().

1030  type(ocean_grid_type), intent(in) :: g !< ocean grid structure
1031  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
1032  type(ale_cs), intent(inout) :: cs !< module control structure
1033  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: s_t !< Salinity at the top edge of each layer
1034  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: s_b !< Salinity at the bottom edge of each layer
1035  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: t_t !< Temperature at the top edge of each layer
1036  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: t_b !< Temperature at the bottom edge of each layer
1037  type(thermo_var_ptrs), intent(in) :: tv !< thermodynamics structure
1038  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< layer thickness
1039 
1040  ! Local variables
1041  integer :: i, j, k
1042  real :: htmp(gv%ke)
1043  real :: tmp(gv%ke)
1044  real, dimension(CS%nk,2) :: ppoly_linear_e !Edge value of polynomial
1045  real, dimension(CS%nk,CS%degree_linear+1) :: ppoly_linear_coefficients !Coefficients of polynomial
1046 
1047  ! NOTE: the variables 'CS%grid_generic' and 'CS%ppoly_linear' are declared at
1048  ! the module level.
1049 
1050  ! Determine reconstruction within each column
1051 !$OMP parallel do default(none) shared(G,GV,h,tv,CS,S_t,S_b,T_t,T_b) &
1052 !$OMP private(hTmp,ppoly_linear_E,ppoly_linear_coefficients,tmp)
1053  do j = g%jsc-1,g%jec+1
1054  do i = g%isc-1,g%iec+1
1055  ! Build current grid
1056  htmp(:) = h(i,j,:)*gv%H_to_m
1057  tmp(:) = tv%S(i,j,:)
1058  ! Reconstruct salinity profile
1059  ppoly_linear_e = 0.0
1060  ppoly_linear_coefficients = 0.0
1061  call plm_reconstruction( gv%ke, htmp, tmp, ppoly_linear_e, ppoly_linear_coefficients )
1062  if (cs%boundary_extrapolation_for_pressure) call &
1063  plm_boundary_extrapolation( gv%ke, htmp, tmp, ppoly_linear_e, ppoly_linear_coefficients )
1064 
1065  do k = 1,gv%ke
1066  s_t(i,j,k) = ppoly_linear_e(k,1)
1067  s_b(i,j,k) = ppoly_linear_e(k,2)
1068  end do
1069 
1070  ! Reconstruct temperature profile
1071  ppoly_linear_e = 0.0
1072  ppoly_linear_coefficients = 0.0
1073  tmp(:) = tv%T(i,j,:)
1074  call plm_reconstruction( gv%ke, htmp, tmp, ppoly_linear_e, ppoly_linear_coefficients )
1075  if (cs%boundary_extrapolation_for_pressure) call &
1076  plm_boundary_extrapolation( gv%ke, htmp, tmp, ppoly_linear_e, ppoly_linear_coefficients )
1077 
1078  do k = 1,gv%ke
1079  t_t(i,j,k) = ppoly_linear_e(k,1)
1080  t_b(i,j,k) = ppoly_linear_e(k,2)
1081  end do
1082 
1083  end do
1084  end do
1085 
Here is the call graph for this function:

◆ pressure_gradient_ppm()

subroutine, public mom_ale::pressure_gradient_ppm ( type(ale_cs), intent(inout)  CS,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  S_t,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  S_b,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  T_t,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(inout)  T_b,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
type(thermo_var_ptrs), intent(in)  tv,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h 
)

Use ppm reconstruction for pressure gradient (determine edge values) By using a PPM (limited piecewise linear method) reconstruction, this routine determines the edge values for the salinity and temperature within each layer. These edge values are returned and are used to compute the pressure gradient (by computing the densities).

Parameters
[in]gocean grid structure
[in]gvOcean vertical grid structure
[in,out]csmodule control structure
[in,out]s_tSalinity at top edge of each layer
[in,out]s_bSalinity at bottom edge of each layer
[in,out]t_tTemperature at the top edge of each layer
[in,out]t_bTemperature at the bottom edge of each layer
[in]tvocean thermodynamics structure
[in]hlayer thickness

Definition at line 1095 of file MOM_ALE.F90.

References regrid_edge_values::edge_values_implicit_h4(), ppm_functions::ppm_boundary_extrapolation(), and ppm_functions::ppm_reconstruction().

1095  type(ocean_grid_type), intent(in) :: g !< ocean grid structure
1096  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
1097  type(ale_cs), intent(inout) :: cs !< module control structure
1098  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: s_t !< Salinity at top edge of each layer
1099  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: s_b !< Salinity at bottom edge of each layer
1100  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: t_t !< Temperature at the top edge of each layer
1101  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(inout) :: t_b !< Temperature at the bottom edge of each layer
1102  type(thermo_var_ptrs), intent(in) :: tv !< ocean thermodynamics structure
1103  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h !< layer thickness
1104 
1105  ! Local variables
1106  integer :: i, j, k
1107  real :: htmp(gv%ke)
1108  real :: tmp(gv%ke)
1109  real, dimension(CS%nk,2) :: &
1110  ppoly_parab_e !Edge value of polynomial
1111  real, dimension(CS%nk,CS%degree_parab+1) :: &
1112  ppoly_parab_coefficients !Coefficients of polynomial
1113 
1114 
1115  ! NOTE: the variables 'CS%grid_generic' and 'CS%ppoly_parab' are declared at
1116  ! the module level.
1117 
1118  ! Determine reconstruction within each column
1119 !$OMP parallel do default(none) shared(G,GV,h,tv,CS,S_t,S_b,T_t,T_b) &
1120 !$OMP private(hTmp,tmp,ppoly_parab_E,ppoly_parab_coefficients)
1121  do j = g%jsc-1,g%jec+1
1122  do i = g%isc-1,g%iec+1
1123 
1124  ! Build current grid
1125  htmp(:) = h(i,j,:) * gv%H_to_m
1126  tmp(:) = tv%S(i,j,:)
1127 
1128  ! Reconstruct salinity profile
1129  ppoly_parab_e = 0.0
1130  ppoly_parab_coefficients = 0.0
1131  call edge_values_implicit_h4( gv%ke, htmp, tmp, ppoly_parab_e )
1132  call ppm_reconstruction( gv%ke, htmp, tmp, ppoly_parab_e, ppoly_parab_coefficients )
1133  if (cs%boundary_extrapolation_for_pressure) call &
1134  ppm_boundary_extrapolation( gv%ke, htmp, tmp, ppoly_parab_e, ppoly_parab_coefficients )
1135 
1136  do k = 1,gv%ke
1137  s_t(i,j,k) = ppoly_parab_e(k,1)
1138  s_b(i,j,k) = ppoly_parab_e(k,2)
1139  end do
1140 
1141  ! Reconstruct temperature profile
1142  ppoly_parab_e = 0.0
1143  ppoly_parab_coefficients = 0.0
1144  tmp(:) = tv%T(i,j,:)
1145  call edge_values_implicit_h4( gv%ke, htmp, tmp, ppoly_parab_e )
1146  call ppm_reconstruction( gv%ke, htmp, tmp, ppoly_parab_e, ppoly_parab_coefficients )
1147  if (cs%boundary_extrapolation_for_pressure) call &
1148  ppm_boundary_extrapolation( gv%ke, htmp, tmp, ppoly_parab_e, ppoly_parab_coefficients )
1149 
1150  do k = 1,gv%ke
1151  t_t(i,j,k) = ppoly_parab_e(k,1)
1152  t_b(i,j,k) = ppoly_parab_e(k,2)
1153  end do
1154 
1155  end do
1156  end do
1157 
Here is the call graph for this function:

◆ pressurereconstructionscheme()

integer function, public mom_ale::pressurereconstructionscheme ( type(ale_cs), pointer  CS)

pressure reconstruction integer

Parameters
cscontrol structure

Definition at line 1176 of file MOM_ALE.F90.

1176  type(ale_cs), pointer :: cs !< control structure
1177 
1178  if (associated(cs)) then
1179  pressurereconstructionscheme=cs%pressureReconstructionScheme
1180  else
1181  pressurereconstructionscheme=-1
1182  endif
1183 

◆ remap_all_state_vars()

subroutine mom_ale::remap_all_state_vars ( type(remapping_cs), intent(in)  CS_remapping,
type(ale_cs), intent(in)  CS_ALE,
type(ocean_grid_type), intent(in)  G,
type(verticalgrid_type), intent(in)  GV,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h_old,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke), intent(in)  h_new,
type(tracer_registry_type), pointer  Reg,
real, dimension( g %isd: g %ied, g %jsd: g %jed, gv %ke+1), intent(in), optional  dxInterface,
real, dimension( g %isdb: g %iedb, g %jsd: g %jed, gv %ke), intent(inout), optional  u,
real, dimension( g %isd: g %ied, g %jsdb: g %jedb, gv %ke), intent(inout), optional  v,
logical, intent(in), optional  debug,
real, intent(in), optional  dt 
)
private

This routine takes care of remapping all variable between the old and the new grids. When velocity components need to be remapped, thicknesses at velocity points are taken to be arithmetic averages of tracer thicknesses. This routine is called during initialization of the model at time=0, to remap initiali conditions to the model grid. It is also called during a time step to update the state.

Parameters
[in]cs_remappingRemapping control structure
[in]cs_aleALE control structure
[in]gOcean grid structure
[in]gvOcean vertical grid structure
[in]h_oldThickness of source grid (m or Pa)
[in]h_newThickness of destination grid (m or Pa)
regTracer registry structure
[in]dxinterfaceChange in interface position (Hm or Pa)
[in,out]uZonal velocity component (m/s)
[in,out]vMeridional velocity component (m/s)
[in]debugIf true, show the call tree
[in]dttime step for diagnostics

Definition at line 764 of file MOM_ALE.F90.

References mom_error_handler::calltree_enter(), mom_error_handler::calltree_leave(), and mom_error_handler::calltree_waypoint().

Referenced by ale_main(), ale_main_offline(), ale_offline_inputs(), ale_offline_tracer_final(), and ale_regrid_accelerated().

764  type(remapping_cs), intent(in) :: cs_remapping !< Remapping control structure
765  type(ale_cs), intent(in) :: cs_ale !< ALE control structure
766  type(ocean_grid_type), intent(in) :: g !< Ocean grid structure
767  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
768  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_old !< Thickness of source grid (m or Pa)
769  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)), intent(in) :: h_new !< Thickness of destination grid (m or Pa)
770  type(tracer_registry_type), pointer :: reg !< Tracer registry structure
771  real, dimension(SZI_(G),SZJ_(G),SZK_(GV)+1),optional, intent(in) :: dxinterface !< Change in interface position (Hm or Pa)
772  real, dimension(SZIB_(G),SZJ_(G),SZK_(GV)), optional, intent(inout) :: u !< Zonal velocity component (m/s)
773  real, dimension(SZI_(G),SZJB_(G),SZK_(GV)), optional, intent(inout) :: v !< Meridional velocity component (m/s)
774  logical, optional, intent(in) :: debug !< If true, show the call tree
775  real, optional, intent(in) :: dt !< time step for diagnostics
776  ! Local variables
777  integer :: i, j, k, m
778  integer :: nz, ntr
779  real, dimension(GV%ke+1) :: dx
780  real, dimension(GV%ke) :: h1, u_column
781  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)) :: work_conc
782  real, dimension(SZI_(G), SZJ_(G), SZK_(GV)) :: work_cont
783  real, dimension(SZI_(G), SZJ_(G)) :: work_2d
784  real :: idt, ppt2mks
785  real, dimension(GV%ke) :: h2
786  logical :: show_call_tree
787 
788  show_call_tree = .false.
789  if (present(debug)) show_call_tree = debug
790  if (show_call_tree) call calltree_enter("remap_all_state_vars(), MOM_ALE.F90")
791 
792  ! If remap_uv_using_old_alg is .true. and u or v is requested, then we must have dxInterface. Otherwise,
793  ! u and v can be remapped without dxInterface
794  if ( .not. present(dxinterface) .and. (cs_ale%remap_uv_using_old_alg .and. (present(u) .or. present(v))) ) then
795  call mom_error(fatal, "remap_all_state_vars: dxInterface must be present if using old algorithm and u/v are to"// &
796  "be remapped")
797  endif
798 
799  nz = gv%ke
800  ppt2mks = 0.001
801 
802  if (associated(reg)) then
803  ntr = reg%ntr
804  else
805  ntr = 0
806  endif
807 
808  if(present(dt)) then
809  work_conc(:,:,:) = 0.0
810  work_cont(:,:,:) = 0.0
811  work_2d(:,:) = 0.0
812  idt = 1.0/dt
813  endif
814 
815  ! Remap tracer
816 !$OMP parallel default(none) shared(G,GV,h_old,h_new,dxInterface,CS_remapping,nz,Reg,u,v,ntr,show_call_tree, &
817 !$OMP dt,CS_ALE,work_conc,work_cont,work_2d,Idt,ppt2mks) &
818 !$OMP private(h1,h2,dx,u_column)
819  if (ntr>0) then
820  if (show_call_tree) call calltree_waypoint("remapping tracers (remap_all_state_vars)")
821 !$OMP do
822  do m=1,ntr ! For each tracer
823 
824  do j = g%jsc,g%jec
825  do i = g%isc,g%iec
826 
827  if (g%mask2dT(i,j)>0.) then
828 
829  ! Build the start and final grids
830  h1(:) = h_old(i,j,:)
831  h2(:) = h_new(i,j,:)
832  call remapping_core_h(cs_remapping, nz, h1, reg%Tr(m)%t(i,j,:), nz, h2, u_column)
833 
834  ! Intermediate steps for tendency of tracer concentration and tracer content.
835  ! Note: do not merge the two if-tests, since do_tendency_diag(:) is not
836  ! allocated during the time=0 initialization call to this routine.
837  if(present(dt)) then
838  if(cs_ale%do_tendency_diag(m)) then
839  do k=1,gv%ke
840  work_conc(i,j,k) = (u_column(k) - reg%Tr(m)%t(i,j,k) ) * idt
841  work_cont(i,j,k) = (u_column(k)*h2(k) - reg%Tr(m)%t(i,j,k)*h1(k)) * idt * gv%H_to_kg_m2
842  enddo
843  endif
844  endif
845 
846  ! update tracer concentration
847  reg%Tr(m)%t(i,j,:) = u_column(:)
848 
849  endif
850 
851  enddo ! i
852  enddo ! j
853 
854 
855  ! tendency diagnostics.
856  ! Note: do not merge the two if-tests if(present(dt)) and
857  ! if(CS_ALE%do_tendency_diag(m)). The reason is that
858  ! do_tendency_diag(:) is not allocated when this routine is called
859  ! during initialization (time=0). So need to keep the if-tests split.
860  if(present(dt)) then
861  if(cs_ale%do_tendency_diag(m)) then
862 
863  if(cs_ale%id_tracer_remap_tendency(m) > 0) then
864  call post_data(cs_ale%id_tracer_remap_tendency(m), work_conc, cs_ale%diag)
865  endif
866 
867  if (cs_ale%id_Htracer_remap_tendency(m) > 0 .or. cs_ale%id_Htracer_remap_tendency_2d(m) > 0) then
868  if(trim(reg%Tr(m)%name) == 'T') then
869  do k=1,gv%ke
870  do j = g%jsc,g%jec
871  do i = g%isc,g%iec
872  work_cont(i,j,k) = work_cont(i,j,k) * cs_ale%C_p
873  enddo
874  enddo
875  enddo
876  elseif(trim(reg%Tr(m)%name) == 'S') then
877  do k=1,gv%ke
878  do j = g%jsc,g%jec
879  do i = g%isc,g%iec
880  work_cont(i,j,k) = work_cont(i,j,k) * ppt2mks
881  enddo
882  enddo
883  enddo
884  endif
885  endif
886 
887  if (cs_ale%id_Htracer_remap_tendency(m) > 0) then
888  call post_data(cs_ale%id_Htracer_remap_tendency(m), work_cont, cs_ale%diag)
889  endif
890  if (cs_ale%id_Htracer_remap_tendency_2d(m) > 0) then
891  do j = g%jsc,g%jec
892  do i = g%isc,g%iec
893  work_2d(i,j) = 0.0
894  do k = 1,gv%ke
895  work_2d(i,j) = work_2d(i,j) + work_cont(i,j,k)
896  enddo
897  enddo
898  enddo
899  call post_data(cs_ale%id_Htracer_remap_tendency_2d(m), work_2d, cs_ale%diag)
900  endif
901 
902  endif
903  endif
904 
905  enddo ! m=1,ntr
906 
907  endif ! endif for ntr > 0
908 
909  if (show_call_tree) call calltree_waypoint("tracers remapped (remap_all_state_vars)")
910 
911  ! Remap u velocity component
912  if ( present(u) ) then
913 !$OMP do
914  do j = g%jsc,g%jec
915  do i = g%iscB,g%iecB
916  if (g%mask2dCu(i,j)>0.) then
917  ! Build the start and final grids
918  h1(:) = 0.5 * ( h_old(i,j,:) + h_old(i+1,j,:) )
919  if (cs_ale%remap_uv_using_old_alg) then
920  dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i+1,j,:) )
921  do k = 1, nz
922  h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
923  enddo
924  else
925  h2(:) = 0.5 * ( h_new(i,j,:) + h_new(i+1,j,:) )
926  endif
927  call remapping_core_h(cs_remapping, nz, h1, u(i,j,:), nz, h2, u_column)
928  u(i,j,:) = u_column(:)
929  endif
930  enddo
931  enddo
932  endif
933 
934  if (show_call_tree) call calltree_waypoint("u remapped (remap_all_state_vars)")
935 
936  ! Remap v velocity component
937  if ( present(v) ) then
938 !$OMP do
939  do j = g%jscB,g%jecB
940  do i = g%isc,g%iec
941  if (g%mask2dCv(i,j)>0.) then
942  ! Build the start and final grids
943  h1(:) = 0.5 * ( h_old(i,j,:) + h_old(i,j+1,:) )
944  if (cs_ale%remap_uv_using_old_alg) then
945  dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i,j+1,:) )
946  do k = 1, nz
947  h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
948  enddo
949  else
950  h2(:) = 0.5 * ( h_new(i,j,:) + h_new(i,j+1,:) )
951  endif
952  call remapping_core_h(cs_remapping, nz, h1, v(i,j,:), nz, h2, u_column)
953  v(i,j,:) = u_column(:)
954  endif
955  enddo
956  enddo
957  endif
958 !$OMP end parallel
959 
960  if (show_call_tree) call calltree_waypoint("v remapped (remap_all_state_vars)")
961  if (show_call_tree) call calltree_leave("remap_all_state_vars()")
962 
Here is the call graph for this function:
Here is the caller graph for this function:

◆ usepressurereconstruction()

logical function, public mom_ale::usepressurereconstruction ( type(ale_cs), pointer  CS)

pressure reconstruction logical

Parameters
cscontrol structure

Definition at line 1163 of file MOM_ALE.F90.

1163  type(ale_cs), pointer :: cs !< control structure
1164 
1165  if (associated(cs)) then
1166  usepressurereconstruction=cs%reconstructForPressure
1167  else
1168  usepressurereconstruction=.false.
1169  endif
1170