Skip to content

Commit

Permalink
Moved open_boundary_CS parameters into ocean_OBC_type
Browse files Browse the repository at this point in the history
- Although open_boundary_CS was a true "control structure" and
  ocean_OBC_type was a data container with public members I am
  moving the three parameters in open_boundary_CS into ocean_OBC_type
  and removed open_boundary_CS as part of a larger refactoring.
- No answer changes.
  • Loading branch information
adcroft committed Jun 13, 2016
1 parent 2db5e11 commit ec8ba6f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 52 deletions.
8 changes: 3 additions & 5 deletions src/core/MOM_dynamics_legacy_split.F90
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ module MOM_dynamics_legacy_split
use MOM_lateral_mixing_coeffs, only : VarMix_CS
use MOM_MEKE_types, only : MEKE_type
use MOM_open_boundary, only : Radiation_Open_Bdry_Conds, open_boundary_init
use MOM_open_boundary, only : open_boundary_CS
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
use MOM_vert_friction, only : vertvisc, vertvisc_coef, vertvisc_remnant
Expand Down Expand Up @@ -241,7 +240,6 @@ module MOM_dynamics_legacy_split
type(legacy_barotropic_CS), pointer :: barotropic_CSp => NULL()
type(vertvisc_CS), pointer :: vertvisc_CSp => NULL()
type(set_visc_CS), pointer :: set_visc_CSp => NULL()
type(open_boundary_CS), pointer :: open_boundary_CSp => NULL()
type(ocean_OBC_type), pointer :: OBC => NULL() ! A pointer to an open boundary
! condition type that specifies whether, where, and what open boundary
! conditions are used. If no open BCs are used, this pointer stays
Expand Down Expand Up @@ -739,7 +737,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, &

if (associated(CS%OBC)) then
call Radiation_Open_Bdry_Conds(CS%OBC, u_av, u_old_rad_OBC, v_av, &
v_old_rad_OBC, hp, h_old_rad_OBC, G, CS%open_boundary_CSp)
v_old_rad_OBC, hp, h_old_rad_OBC, G)
endif

! h_av = (h + hp)/2
Expand Down Expand Up @@ -998,7 +996,7 @@ subroutine step_MOM_dyn_legacy_split(u, v, h, tv, visc, &

if (associated(CS%OBC)) then
call Radiation_Open_Bdry_Conds(CS%OBC, u, u_old_rad_OBC, v, &
v_old_rad_OBC, h, h_old_rad_OBC, G, CS%open_boundary_CSp)
v_old_rad_OBC, h, h_old_rad_OBC, G)
endif

! h_av = (h_in + h_out)/2 . Going in to this line, h_av = h_in.
Expand Down Expand Up @@ -1382,7 +1380,7 @@ subroutine initialize_dyn_legacy_split(u, v, h, uh, vh, eta, Time, G, GV, param_
if (associated(ALE_CSp)) CS%ALE_CSp => ALE_CSp
if (associated(OBC)) then
CS%OBC => OBC
call open_boundary_init(Time, G, param_file, diag, CS%open_boundary_CSp)
call open_boundary_init(Time, G, param_file, diag, CS%OBC)
endif

if (.not. query_initialized(CS%eta,"sfc",restart_CS)) then
Expand Down
8 changes: 3 additions & 5 deletions src/core/MOM_dynamics_split_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ module MOM_dynamics_split_RK2
use MOM_MEKE_types, only : MEKE_type
use MOM_open_boundary, only : ocean_OBC_type
use MOM_open_boundary, only : Radiation_Open_Bdry_Conds, open_boundary_init
use MOM_open_boundary, only : open_boundary_CS
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_BBL, set_viscous_ML, set_visc_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
Expand Down Expand Up @@ -161,7 +160,6 @@ module MOM_dynamics_split_RK2
type(barotropic_CS), pointer :: barotropic_CSp => NULL()
type(vertvisc_CS), pointer :: vertvisc_CSp => NULL()
type(set_visc_CS), pointer :: set_visc_CSp => NULL()
type(open_boundary_CS), pointer :: open_boundary_CSp => NULL()
type(tidal_forcing_CS), pointer :: tides_CSp => NULL()

type(ocean_OBC_type), pointer :: OBC => NULL() !< A pointer to an open boundary
Expand Down Expand Up @@ -640,7 +638,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, &

if (associated(CS%OBC)) then
call Radiation_Open_Bdry_Conds(CS%OBC, u_av, u_old_rad_OBC, v_av, &
v_old_rad_OBC, hp, h_old_rad_OBC, G, CS%open_boundary_CSp)
v_old_rad_OBC, hp, h_old_rad_OBC, G)
endif

! h_av = (h + hp)/2
Expand Down Expand Up @@ -852,7 +850,7 @@ subroutine step_MOM_dyn_split_RK2(u, v, h, tv, visc, &

if (associated(CS%OBC)) then
call Radiation_Open_Bdry_Conds(CS%OBC, u, u_old_rad_OBC, v, &
v_old_rad_OBC, h, h_old_rad_OBC, G, CS%open_boundary_CSp)
v_old_rad_OBC, h, h_old_rad_OBC, G)
endif

! h_av = (h_in + h_out)/2 . Going in to this line, h_av = h_in.
Expand Down Expand Up @@ -1143,7 +1141,7 @@ subroutine initialize_dyn_split_RK2(u, v, h, uh, vh, eta, Time, G, GV, param_fil
if (associated(ALE_CSp)) CS%ALE_CSp => ALE_CSp
if (associated(OBC)) then
CS%OBC => OBC
call open_boundary_init(Time, G, param_file, diag, CS%open_boundary_CSp)
call open_boundary_init(Time, G, param_file, diag, CS%OBC)
endif

if (.not. query_initialized(CS%eta,"sfc",restart_CS)) then
Expand Down
4 changes: 1 addition & 3 deletions src/core/MOM_dynamics_unsplit.F90
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ module MOM_dynamics_unsplit
use MOM_MEKE_types, only : MEKE_type
use MOM_open_boundary, only : ocean_OBC_type
use MOM_open_boundary, only : Radiation_Open_Bdry_Conds, open_boundary_init
use MOM_open_boundary, only : open_boundary_CS
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_BBL, set_viscous_ML, set_visc_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
Expand Down Expand Up @@ -156,7 +155,6 @@ module MOM_dynamics_unsplit
type(PressureForce_CS), pointer :: PressureForce_CSp => NULL()
type(vertvisc_CS), pointer :: vertvisc_CSp => NULL()
type(set_visc_CS), pointer :: set_visc_CSp => NULL()
type(open_boundary_CS), pointer :: open_boundary_CSp => NULL()
type(ocean_OBC_type), pointer :: OBC => NULL() ! A pointer to an open boundary
! condition type that specifies whether, where, and what open boundary
! conditions are used. If no open BCs are used, this pointer stays
Expand Down Expand Up @@ -682,7 +680,7 @@ subroutine initialize_dyn_unsplit(u, v, h, Time, G, GV, param_file, diag, CS, &
if (associated(ALE_CSp)) CS%ALE_CSp => ALE_CSp
if (associated(OBC)) then
CS%OBC => OBC
call open_boundary_init(Time, G, param_file, diag, CS%open_boundary_CSp)
call open_boundary_init(Time, G, param_file, diag, CS%OBC)
endif

flux_units = get_flux_units(GV)
Expand Down
4 changes: 1 addition & 3 deletions src/core/MOM_dynamics_unsplit_RK2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ module MOM_dynamics_unsplit_RK2
use MOM_MEKE_types, only : MEKE_type
use MOM_open_boundary, only : ocean_OBC_type
use MOM_open_boundary, only : Radiation_Open_Bdry_Conds, open_boundary_init
use MOM_open_boundary, only : open_boundary_CS
use MOM_PressureForce, only : PressureForce, PressureForce_init, PressureForce_CS
use MOM_set_visc, only : set_viscous_BBL, set_viscous_ML, set_visc_CS
use MOM_tidal_forcing, only : tidal_forcing_init, tidal_forcing_CS
Expand Down Expand Up @@ -162,7 +161,6 @@ module MOM_dynamics_unsplit_RK2
type(PressureForce_CS), pointer :: PressureForce_CSp => NULL()
type(vertvisc_CS), pointer :: vertvisc_CSp => NULL()
type(set_visc_CS), pointer :: set_visc_CSp => NULL()
type(open_boundary_CS), pointer :: open_boundary_CSp => NULL()
type(ocean_OBC_type), pointer :: OBC => NULL() ! A pointer to an open boundary
! condition type that specifies whether, where, and what open boundary
! conditions are used. If no open BCs are used, this pointer stays
Expand Down Expand Up @@ -646,7 +644,7 @@ subroutine initialize_dyn_unsplit_RK2(u, v, h, Time, G, GV, param_file, diag, CS
if (associated(ALE_CSp)) CS%ALE_CSp => ALE_CSp
if (associated(OBC)) then
CS%OBC => OBC
call open_boundary_init(Time, G, param_file, diag, CS%open_boundary_CSp)
call open_boundary_init(Time, G, param_file, diag, CS%OBC)
endif

flux_units = get_flux_units(GV)
Expand Down
61 changes: 25 additions & 36 deletions src/core/MOM_open_boundary.F90
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,6 @@ module MOM_open_boundary

public Radiation_Open_Bdry_Conds, open_boundary_init, open_boundary_end

!> The control structure for open-boundaries
type, public :: open_boundary_CS ; private
real :: gamma_uv !< The relative weighting for the baroclinic radiation
!! velocities (or speed of characteristics) at the
!! new time level (1) or the running mean (0) for velocities.
!! Valid values range from 0 to 1, with a default of 0.3.
real :: gamma_h !< The relative weighting for the baroclinic radiation
!! velocities (or speed of characteristics) at the
!! new time level (1) or the running mean (0) for thicknesses.
!! Valid values range from 0 to 1, with a default of 0.2.
real :: rx_max !< The maximum magnitude of the baroclinic radiation
!! velocity (or speed of characteristics), in m s-1. The
!! default value is 10 m s-1.
end type open_boundary_CS

integer, parameter, public :: OBC_NONE = 0, OBC_SIMPLE = 1, OBC_WALL = 2
integer, parameter, public :: OBC_FLATHER_E = 4, OBC_FLATHER_W = 5
integer, parameter, public :: OBC_FLATHER_N = 6, OBC_FLATHER_S = 7
Expand Down Expand Up @@ -78,6 +63,19 @@ module MOM_open_boundary
v => NULL(), & !< The prescribed values of the meridional velocity (v) at OBC points.
uh => NULL(), & !< The prescribed values of the zonal volume transport (uh) at OBC points.
vh => NULL() !< The prescribed values of the meridional volume transport (vh) at OBC points.

! The following parameters are used in the baroclinic radiation code:
real :: gamma_uv !< The relative weighting for the baroclinic radiation
!! velocities (or speed of characteristics) at the
!! new time level (1) or the running mean (0) for velocities.
!! Valid values range from 0 to 1, with a default of 0.3.
real :: gamma_h !< The relative weighting for the baroclinic radiation
!! velocities (or speed of characteristics) at the
!! new time level (1) or the running mean (0) for thicknesses.
!! Valid values range from 0 to 1, with a default of 0.2.
real :: rx_max !< The maximum magnitude of the baroclinic radiation
!! velocity (or speed of characteristics), in m s-1. The
!! default value is 10 m s-1.
end type ocean_OBC_type

integer :: id_clock_pass
Expand All @@ -90,16 +88,15 @@ module MOM_open_boundary

!> Diagnose radiation conditions at open boundaries
subroutine Radiation_Open_Bdry_Conds(OBC, u_new, u_old, v_new, v_old, &
h_new, h_old, G, CS)
h_new, h_old, G)
type(ocean_grid_type), intent(inout) :: G !< Ocean grid structure
type(ocean_OBC_type), pointer :: OBC !< Open boundary data
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), intent(inout) :: u_new
real, dimension(SZIB_(G),SZJ_(G),SZK_(G)), intent(in) :: u_old
real, dimension(SZI_(G),SZJB_(G),SZK_(G)), intent(inout) :: v_new
real, dimension(SZI_(G),SZJB_(G),SZK_(G)), intent(in) :: v_old
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(inout) :: h_new
real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(in) :: h_old
type(open_boundary_CS), pointer :: CS !< Open boundary control structure
! Local variables
real :: dhdt, dhdx, gamma_u, gamma_h, gamma_v
real :: rx_max, ry_max ! coefficients for radiation
Expand All @@ -112,11 +109,9 @@ subroutine Radiation_Open_Bdry_Conds(OBC, u_new, u_old, v_new, v_old, &
if (.not.(OBC%apply_OBC_u_flather_east .or. OBC%apply_OBC_u_flather_west .or. &
OBC%apply_OBC_v_flather_north .or. OBC%apply_OBC_v_flather_south)) &
return
if (.not.associated(CS)) call MOM_error(FATAL, &
"MOM_open_boundary: Module must be initialized before it is used.")

gamma_u = CS%gamma_uv ; gamma_v = CS%gamma_uv ; gamma_h = CS%gamma_h
rx_max = CS%rx_max ; ry_max = CS%rx_max
gamma_u = OBC%gamma_uv ; gamma_v = OBC%gamma_uv ; gamma_h = OBC%gamma_h
rx_max = OBC%rx_max ; ry_max = OBC%rx_max

if (OBC%apply_OBC_u_flather_east .or. OBC%apply_OBC_u_flather_west) then
do k=1,nz ; do j=js,je ; do I=is-1,ie ; if (OBC%OBC_mask_u(I,j)) then
Expand Down Expand Up @@ -206,20 +201,15 @@ subroutine Radiation_Open_Bdry_Conds(OBC, u_new, u_old, v_new, v_old, &
end subroutine Radiation_Open_Bdry_Conds

!> Initialize open boundary control structure
subroutine open_boundary_init(Time, G, param_file, diag, CS)
subroutine open_boundary_init(Time, G, param_file, diag, OBC)
type(time_type), target, intent(in) :: Time !< Current model time
type(ocean_grid_type), intent(in) :: G !< Ocean grid structure
type(param_file_type), intent(in) :: param_file !< Parameter file handle
type(diag_ctrl), target, intent(inout) :: diag !< Diagnostics control structure
type(open_boundary_CS), pointer :: CS !< Open boundary control structure
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
! Local variables
logical :: flather_east, flather_west, flather_north, flather_south

if (associated(CS)) then
call MOM_error(WARNING, "MOM_open_boundary: open_boundary_init called with associated control structure.")
return
endif

call log_version(param_file, mod, version)
call get_param(param_file, mod, "APPLY_OBC_U_FLATHER_EAST", flather_east, &
"If true, some zonal velocity points use Flather open \n"//&
Expand All @@ -240,20 +230,19 @@ subroutine open_boundary_init(Time, G, param_file, diag, CS)
if (.not.(flather_east .or. flather_west .or. flather_north .or. &
flather_south)) return

allocate(CS)
call get_param(param_file, mod, "OBC_RADIATION_MAX", CS%rx_max, &
call get_param(param_file, mod, "OBC_RADIATION_MAX", OBC%rx_max, &
"The maximum magnitude of the baroclinic radiation \n"//&
"velocity (or speed of characteristics). This is only \n"//&
"used if one of the APPLY_OBC_[UV]_FLATHER_... is true.", &
units="m s-1", default=10.0)
call get_param(param_file, mod, "OBC_RAD_VEL_WT", CS%gamma_uv, &
call get_param(param_file, mod, "OBC_RAD_VEL_WT", OBC%gamma_uv, &
"The relative weighting for the baroclinic radiation \n"//&
"velocities (or speed of characteristics) at the new \n"//&
"time level (1) or the running mean (0) for velocities. \n"//&
"Valid values range from 0 to 1. This is only used if \n"//&
"one of the APPLY_OBC_[UV]_FLATHER_... is true.", &
units="nondim", default=0.3)
call get_param(param_file, mod, "OBC_RAD_THICK_WT", CS%gamma_h, &
call get_param(param_file, mod, "OBC_RAD_THICK_WT", OBC%gamma_h, &
"The relative weighting for the baroclinic radiation \n"//&
"velocities (or speed of characteristics) at the new \n"//&
"time level (1) or the running mean (0) for thicknesses. \n"//&
Expand All @@ -266,9 +255,9 @@ subroutine open_boundary_init(Time, G, param_file, diag, CS)
end subroutine open_boundary_init

!> Deallocate open boundary data
subroutine open_boundary_end(CS)
type(open_boundary_CS), pointer :: CS !< Open boundary control structure
deallocate(CS)
subroutine open_boundary_end(OBC)
type(ocean_OBC_type), pointer :: OBC !< Open boundary control structure
deallocate(OBC)
end subroutine open_boundary_end

!> \namespace mom_open_boundary
Expand Down

0 comments on commit ec8ba6f

Please sign in to comment.