MOM6
MOM_boundary_update.F90
Go to the documentation of this file.
1 ! This file is part of MOM6. See LICENSE.md for the license.
2 !> Controls where open boundary conditions are applied
4 
5 ! This file is part of MOM6. See LICENSE.md for the license.
6 
7 use mom_cpu_clock, only : cpu_clock_id, cpu_clock_begin, cpu_clock_end, clock_routine
8 use mom_diag_mediator, only : time_type
9 use mom_error_handler, only : mom_mesg, mom_error, fatal, warning
11 use mom_grid, only : ocean_grid_type
28 
29 implicit none ; private
30 
31 #include <MOM_memory.h>
32 
34 public update_obc_data
35 
36 !> The control structure for the MOM_boundary_update module
37 type, public :: update_obc_cs ; private
38  logical :: use_files = .false. !< If true, use external files for the open boundary.
39  logical :: use_kelvin = .false. !< If true, use the Kelvin wave open boundary.
40  logical :: use_tidal_bay = .false. !< If true, use the tidal_bay open boundary.
41  logical :: use_shelfwave = .false. !< If true, use the shelfwave open boundary.
42  logical :: use_dyed_channel = .false. !< If true, use the dyed channel open boundary.
43  !>@{ Pointers to the control structures for named OBC specifications
44  type(file_obc_cs), pointer :: file_obc_csp => null()
45  type(kelvin_obc_cs), pointer :: kelvin_obc_csp => null()
46  type(tidal_bay_obc_cs), pointer :: tidal_bay_obc_csp => null()
47  type(shelfwave_obc_cs), pointer :: shelfwave_obc_csp => null()
48  type(dyed_channel_obc_cs), pointer :: dyed_channel_obc_csp => null()
49  !!@}
50 end type update_obc_cs
51 
52 integer :: id_clock_pass !< A CPU time clock ID
53 
54 ! character(len=40) :: mdl = "MOM_boundary_update" ! This module's name.
55 
56 contains
57 
58 !> The following subroutines and associated definitions provide the
59 !! machinery to register and call the subroutines that initialize
60 !! open boundary conditions.
61 subroutine call_obc_register(param_file, CS, OBC)
62  type(param_file_type), intent(in) :: param_file !< Parameter file to parse
63  type(update_obc_cs), pointer :: cs !< Control structure for OBCs
64  type(ocean_obc_type), pointer :: obc !< Open boundary structure
65 
66  ! Local variables
67  character(len=40) :: mdl = "MOM_boundary_update" ! This module's name.
68  ! This include declares and sets the variable "version".
69 # include "version_variable.h"
70  if (associated(cs)) then
71  call mom_error(warning, "call_OBC_register called with an associated "// &
72  "control structure.")
73  return
74  else ; allocate(cs) ; endif
75 
76  call log_version(param_file, mdl, version, "")
77 
78  call get_param(param_file, mdl, "USE_FILE_OBC", cs%use_files, &
79  "If true, use external files for the open boundary.", &
80  default=.false.)
81  call get_param(param_file, mdl, "USE_TIDAL_BAY_OBC", cs%use_tidal_bay, &
82  "If true, use the tidal_bay open boundary.", &
83  default=.false.)
84  call get_param(param_file, mdl, "USE_KELVIN_WAVE_OBC", cs%use_Kelvin, &
85  "If true, use the Kelvin wave open boundary.", &
86  default=.false.)
87  call get_param(param_file, mdl, "USE_SHELFWAVE_OBC", cs%use_shelfwave, &
88  "If true, use the shelfwave open boundary.", &
89  default=.false.)
90  call get_param(param_file, mdl, "USE_DYED_CHANNEL_OBC", cs%use_dyed_channel, &
91  "If true, use the dyed channel open boundary.", &
92  default=.false.)
93 
94  if (cs%use_files) cs%use_files = &
95  register_file_obc(param_file, cs%file_OBC_CSp, &
96  obc%OBC_Reg)
97  if (cs%use_tidal_bay) cs%use_tidal_bay = &
98  register_tidal_bay_obc(param_file, cs%tidal_bay_OBC_CSp, &
99  obc%OBC_Reg)
100  if (cs%use_Kelvin) cs%use_Kelvin = &
101  register_kelvin_obc(param_file, cs%Kelvin_OBC_CSp, &
102  obc%OBC_Reg)
103  if (cs%use_shelfwave) cs%use_shelfwave = &
104  register_shelfwave_obc(param_file, cs%shelfwave_OBC_CSp, &
105  obc%OBC_Reg)
106  if (cs%use_dyed_channel) cs%use_dyed_channel = &
107  register_dyed_channel_obc(param_file, cs%dyed_channel_OBC_CSp, &
108  obc%OBC_Reg)
109 
110 end subroutine call_obc_register
111 
112 !> Calls appropriate routine to update the open boundary conditions.
113 subroutine update_obc_data(OBC, G, GV, US, tv, h, CS, Time)
114  type(ocean_grid_type), intent(in) :: g !< Ocean grid structure
115  type(verticalgrid_type), intent(in) :: gv !< Ocean vertical grid structure
116  type(unit_scale_type), intent(in) :: us !< A dimensional unit scaling type
117  type(thermo_var_ptrs), intent(in) :: tv !< Thermodynamics structure
118  real, dimension(SZI_(G),SZJ_(G),SZK_(G)), intent(inout) :: h !< layer thicknesses [H ~> m or kg m-2]
119  type(ocean_obc_type), pointer :: obc !< Open boundary structure
120  type(update_obc_cs), pointer :: cs !< Control structure for OBCs
121  type(time_type), intent(in) :: time !< Model time
122 
123  ! Local variables
124  logical :: read_obc_eta = .false.
125  logical :: read_obc_uv = .false.
126  logical :: read_obc_ts = .false.
127  integer :: i, j, k, itt, is, ie, js, je, isd, ied, jsd, jed, nz
128  integer :: isd_off, jsd_off
129  integer :: isdb, iedb, jsdb, jedb
130  character(len=40) :: mdl = "update_OBC_data" ! This subroutine's name.
131  character(len=200) :: filename, obc_file, inputdir ! Strings for file/path
132 
133  is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec ; nz = g%ke
134  isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
135  isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
136 
137 ! Something here... with CS%file_OBC_CSp?
138 ! if (CS%use_files) &
139 ! call update_OBC_segment_data(G, GV, OBC, tv, h, Time)
140  if (cs%use_tidal_bay) &
141  call tidal_bay_set_obc_data(obc, cs%tidal_bay_OBC_CSp, g, h, time)
142  if (cs%use_Kelvin) &
143  call kelvin_set_obc_data(obc, cs%Kelvin_OBC_CSp, g, gv, us, h, time)
144  if (cs%use_shelfwave) &
145  call shelfwave_set_obc_data(obc, cs%shelfwave_OBC_CSp, g, h, time)
146  if (cs%use_dyed_channel) &
147  call dyed_channel_update_flow(obc, cs%dyed_channel_OBC_CSp, g, time)
148  if (obc%needs_IO_for_data) &
149  call update_obc_segment_data(g, gv, us, obc, tv, h, time)
150 
151 end subroutine update_obc_data
152 
153 !> Clean up the OBC registry.
154 subroutine obc_register_end(CS)
155  type(update_obc_cs), pointer :: cs !< Control structure for OBCs
156 
157  if (cs%use_files) call file_obc_end(cs%file_OBC_CSp)
158  if (cs%use_tidal_bay) call tidal_bay_obc_end(cs%tidal_bay_OBC_CSp)
159  if (cs%use_Kelvin) call kelvin_obc_end(cs%Kelvin_OBC_CSp)
160 
161  if (associated(cs)) deallocate(cs)
162 end subroutine obc_register_end
163 
164 !> \namespace mom_boundary_update
165 !! This module updates the open boundary arrays when time-varying.
166 !! It caused a circular dependency with the tidal_bay setup when
167 !! MOM_open_boundary.
168 !!
169 !! A small fragment of the grid is shown below:
170 !!
171 !! j+1 x ^ x ^ x At x: q, CoriolisBu
172 !! j+1 > o > o > At ^: v, tauy
173 !! j x ^ x ^ x At >: u, taux
174 !! j > o > o > At o: h, bathyT, buoy, tr, T, S, Rml, ustar
175 !! j-1 x ^ x ^ x
176 !! i-1 i i+1 At x & ^:
177 !! i i+1 At > & o:
178 !!
179 !! The boundaries always run through q grid points (x).
180 
181 end module mom_boundary_update
tidal_bay_initialization::tidal_bay_set_obc_data
subroutine, public tidal_bay_set_obc_data(OBC, CS, G, h, Time)
This subroutine sets the properties of flow at open boundary conditions.
Definition: tidal_bay_initialization.F90:64
mom_open_boundary::update_obc_segment_data
subroutine, public update_obc_segment_data(G, GV, US, OBC, tv, h, Time)
Update the OBC values on the segments.
Definition: MOM_open_boundary.F90:3401
kelvin_initialization::kelvin_set_obc_data
subroutine, public kelvin_set_obc_data(OBC, CS, G, GV, US, h, Time)
This subroutine sets the properties of flow at open boundary conditions.
Definition: Kelvin_initialization.F90:184
dyed_channel_initialization::dyed_channel_obc_end
subroutine, public dyed_channel_obc_end(CS)
Clean up the dyed_channel OBC from registry.
Definition: dyed_channel_initialization.F90:74
mom_verticalgrid
Provides a transparent vertical ocean grid type and supporting routines.
Definition: MOM_verticalGrid.F90:2
mom_open_boundary::file_obc_end
subroutine, public file_obc_end(CS)
Clean up the file OBC from registry.
Definition: MOM_open_boundary.F90:3972
mom_file_parser::log_version
An overloaded interface to log version information about modules.
Definition: MOM_file_parser.F90:109
mom_boundary_update
Controls where open boundary conditions are applied.
Definition: MOM_boundary_update.F90:3
dyed_channel_initialization::register_dyed_channel_obc
logical function, public register_dyed_channel_obc(param_file, CS, OBC_Reg)
Add dyed channel to OBC registry.
Definition: dyed_channel_initialization.F90:41
mom_diag_mediator
The subroutines here provide convenient wrappers to the fms diag_manager interfaces with additional d...
Definition: MOM_diag_mediator.F90:3
mom_variables::thermo_var_ptrs
Pointers to an assortment of thermodynamic fields that may be available, including potential temperat...
Definition: MOM_variables.F90:78
mom_dyn_horgrid
Contains a shareable dynamic type for describing horizontal grids and metric data and utilty routines...
Definition: MOM_dyn_horgrid.F90:3
kelvin_initialization
Configures the model for the Kelvin wave experiment.
Definition: Kelvin_initialization.F90:6
shelfwave_initialization::shelfwave_set_obc_data
subroutine, public shelfwave_set_obc_data(OBC, CS, G, h, Time)
This subroutine sets the properties of flow at open boundary conditions.
Definition: shelfwave_initialization.F90:129
mom_error_handler::mom_mesg
subroutine, public mom_mesg(message, verb, all_print)
This provides a convenient interface for writing an informative comment.
Definition: MOM_error_handler.F90:53
shelfwave_initialization::shelfwave_obc_end
subroutine, public shelfwave_obc_end(CS)
Clean up the shelfwave OBC from registry.
Definition: shelfwave_initialization.F90:89
shelfwave_initialization
Configures the model for the idealized shelfwave test case.
Definition: shelfwave_initialization.F90:2
mom_tracer_registry
This module contains the tracer_registry_type and the subroutines that handle registration of tracers...
Definition: MOM_tracer_registry.F90:5
mom_file_parser::param_file_type
A structure that can be parsed to read and document run-time parameters.
Definition: MOM_file_parser.F90:54
mom_boundary_update::update_obc_cs
The control structure for the MOM_boundary_update module.
Definition: MOM_boundary_update.F90:37
mom_file_parser::get_param
An overloaded interface to read and log the values of various types of parameters.
Definition: MOM_file_parser.F90:102
kelvin_initialization::kelvin_obc_cs
Control structure for Kelvin wave open boundaries.
Definition: Kelvin_initialization.F90:36
mom_unit_scaling::unit_scale_type
Describes various unit conversion factors.
Definition: MOM_unit_scaling.F90:14
tidal_bay_initialization::register_tidal_bay_obc
logical function, public register_tidal_bay_obc(param_file, CS, OBC_Reg)
Add tidal bay to OBC registry.
Definition: tidal_bay_initialization.F90:34
mom_boundary_update::obc_register_end
subroutine, public obc_register_end(CS)
Clean up the OBC registry.
Definition: MOM_boundary_update.F90:155
kelvin_initialization::register_kelvin_obc
logical function, public register_kelvin_obc(param_file, CS, OBC_Reg)
Add Kelvin wave to OBC registry.
Definition: Kelvin_initialization.F90:57
mom_open_boundary::file_obc_cs
Control structure for open boundaries that read from files. Probably lots to update here.
Definition: MOM_open_boundary.F90:284
mom_open_boundary::obc_registry_type
Type to carry basic OBC information needed for updating values.
Definition: MOM_open_boundary.F90:294
mom_verticalgrid::verticalgrid_type
Describes the vertical ocean grid, including unit conversion factors.
Definition: MOM_verticalGrid.F90:24
mom_variables
Provides transparent structures with groups of MOM6 variables and supporting routines.
Definition: MOM_variables.F90:2
mom_open_boundary
Controls where open boundary conditions are applied.
Definition: MOM_open_boundary.F90:2
mom_cpu_clock
Wraps the MPP cpu clock functions.
Definition: MOM_cpu_clock.F90:2
tidal_bay_initialization::tidal_bay_obc_end
subroutine, public tidal_bay_obc_end(CS)
Clean up the tidal bay OBC from registry.
Definition: tidal_bay_initialization.F90:55
mom_file_parser
The MOM6 facility to parse input files for runtime parameters.
Definition: MOM_file_parser.F90:2
mom_open_boundary::register_file_obc
logical function, public register_file_obc(param_file, CS, OBC_Reg)
Add file to OBC registry.
Definition: MOM_open_boundary.F90:3951
shelfwave_initialization::shelfwave_obc_cs
Control structure for shelfwave open boundaries.
Definition: shelfwave_initialization.F90:29
mom_tracer_registry::tracer_registry_type
Type to carry basic tracer information.
Definition: MOM_tracer_registry.F90:138
dyed_channel_initialization::dyed_channel_obc_cs
Control structure for dyed-channel open boundaries.
Definition: dyed_channel_initialization.F90:28
dyed_channel_initialization::dyed_channel_update_flow
subroutine, public dyed_channel_update_flow(OBC, CS, G, Time)
This subroutine updates the long-channel flow.
Definition: dyed_channel_initialization.F90:135
mom_grid
Provides the ocean grid type.
Definition: MOM_grid.F90:2
mom_open_boundary::ocean_obc_type
Open-boundary data.
Definition: MOM_open_boundary.F90:195
shelfwave_initialization::register_shelfwave_obc
logical function, public register_shelfwave_obc(param_file, CS, OBC_Reg)
Add shelfwave to OBC registry.
Definition: shelfwave_initialization.F90:44
mom_unit_scaling
Provides a transparent unit rescaling type to facilitate dimensional consistency testing.
Definition: MOM_unit_scaling.F90:2
tidal_bay_initialization::tidal_bay_obc_cs
Control structure for tidal bay open boundaries.
Definition: tidal_bay_initialization.F90:26
mom_error_handler::mom_error
subroutine, public mom_error(level, message, all_print)
This provides a convenient interface for writing an mpp_error message with run-time filter based on a...
Definition: MOM_error_handler.F90:72
mom_boundary_update::update_obc_data
subroutine, public update_obc_data(OBC, G, GV, US, tv, h, CS, Time)
Calls appropriate routine to update the open boundary conditions.
Definition: MOM_boundary_update.F90:114
mom_file_parser::log_param
An overloaded interface to log the values of various types of parameters.
Definition: MOM_file_parser.F90:96
dyed_channel_initialization
Initialization for the dyed_channel configuration.
Definition: dyed_channel_initialization.F90:2
tidal_bay_initialization
Configures the model for the "tidal_bay" experiment. tidal_bay = Tidally resonant bay from Zygmunt Ko...
Definition: tidal_bay_initialization.F90:3
mom_error_handler
Routines for error handling and I/O management.
Definition: MOM_error_handler.F90:2
kelvin_initialization::kelvin_obc_end
subroutine, public kelvin_obc_end(CS)
Clean up the Kelvin wave OBC from registry.
Definition: Kelvin_initialization.F90:122
mom_boundary_update::call_obc_register
subroutine, public call_obc_register(param_file, CS, OBC)
The following subroutines and associated definitions provide the machinery to register and call the s...
Definition: MOM_boundary_update.F90:62
mom_dyn_horgrid::dyn_horgrid_type
Describes the horizontal ocean grid with only dynamic memory arrays.
Definition: MOM_dyn_horgrid.F90:23
mom_grid::ocean_grid_type
Ocean grid type. See mom_grid for details.
Definition: MOM_grid.F90:26
mom_boundary_update::id_clock_pass
integer id_clock_pass
A CPU time clock ID.
Definition: MOM_boundary_update.F90:52