Back to home page

MITgcm

 
 

    


Warning, /doc/phys_pkgs/obcs.rst is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit af61e5eb on 2024-06-06 03:30:35 UTC
8679f9097b Jeff*0001 .. _sub_phys_pkg_obcs:
                0002 
                0003 OBCS: Open boundary conditions for regional modeling
                0004 ----------------------------------------------------
                0005 
bd45a18e71 Mart*0006 Authors:
025afa4065 Jeff*0007 Alistair Adcroft, Patrick Heimbach, Samar Katiwala, Martin Losch
8679f9097b Jeff*0008 
                0009 .. _ssub_pkg_obcs_intro:
                0010 
                0011 Introduction
                0012 ++++++++++++
                0013 
3ceb1ce0a9 Jeff*0014 The OBCS-package (:filelink:`pkg/obcs`) is fundamental to regional ocean modeling with the
bd45a18e71 Mart*0015 MITgcm, but there are so many details to be considered in regional
                0016 ocean modeling that this package cannot accommodate all imaginable and
                0017 possible options. Therefore, for a regional simulation with very
                0018 particular details it is recommended to familiarize oneself not only
3ceb1ce0a9 Jeff*0019 with the compile-time and run-time options of this package, but also with
bd45a18e71 Mart*0020 the code itself. In many cases it will be necessary to adapt the
                0021 obcs-code (in particular :filelink:`S/R OBCS_CALC
                0022 <pkg/obcs/obcs_calc.F>`) to the application in question; in these cases
3ceb1ce0a9 Jeff*0023 :filelink:`pkg/obcs` (together with the :filelink:`pkg/rbcs`, see
bd45a18e71 Mart*0024 :numref:`sub_phys_pkg_rbcs`) is a very useful infrastructure for
                0025 implementing special regional models.
8679f9097b Jeff*0026 
                0027 .. _ssub_pkg_obcs_config_compiling:
                0028 
                0029 OBCS configuration and compiling
                0030 ++++++++++++++++++++++++++++++++
                0031 
3ceb1ce0a9 Jeff*0032 As with all MITgcm packages, OBCS can be turned on or off
                0033 at compile-time
8679f9097b Jeff*0034 
bf89a37abc Phob*0035  - using the :code:`packages.conf` file by adding :code:`obcs` to it
8679f9097b Jeff*0036  - or using :code:`genmake2` adding :code:`-enable=obcs` or :code:`-disable=obcs` switches
                0037  - *Required packages and CPP options:*
                0038 
025afa4065 Jeff*0039    - Two alternatives are available for prescribing open boundary values, which differ in the way how OB's are treated in time:
8679f9097b Jeff*0040 
3ceb1ce0a9 Jeff*0041      - Simple time-management (e.g., constant in time, or cyclic with fixed frequency) is provided through :filelink:`S/R OBCS_FIELDS_LOAD <pkg/obcs/obcs_fields_load.F>`
                0042      - More sophisticated 'real-time' (i.e. calendar time) management is available through :filelink:`S/R OBCS_PRESCRIBE_READ <pkg/obcs/obcs_prescribe_read.F>`
                0043    - The latter case requires packages :filelink:`pkg/cal` and :filelink:`pkg/exf` to be enabled.
8679f9097b Jeff*0044 
3ceb1ce0a9 Jeff*0045 Parts of the OBCS code can be enabled or disabled at compile-time
8679f9097b Jeff*0046 via CPP preprocessor flags. These options are set in
0d16355195 Oliv*0047 :filelink:`OBCS_OPTIONS.h <pkg/obcs/OBCS_OPTIONS.h>`.
                0048 :numref:`tab_phys_pkg_obcs_cpp_opts` summarizes these options.
8679f9097b Jeff*0049 
                0050 
bf89a37abc Phob*0051 .. tabularcolumns:: |\Y{.475}|\Y{.1}|\Y{.45}|
8679f9097b Jeff*0052 
0d16355195 Oliv*0053 .. table:: CPP flags for the obcs package
                0054    :name: tab_phys_pkg_obcs_cpp_opts
                0055 
                0056    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0057    | CPP option               | Default | Description                                                                                              |
                0058    +==========================+=========+==========================================================================================================+
                0059    | ALLOW_OBCS_NORTH         | #define | enable Northern OB                                                                                       |
                0060    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0061    | ALLOW_OBCS_SOUTH         | #define | enable Southern OB                                                                                       |
                0062    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0063    | ALLOW_OBCS_EAST          | #define | enable Eastern OB                                                                                        |
                0064    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0065    | ALLOW_OBCS_WEST          | #define | enable Western OB                                                                                        |
                0066    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0067    | ALLOW_OBCS_PRESCRIBE     | #define | enable code for prescribing OB's                                                                         |
                0068    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0069    | ALLOW_OBCS_SPONGE        | #undef  | enable sponge layer code                                                                                 |
                0070    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0071    | ALLOW_OBCS_BALANCE       | #define | enable code for balancing transports through OB's                                                        |
                0072    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0073    | ALLOW_ORLANSKI           | #define | enable Orlanski radiation conditions at OB's                                                             |
                0074    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0075    | ALLOW_OBCS_STEVENS       | #undef  | enable Stevens (1990) boundary conditions at OB's (currently NOT implemented for ptracers)               |
                0076    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0077    | ALLOW_OBCS_SEAICE_SPONGE | #undef  | Include hooks to sponge layer treatment of pkg/seaice variables                                          |
                0078    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
                0079    | ALLOW_OBCS_TIDES         | #undef  | Add tidal contributions to normal OB flow (At the moment tidal forcing is applied only to "normal" flow) |
                0080    +--------------------------+---------+----------------------------------------------------------------------------------------------------------+
8679f9097b Jeff*0081 
                0082 
                0083 .. _pkg_obcs_runtime:
                0084 
                0085 Run-time parameters
                0086 +++++++++++++++++++
                0087 
                0088 
3ceb1ce0a9 Jeff*0089 Run-time parameters are set in files :code:`data.pkg`, :code:`data.obcs`, and
                0090 :code:`data.exf` if 'real-time' prescription is requested
                0091 (i.e., :filelink:`pkg/exf` enabled). These parameter files are
                0092 read in S/Rs :filelink:`PACKAGES_READPARMS <model/src/packages_readparms.F>`,
                0093 :filelink:`OBCS_READPARMS <pkg/obcs/obcs_readparms.F>`, and
                0094 :filelink:`EXF_READPARMS <pkg/exf/exf_readparms.F>`, respectively.
                0095 Run-time parameters may be broken into three categories:
bd45a18e71 Mart*0096 
bf89a37abc Phob*0097  #. switching on/off the package at runtime
                0098  #. OBCS package flags and parameters
                0099  #. additional timing flags in :code:`data.exf` if selected.
8679f9097b Jeff*0100 
                0101 
                0102 Enabling the package
                0103 ####################
                0104 
                0105 The OBCS package is switched on at runtime by setting
bf89a37abc Phob*0106 :varlink:`useOBCS` = :code:`.TRUE.` in :code:`data.pkg`.
8679f9097b Jeff*0107 
                0108 Package flags and parameters
                0109 ############################
                0110 
0d16355195 Oliv*0111 :numref:`tab_phys_pkg_obcs_runtime_flags` summarizes the
bf89a37abc Phob*0112 runtime flags that are set in :code:`data.obcs` and
8679f9097b Jeff*0113 their default values.
                0114 
                0115 
654ec02869 Phob*0116 .. tabularcolumns:: |\X{1}{3}|c|\X{1}{2}|
8679f9097b Jeff*0117 
0d16355195 Oliv*0118 .. table:: OBCS runtime parameters
                0119    :name: tab_phys_pkg_obcs_runtime_flags
                0120 
                0121    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0122    |         Flag/parameter         |    default    |                                             Description                                             |
                0123    +================================+===============+=====================================================================================================+
                0124    | :varlink:`OB_Jnorth`           | 0             | Nx-vector of J-indices (w.r.t. Ny) of Northern OB at each I-position (w.r.t. Nx)                    |
                0125    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0126    | :varlink:`OB_Jsouth`           | 0             | Nx-vector of J-indices (w.r.t. Ny) of Southern OB at each I-position (w.r.t. Nx)                    |
                0127    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0128    | :varlink:`OB_Ieast`            | 0             | Ny-vector of I-indices (w.r.t. Nx) of Eastern OB at each J-position (w.r.t. Ny)                     |
                0129    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0130    | :varlink:`OB_Iwest`            | 0             | Ny-vector of I-indices (w.r.t. Nx) of Western OB at each J-position (w.r.t. Ny)                     |
                0131    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0132    | :varlink:`useOBCSprescribe`    | FALSE         |                                                                                                     |
                0133    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0134    | :varlink:`useOBCSsponge`       | FALSE         |                                                                                                     |
                0135    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0136    | :varlink:`useOBCSbalance`      | FALSE         |                                                                                                     |
                0137    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0138    | :varlink:`OBCS_balanceFacN`,   | 1             | Factor(s) determining the details of the balancing code                                             |
                0139    | :varlink:`OBCS_balanceFacS`,   |               |                                                                                                     |
                0140    | :varlink:`OBCS_balanceFacE`,   |               |                                                                                                     |
                0141    | :varlink:`OBCS_balanceFacW`    |               |                                                                                                     |
                0142    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0143    | :varlink:`OBCSbalanceSurf`     | FALSE         | include surface mass flux in balance                                                                |
                0144    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0145    | :varlink:`useOrlanskiNorth`,   | FALSE         | Turn on Orlanski boundary conditions for individual boundary.                                       |
                0146    | :varlink:`useOrlanskiSouth`,   |               |                                                                                                     |
                0147    | :varlink:`useOrlanskiEast`,    |               |                                                                                                     |
                0148    | :varlink:`useOrlanskiWest`     |               |                                                                                                     |
                0149    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0150    | :varlink:`useStevensNorth`,    | FALSE         | Turn on Stevens boundary conditions for individual boundary                                         |
                0151    | :varlink:`useStevensSouth`,    |               |                                                                                                     |
                0152    | :varlink:`useStevensEast`,     |               |                                                                                                     |
                0153    | :varlink:`useStevensWest`      |               |                                                                                                     |
                0154    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0155    | OB\ **Xy**\ File               | :kbd:`' '`    | File name of OB field:                                                                              |
                0156    |                                |               |                                                                                                     |
                0157    |                                |               | **X**: **N**\ (orth), **S**\ (outh), **E**\ (ast), **W**\(est)                                      |
                0158    |                                |               |                                                                                                     |
                0159    |                                |               | **y**: **t**\(emperature), **s**\ (salinity), **eta** (sea surface height),                         |
                0160    |                                |               | **u**\ (-velocity),  **v**\(-velocity), **w**\ (-velocity),                                         |
                0161    |                                |               | **a** (seaice area), **h** (sea ice thickness), **sn** (snow thickness), **sl** (sea ice salinity ) |
                0162    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0163    | **Orlanski Parameters**        | *OBCS_PARM02* |                                                                                                     |
                0164    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0165    | :varlink:`cvelTimeScale`       | 2000.0        | Averaging period for phase speed (seconds)                                                          |
                0166    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0167    | :varlink:`CMAX`                | 0.45          | Maximum allowable phase speed-CFL for AB-II (m/s)                                                   |
                0168    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0169    | :varlink:`CFIX`                | 0.8           | Fixed boundary phase speed (m/s)                                                                    |
                0170    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0171    | :varlink:`useFixedCEast`       | FALSE         |                                                                                                     |
                0172    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0173    | :varlink:`useFixedCWest`       | FALSE         |                                                                                                     |
                0174    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0175    | **Sponge layer parameters**    | *OBCS_PARM03* |                                                                                                     |
                0176    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0177    | :varlink:`spongeThickness`     | 0             | sponge layer thickness (in grid points)                                                             |
                0178    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0179    | :varlink:`Urelaxobcsinner`     | 0.0           | relaxation time scale at the innermost sponge layer point of a meridional OB (s)                    |
                0180    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0181    | :varlink:`Vrelaxobcsinner`     | 0.0           | relaxation time scale at the innermost sponge layer point of a zonal OB (s)                         |
                0182    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0183    | :varlink:`Urelaxobcsbound`     | 0.0           | relaxation time scale at the outermost sponge layer point of a meridional OB (s)                    |
                0184    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0185    | :varlink:`Vrelaxobcsbound`     | 0.0           | relaxation time scale at the outermost sponge layer point of a zonal OB (s)                         |
                0186    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0187    | **Stevens parameters**         | *OBCS_PARM04* |                                                                                                     |
                0188    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0189    | :varlink:`TrelaxStevens`       | 0             | Relaxation time scale for temperature/salinity (s)                                                  |
                0190    | :varlink:`SrelaxStevens`       |               |                                                                                                     |
                0191    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0192    | :varlink:`useStevensPhaseVel`  | TRUE          |                                                                                                     |
                0193    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
                0194    | :varlink:`useStevensAdvection` | TRUE          |                                                                                                     |
                0195    +--------------------------------+---------------+-----------------------------------------------------------------------------------------------------+
8679f9097b Jeff*0196 
                0197 
                0198 .. _ssub_phys_pkg_obcs_defining_open_boundaries:
                0199 
                0200 Defining open boundary positions
                0201 ++++++++++++++++++++++++++++++++
                0202 
bd45a18e71 Mart*0203 There are up to four open boundaries (OBs): Northern, Southern, Eastern, and
8679f9097b Jeff*0204 Western. All OB locations are specified by their absolute meridional
025afa4065 Jeff*0205 (Northern/Southern) or zonal (Eastern/Western) indices. Thus, for each
bf89a37abc Phob*0206 zonal position :math:`i=1\ldots N_x` a meridional index :math:`j`
025afa4065 Jeff*0207 specifies the Northern/Southern OB position, and for each meridional
bf89a37abc Phob*0208 position :math:`j=1\ldots N_y` a zonal index :math:`i` specifies the
8679f9097b Jeff*0209 Eastern/Western OB position. For Northern/Southern OB this defines an
bd45a18e71 Mart*0210 :math:`N_x`-dimensional “row” array :varlink:`OB_Jnorth`\(Nx) /
                0211 :varlink:`OB_Jsouth`\ (Nx) and an :math:`N_y`-dimenisonal “column”
                0212 array :varlink:`OB_Ieast`\(Ny) / :varlink:`OB_Iwest`\(Ny). Positions
8679f9097b Jeff*0213 determined in this way allows Northern/Southern OBs to be at variable
bf89a37abc Phob*0214 :math:`j` (or :math:`y`) positions and Eastern/Western OBs at variable
                0215 :math:`i` (or :math:`x`) positions. Here indices refer to tracer points
3ceb1ce0a9 Jeff*0216 on the C-grid. A zero (0) element in ``OB_I...`` / ``OB_J...`` means there is no corresponding OB in that column/row.
                0217 By default all elements in ``OB_I...`` / ``OB_J...`` are zero. For a Northern/Southern OB, the OB V-point is to the South/North.
                0218 For an Eastern/Western OB, the OB U-point is to the West/East. For example
bf89a37abc Phob*0219 
                0220 
                0221 :code:`OB_Jnorth(3)=34`  means that:
bd45a18e71 Mart*0222   - :code:`T(3,34)`  is a an OB point
025afa4065 Jeff*0223   - :code:`U(3,34)`  is a an OB point
                0224   - :code:`V(3,34)`  is a an OB point
bd45a18e71 Mart*0225 :code:`OB_Jsouth(3)=1`  means that:
                0226   - :code:`T(3,1)`  is a an OB point
                0227   - :code:`U(3,1)`  is a an OB point
                0228   - :code:`V(3,2)`  is a an OB point
                0229 :code:`OB_Ieast(10)=69`   means that:
                0230   - :code:`T(69,10)`  is a an OB point
                0231   - :code:`U(69,10)`  is a an OB point
                0232   - :code:`V(69,10)`  is a an OB point
                0233 :code:`OB_Iwest(10)=1`   means that:
                0234   - :code:`T(1,10)`  is a an OB point
                0235   - :code:`U(2,10)`  is a an OB point
025afa4065 Jeff*0236   - :code:`V(1,10)`  is a an OB point
bf89a37abc Phob*0237 
                0238 
3ceb1ce0a9 Jeff*0239 For convenience, negative values for :varlink:`OB_Jnorth` / :varlink:`OB_Ieast` refer to points relative to the
                0240 Northern/Eastern edges of the model, e.g. ``OB_Jnorth(3)=-1`` means that the point ``(3,Ny)`` is a northern OB
                0241 and ``OB_Ieast(3)=-5`` means that the point ``(3,Nx-5)`` is an eastern OB.
bd45a18e71 Mart*0242 
8679f9097b Jeff*0243 
bd45a18e71 Mart*0244 Simple examples
                0245 ###############
8679f9097b Jeff*0246 
3ceb1ce0a9 Jeff*0247 For a model grid with :math:`N_x \times N_y = 120 \times 144` horizontal grid points with four open boundaries
                0248 along the four edges of the domain, the simplest way of specifying the boundary points:
8679f9097b Jeff*0249 
                0250 ::
                0251 
025afa4065 Jeff*0252       OB_Ieast = 144*-1,
                0253     # or OB_Ieast = 144*120,
                0254       OB_Iwest = 144*1,
                0255       OB_Jnorth = 120*-1,
                0256     # or OB_Jnorth = 120*144,
                0257       OB_Jsouth = 120*1,
8679f9097b Jeff*0258 
3ceb1ce0a9 Jeff*0259 When the boundaries are in single rows or columns as in the above example, the same can be achieved with
                0260 the convenient parameters :varlink:`OB_singleJnorth` / :varlink:`OB_singleJsouth` / :varlink:`OB_singleIeast` / :varlink:`OB_singleIwest`:
bd45a18e71 Mart*0261 
                0262 ::
                0263 
                0264       OB_singleIeast  = -1,
                0265       OB_singleIwest  =  1,
                0266       OB_singleJnorth = -1,
                0267       OB_singleJsouth =  1,
                0268 
bf89a37abc Phob*0269 If only the first 50 grid points of the southern boundary are
8679f9097b Jeff*0270 boundary points:
                0271 
                0272 ::
                0273 
025afa4065 Jeff*0274       OB_Jsouth(1:50) = 50*1,
8679f9097b Jeff*0275 
bd45a18e71 Mart*0276 A more complex example
                0277 ######################
aec20833e6 dram*0278 
bd45a18e71 Mart*0279 Open boundaries are not restricted to single rows or columns. Each OB
                0280 can be distributed in different rows and columns resulting
                0281 in OBs consisting of the combination of different types of
3ceb1ce0a9 Jeff*0282 open boundaries (i.e., N, S, E and W). :numref:`fig_obcsexample` displays
bd45a18e71 Mart*0283 such an OB located on the left-bottom corner of a domain.
                0284 Note there are five boundary points defined by southern and
                0285 western boundaries. In particular, there are five southern
aec20833e6 dram*0286 boundary (blue lines) and two western boundaries points (red lines).
bd45a18e71 Mart*0287 For the boundary displayed in :numref:`fig_obcsexample` and the
                0288 same dimensions as in the previous example (i.e. :math:`120 \times 144` grid points),
aec20833e6 dram*0289 the namelist looks like this:
                0290 
                0291 ::
                0292 
bd45a18e71 Mart*0293       OB_Iwest  = 1*0,1*5,142*0,
                0294       OB_Jsouth = 2*3,3*2,115*0,
aec20833e6 dram*0295 
                0296 .. figure:: figs/obcsexample.*
                0297     :width: 70%
                0298     :align: center
                0299     :alt: Example boundary
                0300     :name: fig_obcsexample
                0301 
bd45a18e71 Mart*0302     Example boundary with more than one row. The dark grey, light grey,
                0303     and white boxes are points outside the domain, OB points, and ocean points,
aec20833e6 dram*0304     respectively. The black dots mark the OB index to write into the namelist.
                0305 
7e0367ac08 Jeff*0306 For an even more complicated open boundary geometry, e.g., delimiting a concave interior domain
                0307 (:varlink:`OB_Ieast` :math:`\leq` :varlink:`OB_Iwest`), one might need to also specify the
                0308 interior domain through an additional input file :varlink:`insideOBmaskFile` for the interior
                0309 mask (:math:`=1` inside, :math:`=0` outside).
                0310 
bd45a18e71 Mart*0311 .. _ssub_phys_pkg_obcs_equations:
                0312 
8679f9097b Jeff*0313 Equations and key routines
                0314 ++++++++++++++++++++++++++
                0315 
bf89a37abc Phob*0316 :filelink:`OBCS\_READPARMS <pkg/obcs/obcs_readparms.F>`:
                0317 ########################################################
8679f9097b Jeff*0318 
025afa4065 Jeff*0319 Set OB positions through arrays OB\_Jnorth(Nx), OB\_Jsouth(Nx),
                0320 OB\_Ieast(Ny), OB\_Iwest(Ny) and runtime flags (see Table
0d16355195 Oliv*0321 :numref:`tab_phys_pkg_obcs_runtime_flags`).
8679f9097b Jeff*0322 
bf89a37abc Phob*0323 :filelink:`OBCS\_CALC <pkg/obcs/obcs_calc.F>`:
                0324 ##############################################
8679f9097b Jeff*0325 
                0326 Top-level routine for filling values to be applied at OB for
025afa4065 Jeff*0327 :math:`T,S,U,V,\eta` into corresponding “slice” arrays :math:`(x,z)`
bd45a18e71 Mart*0328 :math:`(y,z)` for each OB: ``OB[N/S/E/W][t/s/u/v]``; e.g. for the
                0329 salinity array at the Southern OB, the array name is
                0330 :varlink:`OBSs`. Values filled are either
8679f9097b Jeff*0331 
025afa4065 Jeff*0332 -  constant vertical :math:`T,S` profiles as specified in file data
bf380c1040 Mart*0333    (:varlink:`tRef`\ (Nr), :varlink:`sRef`\ (Nr)) with zero velocities
                0334    :math:`U,V`
8679f9097b Jeff*0335 
025afa4065 Jeff*0336 -  :math:`T,S,U,V` values determined via Orlanski radiation conditions
bf89a37abc Phob*0337    (see below)
8679f9097b Jeff*0338 
                0339 -  prescribed time-constant or time-varying fields (see below).
                0340 
bd45a18e71 Mart*0341 -  prescribed boundary fields to compute Stevens boundary
8679f9097b Jeff*0342    conditions.
                0343 
                0344 
bf89a37abc Phob*0345 :filelink:`ORLANSKI <pkg/obcs/ORLANSKI.h>`:
                0346 ###########################################
8679f9097b Jeff*0347 
bf380c1040 Mart*0348 Orlanski radiation conditions :cite:`orl:76` examples can be found in
c1f7a487c0 Jeff*0349 example configurations :filelink:`verification/dome` and
                0350 :filelink:`verification/tutorial_plume_on_slope`
                0351 (as described in detail in :numref:`tutorial_plume_on_slope`).
8679f9097b Jeff*0352 
                0353 
bf89a37abc Phob*0354 :filelink:`OBCS\_PRESCRIBE\_READ <pkg/obcs/obcs\_prescibe\_read.F>`:
                0355 ####################################################################
8679f9097b Jeff*0356 
                0357 
bd45a18e71 Mart*0358 When :varlink:`useOBCSprescribe` = ``.TRUE.`` the model tries to read
025afa4065 Jeff*0359 temperature, salinity, u- and v-velocities from files specified in the
bd45a18e71 Mart*0360 runtime parameters ``OB[N/S/E/W][t/s/u/v]File``. These files are
025afa4065 Jeff*0361 the usual IEEE, big-endian files with dimensions of a section along an
8679f9097b Jeff*0362 open boundary:
                0363 
                0364 -  For North/South boundary files the dimensions are
025afa4065 Jeff*0365    :math:`(N_x\times N_r\times\mbox{time levels})`, for East/West
8679f9097b Jeff*0366    boundary files the dimensions are
                0367    :math:`(N_y\times N_r\times\mbox{time levels})`.
                0368 
                0369 -  If a non-linear free surface is used
025afa4065 Jeff*0370    (:numref:`nonlinear-freesurface`), additional files
3ceb1ce0a9 Jeff*0371    ``OB[N/S/E/W]etaFile`` for the sea surface height :math:`\eta` with
8679f9097b Jeff*0372    dimension :math:`(N_{x/y}\times\mbox{time levels})` may be specified.
                0373 
                0374 - If non-hydrostatic dynamics are used
025afa4065 Jeff*0375   (:numref:`non-hydrostatic`), additional files
3ceb1ce0a9 Jeff*0376   ``OB[N/S/E/W]wFile`` for the vertical velocity :math:`w` with
8679f9097b Jeff*0377   dimensions :math:`(N_{x/y}\times N_r\times\mbox{time levels})` can be
                0378   specified.
                0379 
bd45a18e71 Mart*0380 - If :varlink:`useSEAICE` = ``.TRUE.`` then additional files
                0381   ``OB[N/S/E/W][a,h,sl,sn,uice,vice]`` for sea ice area, thickness
                0382   (:varlink:`HEFF`), seaice salinity, snow and ice velocities
8679f9097b Jeff*0383   :math:`(N_{x/y}\times\mbox{time levels})` can be specified.
                0384 
3ceb1ce0a9 Jeff*0385 As in :filelink:`external_fields_load.F
                0386 <model/src/external_fields_load.F>` or as done in :filelink:`pkg/exf`,
                0387 the code reads two time levels for each
bd45a18e71 Mart*0388 variable, e.g., :varlink:`OBNu0` and :varlink:`OBNu1`, and
                0389 interpolates linearly between these time levels to obtain the value
3ceb1ce0a9 Jeff*0390 :varlink:`OBNu` at the current model time (step). When
                0391 :filelink:`pkg/exf` is used, the time levels are
bd45a18e71 Mart*0392 controlled for each boundary separately in the same way as the
3ceb1ce0a9 Jeff*0393 :filelink:`pkg/exf` fields in ``data.exf``, namelist
                0394 ``EXF_NML_OBCS``. The run-time flags follow the above naming
bd45a18e71 Mart*0395 conventions, e.g., for the western boundary the corresponding flags
3ceb1ce0a9 Jeff*0396 are :varlink:`OBCSWstartdate1`, :varlink:`OBCSWstartdate2` and
                0397 :varlink:`OBCSWperiod`. Sea-ice boundary values are controlled
bd45a18e71 Mart*0398 separately with :varlink:`siobWstartdate1`, :varlink:`siobWstartdate2`
3ceb1ce0a9 Jeff*0399 and :varlink:`siobWperiod`.  When :filelink:`pkg/exf`
bd45a18e71 Mart*0400 is not used the time levels are controlled by the runtime flags
                0401 :varlink:`externForcingPeriod` and :varlink:`externForcingCycle` in
                0402 ``data``; see :filelink:`verification/exp4/input/data` for an example.
8679f9097b Jeff*0403 
                0404 
bf89a37abc Phob*0405 :filelink:`OBCS\_CALC\_STEVENS <pkg/obcs/obcs_calc_stevens.F>`:
                0406 ###############################################################
8679f9097b Jeff*0407 
                0408 The boundary conditions following :cite:`stevens:90` require the
                0409 vertically averaged normal velocity (originally specified as a stream
                0410 function along the open boundary) :math:`\bar{u}_{ob}` and the tracer fields
                0411 :math:`\chi_{ob}` (note: passive tracers are currently not implemented and
bf89a37abc Phob*0412 the code stops when package :ref:`ptracers <sub_phys_pkg_ptracers>` is used together with this
                0413 option). Currently the code vertically averages the normal velocity
025afa4065 Jeff*0414 as specified in :code:`OB[E,W]u` or :code:`OB[N,S]v`. From these
8679f9097b Jeff*0415 prescribed values the code computes the boundary values for the next
025afa4065 Jeff*0416 timestep :math:`n+1` as follows (as an example, we use the notation for an
8679f9097b Jeff*0417 eastern or western boundary):
                0418 
                0419 
025afa4065 Jeff*0420 -  :math:`u^{n+1}(y,z) = \bar{u}_{ob}(y) + (u')^{n}(y,z)` where
8679f9097b Jeff*0421    :math:`(u')^{n}` is the deviation from the vertically averaged
                0422    velocity at timestep :math:`n` on the boundary. :math:`(u')^{n}` is
                0423    computed in the previous time step :math:`n` from the intermediate
025afa4065 Jeff*0424    velocity :math:`u^*` prior to the correction step (see
3ceb1ce0a9 Jeff*0425    :numref:`time_stepping` equation :eq:`ustar-backward-free-surface`). (This velocity is not
025afa4065 Jeff*0426    available at the beginning of the next time step :math:`n+1`, when
3ceb1ce0a9 Jeff*0427    S/Rs :filelink:`OBCS_CALC <pkg/obcs/obcs_calc.F>` and :filelink:`OBCS_CALC_STEVENS <pkg/obcs/obcs_calc_stevens.F>`
                0428    are called, therefore it needs to
                0429    be saved in :filelink:`S/R DYNAMICS <model/src/dynamics.F>` by
                0430    calling :filelink:`S/R OBCS_SAVE_UV_N <pkg/obcs/obcs_save_uv_n.F>` and also
8679f9097b Jeff*0431    stored in a separate restart files
                0432    ``pickup_stevens[N/S/E/W].${iteration}.data``)
                0433 
025afa4065 Jeff*0434 -  If :math:`u^{n+1}` is directed into the model domain, the boudary
8679f9097b Jeff*0435    value for tracer :math:`\chi` is restored to the prescribed values:
                0436 
                0437    .. math::
                0438 
bd45a18e71 Mart*0439       \chi^{n+1} = \chi^{n} + \frac{\Delta{t}}{\tau_\chi} (\chi_{ob} -
bf89a37abc Phob*0440         \chi^{n})
8679f9097b Jeff*0441 
bd45a18e71 Mart*0442    where :math:`\tau_\chi` is the relaxation time scale (either
3ceb1ce0a9 Jeff*0443    :varlink:`TrelaxStevens` or :varlink:`SrelaxStevens`). The new
bd45a18e71 Mart*0444    :math:`\chi^{n+1}` is then subject to the advection by
                0445    :math:`u^{n+1}`.
8679f9097b Jeff*0446 
025afa4065 Jeff*0447 -  If :math:`u^{n+1}` is directed out of the model domain, the tracer
8679f9097b Jeff*0448    :math:`\chi^{n+1}` on the boundary at timestep :math:`n+1` is
025afa4065 Jeff*0449    estimated from advection out of the domain with :math:`u^{n+1}+c`,
8679f9097b Jeff*0450    where :math:`c` is a phase velocity estimated as
bd45a18e71 Mart*0451    :math:`\frac{1}{2} \frac{\partial\chi}{\partial{t}}/
                0452    \frac{\partial\chi}{\partial{x}}`.
8679f9097b Jeff*0453    The numerical scheme is (as an example for an eastern boundary):
                0454 
                0455    .. math::
                0456 
bd45a18e71 Mart*0457       \chi_{i_{b},j,k}^{n+1} =   \chi_{i_{b},j,k}^{n} + \Delta{t}
025afa4065 Jeff*0458         (u^{n+1}+c)_{i_{b},j,k}\frac{\chi_{i_{b},j,k}^{n}
bd45a18e71 Mart*0459           - \chi_{i_{b}-1,j,k}^{n}}{\Delta{x}_{i_{b}j}^{C}}
                0460             \mbox{ if }u_{i_{b}jk}^{n+1}>0
8679f9097b Jeff*0461 
bd45a18e71 Mart*0462    where :math:`i_{b}` is the boundary index.  For test purposes, the
                0463    phase velocity contribution or the entire advection can be turned
                0464    off by setting the corresponding parameters
                0465    :varlink:`useStevensPhaseVel` and :varlink:`useStevensAdvection` to
                0466    ``.FALSE.``.
8679f9097b Jeff*0467 
                0468 See :cite:`stevens:90` for details. With this boundary condition
025afa4065 Jeff*0469 specifying the exact net transport across the open boundary is simple,
bd45a18e71 Mart*0470 so that balancing the flow with (:filelink:`S/R OBCS_BALANCE_FLOW
                0471 <pkg/obcs/obcs_balance_flow.F>` see next paragraph) is usually not
                0472 necessary.
8679f9097b Jeff*0473 
0ccc7e686c Mart*0474 Special cases where the current implementation is not complete:
                0475 
bd45a18e71 Mart*0476 - When you use the non-linear free surface option (parameter :varlink:`nonlinFreeSurf` > 1), the current implementation just assumes that the gradient normal to the open boundary is zero (:math:`\frac{\partial\eta}{\partial{n}} = 0`). Although this is inconsistent with geostrophic dynamics and the possibility to specify a non-zero tangent velocity together with Stevens BCs for normal velocities, it seems to work. Recommendation: Always specify zero tangential velocities with Stevens BCs.
0ccc7e686c Mart*0477 
bd45a18e71 Mart*0478 - There is no code for passive tracers, just a commented template in :filelink:`S/R OBCS_CALC_STEVENS <pkg/obcs/obcs_calc_stevens.F>`. This means that passive tracers can be specified independently and are fluxed with the velocities that the Stevens BCs compute, but without the restoring term.
0ccc7e686c Mart*0479 
025afa4065 Jeff*0480 - There are no specific Stevens BCs for sea ice, e.g., :ref:`pkg/seaice <sub_phys_pkg_seaice>`. The model uses the default boundary conditions for the sea ice packages.
0ccc7e686c Mart*0481 
bf89a37abc Phob*0482 :filelink:`OBCS\_BALANCE\_FLOW <pkg/obcs/obcs_balance_flow.F>`:
                0483 ###############################################################
8679f9097b Jeff*0484 
3ceb1ce0a9 Jeff*0485 When turned on (CPP option :varlink:`ALLOW_OBCS_BALANCE` defined in
bd45a18e71 Mart*0486 :filelink:`OBCS_OPTIONS.h <pkg/obcs/OBCS_OPTIONS.h>` and
                0487 :varlink:`useOBCSbalance` set to ``.TRUE.`` in
                0488 ``data.obcs/OBCS_PARM01``), this routine balances the net flow across
                0489 the open boundaries. By default the net flow across the boundaries is
                0490 computed and all normal velocities on boundaries are adjusted to
                0491 obtain zero net inflow.
8679f9097b Jeff*0492 
                0493 This behavior can be controlled with the runtime flags
bd45a18e71 Mart*0494 :varlink:`OBCS_balanceFacN`, :varlink:`OBCS_balanceFacS`,
                0495 :varlink:`OBCS_balanceFacE`, and :varlink:`OBCS_balanceFacW`. The
                0496 values of these flags determine how the net inflow is redistributed as
                0497 small correction velocities between the individual sections. A value
3ceb1ce0a9 Jeff*0498 -1 balances an individual boundary, values >0 determine
bd45a18e71 Mart*0499 the relative size of the correction. For example, the values
                0500 
                0501 ::
8679f9097b Jeff*0502 
bd45a18e71 Mart*0503    OBCS_balanceFacE = 1.,
                0504    OBCS_balanceFacW = -1.,
                0505    OBCS_balanceFacN = 2.,
                0506    OBCS_balanceFacS = 0.,
8679f9097b Jeff*0507 
                0508 
                0509 make the model
                0510 
bd45a18e71 Mart*0511 -  correct Western :varlink:`OBWu` by substracting a uniform velocity to ensure zero net
8679f9097b Jeff*0512    transport through the Western open boundary;
                0513 
025afa4065 Jeff*0514 -  correct Eastern and Northern normal flow, with the Northern velocity
                0515    correction two times larger than the Eastern correction, but *not*
                0516    the Southern normal flow, to ensure that the total inflow through
                0517    East, Northern, and Southern open boundary is balanced.
8679f9097b Jeff*0518 
                0519 
                0520 The old method of balancing the net flow for all sections individually
                0521 can be recovered by setting all flags to -1. Then the normal velocities
025afa4065 Jeff*0522 across each of the four boundaries are modified separately, so that the
                0523 net volume transport across *each* boundary is zero. For example, for
                0524 the western boundary at :math:`i=i_{b}`, the modified velocity is:
8679f9097b Jeff*0525 
                0526 .. math::
                0527 
025afa4065 Jeff*0528    u(y,z) - \int_{\mbox{western boundary}}u dy dz \approx OBNu(j k) - \sum_{j k}
                0529    OBNu(j k) h_{w}(i_{b} j k)\Delta{y_G(i_{b} j)}\Delta{z(k)}.
8679f9097b Jeff*0530 
025afa4065 Jeff*0531 This also ensures a net total inflow of zero through all boundaries, but
                0532 this combination of flags is *not* useful if you want to simulate, for example,
8679f9097b Jeff*0533 a sector of the Southern Ocean with a strong ACC entering through the
025afa4065 Jeff*0534 western and leaving through the eastern boundary, because the value of
3ceb1ce0a9 Jeff*0535 -1 for these flags will make sure that the strong inflow is removed.
                0536 Clearly, global balancing with ``OBCS_balanceFacE/W/N/S`` :math:`\ge 0`
abfe198bce Mart*0537 is the preferred method.
                0538 
bd45a18e71 Mart*0539 Setting runtime parameter :varlink:`OBCSbalanceSurf` to ``TRUE.``, the
                0540 surface mass flux contribution, say, from surface freshwater flux
                0541 :varlink:`EmPmR` is included in the balancing scheme.
8679f9097b Jeff*0542 
                0543 
                0544 OBCS\_APPLY\_*:
                0545 ###############
                0546 
                0547 
bf89a37abc Phob*0548 :filelink:`OBCS\_SPONGE <pkg/obcs/obcs_sponge.F>`:
                0549 ##################################################
8679f9097b Jeff*0550 
af61e5eb16 Mart*0551 The sponge layer code (turned on with CPP option :varlink:`ALLOW_OBCS_SPONGE`
                0552 and run-time parameter :varlink:`useOBCSsponge`) adds a relaxation term to the
                0553 right-hand-side of the momentum and tracer equations. The variables are relaxed
                0554 towards the boundary values with a relaxation time scale that increases
8679f9097b Jeff*0555 linearly with distance from the boundary
                0556 
                0557 .. math::
                0558 
bd45a18e71 Mart*0559    G_{\chi}^{\mbox{(sponge)}} =
8679f9097b Jeff*0560    - \frac{\chi - [( L - \delta{L} ) \chi_{BC} + \delta{L}\chi]/L}
bd45a18e71 Mart*0561    {[(L-\delta{L})\tau_{b}+\delta{L}\tau_{i}]/L}
8679f9097b Jeff*0562    = - \frac{\chi - [( 1 - l ) \chi_{BC} + l\chi]}
                0563    {[(1-l)\tau_{b}+l\tau_{i}]}
                0564 
025afa4065 Jeff*0565 where :math:`\chi` is the model variable (U/V/T/S) in the interior,
af61e5eb16 Mart*0566 :math:`\chi_{BC}` the boundary value, :math:`L` the thickness of the sponge
                0567 layer (runtime parameter :varlink:`spongeThickness` in number of grid points),
                0568 :math:`\delta{L}\in[0,L]` (:math:`\frac{\delta{L}}{L}=l\in[0,1]`) the distance
                0569 from the boundary (also in grid points), and :math:`\tau_{b}` (runtime
                0570 parameters :varlink:`Urelaxobcsbound` and :varlink:`Vrelaxobcsbound`) and
bd45a18e71 Mart*0571 :math:`\tau_{i}` (runtime parameters :varlink:`Urelaxobcsinner` and
af61e5eb16 Mart*0572 :varlink:`Vrelaxobcsinner`) the relaxation time scales on the boundary and at
                0573 the interior termination of the sponge layer. The parameters
                0574 :varlink:`Urelaxobcsbound` and :varlink:`Urelaxobcsinner` set the relaxation
                0575 time scales for the Eastern and Western boundaries, :varlink:`Vrelaxobcsbound`
                0576 and :varlink:`Vrelaxobcsinner` for the Northern and Southern boundaries.
8679f9097b Jeff*0577 
                0578 
                0579 OB's with nonlinear free surface
                0580 ################################
                0581 
0ccc7e686c Mart*0582 OB's with sea ice
                0583 #################
                0584 
af61e5eb16 Mart*0585 Simple Dirichlet boundary conditions for sea ice parameters can be specified in
                0586 anology to the ocean variables via filenames ``OB[N/S/E/W][a/h/sl/sn/u/v]File``
                0587 (sea ice concentration, cell averaged sea ice thickness, salinity, cell
                0588 averaged snow thickness, ice drift components). With CPP-flag
                0589 :varlink:`ALLOW_OBCS_SEAICE_SPONGE` and runtime flags
                0590 :varlink:`useSeaiceSponge`, :varlink:`seaiceSpongeThickness`, and
                0591 ``[A/H/SL/SN]relaxobcs[inner/bound]`` are available in analogy to the sponge
                0592 parameters for the ocean variables.
                0593 
                0594 Neumann boundary conditions :math:`\frac{\partial\phi}{\partial{n}}=0` for all
                0595 sea ice variables can be applied with runtime flag
                0596 :varlink:`SEAICEuseNeumannBC`, which overrides the input files for the
                0597 Dirichlet values.
                0598 
                0599 Defining CPP-flag :varlink:`OBCS_SEAICE_SMOOTH_EDGE` allows to smooth the
                0600 tracer sea-ice variables near the edges.
                0601 
0ccc7e686c Mart*0602 
8679f9097b Jeff*0603 .. _ssub_phys_pkg_obcs_flowchart:
                0604 
                0605 Flow chart
                0606 ++++++++++
                0607 
                0608 
                0609 ::
                0610 
                0611 
                0612     C     !CALLING SEQUENCE:
af61e5eb16 Mart*0613     C    [...]
                0614     C    | |-MAIN_DO_LOOP    :: Open-AD case: Main timestepping loop routine
                0615     C    | \                    otherwise: just call FORWARD_STEP
                0616     C    | |
                0617     C/\  | |-FORWARD_STEP        :: Step forward a time-step ( AT LAST !!! )
                0618     C    [...]
                0619     C/\  | | |-DO_OCEANIC_PHYS   :: Oceanic (& seaice) physics computation
                0620     C/\  | | | |
                0621     C/\  | | | |-OBCS_CALC       :: Open boundary. package (see pkg/obcs).
                0622     C/\  | | | |
                0623     C    [...]
                0624     C/\  | | | |-SEAICE_MODEL          :: pkg/seaice
                0625     C/\  | | | | |-SEAICE_DYNSOLVER    :: pkg/seaice
                0626     C/\  | | | | | |-OBCS_APPLY_UVICE  :: apply uIce/vIce boudnary conditions
                0627     C/\  | | | | |-OBCS_ADJUST_UVICE   :: (Only for OBCS_UVICE_OLD)
                0628     C/\  | | | | |-SEAICE_GROWTH
                0629     C/\  | | | | |-SEAICE_APPLY_SEAICE :: add OBCS for scalar variables
                0630     C    [...]
                0631     C/\  | | |-THERMODYNAMICS         :: theta, salt + tracer equations driver.
                0632     C/\  | | | |                         (synchronous time-stepping case)
                0633     C    [...]
                0634     C/\  | | | |-TEMP_INTEGRATE       :: Step forward Prognostic Eq for Temperature.
                0635     C/\  | | | |
                0636     C/\  | | | |-SALT_INTEGRATE       :: Step forward Prognostic Eq for Salinity.
                0637     C/\  | | | |                         same sequence of calls as in TEMP_INTEGRATE
                0638     C/\  | | | |
                0639     C/\  | | | |-PTRACERS_INTEGRATE   :: Integrate other tracer(s) (see pkg/ptracers).
                0640     C/\  | | | | |                     same sequence of calls as in TEMP_INTEGRATE
                0641     C/\  | | | | |-OBCS_APPLY_PTRACER :: Open boundary package for pTracers
                0642     C/\  | | | |
                0643     C/\  | | | |-OBCS_APPLY_TS        :: Open boundary package (see pkg/obcs ).
                0644     C/\  | | |
                0645     C    [...]
                0646     C/\  | | |
                0647     C/\  | | |-DYNAMICS       :: Momentum equations driver.
                0648     C/\  | | | |
                0649     C    [...]
                0650     C/\  | | | |-OBCS_APPLY_UV    :: Apply Open bndary Conditions to provisional U,V
                0651     C    [...]
                0652     C/\  | | |-MOMENTUM_CORRECTION_STEP :: Finalise momentum stepping
                0653     C    [...]
                0654     C/\  | | | |-OBCS_APPLY_UV       :: Open boundary package (see pkg/obcs).
                0655 
8679f9097b Jeff*0656 
                0657 
                0658 .. _ssub_phys_pkg_obcs_diagnostics:
                0659 
                0660 OBCS diagnostics
                0661 ++++++++++++++++
                0662 
af61e5eb16 Mart*0663 Diagnostics output is available via the diagnostics package (see
                0664 :numref:`sub_outp_pkg_diagnostics`). Currently there are no OBCS-specific
                0665 diagnostics available.
8679f9097b Jeff*0666 
                0667 
bf89a37abc Phob*0668 .. _ssub_phys_pkg_obcs_experiments:
8679f9097b Jeff*0669 
bf89a37abc Phob*0670 Experiments and tutorials that use obcs
                0671 +++++++++++++++++++++++++++++++++++++++
8679f9097b Jeff*0672 
025afa4065 Jeff*0673 In the directory :filelink:`verification` the following experiments use
3ceb1ce0a9 Jeff*0674 :filelink:`pkg/obcs`:
8679f9097b Jeff*0675 
                0676 
025afa4065 Jeff*0677 -  :filelink:`exp4 <verification/exp4>`: box with 4 open boundaries, simulating flow over a Gaussian bump
bf89a37abc Phob*0678    based on  also tests Stevens-boundary conditions;
8679f9097b Jeff*0679 
bf89a37abc Phob*0680 -  :filelink:`dome <verification/dome>`: based on the project “Dynamics of Overflow Mixing and Entrainment”
3ceb1ce0a9 Jeff*0681    uses Orlanski-BCs;
8679f9097b Jeff*0682 
3ceb1ce0a9 Jeff*0683 -  :filelink:`internal_wave <verification/internal_wave>`: uses a heavily modified :filelink:`S/R OBCS_CALC <verification/internal_wave/code/obcs_calc.F>`
8679f9097b Jeff*0684 
bf89a37abc Phob*0685 -  :filelink:`seaice_obcs <verification/seaice_obcs>`: simple example who to use the sea-ice related code based on :filelink:`lab_sea <verification/lab_sea>`;
8679f9097b Jeff*0686 
bf1e6e69d5 Mart*0687 -  Tutorial :ref:`tutorial_plume_on_slope`: uses Orlanski-BCs.