Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redefine ~500 pointers as local or stack variables #5

Merged
merged 30 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ca61bf9
Horizontal viscosity pointer removal
marshallward Sep 24, 2021
0e19103
MEKE pointer cleanup
marshallward Sep 30, 2021
899bf4e
Mixed layer pointer purge
marshallward Oct 5, 2021
9bf8715
Thickness diffusion pointer removal
marshallward Oct 5, 2021
c91b464
Tidal forcing CS pointer removal
marshallward Oct 5, 2021
4a98271
Internal tide pointer removal
marshallward Oct 6, 2021
4b6f45e
Entrain diffusive pointer removal
marshallward Oct 7, 2021
2540b4e
Tidal mixing pointer cleanup
marshallward Oct 7, 2021
e50c667
Geothermal heating pointer removal
marshallward Oct 8, 2021
1a3a20a
Opacity pointer removal
marshallward Oct 11, 2021
3152a9e
Bulk mixed layer pointer removal
marshallward Oct 15, 2021
e3d59fe
Energetic PBL pointer removal
marshallward Oct 15, 2021
d6e98dc
Regularize layers pointer removal
marshallward Oct 15, 2021
5d0160a
CVMix convection pointer removal
marshallward Oct 16, 2021
65a3516
MEKE_type pointer removal
marshallward Oct 18, 2021
1cef96c
Variable mixing pointer removal
marshallward Oct 19, 2021
bbf0f52
Wave speed pointer removal
marshallward Oct 19, 2021
7a63130
MOM_restart_cs pointer removal
marshallward Oct 20, 2021
09a990c
Barotropic CS pointer removal
marshallward Oct 26, 2021
8632fee
Wave structure CS pointer
marshallward Oct 27, 2021
b176571
ALE sponge pointer removal (partial)
marshallward Oct 27, 2021
5b1dd3f
MOM diagnostic pointer removal
marshallward Oct 27, 2021
c4fd89d
set_visc_CS pointer removal
marshallward Nov 10, 2021
62edfdb
tidal_bay_obc_cs pointer removal
marshallward Nov 11, 2021
c4df748
Equation of state pointer removal
marshallward Nov 11, 2021
4ee4dc5
CoriolisAdv_CS pointer removal
marshallward Nov 13, 2021
dc9adeb
PressureForce CS pointer removal
marshallward Nov 15, 2021
a250208
MOM continuity CS pointer removal
marshallward Nov 15, 2021
d00c90b
MOM_open_boundary pointer removal
marshallward Nov 16, 2021
8a73a35
Merge branch 'dev/gfdl' into no_more_pointers
Hallberg-NOAA Nov 22, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ALE/coord_hycom.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ end subroutine set_hycom_params
subroutine build_hycom1_column(CS, eqn_of_state, nz, depth, h, T, S, p_col, &
z_col, z_col_new, zScale, h_neglect, h_neglect_edge)
type(hycom_CS), intent(in) :: CS !< Coordinate control structure
type(EOS_type), pointer :: eqn_of_state !< Equation of state structure
type(EOS_type), intent(in) :: eqn_of_state !< Equation of state structure
integer, intent(in) :: nz !< Number of levels
real, intent(in) :: depth !< Depth of ocean bottom (positive [H ~> m or kg m-2])
real, dimension(nz), intent(in) :: T !< Temperature of column [degC]
Expand Down
4 changes: 2 additions & 2 deletions src/ALE/coord_rho.F90
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ subroutine build_rho_column(CS, nz, depth, h, T, S, eqn_of_state, z_interface, &
real, dimension(nz), intent(in) :: h !< Layer thicknesses [H ~> m or kg m-2]
real, dimension(nz), intent(in) :: T !< Temperature for source column [degC]
real, dimension(nz), intent(in) :: S !< Salinity for source column [ppt]
type(EOS_type), pointer :: eqn_of_state !< Equation of state structure
type(EOS_type), intent(in) :: eqn_of_state !< Equation of state structure
real, dimension(CS%nk+1), &
intent(inout) :: z_interface !< Absolute positions of interfaces
real, optional, intent(in) :: z_rigid_top !< The height of a rigid top (positive upward in the same
Expand Down Expand Up @@ -208,7 +208,7 @@ subroutine build_rho_column_iteratively(CS, remapCS, nz, depth, h, T, S, eqn_of_
real, dimension(nz), intent(in) :: h !< Layer thicknesses in Z coordinates [Z ~> m]
real, dimension(nz), intent(in) :: T !< T for column [degC]
real, dimension(nz), intent(in) :: S !< S for column [ppt]
type(EOS_type), pointer :: eqn_of_state !< Equation of state structure
type(EOS_type), intent(in) :: eqn_of_state !< Equation of state structure
real, dimension(nz+1), intent(inout) :: zInterface !< Absolute positions of interfaces
real, optional, intent(in) :: h_neglect !< A negligibly small width for the
!! purpose of cell reconstructions
Expand Down
2 changes: 1 addition & 1 deletion src/ALE/coord_slight.F90
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ subroutine build_slight_column(CS, eqn_of_state, H_to_pres, H_subroundoff, &
nz, depth, h_col, T_col, S_col, p_col, z_col, z_col_new, &
h_neglect, h_neglect_edge)
type(slight_CS), intent(in) :: CS !< Coordinate control structure
type(EOS_type), pointer :: eqn_of_state !< Equation of state structure
type(EOS_type), intent(in) :: eqn_of_state !< Equation of state structure
real, intent(in) :: H_to_pres !< A conversion factor from thicknesses to
!! scaled pressure [R L2 T-2 H-1 ~> Pa m-1 or Pa m2 kg-1]
real, intent(in) :: H_subroundoff !< GV%H_subroundoff
Expand Down
69 changes: 26 additions & 43 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,7 @@ module MOM
type(diag_ctrl) :: diag !< structure to regulate diagnostic output timing
type(vertvisc_type) :: visc !< structure containing vertical viscosities,
!! bottom drag viscosities, and related fields
type(MEKE_type), pointer :: MEKE => NULL() !< structure containing fields
!! related to the Mesoscale Eddy Kinetic Energy
type(MEKE_type) :: MEKE !< Fields related to the Mesoscale Eddy Kinetic Energy
logical :: adiabatic !< If true, there are no diapycnal mass fluxes, and no calls
!! to routines to calculate or apply diapycnal fluxes.
logical :: diabatic_first !< If true, apply diabatic and thermodynamic processes before time
Expand Down Expand Up @@ -347,21 +346,19 @@ module MOM
!< Pointer to the control structure used for the unsplit RK2 dynamics
type(MOM_dyn_split_RK2_CS), pointer :: dyn_split_RK2_CSp => NULL()
!< Pointer to the control structure used for the mode-split RK2 dynamics
type(thickness_diffuse_CS), pointer :: thickness_diffuse_CSp => NULL()
type(thickness_diffuse_CS) :: thickness_diffuse_CSp
!< Pointer to the control structure used for the isopycnal height diffusive transport.
!! This is also common referred to as Gent-McWilliams diffusion
type(mixedlayer_restrat_CS), pointer :: mixedlayer_restrat_CSp => NULL()
type(mixedlayer_restrat_CS) :: mixedlayer_restrat_CSp
!< Pointer to the control structure used for the mixed layer restratification
type(set_visc_CS), pointer :: set_visc_CSp => NULL()
type(set_visc_CS) :: set_visc_CSp
!< Pointer to the control structure used to set viscosities
type(diabatic_CS), pointer :: diabatic_CSp => NULL()
!< Pointer to the control structure for the diabatic driver
type(MEKE_CS), pointer :: MEKE_CSp => NULL()
type(MEKE_CS) :: MEKE_CSp
!< Pointer to the control structure for the MEKE updates
type(VarMix_CS), pointer :: VarMix => NULL()
!< Pointer to the control structure for the variable mixing module
type(Barotropic_CS), pointer :: Barotropic_CSp => NULL()
!< Pointer to the control structure for the barotropic module
type(VarMix_CS) :: VarMix
!< Control structure for the variable mixing module
type(tracer_registry_type), pointer :: tracer_Reg => NULL()
!< Pointer to the MOM tracer registry
type(tracer_advect_CS), pointer :: tracer_adv_CSp => NULL()
Expand All @@ -388,7 +385,7 @@ module MOM
! Pointers to control structures used for diagnostics
type(sum_output_CS), pointer :: sum_output_CSp => NULL()
!< Pointer to the globally summed output control structure
type(diagnostics_CS), pointer :: diagnostics_CSp => NULL()
type(diagnostics_CS) :: diagnostics_CSp
!< Pointer to the MOM diagnostics control structure
type(offline_transport_CS), pointer :: offline_CSp => NULL()
!< Pointer to the offline tracer transport control structure
Expand Down Expand Up @@ -637,7 +634,7 @@ subroutine step_MOM(forces_in, fluxes_in, sfc_state, Time_start, time_int_in, CS
CS%time_in_cycle = 0.0
do j=js,je ; do i=is,ie ; CS%ssh_rint(i,j) = 0.0 ; enddo ; enddo

if (associated(CS%VarMix)) then
if (CS%VarMix%use_variable_mixing) then
call enable_averages(cycle_time, Time_start + real_to_time(US%T_to_s*cycle_time), CS%diag)
call calc_resoln_function(h, CS%tv, G, GV, US, CS%VarMix)
call calc_depth_function(G, CS%VarMix)
Expand Down Expand Up @@ -1033,7 +1030,7 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &

call enable_averages(dt_thermo, Time_local+real_to_time(US%T_to_s*(dt_thermo-dt)), CS%diag)
call cpu_clock_begin(id_clock_thick_diff)
if (associated(CS%VarMix)) &
if (CS%VarMix%use_variable_mixing) &
call calc_slope_functions(h, CS%tv, dt, G, GV, US, CS%VarMix, OBC=CS%OBC)
call thickness_diffuse(h, CS%uhtr, CS%vhtr, CS%tv, dt_thermo, G, GV, US, &
CS%MEKE, CS%VarMix, CS%CDp, CS%thickness_diffuse_CSp)
Expand Down Expand Up @@ -1112,7 +1109,7 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &

if (CS%debug) call hchksum(h,"Pre-thickness_diffuse h", G%HI, haloshift=0, scale=GV%H_to_m)

if (associated(CS%VarMix)) &
if (CS%VarMix%use_variable_mixing) &
call calc_slope_functions(h, CS%tv, dt, G, GV, US, CS%VarMix, OBC=CS%OBC)
call thickness_diffuse(h, CS%uhtr, CS%vhtr, CS%tv, dt, G, GV, US, &
CS%MEKE, CS%VarMix, CS%CDp, CS%thickness_diffuse_CSp)
Expand Down Expand Up @@ -1563,7 +1560,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS

! Perform offline diffusion if requested
if (.not. skip_diffusion) then
if (associated(CS%VarMix)) then
if (CS%VarMix%use_variable_mixing) then
call pass_var(CS%h, G%Domain)
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix)
call calc_depth_function(G, CS%VarMix)
Expand All @@ -1589,7 +1586,7 @@ subroutine step_offline(forces, fluxes, sfc_state, Time_start, time_interval, CS
call offline_redistribute_residual(CS%offline_CSp, CS%h, uhtr, vhtr, adv_converged)
! Perform offline diffusion if requested
if (.not. skip_diffusion) then
if (associated(CS%VarMix)) then
if (CS%VarMix%use_variable_mixing) then
call pass_var(CS%h, G%Domain)
call calc_resoln_function(CS%h, CS%tv, G, GV, US, CS%VarMix)
call calc_depth_function(G, CS%VarMix)
Expand Down Expand Up @@ -2333,7 +2330,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
! Use the Wright equation of state by default, unless otherwise specified
! Note: this line and the following block ought to be in a separate
! initialization routine for tv.
if (use_EOS) call EOS_init(param_file, CS%tv%eqn_of_state, US)
if (use_EOS) then
allocate(CS%tv%eqn_of_state)
call EOS_init(param_file, CS%tv%eqn_of_state, US)
endif
if (use_temperature) then
allocate(CS%tv%TempxPmE(isd:ied,jsd:jed), source=0.0)
if (use_geothermal) then
Expand All @@ -2351,10 +2351,10 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
CS%dyn_split_RK2_CSp, restart_CSp, CS%uh, CS%vh)
elseif (CS%use_RK2) then
call register_restarts_dyn_unsplit_RK2(HI, GV, param_file, &
CS%dyn_unsplit_RK2_CSp, restart_CSp)
CS%dyn_unsplit_RK2_CSp)
else
call register_restarts_dyn_unsplit(HI, GV, param_file, &
CS%dyn_unsplit_CSp, restart_CSp)
CS%dyn_unsplit_CSp)
endif

! This subroutine calls user-specified tracer registration routines.
Expand Down Expand Up @@ -2662,14 +2662,14 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
endif
elseif (CS%use_RK2) then
call initialize_dyn_unsplit_RK2(CS%u, CS%v, CS%h, Time, G, GV, US, &
param_file, diag, CS%dyn_unsplit_RK2_CSp, restart_CSp, &
CS%ADp, CS%CDp, MOM_internal_state, CS%MEKE, CS%OBC, &
param_file, diag, CS%dyn_unsplit_RK2_CSp, &
CS%ADp, CS%CDp, MOM_internal_state, CS%OBC, &
CS%update_OBC_CSp, CS%ALE_CSp, CS%set_visc_CSp, CS%visc, dirs, &
CS%ntrunc, cont_stencil=CS%cont_stencil)
else
call initialize_dyn_unsplit(CS%u, CS%v, CS%h, Time, G, GV, US, &
param_file, diag, CS%dyn_unsplit_CSp, restart_CSp, &
CS%ADp, CS%CDp, MOM_internal_state, CS%MEKE, CS%OBC, &
param_file, diag, CS%dyn_unsplit_CSp, &
CS%ADp, CS%CDp, MOM_internal_state, CS%OBC, &
CS%update_OBC_CSp, CS%ALE_CSp, CS%set_visc_CSp, CS%visc, dirs, &
CS%ntrunc, cont_stencil=CS%cont_stencil)
endif
Expand Down Expand Up @@ -3595,7 +3595,6 @@ subroutine MOM_end(CS)
endif

call MOM_diagnostics_end(CS%diagnostics_CSp, CS%ADp, CS%CDp)
deallocate(CS%diagnostics_CSp)

if (CS%offline_tracer_mode) call offline_transport_end(CS%offline_CSp)

Expand All @@ -3613,25 +3612,9 @@ subroutine MOM_end(CS)
endif

call thickness_diffuse_end(CS%thickness_diffuse_CSp, CS%CDp)
deallocate(CS%thickness_diffuse_CSp)

if (associated(CS%VarMix)) then
call VarMix_end(CS%VarMix)
deallocate(CS%VarMix)
endif

if (associated(CS%mixedlayer_restrat_CSp)) &
deallocate(CS%mixedlayer_restrat_CSp)

if (associated(CS%set_visc_CSp)) &
call set_visc_end(CS%visc, CS%set_visc_CSp)

if (associated(CS%MEKE_CSp)) deallocate(CS%MEKE_CSp)

if (associated(CS%MEKE)) then
call MEKE_end(CS%MEKE)
deallocate(CS%MEKE)
endif
call VarMix_end(CS%VarMix)
call set_visc_end(CS%visc, CS%set_visc_CSp)
call MEKE_end(CS%MEKE)

if (associated(CS%tv%internal_heat)) deallocate(CS%tv%internal_heat)
if (associated(CS%tv%TempxPmE)) deallocate(CS%tv%TempxPmE)
Expand Down
14 changes: 3 additions & 11 deletions src/core/MOM_CoriolisAdv.F90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ subroutine CorAdCalc(u, v, h, uh, vh, CAu, CAv, OBC, AD, G, GV, US, CS)
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
type(accel_diag_ptrs), intent(inout) :: AD !< Storage for acceleration diagnostics
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(CoriolisAdv_CS), pointer :: CS !< Control structure for MOM_CoriolisAdv
type(CoriolisAdv_CS), intent(in) :: CS !< Control structure for MOM_CoriolisAdv

! Local variables
real, dimension(SZIB_(G),SZJB_(G)) :: &
Expand Down Expand Up @@ -245,8 +245,6 @@ subroutine CorAdCalc(u, v, h, uh, vh, CAu, CAv, OBC, AD, G, GV, US, CS)
! v(is-1:ie+2,js-1:je+1), u(is-1:ie+1,js-1:je+2), h(is-1:ie+2,js-1:je+2),
! uh(is-1,ie,js:je+1) and vh(is:ie+1,js-1:je).

if (.not.associated(CS)) call MOM_error(FATAL, &
"MOM_CoriolisAdv: Module must be initialized before it is used.")
is = G%isc ; ie = G%iec ; js = G%jsc ; je = G%jec
Isq = G%IscB ; Ieq = G%IecB ; Jsq = G%JscB ; Jeq = G%JecB ; nz = GV%ke
vol_neglect = GV%H_subroundoff * (1e-4 * US%m_to_L)**2
Expand Down Expand Up @@ -1034,7 +1032,7 @@ subroutine gradKE(u, v, h, KE, KEx, KEy, k, OBC, G, GV, US, CS)
integer, intent(in) :: k !< Layer number to calculate for
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
type(unit_scale_type), intent(in) :: US !< A dimensional unit scaling type
type(CoriolisAdv_CS), pointer :: CS !< Control structure for MOM_CoriolisAdv
type(CoriolisAdv_CS), intent(in) :: CS !< Control structure for MOM_CoriolisAdv
! Local variables
real :: um, up, vm, vp ! Temporary variables [L T-1 ~> m s-1].
real :: um2, up2, vm2, vp2 ! Temporary variables [L2 T-2 ~> m2 s-2].
Expand Down Expand Up @@ -1113,7 +1111,7 @@ subroutine CoriolisAdv_init(Time, G, GV, US, param_file, diag, AD, CS)
type(param_file_type), intent(in) :: param_file !< Runtime parameter handles
type(diag_ctrl), target, intent(inout) :: diag !< Diagnostics control structure
type(accel_diag_ptrs), target, intent(inout) :: AD !< Strorage for acceleration diagnostics
type(CoriolisAdv_CS), pointer :: CS !< Control structure fro MOM_CoriolisAdv
type(CoriolisAdv_CS), intent(inout) :: CS !< Control structure fro MOM_CoriolisAdv
! Local variables
! This include declares and sets the variable "version".
#include "version_variable.h"
Expand All @@ -1125,12 +1123,6 @@ subroutine CoriolisAdv_init(Time, G, GV, US, param_file, diag, AD, CS)
isd = G%isd ; ied = G%ied ; jsd = G%jsd ; jed = G%jed ; nz = GV%ke
IsdB = G%IsdB ; IedB = G%IedB ; JsdB = G%JsdB ; JedB = G%JedB

if (associated(CS)) then
call MOM_error(WARNING, "CoriolisAdv_init called with associated control structure.")
return
endif
allocate(CS)

CS%diag => diag ; CS%Time => Time

! Read all relevant parameters and write them to the model log.
Expand Down
Loading