| 364 | 
 $\chi_{ob}$ (note: passive tracers are currently not implemented and | 
 $\chi_{ob}$ (note: passive tracers are currently not implemented and | 
| 365 | 
 the code stops when package \code{ptracers} is used together with this | 
 the code stops when package \code{ptracers} is used together with this | 
| 366 | 
 option). Currently, the code vertically averages the normal velocity | 
 option). Currently, the code vertically averages the normal velocity | 
| 367 | 
 as specified. From these prescribed values the code computes the | 
 as specified in \code{OB[E,W]u} or \code{OB[N,S]v}. From these | 
| 368 | 
 boundary values for the next timestep $n+1$ as follows (as an  | 
 prescribed values the code computes the boundary values for the next | 
| 369 | 
 example, we use the notation for an eastern or western boundary): | 
 timestep $n+1$ as follows (as an example, we use the notation for an | 
| 370 | 
  | 
 eastern or western boundary): | 
| 371 | 
 \begin{itemize} | 
 \begin{itemize} | 
| 372 | 
 \item $u^{n+1}(y,z) = \bar{u}_{ob}(y) + u'(y,z)$, where $u_{n}'$ is the | 
 \item $u^{n+1}(y,z) = \bar{u}_{ob}(y) + (u')^{n}(y,z)$, where $(u')^{n}$ | 
| 373 | 
   deviation from the vertically averaged velocity one grid point | 
   is the deviation from the vertically averaged velocity at timestep | 
| 374 | 
   inward from the boundary. | 
   $n$ one grid point inward from the boundary. | 
| 375 | 
 \item If $u^{n+1}$ is directed into the model domain, the boudary | 
 \item If $u^{n+1}$ is directed into the model domain, the boudary | 
| 376 | 
   value for tracer $\chi$ is restored to the prescribed values: | 
   value for tracer $\chi$ is restored to the prescribed values: | 
| 377 | 
   \[\chi^{n+1} =   \chi^{n} + \frac{\Delta{t}}{\tau_\chi} (\chi_{ob} - | 
   \[\chi^{n+1} =   \chi^{n} + \frac{\Delta{t}}{\tau_\chi} (\chi_{ob} - | 
| 378 | 
   \chi^{n}),\] where $\tau_\chi$ is the relaxation time | 
   \chi^{n}),\] where $\tau_\chi$ is the relaxation time | 
| 379 | 
   scale \texttt{T/SrelaxStevens}. | 
   scale \texttt{T/SrelaxStevens}. The new $\chi^{n+1}$ is then subject | 
| 380 | 
 \item If $u^{n+1}$ is directed out of the model domain, the tracer is | 
   to the advection by $u^{n+1}$. | 
| 381 | 
   advected out of the domain with $u^{n+1}+c$, where $c$ is a phase | 
 \item If $u^{n+1}$ is directed out of the model domain, the tracer | 
| 382 | 
   velocity estimated as | 
   $\chi^{n+1}$ on the boundary at timestep $n+1$ is estimated from | 
| 383 | 
   $\frac{1}{2}\frac{\partial\chi}{\partial{t}}/\frac{\partial\chi}{\partial{x}}$. | 
   advection advected out of the domain with $u^{n+1}+c$, where $c$ is | 
| 384 | 
  | 
   a phase velocity estimated as | 
| 385 | 
  | 
   $\frac{1}{2}\frac{\partial\chi}{\partial{t}}/\frac{\partial\chi}{\partial{x}}$. The | 
| 386 | 
  | 
   numerical scheme is (as an example for an eastern boundary): | 
| 387 | 
  | 
   \[\chi_{i,j,k}^{n+1} =   \chi_{i,j,k}^{n} + \Delta{t}  | 
| 388 | 
  | 
   (u^{n+1}+c)_{i_{b},j,k}\frac{\chi_{i_{b},j,k}^{n} | 
| 389 | 
  | 
     - \chi_{i_{b}-1,j,k}^{n}}{\Delta{x}_{i_{b},j}^{C}}\mbox{, if }u_{i_{b},j,k}^{n+1}>0, | 
| 390 | 
  | 
   \] where $i_{b}$ is the boundary index. | 
| 391 | 
  | 
  | 
| 392 | 
   For test purposes, the phase velocity contribution or the entire | 
   For test purposes, the phase velocity contribution or the entire | 
| 393 | 
   advection can | 
   advection can be turned off by setting the corresponding parameters | 
 | 
   be turned off by setting the corresponding parameters | 
  | 
| 394 | 
   \texttt{useStevensPhaseVel} and \texttt{useStevensAdvection} to | 
   \texttt{useStevensPhaseVel} and \texttt{useStevensAdvection} to | 
| 395 | 
   \texttt{.FALSE.}.\end{itemize} See \citet{stevens:90} for details. | 
   \texttt{.FALSE.}.\end{itemize} See \citet{stevens:90} for details. | 
| 396 | 
  | 
  | 
| 408 | 
 how the net inflow is redistributed as small correction velocities | 
 how the net inflow is redistributed as small correction velocities | 
| 409 | 
 between the individual sections. A value ``\code{-1}'' balances an | 
 between the individual sections. A value ``\code{-1}'' balances an | 
| 410 | 
 individual boundary, values $>0$ determine the relative size of the | 
 individual boundary, values $>0$ determine the relative size of the | 
| 411 | 
 correction. For example, with the values | 
 correction. For example, the values | 
| 412 | 
 \begin{tabbing} | 
 \begin{tabbing} | 
| 413 | 
  \code{OBCS\_balanceFac\_E}\=\code{ = 1.,} \\ | 
  \code{OBCS\_balanceFacE}\code{ = 1.,} \\ | 
| 414 | 
  \code{OBCS\_balanceFac\_W}\>\code{ = -1.,} \\ | 
  \code{OBCS\_balanceFacW}\code{ = -1.,} \\ | 
| 415 | 
  \code{OBCS\_balanceFac\_N}\>\code{ = 2.,} \\ | 
  \code{OBCS\_balanceFacN}\code{ = 2.,} \\ | 
| 416 | 
  \code{OBCS\_balanceFac\_S}\>\code{ = 0.,} | 
  \code{OBCS\_balanceFacS}\code{ = 0.,} | 
| 417 | 
 \end{tabbing} | 
 \end{tabbing} | 
| 418 | 
 will make the model | 
 make the model | 
| 419 | 
 \begin{itemize} | 
 \begin{itemize} | 
| 420 | 
 \item correct Western \code{OBWu} by substracting a uniform velocity to | 
 \item correct Western \code{OBWu} by substracting a uniform velocity to | 
| 421 | 
 ensure zero net transport through Western OB | 
 ensure zero net transport through the Western open boundary; | 
| 422 | 
 \item correct Eastern and Northern normal flow, with the Northern | 
 \item correct Eastern and Northern normal flow, with the Northern | 
| 423 | 
   velocity correction two times larger than Eastern correction, but | 
   velocity correction two times larger than the Eastern correction, but | 
| 424 | 
   not the Southern normal flow to ensure that the total inflow through | 
   \emph{not} the Southern normal flow, to ensure that the total inflow through | 
| 425 | 
   East, Northern, and Southern OB is balanced | 
   East, Northern, and Southern open boundary is balanced. | 
| 426 | 
 \end{itemize} | 
 \end{itemize} | 
| 427 | 
  | 
  | 
| 428 | 
 The old method of balancing the net flow for all sections individually | 
 The old method of balancing the net flow for all sections individually | 
| 435 | 
 u(y,z) - \int_{\mbox{western boundary}}u\,dy\,dz \approx OBNu(j,k) - \sum_{j,k} | 
 u(y,z) - \int_{\mbox{western boundary}}u\,dy\,dz \approx OBNu(j,k) - \sum_{j,k} | 
| 436 | 
 OBNu(j,k) h_{w}(i_{b},j,k)\Delta{y_G(i_{b},j)}\Delta{z(k)}. | 
 OBNu(j,k) h_{w}(i_{b},j,k)\Delta{y_G(i_{b},j)}\Delta{z(k)}. | 
| 437 | 
 \] | 
 \] | 
| 438 | 
 This also ensures a net total inflow of zero through all boundaries to | 
 This also ensures a net total inflow of zero through all boundaries, | 
| 439 | 
 make it a useful flag for preventing infinite sea-level change within | 
 but this combination of flags is \emph{not} useful if you want to | 
| 440 | 
 the domain, but this combination of flags is \emph{not} useful if you | 
 simulate, say, a sector of the Southern Ocean with a strong ACC | 
| 441 | 
 want to simulate, say, a sector of the Southern Ocean with a strong | 
 entering through the western and leaving through the eastern boundary, | 
| 442 | 
 ACC entering through the western and leaving through the eastern | 
 because the value of ``\code{-1}'' for these flags will make sure that | 
| 443 | 
 boundary, because the value of ``\code{-1}'' for these flags will make | 
 the strong inflow is removed. Clearly, gobal balancing with | 
| 444 | 
 sure that the strong inflow is removed. | 
 \code{OBCS\_balanceFacE/W/N/S} $\ge0$ is the preferred method. | 
| 445 | 
  | 
  | 
| 446 | 
 \paragraph{OBCS\_APPLY\_*:} ~ \\ | 
 \paragraph{OBCS\_APPLY\_*:} ~ \\ | 
| 447 | 
 ~ | 
 ~ | 
| 463 | 
 where $\chi$ is the model variable (U/V/T/S) in the interior, | 
 where $\chi$ is the model variable (U/V/T/S) in the interior, | 
| 464 | 
 $\chi_{BC}$ the boundary value, $L$ the thickness of the sponge layer | 
 $\chi_{BC}$ the boundary value, $L$ the thickness of the sponge layer | 
| 465 | 
 (runtime parameter \code{spongeThickness} in number of grid points), | 
 (runtime parameter \code{spongeThickness} in number of grid points), | 
| 466 | 
 $\delta{L}\in[0,L]$ ($l\in[0,1]$) the distance from the boundary (also in grid points), and | 
 $\delta{L}\in[0,L]$ ($\frac{\delta{L}}{L}=l\in[0,1]$) the distance from the boundary (also in grid points), and | 
| 467 | 
 $\tau_{b}$ (runtime parameters \code{Urelaxobcsbound} and | 
 $\tau_{b}$ (runtime parameters \code{Urelaxobcsbound} and | 
| 468 | 
 \code{Vrelaxobcsbound}) and $\tau_{i}$ (runtime parameters | 
 \code{Vrelaxobcsbound}) and $\tau_{i}$ (runtime parameters | 
| 469 | 
 \code{Urelaxobcsinner} and \code{Vrelaxobcsinner}) the relaxation time | 
 \code{Urelaxobcsinner} and \code{Vrelaxobcsinner}) the relaxation time |