MOM6
MOM_boundary_update.F90
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
13 use mom_open_boundary, only : ocean_obc_type, update_obc_segment_data
15 use mom_open_boundary, only : register_file_obc, file_obc_end
20 use tidal_bay_initialization, only : tidal_bay_set_obc_data, register_tidal_bay_obc
21 use tidal_bay_initialization, only : tidal_bay_obc_end, tidal_bay_obc_cs
22 use kelvin_initialization, only : kelvin_set_obc_data, register_kelvin_obc
23 use kelvin_initialization, only : kelvin_obc_end, kelvin_obc_cs
24 use shelfwave_initialization, only : shelfwave_set_obc_data, register_shelfwave_obc
25 use shelfwave_initialization, only : shelfwave_obc_end, shelfwave_obc_cs
26 use dyed_channel_initialization, only : dyed_channel_update_flow, register_dyed_channel_obc
27 use dyed_channel_initialization, only : dyed_channel_obc_end, dyed_channel_obc_cs
28 
29 implicit none ; private
30 
31 #include <MOM_memory.h>
32 
33 public call_obc_register, obc_register_end
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
mom_verticalgrid
Provides a transparent vertical ocean grid type and supporting routines.
Definition: MOM_verticalGrid.F90:2
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
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:82
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
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
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:262
mom_open_boundary::obc_registry_type
Type to carry basic OBC information needed for updating values.
Definition: MOM_open_boundary.F90:272
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
mom_file_parser
The MOM6 facility to parse input files for runtime parameters.
Definition: MOM_file_parser.F90:2
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:122
dyed_channel_initialization::dyed_channel_obc_cs
Control structure for dyed-channel open boundaries.
Definition: dyed_channel_initialization.F90:28
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:186
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_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
mom_dyn_horgrid::dyn_horgrid_type
Describes the horizontal ocean grid with only dynamic memory arrays.
Definition: MOM_dyn_horgrid.F90:22
mom_grid::ocean_grid_type
Ocean grid type. See mom_grid for details.
Definition: MOM_grid.F90:25