Skip to content

Commit

Permalink
Adds infrastructure to enable GME to access private arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavo-marques committed Jan 17, 2019
1 parent 60d493a commit ec68e41
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 17 deletions.
14 changes: 10 additions & 4 deletions src/core/MOM.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module MOM
use MOM_ALE, only : ALE_init, ALE_end, ALE_main, ALE_CS, adjustGridForIntegrity
use MOM_ALE, only : ALE_getCoordinate, ALE_getCoordinateUnits, ALE_writeCoordinateFile
use MOM_ALE, only : ALE_updateVerticalGridType, ALE_remap_init_conds, ALE_register_diags
use MOM_barotropic, only : Barotropic_CS
use MOM_boundary_update, only : call_OBC_register, OBC_register_end, update_OBC_CS
use MOM_coord_initialization, only : MOM_initialize_coord
use MOM_diabatic_driver, only : diabatic, diabatic_driver_init, diabatic_CS
Expand Down Expand Up @@ -317,7 +318,8 @@ module MOM
!< 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(tracer_registry_type), pointer :: tracer_Reg => NULL()
!< Pointer to the MOM tracer registry
type(tracer_advect_CS), pointer :: tracer_adv_CSp => NULL()
Expand Down Expand Up @@ -959,7 +961,8 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &

call step_MOM_dyn_split_RK2(u, v, h, CS%tv, CS%visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, CS%uh, CS%vh, CS%uhtr, CS%vhtr, &
CS%eta_av_bc, G, GV, CS%dyn_split_RK2_CSp, calc_dtbt, CS%VarMix, CS%MEKE)
CS%eta_av_bc, G, GV, CS%dyn_split_RK2_CSp, calc_dtbt, CS%VarMix, &
CS%MEKE, CS%Barotropic_CSp, CS%thickness_diffuse_CSp)
if (showCallTree) call callTree_waypoint("finished step_MOM_dyn_split (step_MOM)")

elseif (CS%do_dynamics) then ! ------------------------------------ not SPLIT
Expand All @@ -973,11 +976,13 @@ subroutine step_MOM_dynamics(forces, p_surf_begin, p_surf_end, dt, dt_thermo, &
if (CS%use_RK2) then
call step_MOM_dyn_unsplit_RK2(u, v, h, CS%tv, CS%visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, CS%uh, CS%vh, CS%uhtr, CS%vhtr, &
CS%eta_av_bc, G, GV, CS%dyn_unsplit_RK2_CSp, CS%VarMix, CS%MEKE)
CS%eta_av_bc, G, GV, CS%dyn_unsplit_RK2_CSp, CS%VarMix, CS%MEKE, &
CS%Barotropic_CSp, CS%thickness_diffuse_CSp)
else
call step_MOM_dyn_unsplit(u, v, h, CS%tv, CS%visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, CS%uh, CS%vh, CS%uhtr, CS%vhtr, &
CS%eta_av_bc, G, GV, CS%dyn_unsplit_CSp, CS%VarMix, CS%MEKE, Waves=Waves)
CS%eta_av_bc, G, GV, CS%dyn_unsplit_CSp, CS%VarMix, CS%MEKE, &
CS%Barotropic_CSp, CS%thickness_diffuse_CSp, Waves=Waves)
endif
if (showCallTree) call callTree_waypoint("finished step_MOM_dyn_unsplit (step_MOM)")

Expand Down Expand Up @@ -2291,6 +2296,7 @@ subroutine initialize_MOM(Time, Time_init, param_file, dirs, CS, restart_CSp, &
call initialize_dyn_split_RK2(CS%u, CS%v, CS%h, CS%uh, CS%vh, eta, Time, &
G, GV, param_file, diag, CS%dyn_split_RK2_CSp, restart_CSp, &
CS%dt, CS%ADp, CS%CDp, MOM_internal_state, CS%VarMix, CS%MEKE, &
CS%Barotropic_CSp, CS%thickness_diffuse_CSp, &
CS%OBC, CS%update_OBC_CSp, CS%ALE_CSp, CS%set_visc_CSp, &
CS%visc, dirs, CS%ntrunc, calc_dtbt=calc_dtbt)
if (CS%dtbt_reset_period > 0.0) then
Expand Down
27 changes: 25 additions & 2 deletions src/core/MOM_barotropic.F90
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ module MOM_barotropic
#endif

public btcalc, bt_mass_source, btstep, barotropic_init, barotropic_end
public register_barotropic_restarts, set_dtbt
public register_barotropic_restarts, set_dtbt, barotropic_get_tav

!> The barotropic stepping open boundary condition type
type, private :: BT_OBC_type
Expand Down Expand Up @@ -4348,6 +4348,29 @@ subroutine barotropic_init(u, v, h, eta, Time, G, GV, param_file, diag, CS, &

end subroutine barotropic_init

!> Copies ubtav and vbtav from private type into arrays
subroutine barotropic_get_tav(CS, ubtav, vbtav, G)
type(barotropic_CS), pointer :: CS !< Control structure for
!! this module
type(ocean_grid_type), intent(in) :: G !< Grid structure
real, dimension(SZIB_(G),SZJ_(G)), intent(inout) :: ubtav!< zonal barotropic vel.
!! ave. over baroclinic time-step (m s-1)
real, dimension(SZI_(G),SZJB_(G)), intent(inout) :: vbtav!< meridional barotropic vel.
!! ave. over baroclinic time-step (m s-1)
! Local variables
integer :: i,j

do j = G%jsc, G%jec ; do I = G%isc-1, G%iec
ubtav(I,j) = CS%ubtav(I,j)
enddo ; enddo

do J = G%jsc-1, G%jec ; do i = G%isc, G%iec
vbtav(i,J) = CS%vbtav(i,J)
enddo ; enddo

end subroutine barotropic_get_tav


!> Clean up the barotropic control structure.
subroutine barotropic_end(CS)
type(barotropic_CS), pointer :: CS !< Control structure to clear out.
Expand All @@ -4366,7 +4389,7 @@ subroutine barotropic_end(CS)
end subroutine barotropic_end

!> This subroutine is used to register any fields from MOM_barotropic.F90
!! that should be written to or read from the restart file.
!!! that should be written to or read from the restart file.
subroutine register_barotropic_restarts(HI, GV, param_file, CS, restart_CS)
type(hor_index_type), intent(in) :: HI !< A horizontal index type structure.
type(param_file_type), intent(in) :: param_file !< A structure to parse for run-time parameters.
Expand Down
20 changes: 17 additions & 3 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module MOM_dynamics_split_RK2
use MOM_open_boundary, only : open_boundary_test_extern_h
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_ML, set_visc_CS
use MOM_thickness_diffuse, only : thickness_diffuse_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
use MOM_vert_friction, only : vertvisc, vertvisc_coef, vertvisc_remnant
use MOM_vert_friction, only : vertvisc_limit_vel, vertvisc_init, vertvisc_CS
Expand Down Expand Up @@ -228,7 +229,8 @@ module MOM_dynamics_split_RK2
subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, &
Time_local, dt, forces, p_surf_begin, p_surf_end, &
uh, vh, uhtr, vhtr, eta_av, &
G, GV, CS, calc_dtbt, VarMix, MEKE)
G, GV, CS, calc_dtbt, VarMix, MEKE, Barotropic_CSp, &
thickness_diffuse_CSp)
type(ocean_grid_type), intent(inout) :: G !< ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), &
Expand Down Expand Up @@ -262,7 +264,12 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, &
logical, intent(in) :: calc_dtbt !< if true, recalculate barotropic time step
type(VarMix_CS), pointer :: VarMix !< specify the spatially varying viscosities
type(MEKE_type), pointer :: MEKE !< related to mesoscale eddy kinetic energy param
type(barotropic_CS), pointer :: Barotropic_CSp!< Pointer to a structure containing
!! barotropic velocities
type(thickness_diffuse_CS), pointer :: thickness_diffuse_CSp!< Pointer to a structure containing
!! interface height diffusivities

! local variables
real :: dt_pred ! The time step for the predictor part of the baroclinic time stepping.

real, dimension(SZIB_(G),SZJ_(G),SZK_(G)) :: up ! Predicted zonal velocity in m s-1.
Expand Down Expand Up @@ -679,7 +686,8 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, &
! diffu = horizontal viscosity terms (u_av)
call cpu_clock_begin(id_clock_horvisc)
call horizontal_viscosity(u_av, v_av, h_av, CS%diffu, CS%diffv, &
MEKE, Varmix, G, GV, CS%hor_visc_CSp, OBC=CS%OBC)
MEKE, Varmix, Barotropic_CSp, thickness_diffuse_CSp, &
G, GV, CS%hor_visc_CSp, OBC=CS%OBC)
call cpu_clock_end(id_clock_horvisc)
if (showCallTree) call callTree_wayPoint("done with horizontal_viscosity (step_MOM_dyn_split_RK2)")

Expand Down Expand Up @@ -951,7 +959,8 @@ end subroutine register_restarts_dyn_split_RK2
!! dynamic core, including diagnostics and the cpu clocks.
subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, param_file, &
diag, CS, restart_CS, dt, Accel_diag, Cont_diag, MIS, &
VarMix, MEKE, OBC, update_OBC_CSp, ALE_CSp, setVisc_CSp, &
VarMix, MEKE, Barotropic_CSp, thickness_diffuse_CSp, &
OBC, update_OBC_CSp, ALE_CSp, setVisc_CSp, &
visc, dirs, ntrunc, calc_dtbt)
type(ocean_grid_type), intent(inout) :: G !< ocean grid structure
type(verticalGrid_type), intent(in) :: GV !< ocean vertical grid structure
Expand All @@ -978,6 +987,10 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, param_fil
!! diagnostic pointers
type(VarMix_CS), pointer :: VarMix !< points to spatially variable viscosities
type(MEKE_type), pointer :: MEKE !< points to mesoscale eddy kinetic energy fields
type(Barotropic_CS), pointer :: Barotropic_CSp !< Pointer to the control structure for
!! the barotropic module
type(thickness_diffuse_CS), pointer :: thickness_diffuse_CSp !< Pointer to the control structure
!! used for the isopycnal height diffusive transport.
type(ocean_OBC_type), pointer :: OBC !< points to OBC related fields
type(update_OBC_CS), pointer :: update_OBC_CSp !< points to OBC update related fields
type(ALE_CS), pointer :: ALE_CSp !< points to ALE control structure
Expand Down Expand Up @@ -1126,6 +1139,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, param_fil
if (.not. query_initialized(CS%diffu,"diffu",restart_CS) .or. &
.not. query_initialized(CS%diffv,"diffv",restart_CS)) &
call horizontal_viscosity(u, v, h, CS%diffu, CS%diffv, MEKE, VarMix, &
Barotropic_CSp, thickness_diffuse_CSp, &
G, GV, CS%hor_visc_CSp, OBC=CS%OBC)
if (.not. query_initialized(CS%u_av,"u2", restart_CS) .or. &
.not. query_initialized(CS%u_av,"v2", restart_CS)) then
Expand Down
11 changes: 8 additions & 3 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module MOM_dynamics_unsplit
!* *
!********+*********+*********+*********+*********+*********+*********+**


use MOM_variables, only : vertvisc_type, thermo_var_ptrs
use MOM_variables, only : accel_diag_ptrs, ocean_internal_state, cont_diag_ptrs
use MOM_forcing_type, only : mech_forcing
Expand All @@ -76,6 +75,7 @@ module MOM_dynamics_unsplit
use MOM_time_manager, only : operator(-), operator(>), operator(*), operator(/)

use MOM_ALE, only : ALE_CS
use MOM_barotropic, only : barotropic_CS
use MOM_boundary_update, only : update_OBC_data, update_OBC_CS
use MOM_continuity, only : continuity, continuity_init, continuity_CS
use MOM_CoriolisAdv, only : CorAdCalc, CoriolisAdv_init, CoriolisAdv_CS
Expand All @@ -91,6 +91,7 @@ module MOM_dynamics_unsplit
use MOM_open_boundary, only : open_boundary_zero_normal_flow
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_ML, set_visc_CS
use MOM_thickness_diffuse, only : thickness_diffuse_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
use MOM_vert_friction, only : vertvisc, vertvisc_coef
use MOM_vert_friction, only : vertvisc_limit_vel, vertvisc_init, vertvisc_CS
Expand Down Expand Up @@ -181,7 +182,7 @@ module MOM_dynamics_unsplit
!! 3rd order (for the inviscid momentum equations) order scheme
subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, uh, vh, uhtr, vhtr, eta_av, G, GV, CS, &
VarMix, MEKE, Waves)
VarMix, MEKE, Barotropic, thickness_diffuse, Waves)
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid structure.
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), intent(inout) :: u !< The zonal velocity, in m s-1.
Expand Down Expand Up @@ -216,6 +217,10 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
!! that specify the spatially variable viscosities.
type(MEKE_type), pointer :: MEKE !< A pointer to a structure containing
!! fields related to the Mesoscale Eddy Kinetic Energy.
type(barotropic_CS), pointer :: Barotropic!< Pointer to a structure containing
!! barotropic velocities
type(thickness_diffuse_CS), pointer :: thickness_diffuse!< Pointer to a structure containing
!! interface height diffusivities
type(wave_parameters_CS), optional, pointer :: Waves !< A pointer to a structure containing
!! fields related to the surface wave conditions

Expand Down Expand Up @@ -254,7 +259,7 @@ subroutine step_MOM_dyn_unsplit(u, v, h, tv, visc, Time_local, dt, forces, &
call enable_averaging(dt,Time_local, CS%diag)
call cpu_clock_begin(id_clock_horvisc)
call horizontal_viscosity(u, v, h, CS%diffu, CS%diffv, MEKE, Varmix, &
G, GV, CS%hor_visc_CSp)
Barotropic, thickness_diffuse, G, GV, CS%hor_visc_CSp)
call cpu_clock_end(id_clock_horvisc)
call disable_averaging(CS%diag)

Expand Down
11 changes: 8 additions & 3 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ module MOM_dynamics_unsplit_RK2

use MOM_ALE, only : ALE_CS
use MOM_boundary_update, only : update_OBC_data, update_OBC_CS
use MOM_barotropic, only : barotropic_CS
use MOM_continuity, only : continuity, continuity_init, continuity_CS
use MOM_CoriolisAdv, only : CorAdCalc, CoriolisAdv_init, CoriolisAdv_CS
use MOM_debugging, only : check_redundant
Expand All @@ -88,6 +89,7 @@ module MOM_dynamics_unsplit_RK2
use MOM_open_boundary, only : open_boundary_zero_normal_flow
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_ML, set_visc_CS
use MOM_thickness_diffuse, only : thickness_diffuse_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
use MOM_vert_friction, only : vertvisc, vertvisc_coef
use MOM_vert_friction, only : vertvisc_limit_vel, vertvisc_init, vertvisc_CS
Expand Down Expand Up @@ -183,7 +185,7 @@ module MOM_dynamics_unsplit_RK2
!> Step the MOM6 dynamics using an unsplit quasi-2nd order Runge-Kutta scheme
subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt, forces, &
p_surf_begin, p_surf_end, uh, vh, uhtr, vhtr, eta_av, G, GV, CS, &
VarMix, MEKE)
VarMix, MEKE, Barotropic, thickness_diffuse)
type(ocean_grid_type), intent(inout) :: G !< The ocean's grid structure.
type(verticalGrid_type), intent(in) :: GV !< The ocean's vertical grid
!! structure.
Expand Down Expand Up @@ -230,7 +232,10 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt,
type(MEKE_type), pointer :: MEKE !< A pointer to a structure containing
!! fields related to the Mesoscale
!! Eddy Kinetic Energy.

type(barotropic_CS), pointer :: Barotropic!< Pointer to a structure containing
!! barotropic velocities
type(thickness_diffuse_CS), pointer :: thickness_diffuse!< Pointer to a structure containing
!! interface height diffusivities
! Local variables
real, dimension(SZI_(G),SZJ_(G),SZK_(G)) :: h_av, hp
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)) :: up
Expand Down Expand Up @@ -266,7 +271,7 @@ subroutine step_MOM_dyn_unsplit_RK2(u_in, v_in, h_in, tv, visc, Time_local, dt,
call enable_averaging(dt,Time_local, CS%diag)
call cpu_clock_begin(id_clock_horvisc)
call horizontal_viscosity(u_in, v_in, h_in, CS%diffu, CS%diffv, MEKE, VarMix, &
G, GV, CS%hor_visc_CSp)
Barotropic, thickness_diffuse, G, GV, CS%hor_visc_CSp)
call cpu_clock_end(id_clock_horvisc)
call disable_averaging(CS%diag)
call pass_vector(CS%diffu, CS%diffv, G%Domain, clock=id_clock_pass)
Expand Down
Loading

0 comments on commit ec68e41

Please sign in to comment.