MOM_safe_alloc module reference

Convenience functions for safely allocating memory without accidentally reallocating pointer and causing memory leaks.

Generic Interfaces

safe_alloc_ptr

Allocate a pointer to a 1-d, 2-d or 3-d array

safe_alloc_alloc

Allocate a 2-d or 3-d allocatable array

Functions/Subroutines

safe_alloc_ptr_1d

Allocate a pointer to a 1-d array

safe_alloc_ptr_2d_2arg

Allocate a pointer to a 2-d array based on its dimension sizes

safe_alloc_ptr_3d_3arg

Allocate a pointer to a 3-d array based on its dimension sizes

safe_alloc_ptr_2d

Allocate a pointer to a 2-d array based on its index starting and ending values

safe_alloc_ptr_3d

Allocate a pointer to a 3-d array based on its index starting and ending values

safe_alloc_ptr_3d_6arg

Allocate a pointer to a 3-d array based on its index starting and ending values

safe_alloc_allocatable_2d

Allocate a 2-d allocatable array based on its index starting and ending values

safe_alloc_allocatable_3d

Allocate a 3-d allocatable array based on its index starting and ending values and k-index size

safe_alloc_allocatable_3d_6arg

Allocate a 3-d allocatable array based on its 6 index starting and ending values

Generic Interface Documentation

interface safe_alloc_ptr

Allocate a pointer to a 1-d, 2-d or 3-d array

Callers call graph
Callers of mom_safe_alloc::interface::safe_alloc_ptr calls cluster_bfb_surface_forcing BFB_surface_forcing cluster_dumbbell_surface_forcing dumbbell_surface_forcing cluster_meso_surface_forcing MESO_surface_forcing cluster_mom MOM cluster_mom_coriolisadv MOM_CoriolisAdv cluster_mom_diabatic_driver MOM_diabatic_driver cluster_mom_diagnostics MOM_diagnostics cluster_mom_dynamics_split_rk2 MOM_dynamics_split_RK2 cluster_mom_dynamics_split_rk2b MOM_dynamics_split_RK2b cluster_mom_dynamics_unsplit MOM_dynamics_unsplit cluster_mom_dynamics_unsplit_rk2 MOM_dynamics_unsplit_RK2 cluster_mom_hor_visc MOM_hor_visc cluster_mom_ice_shelf MOM_ice_shelf cluster_mom_pressureforce_fv MOM_PressureForce_FV cluster_mom_safe_alloc MOM_safe_alloc cluster_mom_set_visc MOM_set_visc cluster_mom_surface_forcing MOM_surface_forcing cluster_mom_thickness_diffuse MOM_thickness_diffuse cluster_mom_tracer_registry MOM_tracer_registry cluster_mom_vert_friction MOM_vert_friction cluster_user_surface_forcing user_surface_forcing bfb_surface_forcing::bfb_buoyancy_forcing BFB_buoyancy_forcing mom_safe_alloc::interface::safe_alloc_ptr safe_alloc_ptr (interface) bfb_surface_forcing::bfb_buoyancy_forcing->mom_safe_alloc::interface::safe_alloc_ptr dumbbell_surface_forcing::dumbbell_buoyancy_forcing dumbbell_buoyancy_forcing dumbbell_surface_forcing::dumbbell_buoyancy_forcing->mom_safe_alloc::interface::safe_alloc_ptr dumbbell_surface_forcing::dumbbell_dynamic_forcing dumbbell_dynamic_forcing dumbbell_surface_forcing::dumbbell_dynamic_forcing->mom_safe_alloc::interface::safe_alloc_ptr meso_surface_forcing::meso_buoyancy_forcing MESO_buoyancy_forcing meso_surface_forcing::meso_buoyancy_forcing->mom_safe_alloc::interface::safe_alloc_ptr mom::initialize_mom initialize_MOM mom::initialize_mom->mom_safe_alloc::interface::safe_alloc_ptr mom_coriolisadv::coriolisadv_init CoriolisAdv_init mom_coriolisadv::coriolisadv_init->mom_safe_alloc::interface::safe_alloc_ptr mom_diabatic_driver::diabatic_driver_init diabatic_driver_init mom_diabatic_driver::diabatic_driver_init->mom_safe_alloc::interface::safe_alloc_ptr mom_diagnostics::set_dependent_diagnostics set_dependent_diagnostics [private/internal] mom_diagnostics::set_dependent_diagnostics->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_split_rk2::initialize_dyn_split_rk2 initialize_dyn_split_RK2 mom_dynamics_split_rk2::initialize_dyn_split_rk2->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_split_rk2::step_mom_dyn_split_rk2 step_MOM_dyn_split_RK2 mom_dynamics_split_rk2::step_mom_dyn_split_rk2->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_split_rk2b::initialize_dyn_split_rk2b initialize_dyn_split_RK2b mom_dynamics_split_rk2b::initialize_dyn_split_rk2b->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_split_rk2b::step_mom_dyn_split_rk2b step_MOM_dyn_split_RK2b mom_dynamics_split_rk2b::step_mom_dyn_split_rk2b->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_unsplit::step_mom_dyn_unsplit step_MOM_dyn_unsplit mom_dynamics_unsplit::step_mom_dyn_unsplit->mom_safe_alloc::interface::safe_alloc_ptr mom_dynamics_unsplit_rk2::step_mom_dyn_unsplit_rk2 step_MOM_dyn_unsplit_RK2 mom_dynamics_unsplit_rk2::step_mom_dyn_unsplit_rk2->mom_safe_alloc::interface::safe_alloc_ptr mom_hor_visc::hor_visc_init hor_visc_init mom_hor_visc::hor_visc_init->mom_safe_alloc::interface::safe_alloc_ptr mom_ice_shelf::initialize_ice_shelf initialize_ice_shelf mom_ice_shelf::initialize_ice_shelf->mom_safe_alloc::interface::safe_alloc_ptr mom_pressureforce_fv::pressureforce_fv_init PressureForce_FV_init mom_pressureforce_fv::pressureforce_fv_init->mom_safe_alloc::interface::safe_alloc_ptr mom_set_visc::set_visc_register_restarts set_visc_register_restarts mom_set_visc::set_visc_register_restarts->mom_safe_alloc::interface::safe_alloc_ptr mom_surface_forcing::set_forcing set_forcing mom_surface_forcing::set_forcing->mom_safe_alloc::interface::safe_alloc_ptr mom_surface_forcing::surface_forcing_init surface_forcing_init mom_surface_forcing::surface_forcing_init->mom_safe_alloc::interface::safe_alloc_ptr mom_thickness_diffuse::thickness_diffuse_init thickness_diffuse_init mom_thickness_diffuse::thickness_diffuse_init->mom_safe_alloc::interface::safe_alloc_ptr mom_tracer_registry::register_tracer_diagnostics register_tracer_diagnostics mom_tracer_registry::register_tracer_diagnostics->mom_safe_alloc::interface::safe_alloc_ptr mom_vert_friction::vertvisc_init vertvisc_init mom_vert_friction::vertvisc_init->mom_safe_alloc::interface::safe_alloc_ptr user_surface_forcing::user_buoyancy_forcing USER_buoyancy_forcing user_surface_forcing::user_buoyancy_forcing->mom_safe_alloc::interface::safe_alloc_ptr
Text view
interface safe_alloc_alloc

Allocate a 2-d or 3-d allocatable array

Callers call graph
Callers of mom_safe_alloc::interface::safe_alloc_alloc calls cluster_mom_bulk_mixed_layer MOM_bulk_mixed_layer cluster_mom_energetic_pbl MOM_energetic_PBL cluster_mom_geothermal MOM_geothermal cluster_mom_safe_alloc MOM_safe_alloc mom_bulk_mixed_layer::bulkmixedlayer_init bulkmixedlayer_init mom_safe_alloc::interface::safe_alloc_alloc safe_alloc_alloc (interface) mom_bulk_mixed_layer::bulkmixedlayer_init->mom_safe_alloc::interface::safe_alloc_alloc mom_energetic_pbl::energetic_pbl_init energetic_PBL_init mom_energetic_pbl::energetic_pbl_init->mom_safe_alloc::interface::safe_alloc_alloc mom_geothermal::geothermal_init geothermal_init mom_geothermal::geothermal_init->mom_safe_alloc::interface::safe_alloc_alloc
Text view

Functions/Subroutine Documentation

subroutine safe_alloc_ptr_1d(ptr, i1, i2)

Allocate a pointer to a 1-d array

Parameters
  • ptr

    A pointer to allocate

  • i1 [in]

    The size of the array, or its starting index if i2 is present

  • i2 [in]

    The ending index of the array

subroutine safe_alloc_ptr_2d_2arg(ptr, ni, nj)

Allocate a pointer to a 2-d array based on its dimension sizes

Parameters
  • ptr

    A pointer to allocate

  • ni [in]

    The size of the 1st dimension of the array

  • nj [in]

    The size of the 2nd dimension of the array

subroutine safe_alloc_ptr_3d_3arg(ptr, ni, nj, nk)

Allocate a pointer to a 3-d array based on its dimension sizes

Parameters
  • ptr

    A pointer to allocate

  • ni [in]

    The size of the 1st dimension of the array

  • nj [in]

    The size of the 2nd dimension of the array

  • nk [in]

    The size of the 3rd dimension of the array

subroutine safe_alloc_ptr_2d(ptr, is, ie, js, je)

Allocate a pointer to a 2-d array based on its index starting and ending values

Parameters
  • ptr

    A pointer to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

subroutine safe_alloc_ptr_3d(ptr, is, ie, js, je, nk)

Allocate a pointer to a 3-d array based on its index starting and ending values

Parameters
  • ptr

    A pointer to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

  • nk [in]

    The size to allocate for the 3rd dimension

subroutine safe_alloc_ptr_3d_6arg(ptr, is, ie, js, je, ks, ke)

Allocate a pointer to a 3-d array based on its index starting and ending values

Parameters
  • ptr

    A pointer to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

  • ks [in]

    The start index to allocate for the 3rd dimension

  • ke [in]

    The end index to allocate for the 3rd dimension

subroutine safe_alloc_allocatable_2d(ptr, is, ie, js, je)

Allocate a 2-d allocatable array based on its index starting and ending values

Parameters
  • ptr

    An allocatable array to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

subroutine safe_alloc_allocatable_3d(ptr, is, ie, js, je, nk)

Allocate a 3-d allocatable array based on its index starting and ending values and k-index size

Parameters
  • ptr

    An allocatable array to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

  • nk [in]

    The size to allocate for the 3rd dimension

subroutine safe_alloc_allocatable_3d_6arg(ptr, is, ie, js, je, ks, ke)

Allocate a 3-d allocatable array based on its 6 index starting and ending values

Parameters
  • ptr

    An allocatable array to allocate

  • is [in]

    The start index to allocate for the 1st dimension

  • ie [in]

    The end index to allocate for the 1st dimension

  • js [in]

    The start index to allocate for the 2nd dimension

  • je [in]

    The end index to allocate for the 2nd dimension

  • ks [in]

    The start index to allocate for the 3rd dimension

  • ke [in]

    The end index to allocate for the 3rd dimension

API generated with Flint · Rendered from reStructuredText