\hypertarget{namespacemom__open__boundary}{}\doxysection{mom\+\_\+open\+\_\+boundary Module Reference}
\label{namespacemom__open__boundary}\index{mom\_open\_boundary@{mom\_open\_boundary}}


\doxysubsection{Detailed Description}
Controls where open boundary conditions are applied. 

This module implements some aspects of internal open boundary conditions in M\+OM.

A small fragment of the grid is shown below\+:

j+1 x $^\wedge$ x $^\wedge$ x At x\+: q, Coriolis\+Bu j+1 $>$ o $>$ o $>$ At $^\wedge$\+: v, tauy j x $^\wedge$ x $^\wedge$ x At $>$\+: u, taux j $>$ o $>$ o $>$ At o\+: h, bathyT, buoy, tr, T, S, Rml, ustar j-\/1 x $^\wedge$ x $^\wedge$ x i-\/1 i i+1 At x \& $^\wedge$\+: i i+1 At $>$ \& o\+:

The boundaries always run through q grid points (x). \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1file__obc__cs}{file\+\_\+obc\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure for open boundaries that read from files. Probably lots to update here. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1obc__registry__type}{obc\+\_\+registry\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Type to carry basic O\+BC information needed for updating values. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__data__type}{obc\+\_\+segment\+\_\+data\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Open boundary segment data from files (mostly). \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__tracer__type}{obc\+\_\+segment\+\_\+tracer\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Tracer on O\+BC segment data structure, for putting into a segment tracer registry. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Open boundary segment data structure. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1obc__struct__type}{obc\+\_\+struct\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Type to carry something (what\mbox{]} for the O\+BC registry. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Open-\/boundary data. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__open__boundary_1_1segment__tracer__registry__type}{segment\+\_\+tracer\+\_\+registry\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Registry type for tracers on segments. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_ac94938f1a657896ff03efd3864faa02a}{open\+\_\+boundary\+\_\+config}} (G, US, param\+\_\+file, O\+BC)
\begin{DoxyCompactList}\small\item\em Enables O\+BC module and reads configuration parameters This routine is called from M\+O\+M\+\_\+initialize\+\_\+fixed which occurs before the initialization of the vertical coordinate and A\+L\+E\+\_\+init. Therefore segment data are not fully initialized here. The remainder of the segment data are initialized in a later call to update\+\_\+open\+\_\+boundary\+\_\+data. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a81b020bcce067d3c3a45a21faa526227}{initialize\+\_\+segment\+\_\+data}} (G, O\+BC, PF)
\begin{DoxyCompactList}\small\item\em Allocate space for reading O\+BC data from files. It sets up the required vertical remapping. In the process, it does funky stuff with the M\+PI processes. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a47ad907f8613e7400ac3c6919c22bb11}{initialize\+\_\+obc\+\_\+tides}} (O\+BC, param\+\_\+file)
\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_ac357a1fb341db3aaffdfeca2eacab60b}{setup\+\_\+segment\+\_\+indices}} (G, seg, Is\+\_\+obc, Ie\+\_\+obc, Js\+\_\+obc, Je\+\_\+obc)
\begin{DoxyCompactList}\small\item\em Define indices for segment and store in hor\+\_\+index\+\_\+type using global segment bounds corresponding to q-\/points. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_aa40e3464225d4e017b1a738995eeb3b2}{setup\+\_\+u\+\_\+point\+\_\+obc}} (O\+BC, G, US, segment\+\_\+str, l\+\_\+seg, PF, reentrant\+\_\+y)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string starting with \char`\"{}\+I=\char`\"{} and configure placement and type of O\+BC accordingly. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a706dd2fb2049757b3b76bf8b481e735c}{setup\+\_\+v\+\_\+point\+\_\+obc}} (O\+BC, G, US, segment\+\_\+str, l\+\_\+seg, PF, reentrant\+\_\+x)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string starting with \char`\"{}\+J=\char`\"{} and configure placement and type of O\+BC accordingly. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a0eb361009a2dddf3ad9a24d0d7223898}{parse\+\_\+segment\+\_\+str}} (ni\+\_\+global, nj\+\_\+global, segment\+\_\+str, l, m, n, action\+\_\+str, reentrant)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a69848c26ddd38fe0f619311fa518313f}{parse\+\_\+segment\+\_\+manifest\+\_\+str}} (segment\+\_\+str, num\+\_\+fields, fields)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA string and determine its fields. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_ae97f243936ebbcd30c8cfe91d41729c4}{parse\+\_\+segment\+\_\+data\+\_\+str}} (segment\+\_\+str, idx, var, value, filename, fieldname)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA string. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a2e2dbab2a3e23eb9848aba473f635cec}{parse\+\_\+for\+\_\+tracer\+\_\+reservoirs}} (O\+BC, PF, use\+\_\+temperature)
\begin{DoxyCompactList}\small\item\em Parse all the O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA strings again to see which need tracer reservoirs (all pes need to know). \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a349df847b304948d5b98352ddfd7bf8d}{parse\+\_\+segment\+\_\+param\+\_\+real}} (segment\+\_\+str, var, param\+\_\+value, debug)
\begin{DoxyCompactList}\small\item\em Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+P\+A\+R\+A\+MS string. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a53dc87c231fcaf1c99fe818956fb111e}{open\+\_\+boundary\+\_\+init}} (G, GV, US, param\+\_\+file, O\+BC, restart\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize open boundary control structure and do any necessary rescaling of O\+BC fields that have been read from a restart file. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__open__boundary_af55e663cc3a1f5f697e72066d75c9160}{open\+\_\+boundary\+\_\+query}} (O\+BC, apply\+\_\+open\+\_\+\+O\+BC, apply\+\_\+specified\+\_\+\+O\+BC, apply\+\_\+\+Flather\+\_\+\+O\+BC, apply\+\_\+nudged\+\_\+\+O\+BC, needs\+\_\+ext\+\_\+seg\+\_\+data)
\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a709a33b9e33b5689d5ca73349ed51fb6}{open\+\_\+boundary\+\_\+dealloc}} (O\+BC)
\begin{DoxyCompactList}\small\item\em Deallocate open boundary data. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_afb86d9ee7fc99dea787b88cfdb70f139}{open\+\_\+boundary\+\_\+end}} (O\+BC)
\begin{DoxyCompactList}\small\item\em Close open boundary data. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_afc301353fde1f12ef04dab751ddb7ac2}{open\+\_\+boundary\+\_\+impose\+\_\+normal\+\_\+slope}} (O\+BC, G, depth)
\begin{DoxyCompactList}\small\item\em Sets the slope of bathymetry normal to an open bounndary to zero. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a7aa6f2b520108ce761ef107557f69069}{open\+\_\+boundary\+\_\+impose\+\_\+land\+\_\+mask}} (O\+BC, G, area\+Cu, area\+Cv, US)
\begin{DoxyCompactList}\small\item\em Reconcile masks and open boundaries, deallocate O\+BC on P\+Es where it is not needed. Also adjust u-\/ and v-\/point cell area on specified open boundaries and mask all points outside open boundaries. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a2578141730f51e42c56bb05c3648ea08}{setup\+\_\+obc\+\_\+tracer\+\_\+reservoirs}} (G, O\+BC)
\begin{DoxyCompactList}\small\item\em Make sure the O\+BC tracer reservoirs are initialized. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_ae5ceafcce53e896d30012f321c73d9f4}{radiation\+\_\+open\+\_\+bdry\+\_\+conds}} (O\+BC, u\+\_\+new, u\+\_\+old, v\+\_\+new, v\+\_\+old, G, US, dt)
\begin{DoxyCompactList}\small\item\em Apply radiation conditions to 3D u,v at open boundaries. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a11acc9ede6f2b975bfc6b849a2603b46}{open\+\_\+boundary\+\_\+apply\+\_\+normal\+\_\+flow}} (O\+BC, G, u, v)
\begin{DoxyCompactList}\small\item\em Applies O\+BC values stored in segments to 3d u,v fields. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a9d48e6925d93fa98cbf5bb73903f94be}{open\+\_\+boundary\+\_\+zero\+\_\+normal\+\_\+flow}} (O\+BC, G, u, v)
\begin{DoxyCompactList}\small\item\em Applies zero values to 3d u,v fields on O\+BC segments. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a151df14c3b8b1094ddf8f44c86493fd5}{gradient\+\_\+at\+\_\+q\+\_\+points}} (G, segment, uvel, vvel)
\begin{DoxyCompactList}\small\item\em Calculate the tangential gradient of the normal flow at the boundary q-\/points. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a0a4c67f2e0fe21f1a2274be12844a71a}{set\+\_\+tracer\+\_\+data}} (O\+BC, tv, h, G, PF, tracer\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em Sets the initial values of the tracer open boundary conditions. Redoing this elsewhere. \end{DoxyCompactList}\item 
integer function \mbox{\hyperlink{namespacemom__open__boundary_a29dd2dc87f43e0e26d22367ce93519ff}{lookup\+\_\+seg\+\_\+field}} (O\+B\+C\+\_\+seg, field)
\begin{DoxyCompactList}\small\item\em Needs documentation. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_aa7f532a65dd8ae4db981f2ef4791fc56}{allocate\+\_\+obc\+\_\+segment\+\_\+data}} (O\+BC, segment)
\begin{DoxyCompactList}\small\item\em Allocate segment data fields. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a5d71c596c3bd7d773a39f5c63d5389ac}{deallocate\+\_\+obc\+\_\+segment\+\_\+data}} (O\+BC, segment)
\begin{DoxyCompactList}\small\item\em Deallocate segment data fields. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a556977a2754fab17e837a8fba75cd9ee}{open\+\_\+boundary\+\_\+test\+\_\+extern\+\_\+uv}} (G, O\+BC, u, v)
\begin{DoxyCompactList}\small\item\em Set tangential velocities outside of open boundaries to silly values (used for checking the interior state is independent of values outside of the domain). \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a4123d11abdb141b21a4d52a0c43c4adb}{open\+\_\+boundary\+\_\+test\+\_\+extern\+\_\+h}} (G, GV, O\+BC, h)
\begin{DoxyCompactList}\small\item\em Set thicknesses outside of open boundaries to silly values (used for checking the interior state is independent of values outside of the domain). \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a8d2c8b028b9fc7d65f17155497a0487d}{update\+\_\+obc\+\_\+segment\+\_\+data}} (G, GV, US, O\+BC, tv, h, Time)
\begin{DoxyCompactList}\small\item\em Update the O\+BC values on the segments. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a2459650f97c35ba541246d1418efb6a1}{update\+\_\+obc\+\_\+ramp}} (Time, O\+BC, activate)
\begin{DoxyCompactList}\small\item\em Update the O\+BC ramp value as a function of time. If called with the optional argument activate=.true., record the value of Time as the beginning of the ramp period. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a8e0e22d829c122134f039228c6f1c7fb}{register\+\_\+obc}} (name, param\+\_\+file, Reg)
\begin{DoxyCompactList}\small\item\em register open boundary objects for boundary updates. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a0a6e28bbfec6ab82bfe2fd2848902945}{obc\+\_\+registry\+\_\+init}} (param\+\_\+file, Reg)
\begin{DoxyCompactList}\small\item\em This routine include declares and sets the variable \char`\"{}version\char`\"{}. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__open__boundary_a05d15beca2ef2b44fb36d129166907fa}{register\+\_\+file\+\_\+obc}} (param\+\_\+file, CS, O\+B\+C\+\_\+\+Reg)
\begin{DoxyCompactList}\small\item\em Add file to O\+BC registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a55081f00e4a95f87ddc5dfe1d61f52e0}{file\+\_\+obc\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Clean up the file O\+BC from registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_adcd9637c6cc17658fe064ce1dc1011bf}{segment\+\_\+tracer\+\_\+registry\+\_\+init}} (param\+\_\+file, segment)
\begin{DoxyCompactList}\small\item\em Initialize the segment tracer registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a5d5843dd1a4e1475f69b5eb2c5b0197d}{register\+\_\+segment\+\_\+tracer}} (tr\+\_\+ptr, param\+\_\+file, GV, segment, O\+B\+C\+\_\+scalar, O\+B\+C\+\_\+array)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a71194a8dc156fea37aab6539cc124086}{segment\+\_\+tracer\+\_\+registry\+\_\+end}} (Reg)
\begin{DoxyCompactList}\small\item\em Clean up the segment tracer registry. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a0459cfc5b4e4115bde6ada1dd7c25139}{register\+\_\+temp\+\_\+salt\+\_\+segments}} (GV, O\+BC, tr\+\_\+\+Reg, param\+\_\+file)
\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a70d8b2b93599effe185abbc5a586b35c}{fill\+\_\+temp\+\_\+salt\+\_\+segments}} (G, O\+BC, tv)
\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a7dbf161294debd059a40659ba691ca0b}{mask\+\_\+outside\+\_\+obcs}} (G, US, param\+\_\+file, O\+BC)
\begin{DoxyCompactList}\small\item\em Find the region outside of all open boundary segments and make sure it is set to land mask. Gonna need to know global land mask as well to get it right... \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_ab5a04fc90320c3af571f02f8c98f0b18}{flood\+\_\+fill}} (G, color, cin, cout, cland)
\begin{DoxyCompactList}\small\item\em flood the cin, cout values \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a13ac2cc232309a51db31c3b9ee5f22af}{flood\+\_\+fill2}} (G, color, cin, cout, cland)
\begin{DoxyCompactList}\small\item\em flood the cin, cout values \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_af1d4f35b2cff85617fc5766739db81de}{open\+\_\+boundary\+\_\+register\+\_\+restarts}} (HI, GV, O\+BC, Reg, param\+\_\+file, restart\+\_\+\+C\+Sp, use\+\_\+temperature)
\begin{DoxyCompactList}\small\item\em Register O\+BC segment data for restarts. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a230cf67375352c9d55b4330180d35d7c}{update\+\_\+segment\+\_\+tracer\+\_\+reservoirs}} (G, GV, uhr, vhr, h, O\+BC, dt, Reg)
\begin{DoxyCompactList}\small\item\em Update the O\+BC tracer reservoirs after the tracers have been updated. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a2c6f236ceed8e7e696215f1638cf4b9c}{adjustsegmentetatofitbathymetry}} (G, GV, US, segment, fld)
\begin{DoxyCompactList}\small\item\em Adjust interface heights to fit the bathymetry and diagnose layer thickness. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_a0c4401f57b9a8275c8bb3d2f7c5e013f}{rotate\+\_\+obc\+\_\+config}} (O\+B\+C\+\_\+in, G\+\_\+in, O\+BC, G, turns)
\begin{DoxyCompactList}\small\item\em This is more of a rotate initialization than an actual rotate. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_a68a208918e01e2393f12f737bdff3776}{rotate\+\_\+obc\+\_\+segment\+\_\+config}} (segment\+\_\+in, G\+\_\+in, segment, G, turns)
\begin{DoxyCompactList}\small\item\em Rotate the O\+BC segment configuration data from the input to model index map. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__open__boundary_acafa1a47d4e7f4d347963286d7614104}{rotate\+\_\+obc\+\_\+init}} (O\+B\+C\+\_\+in, G, GV, US, param\+\_\+file, tv, restart\+\_\+\+C\+Sp, O\+BC)
\begin{DoxyCompactList}\small\item\em Initialize the segments and field-\/related data of a rotated O\+BC. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_ae12e12fb8589f53ee4494f46e6e2f96e}\label{namespacemom__open__boundary_ae12e12fb8589f53ee4494f46e6e2f96e}} 
subroutine \mbox{\hyperlink{namespacemom__open__boundary_ae12e12fb8589f53ee4494f46e6e2f96e}{rotate\+\_\+obc\+\_\+segment\+\_\+data}} (segment\+\_\+in, segment, turns)
\begin{DoxyCompactList}\small\item\em Rotate an O\+BC segment\textquotesingle{}s fields from the input to the model index map. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a1dd4294ac05ea337431a26395003325f}\label{namespacemom__open__boundary_a1dd4294ac05ea337431a26395003325f}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a1dd4294ac05ea337431a26395003325f}{obc\+\_\+none}} = 0
\begin{DoxyCompactList}\small\item\em Indicates the use of no open boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_ad14f75b62184f667bb07c0f31b633c7c}\label{namespacemom__open__boundary_ad14f75b62184f667bb07c0f31b633c7c}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_ad14f75b62184f667bb07c0f31b633c7c}{obc\+\_\+simple}} = 1
\begin{DoxyCompactList}\small\item\em Indicates the use of a simple inflow open boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a59020084f9aa725ff55812572cabe6e6}\label{namespacemom__open__boundary_a59020084f9aa725ff55812572cabe6e6}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a59020084f9aa725ff55812572cabe6e6}{obc\+\_\+wall}} = 2
\begin{DoxyCompactList}\small\item\em Indicates the use of a closed wall. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_aab15bba6b94442339da4ea4dcb35811d}\label{namespacemom__open__boundary_aab15bba6b94442339da4ea4dcb35811d}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_aab15bba6b94442339da4ea4dcb35811d}{obc\+\_\+flather}} = 3
\begin{DoxyCompactList}\small\item\em Indicates the use of a Flather open boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a8f7b9f941c542c5bcddb75de5fa8e38e}\label{namespacemom__open__boundary_a8f7b9f941c542c5bcddb75de5fa8e38e}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a8f7b9f941c542c5bcddb75de5fa8e38e}{obc\+\_\+radiation}} = 4
\begin{DoxyCompactList}\small\item\em Indicates the use of a radiation open boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a6ace8760d7fa465a59d8cbc3340a5b5e}\label{namespacemom__open__boundary_a6ace8760d7fa465a59d8cbc3340a5b5e}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a6ace8760d7fa465a59d8cbc3340a5b5e}{obc\+\_\+direction\+\_\+n}} = 100
\begin{DoxyCompactList}\small\item\em Indicates the boundary is an effective northern boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a29aee121a765fc751bd1c21adf80af10}\label{namespacemom__open__boundary_a29aee121a765fc751bd1c21adf80af10}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a29aee121a765fc751bd1c21adf80af10}{obc\+\_\+direction\+\_\+s}} = 200
\begin{DoxyCompactList}\small\item\em Indicates the boundary is an effective southern boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a876256dbb0556d7e04cdf091f1744b65}\label{namespacemom__open__boundary_a876256dbb0556d7e04cdf091f1744b65}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a876256dbb0556d7e04cdf091f1744b65}{obc\+\_\+direction\+\_\+e}} = 300
\begin{DoxyCompactList}\small\item\em Indicates the boundary is an effective eastern boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a015e27a65957919ea3cd67767b8f26f7}\label{namespacemom__open__boundary_a015e27a65957919ea3cd67767b8f26f7}} 
integer, parameter, public \mbox{\hyperlink{namespacemom__open__boundary_a015e27a65957919ea3cd67767b8f26f7}{obc\+\_\+direction\+\_\+w}} = 400
\begin{DoxyCompactList}\small\item\em Indicates the boundary is an effective western boundary. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_a6997b7b50a4afe32b14fd61ba858254f}\label{namespacemom__open__boundary_a6997b7b50a4afe32b14fd61ba858254f}} 
integer, parameter \mbox{\hyperlink{namespacemom__open__boundary_a6997b7b50a4afe32b14fd61ba858254f}{max\+\_\+obc\+\_\+fields}} = 100
\begin{DoxyCompactList}\small\item\em Maximum number of data fields needed for O\+BC segments. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_ad6193d2825ef41d066e20706754a0d68}\label{namespacemom__open__boundary_ad6193d2825ef41d066e20706754a0d68}} 
integer \mbox{\hyperlink{namespacemom__open__boundary_ad6193d2825ef41d066e20706754a0d68}{id\+\_\+clock\+\_\+pass}}
\begin{DoxyCompactList}\small\item\em A C\+PU time clock. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespacemom__open__boundary_aafc1b36aca40a894743f1565f4f9d152}\label{namespacemom__open__boundary_aafc1b36aca40a894743f1565f4f9d152}} 
character(len=40) \mbox{\hyperlink{namespacemom__open__boundary_aafc1b36aca40a894743f1565f4f9d152}{mdl}} = \char`\"{}M\+O\+M\+\_\+open\+\_\+boundary\char`\"{}
\begin{DoxyCompactList}\small\item\em This module\textquotesingle{}s name. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__open__boundary_a2c6f236ceed8e7e696215f1638cf4b9c}\label{namespacemom__open__boundary_a2c6f236ceed8e7e696215f1638cf4b9c}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!adjustsegmentetatofitbathymetry@{adjustsegmentetatofitbathymetry}}
\index{adjustsegmentetatofitbathymetry@{adjustsegmentetatofitbathymetry}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{adjustsegmentetatofitbathymetry()}{adjustsegmentetatofitbathymetry()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::adjustsegmentetatofitbathymetry (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment,  }\item[{integer, intent(in)}]{fld }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adjust interface heights to fit the bathymetry and diagnose layer thickness. 

If the bottom most interface is below the topography then the bottom-\/most layers are contracted to GVAngstrom\+\_\+m. If the bottom most interface is above the topography then the entire column is dilated (expanded) to fill the void. \begin{DoxyRemark}{Remarks}
\{There is a (hard-\/wired) \char`\"{}tolerance\char`\"{} parameter such that the criteria for adjustment must equal or exceed 10cm.\} 
\end{DoxyRemark}

\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & pointer to segment type \\
\hline
\mbox{\texttt{ in}}  & {\em fld} & field index to adjust thickness \\
\hline
\end{DoxyParams}


Definition at line 5144 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{5145   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< The ocean's grid structure}}
\DoxyCodeLine{5146   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< The ocean's vertical grid structure}}
\DoxyCodeLine{5147   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{5148   \textcolor{keywordtype}{type}(OBC\_segment\_type),                     \textcolor{keywordtype}{intent(inout)} :: segment\textcolor{comment}{ !< pointer to segment type}}
\DoxyCodeLine{5149   \textcolor{keywordtype}{integer},                                    \textcolor{keywordtype}{intent(in)}    :: fld\textcolor{comment}{  !< field index to adjust thickness}}
\DoxyCodeLine{5150   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{5151   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, nz, contractions, dilations}
\DoxyCodeLine{5152   \textcolor{keywordtype}{integer} :: n}
\DoxyCodeLine{5153 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: eta \textcolor{comment}{! Segment source data interface heights, [Z -\/> m]}}
\DoxyCodeLine{5154 \textcolor{keywordtype}{  real} :: hTolerance = 0.1\textcolor{comment}{ !<  Tolerance to exceed adjustment criteria [Z \string~> m]}}
\DoxyCodeLine{5155 \textcolor{keywordtype}{  real} :: hTmp, eTmp, dilate}
\DoxyCodeLine{5156   \textcolor{keywordtype}{character(len=100)} :: mesg}
\DoxyCodeLine{5157 }
\DoxyCodeLine{5158   htolerance = 0.1*us\%m\_to\_Z}
\DoxyCodeLine{5159 }
\DoxyCodeLine{5160   nz = \textcolor{keyword}{size}(segment\%field(fld)\%dz\_src,3)}
\DoxyCodeLine{5161 }
\DoxyCodeLine{5162   \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5163      \textcolor{comment}{! segment thicknesses are defined at cell face centers.}}
\DoxyCodeLine{5164      is = segment\%HI\%isdB ; ie = segment\%HI\%iedB}
\DoxyCodeLine{5165      js = segment\%HI\%jsd ; je = segment\%HI\%jed}
\DoxyCodeLine{5166   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5167      is = segment\%HI\%isd ; ie = segment\%HI\%ied}
\DoxyCodeLine{5168      js = segment\%HI\%jsdB ; je = segment\%HI\%jedB}
\DoxyCodeLine{5169 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5170   \textcolor{keyword}{allocate}(eta(is:ie,js:je,nz+1))}
\DoxyCodeLine{5171   contractions=0; dilations=0}
\DoxyCodeLine{5172   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{5173     eta(i,j,1)=0.0   \textcolor{comment}{! segment data are assumed to be located on a static grid}}
\DoxyCodeLine{5174     \textcolor{comment}{! For remapping calls, the entire column will be dilated}}
\DoxyCodeLine{5175     \textcolor{comment}{! by a factor equal to the ratio of the sum of the geopotential referenced}}
\DoxyCodeLine{5176     \textcolor{comment}{! source data thicknesses, and the current model thicknesses. This could be}}
\DoxyCodeLine{5177     \textcolor{comment}{! an issue to be addressed, for instance if we are placing open boundaries}}
\DoxyCodeLine{5178     \textcolor{comment}{! under ice shelf cavities.}}
\DoxyCodeLine{5179     \textcolor{keywordflow}{do} k=2,nz+1}
\DoxyCodeLine{5180       eta(i,j,k)=eta(i,j,k-\/1)-\/segment\%field(fld)\%dz\_src(i,j,k-\/1)}
\DoxyCodeLine{5181 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5182     \textcolor{comment}{! The normal slope at the boundary is zero by a}}
\DoxyCodeLine{5183     \textcolor{comment}{! previous call to open\_boundary\_impose\_normal\_slope}}
\DoxyCodeLine{5184     \textcolor{keywordflow}{do} k=nz+1,1,-\/1}
\DoxyCodeLine{5185       \textcolor{keywordflow}{if} (-\/eta(i,j,k) > segment\%Htot(i,j)*gv\%H\_to\_Z + htolerance) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5186          eta(i,j,k) = -\/segment\%Htot(i,j)*gv\%H\_to\_Z}
\DoxyCodeLine{5187          contractions = contractions + 1}
\DoxyCodeLine{5188 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{5189 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5190 }
\DoxyCodeLine{5191     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{5192       \textcolor{comment}{! Collapse layers to thinnest possible if the thickness less than}}
\DoxyCodeLine{5193       \textcolor{comment}{! the thinnest possible (or negative).}}
\DoxyCodeLine{5194       \textcolor{keywordflow}{if} (eta(i,j,k) < (eta(i,j,k+1) + gv\%Angstrom\_Z)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5195          eta(i,j,k) = eta(i,j,k+1) + gv\%Angstrom\_Z}
\DoxyCodeLine{5196          segment\%field(fld)\%dz\_src(i,j,k) = gv\%Angstrom\_Z}
\DoxyCodeLine{5197       \textcolor{keywordflow}{else}}
\DoxyCodeLine{5198          segment\%field(fld)\%dz\_src(i,j,k) = (eta(i,j,k) -\/ eta(i,j,k+1))}
\DoxyCodeLine{5199 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{5200 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5201 }
\DoxyCodeLine{5202     \textcolor{comment}{!   The whole column is dilated to accommodate deeper topography than}}
\DoxyCodeLine{5203     \textcolor{comment}{! the bathymetry would indicate.}}
\DoxyCodeLine{5204     \textcolor{keywordflow}{if} (-\/eta(i,j,nz+1) < (segment\%Htot(i,j) * gv\%H\_to\_Z) -\/ htolerance) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5205        dilations = dilations + 1}
\DoxyCodeLine{5206        \textcolor{comment}{! expand bottom-\/most cell only}}
\DoxyCodeLine{5207        eta(i,j,nz+1) = -\/(segment\%Htot(i,j) * gv\%H\_to\_Z)}
\DoxyCodeLine{5208        segment\%field(fld)\%dz\_src(i,j,nz)= eta(i,j,nz)-\/eta(i,j,nz+1)}
\DoxyCodeLine{5209        \textcolor{comment}{! if (eta(i,j,1) <= eta(i,j,nz+1)) then}}
\DoxyCodeLine{5210        \textcolor{comment}{!   do k=1,nz ; segment\%field(fld)\%dz\_src(i,j,k) = (eta(i,j,1) + G\%bathyT(i,j)) / real(nz) ; enddo}}
\DoxyCodeLine{5211        \textcolor{comment}{! else}}
\DoxyCodeLine{5212        \textcolor{comment}{!   dilate = (eta(i,j,1) + G\%bathyT(i,j)) / (eta(i,j,1) -\/ eta(i,j,nz+1))}}
\DoxyCodeLine{5213        \textcolor{comment}{!   do k=1,nz ; segment\%field(fld)\%dz\_src(i,j,k) = segment\%field(fld)\%dz\_src(i,j,k) * dilate ; enddo}}
\DoxyCodeLine{5214        \textcolor{comment}{! endif}}
\DoxyCodeLine{5215        \textcolor{comment}{!do k=nz,2,-\/1 ; eta(i,j,K) = eta(i,j,K+1) + segment\%field(fld)\%dz\_src(i,j,k) ; enddo}}
\DoxyCodeLine{5216 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{5217     \textcolor{comment}{! Now convert thicknesses to units of H.}}
\DoxyCodeLine{5218     \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{5219       segment\%field(fld)\%dz\_src(i,j,k) = segment\%field(fld)\%dz\_src(i,j,k)*gv\%Z\_to\_H}
\DoxyCodeLine{5220 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5221   enddo;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{5222 }
\DoxyCodeLine{5223   \textcolor{comment}{! can not do communication call here since only PEs on the current segment are here}}
\DoxyCodeLine{5224 }
\DoxyCodeLine{5225   \textcolor{comment}{! call sum\_across\_PEs(contractions)}}
\DoxyCodeLine{5226   \textcolor{comment}{! if ((contractions > 0) .and. (is\_root\_pe())) then}}
\DoxyCodeLine{5227   \textcolor{comment}{!    write(mesg,'("{}Thickness OBCs were contracted "{},'// \&}}
\DoxyCodeLine{5228   \textcolor{comment}{!         '"{}to fit topography in "{},I8,"{} places."{})') contractions}}
\DoxyCodeLine{5229   \textcolor{comment}{!    call MOM\_error(WARNING, 'adjustEtaToFitBathymetry: '//mesg)}}
\DoxyCodeLine{5230   \textcolor{comment}{! endif}}
\DoxyCodeLine{5231   \textcolor{comment}{! call sum\_across\_PEs(dilations)}}
\DoxyCodeLine{5232   \textcolor{comment}{! if ((dilations > 0) .and. (is\_root\_pe())) then}}
\DoxyCodeLine{5233   \textcolor{comment}{!    write(mesg,'("{}Thickness OBCs were dilated "{},'// \&}}
\DoxyCodeLine{5234   \textcolor{comment}{!         '"{}to fit topography in "{},I8,"{} places."{})') dilations}}
\DoxyCodeLine{5235   \textcolor{comment}{!    call MOM\_error(WARNING, 'adjustEtaToFitBathymetry: '//mesg)}}
\DoxyCodeLine{5236   \textcolor{comment}{! endif}}
\DoxyCodeLine{5237   \textcolor{keyword}{deallocate}(eta)}
\DoxyCodeLine{5238 }
\DoxyCodeLine{5239 }
\DoxyCodeLine{5240 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_aa7f532a65dd8ae4db981f2ef4791fc56}\label{namespacemom__open__boundary_aa7f532a65dd8ae4db981f2ef4791fc56}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!allocate\_obc\_segment\_data@{allocate\_obc\_segment\_data}}
\index{allocate\_obc\_segment\_data@{allocate\_obc\_segment\_data}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{allocate\_obc\_segment\_data()}{allocate\_obc\_segment\_data()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::allocate\+\_\+obc\+\_\+segment\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Allocate segment data fields. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & Open boundary segment \\
\hline
\end{DoxyParams}


Definition at line 3501 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3502   \textcolor{keywordtype}{type}(ocean\_OBC\_type),   \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{     !< Open boundary structure}}
\DoxyCodeLine{3503   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)} :: segment\textcolor{comment}{ !< Open boundary segment}}
\DoxyCodeLine{3504   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3505   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{3506   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{3507   \textcolor{keywordtype}{integer} :: IscB, IecB, JscB, JecB}
\DoxyCodeLine{3508   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}allocate\_OBC\_segment\_data"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{3509 }
\DoxyCodeLine{3510   isd = segment\%HI\%isd ; ied = segment\%HI\%ied}
\DoxyCodeLine{3511   jsd = segment\%HI\%jsd ; jed = segment\%HI\%jed}
\DoxyCodeLine{3512   isdb = segment\%HI\%IsdB ; iedb = segment\%HI\%IedB}
\DoxyCodeLine{3513   jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{3514   iscb = segment\%HI\%IscB ; iecb = segment\%HI\%IecB}
\DoxyCodeLine{3515   jscb = segment\%HI\%JscB ; jecb = segment\%HI\%JecB}
\DoxyCodeLine{3516 }
\DoxyCodeLine{3517   \textcolor{keywordflow}{if} (.not. segment\%on\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3518 }
\DoxyCodeLine{3519   \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3520     \textcolor{comment}{! If these are just Flather, change update\_OBC\_segment\_data accordingly}}
\DoxyCodeLine{3521     \textcolor{keyword}{allocate}(segment\%Cg(isdb:iedb,jsd:jed));                  segment\%Cg(:,:)=0.}
\DoxyCodeLine{3522     \textcolor{keyword}{allocate}(segment\%Htot(isdb:iedb,jsd:jed));                segment\%Htot(:,:)=0.0}
\DoxyCodeLine{3523     \textcolor{keyword}{allocate}(segment\%h(isdb:iedb,jsd:jed,obc\%ke));            segment\%h(:,:,:)=0.0}
\DoxyCodeLine{3524     \textcolor{keyword}{allocate}(segment\%eta(isdb:iedb,jsd:jed));                 segment\%eta(:,:)=0.0}
\DoxyCodeLine{3525     \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3526       \textcolor{keyword}{allocate}(segment\%rx\_norm\_rad(isdb:iedb,jsd:jed,obc\%ke));  segment\%rx\_norm\_rad(:,:,:)=0.0}
\DoxyCodeLine{3527 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3528     \textcolor{keyword}{allocate}(segment\%normal\_vel(isdb:iedb,jsd:jed,obc\%ke));   segment\%normal\_vel(:,:,:)=0.0}
\DoxyCodeLine{3529     \textcolor{keyword}{allocate}(segment\%normal\_vel\_bt(isdb:iedb,jsd:jed));       segment\%normal\_vel\_bt(:,:)=0.0}
\DoxyCodeLine{3530     \textcolor{keyword}{allocate}(segment\%normal\_trans(isdb:iedb,jsd:jed,obc\%ke)); segment\%normal\_trans(:,:,:)=0.0}
\DoxyCodeLine{3531     \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3532       \textcolor{keyword}{allocate}(segment\%nudged\_normal\_vel(isdb:iedb,jsd:jed,obc\%ke)); segment\%nudged\_normal\_vel(:,:,:)=0.0}
\DoxyCodeLine{3533 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3534     \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%nudged\_tan .or. segment\%specified\_tan .or. \&}
\DoxyCodeLine{3535         segment\%oblique\_tan .or. obc\%computed\_vorticity .or. obc\%computed\_strain) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3536       \textcolor{keyword}{allocate}(segment\%tangential\_vel(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%tangential\_vel(:,:,:)=0.0}
\DoxyCodeLine{3537 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3538     \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3539       \textcolor{keyword}{allocate}(segment\%nudged\_tangential\_vel(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%nudged\_tangential\_vel(:,:,:)=0.0}
\DoxyCodeLine{3540 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3541     \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3542       \textcolor{keyword}{allocate}(segment\%nudged\_tangential\_grad(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%nudged\_tangential\_grad(:,:,:)=0.0}
\DoxyCodeLine{3543 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3544     \textcolor{keywordflow}{if} (obc\%specified\_vorticity .or. obc\%specified\_strain .or. segment\%radiation\_grad .or. \&}
\DoxyCodeLine{3545               segment\%oblique\_grad .or. segment\%specified\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3546       \textcolor{keyword}{allocate}(segment\%tangential\_grad(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%tangential\_grad(:,:,:)=0.0}
\DoxyCodeLine{3547 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3548     \textcolor{keywordflow}{if} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3549       \textcolor{keyword}{allocate}(segment\%grad\_normal(jsdb:jedb,2,obc\%ke));      segment\%grad\_normal(:,:,:) = 0.0}
\DoxyCodeLine{3550       \textcolor{keyword}{allocate}(segment\%rx\_norm\_obl(isdb:iedb,jsd:jed,obc\%ke));  segment\%rx\_norm\_obl(:,:,:)=0.0}
\DoxyCodeLine{3551       \textcolor{keyword}{allocate}(segment\%ry\_norm\_obl(isdb:iedb,jsd:jed,obc\%ke));  segment\%ry\_norm\_obl(:,:,:)=0.0}
\DoxyCodeLine{3552       \textcolor{keyword}{allocate}(segment\%cff\_normal(isdb:iedb,jsd:jed,obc\%ke)); segment\%cff\_normal(:,:,:)=0.0}
\DoxyCodeLine{3553 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3554     \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3555       \textcolor{keyword}{allocate}(segment\%grad\_tan(jsd-\/1:jed+1,2,obc\%ke));           segment\%grad\_tan(:,:,:) = 0.0}
\DoxyCodeLine{3556 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3557     \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3558       \textcolor{keyword}{allocate}(segment\%grad\_gradient(jsd:jed,2,obc\%ke));      segment\%grad\_gradient(:,:,:) = 0.0}
\DoxyCodeLine{3559 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3560 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{3561 }
\DoxyCodeLine{3562   \textcolor{keywordflow}{if} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3563     \textcolor{comment}{! If these are just Flather, change update\_OBC\_segment\_data accordingly}}
\DoxyCodeLine{3564     \textcolor{keyword}{allocate}(segment\%Cg(isd:ied,jsdb:jedb));                  segment\%Cg(:,:)=0.}
\DoxyCodeLine{3565     \textcolor{keyword}{allocate}(segment\%Htot(isd:ied,jsdb:jedb));                segment\%Htot(:,:)=0.0}
\DoxyCodeLine{3566     \textcolor{keyword}{allocate}(segment\%h(isd:ied,jsdb:jedb,obc\%ke));            segment\%h(:,:,:)=0.0}
\DoxyCodeLine{3567     \textcolor{keyword}{allocate}(segment\%eta(isd:ied,jsdb:jedb));                 segment\%eta(:,:)=0.0}
\DoxyCodeLine{3568     \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3569       \textcolor{keyword}{allocate}(segment\%ry\_norm\_rad(isd:ied,jsdb:jedb,obc\%ke));  segment\%ry\_norm\_rad(:,:,:)=0.0}
\DoxyCodeLine{3570 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3571     \textcolor{keyword}{allocate}(segment\%normal\_vel(isd:ied,jsdb:jedb,obc\%ke));   segment\%normal\_vel(:,:,:)=0.0}
\DoxyCodeLine{3572     \textcolor{keyword}{allocate}(segment\%normal\_vel\_bt(isd:ied,jsdb:jedb));       segment\%normal\_vel\_bt(:,:)=0.0}
\DoxyCodeLine{3573     \textcolor{keyword}{allocate}(segment\%normal\_trans(isd:ied,jsdb:jedb,obc\%ke)); segment\%normal\_trans(:,:,:)=0.0}
\DoxyCodeLine{3574     \textcolor{keywordflow}{if} (segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3575       \textcolor{keyword}{allocate}(segment\%nudged\_normal\_vel(isd:ied,jsdb:jedb,obc\%ke)); segment\%nudged\_normal\_vel(:,:,:)=0.0}
\DoxyCodeLine{3576 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3577     \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%nudged\_tan .or. segment\%specified\_tan .or. \&}
\DoxyCodeLine{3578         segment\%oblique\_tan .or. obc\%computed\_vorticity .or. obc\%computed\_strain) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3579       \textcolor{keyword}{allocate}(segment\%tangential\_vel(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%tangential\_vel(:,:,:)=0.0}
\DoxyCodeLine{3580 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3581     \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3582       \textcolor{keyword}{allocate}(segment\%nudged\_tangential\_vel(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%nudged\_tangential\_vel(:,:,:)=0.0}
\DoxyCodeLine{3583 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3584     \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3585       \textcolor{keyword}{allocate}(segment\%nudged\_tangential\_grad(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%nudged\_tangential\_grad(:,:,:)=0.0}
\DoxyCodeLine{3586 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3587     \textcolor{keywordflow}{if} (obc\%specified\_vorticity .or. obc\%specified\_strain .or. segment\%radiation\_grad .or. \&}
\DoxyCodeLine{3588               segment\%oblique\_grad .or. segment\%specified\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3589       \textcolor{keyword}{allocate}(segment\%tangential\_grad(isdb:iedb,jsdb:jedb,obc\%ke)); segment\%tangential\_grad(:,:,:)=0.0}
\DoxyCodeLine{3590 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3591     \textcolor{keywordflow}{if} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3592       \textcolor{keyword}{allocate}(segment\%grad\_normal(isdb:iedb,2,obc\%ke));      segment\%grad\_normal(:,:,:) = 0.0}
\DoxyCodeLine{3593       \textcolor{keyword}{allocate}(segment\%rx\_norm\_obl(isd:ied,jsdb:jedb,obc\%ke));  segment\%rx\_norm\_obl(:,:,:)=0.0}
\DoxyCodeLine{3594       \textcolor{keyword}{allocate}(segment\%ry\_norm\_obl(isd:ied,jsdb:jedb,obc\%ke));  segment\%ry\_norm\_obl(:,:,:)=0.0}
\DoxyCodeLine{3595       \textcolor{keyword}{allocate}(segment\%cff\_normal(isd:ied,jsdb:jedb,obc\%ke)); segment\%cff\_normal(:,:,:)=0.0}
\DoxyCodeLine{3596 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3597     \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3598       \textcolor{keyword}{allocate}(segment\%grad\_tan(isd-\/1:ied+1,2,obc\%ke));           segment\%grad\_tan(:,:,:) = 0.0}
\DoxyCodeLine{3599 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3600     \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3601       \textcolor{keyword}{allocate}(segment\%grad\_gradient(isd:ied,2,obc\%ke));      segment\%grad\_gradient(:,:,:) = 0.0}
\DoxyCodeLine{3602 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3603 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{3604 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a5d71c596c3bd7d773a39f5c63d5389ac}\label{namespacemom__open__boundary_a5d71c596c3bd7d773a39f5c63d5389ac}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!deallocate\_obc\_segment\_data@{deallocate\_obc\_segment\_data}}
\index{deallocate\_obc\_segment\_data@{deallocate\_obc\_segment\_data}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{deallocate\_obc\_segment\_data()}{deallocate\_obc\_segment\_data()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::deallocate\+\_\+obc\+\_\+segment\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Deallocate segment data fields. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & Open boundary segment \\
\hline
\end{DoxyParams}


Definition at line 3608 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3609   \textcolor{keywordtype}{type}(ocean\_OBC\_type),   \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{     !< Open boundary structure}}
\DoxyCodeLine{3610   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)} :: segment\textcolor{comment}{ !< Open boundary segment}}
\DoxyCodeLine{3611   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3612   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}deallocate\_OBC\_segment\_data"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{3613 }
\DoxyCodeLine{3614   \textcolor{keywordflow}{if} (.not. segment\%on\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3615 }
\DoxyCodeLine{3616   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%Cg)) \textcolor{keyword}{deallocate}(segment\%Cg)}
\DoxyCodeLine{3617   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%Htot)) \textcolor{keyword}{deallocate}(segment\%Htot)}
\DoxyCodeLine{3618   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%h)) \textcolor{keyword}{deallocate}(segment\%h)}
\DoxyCodeLine{3619   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%eta)) \textcolor{keyword}{deallocate}(segment\%eta)}
\DoxyCodeLine{3620   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%rx\_norm\_rad)) \textcolor{keyword}{deallocate}(segment\%rx\_norm\_rad)}
\DoxyCodeLine{3621   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%ry\_norm\_rad)) \textcolor{keyword}{deallocate}(segment\%ry\_norm\_rad)}
\DoxyCodeLine{3622   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%rx\_norm\_obl)) \textcolor{keyword}{deallocate}(segment\%rx\_norm\_obl)}
\DoxyCodeLine{3623   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%ry\_norm\_obl)) \textcolor{keyword}{deallocate}(segment\%ry\_norm\_obl)}
\DoxyCodeLine{3624   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%cff\_normal)) \textcolor{keyword}{deallocate}(segment\%cff\_normal)}
\DoxyCodeLine{3625   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%grad\_normal)) \textcolor{keyword}{deallocate}(segment\%grad\_normal)}
\DoxyCodeLine{3626   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%grad\_tan)) \textcolor{keyword}{deallocate}(segment\%grad\_tan)}
\DoxyCodeLine{3627   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%grad\_gradient)) \textcolor{keyword}{deallocate}(segment\%grad\_gradient)}
\DoxyCodeLine{3628   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%normal\_vel)) \textcolor{keyword}{deallocate}(segment\%normal\_vel)}
\DoxyCodeLine{3629   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%normal\_vel\_bt)) \textcolor{keyword}{deallocate}(segment\%normal\_vel\_bt)}
\DoxyCodeLine{3630   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%normal\_trans)) \textcolor{keyword}{deallocate}(segment\%normal\_trans)}
\DoxyCodeLine{3631   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%nudged\_normal\_vel)) \textcolor{keyword}{deallocate}(segment\%nudged\_normal\_vel)}
\DoxyCodeLine{3632   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%tangential\_vel)) \textcolor{keyword}{deallocate}(segment\%tangential\_vel)}
\DoxyCodeLine{3633   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%nudged\_tangential\_vel)) \textcolor{keyword}{deallocate}(segment\%nudged\_tangential\_vel)}
\DoxyCodeLine{3634   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%nudged\_tangential\_grad)) \textcolor{keyword}{deallocate}(segment\%nudged\_tangential\_grad)}
\DoxyCodeLine{3635   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%tangential\_grad)) \textcolor{keyword}{deallocate}(segment\%tangential\_grad)}
\DoxyCodeLine{3636   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated} (segment\%tr\_Reg)) \textcolor{keyword}{call }segment\_tracer\_registry\_end(segment\%tr\_Reg)}
\DoxyCodeLine{3637 }
\DoxyCodeLine{3638 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a55081f00e4a95f87ddc5dfe1d61f52e0}\label{namespacemom__open__boundary_a55081f00e4a95f87ddc5dfe1d61f52e0}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!file\_obc\_end@{file\_obc\_end}}
\index{file\_obc\_end@{file\_obc\_end}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{file\_obc\_end()}{file\_obc\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::file\+\_\+obc\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1file__obc__cs}{file\+\_\+obc\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Clean up the file O\+BC from registry. 


\begin{DoxyParams}{Parameters}
{\em cs} & O\+BC file control structure. \\
\hline
\end{DoxyParams}


Definition at line 4486 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4487   \textcolor{keywordtype}{type}(file\_OBC\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< OBC file control structure.}}
\DoxyCodeLine{4488 }
\DoxyCodeLine{4489   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4490     \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{4491 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a70d8b2b93599effe185abbc5a586b35c}\label{namespacemom__open__boundary_a70d8b2b93599effe185abbc5a586b35c}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!fill\_temp\_salt\_segments@{fill\_temp\_salt\_segments}}
\index{fill\_temp\_salt\_segments@{fill\_temp\_salt\_segments}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{fill\_temp\_salt\_segments()}{fill\_temp\_salt\_segments()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::fill\+\_\+temp\+\_\+salt\+\_\+segments (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(inout)}]{tv }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure\\
\hline
 & {\em obc} & Open boundary structure\\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamics structure \\
\hline
\end{DoxyParams}


Definition at line 4636 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4637   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{          !< Ocean grid structure}}
\DoxyCodeLine{4638   \textcolor{keywordtype}{type}(ocean\_OBC\_type),       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{        !< Open boundary structure}}
\DoxyCodeLine{4639   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{         !< Thermodynamics structure}}
\DoxyCodeLine{4640 }
\DoxyCodeLine{4641 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4642   \textcolor{keywordtype}{integer} :: isd, ied, IsdB, IedB, jsd, jed, JsdB, JedB, n, nz}
\DoxyCodeLine{4643   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{4644   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{4645 }
\DoxyCodeLine{4646   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{4647   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(tv\%T) .and. \textcolor{keyword}{associated}(tv\%S)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{4648   \textcolor{comment}{! Both temperature and salinity fields}}
\DoxyCodeLine{4649 }
\DoxyCodeLine{4650   \textcolor{keyword}{call }pass\_var(tv\%T, g\%Domain)}
\DoxyCodeLine{4651   \textcolor{keyword}{call }pass\_var(tv\%S, g\%Domain)}
\DoxyCodeLine{4652 }
\DoxyCodeLine{4653   nz = g\%ke}
\DoxyCodeLine{4654 }
\DoxyCodeLine{4655   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{4656     segment => obc\%segment(n)}
\DoxyCodeLine{4657     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{4658 }
\DoxyCodeLine{4659     isd = segment\%HI\%isd ; ied = segment\%HI\%ied}
\DoxyCodeLine{4660     jsd = segment\%HI\%jsd ; jed = segment\%HI\%jed}
\DoxyCodeLine{4661     isdb = segment\%HI\%IsdB ; iedb = segment\%HI\%IedB}
\DoxyCodeLine{4662     jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{4663 }
\DoxyCodeLine{4664     \textcolor{comment}{! Fill with T and S values}}
\DoxyCodeLine{4665     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4666       i=segment\%HI\%IsdB}
\DoxyCodeLine{4667       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{4668         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4669           segment\%tr\_Reg\%Tr(1)\%t(i,j,k) = tv\%T(i+1,j,k)}
\DoxyCodeLine{4670           segment\%tr\_Reg\%Tr(2)\%t(i,j,k) = tv\%S(i+1,j,k)}
\DoxyCodeLine{4671         \textcolor{keywordflow}{else}}
\DoxyCodeLine{4672           segment\%tr\_Reg\%Tr(1)\%t(i,j,k) = tv\%T(i,j,k)}
\DoxyCodeLine{4673           segment\%tr\_Reg\%Tr(2)\%t(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{4674 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4675 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4676     \textcolor{keywordflow}{else}}
\DoxyCodeLine{4677       j=segment\%HI\%JsdB}
\DoxyCodeLine{4678       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{4679         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4680           segment\%tr\_Reg\%Tr(1)\%t(i,j,k) = tv\%T(i,j+1,k)}
\DoxyCodeLine{4681           segment\%tr\_Reg\%Tr(2)\%t(i,j,k) = tv\%S(i,j+1,k)}
\DoxyCodeLine{4682         \textcolor{keywordflow}{else}}
\DoxyCodeLine{4683           segment\%tr\_Reg\%Tr(1)\%t(i,j,k) = tv\%T(i,j,k)}
\DoxyCodeLine{4684           segment\%tr\_Reg\%Tr(2)\%t(i,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{4685 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4686 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4687 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4688     segment\%tr\_Reg\%Tr(1)\%tres(:,:,:) = segment\%tr\_Reg\%Tr(1)\%t(:,:,:)}
\DoxyCodeLine{4689     segment\%tr\_Reg\%Tr(2)\%tres(:,:,:) = segment\%tr\_Reg\%Tr(2)\%t(:,:,:)}
\DoxyCodeLine{4690 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4691 }
\DoxyCodeLine{4692   \textcolor{keyword}{call }setup\_obc\_tracer\_reservoirs(g, obc)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_ab5a04fc90320c3af571f02f8c98f0b18}\label{namespacemom__open__boundary_ab5a04fc90320c3af571f02f8c98f0b18}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!flood\_fill@{flood\_fill}}
\index{flood\_fill@{flood\_fill}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{flood\_fill()}{flood\_fill()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::flood\+\_\+fill (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{color,  }\item[{integer, intent(in)}]{cin,  }\item[{integer, intent(in)}]{cout,  }\item[{integer, intent(in)}]{cland }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



flood the cin, cout values 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em color} & For sorting inside from outside \\
\hline
\mbox{\texttt{ in}}  & {\em cin} & color for inside the domain \\
\hline
\mbox{\texttt{ in}}  & {\em cout} & color for outside the domain \\
\hline
\mbox{\texttt{ in}}  & {\em cland} & color for inside the land mask \\
\hline
\end{DoxyParams}


Definition at line 4820 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4821   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Ocean grid structure}}
\DoxyCodeLine{4822 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{intent(inout)} :: color\textcolor{comment}{  !< For sorting inside from outside}}
\DoxyCodeLine{4823   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cin\textcolor{comment}{    !< color for inside the domain}}
\DoxyCodeLine{4824   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cout\textcolor{comment}{   !< color for outside the domain}}
\DoxyCodeLine{4825   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cland\textcolor{comment}{  !< color for inside the land mask}}
\DoxyCodeLine{4826 }
\DoxyCodeLine{4827 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4828   \textcolor{keywordtype}{integer} :: i, j, ncount}
\DoxyCodeLine{4829 }
\DoxyCodeLine{4830   ncount = 1}
\DoxyCodeLine{4831   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (ncount > 0)}
\DoxyCodeLine{4832     ncount = 0}
\DoxyCodeLine{4833     \textcolor{keywordflow}{do} j=g\%jsd+1,g\%jed-\/1}
\DoxyCodeLine{4834       \textcolor{keywordflow}{do} i=g\%isd+1,g\%ied-\/1}
\DoxyCodeLine{4835         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i-\/1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4836           color(i,j) = color(i-\/1,j)}
\DoxyCodeLine{4837           ncount = ncount + 1}
\DoxyCodeLine{4838 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4839         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i+1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4840           color(i,j) = color(i+1,j)}
\DoxyCodeLine{4841           ncount = ncount + 1}
\DoxyCodeLine{4842 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4843         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j-\/1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4844           color(i,j) = color(i,j-\/1)}
\DoxyCodeLine{4845           ncount = ncount + 1}
\DoxyCodeLine{4846 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4847         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4848           color(i,j) = color(i,j+1)}
\DoxyCodeLine{4849           ncount = ncount + 1}
\DoxyCodeLine{4850 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4851 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{4852 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4853     \textcolor{keywordflow}{do} j=g\%jed-\/1,g\%jsd+1,-\/1}
\DoxyCodeLine{4854       \textcolor{keywordflow}{do} i=g\%ied-\/1,g\%isd+1,-\/1}
\DoxyCodeLine{4855         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i-\/1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4856           color(i,j) = color(i-\/1,j)}
\DoxyCodeLine{4857           ncount = ncount + 1}
\DoxyCodeLine{4858 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4859         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i+1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4860           color(i,j) = color(i+1,j)}
\DoxyCodeLine{4861           ncount = ncount + 1}
\DoxyCodeLine{4862 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4863         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j-\/1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4864           color(i,j) = color(i,j-\/1)}
\DoxyCodeLine{4865           ncount = ncount + 1}
\DoxyCodeLine{4866 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4867         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4868           color(i,j) = color(i,j+1)}
\DoxyCodeLine{4869           ncount = ncount + 1}
\DoxyCodeLine{4870 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4871 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{4872 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4873     \textcolor{keyword}{call }pass\_var(color, g\%Domain)}
\DoxyCodeLine{4874     \textcolor{keyword}{call }sum\_across\_pes(ncount)}
\DoxyCodeLine{4875 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4876 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a13ac2cc232309a51db31c3b9ee5f22af}\label{namespacemom__open__boundary_a13ac2cc232309a51db31c3b9ee5f22af}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!flood\_fill2@{flood\_fill2}}
\index{flood\_fill2@{flood\_fill2}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{flood\_fill2()}{flood\_fill2()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::flood\+\_\+fill2 (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{color,  }\item[{integer, intent(in)}]{cin,  }\item[{integer, intent(in)}]{cout,  }\item[{integer, intent(in)}]{cland }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



flood the cin, cout values 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em color} & For sorting inside from outside \\
\hline
\mbox{\texttt{ in}}  & {\em cin} & color for inside the domain \\
\hline
\mbox{\texttt{ in}}  & {\em cout} & color for outside the domain \\
\hline
\mbox{\texttt{ in}}  & {\em cland} & color for inside the land mask \\
\hline
\end{DoxyParams}


Definition at line 4880 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4881   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{       !< Ocean grid structure}}
\DoxyCodeLine{4882 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{intent(inout)} :: color\textcolor{comment}{   !< For sorting inside from outside}}
\DoxyCodeLine{4883   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cin\textcolor{comment}{    !< color for inside the domain}}
\DoxyCodeLine{4884   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cout\textcolor{comment}{   !< color for outside the domain}}
\DoxyCodeLine{4885   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: cland\textcolor{comment}{  !< color for inside the land mask}}
\DoxyCodeLine{4886 }
\DoxyCodeLine{4887 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4888   \textcolor{keywordtype}{integer} :: i, j, ncount}
\DoxyCodeLine{4889 }
\DoxyCodeLine{4890   ncount = 1}
\DoxyCodeLine{4891   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (ncount > 0)}
\DoxyCodeLine{4892     ncount = 0}
\DoxyCodeLine{4893     \textcolor{keywordflow}{do} i=g\%isd+1,g\%ied-\/1}
\DoxyCodeLine{4894       \textcolor{keywordflow}{do} j=g\%jsd+1,g\%jed-\/1}
\DoxyCodeLine{4895         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i-\/1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4896           color(i,j) = color(i-\/1,j)}
\DoxyCodeLine{4897           ncount = ncount + 1}
\DoxyCodeLine{4898 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4899         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i+1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4900           color(i,j) = color(i+1,j)}
\DoxyCodeLine{4901           ncount = ncount + 1}
\DoxyCodeLine{4902 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4903         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j-\/1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4904           color(i,j) = color(i,j-\/1)}
\DoxyCodeLine{4905           ncount = ncount + 1}
\DoxyCodeLine{4906 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4907         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4908           color(i,j) = color(i,j+1)}
\DoxyCodeLine{4909           ncount = ncount + 1}
\DoxyCodeLine{4910 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4911 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{4912 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4913     \textcolor{keywordflow}{do} i=g\%ied-\/1,g\%isd+1,-\/1}
\DoxyCodeLine{4914       \textcolor{keywordflow}{do} j=g\%jed-\/1,g\%jsd+1,-\/1}
\DoxyCodeLine{4915         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i-\/1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4916           color(i,j) = color(i-\/1,j)}
\DoxyCodeLine{4917           ncount = ncount + 1}
\DoxyCodeLine{4918 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4919         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i+1,j) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4920           color(i,j) = color(i+1,j)}
\DoxyCodeLine{4921           ncount = ncount + 1}
\DoxyCodeLine{4922 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4923         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j-\/1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4924           color(i,j) = color(i,j-\/1)}
\DoxyCodeLine{4925           ncount = ncount + 1}
\DoxyCodeLine{4926 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4927         \textcolor{keywordflow}{if} (color(i,j) == 0.0 .and. color(i,j+1) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4928           color(i,j) = color(i,j+1)}
\DoxyCodeLine{4929           ncount = ncount + 1}
\DoxyCodeLine{4930 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4931 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{4932 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4933     \textcolor{keyword}{call }pass\_var(color, g\%Domain)}
\DoxyCodeLine{4934     \textcolor{keyword}{call }sum\_across\_pes(ncount)}
\DoxyCodeLine{4935 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4936 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a151df14c3b8b1094ddf8f44c86493fd5}\label{namespacemom__open__boundary_a151df14c3b8b1094ddf8f44c86493fd5}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!gradient\_at\_q\_points@{gradient\_at\_q\_points}}
\index{gradient\_at\_q\_points@{gradient\_at\_q\_points}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{gradient\_at\_q\_points()}{gradient\_at\_q\_points()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::gradient\+\_\+at\+\_\+q\+\_\+points (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), pointer}]{segment,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{uvel,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(in)}]{vvel }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Calculate the tangential gradient of the normal flow at the boundary q-\/points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
 & {\em segment} & O\+BC segment structure \\
\hline
\mbox{\texttt{ in}}  & {\em uvel} & zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em vvel} & meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 3296 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3297   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{3298   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment\textcolor{comment}{ !< OBC segment structure}}
\DoxyCodeLine{3299 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: uvel\textcolor{comment}{ !< zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3300 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: vvel\textcolor{comment}{ !< meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3301   \textcolor{keywordtype}{integer} :: i,j,k}
\DoxyCodeLine{3302 }
\DoxyCodeLine{3303   \textcolor{keywordflow}{if} (.not. segment\%on\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3304 }
\DoxyCodeLine{3305   \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3306     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3307       i=segment\%HI\%isdB}
\DoxyCodeLine{3308       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3309         \textcolor{keywordflow}{do} j=max(segment\%HI\%JsdB, g\%HI\%JsdB+1),min(segment\%HI\%JedB, g\%HI\%JedB-\/1)}
\DoxyCodeLine{3310           segment\%grad\_normal(j,1,k) = (uvel(i-\/1,j+1,k)-\/uvel(i-\/1,j,k)) * g\%mask2dBu(i-\/1,j)}
\DoxyCodeLine{3311           segment\%grad\_normal(j,2,k) = (uvel(i,j+1,k)-\/uvel(i,j,k)) * g\%mask2dBu(i,j)}
\DoxyCodeLine{3312 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3313 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3314       \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3315         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3316           \textcolor{keywordflow}{do} j=max(segment\%HI\%jsd-\/1, g\%HI\%jsd),min(segment\%HI\%jed+1, g\%HI\%jed)}
\DoxyCodeLine{3317             segment\%grad\_tan(j,1,k) = (vvel(i-\/1,j,k)-\/vvel(i-\/1,j-\/1,k)) * g\%mask2dT(i-\/1,j)}
\DoxyCodeLine{3318             segment\%grad\_tan(j,2,k) = (vvel(i,j,k)-\/vvel(i,j-\/1,k)) * g\%mask2dT(i,j)}
\DoxyCodeLine{3319 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3320 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3321 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3322       \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3323         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3324           \textcolor{keywordflow}{do} j=max(segment\%HI\%jsd, g\%HI\%jsd+1),min(segment\%HI\%jed, g\%HI\%jed-\/1)}
\DoxyCodeLine{3325             segment\%grad\_gradient(j,1,k) = (((vvel(i-\/1,j,k) -\/ vvel(i-\/2,j,k))*g\%IdxBu(i-\/2,j)) -\/ \&}
\DoxyCodeLine{3326                  (vvel(i-\/1,j-\/1,k) -\/ vvel(i-\/2,j-\/1,k))*g\%IdxBu(i-\/2,j-\/1)) * g\%mask2dCu(i-\/2,j)}
\DoxyCodeLine{3327             segment\%grad\_gradient(j,2,k) = (((vvel(i,j,k) -\/ vvel(i-\/1,j,k))*g\%IdxBu(i-\/1,j)) -\/ \&}
\DoxyCodeLine{3328                  (vvel(i,j-\/1,k) -\/ vvel(i-\/1,j-\/1,k))*g\%IdxBu(i-\/1,j-\/1)) * g\%mask2dCu(i-\/1,j)}
\DoxyCodeLine{3329 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3330 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3331 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3332     \textcolor{keywordflow}{else} \textcolor{comment}{! western segment}}
\DoxyCodeLine{3333       i=segment\%HI\%isdB}
\DoxyCodeLine{3334       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3335         \textcolor{keywordflow}{do} j=max(segment\%HI\%JsdB, g\%HI\%JsdB+1),min(segment\%HI\%JedB, g\%HI\%JedB-\/1)}
\DoxyCodeLine{3336           segment\%grad\_normal(j,1,k) = (uvel(i+1,j+1,k)-\/uvel(i+1,j,k)) * g\%mask2dBu(i+1,j)}
\DoxyCodeLine{3337           segment\%grad\_normal(j,2,k) = (uvel(i,j+1,k)-\/uvel(i,j,k)) * g\%mask2dBu(i,j)}
\DoxyCodeLine{3338 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3339 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3340       \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3341         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3342           \textcolor{keywordflow}{do} j=max(segment\%HI\%jsd-\/1, g\%HI\%jsd),min(segment\%HI\%jed+1, g\%HI\%jed)}
\DoxyCodeLine{3343             segment\%grad\_tan(j,1,k) = (vvel(i+2,j,k)-\/vvel(i+2,j-\/1,k)) * g\%mask2dT(i+2,j)}
\DoxyCodeLine{3344             segment\%grad\_tan(j,2,k) = (vvel(i+1,j,k)-\/vvel(i+1,j-\/1,k)) * g\%mask2dT(i+1,j)}
\DoxyCodeLine{3345 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3346 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3347 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3348       \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3349         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3350           \textcolor{keywordflow}{do} j=max(segment\%HI\%jsd, g\%HI\%jsd+1),min(segment\%HI\%jed, g\%HI\%jed-\/1)}
\DoxyCodeLine{3351             segment\%grad\_gradient(j,1,k) = (((vvel(i+3,j,k) -\/ vvel(i+2,j,k))*g\%IdxBu(i+2,j)) -\/ \&}
\DoxyCodeLine{3352                  (vvel(i+3,j-\/1,k) -\/ vvel(i+2,j-\/1,k))*g\%IdxBu(i+2,j-\/1)) * g\%mask2dCu(i+2,j)}
\DoxyCodeLine{3353             segment\%grad\_gradient(j,2,k) = (((vvel(i+2,j,k) -\/ vvel(i+1,j,k))*g\%IdxBu(i+1,j)) -\/ \&}
\DoxyCodeLine{3354                  (vvel(i+2,j-\/1,k) -\/ vvel(i+1,j-\/1,k))*g\%IdxBu(i+1,j-\/1)) * g\%mask2dCu(i+1,j)}
\DoxyCodeLine{3355 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3356 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3357 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3358 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3359   \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3360     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3361       j=segment\%HI\%jsdB}
\DoxyCodeLine{3362       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3363         \textcolor{keywordflow}{do} i=max(segment\%HI\%IsdB, g\%HI\%IsdB+1),min(segment\%HI\%IedB, g\%HI\%IedB-\/1)}
\DoxyCodeLine{3364           segment\%grad\_normal(i,1,k) = (vvel(i+1,j-\/1,k)-\/vvel(i,j-\/1,k)) * g\%mask2dBu(i,j-\/1)}
\DoxyCodeLine{3365           segment\%grad\_normal(i,2,k) = (vvel(i+1,j,k)-\/vvel(i,j,k)) * g\%mask2dBu(i,j)}
\DoxyCodeLine{3366 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3367 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3368       \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3369         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3370           \textcolor{keywordflow}{do} i=max(segment\%HI\%isd-\/1, g\%HI\%isd),min(segment\%HI\%ied+1, g\%HI\%ied)}
\DoxyCodeLine{3371             segment\%grad\_tan(i,1,k) = (uvel(i,j-\/1,k)-\/uvel(i-\/1,j-\/1,k)) * g\%mask2dT(i,j-\/1)}
\DoxyCodeLine{3372             segment\%grad\_tan(i,2,k) = (uvel(i,j,k)-\/uvel(i-\/1,j,k)) * g\%mask2dT(i,j)}
\DoxyCodeLine{3373 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3374 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3375 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3376       \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3377         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3378           \textcolor{keywordflow}{do} i=max(segment\%HI\%isd, g\%HI\%isd+1),min(segment\%HI\%ied, g\%HI\%ied-\/1)}
\DoxyCodeLine{3379             segment\%grad\_gradient(i,1,k) = (((uvel(i,j-\/1,k) -\/ uvel(i,j-\/2,k))*g\%IdyBu(i,j-\/2)) -\/ \&}
\DoxyCodeLine{3380                  (uvel(i-\/1,j-\/1,k) -\/ uvel(i-\/1,j-\/2,k))*g\%IdyBu(i-\/1,j-\/2)) * g\%mask2dCv(i,j-\/2)}
\DoxyCodeLine{3381             segment\%grad\_gradient(i,2,k) = (((uvel(i,j,k) -\/ uvel(i,j-\/1,k))*g\%IdyBu(i,j-\/1)) -\/ \&}
\DoxyCodeLine{3382                  (uvel(i-\/1,j,k) -\/ uvel(i-\/1,j-\/1,k))*g\%IdyBu(i-\/1,j-\/1)) * g\%mask2dCv(i,j-\/1)}
\DoxyCodeLine{3383 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3384 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3385 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3386     \textcolor{keywordflow}{else} \textcolor{comment}{! south segment}}
\DoxyCodeLine{3387       j=segment\%HI\%jsdB}
\DoxyCodeLine{3388       \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3389         \textcolor{keywordflow}{do} i=max(segment\%HI\%IsdB, g\%HI\%IsdB+1),min(segment\%HI\%IedB, g\%HI\%IedB-\/1)}
\DoxyCodeLine{3390           segment\%grad\_normal(i,1,k) = (vvel(i+1,j+1,k)-\/vvel(i,j+1,k)) * g\%mask2dBu(i,j+1)}
\DoxyCodeLine{3391           segment\%grad\_normal(i,2,k) = (vvel(i+1,j,k)-\/vvel(i,j,k)) * g\%mask2dBu(i,j)}
\DoxyCodeLine{3392 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3393 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3394       \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3395         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3396           \textcolor{keywordflow}{do} i=max(segment\%HI\%isd-\/1, g\%HI\%isd),min(segment\%HI\%ied+1, g\%HI\%ied)}
\DoxyCodeLine{3397             segment\%grad\_tan(i,1,k) = (uvel(i,j+2,k)-\/uvel(i-\/1,j+2,k)) * g\%mask2dT(i,j+2)}
\DoxyCodeLine{3398             segment\%grad\_tan(i,2,k) = (uvel(i,j+1,k)-\/uvel(i-\/1,j+1,k)) * g\%mask2dT(i,j+1)}
\DoxyCodeLine{3399 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3400 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3401 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3402       \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3403         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3404           \textcolor{keywordflow}{do} i=max(segment\%HI\%isd, g\%HI\%isd+1),min(segment\%HI\%ied, g\%HI\%ied-\/1)}
\DoxyCodeLine{3405             segment\%grad\_gradient(i,1,k) = (((uvel(i,j+3,k) -\/ uvel(i,j+2,k))*g\%IdyBu(i,j+2)) -\/ \&}
\DoxyCodeLine{3406                  (uvel(i-\/1,j+3,k) -\/ uvel(i-\/1,j+2,k))*g\%IdyBu(i-\/1,j+2)) * g\%mask2dCv(i,j+2)}
\DoxyCodeLine{3407             segment\%grad\_gradient(i,2,k) = (((uvel(i,j+2,k) -\/ uvel(i,j+1,k))*g\%IdyBu(i,j+1)) -\/ \&}
\DoxyCodeLine{3408                  (uvel(i-\/1,j+2,k) -\/ uvel(i-\/1,j+1,k))*g\%IdyBu(i-\/1,j+1)) * g\%mask2dCv(i,j+1)}
\DoxyCodeLine{3409 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3410 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3411 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3412 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3413 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{3414 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a47ad907f8613e7400ac3c6919c22bb11}\label{namespacemom__open__boundary_a47ad907f8613e7400ac3c6919c22bb11}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!initialize\_obc\_tides@{initialize\_obc\_tides}}
\index{initialize\_obc\_tides@{initialize\_obc\_tides}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{initialize\_obc\_tides()}{initialize\_obc\_tides()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::initialize\+\_\+obc\+\_\+tides (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure\\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
\end{DoxyParams}


Definition at line 962 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{963   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{964   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{965   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(3)} :: tide\_ref\_date\textcolor{comment}{      !< Reference date (t = 0) for tidal forcing (year, month, day).}}
\DoxyCodeLine{966   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(3)} :: nodal\_ref\_date\textcolor{comment}{     !< Date to calculate nodal modulation for (year, month, day).}}
\DoxyCodeLine{967   \textcolor{keywordtype}{character(len=50)} :: tide\_constituent\_str\textcolor{comment}{   !< List of tidal constituents to include on boundary.}}
\DoxyCodeLine{968   \textcolor{keywordtype}{type}(astro\_longitudes) :: nodal\_longitudes\textcolor{comment}{              !< Solar and lunar longitudes for tidal forcing}}
\DoxyCodeLine{969   \textcolor{keywordtype}{type}(time\_type) :: nodal\_time\textcolor{comment}{                           !< Model time to calculate nodal modulation for.}}
\DoxyCodeLine{970   \textcolor{keywordtype}{integer} :: c\textcolor{comment}{                                            !< Index to tidal constituent.}}
\DoxyCodeLine{971 }
\DoxyCodeLine{972   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_CONSTITUENTS"{}}, tide\_constituent\_str, \&}
\DoxyCodeLine{973       \textcolor{stringliteral}{"{}Names of tidal constituents being added to the open boundaries."{}}, \&}
\DoxyCodeLine{974       fail\_if\_missing=.true.)}
\DoxyCodeLine{975 }
\DoxyCodeLine{976   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_ADD\_EQ\_PHASE"{}}, obc\%add\_eq\_phase, \&}
\DoxyCodeLine{977       \textcolor{stringliteral}{"{}If true, add the equilibrium phase argument to the specified tidal phases."{}}, \&}
\DoxyCodeLine{978       default=.false., fail\_if\_missing=.false.)}
\DoxyCodeLine{979 }
\DoxyCodeLine{980   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_ADD\_NODAL"{}}, obc\%add\_nodal\_terms, \&}
\DoxyCodeLine{981       \textcolor{stringliteral}{"{}If true, include 18.6 year nodal modulation in the boundary tidal forcing."{}}, \&}
\DoxyCodeLine{982       default=.false.)}
\DoxyCodeLine{983 }
\DoxyCodeLine{984   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_REF\_DATE"{}}, tide\_ref\_date, \&}
\DoxyCodeLine{985       \textcolor{stringliteral}{"{}Reference date to use for tidal calculations and equilibrium phase."{}}, \&}
\DoxyCodeLine{986       fail\_if\_missing=.true.)}
\DoxyCodeLine{987 }
\DoxyCodeLine{988   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_NODAL\_REF\_DATE"{}}, nodal\_ref\_date, \&}
\DoxyCodeLine{989       \textcolor{stringliteral}{"{}Fixed reference date to use for nodal modulation of boundary tides."{}}, \&}
\DoxyCodeLine{990       fail\_if\_missing=.false., default=0)}
\DoxyCodeLine{991 }
\DoxyCodeLine{992   \textcolor{keywordflow}{if} (.not. obc\%add\_eq\_phase) \textcolor{keywordflow}{then}}
\DoxyCodeLine{993     \textcolor{comment}{! If equilibrium phase argument is not added, the input phases}}
\DoxyCodeLine{994     \textcolor{comment}{! should already be relative to the reference time.}}
\DoxyCodeLine{995     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'OBC tidal phases will *not* be corrected with equilibrium arguments.'})}
\DoxyCodeLine{996 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{997 }
\DoxyCodeLine{998   \textcolor{keyword}{allocate}(obc\%tide\_names(obc\%n\_tide\_constituents))}
\DoxyCodeLine{999   \textcolor{keyword}{read}(tide\_constituent\_str, *) obc\%tide\_names}
\DoxyCodeLine{1000 }
\DoxyCodeLine{1001   \textcolor{comment}{! Set reference time (t = 0) for boundary tidal forcing.}}
\DoxyCodeLine{1002   obc\%time\_ref = set\_date(tide\_ref\_date(1), tide\_ref\_date(2), tide\_ref\_date(3))}
\DoxyCodeLine{1003 }
\DoxyCodeLine{1004   \textcolor{comment}{! Find relevant lunar and solar longitudes at the reference time}}
\DoxyCodeLine{1005   \textcolor{keywordflow}{if} (obc\%add\_eq\_phase) \textcolor{keyword}{call }astro\_longitudes\_init(obc\%time\_ref, obc\%tidal\_longitudes)}
\DoxyCodeLine{1006 }
\DoxyCodeLine{1007   \textcolor{comment}{! If the nodal correction is based on a different time, initialize that.}}
\DoxyCodeLine{1008   \textcolor{comment}{! Otherwise, it can use N from the time reference.}}
\DoxyCodeLine{1009   \textcolor{keywordflow}{if} (obc\%add\_nodal\_terms) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1010     \textcolor{keywordflow}{if} (sum(nodal\_ref\_date) .ne. 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1011       \textcolor{comment}{! A reference date was provided for the nodal correction}}
\DoxyCodeLine{1012       nodal\_time = set\_date(nodal\_ref\_date(1), nodal\_ref\_date(2), nodal\_ref\_date(3))}
\DoxyCodeLine{1013       \textcolor{keyword}{call }astro\_longitudes\_init(nodal\_time, nodal\_longitudes)}
\DoxyCodeLine{1014     \textcolor{keywordflow}{elseif} (obc\%add\_eq\_phase) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1015       \textcolor{comment}{! Astronomical longitudes were already calculated for use in equilibrium phases,}}
\DoxyCodeLine{1016       \textcolor{comment}{! so use nodal longitude from that.}}
\DoxyCodeLine{1017       nodal\_longitudes = obc\%tidal\_longitudes}
\DoxyCodeLine{1018     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1019       \textcolor{comment}{! Tidal reference time is a required parameter, so calculate the longitudes from that.}}
\DoxyCodeLine{1020       \textcolor{keyword}{call }astro\_longitudes\_init(obc\%time\_ref, nodal\_longitudes)}
\DoxyCodeLine{1021 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1022 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1023 }
\DoxyCodeLine{1024   \textcolor{keyword}{allocate}(obc\%tide\_frequencies(obc\%n\_tide\_constituents))}
\DoxyCodeLine{1025   \textcolor{keyword}{allocate}(obc\%tide\_eq\_phases(obc\%n\_tide\_constituents))}
\DoxyCodeLine{1026   \textcolor{keyword}{allocate}(obc\%tide\_fn(obc\%n\_tide\_constituents))}
\DoxyCodeLine{1027   \textcolor{keyword}{allocate}(obc\%tide\_un(obc\%n\_tide\_constituents))}
\DoxyCodeLine{1028 }
\DoxyCodeLine{1029   \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{1030     \textcolor{comment}{! If tidal frequency is overridden by setting TIDE\_*\_FREQ, use that, otherwise use the}}
\DoxyCodeLine{1031     \textcolor{comment}{! default realistic frequency for this constituent.}}
\DoxyCodeLine{1032     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}TIDE\_"{}}//trim(obc\%tide\_names(c))//\textcolor{stringliteral}{"{}\_FREQ"{}}, obc\%tide\_frequencies(c), \&}
\DoxyCodeLine{1033         \textcolor{stringliteral}{"{}Frequency of the "{}}//trim(obc\%tide\_names(c))//\textcolor{stringliteral}{"{} tidal constituent. "{}}//\&}
\DoxyCodeLine{1034         \textcolor{stringliteral}{"{}This is only used if TIDES and TIDE\_"{}}//trim(obc\%tide\_names(c))// \&}
\DoxyCodeLine{1035         \textcolor{stringliteral}{"{} are true, or if OBC\_TIDE\_N\_CONSTITUENTS > 0 and "{}}//trim(obc\%tide\_names(c))//\&}
\DoxyCodeLine{1036         \textcolor{stringliteral}{"{} is in OBC\_TIDE\_CONSTITUENTS."{}}, units=\textcolor{stringliteral}{"{}s-\/1"{}}, default=tidal\_frequency(trim(obc\%tide\_names(c))))}
\DoxyCodeLine{1037 }
\DoxyCodeLine{1038     \textcolor{comment}{! Find equilibrum phase if needed}}
\DoxyCodeLine{1039     \textcolor{keywordflow}{if} (obc\%add\_eq\_phase) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1040       obc\%tide\_eq\_phases(c) = eq\_phase(trim(obc\%tide\_names(c)), obc\%tidal\_longitudes)}
\DoxyCodeLine{1041     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1042       obc\%tide\_eq\_phases(c) = 0.0}
\DoxyCodeLine{1043 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1044 }
\DoxyCodeLine{1045     \textcolor{comment}{! Find nodal corrections if needed}}
\DoxyCodeLine{1046     \textcolor{keywordflow}{if} (obc\%add\_nodal\_terms) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1047       \textcolor{keyword}{call }nodal\_fu(trim(obc\%tide\_names(c)), nodal\_longitudes\%N, obc\%tide\_fn(c), obc\%tide\_un(c))}
\DoxyCodeLine{1048     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1049       obc\%tide\_fn(c) = 1.0}
\DoxyCodeLine{1050       obc\%tide\_un(c) = 0.0}
\DoxyCodeLine{1051 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1052 \textcolor{keywordflow}{  enddo}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a81b020bcce067d3c3a45a21faa526227}\label{namespacemom__open__boundary_a81b020bcce067d3c3a45a21faa526227}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!initialize\_segment\_data@{initialize\_segment\_data}}
\index{initialize\_segment\_data@{initialize\_segment\_data}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{initialize\_segment\_data()}{initialize\_segment\_data()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::initialize\+\_\+segment\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(inout)}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF }\end{DoxyParamCaption})}



Allocate space for reading O\+BC data from files. It sets up the required vertical remapping. In the process, it does funky stuff with the M\+PI processes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & Parameter file handle \\
\hline
\end{DoxyParams}


Definition at line 653 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{654   \textcolor{keywordtype}{use }mpp\_mod, \textcolor{keywordtype}{only} : mpp\_pe, mpp\_set\_current\_pelist, mpp\_get\_current\_pelist,mpp\_npes}
\DoxyCodeLine{655 }
\DoxyCodeLine{656   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{657   \textcolor{keywordtype}{type}(ocean\_OBC\_type),   \textcolor{keywordtype}{intent(inout)} :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{658   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{  !< Parameter file handle}}
\DoxyCodeLine{659 }
\DoxyCodeLine{660   \textcolor{keywordtype}{integer} :: n,m,num\_fields}
\DoxyCodeLine{661   \textcolor{keywordtype}{character(len=1024)} :: segstr}
\DoxyCodeLine{662   \textcolor{keywordtype}{character(len=256)} :: filename}
\DoxyCodeLine{663   \textcolor{keywordtype}{character(len=20)}  :: segnam, suffix}
\DoxyCodeLine{664   \textcolor{keywordtype}{character(len=32)}  :: varnam, fieldname}
\DoxyCodeLine{665 \textcolor{keywordtype}{  real}               :: value}
\DoxyCodeLine{666   \textcolor{keywordtype}{character(len=32)}, \textcolor{keywordtype}{dimension(MAX\_OBC\_FIELDS)} :: fields  \textcolor{comment}{! segment field names}}
\DoxyCodeLine{667   \textcolor{keywordtype}{character(len=128)} :: inputdir}
\DoxyCodeLine{668   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{669   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{670   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: siz,siz2}
\DoxyCodeLine{671   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{672   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{673   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{674   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: saved\_pelist}
\DoxyCodeLine{675   \textcolor{keywordtype}{integer} :: current\_pe}
\DoxyCodeLine{676   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(1)} :: single\_pelist}
\DoxyCodeLine{677   \textcolor{comment}{!will be able to dynamically switch between sub-\/sampling refined grid data or model grid}}
\DoxyCodeLine{678 }
\DoxyCodeLine{679   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{680 }
\DoxyCodeLine{681   \textcolor{comment}{! There is a problem with the order of the OBC initialization}}
\DoxyCodeLine{682   \textcolor{comment}{! with respect to ALE\_init. Currently handling this by copying the}}
\DoxyCodeLine{683   \textcolor{comment}{! param file so that I can use it later in step\_MOM in order to finish}}
\DoxyCodeLine{684   \textcolor{comment}{! initializing segments on the first step.}}
\DoxyCodeLine{685 }
\DoxyCodeLine{686   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"{}INPUTDIR"{}}, inputdir, default=\textcolor{stringliteral}{"{}."{}})}
\DoxyCodeLine{687   inputdir = slasher(inputdir)}
\DoxyCodeLine{688 }
\DoxyCodeLine{689   \textcolor{keywordflow}{if} (obc\%user\_BCs\_set\_globally) \textcolor{keywordflow}{return}}
\DoxyCodeLine{690 }
\DoxyCodeLine{691   \textcolor{comment}{! Try this here just for the documentation. It is repeated below.}}
\DoxyCodeLine{692   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{693     segment => obc\%segment(n)}
\DoxyCodeLine{694     \textcolor{keyword}{write}(segnam,\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3,'\_DATA')"{}}) n}
\DoxyCodeLine{695     \textcolor{keyword}{call }get\_param(pf, mdl, segnam, segstr, \textcolor{stringliteral}{'OBC segment docs'})}
\DoxyCodeLine{696 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{697 }
\DoxyCodeLine{698   \textcolor{comment}{!< temporarily disable communication in order to read segment data independently}}
\DoxyCodeLine{699 }
\DoxyCodeLine{700   \textcolor{keyword}{allocate}(saved\_pelist(0:mpp\_npes()-\/1))}
\DoxyCodeLine{701   \textcolor{keyword}{call }mpp\_get\_current\_pelist(saved\_pelist)}
\DoxyCodeLine{702   current\_pe = mpp\_pe()}
\DoxyCodeLine{703   single\_pelist(1) = current\_pe}
\DoxyCodeLine{704   \textcolor{keyword}{call }mpp\_set\_current\_pelist(single\_pelist)}
\DoxyCodeLine{705 }
\DoxyCodeLine{706   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{707     segment => obc\%segment(n)}
\DoxyCodeLine{708     \textcolor{keywordflow}{if} (.not. segment\%values\_needed) cycle}
\DoxyCodeLine{709 }
\DoxyCodeLine{710     \textcolor{keyword}{write}(segnam,\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3,'\_DATA')"{}}) n}
\DoxyCodeLine{711     \textcolor{keyword}{write}(suffix,\textcolor{stringliteral}{"{}('\_segment\_',i3.3)"{}}) n}
\DoxyCodeLine{712     \textcolor{comment}{! needs documentation !!  Yet, unsafe for now, causes grief for}}
\DoxyCodeLine{713     \textcolor{comment}{! MOM\_parameter\_docs in circle\_obcs on two processes.}}
\DoxyCodeLine{714 \textcolor{comment}{!   call get\_param(PF, mdl, segnam, segstr, 'xyz')}}
\DoxyCodeLine{715     \textcolor{comment}{! Clear out any old values}}
\DoxyCodeLine{716     segstr = \textcolor{stringliteral}{''}}
\DoxyCodeLine{717     \textcolor{keyword}{call }get\_param(pf, mdl, segnam, segstr)}
\DoxyCodeLine{718     \textcolor{keywordflow}{if} (segstr == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{719       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}No OBC\_SEGMENT\_XXX\_DATA string for OBC segment "{},I3)'}) n}
\DoxyCodeLine{720       \textcolor{keyword}{call }mom\_error(fatal, mesg)}
\DoxyCodeLine{721 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{722 }
\DoxyCodeLine{723     \textcolor{keyword}{call }parse\_segment\_manifest\_str(trim(segstr), num\_fields, fields)}
\DoxyCodeLine{724     \textcolor{keywordflow}{if} (num\_fields == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{725       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'initialize\_segment\_data: num\_fields = 0'})}
\DoxyCodeLine{726       cycle \textcolor{comment}{! cycle to next segment}}
\DoxyCodeLine{727 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{728 }
\DoxyCodeLine{729     \textcolor{keyword}{allocate}(segment\%field(num\_fields))}
\DoxyCodeLine{730     segment\%num\_fields = num\_fields}
\DoxyCodeLine{731 }
\DoxyCodeLine{732     segment\%temp\_segment\_data\_exists=.false.}
\DoxyCodeLine{733     segment\%salt\_segment\_data\_exists=.false.}
\DoxyCodeLine{734 \textcolor{comment}{!!}}
\DoxyCodeLine{735 \textcolor{comment}{! CODE HERE FOR OTHER OPTIONS (CLAMPED, NUDGED,..)}}
\DoxyCodeLine{736 \textcolor{comment}{!!}}
\DoxyCodeLine{737 }
\DoxyCodeLine{738     isd = segment\%HI\%isd ; ied = segment\%HI\%ied}
\DoxyCodeLine{739     jsd = segment\%HI\%jsd ; jed = segment\%HI\%jed}
\DoxyCodeLine{740     isdb = segment\%HI\%IsdB ; iedb = segment\%HI\%IedB}
\DoxyCodeLine{741     jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{742 }
\DoxyCodeLine{743     \textcolor{keywordflow}{do} m=1,num\_fields}
\DoxyCodeLine{744       \textcolor{keyword}{call }parse\_segment\_data\_str(trim(segstr), m, trim(fields(m)), \&}
\DoxyCodeLine{745           \textcolor{keywordtype}{value}, filename, fieldname)}
\DoxyCodeLine{746       \textcolor{keywordflow}{if} (trim(filename) /= \textcolor{stringliteral}{'none'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{747         obc\%update\_OBC = .true. \textcolor{comment}{! Data is assumed to be time-\/dependent if we are reading from file}}
\DoxyCodeLine{748         obc\%needs\_IO\_for\_data = .true. \textcolor{comment}{! At least one segment is using I/O for OBC data}}
\DoxyCodeLine{749 \textcolor{comment}{!       segment\%values\_needed = .true. ! Indicates that i/o will be needed for this segment}}
\DoxyCodeLine{750         segment\%field(m)\%name = trim(fields(m))}
\DoxyCodeLine{751         \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{752            segment\%temp\_segment\_data\_exists=.true.}
\DoxyCodeLine{753            segment\%t\_values\_needed = .false.}
\DoxyCodeLine{754 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{755         \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{756            segment\%salt\_segment\_data\_exists=.true.}
\DoxyCodeLine{757            segment\%s\_values\_needed = .false.}
\DoxyCodeLine{758 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{759         filename = trim(inputdir)//trim(filename)}
\DoxyCodeLine{760         fieldname = trim(fieldname)//trim(suffix)}
\DoxyCodeLine{761         \textcolor{keyword}{call }field\_size(filename,fieldname,siz,no\_domain=.true.)}
\DoxyCodeLine{762 \textcolor{comment}{!       if (siz(4) == 1) segment\%values\_needed = .false.}}
\DoxyCodeLine{763         \textcolor{keywordflow}{if} (segment\%on\_pe) \textcolor{keywordflow}{then}}
\DoxyCodeLine{764           \textcolor{keywordflow}{if} (obc\%brushcutter\_mode .and. (modulo(siz(1),2) == 0 .or. modulo(siz(2),2) == 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{765             \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'segment data are not on the supergrid'})}
\DoxyCodeLine{766 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{767           siz2(1)=1}
\DoxyCodeLine{768 }
\DoxyCodeLine{769           \textcolor{keywordflow}{if} (siz(1)>1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{770             \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{771               siz2(1)=(siz(1)-\/1)/2}
\DoxyCodeLine{772             \textcolor{keywordflow}{else}}
\DoxyCodeLine{773               siz2(1)=siz(1)}
\DoxyCodeLine{774 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{775 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{776           siz2(2)=1}
\DoxyCodeLine{777           \textcolor{keywordflow}{if} (siz(2)>1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{778             \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{779               siz2(2)=(siz(2)-\/1)/2}
\DoxyCodeLine{780             \textcolor{keywordflow}{else}}
\DoxyCodeLine{781               siz2(2)=siz(2)}
\DoxyCodeLine{782 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{783 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{784           siz2(3)=siz(3)}
\DoxyCodeLine{785 }
\DoxyCodeLine{786           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{787             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{788               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{789               segment\%v\_values\_needed = .false.}
\DoxyCodeLine{790             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{791               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{792               segment\%vamp\_values\_needed = .false.}
\DoxyCodeLine{793               segment\%vamp\_index = m}
\DoxyCodeLine{794             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{795               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{796               segment\%vphase\_values\_needed = .false.}
\DoxyCodeLine{797               segment\%vphase\_index = m}
\DoxyCodeLine{798             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{799               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{800               segment\%g\_values\_needed = .false.}
\DoxyCodeLine{801             \textcolor{keywordflow}{else}}
\DoxyCodeLine{802               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsd:jed,siz2(3)))}
\DoxyCodeLine{803               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{804                 segment\%u\_values\_needed = .false.}
\DoxyCodeLine{805               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{806                 segment\%uamp\_values\_needed = .false.}
\DoxyCodeLine{807                 segment\%uamp\_index = m}
\DoxyCodeLine{808               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{809                 segment\%uphase\_values\_needed = .false.}
\DoxyCodeLine{810                 segment\%uphase\_index = m}
\DoxyCodeLine{811               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSH'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{812                 segment\%z\_values\_needed = .false.}
\DoxyCodeLine{813               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{814                 segment\%zamp\_values\_needed = .false.}
\DoxyCodeLine{815                 segment\%zamp\_index = m}
\DoxyCodeLine{816               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{817                 segment\%zphase\_values\_needed = .false.}
\DoxyCodeLine{818                 segment\%zphase\_index = m}
\DoxyCodeLine{819               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{820                 segment\%t\_values\_needed = .false.}
\DoxyCodeLine{821               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{822                 segment\%s\_values\_needed = .false.}
\DoxyCodeLine{823 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{824 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{825           \textcolor{keywordflow}{else}}
\DoxyCodeLine{826             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{827               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{828               segment\%u\_values\_needed = .false.}
\DoxyCodeLine{829             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{830               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{831               segment\%g\_values\_needed = .false.}
\DoxyCodeLine{832             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{833               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{834               segment\%uamp\_values\_needed = .false.}
\DoxyCodeLine{835               segment\%uamp\_index = m}
\DoxyCodeLine{836             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{837               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isdb:iedb,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{838               segment\%uphase\_values\_needed = .false.}
\DoxyCodeLine{839               segment\%uphase\_index = m}
\DoxyCodeLine{840             \textcolor{keywordflow}{else}}
\DoxyCodeLine{841               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_src(isd:ied,jsdb:jedb,siz2(3)))}
\DoxyCodeLine{842               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{843                 segment\%v\_values\_needed = .false.}
\DoxyCodeLine{844               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{845                 segment\%vamp\_values\_needed = .false.}
\DoxyCodeLine{846                 segment\%vamp\_index = m}
\DoxyCodeLine{847               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{848                 segment\%vphase\_values\_needed = .false.}
\DoxyCodeLine{849                 segment\%vphase\_index = m}
\DoxyCodeLine{850               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSH'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{851                 segment\%z\_values\_needed = .false.}
\DoxyCodeLine{852               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{853                 segment\%zamp\_values\_needed = .false.}
\DoxyCodeLine{854                 segment\%zamp\_index = m}
\DoxyCodeLine{855               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{856                 segment\%zphase\_values\_needed = .false.}
\DoxyCodeLine{857                 segment\%zphase\_index = m}
\DoxyCodeLine{858               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{859                 segment\%t\_values\_needed = .false.}
\DoxyCodeLine{860               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{861                 segment\%s\_values\_needed = .false.}
\DoxyCodeLine{862 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{863 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{864 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{865           segment\%field(m)\%buffer\_src(:,:,:)=0.0}
\DoxyCodeLine{866           segment\%field(m)\%fid = init\_external\_field(trim(filename),\&}
\DoxyCodeLine{867                trim(fieldname),ignore\_axis\_atts=.true.,threading=single\_file)}
\DoxyCodeLine{868           \textcolor{keywordflow}{if} (siz(3) > 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{869             \textcolor{keywordflow}{if} ((index(segment\%field(m)\%name, \textcolor{stringliteral}{'phase'}) > 0) .or. (index(segment\%field(m)\%name, \textcolor{stringliteral}{'amp'}) > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{870               \textcolor{comment}{! siz(3) is constituent for tidal variables}}
\DoxyCodeLine{871               \textcolor{keyword}{call }field\_size(filename, \textcolor{stringliteral}{'constituent'}, siz, no\_domain=.true.)}
\DoxyCodeLine{872               \textcolor{comment}{! expect third dimension to be number of constituents in MOM\_input}}
\DoxyCodeLine{873               \textcolor{keywordflow}{if} (siz(3) .ne. obc\%n\_tide\_constituents .and. obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{874                 \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'Number of constituents in input data is not '}//\&}
\DoxyCodeLine{875                     \textcolor{stringliteral}{'the same as the number specified'})}
\DoxyCodeLine{876 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{877               segment\%field(m)\%nk\_src=siz(3)}
\DoxyCodeLine{878             \textcolor{keywordflow}{else}}
\DoxyCodeLine{879               \textcolor{comment}{! siz(3) is depth for everything else}}
\DoxyCodeLine{880               fieldname = \textcolor{stringliteral}{'dz\_'}//trim(fieldname)}
\DoxyCodeLine{881               \textcolor{keyword}{call }field\_size(filename,fieldname,siz,no\_domain=.true.)}
\DoxyCodeLine{882               \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{883                 \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{884                   \textcolor{keyword}{allocate}(segment\%field(m)\%dz\_src(isdb:iedb,jsdb:jedb,siz(3)))}
\DoxyCodeLine{885                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{886                   \textcolor{keyword}{allocate}(segment\%field(m)\%dz\_src(isdb:iedb,jsd:jed,siz(3)))}
\DoxyCodeLine{887 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{888               \textcolor{keywordflow}{else}}
\DoxyCodeLine{889                 \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{890                   \textcolor{keyword}{allocate}(segment\%field(m)\%dz\_src(isdb:iedb,jsdb:jedb,siz(3)))}
\DoxyCodeLine{891                 \textcolor{keywordflow}{else}}
\DoxyCodeLine{892                   \textcolor{keyword}{allocate}(segment\%field(m)\%dz\_src(isd:ied,jsdb:jedb,siz(3)))}
\DoxyCodeLine{893 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{894 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{895               segment\%field(m)\%dz\_src(:,:,:)=0.0}
\DoxyCodeLine{896               segment\%field(m)\%nk\_src=siz(3)}
\DoxyCodeLine{897               segment\%field(m)\%fid\_dz = init\_external\_field(trim(filename),trim(fieldname),\&}
\DoxyCodeLine{898                         ignore\_axis\_atts=.true.,threading=single\_file)}
\DoxyCodeLine{899 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{900           \textcolor{keywordflow}{else}}
\DoxyCodeLine{901             segment\%field(m)\%nk\_src=1}
\DoxyCodeLine{902 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{903 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{904       \textcolor{keywordflow}{else}}
\DoxyCodeLine{905         segment\%field(m)\%fid = -\/1}
\DoxyCodeLine{906         segment\%field(m)\%value = \textcolor{keywordtype}{value}}
\DoxyCodeLine{907         segment\%field(m)\%name = trim(fields(m))}
\DoxyCodeLine{908         \textcolor{comment}{! Check if this is a tidal field. If so, the number}}
\DoxyCodeLine{909         \textcolor{comment}{! of expected constiuents must be 1.}}
\DoxyCodeLine{910         \textcolor{keywordflow}{if} ((index(segment\%field(m)\%name, \textcolor{stringliteral}{'phase'}) > 0) .or. (index(segment\%field(m)\%name, \textcolor{stringliteral}{'amp'}) > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{911           \textcolor{keywordflow}{if} (obc\%n\_tide\_constituents .gt. 1 .and. obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{912             \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'Only one constituent is supported when specifying '}//\&}
\DoxyCodeLine{913                 \textcolor{stringliteral}{'tidal boundary conditions by value rather than file.'})}
\DoxyCodeLine{914 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{915 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{916         \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{917           segment\%u\_values\_needed = .false.}
\DoxyCodeLine{918         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{919           segment\%uamp\_values\_needed = .false.}
\DoxyCodeLine{920           segment\%uamp\_index = m}
\DoxyCodeLine{921         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{922           segment\%uphase\_values\_needed = .false.}
\DoxyCodeLine{923           segment\%uphase\_index = m}
\DoxyCodeLine{924         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{925           segment\%v\_values\_needed = .false.}
\DoxyCodeLine{926         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{927           segment\%vamp\_values\_needed = .false.}
\DoxyCodeLine{928           segment\%vamp\_index = m}
\DoxyCodeLine{929         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{930           segment\%vphase\_values\_needed = .false.}
\DoxyCodeLine{931           segment\%vphase\_index = m}
\DoxyCodeLine{932         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSH'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{933           segment\%z\_values\_needed = .false.}
\DoxyCodeLine{934         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{935           segment\%zamp\_values\_needed = .false.}
\DoxyCodeLine{936           segment\%zamp\_index = m}
\DoxyCodeLine{937         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{938           segment\%zphase\_values\_needed = .false.}
\DoxyCodeLine{939           segment\%zphase\_index = m}
\DoxyCodeLine{940         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{941           segment\%t\_values\_needed = .false.}
\DoxyCodeLine{942         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{943           segment\%s\_values\_needed = .false.}
\DoxyCodeLine{944         \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{945           segment\%g\_values\_needed = .false.}
\DoxyCodeLine{946 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{947 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{948 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{949     \textcolor{keywordflow}{if} (segment\%u\_values\_needed .or. segment\%uamp\_values\_needed .or. segment\%uphase\_values\_needed .or. \&}
\DoxyCodeLine{950         segment\%v\_values\_needed .or. segment\%vamp\_values\_needed .or. segment\%vphase\_values\_needed .or. \&}
\DoxyCodeLine{951         segment\%t\_values\_needed .or. segment\%s\_values\_needed .or. segment\%g\_values\_needed .or. \&}
\DoxyCodeLine{952         segment\%z\_values\_needed .or. segment\%zamp\_values\_needed .or. segment\%zphase\_values\_needed ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{953       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}Values needed for OBC segment "{},I3)'}) n}
\DoxyCodeLine{954       \textcolor{keyword}{call }mom\_error(fatal, mesg)}
\DoxyCodeLine{955 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{956 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{957 }
\DoxyCodeLine{958   \textcolor{keyword}{call }mpp\_set\_current\_pelist(saved\_pelist)}
\DoxyCodeLine{959 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a29dd2dc87f43e0e26d22367ce93519ff}\label{namespacemom__open__boundary_a29dd2dc87f43e0e26d22367ce93519ff}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!lookup\_seg\_field@{lookup\_seg\_field}}
\index{lookup\_seg\_field@{lookup\_seg\_field}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{lookup\_seg\_field()}{lookup\_seg\_field()}}
{\footnotesize\ttfamily integer function mom\+\_\+open\+\_\+boundary\+::lookup\+\_\+seg\+\_\+field (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), pointer}]{O\+B\+C\+\_\+seg,  }\item[{character(len=32), intent(in)}]{field }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Needs documentation. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc\+\_\+seg} & O\+BC segment \\
\hline
\mbox{\texttt{ in}}  & {\em field} & The field name \\
\hline
\end{DoxyParams}


Definition at line 3482 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3483   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: OBC\_seg\textcolor{comment}{ !< OBC segment}}
\DoxyCodeLine{3484   \textcolor{keywordtype}{character(len=32)}, \textcolor{keywordtype}{intent(in)} :: field\textcolor{comment}{ !< The field name}}
\DoxyCodeLine{3485   \textcolor{keywordtype}{integer} :: lookup\_seg\_field}
\DoxyCodeLine{3486   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3487   \textcolor{keywordtype}{integer} :: n}
\DoxyCodeLine{3488 }
\DoxyCodeLine{3489   lookup\_seg\_field=-\/1}
\DoxyCodeLine{3490   \textcolor{keywordflow}{do} n=1,obc\_seg\%num\_fields}
\DoxyCodeLine{3491    \textcolor{keywordflow}{if} (trim(field) == obc\_seg\%field(n)\%name) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3492      lookup\_seg\_field=n}
\DoxyCodeLine{3493      \textcolor{keywordflow}{return}}
\DoxyCodeLine{3494 \textcolor{keywordflow}{   endif}}
\DoxyCodeLine{3495 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3496 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a7dbf161294debd059a40659ba691ca0b}\label{namespacemom__open__boundary_a7dbf161294debd059a40659ba691ca0b}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!mask\_outside\_obcs@{mask\_outside\_obcs}}
\index{mask\_outside\_obcs@{mask\_outside\_obcs}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{mask\_outside\_obcs()}{mask\_outside\_obcs()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::mask\+\_\+outside\+\_\+obcs (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Find the region outside of all open boundary segments and make sure it is set to land mask. Gonna need to know global land mask as well to get it right... 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 4698 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4699   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),       \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{          !< Ocean grid structure}}
\DoxyCodeLine{4700   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{4701   \textcolor{keywordtype}{type}(ocean\_OBC\_type),         \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{        !< Open boundary structure}}
\DoxyCodeLine{4702   \textcolor{keywordtype}{type}(unit\_scale\_type),        \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{         !< A dimensional unit scaling type}}
\DoxyCodeLine{4703 }
\DoxyCodeLine{4704   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4705   \textcolor{keywordtype}{integer} :: isd, ied, IsdB, IedB, jsd, jed, JsdB, JedB, n}
\DoxyCodeLine{4706   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{4707   \textcolor{keywordtype}{integer} :: l\_seg}
\DoxyCodeLine{4708   \textcolor{keywordtype}{logical} :: fatal\_error = .false.}
\DoxyCodeLine{4709 \textcolor{keywordtype}{  real}    :: min\_depth}
\DoxyCodeLine{4710   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: cin = 3, cout = 4, cland = -\/1, cedge = -\/2}
\DoxyCodeLine{4711   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{4712   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{4713 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:)} :: color, color2  \textcolor{comment}{! For sorting inside from outside,}}
\DoxyCodeLine{4714                                                       \textcolor{comment}{! two different ways}}
\DoxyCodeLine{4715 }
\DoxyCodeLine{4716   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{4717 }
\DoxyCodeLine{4718   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}MINIMUM\_DEPTH"{}}, min\_depth, \&}
\DoxyCodeLine{4719                  units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=us\%m\_to\_Z, do\_not\_log=.true.)}
\DoxyCodeLine{4720 }
\DoxyCodeLine{4721   \textcolor{keyword}{allocate}(color(g\%isd:g\%ied, g\%jsd:g\%jed)) ; color = 0}
\DoxyCodeLine{4722   \textcolor{keyword}{allocate}(color2(g\%isd:g\%ied, g\%jsd:g\%jed)) ; color2 = 0}
\DoxyCodeLine{4723 }
\DoxyCodeLine{4724 }
\DoxyCodeLine{4725   \textcolor{comment}{! Paint a frame around the outside.}}
\DoxyCodeLine{4726   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed}
\DoxyCodeLine{4727     color(g\%isd,j) = cedge}
\DoxyCodeLine{4728     color(g\%ied,j) = cedge}
\DoxyCodeLine{4729     color2(g\%isd,j) = cedge}
\DoxyCodeLine{4730     color2(g\%ied,j) = cedge}
\DoxyCodeLine{4731 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4732   \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{4733     color(i,g\%jsd) = cedge}
\DoxyCodeLine{4734     color(i,g\%jed) = cedge}
\DoxyCodeLine{4735     color2(i,g\%jsd) = cedge}
\DoxyCodeLine{4736     color2(i,g\%jed) = cedge}
\DoxyCodeLine{4737 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4738 }
\DoxyCodeLine{4739   \textcolor{comment}{! Set color to cland in the land. Note that this is before the land}}
\DoxyCodeLine{4740   \textcolor{comment}{! mask has been initialized, set mask values based on depth.}}
\DoxyCodeLine{4741   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed}
\DoxyCodeLine{4742     \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{4743       \textcolor{keywordflow}{if} (g\%bathyT(i,j) <= min\_depth) color(i,j) = cland}
\DoxyCodeLine{4744       \textcolor{keywordflow}{if} (g\%bathyT(i,j) <= min\_depth) color2(i,j) = cland}
\DoxyCodeLine{4745 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4746 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4747 }
\DoxyCodeLine{4748   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%IsdB+1,g\%IedB-\/1}
\DoxyCodeLine{4749     l\_seg = obc\%segnum\_u(i,j)}
\DoxyCodeLine{4750     \textcolor{keywordflow}{if} (l\_seg == obc\_none) cycle}
\DoxyCodeLine{4751 }
\DoxyCodeLine{4752     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4753       \textcolor{keywordflow}{if} (color(i,j) == 0.0) color(i,j) = cout}
\DoxyCodeLine{4754       \textcolor{keywordflow}{if} (color(i+1,j) == 0.0) color(i+1,j) = cin}
\DoxyCodeLine{4755     \textcolor{keywordflow}{elseif} (obc\%segment(l\_seg)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4756       \textcolor{keywordflow}{if} (color(i,j) == 0.0) color(i,j) = cin}
\DoxyCodeLine{4757       \textcolor{keywordflow}{if} (color(i+1,j) == 0.0) color(i+1,j) = cout}
\DoxyCodeLine{4758 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4759 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4760   \textcolor{keywordflow}{do} j=g\%JsdB+1,g\%JedB-\/1 ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{4761     l\_seg = obc\%segnum\_v(i,j)}
\DoxyCodeLine{4762     \textcolor{keywordflow}{if} (l\_seg == obc\_none) cycle}
\DoxyCodeLine{4763 }
\DoxyCodeLine{4764     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4765       \textcolor{keywordflow}{if} (color(i,j) == 0.0) color(i,j) = cout}
\DoxyCodeLine{4766       \textcolor{keywordflow}{if} (color(i,j+1) == 0.0) color(i,j+1) = cin}
\DoxyCodeLine{4767     \textcolor{keywordflow}{elseif} (obc\%segment(l\_seg)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4768       \textcolor{keywordflow}{if} (color(i,j) == 0.0) color(i,j) = cin}
\DoxyCodeLine{4769       \textcolor{keywordflow}{if} (color(i,j+1) == 0.0) color(i,j+1) = cout}
\DoxyCodeLine{4770 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4771 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4772 }
\DoxyCodeLine{4773   \textcolor{keywordflow}{do} j=g\%JsdB+1,g\%JedB-\/1 ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{4774     l\_seg = obc\%segnum\_v(i,j)}
\DoxyCodeLine{4775     \textcolor{keywordflow}{if} (l\_seg == obc\_none) cycle}
\DoxyCodeLine{4776 }
\DoxyCodeLine{4777     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4778       \textcolor{keywordflow}{if} (color2(i,j) == 0.0) color2(i,j) = cout}
\DoxyCodeLine{4779       \textcolor{keywordflow}{if} (color2(i,j+1) == 0.0) color2(i,j+1) = cin}
\DoxyCodeLine{4780     \textcolor{keywordflow}{elseif} (obc\%segment(l\_seg)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4781       \textcolor{keywordflow}{if} (color2(i,j) == 0.0) color2(i,j) = cin}
\DoxyCodeLine{4782       \textcolor{keywordflow}{if} (color2(i,j+1) == 0.0) color2(i,j+1) = cout}
\DoxyCodeLine{4783 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4784 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4785   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%IsdB+1,g\%IedB-\/1}
\DoxyCodeLine{4786     l\_seg = obc\%segnum\_u(i,j)}
\DoxyCodeLine{4787     \textcolor{keywordflow}{if} (l\_seg == obc\_none) cycle}
\DoxyCodeLine{4788 }
\DoxyCodeLine{4789     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4790       \textcolor{keywordflow}{if} (color2(i,j) == 0.0) color2(i,j) = cout}
\DoxyCodeLine{4791       \textcolor{keywordflow}{if} (color2(i+1,j) == 0.0) color2(i+1,j) = cin}
\DoxyCodeLine{4792     \textcolor{keywordflow}{elseif} (obc\%segment(l\_seg)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4793       \textcolor{keywordflow}{if} (color2(i,j) == 0.0) color2(i,j) = cin}
\DoxyCodeLine{4794       \textcolor{keywordflow}{if} (color2(i+1,j) == 0.0) color2(i+1,j) = cout}
\DoxyCodeLine{4795 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4796 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4797 }
\DoxyCodeLine{4798   \textcolor{comment}{! Do the flood fill until there are no more uncolored cells.}}
\DoxyCodeLine{4799   \textcolor{keyword}{call }flood\_fill(g, color, cin, cout, cland)}
\DoxyCodeLine{4800   \textcolor{keyword}{call }flood\_fill2(g, color2, cin, cout, cland)}
\DoxyCodeLine{4801 }
\DoxyCodeLine{4802   \textcolor{comment}{! Use the color to set outside to min\_depth on this process.}}
\DoxyCodeLine{4803   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{4804     \textcolor{keywordflow}{if} (color(i,j) /= color2(i,j)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4805       fatal\_error = .true.}
\DoxyCodeLine{4806       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}MOM\_open\_boundary: problem with OBC segments specification at "{},I5,"{},"{},I5,"{} during\(\backslash\)n"{}, \&}}
\DoxyCodeLine{4807 \textcolor{stringliteral}{}\textcolor{stringliteral}{          "{}the masking of the outside grid points."{})'}) i, j}
\DoxyCodeLine{4808       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"{}MOM register\_tracer: "{}}//mesg, all\_print=.true.)}
\DoxyCodeLine{4809 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4810     \textcolor{keywordflow}{if} (color(i,j) == cout) g\%bathyT(i,j) = min\_depth}
\DoxyCodeLine{4811 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4812   \textcolor{keywordflow}{if} (fatal\_error) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{4813       \textcolor{stringliteral}{"{}MOM\_open\_boundary: inconsistent OBC segments."{}})}
\DoxyCodeLine{4814 }
\DoxyCodeLine{4815   \textcolor{keyword}{deallocate}(color)}
\DoxyCodeLine{4816   \textcolor{keyword}{deallocate}(color2)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a0a6e28bbfec6ab82bfe2fd2848902945}\label{namespacemom__open__boundary_a0a6e28bbfec6ab82bfe2fd2848902945}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!obc\_registry\_init@{obc\_registry\_init}}
\index{obc\_registry\_init@{obc\_registry\_init}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{obc\_registry\_init()}{obc\_registry\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::obc\+\_\+registry\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__registry__type}{obc\+\_\+registry\+\_\+type}}), pointer}]{Reg }\end{DoxyParamCaption})}



This routine include declares and sets the variable \char`\"{}version\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & open file to parse for model parameters \\
\hline
 & {\em reg} & pointer to O\+BC registry \\
\hline
\end{DoxyParams}


Definition at line 4439 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4440   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< open file to parse for model parameters}}
\DoxyCodeLine{4441   \textcolor{keywordtype}{type}(OBC\_registry\_type), \textcolor{keywordtype}{pointer}    :: Reg\textcolor{comment}{        !< pointer to OBC registry}}
\DoxyCodeLine{4442 }
\DoxyCodeLine{4443   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{save} :: init\_calls = 0}
\DoxyCodeLine{4444 }
\DoxyCodeLine{4445 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{4446 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}MOM\_open\_boundary"{}} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{4447   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{4448 }
\DoxyCodeLine{4449   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(reg)) \textcolor{keywordflow}{then} ; \textcolor{keyword}{allocate}(reg)}
\DoxyCodeLine{4450   \textcolor{keywordflow}{else} ; \textcolor{keywordflow}{return} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{4451 }
\DoxyCodeLine{4452   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{4453 \textcolor{comment}{! call log\_version(param\_file, mdl,s version, "{}"{})}}
\DoxyCodeLine{4454 }
\DoxyCodeLine{4455   init\_calls = init\_calls + 1}
\DoxyCodeLine{4456   \textcolor{keywordflow}{if} (init\_calls > 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4457     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}OBC\_registry\_init called "{},I3, \&}}
\DoxyCodeLine{4458 \textcolor{stringliteral}{}\textcolor{stringliteral}{      \&"{} times with different registry pointers."{})'}) init\_calls}
\DoxyCodeLine{4459     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"{}MOM\_open\_boundary"{}}//mesg)}
\DoxyCodeLine{4460 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4461 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a11acc9ede6f2b975bfc6b849a2603b46}\label{namespacemom__open__boundary_a11acc9ede6f2b975bfc6b849a2603b46}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_apply\_normal\_flow@{open\_boundary\_apply\_normal\_flow}}
\index{open\_boundary\_apply\_normal\_flow@{open\_boundary\_apply\_normal\_flow}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_apply\_normal\_flow()}{open\_boundary\_apply\_normal\_flow()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+apply\+\_\+normal\+\_\+flow (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v }\end{DoxyParamCaption})}



Applies O\+BC values stored in segments to 3d u,v fields. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & u field to update on open boundaries \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & v field to update on open boundaries \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 3228 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3229   \textcolor{comment}{! Arguments}}
\DoxyCodeLine{3230   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{3231   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{3232 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{   !< u field to update on open}}
\DoxyCodeLine{3233 \textcolor{comment}{                                                                  !! boundaries [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3234 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{   !< v field to update on open}}
\DoxyCodeLine{3235 \textcolor{comment}{                                                                  !! boundaries [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3236   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3237   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{3238   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{3239 }
\DoxyCodeLine{3240   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return} \textcolor{comment}{! Bail out if OBC is not available}}
\DoxyCodeLine{3241 }
\DoxyCodeLine{3242   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{3243     segment => obc\%segment(n)}
\DoxyCodeLine{3244     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3245       cycle}
\DoxyCodeLine{3246     \textcolor{keywordflow}{elseif} (segment\%radiation .or. segment\%oblique .or. segment\%gradient) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3247       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3248         i=segment\%HI\%IsdB}
\DoxyCodeLine{3249         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{3250           u(i,j,k) = segment\%normal\_vel(i,j,k)}
\DoxyCodeLine{3251 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3252       \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3253         j=segment\%HI\%JsdB}
\DoxyCodeLine{3254         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{3255           v(i,j,k) = segment\%normal\_vel(i,j,k)}
\DoxyCodeLine{3256 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3257 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3258 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3259 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3260 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_ac94938f1a657896ff03efd3864faa02a}\label{namespacemom__open__boundary_ac94938f1a657896ff03efd3864faa02a}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_config@{open\_boundary\_config}}
\index{open\_boundary\_config@{open\_boundary\_config}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_config()}{open\_boundary\_config()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+config (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC }\end{DoxyParamCaption})}



Enables O\+BC module and reads configuration parameters This routine is called from M\+O\+M\+\_\+initialize\+\_\+fixed which occurs before the initialization of the vertical coordinate and A\+L\+E\+\_\+init. Therefore segment data are not fully initialized here. The remainder of the segment data are initialized in a later call to update\+\_\+open\+\_\+boundary\+\_\+data. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
\end{DoxyParams}


Definition at line 359 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{360   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{361   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{362   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{363   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{364   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{365   \textcolor{keywordtype}{integer} :: l \textcolor{comment}{! For looping over segments}}
\DoxyCodeLine{366   \textcolor{keywordtype}{logical} :: debug\_OBC, debug, mask\_outside, reentrant\_x, reentrant\_y}
\DoxyCodeLine{367   \textcolor{keywordtype}{character(len=15)} :: segment\_param\_str \textcolor{comment}{! The run-\/time parameter name for each segment}}
\DoxyCodeLine{368   \textcolor{keywordtype}{character(len=1024)} :: segment\_str      \textcolor{comment}{! The contents (rhs) for parameter "{}segment\_param\_str"{}}}
\DoxyCodeLine{369   \textcolor{keywordtype}{character(len=200)} :: config1          \textcolor{comment}{! String for OBC\_USER\_CONFIG}}
\DoxyCodeLine{370 \textcolor{keywordtype}{  real}               :: Lscale\_in, Lscale\_out \textcolor{comment}{! parameters controlling tracer values at the boundaries [L \string~> m]}}
\DoxyCodeLine{371   \textcolor{keywordtype}{character(len=128)} :: inputdir}
\DoxyCodeLine{372   \textcolor{keywordtype}{logical} :: answers\_2018, default\_2018\_answers}
\DoxyCodeLine{373   \textcolor{keywordtype}{logical} :: check\_reconstruction, check\_remapping, force\_bounds\_in\_subcell}
\DoxyCodeLine{374   \textcolor{keywordtype}{character(len=32)}  :: remappingScheme}
\DoxyCodeLine{375   \textcolor{keyword}{allocate}(obc)}
\DoxyCodeLine{376 }
\DoxyCodeLine{377   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_NUMBER\_OF\_SEGMENTS"{}}, obc\%number\_of\_segments, \&}
\DoxyCodeLine{378                  default=0, do\_not\_log=.true.)}
\DoxyCodeLine{379   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \&}
\DoxyCodeLine{380                  \textcolor{stringliteral}{"{}Controls where open boundaries are located, what kind of boundary condition "{}}//\&}
\DoxyCodeLine{381                  \textcolor{stringliteral}{"{}to impose, and what data to apply, if any."{}}, \&}
\DoxyCodeLine{382                  all\_default=(obc\%number\_of\_segments<=0))}
\DoxyCodeLine{383   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_NUMBER\_OF\_SEGMENTS"{}}, obc\%number\_of\_segments, \&}
\DoxyCodeLine{384                  \textcolor{stringliteral}{"{}The number of open boundary segments."{}}, \&}
\DoxyCodeLine{385                  default=0)}
\DoxyCodeLine{386   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_USER\_CONFIG"{}}, config1, \&}
\DoxyCodeLine{387                  \textcolor{stringliteral}{"{}A string that sets how the open boundary conditions are "{}}//\&}
\DoxyCodeLine{388                  \textcolor{stringliteral}{"{} configured: \(\backslash\)n"{}}, default=\textcolor{stringliteral}{"{}none"{}}, do\_not\_log=.true.)}
\DoxyCodeLine{389   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}NK"{}}, obc\%ke, \&}
\DoxyCodeLine{390                  \textcolor{stringliteral}{"{}The number of model layers"{}}, default=0, do\_not\_log=.true.)}
\DoxyCodeLine{391 }
\DoxyCodeLine{392   \textcolor{keywordflow}{if} (config1 /= \textcolor{stringliteral}{"{}none"{}} .and. config1 /= \textcolor{stringliteral}{"{}dyed\_obcs"{}}) obc\%user\_BCs\_set\_globally = .true.}
\DoxyCodeLine{393 }
\DoxyCodeLine{394   \textcolor{keywordflow}{if} (obc\%number\_of\_segments > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{395     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_ZERO\_VORTICITY"{}}, obc\%zero\_vorticity, \&}
\DoxyCodeLine{396          \textcolor{stringliteral}{"{}If true, sets relative vorticity to zero on open boundaries."{}}, \&}
\DoxyCodeLine{397          default=.false.)}
\DoxyCodeLine{398     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_FREESLIP\_VORTICITY"{}}, obc\%freeslip\_vorticity, \&}
\DoxyCodeLine{399          \textcolor{stringliteral}{"{}If true, sets the normal gradient of tangential velocity to "{}}//\&}
\DoxyCodeLine{400          \textcolor{stringliteral}{"{}zero in the relative vorticity on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{401          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_VORTICITY option is True."{}}, default=.true.)}
\DoxyCodeLine{402     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_COMPUTED\_VORTICITY"{}}, obc\%computed\_vorticity, \&}
\DoxyCodeLine{403          \textcolor{stringliteral}{"{}If true, uses the external values of tangential velocity "{}}//\&}
\DoxyCodeLine{404          \textcolor{stringliteral}{"{}in the relative vorticity on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{405          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_VORTICITY option is True."{}}, default=.false.)}
\DoxyCodeLine{406     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_SPECIFIED\_VORTICITY"{}}, obc\%specified\_vorticity, \&}
\DoxyCodeLine{407          \textcolor{stringliteral}{"{}If true, uses the external values of tangential velocity "{}}//\&}
\DoxyCodeLine{408          \textcolor{stringliteral}{"{}in the relative vorticity on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{409          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_VORTICITY option is True."{}}, default=.false.)}
\DoxyCodeLine{410     \textcolor{keywordflow}{if} ((obc\%zero\_vorticity .and. obc\%freeslip\_vorticity) .or.  \&}
\DoxyCodeLine{411         (obc\%zero\_vorticity .and. obc\%computed\_vorticity) .or.  \&}
\DoxyCodeLine{412         (obc\%zero\_vorticity .and. obc\%specified\_vorticity) .or.  \&}
\DoxyCodeLine{413         (obc\%freeslip\_vorticity .and. obc\%computed\_vorticity) .or.  \&}
\DoxyCodeLine{414         (obc\%freeslip\_vorticity .and. obc\%specified\_vorticity) .or.  \&}
\DoxyCodeLine{415         (obc\%computed\_vorticity .and. obc\%specified\_vorticity))  \&}
\DoxyCodeLine{416          \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, open\_boundary\_config:\(\backslash\)n"{}}//\&}
\DoxyCodeLine{417          \textcolor{stringliteral}{"{}Only one of OBC\_ZERO\_VORTICITY, OBC\_FREESLIP\_VORTICITY, OBC\_COMPUTED\_VORTICITY\(\backslash\)n"{}}//\&}
\DoxyCodeLine{418          \textcolor{stringliteral}{"{}and OBC\_IMPORTED\_VORTICITY can be True at once."{}})}
\DoxyCodeLine{419     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_ZERO\_STRAIN"{}}, obc\%zero\_strain, \&}
\DoxyCodeLine{420          \textcolor{stringliteral}{"{}If true, sets the strain used in the stress tensor to zero on open boundaries."{}}, \&}
\DoxyCodeLine{421          default=.false.)}
\DoxyCodeLine{422     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_FREESLIP\_STRAIN"{}}, obc\%freeslip\_strain, \&}
\DoxyCodeLine{423          \textcolor{stringliteral}{"{}If true, sets the normal gradient of tangential velocity to "{}}//\&}
\DoxyCodeLine{424          \textcolor{stringliteral}{"{}zero in the strain use in the stress tensor on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{425          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_STRAIN option is True."{}}, default=.true.)}
\DoxyCodeLine{426     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_COMPUTED\_STRAIN"{}}, obc\%computed\_strain, \&}
\DoxyCodeLine{427          \textcolor{stringliteral}{"{}If true, sets the normal gradient of tangential velocity to "{}}//\&}
\DoxyCodeLine{428          \textcolor{stringliteral}{"{}zero in the strain use in the stress tensor on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{429          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_STRAIN option is True."{}}, default=.false.)}
\DoxyCodeLine{430     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_SPECIFIED\_STRAIN"{}}, obc\%specified\_strain, \&}
\DoxyCodeLine{431          \textcolor{stringliteral}{"{}If true, sets the normal gradient of tangential velocity to "{}}//\&}
\DoxyCodeLine{432          \textcolor{stringliteral}{"{}zero in the strain use in the stress tensor on open boundaries. This cannot "{}}//\&}
\DoxyCodeLine{433          \textcolor{stringliteral}{"{}be true if another OBC\_XXX\_STRAIN option is True."{}}, default=.false.)}
\DoxyCodeLine{434     \textcolor{keywordflow}{if} ((obc\%zero\_strain .and. obc\%freeslip\_strain) .or.  \&}
\DoxyCodeLine{435         (obc\%zero\_strain .and. obc\%computed\_strain) .or.  \&}
\DoxyCodeLine{436         (obc\%zero\_strain .and. obc\%specified\_strain) .or.  \&}
\DoxyCodeLine{437         (obc\%freeslip\_strain .and. obc\%computed\_strain) .or.  \&}
\DoxyCodeLine{438         (obc\%freeslip\_strain .and. obc\%specified\_strain) .or.  \&}
\DoxyCodeLine{439         (obc\%computed\_strain .and. obc\%specified\_strain))  \&}
\DoxyCodeLine{440          \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, open\_boundary\_config: \(\backslash\)n"{}}//\&}
\DoxyCodeLine{441          \textcolor{stringliteral}{"{}Only one of OBC\_ZERO\_STRAIN, OBC\_FREESLIP\_STRAIN, OBC\_COMPUTED\_STRAIN \(\backslash\)n"{}}//\&}
\DoxyCodeLine{442          \textcolor{stringliteral}{"{}and OBC\_IMPORTED\_STRAIN can be True at once."{}})}
\DoxyCodeLine{443     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_ZERO\_BIHARMONIC"{}}, obc\%zero\_biharmonic, \&}
\DoxyCodeLine{444          \textcolor{stringliteral}{"{}If true, zeros the Laplacian of flow on open boundaries in the biharmonic "{}}//\&}
\DoxyCodeLine{445          \textcolor{stringliteral}{"{}viscosity term."{}}, default=.false.)}
\DoxyCodeLine{446     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}MASK\_OUTSIDE\_OBCS"{}}, mask\_outside, \&}
\DoxyCodeLine{447          \textcolor{stringliteral}{"{}If true, set the areas outside open boundaries to be land."{}}, \&}
\DoxyCodeLine{448          default=.false.)}
\DoxyCodeLine{449     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}RAMP\_OBCS"{}}, obc\%ramp, \&}
\DoxyCodeLine{450          \textcolor{stringliteral}{"{}If true, ramps from zero to the external values over time, with"{}}//\&}
\DoxyCodeLine{451          \textcolor{stringliteral}{"{}a ramping timescale given by RAMP\_TIMESCALE. Ramping SSH only so far"{}}, \&}
\DoxyCodeLine{452          default=.false.)}
\DoxyCodeLine{453     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_RAMP\_TIMESCALE"{}}, obc\%ramp\_timescale, \&}
\DoxyCodeLine{454          \textcolor{stringliteral}{"{}If RAMP\_OBCS is true, this sets the ramping timescale."{}}, \&}
\DoxyCodeLine{455          units=\textcolor{stringliteral}{"{}days"{}}, default=1.0, scale=86400.0*us\%s\_to\_T)}
\DoxyCodeLine{456     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TIDE\_N\_CONSTITUENTS"{}}, obc\%n\_tide\_constituents, \&}
\DoxyCodeLine{457          \textcolor{stringliteral}{"{}Number of tidal constituents being added to the open boundary."{}}, \&}
\DoxyCodeLine{458          default=0)}
\DoxyCodeLine{459 }
\DoxyCodeLine{460     \textcolor{keywordflow}{if} (obc\%n\_tide\_constituents > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{461       obc\%add\_tide\_constituents = .true.}
\DoxyCodeLine{462     \textcolor{keywordflow}{else}}
\DoxyCodeLine{463       obc\%add\_tide\_constituents = .false.}
\DoxyCodeLine{464 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{465 }
\DoxyCodeLine{466     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DEBUG"{}}, debug, default=.false.)}
\DoxyCodeLine{467     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DEBUG\_OBC"{}}, debug\_obc, default=.false.)}
\DoxyCodeLine{468     \textcolor{keywordflow}{if} (debug\_obc .or. debug) \&}
\DoxyCodeLine{469       \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DEBUG\_OBC"{}}, debug\_obc, \&}
\DoxyCodeLine{470                  \textcolor{stringliteral}{"{}If true, do additional calls to help debug the performance "{}}//\&}
\DoxyCodeLine{471                  \textcolor{stringliteral}{"{}of the open boundary condition code."{}}, default=.false., \&}
\DoxyCodeLine{472                  debuggingparam=.true.)}
\DoxyCodeLine{473 }
\DoxyCodeLine{474     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_SILLY\_THICK"{}}, obc\%silly\_h, \&}
\DoxyCodeLine{475                  \textcolor{stringliteral}{"{}A silly value of thicknesses used outside of open boundary "{}}//\&}
\DoxyCodeLine{476                  \textcolor{stringliteral}{"{}conditions for debugging."{}}, units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=us\%m\_to\_Z, \&}
\DoxyCodeLine{477                  do\_not\_log=.not.debug\_obc, debuggingparam=.true.)}
\DoxyCodeLine{478     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_SILLY\_VEL"{}}, obc\%silly\_u, \&}
\DoxyCodeLine{479                  \textcolor{stringliteral}{"{}A silly value of velocities used outside of open boundary "{}}//\&}
\DoxyCodeLine{480                  \textcolor{stringliteral}{"{}conditions for debugging."{}}, units=\textcolor{stringliteral}{"{}m/s"{}}, default=0.0, scale=us\%m\_s\_to\_L\_T, \&}
\DoxyCodeLine{481                  do\_not\_log=.not.debug\_obc, debuggingparam=.true.)}
\DoxyCodeLine{482     reentrant\_x = .false.}
\DoxyCodeLine{483     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REENTRANT\_X"{}}, reentrant\_x, default=.true.)}
\DoxyCodeLine{484     reentrant\_y = .false.}
\DoxyCodeLine{485     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REENTRANT\_Y"{}}, reentrant\_y, default=.false.)}
\DoxyCodeLine{486 }
\DoxyCodeLine{487     \textcolor{comment}{! Allocate everything}}
\DoxyCodeLine{488     \textcolor{keyword}{allocate}(obc\%segment(1:obc\%number\_of\_segments))}
\DoxyCodeLine{489     \textcolor{keywordflow}{do} l=1,obc\%number\_of\_segments}
\DoxyCodeLine{490       obc\%segment(l)\%Flather = .false.}
\DoxyCodeLine{491       obc\%segment(l)\%radiation = .false.}
\DoxyCodeLine{492       obc\%segment(l)\%radiation\_tan = .false.}
\DoxyCodeLine{493       obc\%segment(l)\%radiation\_grad = .false.}
\DoxyCodeLine{494       obc\%segment(l)\%oblique = .false.}
\DoxyCodeLine{495       obc\%segment(l)\%oblique\_tan = .false.}
\DoxyCodeLine{496       obc\%segment(l)\%oblique\_grad = .false.}
\DoxyCodeLine{497       obc\%segment(l)\%nudged = .false.}
\DoxyCodeLine{498       obc\%segment(l)\%nudged\_tan = .false.}
\DoxyCodeLine{499       obc\%segment(l)\%nudged\_grad = .false.}
\DoxyCodeLine{500       obc\%segment(l)\%specified = .false.}
\DoxyCodeLine{501       obc\%segment(l)\%specified\_tan = .false.}
\DoxyCodeLine{502       obc\%segment(l)\%specified\_grad = .false.}
\DoxyCodeLine{503       obc\%segment(l)\%open = .false.}
\DoxyCodeLine{504       obc\%segment(l)\%gradient = .false.}
\DoxyCodeLine{505       obc\%segment(l)\%values\_needed = .false.}
\DoxyCodeLine{506       obc\%segment(l)\%u\_values\_needed = .false.}
\DoxyCodeLine{507       obc\%segment(l)\%uamp\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{508       obc\%segment(l)\%uphase\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{509       obc\%segment(l)\%v\_values\_needed = .false.}
\DoxyCodeLine{510       obc\%segment(l)\%vamp\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{511       obc\%segment(l)\%vphase\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{512       obc\%segment(l)\%t\_values\_needed = .false.}
\DoxyCodeLine{513       obc\%segment(l)\%s\_values\_needed = .false.}
\DoxyCodeLine{514       obc\%segment(l)\%z\_values\_needed = .false.}
\DoxyCodeLine{515       obc\%segment(l)\%zamp\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{516       obc\%segment(l)\%zphase\_values\_needed = obc\%add\_tide\_constituents}
\DoxyCodeLine{517       obc\%segment(l)\%g\_values\_needed = .false.}
\DoxyCodeLine{518       obc\%segment(l)\%direction = obc\_none}
\DoxyCodeLine{519       obc\%segment(l)\%is\_N\_or\_S = .false.}
\DoxyCodeLine{520       obc\%segment(l)\%is\_E\_or\_W = .false.}
\DoxyCodeLine{521       obc\%segment(l)\%is\_E\_or\_W\_2 = .false.}
\DoxyCodeLine{522       obc\%segment(l)\%Velocity\_nudging\_timescale\_in = 0.0}
\DoxyCodeLine{523       obc\%segment(l)\%Velocity\_nudging\_timescale\_out = 0.0}
\DoxyCodeLine{524       obc\%segment(l)\%num\_fields = 0}
\DoxyCodeLine{525 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{526     \textcolor{keyword}{allocate}(obc\%segnum\_u(g\%IsdB:g\%IedB,g\%jsd:g\%jed)) ; obc\%segnum\_u(:,:) = obc\_none}
\DoxyCodeLine{527     \textcolor{keyword}{allocate}(obc\%segnum\_v(g\%isd:g\%ied,g\%JsdB:g\%JedB)) ; obc\%segnum\_v(:,:) = obc\_none}
\DoxyCodeLine{528 }
\DoxyCodeLine{529     \textcolor{keywordflow}{do} l = 1, obc\%number\_of\_segments}
\DoxyCodeLine{530       \textcolor{keyword}{write}(segment\_param\_str(1:15),\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3)"{}}) l}
\DoxyCodeLine{531       \textcolor{keyword}{call }get\_param(param\_file, mdl, segment\_param\_str, segment\_str, \&}
\DoxyCodeLine{532            \textcolor{stringliteral}{"{}Documentation needs to be dynamic?????"{}}, \&}
\DoxyCodeLine{533            fail\_if\_missing=.true.)}
\DoxyCodeLine{534       segment\_str = remove\_spaces(segment\_str)}
\DoxyCodeLine{535       \textcolor{keywordflow}{if} (segment\_str(1:2) == \textcolor{stringliteral}{'I='}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{536         \textcolor{keyword}{call }setup\_u\_point\_obc(obc, g, us, segment\_str, l, param\_file, reentrant\_y)}
\DoxyCodeLine{537       \textcolor{keywordflow}{elseif} (segment\_str(1:2) == \textcolor{stringliteral}{'J='}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{538         \textcolor{keyword}{call }setup\_v\_point\_obc(obc, g, us, segment\_str, l, param\_file, reentrant\_x)}
\DoxyCodeLine{539       \textcolor{keywordflow}{else}}
\DoxyCodeLine{540         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, open\_boundary\_config: "{}}//\&}
\DoxyCodeLine{541              \textcolor{stringliteral}{"{}Unable to interpret "{}}//segment\_param\_str//\textcolor{stringliteral}{"{} = "{}}//trim(segment\_str))}
\DoxyCodeLine{542 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{543 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{544 }
\DoxyCodeLine{545     \textcolor{comment}{! Moved this earlier because time\_interp\_external\_init needs to be called}}
\DoxyCodeLine{546     \textcolor{comment}{! before anything that uses time\_interp\_external (such as initialize\_segment\_data)}}
\DoxyCodeLine{547     \textcolor{keywordflow}{if} (obc\%specified\_u\_BCs\_exist\_globally .or. obc\%specified\_v\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{548       obc\%open\_u\_BCs\_exist\_globally .or. obc\%open\_v\_BCs\_exist\_globally) \textcolor{keywordflow}{then}}
\DoxyCodeLine{549       \textcolor{comment}{! Need this for ocean\_only mode boundary interpolation.}}
\DoxyCodeLine{550       \textcolor{keyword}{call }time\_interp\_external\_init()}
\DoxyCodeLine{551 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{552     \textcolor{comment}{!    if (open\_boundary\_query(OBC, needs\_ext\_seg\_data=.true.)) \&}}
\DoxyCodeLine{553  \textcolor{comment}{!   call initialize\_segment\_data(G, OBC, param\_file)}}
\DoxyCodeLine{554 }
\DoxyCodeLine{555     \textcolor{keywordflow}{if} (open\_boundary\_query(obc, apply\_open\_obc=.true.)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{556       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_RADIATION\_MAX"{}}, obc\%rx\_max, \&}
\DoxyCodeLine{557                    \textcolor{stringliteral}{"{}The maximum magnitude of the baroclinic radiation velocity (or speed of "{}}//\&}
\DoxyCodeLine{558                    \textcolor{stringliteral}{"{}characteristics), in gridpoints per timestep.  This is only "{}}//\&}
\DoxyCodeLine{559                    \textcolor{stringliteral}{"{}used if one of the open boundary segments is using Orlanski."{}}, \&}
\DoxyCodeLine{560                    units=\textcolor{stringliteral}{"{}nondim"{}}, default=1.0)}
\DoxyCodeLine{561       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_RAD\_VEL\_WT"{}}, obc\%gamma\_uv, \&}
\DoxyCodeLine{562                    \textcolor{stringliteral}{"{}The relative weighting for the baroclinic radiation "{}}//\&}
\DoxyCodeLine{563                    \textcolor{stringliteral}{"{}velocities (or speed of characteristics) at the new "{}}//\&}
\DoxyCodeLine{564                    \textcolor{stringliteral}{"{}time level (1) or the running mean (0) for velocities. "{}}//\&}
\DoxyCodeLine{565                    \textcolor{stringliteral}{"{}Valid values range from 0 to 1. This is only used if "{}}//\&}
\DoxyCodeLine{566                    \textcolor{stringliteral}{"{}one of the open boundary segments is using Orlanski."{}}, \&}
\DoxyCodeLine{567                    units=\textcolor{stringliteral}{"{}nondim"{}}, default=0.3)}
\DoxyCodeLine{568 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{569 }
\DoxyCodeLine{570     lscale\_in = 0.}
\DoxyCodeLine{571     lscale\_out = 0.}
\DoxyCodeLine{572     \textcolor{keywordflow}{if} (open\_boundary\_query(obc, apply\_open\_obc=.true.)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{573       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TRACER\_RESERVOIR\_LENGTH\_SCALE\_OUT "{}}, lscale\_out, \&}
\DoxyCodeLine{574                  \textcolor{stringliteral}{"{}An effective length scale for restoring the tracer concentration "{}}//\&}
\DoxyCodeLine{575                  \textcolor{stringliteral}{"{}at the boundaries to externally imposed values when the flow "{}}//\&}
\DoxyCodeLine{576                  \textcolor{stringliteral}{"{}is exiting the domain."{}}, units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=us\%m\_to\_L)}
\DoxyCodeLine{577 }
\DoxyCodeLine{578       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}OBC\_TRACER\_RESERVOIR\_LENGTH\_SCALE\_IN "{}}, lscale\_in, \&}
\DoxyCodeLine{579                  \textcolor{stringliteral}{"{}An effective length scale for restoring the tracer concentration "{}}//\&}
\DoxyCodeLine{580                  \textcolor{stringliteral}{"{}at the boundaries to values from the interior when the flow "{}}//\&}
\DoxyCodeLine{581                  \textcolor{stringliteral}{"{}is entering the domain."{}}, units=\textcolor{stringliteral}{"{}m"{}}, default=0.0, scale=us\%m\_to\_L)}
\DoxyCodeLine{582 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{583 }
\DoxyCodeLine{584     \textcolor{keywordflow}{if} (mask\_outside) \textcolor{keyword}{call }mask\_outside\_obcs(g, us, param\_file, obc)}
\DoxyCodeLine{585 }
\DoxyCodeLine{586     \textcolor{comment}{! All tracers are using the same restoring length scale for now, but we may want to make this}}
\DoxyCodeLine{587     \textcolor{comment}{! tracer-\/specific in the future for example, in cases where certain tracers are poorly constrained}}
\DoxyCodeLine{588     \textcolor{comment}{! by data while others are well constrained -\/ MJH.}}
\DoxyCodeLine{589     \textcolor{keywordflow}{do} l = 1, obc\%number\_of\_segments}
\DoxyCodeLine{590       obc\%segment(l)\%Tr\_InvLscale\_in = 0.0}
\DoxyCodeLine{591       \textcolor{keywordflow}{if} (lscale\_in>0.) obc\%segment(l)\%Tr\_InvLscale\_in =  1.0/lscale\_in}
\DoxyCodeLine{592       obc\%segment(l)\%Tr\_InvLscale\_out = 0.0}
\DoxyCodeLine{593       \textcolor{keywordflow}{if} (lscale\_out>0.) obc\%segment(l)\%Tr\_InvLscale\_out =  1.0/lscale\_out}
\DoxyCodeLine{594 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{595 }
\DoxyCodeLine{596     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REMAPPING\_SCHEME"{}}, remappingscheme, \&}
\DoxyCodeLine{597           \textcolor{stringliteral}{"{}This sets the reconstruction scheme used "{}}//\&}
\DoxyCodeLine{598           \textcolor{stringliteral}{"{}for vertical remapping for all variables. "{}}//\&}
\DoxyCodeLine{599           \textcolor{stringliteral}{"{}It can be one of the following schemes: \(\backslash\)n"{}}//\&}
\DoxyCodeLine{600           trim(remappingschemesdoc), default=remappingdefaultscheme,do\_not\_log=.true.)}
\DoxyCodeLine{601     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}FATAL\_CHECK\_RECONSTRUCTIONS"{}}, check\_reconstruction, \&}
\DoxyCodeLine{602           \textcolor{stringliteral}{"{}If true, cell-\/by-\/cell reconstructions are checked for "{}}//\&}
\DoxyCodeLine{603           \textcolor{stringliteral}{"{}consistency and if non-\/monotonicity or an inconsistency is "{}}//\&}
\DoxyCodeLine{604           \textcolor{stringliteral}{"{}detected then a FATAL error is issued."{}}, default=.false.,do\_not\_log=.true.)}
\DoxyCodeLine{605     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}FATAL\_CHECK\_REMAPPING"{}}, check\_remapping, \&}
\DoxyCodeLine{606           \textcolor{stringliteral}{"{}If true, the results of remapping are checked for "{}}//\&}
\DoxyCodeLine{607           \textcolor{stringliteral}{"{}conservation and new extrema and if an inconsistency is "{}}//\&}
\DoxyCodeLine{608           \textcolor{stringliteral}{"{}detected then a FATAL error is issued."{}}, default=.false.,do\_not\_log=.true.)}
\DoxyCodeLine{609     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}BRUSHCUTTER\_MODE"{}}, obc\%brushcutter\_mode, \&}
\DoxyCodeLine{610          \textcolor{stringliteral}{"{}If true, read external OBC data on the supergrid."{}}, \&}
\DoxyCodeLine{611          default=.false.)}
\DoxyCodeLine{612     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REMAP\_BOUND\_INTERMEDIATE\_VALUES"{}}, force\_bounds\_in\_subcell, \&}
\DoxyCodeLine{613           \textcolor{stringliteral}{"{}If true, the values on the intermediate grid used for remapping "{}}//\&}
\DoxyCodeLine{614           \textcolor{stringliteral}{"{}are forced to be bounded, which might not be the case due to "{}}//\&}
\DoxyCodeLine{615           \textcolor{stringliteral}{"{}round off."{}}, default=.false.,do\_not\_log=.true.)}
\DoxyCodeLine{616     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}DEFAULT\_2018\_ANSWERS"{}}, default\_2018\_answers, \&}
\DoxyCodeLine{617                  \textcolor{stringliteral}{"{}This sets the default value for the various \_2018\_ANSWERS parameters."{}}, \&}
\DoxyCodeLine{618                  default=.false.)}
\DoxyCodeLine{619     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"{}REMAPPING\_2018\_ANSWERS"{}}, answers\_2018, \&}
\DoxyCodeLine{620                  \textcolor{stringliteral}{"{}If true, use the order of arithmetic and expressions that recover the "{}}//\&}
\DoxyCodeLine{621                  \textcolor{stringliteral}{"{}answers from the end of 2018.  Otherwise, use updated and more robust "{}}//\&}
\DoxyCodeLine{622                  \textcolor{stringliteral}{"{}forms of the same expressions."{}}, default=default\_2018\_answers)}
\DoxyCodeLine{623 }
\DoxyCodeLine{624     \textcolor{keyword}{allocate}(obc\%remap\_CS)}
\DoxyCodeLine{625     \textcolor{keyword}{call }initialize\_remapping(obc\%remap\_CS, remappingscheme, boundary\_extrapolation = .false., \&}
\DoxyCodeLine{626                check\_reconstruction=check\_reconstruction, check\_remapping=check\_remapping, \&}
\DoxyCodeLine{627                force\_bounds\_in\_subcell=force\_bounds\_in\_subcell, answers\_2018=answers\_2018)}
\DoxyCodeLine{628 }
\DoxyCodeLine{629 \textcolor{keywordflow}{  endif} \textcolor{comment}{! OBC\%number\_of\_segments > 0}}
\DoxyCodeLine{630 }
\DoxyCodeLine{631     \textcolor{comment}{! Safety check}}
\DoxyCodeLine{632   \textcolor{keywordflow}{if} ((obc\%open\_u\_BCs\_exist\_globally .or. obc\%open\_v\_BCs\_exist\_globally) .and. \&}
\DoxyCodeLine{633        .not.g\%symmetric ) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{634        \textcolor{stringliteral}{"{}MOM\_open\_boundary, open\_boundary\_config: "{}}//\&}
\DoxyCodeLine{635        \textcolor{stringliteral}{"{}Symmetric memory must be used when using Flather OBCs."{}})}
\DoxyCodeLine{636   \textcolor{comment}{! Need to do this last, because it depends on time\_interp\_external\_init having already been called}}
\DoxyCodeLine{637   \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{638     \textcolor{keyword}{call }initialize\_obc\_tides(obc, param\_file)}
\DoxyCodeLine{639     \textcolor{comment}{! Tide update is done within update\_OBC\_segment\_data, so this should be true if tides are included.}}
\DoxyCodeLine{640     obc\%update\_OBC = .true.}
\DoxyCodeLine{641 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{642 }
\DoxyCodeLine{643   \textcolor{keywordflow}{if} (.not.(obc\%specified\_u\_BCs\_exist\_globally .or. obc\%specified\_v\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{644               obc\%open\_u\_BCs\_exist\_globally .or. obc\%open\_v\_BCs\_exist\_globally)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{645     \textcolor{comment}{! No open boundaries have been requested}}
\DoxyCodeLine{646     \textcolor{keyword}{call }open\_boundary\_dealloc(obc)}
\DoxyCodeLine{647 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{648 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a709a33b9e33b5689d5ca73349ed51fb6}\label{namespacemom__open__boundary_a709a33b9e33b5689d5ca73349ed51fb6}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_dealloc@{open\_boundary\_dealloc}}
\index{open\_boundary\_dealloc@{open\_boundary\_dealloc}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_dealloc()}{open\_boundary\_dealloc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+dealloc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Deallocate open boundary data. 


\begin{DoxyParams}{Parameters}
{\em obc} & Open boundary control structure \\
\hline
\end{DoxyParams}


Definition at line 1893 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1894   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer} :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1895   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{1896   \textcolor{keywordtype}{integer} :: n}
\DoxyCodeLine{1897 }
\DoxyCodeLine{1898   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1899 }
\DoxyCodeLine{1900   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{1901     segment => obc\%segment(n)}
\DoxyCodeLine{1902     \textcolor{keyword}{call }deallocate\_obc\_segment\_data(obc, segment)}
\DoxyCodeLine{1903 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1904   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%segment)) \textcolor{keyword}{deallocate}(obc\%segment)}
\DoxyCodeLine{1905   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%segnum\_u)) \textcolor{keyword}{deallocate}(obc\%segnum\_u)}
\DoxyCodeLine{1906   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%segnum\_v)) \textcolor{keyword}{deallocate}(obc\%segnum\_v)}
\DoxyCodeLine{1907   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%rx\_normal)) \textcolor{keyword}{deallocate}(obc\%rx\_normal)}
\DoxyCodeLine{1908   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%ry\_normal)) \textcolor{keyword}{deallocate}(obc\%ry\_normal)}
\DoxyCodeLine{1909   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%rx\_oblique)) \textcolor{keyword}{deallocate}(obc\%rx\_oblique)}
\DoxyCodeLine{1910   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%ry\_oblique)) \textcolor{keyword}{deallocate}(obc\%ry\_oblique)}
\DoxyCodeLine{1911   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%cff\_normal)) \textcolor{keyword}{deallocate}(obc\%cff\_normal)}
\DoxyCodeLine{1912   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_x)) \textcolor{keyword}{deallocate}(obc\%tres\_x)}
\DoxyCodeLine{1913   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_y)) \textcolor{keyword}{deallocate}(obc\%tres\_y)}
\DoxyCodeLine{1914   \textcolor{keyword}{deallocate}(obc)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_afb86d9ee7fc99dea787b88cfdb70f139}\label{namespacemom__open__boundary_afb86d9ee7fc99dea787b88cfdb70f139}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_end@{open\_boundary\_end}}
\index{open\_boundary\_end@{open\_boundary\_end}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_end()}{open\_boundary\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC }\end{DoxyParamCaption})}



Close open boundary data. 


\begin{DoxyParams}{Parameters}
{\em obc} & Open boundary control structure \\
\hline
\end{DoxyParams}


Definition at line 1918 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1919   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer} :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1920   \textcolor{keyword}{call }open\_boundary\_dealloc(obc)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a7aa6f2b520108ce761ef107557f69069}\label{namespacemom__open__boundary_a7aa6f2b520108ce761ef107557f69069}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_impose\_land\_mask@{open\_boundary\_impose\_land\_mask}}
\index{open\_boundary\_impose\_land\_mask@{open\_boundary\_impose\_land\_mask}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_impose\_land\_mask()}{open\_boundary\_impose\_land\_mask()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+impose\+\_\+land\+\_\+mask (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g)), intent(inout)}]{area\+Cu,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g)), intent(inout)}]{area\+Cv,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US }\end{DoxyParamCaption})}



Reconcile masks and open boundaries, deallocate O\+BC on P\+Es where it is not needed. Also adjust u-\/ and v-\/point cell area on specified open boundaries and mask all points outside open boundaries. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em areacu} & Area of a u-\/cell \mbox{[}L2 $\sim$$>$ m2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em areacv} & Area of a u-\/cell \mbox{[}L2 $\sim$$>$ m2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1969 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1970   \textcolor{keywordtype}{type}(ocean\_OBC\_type),              \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1971   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),            \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{1972   \textcolor{keywordtype}{type}(unit\_scale\_type),             \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1973 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: areaCu\textcolor{comment}{ !< Area of a u-\/cell [L2 \string~> m2]}}
\DoxyCodeLine{1974 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G))}, \textcolor{keywordtype}{intent(inout)} :: areaCv\textcolor{comment}{ !< Area of a u-\/cell [L2 \string~> m2]}}
\DoxyCodeLine{1975   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1976   \textcolor{keywordtype}{integer} :: i, j, n}
\DoxyCodeLine{1977   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{1978   \textcolor{keywordtype}{logical} :: any\_U, any\_V}
\DoxyCodeLine{1979 }
\DoxyCodeLine{1980   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1981 }
\DoxyCodeLine{1982   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{1983     segment=>obc\%segment(n)}
\DoxyCodeLine{1984     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{1985     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1986       \textcolor{comment}{! Sweep along u-\/segments and delete the OBC for blocked points.}}
\DoxyCodeLine{1987       \textcolor{comment}{! Also, mask all points outside.}}
\DoxyCodeLine{1988       i=segment\%HI\%IsdB}
\DoxyCodeLine{1989       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{1990         \textcolor{keywordflow}{if} (g\%mask2dCu(i,j) == 0) obc\%segnum\_u(i,j) = obc\_none}
\DoxyCodeLine{1991         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1992           g\%mask2dT(i,j) = 0}
\DoxyCodeLine{1993         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1994           g\%mask2dT(i+1,j) = 0}
\DoxyCodeLine{1995 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1996 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1997       \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{1998         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1999           g\%mask2dCv(i,j) = 0}
\DoxyCodeLine{2000         \textcolor{keywordflow}{else}}
\DoxyCodeLine{2001           g\%mask2dCv(i+1,j) = 0}
\DoxyCodeLine{2002 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2003 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2004     \textcolor{keywordflow}{else}}
\DoxyCodeLine{2005       \textcolor{comment}{! Sweep along v-\/segments and delete the OBC for blocked points.}}
\DoxyCodeLine{2006       j=segment\%HI\%JsdB}
\DoxyCodeLine{2007       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2008         \textcolor{keywordflow}{if} (g\%mask2dCv(i,j) == 0) obc\%segnum\_v(i,j) = obc\_none}
\DoxyCodeLine{2009         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2010           g\%mask2dT(i,j) = 0}
\DoxyCodeLine{2011         \textcolor{keywordflow}{else}}
\DoxyCodeLine{2012           g\%mask2dT(i,j+1) = 0}
\DoxyCodeLine{2013 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2014 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2015       \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{2016         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2017           g\%mask2dCu(i,j) = 0}
\DoxyCodeLine{2018         \textcolor{keywordflow}{else}}
\DoxyCodeLine{2019           g\%mask2dCu(i,j+1) = 0}
\DoxyCodeLine{2020 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2021 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2022 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2023 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2024 }
\DoxyCodeLine{2025   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2026     segment=>obc\%segment(n)}
\DoxyCodeLine{2027     \textcolor{keywordflow}{if} (.not. segment\%on\_pe .or. .not. segment\%specified) cycle}
\DoxyCodeLine{2028     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2029       \textcolor{comment}{! Sweep along u-\/segments and for \%specified BC points reset the u-\/point area which was masked out}}
\DoxyCodeLine{2030       i=segment\%HI\%IsdB}
\DoxyCodeLine{2031       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2032         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2033           areacu(i,j) = g\%areaT(i,j)   \textcolor{comment}{! Both of these are in [L2 \string~> m2]}}
\DoxyCodeLine{2034         \textcolor{keywordflow}{else}   \textcolor{comment}{! West}}
\DoxyCodeLine{2035           areacu(i,j) = g\%areaT(i+1,j) \textcolor{comment}{! Both of these are in [L2 \string~> m2]}}
\DoxyCodeLine{2036 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2037 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2038     \textcolor{keywordflow}{else}}
\DoxyCodeLine{2039       \textcolor{comment}{! Sweep along v-\/segments and for \%specified BC points reset the v-\/point area which was masked out}}
\DoxyCodeLine{2040       j=segment\%HI\%JsdB}
\DoxyCodeLine{2041       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2042         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2043           areacv(i,j) = g\%areaT(i,j+1) \textcolor{comment}{! Both of these are in [L2 \string~> m2]}}
\DoxyCodeLine{2044         \textcolor{keywordflow}{else}      \textcolor{comment}{! North}}
\DoxyCodeLine{2045           areacu(i,j) = g\%areaT(i,j)   \textcolor{comment}{! Both of these are in [L2 \string~> m2]}}
\DoxyCodeLine{2046 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{2047 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2048 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2049 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2050 }
\DoxyCodeLine{2051   \textcolor{comment}{! G\%mask2du will be open wherever bathymetry allows it.}}
\DoxyCodeLine{2052   \textcolor{comment}{! Bathymetry outside of the open boundary was adjusted to match}}
\DoxyCodeLine{2053   \textcolor{comment}{! the bathymetry inside so these points will be open unless the}}
\DoxyCodeLine{2054   \textcolor{comment}{! bathymetry inside the boundary was too shallow and flagged as land.}}
\DoxyCodeLine{2055   any\_u = .false.}
\DoxyCodeLine{2056   any\_v = .false.}
\DoxyCodeLine{2057   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2058     segment=>obc\%segment(n)}
\DoxyCodeLine{2059     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{2060     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2061       i=segment\%HI\%IsdB}
\DoxyCodeLine{2062       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2063         \textcolor{keywordflow}{if} (obc\%segnum\_u(i,j) /= obc\_none) any\_u = .true.}
\DoxyCodeLine{2064 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2065     \textcolor{keywordflow}{else}}
\DoxyCodeLine{2066       j=segment\%HI\%JsdB}
\DoxyCodeLine{2067       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2068         \textcolor{keywordflow}{if} (obc\%segnum\_v(i,j) /= obc\_none) any\_v = .true.}
\DoxyCodeLine{2069 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{2070 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2071 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2072 }
\DoxyCodeLine{2073   obc\%OBC\_pe = .true.}
\DoxyCodeLine{2074   \textcolor{keywordflow}{if} (.not.(any\_u .or. any\_v)) obc\%OBC\_pe = .false.}
\DoxyCodeLine{2075 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_afc301353fde1f12ef04dab751ddb7ac2}\label{namespacemom__open__boundary_afc301353fde1f12ef04dab751ddb7ac2}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_impose\_normal\_slope@{open\_boundary\_impose\_normal\_slope}}
\index{open\_boundary\_impose\_normal\_slope@{open\_boundary\_impose\_normal\_slope}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_impose\_normal\_slope()}{open\_boundary\_impose\_normal\_slope()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+impose\+\_\+normal\+\_\+slope (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g)), intent(inout)}]{depth }\end{DoxyParamCaption})}



Sets the slope of bathymetry normal to an open bounndary to zero. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em depth} & Bathymetry at h-\/points \\
\hline
\end{DoxyParams}


Definition at line 1924 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1925   \textcolor{keywordtype}{type}(ocean\_OBC\_type),             \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1926   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),           \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{1927 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))}, \textcolor{keywordtype}{intent(inout)} :: depth\textcolor{comment}{ !< Bathymetry at h-\/points}}
\DoxyCodeLine{1928   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1929   \textcolor{keywordtype}{integer} :: i, j, n}
\DoxyCodeLine{1930   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{1931 }
\DoxyCodeLine{1932   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1933 }
\DoxyCodeLine{1934   \textcolor{keywordflow}{if} (.not.(obc\%specified\_u\_BCs\_exist\_globally .or. obc\%specified\_v\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{1935               obc\%open\_u\_BCs\_exist\_globally .or. obc\%open\_v\_BCs\_exist\_globally)) \&}
\DoxyCodeLine{1936     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1937 }
\DoxyCodeLine{1938   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{1939     segment=>obc\%segment(n)}
\DoxyCodeLine{1940     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{1941     \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1942       i=segment\%HI\%IsdB}
\DoxyCodeLine{1943       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{1944         depth(i+1,j) = depth(i,j)}
\DoxyCodeLine{1945 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1946     \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1947       i=segment\%HI\%IsdB}
\DoxyCodeLine{1948       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{1949         depth(i,j) = depth(i+1,j)}
\DoxyCodeLine{1950 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1951     \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1952       j=segment\%HI\%JsdB}
\DoxyCodeLine{1953       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{1954         depth(i,j+1) = depth(i,j)}
\DoxyCodeLine{1955 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1956     \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1957       j=segment\%HI\%JsdB}
\DoxyCodeLine{1958       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{1959         depth(i,j) = depth(i,j+1)}
\DoxyCodeLine{1960 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{1961 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1962 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1963 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a53dc87c231fcaf1c99fe818956fb111e}\label{namespacemom__open__boundary_a53dc87c231fcaf1c99fe818956fb111e}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_init@{open\_boundary\_init}}
\index{open\_boundary\_init@{open\_boundary\_init}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_init()}{open\_boundary\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__restart_1_1mom__restart__cs}{mom\+\_\+restart\+\_\+cs}}), pointer}]{restart\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize open boundary control structure and do any necessary rescaling of O\+BC fields that have been read from a restart file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Container for vertical grid information \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
 & {\em restart\+\_\+csp} & Restart structure, data intent(inout) \\
\hline
\end{DoxyParams}


Definition at line 1791 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1792   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{1793   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{  !< Container for vertical grid information}}
\DoxyCodeLine{1794   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1795   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{1796   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1797   \textcolor{keywordtype}{type}(MOM\_restart\_CS),    \textcolor{keywordtype}{pointer}    :: restart\_CSp\textcolor{comment}{ !< Restart structure, data intent(inout)}}
\DoxyCodeLine{1798 }
\DoxyCodeLine{1799   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1800 \textcolor{keywordtype}{  real} :: vel2\_rescale \textcolor{comment}{! A rescaling factor for squared velocities from the representation in}}
\DoxyCodeLine{1801                        \textcolor{comment}{! a restart file to the internal representation in this run.}}
\DoxyCodeLine{1802   \textcolor{keywordtype}{integer} :: i, j, k, isd, ied, jsd, jed, nz, m}
\DoxyCodeLine{1803   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{1804   isd  = g\%isd  ; ied  = g\%ied  ; jsd  = g\%jsd  ; jed  = g\%jed ; nz = gv\%ke}
\DoxyCodeLine{1805   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{1806 }
\DoxyCodeLine{1807   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1808 }
\DoxyCodeLine{1809   id\_clock\_pass = cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean OBC halo updates)'}, grain=clock\_routine)}
\DoxyCodeLine{1810   \textcolor{keywordflow}{if} (obc\%radiation\_BCs\_exist\_globally) \textcolor{keyword}{call }pass\_vector(obc\%rx\_normal, obc\%ry\_normal, g\%Domain, \&}
\DoxyCodeLine{1811                      to\_all+scalar\_pair)}
\DoxyCodeLine{1812   \textcolor{keywordflow}{if} (obc\%oblique\_BCs\_exist\_globally) \textcolor{keyword}{call }pass\_vector(obc\%rx\_oblique, obc\%ry\_oblique, g\%Domain, \&}
\DoxyCodeLine{1813                      to\_all+scalar\_pair)}
\DoxyCodeLine{1814   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%cff\_normal)) \textcolor{keyword}{call }pass\_var(obc\%cff\_normal, g\%Domain, position=corner)}
\DoxyCodeLine{1815   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_x) .and. \textcolor{keyword}{associated}(obc\%tres\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1816     \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{1817       \textcolor{keyword}{call }pass\_vector(obc\%tres\_x(:,:,:,m), obc\%tres\_y(:,:,:,m), g\%Domain, to\_all+scalar\_pair)}
\DoxyCodeLine{1818 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1819   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(obc\%tres\_x)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1820     \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{1821       \textcolor{keyword}{call }pass\_var(obc\%tres\_x(:,:,:,m), g\%Domain, position=east\_face)}
\DoxyCodeLine{1822 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1823   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{associated}(obc\%tres\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1824     \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{1825       \textcolor{keyword}{call }pass\_var(obc\%tres\_y(:,:,:,m), g\%Domain, position=north\_face)}
\DoxyCodeLine{1826 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1827 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1828 }
\DoxyCodeLine{1829   \textcolor{comment}{! The rx\_normal and ry\_normal arrays used with radiation OBCs are currently in units of grid}}
\DoxyCodeLine{1830   \textcolor{comment}{! points per timestep, but if this were to be corrected to [L T-\/1 \string~> m s-\/1] or [T-\/1 \string~> s-\/1] to}}
\DoxyCodeLine{1831   \textcolor{comment}{! permit timesteps to change between calls to the OBC code, the following would be needed:}}
\DoxyCodeLine{1832 \textcolor{comment}{!  if ( OBC\%radiation\_BCs\_exist\_globally .and. (US\%s\_to\_T\_restart * US\%m\_to\_L\_restart /= 0.0) .and. \&}}
\DoxyCodeLine{1833 \textcolor{comment}{!       ((US\%m\_to\_L * US\%s\_to\_T\_restart) /= (US\%m\_to\_L\_restart * US\%s\_to\_T)) ) then}}
\DoxyCodeLine{1834 \textcolor{comment}{!    vel\_rescale = (US\%m\_to\_L * US\%s\_to\_T\_restart) /  (US\%m\_to\_L\_restart * US\%s\_to\_T)}}
\DoxyCodeLine{1835 \textcolor{comment}{!    if (query\_initialized(OBC\%rx\_normal, "{}rx\_normal"{}, restart\_CSp)) then}}
\DoxyCodeLine{1836 \textcolor{comment}{!      do k=1,nz ; do j=jsd,jed ; do I=IsdB,IedB}}
\DoxyCodeLine{1837 \textcolor{comment}{!        OBC\%rx\_normal(I,j,k) = vel\_rescale * OBC\%rx\_normal(I,j,k)}}
\DoxyCodeLine{1838 \textcolor{comment}{!      enddo ; enddo ; enddo}}
\DoxyCodeLine{1839 \textcolor{comment}{!    endif}}
\DoxyCodeLine{1840 \textcolor{comment}{!    if (query\_initialized(OBC\%ry\_normal, "{}ry\_normal"{}, restart\_CSp)) then}}
\DoxyCodeLine{1841 \textcolor{comment}{!      do k=1,nz ; do J=JsdB,JedB ; do i=isd,ied}}
\DoxyCodeLine{1842 \textcolor{comment}{!        OBC\%ry\_normal(i,J,k) = vel\_rescale * OBC\%ry\_normal(i,J,k)}}
\DoxyCodeLine{1843 \textcolor{comment}{!      enddo ; enddo ; enddo}}
\DoxyCodeLine{1844 \textcolor{comment}{!    endif}}
\DoxyCodeLine{1845 \textcolor{comment}{!  endif}}
\DoxyCodeLine{1846 }
\DoxyCodeLine{1847   \textcolor{comment}{! The oblique boundary condition terms have units of [L2 T-\/2 \string~> m2 s-\/2] and may need to be rescaled.}}
\DoxyCodeLine{1848   \textcolor{keywordflow}{if} ( obc\%oblique\_BCs\_exist\_globally .and. (us\%s\_to\_T\_restart * us\%m\_to\_L\_restart /= 0.0) .and. \&}
\DoxyCodeLine{1849        ((us\%m\_to\_L * us\%s\_to\_T\_restart) /= (us\%m\_to\_L\_restart * us\%s\_to\_T)) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1850     vel2\_rescale = (us\%m\_to\_L * us\%s\_to\_T\_restart)**2 /  (us\%m\_to\_L\_restart * us\%s\_to\_T)**2}
\DoxyCodeLine{1851     \textcolor{keywordflow}{if} (query\_initialized(obc\%rx\_oblique, \textcolor{stringliteral}{"{}rx\_oblique"{}}, restart\_csp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1852       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{1853         obc\%rx\_oblique(i,j,k) = vel2\_rescale * obc\%rx\_oblique(i,j,k)}
\DoxyCodeLine{1854 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1855 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1856     \textcolor{keywordflow}{if} (query\_initialized(obc\%ry\_oblique, \textcolor{stringliteral}{"{}ry\_oblique"{}}, restart\_csp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1857       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{1858         obc\%ry\_oblique(i,j,k) = vel2\_rescale * obc\%ry\_oblique(i,j,k)}
\DoxyCodeLine{1859 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1860 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1861     \textcolor{keywordflow}{if} (query\_initialized(obc\%cff\_normal, \textcolor{stringliteral}{"{}cff\_normal"{}}, restart\_csp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1862       \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{1863         obc\%cff\_normal(i,j,k) = vel2\_rescale * obc\%cff\_normal(i,j,k)}
\DoxyCodeLine{1864 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1865 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1866 \textcolor{keywordflow}{   endif}}
\DoxyCodeLine{1867 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_af55e663cc3a1f5f697e72066d75c9160}\label{namespacemom__open__boundary_af55e663cc3a1f5f697e72066d75c9160}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_query@{open\_boundary\_query}}
\index{open\_boundary\_query@{open\_boundary\_query}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_query()}{open\_boundary\_query()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+query (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{logical, intent(in), optional}]{apply\+\_\+open\+\_\+\+O\+BC,  }\item[{logical, intent(in), optional}]{apply\+\_\+specified\+\_\+\+O\+BC,  }\item[{logical, intent(in), optional}]{apply\+\_\+\+Flather\+\_\+\+O\+BC,  }\item[{logical, intent(in), optional}]{apply\+\_\+nudged\+\_\+\+O\+BC,  }\item[{logical, intent(in), optional}]{needs\+\_\+ext\+\_\+seg\+\_\+data }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure\\
\hline
\mbox{\texttt{ in}}  & {\em apply\+\_\+open\+\_\+obc} & Returns True if open\+\_\+$\ast$\+\_\+\+B\+Cs\+\_\+exist\+\_\+globally is true\\
\hline
\mbox{\texttt{ in}}  & {\em apply\+\_\+specified\+\_\+obc} & Returns True if specified\+\_\+$\ast$\+\_\+\+B\+Cs\+\_\+exist\+\_\+globally is true\\
\hline
\mbox{\texttt{ in}}  & {\em apply\+\_\+flather\+\_\+obc} & Returns True if Flather\+\_\+$\ast$\+\_\+\+B\+Cs\+\_\+exist\+\_\+globally is true\\
\hline
\mbox{\texttt{ in}}  & {\em apply\+\_\+nudged\+\_\+obc} & Returns True if nudged\+\_\+$\ast$\+\_\+\+B\+Cs\+\_\+exist\+\_\+globally is true\\
\hline
\mbox{\texttt{ in}}  & {\em needs\+\_\+ext\+\_\+seg\+\_\+data} & Returns True if external segment data needed \\
\hline
\end{DoxyParams}


Definition at line 1870 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1872   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1873   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},    \textcolor{keywordtype}{intent(in)} :: apply\_open\_OBC\textcolor{comment}{      !< Returns True if open\_*\_BCs\_exist\_globally is true}}
\DoxyCodeLine{1874   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},    \textcolor{keywordtype}{intent(in)} :: apply\_specified\_OBC\textcolor{comment}{ !< Returns True if specified\_*\_BCs\_exist\_globally is true}}
\DoxyCodeLine{1875   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},    \textcolor{keywordtype}{intent(in)} :: apply\_Flather\_OBC\textcolor{comment}{   !< Returns True if Flather\_*\_BCs\_exist\_globally is true}}
\DoxyCodeLine{1876   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},    \textcolor{keywordtype}{intent(in)} :: apply\_nudged\_OBC\textcolor{comment}{    !< Returns True if nudged\_*\_BCs\_exist\_globally is true}}
\DoxyCodeLine{1877   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},    \textcolor{keywordtype}{intent(in)} :: needs\_ext\_seg\_data\textcolor{comment}{  !< Returns True if external segment data needed}}
\DoxyCodeLine{1878   open\_boundary\_query = .false.}
\DoxyCodeLine{1879   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1880   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(apply\_open\_obc)) open\_boundary\_query = obc\%open\_u\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{1881                                                      obc\%open\_v\_BCs\_exist\_globally}
\DoxyCodeLine{1882   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(apply\_specified\_obc)) open\_boundary\_query = obc\%specified\_u\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{1883                                                           obc\%specified\_v\_BCs\_exist\_globally}
\DoxyCodeLine{1884   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(apply\_flather\_obc)) open\_boundary\_query = obc\%Flather\_u\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{1885                                                         obc\%Flather\_v\_BCs\_exist\_globally}
\DoxyCodeLine{1886   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(apply\_nudged\_obc)) open\_boundary\_query = obc\%nudged\_u\_BCs\_exist\_globally .or. \&}
\DoxyCodeLine{1887                                                        obc\%nudged\_v\_BCs\_exist\_globally}
\DoxyCodeLine{1888   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(needs\_ext\_seg\_data)) open\_boundary\_query = obc\%needs\_IO\_for\_data}
\DoxyCodeLine{1889 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_af1d4f35b2cff85617fc5766739db81de}\label{namespacemom__open__boundary_af1d4f35b2cff85617fc5766739db81de}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_register\_restarts@{open\_boundary\_register\_restarts}}
\index{open\_boundary\_register\_restarts@{open\_boundary\_register\_restarts}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_register\_restarts()}{open\_boundary\_register\_restarts()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+register\+\_\+restarts (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{HI,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), pointer}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}}), pointer}]{Reg,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__restart_1_1mom__restart__cs}{mom\+\_\+restart\+\_\+cs}}), pointer}]{restart\+\_\+\+C\+Sp,  }\item[{logical, intent(in)}]{use\+\_\+temperature }\end{DoxyParamCaption})}



Register O\+BC segment data for restarts. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em hi} & Horizontal indices \\
\hline
 & {\em gv} & Container for vertical grid information \\
\hline
 & {\em obc} & O\+BC data structure, data intent(inout) \\
\hline
 & {\em reg} & pointer to tracer registry \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
 & {\em restart\+\_\+csp} & Restart structure, data intent(inout) \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+temperature} & If true, T and S are used \\
\hline
\end{DoxyParams}


Definition at line 4940 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4942   \textcolor{keywordtype}{type}(hor\_index\_type),    \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{ !< Horizontal indices}}
\DoxyCodeLine{4943   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{pointer}    :: GV\textcolor{comment}{ !< Container for vertical grid information}}
\DoxyCodeLine{4944   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< OBC data structure, data intent(inout)}}
\DoxyCodeLine{4945   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer} :: Reg\textcolor{comment}{ !< pointer to tracer registry}}
\DoxyCodeLine{4946   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{4947   \textcolor{keywordtype}{type}(MOM\_restart\_CS),    \textcolor{keywordtype}{pointer}    :: restart\_CSp\textcolor{comment}{ !< Restart structure, data intent(inout)}}
\DoxyCodeLine{4948   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: use\_temperature\textcolor{comment}{ !< If true, T and S are used}}
\DoxyCodeLine{4949   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4950   \textcolor{keywordtype}{type}(vardesc) :: vd(2)}
\DoxyCodeLine{4951   \textcolor{keywordtype}{integer}       :: m, n}
\DoxyCodeLine{4952   \textcolor{keywordtype}{character(len=100)} :: mesg}
\DoxyCodeLine{4953   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment=>null()}
\DoxyCodeLine{4954 }
\DoxyCodeLine{4955   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \&}
\DoxyCodeLine{4956        \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}open\_boundary\_register\_restarts: Called with "{}}//\&}
\DoxyCodeLine{4957                       \textcolor{stringliteral}{"{}uninitialized OBC control structure"{}})}
\DoxyCodeLine{4958 }
\DoxyCodeLine{4959   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%rx\_normal) .or. \textcolor{keyword}{associated}(obc\%ry\_normal) .or. \&}
\DoxyCodeLine{4960       \textcolor{keyword}{associated}(obc\%rx\_oblique) .or. \textcolor{keyword}{associated}(obc\%ry\_oblique) .or. \textcolor{keyword}{associated}(obc\%cff\_normal)) \&}
\DoxyCodeLine{4961        \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}open\_boundary\_register\_restarts: Restart "{}}//\&}
\DoxyCodeLine{4962                       \textcolor{stringliteral}{"{}arrays were previously allocated"{}})}
\DoxyCodeLine{4963 }
\DoxyCodeLine{4964   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_x) .or. \textcolor{keyword}{associated}(obc\%tres\_y)) \&}
\DoxyCodeLine{4965        \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}open\_boundary\_register\_restarts: Restart "{}}//\&}
\DoxyCodeLine{4966                       \textcolor{stringliteral}{"{}arrays were previously allocated"{}})}
\DoxyCodeLine{4967 }
\DoxyCodeLine{4968   \textcolor{comment}{! *** This is a temporary work around for restarts with OBC segments.}}
\DoxyCodeLine{4969   \textcolor{comment}{! This implementation uses 3D arrays solely for restarts. We need}}
\DoxyCodeLine{4970   \textcolor{comment}{! to be able to add 2D ( x,z or y,z ) data to restarts to avoid using}}
\DoxyCodeLine{4971   \textcolor{comment}{! so much memory and disk space. ***}}
\DoxyCodeLine{4972   \textcolor{keywordflow}{if} (obc\%radiation\_BCs\_exist\_globally) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4973     \textcolor{keyword}{allocate}(obc\%rx\_normal(hi\%isdB:hi\%iedB,hi\%jsd:hi\%jed,gv\%ke))}
\DoxyCodeLine{4974     \textcolor{keyword}{allocate}(obc\%ry\_normal(hi\%isd:hi\%ied,hi\%jsdB:hi\%jedB,gv\%ke))}
\DoxyCodeLine{4975     obc\%rx\_normal(:,:,:) = 0.0}
\DoxyCodeLine{4976     obc\%ry\_normal(:,:,:) = 0.0}
\DoxyCodeLine{4977 }
\DoxyCodeLine{4978     vd(1) = var\_desc(\textcolor{stringliteral}{"{}rx\_normal"{}}, \textcolor{stringliteral}{"{}m s-\/1"{}}, \textcolor{stringliteral}{"{}Normal Phase Speed for EW radiation OBCs"{}}, \textcolor{stringliteral}{'u'}, \textcolor{stringliteral}{'L'})}
\DoxyCodeLine{4979     vd(2) = var\_desc(\textcolor{stringliteral}{"{}ry\_normal"{}}, \textcolor{stringliteral}{"{}m s-\/1"{}}, \textcolor{stringliteral}{"{}Normal Phase Speed for NS radiation OBCs"{}}, \textcolor{stringliteral}{'v'}, \textcolor{stringliteral}{'L'})}
\DoxyCodeLine{4980     \textcolor{keyword}{call }register\_restart\_pair(obc\%rx\_normal, obc\%ry\_normal, vd(1), vd(2), \&}
\DoxyCodeLine{4981         .false., restart\_csp)}
\DoxyCodeLine{4982 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4983 }
\DoxyCodeLine{4984   \textcolor{keywordflow}{if} (obc\%oblique\_BCs\_exist\_globally) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4985     \textcolor{keyword}{allocate}(obc\%rx\_oblique(hi\%isdB:hi\%iedB,hi\%jsd:hi\%jed,gv\%ke))}
\DoxyCodeLine{4986     \textcolor{keyword}{allocate}(obc\%ry\_oblique(hi\%isd:hi\%ied,hi\%jsdB:hi\%jedB,gv\%ke))}
\DoxyCodeLine{4987     obc\%rx\_oblique(:,:,:) = 0.0}
\DoxyCodeLine{4988     obc\%ry\_oblique(:,:,:) = 0.0}
\DoxyCodeLine{4989 }
\DoxyCodeLine{4990     vd(1) = var\_desc(\textcolor{stringliteral}{"{}rx\_oblique"{}}, \textcolor{stringliteral}{"{}m2 s-\/2"{}}, \textcolor{stringliteral}{"{}Radiation Speed Squared for EW oblique OBCs"{}}, \textcolor{stringliteral}{'u'}, \textcolor{stringliteral}{'L'})}
\DoxyCodeLine{4991     vd(2) = var\_desc(\textcolor{stringliteral}{"{}ry\_oblique"{}}, \textcolor{stringliteral}{"{}m2 s-\/2"{}}, \textcolor{stringliteral}{"{}Radiation Speed Squared for NS oblique OBCs"{}}, \textcolor{stringliteral}{'v'}, \textcolor{stringliteral}{'L'})}
\DoxyCodeLine{4992     \textcolor{keyword}{call }register\_restart\_pair(obc\%rx\_oblique, obc\%ry\_oblique, vd(1), vd(2), \&}
\DoxyCodeLine{4993         .false., restart\_csp)}
\DoxyCodeLine{4994 }
\DoxyCodeLine{4995     \textcolor{keyword}{allocate}(obc\%cff\_normal(hi\%IsdB:hi\%IedB,hi\%jsdB:hi\%jedB,gv\%ke))}
\DoxyCodeLine{4996     obc\%cff\_normal(:,:,:) = 0.0}
\DoxyCodeLine{4997     vd(1) = var\_desc(\textcolor{stringliteral}{"{}cff\_normal"{}}, \textcolor{stringliteral}{"{}m2 s-\/2"{}}, \textcolor{stringliteral}{"{}denominator for oblique OBCs"{}}, \textcolor{stringliteral}{'q'}, \textcolor{stringliteral}{'L'})}
\DoxyCodeLine{4998     \textcolor{keyword}{call }register\_restart\_field(obc\%cff\_normal, vd(1), .false., restart\_csp)}
\DoxyCodeLine{4999 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5000 }
\DoxyCodeLine{5001   \textcolor{keywordflow}{if} (reg\%ntr == 0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{5002   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc\%tracer\_x\_reservoirs\_used)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5003     obc\%ntr = reg\%ntr}
\DoxyCodeLine{5004     \textcolor{keyword}{allocate}(obc\%tracer\_x\_reservoirs\_used(reg\%ntr))}
\DoxyCodeLine{5005     \textcolor{keyword}{allocate}(obc\%tracer\_y\_reservoirs\_used(reg\%ntr))}
\DoxyCodeLine{5006     obc\%tracer\_x\_reservoirs\_used(:) = .false.}
\DoxyCodeLine{5007     obc\%tracer\_y\_reservoirs\_used(:) = .false.}
\DoxyCodeLine{5008     \textcolor{keyword}{call }parse\_for\_tracer\_reservoirs(obc, param\_file, use\_temperature)}
\DoxyCodeLine{5009   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5010     \textcolor{comment}{! This would be coming from user code such as DOME.}}
\DoxyCodeLine{5011     \textcolor{keywordflow}{if} (obc\%ntr /= reg\%ntr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5012 \textcolor{comment}{!        call MOM\_error(FATAL, "{}open\_boundary\_regiser\_restarts: Inconsistent value for ntr"{})}}
\DoxyCodeLine{5013       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}Inconsistent values for ntr "{}, I8,"{} and "{},I8,"{}."{})'}) obc\%ntr, reg\%ntr}
\DoxyCodeLine{5014       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{'open\_boundary\_register\_restarts: '}//mesg)}
\DoxyCodeLine{5015 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{5016 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5017 }
\DoxyCodeLine{5018   \textcolor{comment}{! Still painfully inefficient, now in four dimensions.}}
\DoxyCodeLine{5019   \textcolor{keywordflow}{if} (any(obc\%tracer\_x\_reservoirs\_used)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5020     \textcolor{keyword}{allocate}(obc\%tres\_x(hi\%isdB:hi\%iedB,hi\%jsd:hi\%jed,gv\%ke,obc\%ntr))}
\DoxyCodeLine{5021     obc\%tres\_x(:,:,:,:) = 0.0}
\DoxyCodeLine{5022     \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{5023       \textcolor{keywordflow}{if} (obc\%tracer\_x\_reservoirs\_used(m)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5024         \textcolor{keywordflow}{if} (modulo(hi\%turns, 2) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5025           \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}tres\_y\_"{},I3.3)'}) m}
\DoxyCodeLine{5026           vd(1) = var\_desc(mesg,\textcolor{stringliteral}{"{}Conc"{}}, \textcolor{stringliteral}{"{}Tracer concentration for NS OBCs"{}},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'L'})}
\DoxyCodeLine{5027           \textcolor{keyword}{call }register\_restart\_field(obc\%tres\_x(:,:,:,m), vd(1), .false., restart\_csp)}
\DoxyCodeLine{5028         \textcolor{keywordflow}{else}}
\DoxyCodeLine{5029           \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}tres\_x\_"{},I3.3)'}) m}
\DoxyCodeLine{5030           vd(1) = var\_desc(mesg,\textcolor{stringliteral}{"{}Conc"{}}, \textcolor{stringliteral}{"{}Tracer concentration for EW OBCs"{}},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'L'})}
\DoxyCodeLine{5031           \textcolor{keyword}{call }register\_restart\_field(obc\%tres\_x(:,:,:,m), vd(1), .false., restart\_csp)}
\DoxyCodeLine{5032 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{5033 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{5034 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5035 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5036   \textcolor{keywordflow}{if} (any(obc\%tracer\_y\_reservoirs\_used)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5037     \textcolor{keyword}{allocate}(obc\%tres\_y(hi\%isd:hi\%ied,hi\%jsdB:hi\%jedB,gv\%ke,obc\%ntr))}
\DoxyCodeLine{5038     obc\%tres\_y(:,:,:,:) = 0.0}
\DoxyCodeLine{5039     \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{5040       \textcolor{keywordflow}{if} (obc\%tracer\_y\_reservoirs\_used(m)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5041         \textcolor{keywordflow}{if} (modulo(hi\%turns, 2) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5042           \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}tres\_x\_"{},I3.3)'}) m}
\DoxyCodeLine{5043           vd(1) = var\_desc(mesg,\textcolor{stringliteral}{"{}Conc"{}}, \textcolor{stringliteral}{"{}Tracer concentration for EW OBCs"{}},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'L'})}
\DoxyCodeLine{5044           \textcolor{keyword}{call }register\_restart\_field(obc\%tres\_y(:,:,:,m), vd(1), .false., restart\_csp)}
\DoxyCodeLine{5045         \textcolor{keywordflow}{else}}
\DoxyCodeLine{5046           \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}tres\_y\_"{},I3.3)'}) m}
\DoxyCodeLine{5047           vd(1) = var\_desc(mesg,\textcolor{stringliteral}{"{}Conc"{}}, \textcolor{stringliteral}{"{}Tracer concentration for NS OBCs"{}},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'L'})}
\DoxyCodeLine{5048           \textcolor{keyword}{call }register\_restart\_field(obc\%tres\_y(:,:,:,m), vd(1), .false., restart\_csp)}
\DoxyCodeLine{5049 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{5050 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{5051 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{5052 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a4123d11abdb141b21a4d52a0c43c4adb}\label{namespacemom__open__boundary_a4123d11abdb141b21a4d52a0c43c4adb}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_test\_extern\_h@{open\_boundary\_test\_extern\_h}}
\index{open\_boundary\_test\_extern\_h@{open\_boundary\_test\_extern\_h}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_test\_extern\_h()}{open\_boundary\_test\_extern\_h()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+test\+\_\+extern\+\_\+h (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  gv \%ke), intent(inout)}]{h }\end{DoxyParamCaption})}



Set thicknesses outside of open boundaries to silly values (used for checking the interior state is independent of values outside of the domain). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 3687 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3688   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{3689   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !<  Ocean vertical grid structure}}
\DoxyCodeLine{3690   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{3691 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(GV))},\textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{3692   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3693 \textcolor{keywordtype}{  real} :: silly\_h  \textcolor{comment}{! A silly thickness for testing [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{3694   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{3695 }
\DoxyCodeLine{3696   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3697 }
\DoxyCodeLine{3698   silly\_h = gv\%Z\_to\_H*obc\%silly\_h}
\DoxyCodeLine{3699 }
\DoxyCodeLine{3700   \textcolor{keywordflow}{do} n = 1, obc\%number\_of\_segments}
\DoxyCodeLine{3701     \textcolor{keywordflow}{do} k = 1, gv\%ke}
\DoxyCodeLine{3702       \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3703         j = obc\%segment(n)\%HI\%JsdB}
\DoxyCodeLine{3704         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3705           \textcolor{keywordflow}{do} i = obc\%segment(n)\%HI\%isd, obc\%segment(n)\%HI\%ied}
\DoxyCodeLine{3706             h(i,j+1,k) = silly\_h}
\DoxyCodeLine{3707 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3708         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3709           \textcolor{keywordflow}{do} i = obc\%segment(n)\%HI\%isd, obc\%segment(n)\%HI\%ied}
\DoxyCodeLine{3710             h(i,j,k) = silly\_h}
\DoxyCodeLine{3711 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3712 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3713       \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3714         i = obc\%segment(n)\%HI\%IsdB}
\DoxyCodeLine{3715         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3716           \textcolor{keywordflow}{do} j = obc\%segment(n)\%HI\%jsd, obc\%segment(n)\%HI\%jed}
\DoxyCodeLine{3717             h(i+1,j,k) = silly\_h}
\DoxyCodeLine{3718 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3719         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3720           \textcolor{keywordflow}{do} j = obc\%segment(n)\%HI\%jsd, obc\%segment(n)\%HI\%jed}
\DoxyCodeLine{3721             h(i,j,k) = silly\_h}
\DoxyCodeLine{3722 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3723 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3724 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3725 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{3726 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3727 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a556977a2754fab17e837a8fba75cd9ee}\label{namespacemom__open__boundary_a556977a2754fab17e837a8fba75cd9ee}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_test\_extern\_uv@{open\_boundary\_test\_extern\_uv}}
\index{open\_boundary\_test\_extern\_uv@{open\_boundary\_test\_extern\_uv}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_test\_extern\_uv()}{open\_boundary\_test\_extern\_uv()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+test\+\_\+extern\+\_\+uv (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed,  g \%ke), intent(inout)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb,  g \%ke), intent(inout)}]{v }\end{DoxyParamCaption})}



Set tangential velocities outside of open boundaries to silly values (used for checking the interior state is independent of values outside of the domain). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 3644 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3645   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{3646   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{3647 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G), SZK\_(G))},\textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{ !< Zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3648 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G), SZK\_(G))},\textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{ !< Meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{3649   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3650   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{3651 }
\DoxyCodeLine{3652   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3653 }
\DoxyCodeLine{3654   \textcolor{keywordflow}{do} n = 1, obc\%number\_of\_segments}
\DoxyCodeLine{3655     \textcolor{keywordflow}{do} k = 1, g\%ke}
\DoxyCodeLine{3656       \textcolor{keywordflow}{if} (obc\%segment(n)\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3657         j = obc\%segment(n)\%HI\%JsdB}
\DoxyCodeLine{3658         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3659           \textcolor{keywordflow}{do} i = obc\%segment(n)\%HI\%IsdB, obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{3660             u(i,j+1,k) = obc\%silly\_u}
\DoxyCodeLine{3661 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3662         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3663           \textcolor{keywordflow}{do} i = obc\%segment(n)\%HI\%IsdB, obc\%segment(n)\%HI\%IedB}
\DoxyCodeLine{3664             u(i,j,k) = obc\%silly\_u}
\DoxyCodeLine{3665 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3666 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3667       \textcolor{keywordflow}{elseif} (obc\%segment(n)\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3668         i = obc\%segment(n)\%HI\%IsdB}
\DoxyCodeLine{3669         \textcolor{keywordflow}{if} (obc\%segment(n)\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3670           \textcolor{keywordflow}{do} j = obc\%segment(n)\%HI\%JsdB, obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{3671             v(i+1,j,k) = obc\%silly\_u}
\DoxyCodeLine{3672 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3673         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3674           \textcolor{keywordflow}{do} j = obc\%segment(n)\%HI\%JsdB, obc\%segment(n)\%HI\%JedB}
\DoxyCodeLine{3675             v(i,j,k) = obc\%silly\_u}
\DoxyCodeLine{3676 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{3677 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3678 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3679 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{3680 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3681 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a9d48e6925d93fa98cbf5bb73903f94be}\label{namespacemom__open__boundary_a9d48e6925d93fa98cbf5bb73903f94be}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!open\_boundary\_zero\_normal\_flow@{open\_boundary\_zero\_normal\_flow}}
\index{open\_boundary\_zero\_normal\_flow@{open\_boundary\_zero\_normal\_flow}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{open\_boundary\_zero\_normal\_flow()}{open\_boundary\_zero\_normal\_flow()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::open\+\_\+boundary\+\_\+zero\+\_\+normal\+\_\+flow (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v }\end{DoxyParamCaption})}



Applies zero values to 3d u,v fields on O\+BC segments. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & u field to update on open boundaries \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & v field to update on open boundaries \\
\hline
\end{DoxyParams}


Definition at line 3264 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3265   \textcolor{comment}{! Arguments}}
\DoxyCodeLine{3266   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{3267   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{3268 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{   !< u field to update on open boundaries}}
\DoxyCodeLine{3269 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{   !< v field to update on open boundaries}}
\DoxyCodeLine{3270   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3271   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{3272   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{3273 }
\DoxyCodeLine{3274   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return} \textcolor{comment}{! Bail out if OBC is not available}}
\DoxyCodeLine{3275 }
\DoxyCodeLine{3276   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{3277     segment => obc\%segment(n)}
\DoxyCodeLine{3278     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3279       cycle}
\DoxyCodeLine{3280     \textcolor{keywordflow}{elseif} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3281       i=segment\%HI\%IsdB}
\DoxyCodeLine{3282       \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{3283         u(i,j,k) = 0.}
\DoxyCodeLine{3284 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3285     \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3286       j=segment\%HI\%JsdB}
\DoxyCodeLine{3287       \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{3288         v(i,j,k) = 0.}
\DoxyCodeLine{3289 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3290 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3291 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3292 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a2e2dbab2a3e23eb9848aba473f635cec}\label{namespacemom__open__boundary_a2e2dbab2a3e23eb9848aba473f635cec}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!parse\_for\_tracer\_reservoirs@{parse\_for\_tracer\_reservoirs}}
\index{parse\_for\_tracer\_reservoirs@{parse\_for\_tracer\_reservoirs}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{parse\_for\_tracer\_reservoirs()}{parse\_for\_tracer\_reservoirs()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::parse\+\_\+for\+\_\+tracer\+\_\+reservoirs (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(inout)}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF,  }\item[{logical, intent(in)}]{use\+\_\+temperature }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse all the O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA strings again to see which need tracer reservoirs (all pes need to know). 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & Parameter file handle \\
\hline
\mbox{\texttt{ in}}  & {\em use\+\_\+temperature} & If true, T and S are used \\
\hline
\end{DoxyParams}


Definition at line 1642 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1643   \textcolor{keywordtype}{type}(ocean\_OBC\_type),   \textcolor{keywordtype}{intent(inout)} :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1644   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{  !< Parameter file handle}}
\DoxyCodeLine{1645   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: use\_temperature\textcolor{comment}{ !< If true, T and S are used}}
\DoxyCodeLine{1646 }
\DoxyCodeLine{1647   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1648   \textcolor{keywordtype}{integer} :: n,m,num\_fields}
\DoxyCodeLine{1649   \textcolor{keywordtype}{character(len=1024)} :: segstr}
\DoxyCodeLine{1650   \textcolor{keywordtype}{character(len=256)} :: filename}
\DoxyCodeLine{1651   \textcolor{keywordtype}{character(len=20)}  :: segnam, suffix}
\DoxyCodeLine{1652   \textcolor{keywordtype}{character(len=32)}  :: varnam, fieldname}
\DoxyCodeLine{1653 \textcolor{keywordtype}{  real}               :: value}
\DoxyCodeLine{1654   \textcolor{keywordtype}{character(len=32)}, \textcolor{keywordtype}{dimension(MAX\_OBC\_FIELDS)} :: fields  \textcolor{comment}{! segment field names}}
\DoxyCodeLine{1655   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{1656   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{1657 }
\DoxyCodeLine{1658   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{1659     segment => obc\%segment(n)}
\DoxyCodeLine{1660     \textcolor{keyword}{write}(segnam,\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3,'\_DATA')"{}}) n}
\DoxyCodeLine{1661     \textcolor{keyword}{write}(suffix,\textcolor{stringliteral}{"{}('\_segment\_',i3.3)"{}}) n}
\DoxyCodeLine{1662     \textcolor{comment}{! Clear out any old values}}
\DoxyCodeLine{1663     segstr = \textcolor{stringliteral}{''}}
\DoxyCodeLine{1664     \textcolor{keyword}{call }get\_param(pf, mdl, segnam, segstr)}
\DoxyCodeLine{1665     \textcolor{keywordflow}{if} (segstr == \textcolor{stringliteral}{''}) cycle}
\DoxyCodeLine{1666 }
\DoxyCodeLine{1667     \textcolor{keyword}{call }parse\_segment\_manifest\_str(trim(segstr), num\_fields, fields)}
\DoxyCodeLine{1668     \textcolor{keywordflow}{if} (num\_fields == 0) cycle}
\DoxyCodeLine{1669 }
\DoxyCodeLine{1670     \textcolor{comment}{! At this point, just search for TEMP and SALT as tracers 1 and 2.}}
\DoxyCodeLine{1671     \textcolor{keywordflow}{do} m=1,num\_fields}
\DoxyCodeLine{1672       \textcolor{keyword}{call }parse\_segment\_data\_str(trim(segstr), m, trim(fields(m)), \&}
\DoxyCodeLine{1673           \textcolor{keywordtype}{value}, filename, fieldname)}
\DoxyCodeLine{1674       \textcolor{keywordflow}{if} (trim(filename) /= \textcolor{stringliteral}{'none'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1675         \textcolor{keywordflow}{if} (fields(m) == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1676           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W\_2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1677             obc\%tracer\_x\_reservoirs\_used(1) = .true.}
\DoxyCodeLine{1678           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1679             obc\%tracer\_y\_reservoirs\_used(1) = .true.}
\DoxyCodeLine{1680 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1681 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1682         \textcolor{keywordflow}{if} (fields(m) == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1683           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W\_2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1684             obc\%tracer\_x\_reservoirs\_used(2) = .true.}
\DoxyCodeLine{1685           \textcolor{keywordflow}{else}}
\DoxyCodeLine{1686             obc\%tracer\_y\_reservoirs\_used(2) = .true.}
\DoxyCodeLine{1687 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{1688 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1689 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1690 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1691     \textcolor{comment}{! Alternately, set first two to true if use\_temperature is true}}
\DoxyCodeLine{1692     \textcolor{keywordflow}{if} (use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1693       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W\_2) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1694         obc\%tracer\_x\_reservoirs\_used(1) = .true.}
\DoxyCodeLine{1695         obc\%tracer\_x\_reservoirs\_used(2) = .true.}
\DoxyCodeLine{1696       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1697         obc\%tracer\_y\_reservoirs\_used(1) = .true.}
\DoxyCodeLine{1698         obc\%tracer\_y\_reservoirs\_used(2) = .true.}
\DoxyCodeLine{1699 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1700 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1701 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1702 }
\DoxyCodeLine{1703   \textcolor{keywordflow}{return}}
\DoxyCodeLine{1704 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_ae97f243936ebbcd30c8cfe91d41729c4}\label{namespacemom__open__boundary_ae97f243936ebbcd30c8cfe91d41729c4}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!parse\_segment\_data\_str@{parse\_segment\_data\_str}}
\index{parse\_segment\_data\_str@{parse\_segment\_data\_str}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{parse\_segment\_data\_str()}{parse\_segment\_data\_str()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::parse\+\_\+segment\+\_\+data\+\_\+str (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{integer, intent(in)}]{idx,  }\item[{character(len=$\ast$), intent(in)}]{var,  }\item[{real, intent(out), optional}]{value,  }\item[{character(len=$\ast$), intent(out)}]{filename,  }\item[{character(len=$\ast$), intent(out)}]{fieldname }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+V\+A\+R1=file\+:foo1.\+nc(varnam1),\+V\+A\+R2=file\+:foo2.\+nc(varnam2),...\char`\"{} \\
\hline
\mbox{\texttt{ in}}  & {\em idx} & Index of segment\+\_\+str record \\
\hline
\mbox{\texttt{ in}}  & {\em var} & The name of the variable for which parameters are needed \\
\hline
\mbox{\texttt{ out}}  & {\em filename} & The name of the input file if using \char`\"{}file\char`\"{} method \\
\hline
\mbox{\texttt{ out}}  & {\em fieldname} & The name of the variable in the input file if using \char`\"{}file\char`\"{} method \\
\hline
\mbox{\texttt{ out}}  & {\em value} & A constant value if using the \char`\"{}value\char`\"{} method \\
\hline
\end{DoxyParams}


Definition at line 1595 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1596   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: segment\_str\textcolor{comment}{   !< A string in form of}}
\DoxyCodeLine{1597 \textcolor{comment}{      !! "{}VAR1=file:foo1.nc(varnam1),VAR2=file:foo2.nc(varnam2),..."{}}}
\DoxyCodeLine{1598   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: idx\textcolor{comment}{                    !< Index of segment\_str record}}
\DoxyCodeLine{1599   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: var\textcolor{comment}{           !< The name of the variable for which parameters are needed}}
\DoxyCodeLine{1600   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(out)} :: filename\textcolor{comment}{     !< The name of the input file if using "{}file"{} method}}
\DoxyCodeLine{1601   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(out)} :: fieldname\textcolor{comment}{    !< The name of the variable in the input file if using}}
\DoxyCodeLine{1602 \textcolor{comment}{                                                !! "{}file"{} method}}
\DoxyCodeLine{1603 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)}  :: \textcolor{keywordtype}{value}\textcolor{comment}{         !< A constant value if using the "{}value"{} method}}
\DoxyCodeLine{1604 }
\DoxyCodeLine{1605   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1606   \textcolor{keywordtype}{character(len=128)} :: word1, word2, word3, method}
\DoxyCodeLine{1607   \textcolor{keywordtype}{integer} :: lword}
\DoxyCodeLine{1608 }
\DoxyCodeLine{1609   \textcolor{comment}{! Process first word which will start with the fieldname}}
\DoxyCodeLine{1610   word3 = extract\_word(segment\_str, \textcolor{stringliteral}{','}, idx)}
\DoxyCodeLine{1611   word1 = extract\_word(word3, \textcolor{stringliteral}{':'}, 1)}
\DoxyCodeLine{1612   \textcolor{comment}{!if (trim(word1) == '') exit}}
\DoxyCodeLine{1613   word2 = extract\_word(word1, \textcolor{stringliteral}{'='}, 1)}
\DoxyCodeLine{1614   \textcolor{keywordflow}{if} (trim(word2) == trim(var)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1615     method = trim(extract\_word(word1, \textcolor{stringliteral}{'='}, 2))}
\DoxyCodeLine{1616     lword = len\_trim(method)}
\DoxyCodeLine{1617     \textcolor{keywordflow}{if} (method(lword-\/3:lword) == \textcolor{stringliteral}{'file'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1618       \textcolor{comment}{! raise an error id filename/fieldname not in argument list}}
\DoxyCodeLine{1619       word1 = extract\_word(word3, \textcolor{stringliteral}{':'}, 2)}
\DoxyCodeLine{1620       filename = extract\_word(word1, \textcolor{stringliteral}{'('}, 1)}
\DoxyCodeLine{1621       fieldname = extract\_word(word1, \textcolor{stringliteral}{'('}, 2)}
\DoxyCodeLine{1622       lword = len\_trim(fieldname)}
\DoxyCodeLine{1623       fieldname = fieldname(1:lword-\/1)  \textcolor{comment}{! remove trailing parenth}}
\DoxyCodeLine{1624       \textcolor{keywordtype}{value} = -\/999.}
\DoxyCodeLine{1625     \textcolor{keywordflow}{elseif} (method(lword-\/4:lword) == \textcolor{stringliteral}{'value'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1626       filename = \textcolor{stringliteral}{'none'}}
\DoxyCodeLine{1627       fieldname = \textcolor{stringliteral}{'none'}}
\DoxyCodeLine{1628       word1 = extract\_word(word3, \textcolor{stringliteral}{':'}, 2)}
\DoxyCodeLine{1629       lword = len\_trim(word1)}
\DoxyCodeLine{1630       \textcolor{keyword}{read}(word1(1:lword), *, \textcolor{keyword}{end}=986, err=987) value}
\DoxyCodeLine{1631 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1632 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1633 }
\DoxyCodeLine{1634   \textcolor{keywordflow}{return}}
\DoxyCodeLine{1635 986 \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'End of record while parsing segment data specification! '}//trim(segment\_str))}
\DoxyCodeLine{1636 987 \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'Error while parsing segment data specification! '}//trim(segment\_str))}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a69848c26ddd38fe0f619311fa518313f}\label{namespacemom__open__boundary_a69848c26ddd38fe0f619311fa518313f}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!parse\_segment\_manifest\_str@{parse\_segment\_manifest\_str}}
\index{parse\_segment\_manifest\_str@{parse\_segment\_manifest\_str}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{parse\_segment\_manifest\_str()}{parse\_segment\_manifest\_str()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::parse\+\_\+segment\+\_\+manifest\+\_\+str (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{integer, intent(out)}]{num\+\_\+fields,  }\item[{character(len=$\ast$), dimension(\mbox{\hyperlink{namespacemom__open__boundary_a6997b7b50a4afe32b14fd61ba858254f}{max\+\_\+obc\+\_\+fields}}), intent(out)}]{fields }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+D\+A\+TA string and determine its fields. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+V\+A\+R1=file\+:foo1.\+nc(varnam1),\+V\+A\+R2=file\+:foo2.\+nc(varnam2),...\char`\"{} \\
\hline
\mbox{\texttt{ out}}  & {\em num\+\_\+fields} & The number of fields in the segment data \\
\hline
\mbox{\texttt{ out}}  & {\em fields} & List of fieldnames for each segment \\
\hline
\end{DoxyParams}


Definition at line 1573 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1574   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: segment\_str\textcolor{comment}{   !< A string in form of}}
\DoxyCodeLine{1575 \textcolor{comment}{                                        !< "{}VAR1=file:foo1.nc(varnam1),VAR2=file:foo2.nc(varnam2),..."{}}}
\DoxyCodeLine{1576   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)} :: num\_fields\textcolor{comment}{    !< The number of fields in the segment data}}
\DoxyCodeLine{1577   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{dimension(MAX\_OBC\_FIELDS)}, \textcolor{keywordtype}{intent(out)} :: fields}
\DoxyCodeLine{1578                                         \textcolor{comment}{!< List of fieldnames for each segment}}
\DoxyCodeLine{1579 }
\DoxyCodeLine{1580   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1581   \textcolor{keywordtype}{character(len=128)} :: word1, word2}
\DoxyCodeLine{1582 }
\DoxyCodeLine{1583   num\_fields = 0}
\DoxyCodeLine{1584   \textcolor{keywordflow}{do}}
\DoxyCodeLine{1585     word1 = extract\_word(segment\_str, \textcolor{stringliteral}{','}, num\_fields+1)}
\DoxyCodeLine{1586     \textcolor{keywordflow}{if} (trim(word1) == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1587     num\_fields = num\_fields + 1}
\DoxyCodeLine{1588     word2 = extract\_word(word1, \textcolor{stringliteral}{'='}, 1)}
\DoxyCodeLine{1589     fields(num\_fields) = trim(word2)}
\DoxyCodeLine{1590 \textcolor{keywordflow}{  enddo}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a349df847b304948d5b98352ddfd7bf8d}\label{namespacemom__open__boundary_a349df847b304948d5b98352ddfd7bf8d}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!parse\_segment\_param\_real@{parse\_segment\_param\_real}}
\index{parse\_segment\_param\_real@{parse\_segment\_param\_real}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{parse\_segment\_param\_real()}{parse\_segment\_param\_real()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::parse\+\_\+segment\+\_\+param\+\_\+real (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{character(len=$\ast$), intent(in)}]{var,  }\item[{real, intent(out)}]{param\+\_\+value,  }\item[{logical, intent(in), optional}]{debug }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\+\_\+\+P\+A\+R\+A\+MS string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+V\+A\+R1=file\+:foo1.\+nc(varnam1),\+V\+A\+R2=file\+:foo2.\+nc(varnam2),...\char`\"{} \\
\hline
\mbox{\texttt{ in}}  & {\em var} & The name of the variable for which parameters are needed \\
\hline
\mbox{\texttt{ out}}  & {\em param\+\_\+value} & The value of the parameter \\
\hline
\mbox{\texttt{ in}}  & {\em debug} & If present and true, write verbose debugging messages \\
\hline
\end{DoxyParams}


Definition at line 1708 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1709    \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)}  :: segment\_str\textcolor{comment}{ !< A string in form of}}
\DoxyCodeLine{1710 \textcolor{comment}{                                                 !! "{}VAR1=file:foo1.nc(varnam1),VAR2=file:foo2.nc(varnam2),..."{}}}
\DoxyCodeLine{1711    \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)}  :: var\textcolor{comment}{         !< The name of the variable for which parameters are needed}}
\DoxyCodeLine{1712 \textcolor{keywordtype}{   real},              \textcolor{keywordtype}{intent(out)} :: param\_value\textcolor{comment}{ !< The value of the parameter}}
\DoxyCodeLine{1713    \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: debug\textcolor{comment}{       !< If present and true, write verbose debugging messages}}
\DoxyCodeLine{1714    \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1715    \textcolor{keywordtype}{character(len=128)} :: word1, word2, word3, method}
\DoxyCodeLine{1716    \textcolor{keywordtype}{integer} :: lword, nfields, n, m}
\DoxyCodeLine{1717    \textcolor{keywordtype}{logical} :: continue,dbg}
\DoxyCodeLine{1718    \textcolor{keywordtype}{character(len=32)}, \textcolor{keywordtype}{dimension(MAX\_OBC\_FIELDS)} :: flds}
\DoxyCodeLine{1719 }
\DoxyCodeLine{1720    nfields=0}
\DoxyCodeLine{1721    continue=.true.}
\DoxyCodeLine{1722    dbg=.false.}
\DoxyCodeLine{1723    \textcolor{keywordflow}{if} (\textcolor{keyword}{PRESENT}(debug)) dbg=debug}
\DoxyCodeLine{1724 }
\DoxyCodeLine{1725    \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (continue)}
\DoxyCodeLine{1726       word1 = extract\_word(segment\_str,\textcolor{stringliteral}{','},nfields+1)}
\DoxyCodeLine{1727       \textcolor{keywordflow}{if} (trim(word1) == \textcolor{stringliteral}{''}) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1728       nfields=nfields+1}
\DoxyCodeLine{1729       word2 = extract\_word(word1,\textcolor{stringliteral}{'='},1)}
\DoxyCodeLine{1730       flds(nfields) = trim(word2)}
\DoxyCodeLine{1731 \textcolor{keywordflow}{   enddo}}
\DoxyCodeLine{1732 }
\DoxyCodeLine{1733    \textcolor{comment}{! if (PRESENT(fields)) then}}
\DoxyCodeLine{1734    \textcolor{comment}{!   do n=1,nfields}}
\DoxyCodeLine{1735    \textcolor{comment}{!     fields(n) = flds(n)}}
\DoxyCodeLine{1736    \textcolor{comment}{!   enddo}}
\DoxyCodeLine{1737    \textcolor{comment}{! endif}}
\DoxyCodeLine{1738 }
\DoxyCodeLine{1739    \textcolor{comment}{! if (PRESENT(num\_fields)) then}}
\DoxyCodeLine{1740    \textcolor{comment}{!    num\_fields=nfields}}
\DoxyCodeLine{1741    \textcolor{comment}{!    return}}
\DoxyCodeLine{1742    \textcolor{comment}{! endif}}
\DoxyCodeLine{1743 }
\DoxyCodeLine{1744    m=0}
\DoxyCodeLine{1745 \textcolor{comment}{!   if (PRESENT(var)) then}}
\DoxyCodeLine{1746      \textcolor{keywordflow}{do} n=1,nfields}
\DoxyCodeLine{1747        \textcolor{keywordflow}{if} (trim(var)==trim(flds(n))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1748           m=n}
\DoxyCodeLine{1749           \textcolor{keywordflow}{exit}}
\DoxyCodeLine{1750 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{1751 \textcolor{keywordflow}{     enddo}}
\DoxyCodeLine{1752      \textcolor{keywordflow}{if} (m==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1753         \textcolor{keyword}{call }abort()}
\DoxyCodeLine{1754 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{1755 }
\DoxyCodeLine{1756     \textcolor{comment}{! Process first word which will start with the fieldname}}
\DoxyCodeLine{1757      word3 = extract\_word(segment\_str,\textcolor{stringliteral}{','},m)}
\DoxyCodeLine{1758 \textcolor{comment}{!     word1 = extract\_word(word3,':',1)}}
\DoxyCodeLine{1759 \textcolor{comment}{!     if (trim(word1) == '') exit}}
\DoxyCodeLine{1760      word2 = extract\_word(word1,\textcolor{stringliteral}{'='},1)}
\DoxyCodeLine{1761      \textcolor{keywordflow}{if} (trim(word2) == trim(var)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1762         method=trim(extract\_word(word1,\textcolor{stringliteral}{'='},2))}
\DoxyCodeLine{1763         lword=len\_trim(method)}
\DoxyCodeLine{1764         \textcolor{keyword}{read}(method(1:lword),*,err=987) param\_value}
\DoxyCodeLine{1765         \textcolor{comment}{! if (method(lword-\/3:lword) == 'file') then}}
\DoxyCodeLine{1766         \textcolor{comment}{!    ! raise an error id filename/fieldname not in argument list}}
\DoxyCodeLine{1767         \textcolor{comment}{!    word1 = extract\_word(word3,':',2)}}
\DoxyCodeLine{1768         \textcolor{comment}{!    filenam = extract\_word(word1,'(',1)}}
\DoxyCodeLine{1769         \textcolor{comment}{!    fieldnam = extract\_word(word1,'(',2)}}
\DoxyCodeLine{1770         \textcolor{comment}{!    lword=len\_trim(fieldnam)}}
\DoxyCodeLine{1771         \textcolor{comment}{!    fieldnam = fieldnam(1:lword-\/1)  ! remove trailing parenth}}
\DoxyCodeLine{1772         \textcolor{comment}{!    value=-\/999.}}
\DoxyCodeLine{1773         \textcolor{comment}{! elseif (method(lword-\/4:lword) == 'value') then}}
\DoxyCodeLine{1774         \textcolor{comment}{!    filenam = 'none'}}
\DoxyCodeLine{1775         \textcolor{comment}{!    fieldnam = 'none'}}
\DoxyCodeLine{1776         \textcolor{comment}{!    word1 = extract\_word(word3,':',2)}}
\DoxyCodeLine{1777         \textcolor{comment}{!    lword=len\_trim(word1)}}
\DoxyCodeLine{1778         \textcolor{comment}{!    read(word1(1:lword),*,end=986,err=987) value}}
\DoxyCodeLine{1779         \textcolor{comment}{! endif}}
\DoxyCodeLine{1780 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1781 \textcolor{comment}{!    endif}}
\DoxyCodeLine{1782 }
\DoxyCodeLine{1783    \textcolor{keywordflow}{return}}
\DoxyCodeLine{1784  986 \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'End of record while parsing segment data specification! '}//trim(segment\_str))}
\DoxyCodeLine{1785  987 \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'Error while parsing segment parameter specification! '}//trim(segment\_str))}
\DoxyCodeLine{1786 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a0eb361009a2dddf3ad9a24d0d7223898}\label{namespacemom__open__boundary_a0eb361009a2dddf3ad9a24d0d7223898}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!parse\_segment\_str@{parse\_segment\_str}}
\index{parse\_segment\_str@{parse\_segment\_str}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{parse\_segment\_str()}{parse\_segment\_str()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::parse\+\_\+segment\+\_\+str (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{ni\+\_\+global,  }\item[{integer, intent(in)}]{nj\+\_\+global,  }\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{integer, intent(out)}]{l,  }\item[{integer, intent(out)}]{m,  }\item[{integer, intent(out)}]{n,  }\item[{character(len=$\ast$), dimension(\+:), intent(out)}]{action\+\_\+str,  }\item[{logical, intent(in)}]{reentrant }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ni\+\_\+global} & Number of h-\/points in zonal direction \\
\hline
\mbox{\texttt{ in}}  & {\em nj\+\_\+global} & Number of h-\/points in meridional direction \\
\hline
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+I=l,\+J=m\+:n,string\char`\"{} or \char`\"{}\+J=l,\+I=m,n,string\char`\"{} \\
\hline
\mbox{\texttt{ out}}  & {\em l} & The value of I=l, if segment\+\_\+str begins with I=l, or the value of J=l \\
\hline
\mbox{\texttt{ out}}  & {\em m} & The value of J=m, if segment\+\_\+str begins with I=, or the value of I=m \\
\hline
\mbox{\texttt{ out}}  & {\em n} & The value of J=n, if segment\+\_\+str begins with I=, or the value of I=n \\
\hline
\mbox{\texttt{ out}}  & {\em action\+\_\+str} & The \char`\"{}string\char`\"{} part of segment\+\_\+str \\
\hline
\mbox{\texttt{ in}}  & {\em reentrant} & is domain reentrant in relevant direction? \\
\hline
\end{DoxyParams}


Definition at line 1458 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1459   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)}  :: ni\_global\textcolor{comment}{ !< Number of h-\/points in zonal direction}}
\DoxyCodeLine{1460   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)}  :: nj\_global\textcolor{comment}{ !< Number of h-\/points in meridional direction}}
\DoxyCodeLine{1461   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}  :: segment\_str\textcolor{comment}{ !< A string in form of "{}I=l,J=m:n,string"{} or "{}J=l,I=m,n,string"{}}}
\DoxyCodeLine{1462   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(out)} :: l\textcolor{comment}{ !< The value of I=l, if segment\_str begins with I=l, or the value of J=l}}
\DoxyCodeLine{1463   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(out)} :: m\textcolor{comment}{ !< The value of J=m, if segment\_str begins with I=, or the value of I=m}}
\DoxyCodeLine{1464   \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(out)} :: n\textcolor{comment}{ !< The value of J=n, if segment\_str begins with I=, or the value of I=n}}
\DoxyCodeLine{1465   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(out)} :: action\_str(:)\textcolor{comment}{ !< The "{}string"{} part of segment\_str}}
\DoxyCodeLine{1466   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{intent(in)}  :: reentrant\textcolor{comment}{ !< is domain reentrant in relevant direction?}}
\DoxyCodeLine{1467   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1468   \textcolor{keywordtype}{character(len=24)} :: word1, word2, m\_word, n\_word\textcolor{comment}{ !< Words delineated by commas in a string in form of}}
\DoxyCodeLine{1469 \textcolor{comment}{                                                    !! "{}I=\%,J=\%:\%,string"{}}}
\DoxyCodeLine{1470   \textcolor{keywordtype}{integer} :: l\_max\textcolor{comment}{ !< Either ni\_global or nj\_global, depending on whether segment\_str begins with "{}I="{} or "{}J="{}}}
\DoxyCodeLine{1471   \textcolor{keywordtype}{integer} :: mn\_max\textcolor{comment}{ !< Either nj\_global or ni\_global, depending on whether segment\_str begins with "{}I="{} or "{}J="{}}}
\DoxyCodeLine{1472   \textcolor{keywordtype}{integer} :: j}
\DoxyCodeLine{1473   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: halo = 10}
\DoxyCodeLine{1474 }
\DoxyCodeLine{1475   \textcolor{comment}{! Process first word which will started with either 'I=' or 'J='}}
\DoxyCodeLine{1476   word1 = extract\_word(segment\_str,\textcolor{stringliteral}{','},1)}
\DoxyCodeLine{1477   word2 = extract\_word(segment\_str,\textcolor{stringliteral}{','},2)}
\DoxyCodeLine{1478   \textcolor{keywordflow}{if} (word1(1:2)==\textcolor{stringliteral}{'I='}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1479     l\_max = ni\_global}
\DoxyCodeLine{1480     mn\_max = nj\_global}
\DoxyCodeLine{1481     \textcolor{keywordflow}{if} (.not. (word2(1:2)==\textcolor{stringliteral}{'J='})) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1482                      \textcolor{stringliteral}{"{}Second word of string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' must start with 'J='."{}})}
\DoxyCodeLine{1483   \textcolor{keywordflow}{elseif} (word1(1:2)==\textcolor{stringliteral}{'J='}) \textcolor{keywordflow}{then} \textcolor{comment}{! Note that the file\_parser uniformaly expands "{}="{} to "{} = "{}}}
\DoxyCodeLine{1484     l\_max = nj\_global}
\DoxyCodeLine{1485     mn\_max = ni\_global}
\DoxyCodeLine{1486     \textcolor{keywordflow}{if} (.not. (word2(1:2)==\textcolor{stringliteral}{'I='})) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1487                      \textcolor{stringliteral}{"{}Second word of string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' must start with 'I='."{}})}
\DoxyCodeLine{1488   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1489     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str"{}}//\&}
\DoxyCodeLine{1490                    \textcolor{stringliteral}{"{}String '"{}}//segment\_str//\textcolor{stringliteral}{"{}' must start with 'I=' or 'J='."{}})}
\DoxyCodeLine{1491 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1492 }
\DoxyCodeLine{1493   \textcolor{comment}{! Read l}}
\DoxyCodeLine{1494   l = interpret\_int\_expr( word1(3:24), l\_max )}
\DoxyCodeLine{1495   \textcolor{keywordflow}{if} (l<0 .or. l>l\_max) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1496     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1497                    \textcolor{stringliteral}{"{}First value from string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' is outside of the physical domain."{}})}
\DoxyCodeLine{1498 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1499 }
\DoxyCodeLine{1500   \textcolor{comment}{! Read m}}
\DoxyCodeLine{1501   m\_word = extract\_word(word2(3:24),\textcolor{stringliteral}{':'},1)}
\DoxyCodeLine{1502   m = interpret\_int\_expr( m\_word, mn\_max )}
\DoxyCodeLine{1503   \textcolor{keywordflow}{if} (reentrant) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1504     \textcolor{keywordflow}{if} (m<-\/halo .or. m>mn\_max+halo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1505       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1506                      \textcolor{stringliteral}{"{}Beginning of range in string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' is outside of the physical domain."{}})}
\DoxyCodeLine{1507 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1508   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1509     \textcolor{keywordflow}{if} (m<-\/1 .or. m>mn\_max+1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1510       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1511                      \textcolor{stringliteral}{"{}Beginning of range in string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' is outside of the physical domain."{}})}
\DoxyCodeLine{1512 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1513 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1514 }
\DoxyCodeLine{1515   \textcolor{comment}{! Read n}}
\DoxyCodeLine{1516   n\_word = extract\_word(word2(3:24),\textcolor{stringliteral}{':'},2)}
\DoxyCodeLine{1517   n = interpret\_int\_expr( n\_word, mn\_max )}
\DoxyCodeLine{1518   \textcolor{keywordflow}{if} (reentrant) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1519     \textcolor{keywordflow}{if} (n<-\/halo .or. n>mn\_max+halo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1520       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1521                      \textcolor{stringliteral}{"{}End of range in string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' is outside of the physical domain."{}})}
\DoxyCodeLine{1522 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1523   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1524     \textcolor{keywordflow}{if} (n<-\/1 .or. n>mn\_max+1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1525       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1526                      \textcolor{stringliteral}{"{}End of range in string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' is outside of the physical domain."{}})}
\DoxyCodeLine{1527 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1528 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1529 }
\DoxyCodeLine{1530   \textcolor{keywordflow}{if} (abs(n-\/m)==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1531     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str: "{}}//\&}
\DoxyCodeLine{1532                    \textcolor{stringliteral}{"{}Range in string '"{}}//trim(segment\_str)//\textcolor{stringliteral}{"{}' must span one cell."{}})}
\DoxyCodeLine{1533 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1534 }
\DoxyCodeLine{1535   \textcolor{comment}{! Type of open boundary condition}}
\DoxyCodeLine{1536   \textcolor{keywordflow}{do} j = 1, \textcolor{keyword}{size}(action\_str)}
\DoxyCodeLine{1537     action\_str(j) = extract\_word(segment\_str,\textcolor{stringliteral}{','},2+j)}
\DoxyCodeLine{1538 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1539 }
\DoxyCodeLine{1540   \textcolor{keyword}{contains}}
\DoxyCodeLine{1541 }
\DoxyCodeLine{1542   \textcolor{comment}{! Returns integer value interpreted from string in form of \%I, N or N+-\/\%I}}
\DoxyCodeLine{1543   \textcolor{keyword}{integer }\textcolor{keyword}{function }interpret\_int\_expr(string, imax)}
\DoxyCodeLine{1544     \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: string\textcolor{comment}{ !< Integer in form or \%I, N or N-\/\%I}}
\DoxyCodeLine{1545     \textcolor{keywordtype}{integer},          \textcolor{keywordtype}{intent(in)} :: imax\textcolor{comment}{ !< Value to replace 'N' with}}
\DoxyCodeLine{1546     \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1547     \textcolor{keywordtype}{integer} slen}
\DoxyCodeLine{1548 }
\DoxyCodeLine{1549     slen = len\_trim(string)}
\DoxyCodeLine{1550     \textcolor{keywordflow}{if} (slen==0) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str"{}}//\&}
\DoxyCodeLine{1551                                 \textcolor{stringliteral}{"{}Parsed string was empty!"{}})}
\DoxyCodeLine{1552     \textcolor{keywordflow}{if} (len\_trim(string)==1 .and. string(1:1)==\textcolor{stringliteral}{'N'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1553       interpret\_int\_expr = imax}
\DoxyCodeLine{1554     \textcolor{keywordflow}{elseif} (string(1:1)==\textcolor{stringliteral}{'N'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1555       \textcolor{keywordflow}{if} (string(2:2)==\textcolor{stringliteral}{'+'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1556         \textcolor{keyword}{read}(string(3:slen),*,err=911) interpret\_int\_expr}
\DoxyCodeLine{1557         interpret\_int\_expr = imax + interpret\_int\_expr}
\DoxyCodeLine{1558       \textcolor{keywordflow}{elseif} (string(2:2)==\textcolor{stringliteral}{'-\/'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1559         \textcolor{keyword}{read}(string(3:slen),*,err=911) interpret\_int\_expr}
\DoxyCodeLine{1560         interpret\_int\_expr = imax -\/ interpret\_int\_expr}
\DoxyCodeLine{1561 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1562     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1563       \textcolor{keyword}{read}(string(1:slen),*,err=911) interpret\_int\_expr}
\DoxyCodeLine{1564 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1565     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1566     911 \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, parse\_segment\_str"{}}//\&}
\DoxyCodeLine{1567                        \textcolor{stringliteral}{"{}Problem reading value from string '"{}}//trim(string)//\textcolor{stringliteral}{"{}'."{}})}
\DoxyCodeLine{1568   \textcolor{keyword}{end function }interpret\_int\_expr}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_ae5ceafcce53e896d30012f321c73d9f4}\label{namespacemom__open__boundary_ae5ceafcce53e896d30012f321c73d9f4}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!radiation\_open\_bdry\_conds@{radiation\_open\_bdry\_conds}}
\index{radiation\_open\_bdry\_conds@{radiation\_open\_bdry\_conds}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{radiation\_open\_bdry\_conds()}{radiation\_open\_bdry\_conds()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::radiation\+\_\+open\+\_\+bdry\+\_\+conds (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{u\+\_\+new,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{u\+\_\+old,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(inout)}]{v\+\_\+new,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(in)}]{v\+\_\+old,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{real, intent(in)}]{dt }\end{DoxyParamCaption})}



Apply radiation conditions to 3D u,v at open boundaries. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+new} & On exit, new u values on open boundaries On entry, the old time-\/level v but including barotropic accelerations \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+old} & Original unadjusted u \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+new} & On exit, new v values on open boundaries. On entry, the old time-\/level v but including barotropic accelerations \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+old} & Original unadjusted v \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Appropriate timestep \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 2118 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2119   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{2120   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{2121 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: u\_new\textcolor{comment}{ !< On exit, new u values on open boundaries}}
\DoxyCodeLine{2122 \textcolor{comment}{                                                                    !! On entry, the old time-\/level v but including}}
\DoxyCodeLine{2123 \textcolor{comment}{                                                                    !! barotropic accelerations [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{2124 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: u\_old\textcolor{comment}{ !< Original unadjusted u [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2125 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: v\_new\textcolor{comment}{ !< On exit, new v values on open boundaries.}}
\DoxyCodeLine{2126 \textcolor{comment}{                                                                    !! On entry, the old time-\/level v but including}}
\DoxyCodeLine{2127 \textcolor{comment}{                                                                    !! barotropic accelerations [L T-\/1 \string~> m s-\/1].}}
\DoxyCodeLine{2128 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)}    :: v\_old\textcolor{comment}{ !< Original unadjusted v  [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2129   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{2130 \textcolor{keywordtype}{  real},                                      \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{    !< Appropriate timestep [T \string~> s]}}
\DoxyCodeLine{2131   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{2132 \textcolor{keywordtype}{  real} :: dhdt, dhdx, dhdy  \textcolor{comment}{! One-\/point differences in time or space [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{2133 \textcolor{keywordtype}{  real} :: gamma\_u, gamma\_2  \textcolor{comment}{! Fractional weightings of new values [nondim]}}
\DoxyCodeLine{2134 \textcolor{keywordtype}{  real} :: tau            \textcolor{comment}{! A local nudging timescale [T \string~> s]}}
\DoxyCodeLine{2135 \textcolor{keywordtype}{  real} :: rx\_max, ry\_max \textcolor{comment}{! coefficients for radiation [nondim]}}
\DoxyCodeLine{2136 \textcolor{keywordtype}{  real} :: rx\_new, rx\_avg \textcolor{comment}{! coefficients for radiation [nondim] or [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2137 \textcolor{keywordtype}{  real} :: ry\_new, ry\_avg \textcolor{comment}{! coefficients for radiation [nondim] or [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2138 \textcolor{keywordtype}{  real} :: cff\_new, cff\_avg \textcolor{comment}{! denominator in oblique [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2139 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:,:,:)} :: \&}
\DoxyCodeLine{2140     rx\_tang\_rad, \& \textcolor{comment}{! The phase speed at u-\/points for tangential oblique OBCs}}
\DoxyCodeLine{2141                    \textcolor{comment}{! in units of grid points per timestep [nondim]}}
\DoxyCodeLine{2142     ry\_tang\_rad, \& \textcolor{comment}{! The phase speed at v-\/points for tangential oblique OBCs}}
\DoxyCodeLine{2143                    \textcolor{comment}{! in units of grid points per timestep [nondim]}}
\DoxyCodeLine{2144     rx\_tang\_obl, \& \textcolor{comment}{! The x-\/coefficient for tangential oblique OBCs [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2145     ry\_tang\_obl, \& \textcolor{comment}{! The y-\/coefficient for tangential oblique OBCs [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2146     cff\_tangential \textcolor{comment}{! The denominator for tangential oblique OBCs [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2147 \textcolor{keywordtype}{  real} :: eps      \textcolor{comment}{! A small velocity squared [L2 T-\/2 \string~> m2 s-\/2]}}
\DoxyCodeLine{2148   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{2149   \textcolor{keywordtype}{integer} :: i, j, k, is, ie, js, je, m, nz, n}
\DoxyCodeLine{2150   \textcolor{keywordtype}{integer} :: is\_obc, ie\_obc, js\_obc, je\_obc}
\DoxyCodeLine{2151 }
\DoxyCodeLine{2152   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{2153 }
\DoxyCodeLine{2154   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{2155 }
\DoxyCodeLine{2156   \textcolor{keywordflow}{if} (.not.(obc\%open\_u\_BCs\_exist\_globally .or. obc\%open\_v\_BCs\_exist\_globally)) \&}
\DoxyCodeLine{2157     \textcolor{keywordflow}{return}}
\DoxyCodeLine{2158 }
\DoxyCodeLine{2159   eps = 1.0e-\/20*us\%m\_s\_to\_L\_T**2}
\DoxyCodeLine{2160 }
\DoxyCodeLine{2161   \textcolor{comment}{!! Copy previously calculated phase velocity from global arrays into segments}}
\DoxyCodeLine{2162   \textcolor{comment}{!! This is terribly inefficient and temporary solution for continuity across restarts}}
\DoxyCodeLine{2163   \textcolor{comment}{!! and needs to be revisited in the future.}}
\DoxyCodeLine{2164   \textcolor{keywordflow}{if} (obc\%gamma\_uv < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2165     \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2166       segment=>obc\%segment(n)}
\DoxyCodeLine{2167       \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{2168       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W .and. segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2169         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2170           i=segment\%HI\%IsdB}
\DoxyCodeLine{2171           \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2172             segment\%rx\_norm\_rad(i,j,k) = obc\%rx\_normal(i,j,k)}
\DoxyCodeLine{2173 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{2174 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2175       \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S .and. segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2176         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2177           j=segment\%HI\%JsdB}
\DoxyCodeLine{2178           \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2179             segment\%ry\_norm\_rad(i,j,k) = obc\%ry\_normal(i,j,k)}
\DoxyCodeLine{2180 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{2181 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2182 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2183       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W .and. segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2184         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2185           i=segment\%HI\%IsdB}
\DoxyCodeLine{2186           \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2187             segment\%rx\_norm\_obl(i,j,k) = obc\%rx\_oblique(i,j,k)}
\DoxyCodeLine{2188             segment\%ry\_norm\_obl(i,j,k) = obc\%ry\_oblique(i,j,k)}
\DoxyCodeLine{2189             segment\%cff\_normal(i,j,k) = obc\%cff\_normal(i,j,k)}
\DoxyCodeLine{2190 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{2191 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2192       \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S .and. segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2193         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2194           j=segment\%HI\%JsdB}
\DoxyCodeLine{2195           \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2196             segment\%rx\_norm\_obl(i,j,k) = obc\%rx\_oblique(i,j,k)}
\DoxyCodeLine{2197             segment\%ry\_norm\_obl(i,j,k) = obc\%ry\_oblique(i,j,k)}
\DoxyCodeLine{2198             segment\%cff\_normal(i,j,k) = obc\%cff\_normal(i,j,k)}
\DoxyCodeLine{2199 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{2200 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2201 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2202 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{2203 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{2204 }
\DoxyCodeLine{2205   \textcolor{comment}{! Now tracers (if any)}}
\DoxyCodeLine{2206   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2207     segment=>obc\%segment(n)}
\DoxyCodeLine{2208     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2209       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2210         i = segment\%HI\%IsdB}
\DoxyCodeLine{2211         \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{2212           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2213             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2214               \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2215                 segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) = obc\%tres\_x(i,j,k,m)}
\DoxyCodeLine{2216 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{2217 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{2218 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2219 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2220       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2221         j = segment\%HI\%JsdB}
\DoxyCodeLine{2222         \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{2223           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2224             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2225               \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2226                 segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) = obc\%tres\_y(i,j,k,m)}
\DoxyCodeLine{2227 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{2228 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{2229 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2230 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2231 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2232 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2233 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2234 }
\DoxyCodeLine{2235   gamma\_u = obc\%gamma\_uv}
\DoxyCodeLine{2236   rx\_max = obc\%rx\_max ; ry\_max = obc\%rx\_max}
\DoxyCodeLine{2237   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2238      segment=>obc\%segment(n)}
\DoxyCodeLine{2239      \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{2240      \textcolor{keywordflow}{if} (segment\%oblique) \textcolor{keyword}{call }gradient\_at\_q\_points(g, segment, u\_new(:,:,:), v\_new(:,:,:))}
\DoxyCodeLine{2241      \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2242        i=segment\%HI\%IsdB}
\DoxyCodeLine{2243        \textcolor{keywordflow}{if} (i<g\%HI\%IscB) cycle}
\DoxyCodeLine{2244        \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2245          \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2246            dhdt = (u\_old(i-\/1,j,k) -\/ u\_new(i-\/1,j,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2247            dhdx = (u\_new(i-\/1,j,k) -\/ u\_new(i-\/2,j,k)) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2248            rx\_new = 0.0}
\DoxyCodeLine{2249            \textcolor{keywordflow}{if} (dhdt*dhdx > 0.0) rx\_new = min( (dhdt/dhdx), rx\_max) \textcolor{comment}{! outward phase speed}}
\DoxyCodeLine{2250            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2251              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_rad(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{2252            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2253              rx\_avg = rx\_new}
\DoxyCodeLine{2254 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2255            segment\%rx\_norm\_rad(i,j,k) = rx\_avg}
\DoxyCodeLine{2256            \textcolor{comment}{! The new boundary value is interpolated between future interior}}
\DoxyCodeLine{2257            \textcolor{comment}{! value, u\_new(I-\/1) and past boundary value but with barotropic}}
\DoxyCodeLine{2258            \textcolor{comment}{! accelerations, u\_new(I).}}
\DoxyCodeLine{2259            segment\%normal\_vel(i,j,k) = (u\_new(i,j,k) + rx\_avg*u\_new(i-\/1,j,k)) / (1.0+rx\_avg)}
\DoxyCodeLine{2260            \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2261            \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2262            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2263              obc\%rx\_normal(i,j,k) = segment\%rx\_norm\_rad(i,j,k)}
\DoxyCodeLine{2264 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2265          \textcolor{keywordflow}{elseif} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2266            dhdt = (u\_old(i-\/1,j,k) -\/ u\_new(i-\/1,j,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2267            dhdx = (u\_new(i-\/1,j,k) -\/ u\_new(i-\/2,j,k)) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2268            \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_normal(j,1,k) + segment\%grad\_normal(j-\/1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2269              dhdy = segment\%grad\_normal(j-\/1,1,k)}
\DoxyCodeLine{2270            \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_normal(j,1,k) + segment\%grad\_normal(j-\/1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2271              dhdy = 0.0}
\DoxyCodeLine{2272            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2273              dhdy = segment\%grad\_normal(j,1,k)}
\DoxyCodeLine{2274 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2275            \textcolor{keywordflow}{if} (dhdt*dhdx < 0.0) dhdt = 0.0}
\DoxyCodeLine{2276            cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2277            rx\_new = min(dhdt*dhdx, cff\_new*rx\_max)}
\DoxyCodeLine{2278            ry\_new = min(cff\_new,max(dhdt*dhdy,-\/cff\_new))}
\DoxyCodeLine{2279            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2280              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_obl(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{2281              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_obl(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{2282              cff\_avg = (1.0-\/gamma\_u)*segment\%cff\_normal(i,j,k) + gamma\_u*cff\_new}
\DoxyCodeLine{2283            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2284              rx\_avg = rx\_new}
\DoxyCodeLine{2285              ry\_avg = ry\_new}
\DoxyCodeLine{2286              cff\_avg = cff\_new}
\DoxyCodeLine{2287 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2288            segment\%rx\_norm\_obl(i,j,k) = rx\_avg}
\DoxyCodeLine{2289            segment\%ry\_norm\_obl(i,j,k) = ry\_avg}
\DoxyCodeLine{2290            segment\%cff\_normal(i,j,k) = cff\_avg}
\DoxyCodeLine{2291            segment\%normal\_vel(i,j,k) = ((cff\_avg*u\_new(i,j,k) + rx\_avg*u\_new(i-\/1,j,k)) -\/ \&}
\DoxyCodeLine{2292                               (max(ry\_avg,0.0)*segment\%grad\_normal(j-\/1,2,k) + \&}
\DoxyCodeLine{2293                                min(ry\_avg,0.0)*segment\%grad\_normal(j,2,k))) / \&}
\DoxyCodeLine{2294                             (cff\_avg + rx\_avg)}
\DoxyCodeLine{2295            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2296              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary}}
\DoxyCodeLine{2297              \textcolor{comment}{! implementation as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2298              obc\%rx\_oblique(i,j,k) = segment\%rx\_norm\_obl(i,j,k)}
\DoxyCodeLine{2299              obc\%ry\_oblique(i,j,k) = segment\%ry\_norm\_obl(i,j,k)}
\DoxyCodeLine{2300              obc\%cff\_normal(i,j,k) = segment\%cff\_normal(i,j,k)}
\DoxyCodeLine{2301 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2302          \textcolor{keywordflow}{elseif} (segment\%gradient) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2303            segment\%normal\_vel(i,j,k) = u\_new(i-\/1,j,k)}
\DoxyCodeLine{2304 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2305          \textcolor{keywordflow}{if} ((segment\%radiation .or. segment\%oblique) .and. segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2306            \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2307            \textcolor{keywordflow}{if} (dhdt*dhdx <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2308              tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2309            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2310              tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2311 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2312            gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2313            segment\%normal\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%normal\_vel(i,j,k) + \&}
\DoxyCodeLine{2314                                  gamma\_2 * segment\%nudged\_normal\_vel(i,j,k)}
\DoxyCodeLine{2315 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2316 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2317        \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2318          i=segment\%HI\%IsdB}
\DoxyCodeLine{2319          \textcolor{keyword}{allocate}(rx\_tang\_rad(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2320          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2321            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2322              rx\_tang\_rad(i,segment\%HI\%JsdB,k) = segment\%rx\_norm\_rad(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2323              rx\_tang\_rad(i,segment\%HI\%JedB,k) = segment\%rx\_norm\_rad(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2324              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2325                rx\_tang\_rad(i,j,k) = 0.5*(segment\%rx\_norm\_rad(i,j,k) + segment\%rx\_norm\_rad(i,j+1,k))}
\DoxyCodeLine{2326 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2327            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2328              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2329                dhdt = v\_old(i,j,k)-\/v\_new(i,j,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2330                dhdx = v\_new(i,j,k)-\/v\_new(i-\/1,j,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2331                rx\_tang\_rad(i,j,k) = 0.0}
\DoxyCodeLine{2332                \textcolor{keywordflow}{if} (dhdt*dhdx > 0.0) rx\_tang\_rad(i,j,k) = min( (dhdt/dhdx), rx\_max) \textcolor{comment}{! outward phase speed}}
\DoxyCodeLine{2333 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2334 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2335 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2336          \textcolor{keywordflow}{if} (segment\%radiation\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2337            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2338              rx\_avg = rx\_tang\_rad(i,j,k)}
\DoxyCodeLine{2339              segment\%tangential\_vel(i,j,k) = (v\_new(i,j,k) + rx\_avg*v\_new(i-\/1,j,k)) / (1.0+rx\_avg)}
\DoxyCodeLine{2340 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2341 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2342          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2343            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2344              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2345              \textcolor{keywordflow}{if} (rx\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2346                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2347              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2348                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2349 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2350              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2351              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2352                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2353 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2354 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2355          \textcolor{keywordflow}{if} (segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2356            js\_obc = max(segment\%HI\%JsdB,g\%jsd+1)}
\DoxyCodeLine{2357            je\_obc = min(segment\%HI\%JedB,g\%jed-\/1)}
\DoxyCodeLine{2358            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=js\_obc,je\_obc}
\DoxyCodeLine{2359              rx\_avg = rx\_tang\_rad(i,j,k)}
\DoxyCodeLine{2360 \textcolor{comment}{!            if (G\%mask2dCu(I-\/1,j) > 0.0 .and. G\%mask2dCu(I-\/1,j+1) > 0.0) then}}
\DoxyCodeLine{2361 \textcolor{comment}{!              rx\_avg = 0.5*(u\_new(I-\/1,j,k) + u\_new(I-\/1,j+1,k)) * dt * G\%IdxBu(I-\/1,J)}}
\DoxyCodeLine{2362 \textcolor{comment}{!            elseif (G\%mask2dCu(I-\/1,j) > 0.0) then}}
\DoxyCodeLine{2363 \textcolor{comment}{!              rx\_avg = u\_new(I-\/1,j,k) * dt * G\%IdxBu(I-\/1,J)}}
\DoxyCodeLine{2364 \textcolor{comment}{!            elseif (G\%mask2dCu(I-\/1,j+1) > 0.0) then}}
\DoxyCodeLine{2365 \textcolor{comment}{!              rx\_avg = u\_new(I-\/1,j+1,k) * dt * G\%IdxBu(I-\/1,J)}}
\DoxyCodeLine{2366 \textcolor{comment}{!            else}}
\DoxyCodeLine{2367 \textcolor{comment}{!              rx\_avg = 0.0}}
\DoxyCodeLine{2368 \textcolor{comment}{!            endif}}
\DoxyCodeLine{2369              segment\%tangential\_grad(i,j,k) = ((v\_new(i,j,k) -\/ v\_new(i-\/1,j,k))*g\%IdxBu(i-\/1,j) + \&}
\DoxyCodeLine{2370                                rx\_avg*(v\_new(i-\/1,j,k) -\/ v\_new(i-\/2,j,k))*g\%IdxBu(i-\/2,j)) / (1.0+rx\_avg)}
\DoxyCodeLine{2371 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2372 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2373          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2374            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2375              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2376              \textcolor{keywordflow}{if} (rx\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2377                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2378              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2379                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2380 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2381              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2382              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2383                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2384 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2385 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2386          \textcolor{keyword}{deallocate}(rx\_tang\_rad)}
\DoxyCodeLine{2387 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2388        \textcolor{keywordflow}{if} (segment\%oblique\_tan .or. segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2389          i=segment\%HI\%IsdB}
\DoxyCodeLine{2390          \textcolor{keyword}{allocate}(rx\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2391          \textcolor{keyword}{allocate}(ry\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2392          \textcolor{keyword}{allocate}(cff\_tangential(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2393          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2394            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2395              rx\_tang\_obl(i,segment\%HI\%JsdB,k) = segment\%rx\_norm\_obl(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2396              rx\_tang\_obl(i,segment\%HI\%JedB,k) = segment\%rx\_norm\_obl(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2397              ry\_tang\_obl(i,segment\%HI\%JsdB,k) = segment\%ry\_norm\_obl(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2398              ry\_tang\_obl(i,segment\%HI\%JedB,k) = segment\%ry\_norm\_obl(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2399              cff\_tangential(i,segment\%HI\%JsdB,k) = segment\%cff\_normal(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2400              cff\_tangential(i,segment\%HI\%JedB,k) = segment\%cff\_normal(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2401              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2402                rx\_tang\_obl(i,j,k) = 0.5*(segment\%rx\_norm\_obl(i,j,k) + segment\%rx\_norm\_obl(i,j+1,k))}
\DoxyCodeLine{2403                ry\_tang\_obl(i,j,k) = 0.5*(segment\%ry\_norm\_obl(i,j,k) + segment\%ry\_norm\_obl(i,j+1,k))}
\DoxyCodeLine{2404                cff\_tangential(i,j,k) = 0.5*(segment\%cff\_normal(i,j,k) + segment\%cff\_normal(i,j+1,k))}
\DoxyCodeLine{2405 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2406            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2407              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2408                dhdt = v\_old(i,j,k)-\/v\_new(i,j,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2409                dhdx = v\_new(i,j,k)-\/v\_new(i-\/1,j,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2410                \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_tan(j,1,k) + segment\%grad\_tan(j+1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2411                  dhdy = segment\%grad\_tan(j,1,k)}
\DoxyCodeLine{2412                \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_tan(j,1,k) + segment\%grad\_tan(j+1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2413                  dhdy = 0.0}
\DoxyCodeLine{2414                \textcolor{keywordflow}{else}}
\DoxyCodeLine{2415                  dhdy = segment\%grad\_tan(j+1,1,k)}
\DoxyCodeLine{2416 \textcolor{keywordflow}{               endif}}
\DoxyCodeLine{2417                \textcolor{keywordflow}{if} (dhdt*dhdx < 0.0) dhdt = 0.0}
\DoxyCodeLine{2418                cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2419                rx\_new = min(dhdt*dhdx, cff\_new*rx\_max)}
\DoxyCodeLine{2420                ry\_new = min(cff\_new,max(dhdt*dhdy,-\/cff\_new))}
\DoxyCodeLine{2421                rx\_tang\_obl(i,j,k) = rx\_new}
\DoxyCodeLine{2422                ry\_tang\_obl(i,j,k) = ry\_new}
\DoxyCodeLine{2423                cff\_tangential(i,j,k) = cff\_new}
\DoxyCodeLine{2424 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2425 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2426 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2427          \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2428            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2429              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2430              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2431              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2432              segment\%tangential\_vel(i,j,k) = ((cff\_avg*v\_new(i,j,k) + rx\_avg*v\_new(i-\/1,j,k)) -\/ \&}
\DoxyCodeLine{2433                                               (max(ry\_avg,0.0)*segment\%grad\_tan(j,2,k) + \&}
\DoxyCodeLine{2434                                                min(ry\_avg,0.0)*segment\%grad\_tan(j+1,2,k))) / \&}
\DoxyCodeLine{2435                                              (cff\_avg + rx\_avg)}
\DoxyCodeLine{2436 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2437 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2438          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2439            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2440              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2441              \textcolor{keywordflow}{if} (rx\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2442                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2443              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2444                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2445 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2446              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2447              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2448                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2449 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2450 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2451          \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2452            js\_obc = max(segment\%HI\%JsdB,g\%jsd+1)}
\DoxyCodeLine{2453            je\_obc = min(segment\%HI\%JedB,g\%jed-\/1)}
\DoxyCodeLine{2454            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2455              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2456              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2457              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2458              segment\%tangential\_grad(i,j,k) =  \&}
\DoxyCodeLine{2459                  ((cff\_avg*(v\_new(i,j,k)  -\/ v\_new(i-\/1,j,k))*g\%IdxBu(i-\/1,j) + \&}
\DoxyCodeLine{2460                    rx\_avg*(v\_new(i-\/1,j,k) -\/ v\_new(i-\/2,j,k))*g\%IdxBu(i-\/2,j)) -\/ \&}
\DoxyCodeLine{2461                   (max(ry\_avg,0.0)*segment\%grad\_gradient(j,2,k) + \&}
\DoxyCodeLine{2462                    min(ry\_avg,0.0)*segment\%grad\_gradient(j+1,2,k)) ) / \&}
\DoxyCodeLine{2463                  (cff\_avg + rx\_avg)}
\DoxyCodeLine{2464 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2465 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2466          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2467            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2468              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2469              \textcolor{keywordflow}{if} (rx\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2470                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2471              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2472                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2473 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2474              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2475              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2476                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2477 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2478 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2479          \textcolor{keyword}{deallocate}(rx\_tang\_obl)}
\DoxyCodeLine{2480          \textcolor{keyword}{deallocate}(ry\_tang\_obl)}
\DoxyCodeLine{2481          \textcolor{keyword}{deallocate}(cff\_tangential)}
\DoxyCodeLine{2482 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2483 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{2484 }
\DoxyCodeLine{2485      \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2486        i=segment\%HI\%IsdB}
\DoxyCodeLine{2487        \textcolor{keywordflow}{if} (i>g\%HI\%IecB) cycle}
\DoxyCodeLine{2488        \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2489          \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2490            dhdt = (u\_old(i+1,j,k) -\/ u\_new(i+1,j,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2491            dhdx = (u\_new(i+1,j,k) -\/ u\_new(i+2,j,k)) \textcolor{comment}{!in new time forward sasha for I+1}}
\DoxyCodeLine{2492            rx\_new = 0.0}
\DoxyCodeLine{2493            \textcolor{keywordflow}{if} (dhdt*dhdx > 0.0) rx\_new = min( (dhdt/dhdx), rx\_max)}
\DoxyCodeLine{2494            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2495              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_rad(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{2496            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2497              rx\_avg = rx\_new}
\DoxyCodeLine{2498 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2499            segment\%rx\_norm\_rad(i,j,k) = rx\_avg}
\DoxyCodeLine{2500            \textcolor{comment}{! The new boundary value is interpolated between future interior}}
\DoxyCodeLine{2501            \textcolor{comment}{! value, u\_new(I+1) and past boundary value but with barotropic}}
\DoxyCodeLine{2502            \textcolor{comment}{! accelerations, u\_new(I).}}
\DoxyCodeLine{2503            segment\%normal\_vel(i,j,k) = (u\_new(i,j,k) + rx\_avg*u\_new(i+1,j,k)) / (1.0+rx\_avg)}
\DoxyCodeLine{2504            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2505              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2506              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2507              obc\%rx\_normal(i,j,k) = segment\%rx\_norm\_rad(i,j,k)}
\DoxyCodeLine{2508 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2509          \textcolor{keywordflow}{elseif} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2510            dhdt = (u\_old(i+1,j,k) -\/ u\_new(i+1,j,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2511            dhdx = (u\_new(i+1,j,k) -\/ u\_new(i+2,j,k)) \textcolor{comment}{!in new time forward sasha for I+1}}
\DoxyCodeLine{2512            \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_normal(j,1,k) + segment\%grad\_normal(j-\/1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2513              dhdy = segment\%grad\_normal(j-\/1,1,k)}
\DoxyCodeLine{2514            \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_normal(j,1,k) + segment\%grad\_normal(j-\/1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2515              dhdy = 0.0}
\DoxyCodeLine{2516            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2517              dhdy = segment\%grad\_normal(j,1,k)}
\DoxyCodeLine{2518 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2519            \textcolor{keywordflow}{if} (dhdt*dhdx < 0.0) dhdt = 0.0}
\DoxyCodeLine{2520 }
\DoxyCodeLine{2521            cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2522            rx\_new = min(dhdt*dhdx, cff\_new*rx\_max)}
\DoxyCodeLine{2523            ry\_new = min(cff\_new,max(dhdt*dhdy,-\/cff\_new))}
\DoxyCodeLine{2524            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2525              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_obl(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{2526              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_obl(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{2527              cff\_avg = (1.0-\/gamma\_u)*segment\%cff\_normal(i,j,k) + gamma\_u*cff\_new}
\DoxyCodeLine{2528            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2529              rx\_avg = rx\_new}
\DoxyCodeLine{2530              ry\_avg = ry\_new}
\DoxyCodeLine{2531              cff\_avg = cff\_new}
\DoxyCodeLine{2532 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2533            segment\%rx\_norm\_obl(i,j,k) = rx\_avg}
\DoxyCodeLine{2534            segment\%ry\_norm\_obl(i,j,k) = ry\_avg}
\DoxyCodeLine{2535            segment\%cff\_normal(i,j,k) = cff\_avg}
\DoxyCodeLine{2536            segment\%normal\_vel(i,j,k) = ((cff\_avg*u\_new(i,j,k) + rx\_avg*u\_new(i+1,j,k)) -\/ \&}
\DoxyCodeLine{2537                                         (max(ry\_avg,0.0)*segment\%grad\_normal(j-\/1,2,k) + \&}
\DoxyCodeLine{2538                                          min(ry\_avg,0.0)*segment\%grad\_normal(j,2,k))) / \&}
\DoxyCodeLine{2539                                        (cff\_avg + rx\_avg)}
\DoxyCodeLine{2540            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2541              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2542              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2543              obc\%rx\_oblique(i,j,k) = segment\%rx\_norm\_obl(i,j,k)}
\DoxyCodeLine{2544              obc\%ry\_oblique(i,j,k) = segment\%ry\_norm\_obl(i,j,k)}
\DoxyCodeLine{2545              obc\%cff\_normal(i,j,k) = segment\%cff\_normal(i,j,k)}
\DoxyCodeLine{2546 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2547          \textcolor{keywordflow}{elseif} (segment\%gradient) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2548            segment\%normal\_vel(i,j,k) = u\_new(i+1,j,k)}
\DoxyCodeLine{2549 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2550          \textcolor{keywordflow}{if} ((segment\%radiation .or. segment\%oblique) .and. segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2551            \textcolor{comment}{! dhdt gets set to 0. on inflow in oblique case}}
\DoxyCodeLine{2552            \textcolor{keywordflow}{if} (dhdt*dhdx <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2553              tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2554            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2555              tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2556 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2557            gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2558            segment\%normal\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%normal\_vel(i,j,k) + \&}
\DoxyCodeLine{2559                                  gamma\_2 * segment\%nudged\_normal\_vel(i,j,k)}
\DoxyCodeLine{2560 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2561 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2562        \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2563          i=segment\%HI\%IsdB}
\DoxyCodeLine{2564          \textcolor{keyword}{allocate}(rx\_tang\_rad(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2565          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2566            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2567              rx\_tang\_rad(i,segment\%HI\%JsdB,k) = segment\%rx\_norm\_rad(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2568              rx\_tang\_rad(i,segment\%HI\%JedB,k) = segment\%rx\_norm\_rad(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2569              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2570                rx\_tang\_rad(i,j,k) = 0.5*(segment\%rx\_norm\_rad(i,j,k) + segment\%rx\_norm\_rad(i,j+1,k))}
\DoxyCodeLine{2571 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2572            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2573              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2574                dhdt = v\_old(i+1,j,k)-\/v\_new(i+1,j,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2575                dhdx = v\_new(i+1,j,k)-\/v\_new(i+2,j,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2576                rx\_tang\_rad(i,j,k) = 0.0}
\DoxyCodeLine{2577                \textcolor{keywordflow}{if} (dhdt*dhdx > 0.0) rx\_tang\_rad(i,j,k) = min( (dhdt/dhdx), rx\_max) \textcolor{comment}{! outward phase speed}}
\DoxyCodeLine{2578 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2579 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2580 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2581          \textcolor{keywordflow}{if} (segment\%radiation\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2582            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2583              rx\_avg = rx\_tang\_rad(i,j,k)}
\DoxyCodeLine{2584              segment\%tangential\_vel(i,j,k) = (v\_new(i+1,j,k) + rx\_avg*v\_new(i+2,j,k)) / (1.0+rx\_avg)}
\DoxyCodeLine{2585 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2586 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2587          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2588            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2589              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2590              \textcolor{keywordflow}{if} (rx\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2591                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2592              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2593                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2594 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2595              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2596              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2597                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2598 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2599 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2600          \textcolor{keywordflow}{if} (segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2601            js\_obc = max(segment\%HI\%JsdB,g\%jsd+1)}
\DoxyCodeLine{2602            je\_obc = min(segment\%HI\%JedB,g\%jed-\/1)}
\DoxyCodeLine{2603            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=js\_obc,je\_obc}
\DoxyCodeLine{2604              rx\_avg = rx\_tang\_rad(i,j,k)}
\DoxyCodeLine{2605 \textcolor{comment}{!            if (G\%mask2dCu(I+1,j) > 0.0 .and. G\%mask2dCu(I+1,j+1) > 0.0) then}}
\DoxyCodeLine{2606 \textcolor{comment}{!              rx\_avg = 0.5*(u\_new(I+1,j,k) + u\_new(I+1,j+1,k)) * dt * G\%IdxBu(I+1,J)}}
\DoxyCodeLine{2607 \textcolor{comment}{!            elseif (G\%mask2dCu(I+1,j) > 0.0) then}}
\DoxyCodeLine{2608 \textcolor{comment}{!              rx\_avg = u\_new(I+1,j,k) * dt * G\%IdxBu(I+1,J)}}
\DoxyCodeLine{2609 \textcolor{comment}{!            elseif (G\%mask2dCu(I+1,j+1) > 0.0) then}}
\DoxyCodeLine{2610 \textcolor{comment}{!              rx\_avg = u\_new(I+1,j+1,k) * dt * G\%IdxBu(I+1,J)}}
\DoxyCodeLine{2611 \textcolor{comment}{!            else}}
\DoxyCodeLine{2612 \textcolor{comment}{!              rx\_avg = 0.0}}
\DoxyCodeLine{2613 \textcolor{comment}{!            endif}}
\DoxyCodeLine{2614              segment\%tangential\_grad(i,j,k) = ((v\_new(i+2,j,k) -\/ v\_new(i+1,j,k))*g\%IdxBu(i+1,j) + \&}
\DoxyCodeLine{2615                                rx\_avg*(v\_new(i+3,j,k) -\/ v\_new(i+2,j,k))*g\%IdxBu(i+2,j)) / (1.0+rx\_avg)}
\DoxyCodeLine{2616 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2617 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2618          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2619            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2620              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2621              \textcolor{keywordflow}{if} (rx\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2622                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2623              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2624                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2625 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2626              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2627              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2628                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2629 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2630 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2631          \textcolor{keyword}{deallocate}(rx\_tang\_rad)}
\DoxyCodeLine{2632 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2633        \textcolor{keywordflow}{if} (segment\%oblique\_tan .or. segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2634          i=segment\%HI\%IsdB}
\DoxyCodeLine{2635          \textcolor{keyword}{allocate}(rx\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2636          \textcolor{keyword}{allocate}(ry\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2637          \textcolor{keyword}{allocate}(cff\_tangential(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2638          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2639            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2640              rx\_tang\_obl(i,segment\%HI\%JsdB,k) = segment\%rx\_norm\_obl(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2641              rx\_tang\_obl(i,segment\%HI\%JedB,k) = segment\%rx\_norm\_obl(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2642              ry\_tang\_obl(i,segment\%HI\%JsdB,k) = segment\%ry\_norm\_obl(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2643              ry\_tang\_obl(i,segment\%HI\%JedB,k) = segment\%ry\_norm\_obl(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2644              cff\_tangential(i,segment\%HI\%JsdB,k) = segment\%cff\_normal(i,segment\%HI\%jsd,k)}
\DoxyCodeLine{2645              cff\_tangential(i,segment\%HI\%JedB,k) = segment\%cff\_normal(i,segment\%HI\%jed,k)}
\DoxyCodeLine{2646              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2647                rx\_tang\_obl(i,j,k) = 0.5*(segment\%rx\_norm\_obl(i,j,k) + segment\%rx\_norm\_obl(i,j+1,k))}
\DoxyCodeLine{2648                ry\_tang\_obl(i,j,k) = 0.5*(segment\%ry\_norm\_obl(i,j,k) + segment\%ry\_norm\_obl(i,j+1,k))}
\DoxyCodeLine{2649                cff\_tangential(i,j,k) = 0.5*(segment\%cff\_normal(i,j,k) + segment\%cff\_normal(i,j+1,k))}
\DoxyCodeLine{2650 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2651            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2652              \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2653                dhdt = v\_old(i+1,j,k)-\/v\_new(i+1,j,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2654                dhdx = v\_new(i+1,j,k)-\/v\_new(i+2,j,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2655                \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_tan(j,1,k) + segment\%grad\_tan(j+1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2656                  dhdy = segment\%grad\_tan(j,1,k)}
\DoxyCodeLine{2657                \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_tan(j,1,k) + segment\%grad\_tan(j+1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2658                  dhdy = 0.0}
\DoxyCodeLine{2659                \textcolor{keywordflow}{else}}
\DoxyCodeLine{2660                  dhdy = segment\%grad\_tan(j+1,1,k)}
\DoxyCodeLine{2661 \textcolor{keywordflow}{               endif}}
\DoxyCodeLine{2662                \textcolor{keywordflow}{if} (dhdt*dhdx < 0.0) dhdt = 0.0}
\DoxyCodeLine{2663                cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2664                rx\_new = min(dhdt*dhdx, cff\_new*rx\_max)}
\DoxyCodeLine{2665                ry\_new = min(cff\_new,max(dhdt*dhdy,-\/cff\_new))}
\DoxyCodeLine{2666                rx\_tang\_obl(i,j,k) = rx\_new}
\DoxyCodeLine{2667                ry\_tang\_obl(i,j,k) = ry\_new}
\DoxyCodeLine{2668                cff\_tangential(i,j,k) = cff\_new}
\DoxyCodeLine{2669 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2670 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2671 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2672          \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2673            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2674              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2675              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2676              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2677              segment\%tangential\_vel(i,j,k) = ((cff\_avg*v\_new(i+1,j,k) + rx\_avg*v\_new(i+2,j,k)) -\/ \&}
\DoxyCodeLine{2678                                               (max(ry\_avg,0.0)*segment\%grad\_tan(j,2,k) + \&}
\DoxyCodeLine{2679                                                min(ry\_avg,0.0)*segment\%grad\_tan(j+1,2,k))) / \&}
\DoxyCodeLine{2680                                              (cff\_avg + rx\_avg)}
\DoxyCodeLine{2681 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2682 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2683          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2684            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2685              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2686              \textcolor{keywordflow}{if} (rx\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2687                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2688              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2689                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2690 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2691              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2692              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2693                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2694 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2695 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2696          \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2697            js\_obc = max(segment\%HI\%JsdB,g\%jsd+1)}
\DoxyCodeLine{2698            je\_obc = min(segment\%HI\%JedB,g\%jed-\/1)}
\DoxyCodeLine{2699            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} j=segment\%HI\%JsdB+1,segment\%HI\%JedB-\/1}
\DoxyCodeLine{2700              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2701              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2702              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2703              segment\%tangential\_grad(i,j,k) = \&}
\DoxyCodeLine{2704                  ((cff\_avg*(v\_new(i+2,j,k) -\/ v\_new(i+1,j,k))*g\%IdxBu(i+1,j) + \&}
\DoxyCodeLine{2705                     rx\_avg*(v\_new(i+3,j,k) -\/ v\_new(i+2,j,k))*g\%IdxBu(i+2,j)) -\/ \&}
\DoxyCodeLine{2706                   (max(ry\_avg,0.0)*segment\%grad\_gradient(j,2,k) + \&}
\DoxyCodeLine{2707                    min(ry\_avg,0.0)*segment\%grad\_gradient(j+1,2,k))) / \&}
\DoxyCodeLine{2708                  (cff\_avg + rx\_avg)}
\DoxyCodeLine{2709 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2710 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2711          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2712            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{2713              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2714              \textcolor{keywordflow}{if} (rx\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2715                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2716              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2717                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2718 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2719              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2720              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2721                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2722 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2723 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2724          \textcolor{keyword}{deallocate}(rx\_tang\_obl)}
\DoxyCodeLine{2725          \textcolor{keyword}{deallocate}(ry\_tang\_obl)}
\DoxyCodeLine{2726          \textcolor{keyword}{deallocate}(cff\_tangential)}
\DoxyCodeLine{2727 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2728 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{2729 }
\DoxyCodeLine{2730      \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2731        j=segment\%HI\%JsdB}
\DoxyCodeLine{2732        \textcolor{keywordflow}{if} (j<g\%HI\%JscB) cycle}
\DoxyCodeLine{2733        \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2734          \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2735            dhdt = (v\_old(i,j-\/1,k) -\/ v\_new(i,j-\/1,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2736            dhdy = (v\_new(i,j-\/1,k) -\/ v\_new(i,j-\/2,k)) \textcolor{comment}{!in new time backward sasha for J-\/1}}
\DoxyCodeLine{2737            ry\_new = 0.0}
\DoxyCodeLine{2738            \textcolor{keywordflow}{if} (dhdt*dhdy > 0.0) ry\_new = min( (dhdt/dhdy), ry\_max)}
\DoxyCodeLine{2739            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2740              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_rad(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{2741            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2742              ry\_avg = ry\_new}
\DoxyCodeLine{2743 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2744            segment\%ry\_norm\_rad(i,j,k) = ry\_avg}
\DoxyCodeLine{2745            \textcolor{comment}{! The new boundary value is interpolated between future interior}}
\DoxyCodeLine{2746            \textcolor{comment}{! value, v\_new(J-\/1) and past boundary value but with barotropic}}
\DoxyCodeLine{2747            \textcolor{comment}{! accelerations, v\_new(J).}}
\DoxyCodeLine{2748            segment\%normal\_vel(i,j,k) = (v\_new(i,j,k) + ry\_avg*v\_new(i,j-\/1,k)) / (1.0+ry\_avg)}
\DoxyCodeLine{2749            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2750              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2751              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2752              obc\%ry\_normal(i,j,k) = segment\%ry\_norm\_rad(i,j,k)}
\DoxyCodeLine{2753 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2754          \textcolor{keywordflow}{elseif} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2755            dhdt = (v\_old(i,j-\/1,k) -\/ v\_new(i,j-\/1,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2756            dhdy = (v\_new(i,j-\/1,k) -\/ v\_new(i,j-\/2,k)) \textcolor{comment}{!in new time backward sasha for J-\/1}}
\DoxyCodeLine{2757            \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_normal(i,1,k) + segment\%grad\_normal(i-\/1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2758              dhdx = segment\%grad\_normal(i-\/1,1,k)}
\DoxyCodeLine{2759            \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_normal(i,1,k) + segment\%grad\_normal(i-\/1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2760              dhdx = 0.0}
\DoxyCodeLine{2761            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2762              dhdx = segment\%grad\_normal(i,1,k)}
\DoxyCodeLine{2763 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2764            \textcolor{keywordflow}{if} (dhdt*dhdy < 0.0) dhdt = 0.0}
\DoxyCodeLine{2765            cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2766            ry\_new = min(dhdt*dhdy, cff\_new*ry\_max)}
\DoxyCodeLine{2767            rx\_new = min(cff\_new,max(dhdt*dhdx,-\/cff\_new))}
\DoxyCodeLine{2768            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2769              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_obl(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{2770              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_obl(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{2771              cff\_avg = (1.0-\/gamma\_u)*segment\%cff\_normal(i,j,k) + gamma\_u*cff\_new}
\DoxyCodeLine{2772            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2773              rx\_avg = rx\_new}
\DoxyCodeLine{2774              ry\_avg = ry\_new}
\DoxyCodeLine{2775              cff\_avg = cff\_new}
\DoxyCodeLine{2776 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2777            segment\%rx\_norm\_obl(i,j,k) = rx\_avg}
\DoxyCodeLine{2778            segment\%ry\_norm\_obl(i,j,k) = ry\_avg}
\DoxyCodeLine{2779            segment\%cff\_normal(i,j,k) = cff\_avg}
\DoxyCodeLine{2780            segment\%normal\_vel(i,j,k) = ((cff\_avg*v\_new(i,j,k) + ry\_avg*v\_new(i,j-\/1,k)) -\/ \&}
\DoxyCodeLine{2781                                         (max(rx\_avg,0.0)*segment\%grad\_normal(i-\/1,2,k) +\&}
\DoxyCodeLine{2782                                          min(rx\_avg,0.0)*segment\%grad\_normal(i,2,k))) / \&}
\DoxyCodeLine{2783                                        (cff\_avg + ry\_avg)}
\DoxyCodeLine{2784            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2785              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2786              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2787              obc\%rx\_oblique(i,j,k) = segment\%rx\_norm\_obl(i,j,k)}
\DoxyCodeLine{2788              obc\%ry\_oblique(i,j,k) = segment\%ry\_norm\_obl(i,j,k)}
\DoxyCodeLine{2789              obc\%cff\_normal(i,j,k) = segment\%cff\_normal(i,j,k)}
\DoxyCodeLine{2790 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2791          \textcolor{keywordflow}{elseif} (segment\%gradient) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2792            segment\%normal\_vel(i,j,k) = v\_new(i,j-\/1,k)}
\DoxyCodeLine{2793 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2794          \textcolor{keywordflow}{if} ((segment\%radiation .or. segment\%oblique) .and. segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2795            \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2796            \textcolor{keywordflow}{if} (dhdt*dhdy <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2797              tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2798            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2799              tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2800 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2801            gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2802            segment\%normal\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%normal\_vel(i,j,k) + \&}
\DoxyCodeLine{2803                                  gamma\_2 * segment\%nudged\_normal\_vel(i,j,k)}
\DoxyCodeLine{2804 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2805 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2806        \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2807          j=segment\%HI\%JsdB}
\DoxyCodeLine{2808          \textcolor{keyword}{allocate}(ry\_tang\_rad(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2809          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2810            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2811              ry\_tang\_rad(segment\%HI\%IsdB,j,k) = segment\%ry\_norm\_rad(segment\%HI\%isd,j,k)}
\DoxyCodeLine{2812              ry\_tang\_rad(segment\%HI\%IedB,j,k) = segment\%ry\_norm\_rad(segment\%HI\%ied,j,k)}
\DoxyCodeLine{2813              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{2814                ry\_tang\_rad(i,j,k) = 0.5*(segment\%ry\_norm\_rad(i,j,k) + segment\%ry\_norm\_rad(i+1,j,k))}
\DoxyCodeLine{2815 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2816            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2817              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2818                dhdt = u\_old(i,j-\/1,k)-\/u\_new(i,j-\/1,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2819                dhdy = u\_new(i,j-\/1,k)-\/u\_new(i,j-\/2,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2820                ry\_tang\_rad(i,j,k) = 0.0}
\DoxyCodeLine{2821                \textcolor{keywordflow}{if} (dhdt*dhdy > 0.0) ry\_tang\_rad(i,j,k) = min( (dhdt/dhdy), rx\_max) \textcolor{comment}{! outward phase speed}}
\DoxyCodeLine{2822 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2823 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2824 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2825          \textcolor{keywordflow}{if} (segment\%radiation\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2826            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2827              ry\_avg = ry\_tang\_rad(i,j,k)}
\DoxyCodeLine{2828              segment\%tangential\_vel(i,j,k) = (u\_new(i,j,k) + ry\_avg*u\_new(i,j-\/1,k)) / (1.0+ry\_avg)}
\DoxyCodeLine{2829 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2830 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2831          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2832            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2833              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2834              \textcolor{keywordflow}{if} (ry\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2835                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2836              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2837                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2838 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2839              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2840              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2841                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2842 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2843 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2844          \textcolor{keywordflow}{if} (segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2845            is\_obc = max(segment\%HI\%IsdB,g\%isd+1)}
\DoxyCodeLine{2846            ie\_obc = min(segment\%HI\%IedB,g\%ied-\/1)}
\DoxyCodeLine{2847            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=is\_obc,ie\_obc}
\DoxyCodeLine{2848              ry\_avg = ry\_tang\_rad(i,j,k)}
\DoxyCodeLine{2849 \textcolor{comment}{!            if (G\%mask2dCv(i,J-\/1) > 0.0 .and. G\%mask2dCv(i+1,J-\/1) > 0.0) then}}
\DoxyCodeLine{2850 \textcolor{comment}{!              ry\_avg = 0.5*(v\_new(i,J-\/1,k) + v\_new(i+1,J-\/1,k) * dt * G\%IdyBu(I,J-\/1))}}
\DoxyCodeLine{2851 \textcolor{comment}{!            elseif (G\%mask2dCv(i,J-\/1) > 0.0) then}}
\DoxyCodeLine{2852 \textcolor{comment}{!              ry\_avg = v\_new(i,J-\/1,k) * dt *G\%IdyBu(I,J-\/1)}}
\DoxyCodeLine{2853 \textcolor{comment}{!            elseif (G\%mask2dCv(i+1,J-\/1) > 0.0) then}}
\DoxyCodeLine{2854 \textcolor{comment}{!              ry\_avg = v\_new(i+1,J-\/1,k) * dt *G\%IdyBu(I,J-\/1)}}
\DoxyCodeLine{2855 \textcolor{comment}{!            else}}
\DoxyCodeLine{2856 \textcolor{comment}{!              ry\_avg = 0.0}}
\DoxyCodeLine{2857 \textcolor{comment}{!            endif}}
\DoxyCodeLine{2858              segment\%tangential\_grad(i,j,k) = ((u\_new(i,j,k) -\/ u\_new(i,j-\/1,k))*g\%IdyBu(i,j-\/1) + \&}
\DoxyCodeLine{2859                                ry\_avg*(u\_new(i,j-\/1,k) -\/ u\_new(i,j-\/2,k))*g\%IdyBu(i,j-\/2)) / (1.0+ry\_avg)}
\DoxyCodeLine{2860 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2861 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2862          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2863            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2864              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2865              \textcolor{keywordflow}{if} (ry\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2866                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2867              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2868                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2869 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2870              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2871              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2872                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2873 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2874 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2875          \textcolor{keyword}{deallocate}(ry\_tang\_rad)}
\DoxyCodeLine{2876 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2877        \textcolor{keywordflow}{if} (segment\%oblique\_tan .or. segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2878          j=segment\%HI\%JsdB}
\DoxyCodeLine{2879          \textcolor{keyword}{allocate}(rx\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2880          \textcolor{keyword}{allocate}(ry\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2881          \textcolor{keyword}{allocate}(cff\_tangential(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{2882          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{2883            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2884              rx\_tang\_obl(segment\%HI\%IsdB,j,k) = segment\%rx\_norm\_obl(segment\%HI\%isd,j,k)}
\DoxyCodeLine{2885              rx\_tang\_obl(segment\%HI\%IedB,j,k) = segment\%rx\_norm\_obl(segment\%HI\%ied,j,k)}
\DoxyCodeLine{2886              ry\_tang\_obl(segment\%HI\%IsdB,j,k) = segment\%ry\_norm\_obl(segment\%HI\%isd,j,k)}
\DoxyCodeLine{2887              ry\_tang\_obl(segment\%HI\%IedB,j,k) = segment\%ry\_norm\_obl(segment\%HI\%ied,j,k)}
\DoxyCodeLine{2888              cff\_tangential(segment\%HI\%IsdB,j,k) = segment\%cff\_normal(segment\%HI\%isd,j,k)}
\DoxyCodeLine{2889              cff\_tangential(segment\%HI\%IedB,j,k) = segment\%cff\_normal(segment\%HI\%ied,j,k)}
\DoxyCodeLine{2890              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{2891                rx\_tang\_obl(i,j,k) = 0.5*(segment\%rx\_norm\_obl(i,j,k) + segment\%rx\_norm\_obl(i+1,j,k))}
\DoxyCodeLine{2892                ry\_tang\_obl(i,j,k) = 0.5*(segment\%ry\_norm\_obl(i,j,k) + segment\%ry\_norm\_obl(i+1,j,k))}
\DoxyCodeLine{2893                cff\_tangential(i,j,k) = 0.5*(segment\%cff\_normal(i,j,k) + segment\%cff\_normal(i+1,j,k))}
\DoxyCodeLine{2894 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2895            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2896              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2897                dhdt = u\_old(i,j,k)-\/u\_new(i,j,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2898                dhdy = u\_new(i,j,k)-\/u\_new(i,j-\/1,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{2899                \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_tan(i,1,k) + segment\%grad\_tan(i+1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2900                  dhdx = segment\%grad\_tan(i,1,k)}
\DoxyCodeLine{2901                \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_tan(i,1,k) + segment\%grad\_tan(i+1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2902                  dhdx = 0.0}
\DoxyCodeLine{2903                \textcolor{keywordflow}{else}}
\DoxyCodeLine{2904                  dhdx = segment\%grad\_tan(i+1,1,k)}
\DoxyCodeLine{2905 \textcolor{keywordflow}{               endif}}
\DoxyCodeLine{2906                \textcolor{keywordflow}{if} (dhdt*dhdy < 0.0) dhdt = 0.0}
\DoxyCodeLine{2907                cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{2908                ry\_new = min(dhdt*dhdy, cff\_new*ry\_max)}
\DoxyCodeLine{2909                rx\_new = min(cff\_new,max(dhdt*dhdx,-\/cff\_new))}
\DoxyCodeLine{2910                rx\_tang\_obl(i,j,k) = rx\_new}
\DoxyCodeLine{2911                ry\_tang\_obl(i,j,k) = ry\_new}
\DoxyCodeLine{2912                cff\_tangential(i,j,k) = cff\_new}
\DoxyCodeLine{2913 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{2914 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2915 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{2916          \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2917            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2918              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2919              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2920              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2921              segment\%tangential\_vel(i,j,k) = ((cff\_avg*u\_new(i,j,k) + ry\_avg*u\_new(i,j-\/1,k)) -\/ \&}
\DoxyCodeLine{2922                                               (max(rx\_avg,0.0)*segment\%grad\_tan(i,2,k) + \&}
\DoxyCodeLine{2923                                                min(rx\_avg,0.0)*segment\%grad\_tan(i+1,2,k))) / \&}
\DoxyCodeLine{2924                                              (cff\_avg + ry\_avg)}
\DoxyCodeLine{2925 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2926 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2927          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2928            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2929              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2930              \textcolor{keywordflow}{if} (ry\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2931                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2932              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2933                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2934 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2935              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2936              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{2937                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{2938 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2939 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2940          \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2941            is\_obc = max(segment\%HI\%IsdB,g\%isd+1)}
\DoxyCodeLine{2942            ie\_obc = min(segment\%HI\%IedB,g\%ied-\/1)}
\DoxyCodeLine{2943            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{2944              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{2945              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{2946              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{2947              segment\%tangential\_grad(i,j,k) =  \&}
\DoxyCodeLine{2948                  ((cff\_avg*(u\_new(i,j,k)   -\/ u\_new(i,j-\/1,k))*g\%IdyBu(i,j-\/1) + \&}
\DoxyCodeLine{2949                     ry\_avg*(u\_new(i,j-\/1,k) -\/ u\_new(i,j-\/2,k))*g\%IdyBu(i,j-\/2)) -\/ \&}
\DoxyCodeLine{2950                                   (max(rx\_avg,0.0)*segment\%grad\_gradient(i,2,k) + \&}
\DoxyCodeLine{2951                                    min(rx\_avg,0.0)*segment\%grad\_gradient(i+1,2,k))) / \&}
\DoxyCodeLine{2952                                  (cff\_avg + ry\_avg)}
\DoxyCodeLine{2953 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2954 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2955          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2956            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{2957              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{2958              \textcolor{keywordflow}{if} (ry\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2959                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{2960              \textcolor{keywordflow}{else}}
\DoxyCodeLine{2961                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{2962 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{2963              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{2964              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{2965                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{2966 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{2967 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{2968          \textcolor{keyword}{deallocate}(rx\_tang\_obl)}
\DoxyCodeLine{2969          \textcolor{keyword}{deallocate}(ry\_tang\_obl)}
\DoxyCodeLine{2970          \textcolor{keyword}{deallocate}(cff\_tangential)}
\DoxyCodeLine{2971 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{2972 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{2973 }
\DoxyCodeLine{2974      \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2975        j=segment\%HI\%JsdB}
\DoxyCodeLine{2976        \textcolor{keywordflow}{if} (j>g\%HI\%JecB) cycle}
\DoxyCodeLine{2977        \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2978          \textcolor{keywordflow}{if} (segment\%radiation) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2979            dhdt = (v\_old(i,j+1,k) -\/ v\_new(i,j+1,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{2980            dhdy = (v\_new(i,j+1,k) -\/ v\_new(i,j+2,k)) \textcolor{comment}{!in new time backward sasha for J-\/1}}
\DoxyCodeLine{2981            ry\_new = 0.0}
\DoxyCodeLine{2982            \textcolor{keywordflow}{if} (dhdt*dhdy > 0.0) ry\_new = min( (dhdt/dhdy), ry\_max)}
\DoxyCodeLine{2983            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2984              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_rad(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{2985            \textcolor{keywordflow}{else}}
\DoxyCodeLine{2986              ry\_avg = ry\_new}
\DoxyCodeLine{2987 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2988            segment\%ry\_norm\_rad(i,j,k) = ry\_avg}
\DoxyCodeLine{2989            \textcolor{comment}{! The new boundary value is interpolated between future interior}}
\DoxyCodeLine{2990            \textcolor{comment}{! value, v\_new(J+1) and past boundary value but with barotropic}}
\DoxyCodeLine{2991            \textcolor{comment}{! accelerations, v\_new(J).}}
\DoxyCodeLine{2992            segment\%normal\_vel(i,j,k) = (v\_new(i,j,k) + ry\_avg*v\_new(i,j+1,k)) / (1.0+ry\_avg)}
\DoxyCodeLine{2993            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2994              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{2995              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{2996              obc\%ry\_normal(i,j,k) = segment\%ry\_norm\_rad(i,j,k)}
\DoxyCodeLine{2997 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{2998          \textcolor{keywordflow}{elseif} (segment\%oblique) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2999            dhdt = (v\_old(i,j+1,k) -\/ v\_new(i,j+1,k)) \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{3000            dhdy = (v\_new(i,j+1,k) -\/ v\_new(i,j+2,k)) \textcolor{comment}{!in new time backward sasha for J-\/1}}
\DoxyCodeLine{3001            \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_normal(i,1,k) + segment\%grad\_normal(i-\/1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3002              dhdx = segment\%grad\_normal(i-\/1,1,k)}
\DoxyCodeLine{3003            \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_normal(i,1,k) + segment\%grad\_normal(i-\/1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3004              dhdx = 0.0}
\DoxyCodeLine{3005            \textcolor{keywordflow}{else}}
\DoxyCodeLine{3006              dhdx = segment\%grad\_normal(i,1,k)}
\DoxyCodeLine{3007 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3008            \textcolor{keywordflow}{if} (dhdt*dhdy < 0.0) dhdt = 0.0}
\DoxyCodeLine{3009 }
\DoxyCodeLine{3010            cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{3011            ry\_new = min(dhdt*dhdy, cff\_new*ry\_max)}
\DoxyCodeLine{3012            rx\_new = min(cff\_new,max(dhdt*dhdx,-\/cff\_new))}
\DoxyCodeLine{3013            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3014              rx\_avg = (1.0-\/gamma\_u)*segment\%rx\_norm\_obl(i,j,k) + gamma\_u*rx\_new}
\DoxyCodeLine{3015              ry\_avg = (1.0-\/gamma\_u)*segment\%ry\_norm\_obl(i,j,k) + gamma\_u*ry\_new}
\DoxyCodeLine{3016              cff\_avg = (1.0-\/gamma\_u)*segment\%cff\_normal(i,j,k) + gamma\_u*cff\_new}
\DoxyCodeLine{3017            \textcolor{keywordflow}{else}}
\DoxyCodeLine{3018              rx\_avg = rx\_new}
\DoxyCodeLine{3019              ry\_avg = ry\_new}
\DoxyCodeLine{3020              cff\_avg = cff\_new}
\DoxyCodeLine{3021 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3022            segment\%rx\_norm\_obl(i,j,k) = rx\_avg}
\DoxyCodeLine{3023            segment\%ry\_norm\_obl(i,j,k) = ry\_avg}
\DoxyCodeLine{3024            segment\%cff\_normal(i,j,k) = cff\_avg}
\DoxyCodeLine{3025            segment\%normal\_vel(i,j,k) = ((cff\_avg*v\_new(i,j,k) + ry\_avg*v\_new(i,j+1,k)) -\/ \&}
\DoxyCodeLine{3026                                         (max(rx\_avg,0.0)*segment\%grad\_normal(i-\/1,2,k) + \&}
\DoxyCodeLine{3027                                          min(rx\_avg,0.0)*segment\%grad\_normal(i,2,k))) / \&}
\DoxyCodeLine{3028                                        (cff\_avg + ry\_avg)}
\DoxyCodeLine{3029            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3030              \textcolor{comment}{! Copy restart fields into 3-\/d arrays. This is an inefficient and temporary issues}}
\DoxyCodeLine{3031              \textcolor{comment}{! implemented as a work-\/around to limitations in restart capability}}
\DoxyCodeLine{3032              obc\%rx\_oblique(i,j,k) = segment\%rx\_norm\_obl(i,j,k)}
\DoxyCodeLine{3033              obc\%ry\_oblique(i,j,k) = segment\%ry\_norm\_obl(i,j,k)}
\DoxyCodeLine{3034              obc\%cff\_normal(i,j,k) = segment\%cff\_normal(i,j,k)}
\DoxyCodeLine{3035 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3036          \textcolor{keywordflow}{elseif} (segment\%gradient) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3037            segment\%normal\_vel(i,j,k) = v\_new(i,j+1,k)}
\DoxyCodeLine{3038 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3039          \textcolor{keywordflow}{if} ((segment\%radiation .or. segment\%oblique) .and. segment\%nudged) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3040            \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{3041            \textcolor{keywordflow}{if} (dhdt*dhdy <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3042              tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{3043            \textcolor{keywordflow}{else}}
\DoxyCodeLine{3044              tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{3045 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3046            gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{3047            segment\%normal\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%normal\_vel(i,j,k) + \&}
\DoxyCodeLine{3048                                  gamma\_2 * segment\%nudged\_normal\_vel(i,j,k)}
\DoxyCodeLine{3049 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3050 \textcolor{keywordflow}{       enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3051        \textcolor{keywordflow}{if} (segment\%radiation\_tan .or. segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3052          j=segment\%HI\%JsdB}
\DoxyCodeLine{3053          \textcolor{keyword}{allocate}(ry\_tang\_rad(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{3054          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{3055            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3056              ry\_tang\_rad(segment\%HI\%IsdB,j,k) = segment\%ry\_norm\_rad(segment\%HI\%isd,j,k)}
\DoxyCodeLine{3057              ry\_tang\_rad(segment\%HI\%IedB,j,k) = segment\%ry\_norm\_rad(segment\%HI\%ied,j,k)}
\DoxyCodeLine{3058              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{3059                ry\_tang\_rad(i,j,k) = 0.5*(segment\%ry\_norm\_rad(i,j,k) + segment\%ry\_norm\_rad(i+1,j,k))}
\DoxyCodeLine{3060 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{3061            \textcolor{keywordflow}{else}}
\DoxyCodeLine{3062              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3063                dhdt = u\_old(i,j+1,k)-\/u\_new(i,j+1,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{3064                dhdy = u\_new(i,j+1,k)-\/u\_new(i,j+2,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{3065                ry\_tang\_rad(i,j,k) = 0.0}
\DoxyCodeLine{3066                \textcolor{keywordflow}{if} (dhdt*dhdy > 0.0) ry\_tang\_rad(i,j,k) = min( (dhdt/dhdy), rx\_max) \textcolor{comment}{! outward phase speed}}
\DoxyCodeLine{3067 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{3068 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3069 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{3070          \textcolor{keywordflow}{if} (segment\%radiation\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3071            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3072              ry\_avg = ry\_tang\_rad(i,j,k)}
\DoxyCodeLine{3073              segment\%tangential\_vel(i,j,k) = (u\_new(i,j+1,k) + ry\_avg*u\_new(i,j+2,k)) / (1.0+ry\_avg)}
\DoxyCodeLine{3074 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3075 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3076          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3077            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3078              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{3079              \textcolor{keywordflow}{if} (ry\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3080                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{3081              \textcolor{keywordflow}{else}}
\DoxyCodeLine{3082                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{3083 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{3084              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{3085              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{3086                                  gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{3087 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3088 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3089          \textcolor{keywordflow}{if} (segment\%radiation\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3090            is\_obc = max(segment\%HI\%IsdB,g\%isd+1)}
\DoxyCodeLine{3091            ie\_obc = min(segment\%HI\%IedB,g\%ied-\/1)}
\DoxyCodeLine{3092            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=is\_obc,ie\_obc}
\DoxyCodeLine{3093              ry\_avg = ry\_tang\_rad(i,j,k)}
\DoxyCodeLine{3094 \textcolor{comment}{!            if (G\%mask2dCv(i,J+1) > 0.0 .and. G\%mask2dCv(i+1,J+1) > 0.0) then}}
\DoxyCodeLine{3095 \textcolor{comment}{!              ry\_avg = 0.5*(v\_new(i,J+1,k) + v\_new(i+1,J+1,k)) * dt * G\%IdyBu(I,J+1)}}
\DoxyCodeLine{3096 \textcolor{comment}{!            elseif (G\%mask2dCv(i,J+1) > 0.0) then}}
\DoxyCodeLine{3097 \textcolor{comment}{!              ry\_avg = v\_new(i,J+1,k) * dt * G\%IdyBu(I,J+1)}}
\DoxyCodeLine{3098 \textcolor{comment}{!            elseif (G\%mask2dCv(i+1,J+1) > 0.0) then}}
\DoxyCodeLine{3099 \textcolor{comment}{!              ry\_avg = v\_new(i+1,J+1,k) * dt * G\%IdyBu(I,J+1)}}
\DoxyCodeLine{3100 \textcolor{comment}{!            else}}
\DoxyCodeLine{3101 \textcolor{comment}{!              ry\_avg = 0.0}}
\DoxyCodeLine{3102 \textcolor{comment}{!            endif}}
\DoxyCodeLine{3103              segment\%tangential\_grad(i,j,k) = ((u\_new(i,j+2,k) -\/ u\_new(i,j+1,k))*g\%IdyBu(i,j+1) + \&}
\DoxyCodeLine{3104                                ry\_avg*(u\_new(i,j+3,k) -\/ u\_new(i,j+2,k))*g\%IdyBu(i,j+2)) / (1.0+ry\_avg)}
\DoxyCodeLine{3105 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3106 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3107          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3108            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3109              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{3110              \textcolor{keywordflow}{if} (ry\_tang\_rad(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3111                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{3112              \textcolor{keywordflow}{else}}
\DoxyCodeLine{3113                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{3114 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{3115              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{3116              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{3117                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{3118 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3119 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3120          \textcolor{keyword}{deallocate}(ry\_tang\_rad)}
\DoxyCodeLine{3121 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{3122        \textcolor{keywordflow}{if} (segment\%oblique\_tan .or. segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3123          j=segment\%HI\%JsdB}
\DoxyCodeLine{3124          \textcolor{keyword}{allocate}(rx\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{3125          \textcolor{keyword}{allocate}(ry\_tang\_obl(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{3126          \textcolor{keyword}{allocate}(cff\_tangential(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%JsdB:segment\%HI\%JedB,nz))}
\DoxyCodeLine{3127          \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{3128            \textcolor{keywordflow}{if} (gamma\_u < 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3129              rx\_tang\_obl(segment\%HI\%IsdB,j,k) = segment\%rx\_norm\_obl(segment\%HI\%isd,j,k)}
\DoxyCodeLine{3130              rx\_tang\_obl(segment\%HI\%IedB,j,k) = segment\%rx\_norm\_obl(segment\%HI\%ied,j,k)}
\DoxyCodeLine{3131              ry\_tang\_obl(segment\%HI\%IsdB,j,k) = segment\%ry\_norm\_obl(segment\%HI\%isd,j,k)}
\DoxyCodeLine{3132              ry\_tang\_obl(segment\%HI\%IedB,j,k) = segment\%ry\_norm\_obl(segment\%HI\%ied,j,k)}
\DoxyCodeLine{3133              cff\_tangential(segment\%HI\%IsdB,j,k) = segment\%cff\_normal(segment\%HI\%isd,j,k)}
\DoxyCodeLine{3134              cff\_tangential(segment\%HI\%IedB,j,k) = segment\%cff\_normal(segment\%HI\%ied,j,k)}
\DoxyCodeLine{3135              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{3136                rx\_tang\_obl(i,j,k) = 0.5*(segment\%rx\_norm\_obl(i,j,k) + segment\%rx\_norm\_obl(i+1,j,k))}
\DoxyCodeLine{3137                ry\_tang\_obl(i,j,k) = 0.5*(segment\%ry\_norm\_obl(i,j,k) + segment\%ry\_norm\_obl(i+1,j,k))}
\DoxyCodeLine{3138                cff\_tangential(i,j,k) = 0.5*(segment\%cff\_normal(i,j,k) + segment\%cff\_normal(i+1,j,k))}
\DoxyCodeLine{3139 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{3140            \textcolor{keywordflow}{else}}
\DoxyCodeLine{3141              \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3142                dhdt = u\_old(i,j+1,k)-\/u\_new(i,j+1,k)   \textcolor{comment}{!old-\/new}}
\DoxyCodeLine{3143                dhdy = u\_new(i,j+1,k)-\/u\_new(i,j+2,k) \textcolor{comment}{!in new time backward sasha for I-\/1}}
\DoxyCodeLine{3144                \textcolor{keywordflow}{if} (dhdt*(segment\%grad\_tan(i,1,k) + segment\%grad\_tan(i+1,1,k)) > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3145                  dhdx = segment\%grad\_tan(i,1,k)}
\DoxyCodeLine{3146                \textcolor{keywordflow}{elseif} (dhdt*(segment\%grad\_tan(i,1,k) + segment\%grad\_tan(i+1,1,k)) == 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3147                  dhdx = 0.0}
\DoxyCodeLine{3148                \textcolor{keywordflow}{else}}
\DoxyCodeLine{3149                  dhdx = segment\%grad\_tan(i+1,1,k)}
\DoxyCodeLine{3150 \textcolor{keywordflow}{               endif}}
\DoxyCodeLine{3151                \textcolor{keywordflow}{if} (dhdt*dhdy < 0.0) dhdt = 0.0}
\DoxyCodeLine{3152                cff\_new = max(dhdx*dhdx + dhdy*dhdy, eps)}
\DoxyCodeLine{3153                ry\_new = min(dhdt*dhdy, cff\_new*ry\_max)}
\DoxyCodeLine{3154                rx\_new = min(cff\_new,max(dhdt*dhdx,-\/cff\_new))}
\DoxyCodeLine{3155                rx\_tang\_obl(i,j,k) = rx\_new}
\DoxyCodeLine{3156                ry\_tang\_obl(i,j,k) = ry\_new}
\DoxyCodeLine{3157                cff\_tangential(i,j,k) = cff\_new}
\DoxyCodeLine{3158 \textcolor{keywordflow}{             enddo}}
\DoxyCodeLine{3159 \textcolor{keywordflow}{           endif}}
\DoxyCodeLine{3160 \textcolor{keywordflow}{         enddo}}
\DoxyCodeLine{3161          \textcolor{keywordflow}{if} (segment\%oblique\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3162            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3163              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{3164              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{3165              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{3166              segment\%tangential\_vel(i,j,k) = ((cff\_avg*u\_new(i,j+1,k) + ry\_avg*u\_new(i,j+2,k)) -\/ \&}
\DoxyCodeLine{3167                                               (max(rx\_avg,0.0)*segment\%grad\_tan(i,2,k) + \&}
\DoxyCodeLine{3168                                                min(rx\_avg,0.0)*segment\%grad\_tan(i+1,2,k)) ) / \&}
\DoxyCodeLine{3169                                              (cff\_avg + ry\_avg)}
\DoxyCodeLine{3170 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3171 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3172          \textcolor{keywordflow}{if} (segment\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3173            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} i=segment\%HI\%IsdB,segment\%HI\%IedB}
\DoxyCodeLine{3174              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{3175              \textcolor{keywordflow}{if} (ry\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3176                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{3177              \textcolor{keywordflow}{else}}
\DoxyCodeLine{3178                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{3179 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{3180              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{3181              segment\%tangential\_vel(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_vel(i,j,k) + \&}
\DoxyCodeLine{3182                                              gamma\_2 * segment\%nudged\_tangential\_vel(i,j,k)}
\DoxyCodeLine{3183 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3184 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3185          \textcolor{keywordflow}{if} (segment\%oblique\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3186            is\_obc = max(segment\%HI\%IsdB,g\%isd+1)}
\DoxyCodeLine{3187            ie\_obc = min(segment\%HI\%IedB,g\%ied-\/1)}
\DoxyCodeLine{3188            \textcolor{keywordflow}{do} k=1,nz ;  \textcolor{keywordflow}{do} i=segment\%HI\%IsdB+1,segment\%HI\%IedB-\/1}
\DoxyCodeLine{3189              rx\_avg = rx\_tang\_obl(i,j,k)}
\DoxyCodeLine{3190              ry\_avg = ry\_tang\_obl(i,j,k)}
\DoxyCodeLine{3191              cff\_avg = cff\_tangential(i,j,k)}
\DoxyCodeLine{3192              segment\%tangential\_grad(i,j,k) = \&}
\DoxyCodeLine{3193                  ((cff\_avg*(u\_new(i,j+2,k) -\/ u\_new(i,j+1,k))*g\%IdyBu(i,j+1) + \&}
\DoxyCodeLine{3194                     ry\_avg*(u\_new(i,j+3,k) -\/ u\_new(i,j+2,k))*g\%IdyBu(i,j+2)) -\/ \&}
\DoxyCodeLine{3195                                   (max(rx\_avg,0.0)*segment\%grad\_gradient(i,2,k) + \&}
\DoxyCodeLine{3196                                    min(rx\_avg,0.0)*segment\%grad\_gradient(i+1,2,k))) / \&}
\DoxyCodeLine{3197                                  (cff\_avg + ry\_avg)}
\DoxyCodeLine{3198 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3199 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3200          \textcolor{keywordflow}{if} (segment\%nudged\_grad) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3201            \textcolor{keywordflow}{do} k=1,nz ; \textcolor{keywordflow}{do} j=segment\%HI\%JsdB,segment\%HI\%JedB}
\DoxyCodeLine{3202              \textcolor{comment}{! dhdt gets set to 0 on inflow in oblique case}}
\DoxyCodeLine{3203              \textcolor{keywordflow}{if} (ry\_tang\_obl(i,j,k) <= 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3204                tau = segment\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{3205              \textcolor{keywordflow}{else}}
\DoxyCodeLine{3206                tau = segment\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{3207 \textcolor{keywordflow}{             endif}}
\DoxyCodeLine{3208              gamma\_2 = dt / (tau + dt)}
\DoxyCodeLine{3209              segment\%tangential\_grad(i,j,k) = (1.0 -\/ gamma\_2) * segment\%tangential\_grad(i,j,k) + \&}
\DoxyCodeLine{3210                                  gamma\_2 * segment\%nudged\_tangential\_grad(i,j,k)}
\DoxyCodeLine{3211 \textcolor{keywordflow}{           enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3212 \textcolor{keywordflow}{         endif}}
\DoxyCodeLine{3213          \textcolor{keyword}{deallocate}(rx\_tang\_obl)}
\DoxyCodeLine{3214          \textcolor{keyword}{deallocate}(ry\_tang\_obl)}
\DoxyCodeLine{3215          \textcolor{keyword}{deallocate}(cff\_tangential)}
\DoxyCodeLine{3216 \textcolor{keywordflow}{       endif}}
\DoxyCodeLine{3217 \textcolor{keywordflow}{     endif}}
\DoxyCodeLine{3218 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{3219 }
\DoxyCodeLine{3220   \textcolor{comment}{! Actually update u\_new, v\_new}}
\DoxyCodeLine{3221   \textcolor{keyword}{call }open\_boundary\_apply\_normal\_flow(obc, g, u\_new, v\_new)}
\DoxyCodeLine{3222 }
\DoxyCodeLine{3223   \textcolor{keyword}{call }pass\_vector(u\_new, v\_new, g\%Domain, clock=id\_clock\_pass)}
\DoxyCodeLine{3224 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a05d15beca2ef2b44fb36d129166907fa}\label{namespacemom__open__boundary_a05d15beca2ef2b44fb36d129166907fa}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!register\_file\_obc@{register\_file\_obc}}
\index{register\_file\_obc@{register\_file\_obc}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{register\_file\_obc()}{register\_file\_obc()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+open\+\_\+boundary\+::register\+\_\+file\+\_\+obc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1file__obc__cs}{file\+\_\+obc\+\_\+cs}}), pointer}]{CS,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__registry__type}{obc\+\_\+registry\+\_\+type}}), pointer}]{O\+B\+C\+\_\+\+Reg }\end{DoxyParamCaption})}



Add file to O\+BC registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & parameter file. \\
\hline
 & {\em cs} & file control structure. \\
\hline
 & {\em obc\+\_\+reg} & O\+BC registry. \\
\hline
\end{DoxyParams}


Definition at line 4465 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4466   \textcolor{keywordtype}{type}(param\_file\_type),    \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< parameter file.}}
\DoxyCodeLine{4467   \textcolor{keywordtype}{type}(file\_OBC\_CS),        \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< file control structure.}}
\DoxyCodeLine{4468   \textcolor{keywordtype}{type}(OBC\_registry\_type),  \textcolor{keywordtype}{pointer}    :: OBC\_Reg\textcolor{comment}{    !< OBC registry.}}
\DoxyCodeLine{4469   \textcolor{keywordtype}{logical}                              :: register\_file\_OBC}
\DoxyCodeLine{4470   \textcolor{keywordtype}{character(len=32)}  :: casename = \textcolor{stringliteral}{"{}OBC file"{}}\textcolor{comment}{        !< This case's name.}}
\DoxyCodeLine{4471 }
\DoxyCodeLine{4472   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4473     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"{}register\_file\_OBC called with an "{}}// \&}
\DoxyCodeLine{4474                             \textcolor{stringliteral}{"{}associated control structure."{}})}
\DoxyCodeLine{4475     \textcolor{keywordflow}{return}}
\DoxyCodeLine{4476 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4477   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{4478 }
\DoxyCodeLine{4479   \textcolor{comment}{! Register the file for boundary updates.}}
\DoxyCodeLine{4480   \textcolor{keyword}{call }register\_obc(casename, param\_file, obc\_reg)}
\DoxyCodeLine{4481   register\_file\_obc = .true.}
\DoxyCodeLine{4482 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a8e0e22d829c122134f039228c6f1c7fb}\label{namespacemom__open__boundary_a8e0e22d829c122134f039228c6f1c7fb}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!register\_obc@{register\_obc}}
\index{register\_obc@{register\_obc}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{register\_obc()}{register\_obc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::register\+\_\+obc (\begin{DoxyParamCaption}\item[{character(len=32), intent(in)}]{name,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__registry__type}{obc\+\_\+registry\+\_\+type}}), pointer}]{Reg }\end{DoxyParamCaption})}



register open boundary objects for boundary updates. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em name} & O\+BC name used for error messages \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & file to parse for model parameter values \\
\hline
 & {\em reg} & pointer to the tracer registry \\
\hline
\end{DoxyParams}


Definition at line 4413 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4414   \textcolor{keywordtype}{character(len=32)},     \textcolor{keywordtype}{intent(in)}  :: name\textcolor{comment}{        !< OBC name used for error messages}}
\DoxyCodeLine{4415   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{  !< file to parse for  model parameter values}}
\DoxyCodeLine{4416   \textcolor{keywordtype}{type}(OBC\_registry\_type), \textcolor{keywordtype}{pointer}   :: Reg\textcolor{comment}{         !< pointer to the tracer registry}}
\DoxyCodeLine{4417   \textcolor{keywordtype}{integer} :: nobc}
\DoxyCodeLine{4418   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{4419 }
\DoxyCodeLine{4420   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(reg)) \textcolor{keyword}{call }obc\_registry\_init(param\_file, reg)}
\DoxyCodeLine{4421 }
\DoxyCodeLine{4422   \textcolor{keywordflow}{if} (reg\%nobc>=max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4423     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}Increase MAX\_FIELDS\_ in MOM\_memory.h to at least "{},I3,"{} to allow for \&}}
\DoxyCodeLine{4424 \textcolor{stringliteral}{}\textcolor{stringliteral}{        \&all the open boundaries being registered via register\_OBC."{})'}) reg\%nobc+1}
\DoxyCodeLine{4425     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}MOM register\_tracer: "{}}//mesg)}
\DoxyCodeLine{4426 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4427   reg\%nobc = reg\%nobc + 1}
\DoxyCodeLine{4428   nobc     = reg\%nobc}
\DoxyCodeLine{4429 }
\DoxyCodeLine{4430   reg\%OB(nobc)\%name = name}
\DoxyCodeLine{4431 }
\DoxyCodeLine{4432   \textcolor{keywordflow}{if} (reg\%locked) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{4433       \textcolor{stringliteral}{"{}MOM register\_tracer was called for variable "{}}//trim(reg\%OB(nobc)\%name)//\&}
\DoxyCodeLine{4434       \textcolor{stringliteral}{"{} with a locked tracer registry."{}})}
\DoxyCodeLine{4435 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a5d5843dd1a4e1475f69b5eb2c5b0197d}\label{namespacemom__open__boundary_a5d5843dd1a4e1475f69b5eb2c5b0197d}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!register\_segment\_tracer@{register\_segment\_tracer}}
\index{register\_segment\_tracer@{register\_segment\_tracer}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{register\_segment\_tracer()}{register\_segment\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::register\+\_\+segment\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__type}{tracer\+\_\+type}}), target}]{tr\+\_\+ptr,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment,  }\item[{real, intent(in), optional}]{O\+B\+C\+\_\+scalar,  }\item[{logical, intent(in), optional}]{O\+B\+C\+\_\+array }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure\\
\hline
 & {\em tr\+\_\+ptr} & A target that can be used to set a pointer to the stored value of tr. This target must be an enduring part of the control structure, because the tracer registry will use this memory, but it also means that any updates to this structure in the calling module will be available subsequently to the tracer registry.\\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & file to parse for model parameter values\\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & current segment data structure\\
\hline
\mbox{\texttt{ in}}  & {\em obc\+\_\+scalar} & If present, use scalar value for segment tracer inflow concentration.\\
\hline
\mbox{\texttt{ in}}  & {\em obc\+\_\+array} & If true, use array values for segment tracer inflow concentration. \\
\hline
\end{DoxyParams}


Definition at line 4526 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4528   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}   :: GV\textcolor{comment}{         !< ocean vertical grid structure}}
\DoxyCodeLine{4529   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{target}             :: tr\_ptr\textcolor{comment}{     !< A target that can be used to set a pointer to the}}
\DoxyCodeLine{4530 \textcolor{comment}{                                                      !! stored value of tr. This target must be}}
\DoxyCodeLine{4531 \textcolor{comment}{                                                      !! an enduring part of the control structure,}}
\DoxyCodeLine{4532 \textcolor{comment}{                                                      !! because the tracer registry will use this memory,}}
\DoxyCodeLine{4533 \textcolor{comment}{                                                      !! but it also means that any updates to this}}
\DoxyCodeLine{4534 \textcolor{comment}{                                                      !! structure in the calling module will be}}
\DoxyCodeLine{4535 \textcolor{comment}{                                                      !! available subsequently to the tracer registry.}}
\DoxyCodeLine{4536   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}     :: param\_file\textcolor{comment}{ !< file to parse for  model parameter values}}
\DoxyCodeLine{4537   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)} :: segment\textcolor{comment}{    !< current segment data structure}}
\DoxyCodeLine{4538 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}            :: OBC\_scalar\textcolor{comment}{ !< If present, use scalar value for segment tracer}}
\DoxyCodeLine{4539 \textcolor{comment}{                                                      !! inflow concentration.}}
\DoxyCodeLine{4540   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}         :: OBC\_array\textcolor{comment}{  !< If true, use array values for segment tracer}}
\DoxyCodeLine{4541 \textcolor{comment}{                                                      !! inflow concentration.}}
\DoxyCodeLine{4542 }
\DoxyCodeLine{4543 }
\DoxyCodeLine{4544 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4545   \textcolor{keywordtype}{integer} :: ntseg}
\DoxyCodeLine{4546   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{4547   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{4548   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{4549 }
\DoxyCodeLine{4550   \textcolor{keyword}{call }segment\_tracer\_registry\_init(param\_file, segment)}
\DoxyCodeLine{4551 }
\DoxyCodeLine{4552   \textcolor{keywordflow}{if} (segment\%tr\_Reg\%ntseg>=max\_fields\_) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4553     \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("{}Increase MAX\_FIELDS\_ in MOM\_memory.h to at least "{},I3,"{} to allow for \&}}
\DoxyCodeLine{4554 \textcolor{stringliteral}{}\textcolor{stringliteral}{        \&all the tracers being registered via register\_tracer."{})'}) segment\%tr\_Reg\%ntseg+1}
\DoxyCodeLine{4555     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}MOM register\_tracer: "{}}//mesg)}
\DoxyCodeLine{4556 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4557   segment\%tr\_Reg\%ntseg = segment\%tr\_Reg\%ntseg + 1}
\DoxyCodeLine{4558   ntseg     = segment\%tr\_Reg\%ntseg}
\DoxyCodeLine{4559 }
\DoxyCodeLine{4560   isd = segment\%HI\%isd ; ied = segment\%HI\%ied}
\DoxyCodeLine{4561   jsd = segment\%HI\%jsd ; jed = segment\%HI\%jed}
\DoxyCodeLine{4562   isdb = segment\%HI\%IsdB ; iedb = segment\%HI\%IedB}
\DoxyCodeLine{4563   jsdb = segment\%HI\%JsdB ; jedb = segment\%HI\%JedB}
\DoxyCodeLine{4564 }
\DoxyCodeLine{4565   segment\%tr\_Reg\%Tr(ntseg)\%Tr => tr\_ptr}
\DoxyCodeLine{4566   segment\%tr\_Reg\%Tr(ntseg)\%name = tr\_ptr\%name}
\DoxyCodeLine{4567 }
\DoxyCodeLine{4568   \textcolor{keywordflow}{if} (segment\%tr\_Reg\%locked) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{4569       \textcolor{stringliteral}{"{}MOM register\_tracer was called for variable "{}}//trim(segment\%tr\_Reg\%Tr(ntseg)\%name)//\&}
\DoxyCodeLine{4570       \textcolor{stringliteral}{"{} with a locked tracer registry."{}})}
\DoxyCodeLine{4571 }
\DoxyCodeLine{4572   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(obc\_scalar)) segment\%tr\_Reg\%Tr(ntseg)\%OBC\_inflow\_conc = obc\_scalar \textcolor{comment}{! initialize tracer value later}}
\DoxyCodeLine{4573   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(obc\_array)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4574     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4575       \textcolor{keyword}{allocate}(segment\%tr\_Reg\%Tr(ntseg)\%t(isdb:iedb,jsd:jed,1:gv\%ke));segment\%tr\_Reg\%Tr(ntseg)\%t(:,:,:)=0.0}
\DoxyCodeLine{4576       \textcolor{keyword}{allocate}(segment\%tr\_Reg\%Tr(ntseg)\%tres(isdb:iedb,jsd:jed,1:gv\%ke));segment\%tr\_Reg\%Tr(ntseg)\%tres(:,:,:)=0.0}
\DoxyCodeLine{4577       segment\%tr\_Reg\%Tr(ntseg)\%is\_initialized=.false.}
\DoxyCodeLine{4578     \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4579       \textcolor{keyword}{allocate}(segment\%tr\_Reg\%Tr(ntseg)\%t(isd:ied,jsdb:jedb,1:gv\%ke));segment\%tr\_Reg\%Tr(ntseg)\%t(:,:,:)=0.0}
\DoxyCodeLine{4580       \textcolor{keyword}{allocate}(segment\%tr\_Reg\%Tr(ntseg)\%tres(isd:ied,jsdb:jedb,1:gv\%ke));segment\%tr\_Reg\%Tr(ntseg)\%tres(:,:,:)=0.0}
\DoxyCodeLine{4581       segment\%tr\_Reg\%Tr(ntseg)\%is\_initialized=.false.}
\DoxyCodeLine{4582 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4583 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4584 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a0459cfc5b4e4115bde6ada1dd7c25139}\label{namespacemom__open__boundary_a0459cfc5b4e4115bde6ada1dd7c25139}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!register\_temp\_salt\_segments@{register\_temp\_salt\_segments}}
\index{register\_temp\_salt\_segments@{register\_temp\_salt\_segments}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{register\_temp\_salt\_segments()}{register\_temp\_salt\_segments()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::register\+\_\+temp\+\_\+salt\+\_\+segments (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}}), pointer}]{tr\+\_\+\+Reg,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure\\
\hline
 & {\em obc} & Open boundary structure\\
\hline
 & {\em tr\+\_\+reg} & Tracer registry\\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & file to parse for model parameter values \\
\hline
\end{DoxyParams}


Definition at line 4602 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4603   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{         !< ocean vertical grid structure}}
\DoxyCodeLine{4604   \textcolor{keywordtype}{type}(ocean\_OBC\_type),       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{        !< Open boundary structure}}
\DoxyCodeLine{4605   \textcolor{keywordtype}{type}(tracer\_registry\_type), \textcolor{keywordtype}{pointer}       :: tr\_Reg\textcolor{comment}{     !< Tracer registry}}
\DoxyCodeLine{4606   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< file to parse for  model parameter values}}
\DoxyCodeLine{4607 }
\DoxyCodeLine{4608 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4609   \textcolor{keywordtype}{integer} :: isd, ied, IsdB, IedB, jsd, jed, JsdB, JedB, nz, nf}
\DoxyCodeLine{4610   \textcolor{keywordtype}{integer} :: i, j, k, n}
\DoxyCodeLine{4611   \textcolor{keywordtype}{character(len=32)}  :: name}
\DoxyCodeLine{4612   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{4613   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}      :: tr\_ptr => null()}
\DoxyCodeLine{4614 }
\DoxyCodeLine{4615   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{4616 }
\DoxyCodeLine{4617   \textcolor{keywordflow}{do} n=1, obc\%number\_of\_segments}
\DoxyCodeLine{4618     segment=>obc\%segment(n)}
\DoxyCodeLine{4619     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{4620 }
\DoxyCodeLine{4621     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg)) \&}
\DoxyCodeLine{4622          \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"{}register\_temp\_salt\_segments: tracer array was previously allocated"{}})}
\DoxyCodeLine{4623 }
\DoxyCodeLine{4624     name = \textcolor{stringliteral}{'temp'}}
\DoxyCodeLine{4625     \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)}
\DoxyCodeLine{4626     \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, segment, \&}
\DoxyCodeLine{4627                                  obc\_array=segment\%temp\_segment\_data\_exists)}
\DoxyCodeLine{4628     name = \textcolor{stringliteral}{'salt'}}
\DoxyCodeLine{4629     \textcolor{keyword}{call }tracer\_name\_lookup(tr\_reg, tr\_ptr, name)}
\DoxyCodeLine{4630     \textcolor{keyword}{call }register\_segment\_tracer(tr\_ptr, param\_file, gv, segment, \&}
\DoxyCodeLine{4631                                  obc\_array=segment\%salt\_segment\_data\_exists)}
\DoxyCodeLine{4632 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{4633 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a0c4401f57b9a8275c8bb3d2f7c5e013f}\label{namespacemom__open__boundary_a0c4401f57b9a8275c8bb3d2f7c5e013f}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!rotate\_obc\_config@{rotate\_obc\_config}}
\index{rotate\_obc\_config@{rotate\_obc\_config}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{rotate\_obc\_config()}{rotate\_obc\_config()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::rotate\+\_\+obc\+\_\+config (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(in), pointer}]{O\+B\+C\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(inout), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{integer, intent(in)}]{turns }\end{DoxyParamCaption})}



This is more of a rotate initialization than an actual rotate. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em obc\+\_\+in} & Input O\+BC \\
\hline
\mbox{\texttt{ in}}  & {\em g\+\_\+in} & Input grid metric \\
\hline
\mbox{\texttt{ in,out}}  & {\em obc} & Rotated O\+BC \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Rotated grid metric \\
\hline
\mbox{\texttt{ in}}  & {\em turns} & Number of quarter turns \\
\hline
\end{DoxyParams}


Definition at line 5244 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{5245   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(in)} :: OBC\_in\textcolor{comment}{   !< Input OBC}}
\DoxyCodeLine{5246   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\_in\textcolor{comment}{           !< Input grid metric}}
\DoxyCodeLine{5247   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(inout)} :: OBC\textcolor{comment}{   !< Rotated OBC}}
\DoxyCodeLine{5248   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{              !< Rotated grid metric}}
\DoxyCodeLine{5249   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{                      !< Number of quarter turns}}
\DoxyCodeLine{5250 }
\DoxyCodeLine{5251   \textcolor{keywordtype}{integer} :: l}
\DoxyCodeLine{5252 }
\DoxyCodeLine{5253   \textcolor{keywordflow}{if} (obc\_in\%number\_of\_segments==0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{5254 }
\DoxyCodeLine{5255   \textcolor{comment}{! Scalar and logical transfer}}
\DoxyCodeLine{5256   obc\%number\_of\_segments = obc\_in\%number\_of\_segments}
\DoxyCodeLine{5257   obc\%ke = obc\_in\%ke}
\DoxyCodeLine{5258   obc\%user\_BCs\_set\_globally = obc\_in\%user\_BCs\_set\_globally}
\DoxyCodeLine{5259 }
\DoxyCodeLine{5260   \textcolor{comment}{! These are conditionally read and set if number\_of\_segments > 0}}
\DoxyCodeLine{5261   obc\%zero\_vorticity = obc\_in\%zero\_vorticity}
\DoxyCodeLine{5262   obc\%freeslip\_vorticity = obc\_in\%freeslip\_vorticity}
\DoxyCodeLine{5263   obc\%computed\_vorticity = obc\_in\%computed\_vorticity}
\DoxyCodeLine{5264   obc\%specified\_vorticity = obc\_in\%specified\_vorticity}
\DoxyCodeLine{5265   obc\%zero\_strain = obc\_in\%zero\_strain}
\DoxyCodeLine{5266   obc\%freeslip\_strain = obc\_in\%freeslip\_strain}
\DoxyCodeLine{5267   obc\%computed\_strain = obc\_in\%computed\_strain}
\DoxyCodeLine{5268   obc\%specified\_strain = obc\_in\%specified\_strain}
\DoxyCodeLine{5269   obc\%zero\_biharmonic = obc\_in\%zero\_biharmonic}
\DoxyCodeLine{5270   obc\%silly\_h = obc\_in\%silly\_h}
\DoxyCodeLine{5271   obc\%silly\_u = obc\_in\%silly\_u}
\DoxyCodeLine{5272 }
\DoxyCodeLine{5273   \textcolor{comment}{! Segment rotation}}
\DoxyCodeLine{5274   \textcolor{keyword}{allocate}(obc\%segment(0:obc\%number\_of\_segments))}
\DoxyCodeLine{5275   \textcolor{keywordflow}{do} l = 1, obc\%number\_of\_segments}
\DoxyCodeLine{5276     \textcolor{keyword}{call }rotate\_obc\_segment\_config(obc\_in\%segment(l), g\_in, obc\%segment(l), g, turns)}
\DoxyCodeLine{5277     \textcolor{comment}{! Data up to setup\_[uv]\_point\_obc is needed for allocate\_obc\_segment\_data!}}
\DoxyCodeLine{5278     \textcolor{keyword}{call }allocate\_obc\_segment\_data(obc, obc\%segment(l))}
\DoxyCodeLine{5279     \textcolor{keyword}{call }rotate\_obc\_segment\_data(obc\_in\%segment(l), obc\%segment(l), turns)}
\DoxyCodeLine{5280 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{5281 }
\DoxyCodeLine{5282   \textcolor{comment}{! The horizontal segment map}}
\DoxyCodeLine{5283   \textcolor{keyword}{allocate}(obc\%segnum\_u(g\%IsdB:g\%IedB,g\%jsd:g\%jed))}
\DoxyCodeLine{5284   \textcolor{keyword}{allocate}(obc\%segnum\_v(g\%isd:g\%ied,g\%JsdB:g\%JedB))}
\DoxyCodeLine{5285   \textcolor{keyword}{call }rotate\_array\_pair(obc\_in\%segnum\_u, obc\_in\%segnum\_v, turns, \&}
\DoxyCodeLine{5286       obc\%segnum\_u, obc\%segnum\_v)}
\DoxyCodeLine{5287 }
\DoxyCodeLine{5288   \textcolor{comment}{! These are conditionally enabled during segment configuration}}
\DoxyCodeLine{5289   obc\%open\_u\_BCs\_exist\_globally = obc\_in\%open\_v\_BCs\_exist\_globally}
\DoxyCodeLine{5290   obc\%open\_v\_BCs\_exist\_globally = obc\_in\%open\_u\_BCs\_exist\_globally}
\DoxyCodeLine{5291   obc\%Flather\_u\_BCs\_exist\_globally = obc\_in\%Flather\_v\_BCs\_exist\_globally}
\DoxyCodeLine{5292   obc\%Flather\_v\_BCs\_exist\_globally = obc\_in\%Flather\_u\_BCs\_exist\_globally}
\DoxyCodeLine{5293   obc\%oblique\_BCs\_exist\_globally = obc\_in\%oblique\_BCs\_exist\_globally}
\DoxyCodeLine{5294   obc\%nudged\_u\_BCs\_exist\_globally = obc\_in\%nudged\_v\_BCs\_exist\_globally}
\DoxyCodeLine{5295   obc\%nudged\_v\_BCs\_exist\_globally = obc\_in\%nudged\_u\_BCs\_exist\_globally}
\DoxyCodeLine{5296   obc\%specified\_u\_BCs\_exist\_globally= obc\_in\%specified\_v\_BCs\_exist\_globally}
\DoxyCodeLine{5297   obc\%specified\_v\_BCs\_exist\_globally= obc\_in\%specified\_u\_BCs\_exist\_globally}
\DoxyCodeLine{5298   obc\%radiation\_BCs\_exist\_globally = obc\_in\%radiation\_BCs\_exist\_globally}
\DoxyCodeLine{5299 }
\DoxyCodeLine{5300   \textcolor{comment}{! These are set by initialize\_segment\_data}}
\DoxyCodeLine{5301   obc\%brushcutter\_mode = obc\_in\%brushcutter\_mode}
\DoxyCodeLine{5302   obc\%update\_OBC = obc\_in\%update\_OBC}
\DoxyCodeLine{5303   obc\%needs\_IO\_for\_data = obc\_in\%needs\_IO\_for\_data}
\DoxyCodeLine{5304 }
\DoxyCodeLine{5305   obc\%ntr = obc\_in\%ntr}
\DoxyCodeLine{5306 }
\DoxyCodeLine{5307   obc\%gamma\_uv = obc\_in\%gamma\_uv}
\DoxyCodeLine{5308   obc\%rx\_max = obc\_in\%rx\_max}
\DoxyCodeLine{5309   obc\%OBC\_pe = obc\_in\%OBC\_pe}
\DoxyCodeLine{5310 }
\DoxyCodeLine{5311   \textcolor{comment}{! remap\_CS is set up by initialize\_segment\_data, so we copy the fields here.}}
\DoxyCodeLine{5312   \textcolor{keywordflow}{if} (\textcolor{keyword}{ASSOCIATED}(obc\_in\%remap\_CS)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5313      \textcolor{keyword}{allocate}(obc\%remap\_CS)}
\DoxyCodeLine{5314      obc\%remap\_CS = obc\_in\%remap\_CS}
\DoxyCodeLine{5315 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5316 }
\DoxyCodeLine{5317   \textcolor{comment}{! TODO: The OBC registry seems to be a list of "{}registered"{} OBC types.}}
\DoxyCodeLine{5318   \textcolor{comment}{!   It does not appear to be used, so for now we skip this record.}}
\DoxyCodeLine{5319   \textcolor{comment}{!OBC\%OBC\_Reg => OBC\_in\%OBC\_Reg}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_acafa1a47d4e7f4d347963286d7614104}\label{namespacemom__open__boundary_acafa1a47d4e7f4d347963286d7614104}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!rotate\_obc\_init@{rotate\_obc\_init}}
\index{rotate\_obc\_init@{rotate\_obc\_init}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{rotate\_obc\_init()}{rotate\_obc\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::rotate\+\_\+obc\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(in), pointer}]{O\+B\+C\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(inout)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__restart_1_1mom__restart__cs}{mom\+\_\+restart\+\_\+cs}}), intent(in), pointer}]{restart\+\_\+\+C\+Sp,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), intent(inout), pointer}]{O\+BC }\end{DoxyParamCaption})}



Initialize the segments and field-\/related data of a rotated O\+BC. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em obc\+\_\+in} & O\+BC on input map \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Rotated grid metric \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid \\
\hline
\mbox{\texttt{ in}}  & {\em us} & Unit scaling \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Input parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Tracer fields \\
\hline
\mbox{\texttt{ in}}  & {\em restart\+\_\+csp} & Restart CS \\
\hline
\mbox{\texttt{ in,out}}  & {\em obc} & Rotated O\+BC \\
\hline
\end{DoxyParams}


Definition at line 5457 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{5458   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(in)} :: OBC\_in\textcolor{comment}{   !< OBC on input map}}
\DoxyCodeLine{5459   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{                !< Rotated grid metric}}
\DoxyCodeLine{5460   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{             !< Vertical grid}}
\DoxyCodeLine{5461   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{               !< Unit scaling}}
\DoxyCodeLine{5462   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{       !< Input parameters}}
\DoxyCodeLine{5463   \textcolor{keywordtype}{type}(thermo\_var\_ptrs), \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{            !< Tracer fields}}
\DoxyCodeLine{5464   \textcolor{keywordtype}{type}(MOM\_restart\_CS), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(in)} :: restart\_CSp\textcolor{comment}{  !< Restart CS}}
\DoxyCodeLine{5465   \textcolor{keywordtype}{type}(ocean\_OBC\_type), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(inout)} :: OBC\textcolor{comment}{   !< Rotated OBC}}
\DoxyCodeLine{5466 }
\DoxyCodeLine{5467   \textcolor{keywordtype}{logical} :: use\_temperature}
\DoxyCodeLine{5468   \textcolor{keywordtype}{integer} :: l}
\DoxyCodeLine{5469 }
\DoxyCodeLine{5470   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"{}MOM"{}}, \textcolor{stringliteral}{"{}ENABLE\_THERMODYNAMICS"{}}, use\_temperature, \&}
\DoxyCodeLine{5471                  \textcolor{stringliteral}{"{}If true, Temperature and salinity are used as state "{}}//\&}
\DoxyCodeLine{5472                  \textcolor{stringliteral}{"{}variables."{}}, default=.true., do\_not\_log=.true.)}
\DoxyCodeLine{5473 }
\DoxyCodeLine{5474   \textcolor{keywordflow}{do} l = 1, obc\%number\_of\_segments}
\DoxyCodeLine{5475     \textcolor{keyword}{call }rotate\_obc\_segment\_data(obc\_in\%segment(l), obc\%segment(l), g\%HI\%turns)}
\DoxyCodeLine{5476 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{5477 }
\DoxyCodeLine{5478   \textcolor{keywordflow}{if} (use\_temperature) \&}
\DoxyCodeLine{5479     \textcolor{keyword}{call }fill\_temp\_salt\_segments(g, obc, tv)}
\DoxyCodeLine{5480 }
\DoxyCodeLine{5481   \textcolor{keyword}{call }open\_boundary\_init(g, gv, us, param\_file, obc, restart\_csp)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a68a208918e01e2393f12f737bdff3776}\label{namespacemom__open__boundary_a68a208918e01e2393f12f737bdff3776}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!rotate\_obc\_segment\_config@{rotate\_obc\_segment\_config}}
\index{rotate\_obc\_segment\_config@{rotate\_obc\_segment\_config}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{rotate\_obc\_segment\_config()}{rotate\_obc\_segment\_config()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::rotate\+\_\+obc\+\_\+segment\+\_\+config (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(in)}]{segment\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G\+\_\+in,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{integer, intent(in)}]{turns }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Rotate the O\+BC segment configuration data from the input to model index map. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em segment\+\_\+in} & Input O\+BC segment \\
\hline
\mbox{\texttt{ in}}  & {\em g\+\_\+in} & Input grid metric \\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & Rotated O\+BC segment \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Rotated grid metric \\
\hline
\mbox{\texttt{ in}}  & {\em turns} & Number of quarter turns \\
\hline
\end{DoxyParams}


Definition at line 5323 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{5324   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(in)} :: segment\_in\textcolor{comment}{  !< Input OBC segment}}
\DoxyCodeLine{5325   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\_in\textcolor{comment}{       !< Input grid metric}}
\DoxyCodeLine{5326   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)} :: segment\textcolor{comment}{  !< Rotated OBC segment}}
\DoxyCodeLine{5327   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{          !< Rotated grid metric}}
\DoxyCodeLine{5328   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{                      !< Number of quarter turns}}
\DoxyCodeLine{5329 }
\DoxyCodeLine{5330   \textcolor{comment}{! Global segment indices}}
\DoxyCodeLine{5331   \textcolor{keywordtype}{integer} :: Is\_obc\_in, Ie\_obc\_in, Js\_obc\_in, Je\_obc\_in \textcolor{comment}{! Input domain}}
\DoxyCodeLine{5332   \textcolor{keywordtype}{integer} :: Is\_obc, Ie\_obc, Js\_obc, Je\_obc             \textcolor{comment}{! Rotated domain}}
\DoxyCodeLine{5333 }
\DoxyCodeLine{5334   \textcolor{comment}{! NOTE: A "{}rotation"{} of the OBC segment string would allow us to use}}
\DoxyCodeLine{5335   \textcolor{comment}{!   setup\_[uv]\_point\_obc to set up most of this.  For now, we just copy/swap}}
\DoxyCodeLine{5336   \textcolor{comment}{!   flags and manually rotate the indices.}}
\DoxyCodeLine{5337 }
\DoxyCodeLine{5338   \textcolor{comment}{! This is set if the segment is in the local grid}}
\DoxyCodeLine{5339   segment\%on\_pe = segment\_in\%on\_pe}
\DoxyCodeLine{5340 }
\DoxyCodeLine{5341   \textcolor{comment}{! Transfer configuration flags}}
\DoxyCodeLine{5342   segment\%Flather = segment\_in\%Flather}
\DoxyCodeLine{5343   segment\%radiation = segment\_in\%radiation}
\DoxyCodeLine{5344   segment\%radiation\_tan = segment\_in\%radiation\_tan}
\DoxyCodeLine{5345   segment\%radiation\_grad = segment\_in\%radiation\_grad}
\DoxyCodeLine{5346   segment\%oblique = segment\_in\%oblique}
\DoxyCodeLine{5347   segment\%oblique\_tan = segment\_in\%oblique\_tan}
\DoxyCodeLine{5348   segment\%oblique\_grad = segment\_in\%oblique\_grad}
\DoxyCodeLine{5349   segment\%nudged = segment\_in\%nudged}
\DoxyCodeLine{5350   segment\%nudged\_tan = segment\_in\%nudged\_tan}
\DoxyCodeLine{5351   segment\%nudged\_grad = segment\_in\%nudged\_grad}
\DoxyCodeLine{5352   segment\%specified = segment\_in\%specified}
\DoxyCodeLine{5353   segment\%specified\_tan = segment\_in\%specified\_tan}
\DoxyCodeLine{5354   segment\%specified\_grad = segment\_in\%specified\_grad}
\DoxyCodeLine{5355   segment\%open = segment\_in\%open}
\DoxyCodeLine{5356   segment\%gradient = segment\_in\%gradient}
\DoxyCodeLine{5357 }
\DoxyCodeLine{5358   \textcolor{comment}{! NOTE: [uv]\_values\_needed are swapped}}
\DoxyCodeLine{5359   segment\%u\_values\_needed = segment\_in\%v\_values\_needed}
\DoxyCodeLine{5360   segment\%v\_values\_needed = segment\_in\%u\_values\_needed}
\DoxyCodeLine{5361   segment\%z\_values\_needed = segment\_in\%z\_values\_needed}
\DoxyCodeLine{5362   segment\%g\_values\_needed = segment\_in\%g\_values\_needed}
\DoxyCodeLine{5363   segment\%t\_values\_needed = segment\_in\%t\_values\_needed}
\DoxyCodeLine{5364   segment\%s\_values\_needed = segment\_in\%s\_values\_needed}
\DoxyCodeLine{5365 }
\DoxyCodeLine{5366   segment\%values\_needed = segment\_in\%values\_needed}
\DoxyCodeLine{5367 }
\DoxyCodeLine{5368   \textcolor{comment}{! These are conditionally set if nudged}}
\DoxyCodeLine{5369   segment\%Velocity\_nudging\_timescale\_in = segment\_in\%Velocity\_nudging\_timescale\_in}
\DoxyCodeLine{5370   segment\%Velocity\_nudging\_timescale\_out= segment\_in\%Velocity\_nudging\_timescale\_out}
\DoxyCodeLine{5371 }
\DoxyCodeLine{5372   \textcolor{comment}{! Rotate segment indices}}
\DoxyCodeLine{5373 }
\DoxyCodeLine{5374   \textcolor{comment}{! Reverse engineer the input [IJ][se]\_obc segment indices}}
\DoxyCodeLine{5375   \textcolor{comment}{! NOTE: The values stored in the segment are always saved in ascending order,}}
\DoxyCodeLine{5376   \textcolor{comment}{!   e.g. (is < ie).  In order to use setup\_segment\_indices, we reorder the}}
\DoxyCodeLine{5377   \textcolor{comment}{!   indices here to indicate face direction.}}
\DoxyCodeLine{5378   \textcolor{comment}{!   Segment indices are also indexed locally, so we remove the halo offset.}}
\DoxyCodeLine{5379   \textcolor{keywordflow}{if} (segment\_in\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5380     is\_obc\_in = segment\_in\%Ie\_obc + g\_in\%idg\_offset}
\DoxyCodeLine{5381     ie\_obc\_in = segment\_in\%Is\_obc + g\_in\%idg\_offset}
\DoxyCodeLine{5382   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5383     is\_obc\_in = segment\_in\%Is\_obc + g\_in\%idg\_offset}
\DoxyCodeLine{5384     ie\_obc\_in = segment\_in\%Ie\_obc + g\_in\%idg\_offset}
\DoxyCodeLine{5385 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5386 }
\DoxyCodeLine{5387   \textcolor{keywordflow}{if} (segment\_in\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5388     js\_obc\_in = segment\_in\%Je\_obc + g\_in\%jdg\_offset}
\DoxyCodeLine{5389     je\_obc\_in = segment\_in\%Js\_obc + g\_in\%jdg\_offset}
\DoxyCodeLine{5390   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5391     js\_obc\_in = segment\_in\%Js\_obc + g\_in\%jdg\_offset}
\DoxyCodeLine{5392     je\_obc\_in = segment\_in\%Je\_obc + g\_in\%jdg\_offset}
\DoxyCodeLine{5393 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5394 }
\DoxyCodeLine{5395   \textcolor{comment}{! TODO: This is hardcoded for 90 degrees, and needs to be generalized.}}
\DoxyCodeLine{5396   is\_obc = g\_in\%jegB -\/ js\_obc\_in}
\DoxyCodeLine{5397   ie\_obc = g\_in\%JegB -\/ je\_obc\_in}
\DoxyCodeLine{5398   js\_obc = is\_obc\_in}
\DoxyCodeLine{5399   je\_obc = ie\_obc\_in}
\DoxyCodeLine{5400 }
\DoxyCodeLine{5401   \textcolor{comment}{! Orientation is based on the index ordering, [IJ][se]\_obc are re-\/ordered}}
\DoxyCodeLine{5402   \textcolor{comment}{! after the index is set.  So we now need to restore the original order}}
\DoxyCodeLine{5403 }
\DoxyCodeLine{5404   \textcolor{keyword}{call }setup\_segment\_indices(g, segment, is\_obc, ie\_obc, js\_obc, je\_obc)}
\DoxyCodeLine{5405 }
\DoxyCodeLine{5406   \textcolor{comment}{! Re-\/order [IJ][se]\_obc back to ascending, and remove the halo offset.}}
\DoxyCodeLine{5407   \textcolor{keywordflow}{if} (is\_obc > ie\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5408     segment\%Is\_obc = ie\_obc -\/ g\%idg\_offset}
\DoxyCodeLine{5409     segment\%Ie\_obc = is\_obc -\/ g\%idg\_offset}
\DoxyCodeLine{5410   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5411     segment\%Is\_obc = is\_obc -\/ g\%idg\_offset}
\DoxyCodeLine{5412     segment\%Ie\_obc = ie\_obc -\/ g\%idg\_offset}
\DoxyCodeLine{5413 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5414 }
\DoxyCodeLine{5415   \textcolor{keywordflow}{if} (js\_obc > je\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5416     segment\%Js\_obc = je\_obc -\/ g\%jdg\_offset}
\DoxyCodeLine{5417     segment\%Je\_obc = js\_obc -\/ g\%jdg\_offset}
\DoxyCodeLine{5418   \textcolor{keywordflow}{else}}
\DoxyCodeLine{5419     segment\%Js\_obc = js\_obc -\/ g\%jdg\_offset}
\DoxyCodeLine{5420     segment\%Je\_obc = je\_obc -\/ g\%jdg\_offset}
\DoxyCodeLine{5421 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{5422 }
\DoxyCodeLine{5423   \textcolor{comment}{! Reconfigure the directional flags}}
\DoxyCodeLine{5424   \textcolor{comment}{! TODO: This is hardcoded for 90 degrees, and needs to be generalized.}}
\DoxyCodeLine{5425   \textcolor{keywordflow}{select case} (segment\_in\%direction)}
\DoxyCodeLine{5426     \textcolor{keywordflow}{case} (obc\_direction\_n)}
\DoxyCodeLine{5427       segment\%direction = obc\_direction\_w}
\DoxyCodeLine{5428       segment\%is\_E\_or\_W\_2 = segment\_in\%is\_N\_or\_S}
\DoxyCodeLine{5429       segment\%is\_E\_or\_W = segment\_in\%is\_N\_or\_S .and. segment\_in\%on\_pe}
\DoxyCodeLine{5430       segment\%is\_N\_or\_S = .false.}
\DoxyCodeLine{5431     \textcolor{keywordflow}{case} (obc\_direction\_w)}
\DoxyCodeLine{5432       segment\%direction = obc\_direction\_s}
\DoxyCodeLine{5433       segment\%is\_N\_or\_S = segment\_in\%is\_E\_or\_W}
\DoxyCodeLine{5434       segment\%is\_E\_or\_W = .false.}
\DoxyCodeLine{5435       segment\%is\_E\_or\_W\_2 = .false.}
\DoxyCodeLine{5436     \textcolor{keywordflow}{case} (obc\_direction\_s)}
\DoxyCodeLine{5437       segment\%direction = obc\_direction\_e}
\DoxyCodeLine{5438       segment\%is\_E\_or\_W\_2 = segment\_in\%is\_N\_or\_S}
\DoxyCodeLine{5439       segment\%is\_E\_or\_W = segment\_in\%is\_N\_or\_S .and. segment\_in\%on\_pe}
\DoxyCodeLine{5440       segment\%is\_N\_or\_S = .false.}
\DoxyCodeLine{5441     \textcolor{keywordflow}{case} (obc\_direction\_e)}
\DoxyCodeLine{5442       segment\%direction = obc\_direction\_n}
\DoxyCodeLine{5443       segment\%is\_N\_or\_S = segment\_in\%is\_E\_or\_W}
\DoxyCodeLine{5444       segment\%is\_E\_or\_W = .false.}
\DoxyCodeLine{5445       segment\%is\_E\_or\_W\_2 = .false.}
\DoxyCodeLine{5446     \textcolor{keywordflow}{case} (obc\_none)}
\DoxyCodeLine{5447       segment\%direction = obc\_none}
\DoxyCodeLine{5448 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{5449 }
\DoxyCodeLine{5450   \textcolor{comment}{! These are conditionally set if Lscale\_\{in,out\} are present}}
\DoxyCodeLine{5451   segment\%Tr\_InvLscale\_in = segment\_in\%Tr\_InvLscale\_in}
\DoxyCodeLine{5452   segment\%Tr\_InvLscale\_out = segment\_in\%Tr\_InvLscale\_out}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a71194a8dc156fea37aab6539cc124086}\label{namespacemom__open__boundary_a71194a8dc156fea37aab6539cc124086}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!segment\_tracer\_registry\_end@{segment\_tracer\_registry\_end}}
\index{segment\_tracer\_registry\_end@{segment\_tracer\_registry\_end}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{segment\_tracer\_registry\_end()}{segment\_tracer\_registry\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::segment\+\_\+tracer\+\_\+registry\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1segment__tracer__registry__type}{segment\+\_\+tracer\+\_\+registry\+\_\+type}}), pointer}]{Reg }\end{DoxyParamCaption})}



Clean up the segment tracer registry. 


\begin{DoxyParams}{Parameters}
{\em reg} & pointer to tracer registry \\
\hline
\end{DoxyParams}


Definition at line 4588 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4589   \textcolor{keywordtype}{type}(segment\_tracer\_registry\_type), \textcolor{keywordtype}{pointer} :: Reg\textcolor{comment}{        !< pointer to tracer registry}}
\DoxyCodeLine{4590 }
\DoxyCodeLine{4591 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4592   \textcolor{keywordtype}{integer} n}
\DoxyCodeLine{4593 }
\DoxyCodeLine{4594   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4595     \textcolor{keywordflow}{do} n = 1, reg\%ntseg}
\DoxyCodeLine{4596       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg\%Tr(n)\%t)) \textcolor{keyword}{deallocate}(reg\%Tr(n)\%t)}
\DoxyCodeLine{4597 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4598     \textcolor{keyword}{deallocate}(reg)}
\DoxyCodeLine{4599 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_adcd9637c6cc17658fe064ce1dc1011bf}\label{namespacemom__open__boundary_adcd9637c6cc17658fe064ce1dc1011bf}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!segment\_tracer\_registry\_init@{segment\_tracer\_registry\_init}}
\index{segment\_tracer\_registry\_init@{segment\_tracer\_registry\_init}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{segment\_tracer\_registry\_init()}{segment\_tracer\_registry\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::segment\+\_\+tracer\+\_\+registry\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{segment }\end{DoxyParamCaption})}



Initialize the segment tracer registry. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & open file to parse for model parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em segment} & the segment \\
\hline
\end{DoxyParams}


Definition at line 4495 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4496   \textcolor{keywordtype}{type}(param\_file\_type),      \textcolor{keywordtype}{intent(in)}      :: param\_file\textcolor{comment}{ !< open file to parse for model parameters}}
\DoxyCodeLine{4497   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)}       :: segment\textcolor{comment}{    !<  the segment}}
\DoxyCodeLine{4498 }
\DoxyCodeLine{4499   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{save} :: init\_calls = 0}
\DoxyCodeLine{4500 }
\DoxyCodeLine{4501 \textcolor{comment}{! This include declares and sets the variable "{}version"{}.}}
\DoxyCodeLine{4502 \textcolor{preprocessor}{\#include "{}version\_variable.h"{}}}
\DoxyCodeLine{4503 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}segment\_tracer\_registry\_init"{}} \textcolor{comment}{! This routine's name.}}
\DoxyCodeLine{4504   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}}
\DoxyCodeLine{4505 }
\DoxyCodeLine{4506   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(segment\%tr\_Reg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4507     \textcolor{keyword}{allocate}(segment\%tr\_Reg)}
\DoxyCodeLine{4508   \textcolor{keywordflow}{else}}
\DoxyCodeLine{4509     \textcolor{keywordflow}{return}}
\DoxyCodeLine{4510 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4511 }
\DoxyCodeLine{4512   init\_calls = init\_calls + 1}
\DoxyCodeLine{4513 }
\DoxyCodeLine{4514   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{4515   \textcolor{keywordflow}{if} (init\_calls == 1) \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{"{}"{}})}
\DoxyCodeLine{4516 }
\DoxyCodeLine{4517 \textcolor{comment}{! Need to call once per segment with tracers...}}
\DoxyCodeLine{4518 \textcolor{comment}{! if (init\_calls > 1) then}}
\DoxyCodeLine{4519 \textcolor{comment}{!   write(mesg,'("{}segment\_tracer\_registry\_init called "{},I3, \&}}
\DoxyCodeLine{4520 \textcolor{comment}{!     \&"{} times with different registry pointers."{})') init\_calls}}
\DoxyCodeLine{4521 \textcolor{comment}{!   if (is\_root\_pe()) call MOM\_error(WARNING,"{}MOM\_tracer"{}//mesg)}}
\DoxyCodeLine{4522 \textcolor{comment}{! endif}}
\DoxyCodeLine{4523 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a0a4c67f2e0fe21f1a2274be12844a71a}\label{namespacemom__open__boundary_a0a4c67f2e0fe21f1a2274be12844a71a}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!set\_tracer\_data@{set\_tracer\_data}}
\index{set\_tracer\_data@{set\_tracer\_data}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{set\_tracer\_data()}{set\_tracer\_data()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::set\+\_\+tracer\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(inout)}]{tv,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g), szk\+\_\+(g)), intent(inout)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF,  }\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}}), pointer}]{tracer\+\_\+\+Reg }\end{DoxyParamCaption})}



Sets the initial values of the tracer open boundary conditions. Redoing this elsewhere. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid structure \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamics structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Thickness \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & Parameter file handle \\
\hline
 & {\em tracer\+\_\+reg} & Tracer registry \\
\hline
\end{DoxyParams}


Definition at line 3420 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3421   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{3422   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{3423   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{ !< Thermodynamics structure}}
\DoxyCodeLine{3424 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{ !< Thickness}}
\DoxyCodeLine{3425   \textcolor{keywordtype}{type}(param\_file\_type),                     \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{3426   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}       :: tracer\_Reg\textcolor{comment}{ !< Tracer registry}}
\DoxyCodeLine{3427   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3428   \textcolor{keywordtype}{integer} :: i, j, k, itt, is, ie, js, je, isd, ied, jsd, jed, nz, n}
\DoxyCodeLine{3429   \textcolor{keywordtype}{integer} :: isd\_off, jsd\_off}
\DoxyCodeLine{3430   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{3431   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment  => null() \textcolor{comment}{! pointer to segment type list}}
\DoxyCodeLine{3432   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}set\_tracer\_data"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{3433   \textcolor{keywordtype}{character(len=200)} :: filename, OBC\_file, inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{3434 }
\DoxyCodeLine{3435 \textcolor{keywordtype}{  real} :: temp\_u(G\%domain\%niglobal+1,G\%domain\%njglobal)}
\DoxyCodeLine{3436 \textcolor{keywordtype}{  real} :: temp\_v(G\%domain\%niglobal,G\%domain\%njglobal+1)}
\DoxyCodeLine{3437 }
\DoxyCodeLine{3438   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec ; nz = g\%ke}
\DoxyCodeLine{3439   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{3440   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{3441 }
\DoxyCodeLine{3442   \textcolor{comment}{! For now, there are no radiation conditions applied to the thicknesses, since}}
\DoxyCodeLine{3443   \textcolor{comment}{! the thicknesses might not be physically motivated.  Instead, sponges should be}}
\DoxyCodeLine{3444   \textcolor{comment}{! used to enforce the near-\/boundary layer structure.}}
\DoxyCodeLine{3445 }
\DoxyCodeLine{3446   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tv\%T)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3447 }
\DoxyCodeLine{3448     \textcolor{keyword}{call }pass\_var(tv\%T, g\%Domain)}
\DoxyCodeLine{3449     \textcolor{keyword}{call }pass\_var(tv\%S, g\%Domain)}
\DoxyCodeLine{3450 }
\DoxyCodeLine{3451     \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{3452       segment => obc\%segment(n)}
\DoxyCodeLine{3453       \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle}
\DoxyCodeLine{3454 }
\DoxyCodeLine{3455       \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3456         i=segment\%HI\%IsdB}
\DoxyCodeLine{3457         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{3458           tv\%T(i+1,j,k) = tv\%T(i,j,k) ; tv\%S(i+1,j,k) = tv\%S(i,j,k)}
\DoxyCodeLine{3459 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3460       \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3461         i=segment\%HI\%IsdB}
\DoxyCodeLine{3462         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{3463           tv\%T(i,j,k) = tv\%T(i+1,j,k) ; tv\%S(i,j,k) = tv\%S(i+1,j,k)}
\DoxyCodeLine{3464 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3465       \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3466         j=segment\%HI\%JsdB}
\DoxyCodeLine{3467         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{3468           tv\%T(i,j+1,k) = tv\%T(i,j,k) ; tv\%S(i,j+1,k) = tv\%S(i,j,k)}
\DoxyCodeLine{3469 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3470       \textcolor{keywordflow}{elseif} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3471         j=segment\%HI\%JsdB}
\DoxyCodeLine{3472         \textcolor{keywordflow}{do} k=1,g\%ke ;  \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{3473           tv\%T(i,j,k) = tv\%T(i,j+1,k) ; tv\%S(i,j,k) = tv\%S(i,j+1,k)}
\DoxyCodeLine{3474 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{3475 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{3476 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{3477 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{3478 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a2578141730f51e42c56bb05c3648ea08}\label{namespacemom__open__boundary_a2578141730f51e42c56bb05c3648ea08}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!setup\_obc\_tracer\_reservoirs@{setup\_obc\_tracer\_reservoirs}}
\index{setup\_obc\_tracer\_reservoirs@{setup\_obc\_tracer\_reservoirs}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{setup\_obc\_tracer\_reservoirs()}{setup\_obc\_tracer\_reservoirs()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::setup\+\_\+obc\+\_\+tracer\+\_\+reservoirs (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Make sure the O\+BC tracer reservoirs are initialized. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
 & {\em obc} & Open boundary control structure \\
\hline
\end{DoxyParams}


Definition at line 2079 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{2080   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{          !< Ocean grid structure}}
\DoxyCodeLine{2081   \textcolor{keywordtype}{type}(ocean\_OBC\_type),       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{2082   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{2083   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{2084   \textcolor{keywordtype}{integer} :: i, j, k, m, n}
\DoxyCodeLine{2085 }
\DoxyCodeLine{2086   \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{2087     segment=>obc\%segment(n)}
\DoxyCodeLine{2088     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2089       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2090         i = segment\%HI\%IsdB}
\DoxyCodeLine{2091         \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{2092           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2093             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2094               \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{2095                 obc\%tres\_x(i,j,k,m) = segment\%tr\_Reg\%Tr(m)\%t(i,j,k)}
\DoxyCodeLine{2096 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{2097 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{2098 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2099 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2100       \textcolor{keywordflow}{else}}
\DoxyCodeLine{2101         j = segment\%HI\%JsdB}
\DoxyCodeLine{2102         \textcolor{keywordflow}{do} m=1,obc\%ntr}
\DoxyCodeLine{2103           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{2104             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{2105               \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{2106                 obc\%tres\_y(i,j,k,m) = segment\%tr\_Reg\%Tr(m)\%t(i,j,k)}
\DoxyCodeLine{2107 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{2108 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{2109 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{2110 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{2111 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{2112 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{2113 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{2114 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_ac357a1fb341db3aaffdfeca2eacab60b}\label{namespacemom__open__boundary_ac357a1fb341db3aaffdfeca2eacab60b}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!setup\_segment\_indices@{setup\_segment\_indices}}
\index{setup\_segment\_indices@{setup\_segment\_indices}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{setup\_segment\_indices()}{setup\_segment\_indices()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::setup\+\_\+segment\+\_\+indices (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1obc__segment__type}{obc\+\_\+segment\+\_\+type}}), intent(inout)}]{seg,  }\item[{integer, intent(in)}]{Is\+\_\+obc,  }\item[{integer, intent(in)}]{Ie\+\_\+obc,  }\item[{integer, intent(in)}]{Js\+\_\+obc,  }\item[{integer, intent(in)}]{Je\+\_\+obc }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Define indices for segment and store in hor\+\_\+index\+\_\+type using global segment bounds corresponding to q-\/points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & grid type \\
\hline
\mbox{\texttt{ in,out}}  & {\em seg} & Open boundary segment \\
\hline
\mbox{\texttt{ in}}  & {\em is\+\_\+obc} & Q-\/point global i-\/index of start of segment \\
\hline
\mbox{\texttt{ in}}  & {\em ie\+\_\+obc} & Q-\/point global i-\/index of end of segment \\
\hline
\mbox{\texttt{ in}}  & {\em js\+\_\+obc} & Q-\/point global j-\/index of start of segment \\
\hline
\mbox{\texttt{ in}}  & {\em je\+\_\+obc} & Q-\/point global j-\/index of end of segment \\
\hline
\end{DoxyParams}


Definition at line 1057 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1058   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< grid type}}
\DoxyCodeLine{1059   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{intent(inout)} :: seg\textcolor{comment}{  !< Open boundary segment}}
\DoxyCodeLine{1060   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: Is\_obc\textcolor{comment}{ !< Q-\/point global i-\/index of start of segment}}
\DoxyCodeLine{1061   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: Ie\_obc\textcolor{comment}{ !< Q-\/point global i-\/index of end of segment}}
\DoxyCodeLine{1062   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: Js\_obc\textcolor{comment}{ !< Q-\/point global j-\/index of start of segment}}
\DoxyCodeLine{1063   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: Je\_obc\textcolor{comment}{ !< Q-\/point global j-\/index of end of segment}}
\DoxyCodeLine{1064   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1065   \textcolor{keywordtype}{integer} :: IsgB, IegB, JsgB, JegB}
\DoxyCodeLine{1066   \textcolor{keywordtype}{integer} :: isg, ieg, jsg, jeg}
\DoxyCodeLine{1067 }
\DoxyCodeLine{1068   \textcolor{comment}{! Isg, Ieg will be I*\_obc in global space}}
\DoxyCodeLine{1069   \textcolor{keywordflow}{if} (ie\_obc < is\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1070     isgb = ie\_obc}
\DoxyCodeLine{1071     iegb = is\_obc}
\DoxyCodeLine{1072   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1073     isgb = is\_obc}
\DoxyCodeLine{1074     iegb = ie\_obc}
\DoxyCodeLine{1075 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1076 }
\DoxyCodeLine{1077   \textcolor{keywordflow}{if} (je\_obc < js\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1078     jsgb = je\_obc}
\DoxyCodeLine{1079     jegb = js\_obc}
\DoxyCodeLine{1080   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1081     jsgb = js\_obc}
\DoxyCodeLine{1082     jegb = je\_obc}
\DoxyCodeLine{1083 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1084 }
\DoxyCodeLine{1085   \textcolor{comment}{! NOTE: h-\/points are defined along the interior of the segment q-\/points.}}
\DoxyCodeLine{1086   \textcolor{comment}{!   For a given segment and its start and end index pairs, [IJ][se]gB, the}}
\DoxyCodeLine{1087   \textcolor{comment}{!   h-\/cell corresponding to this pair are shown in the figure below.}}
\DoxyCodeLine{1088   \textcolor{comment}{!}}
\DoxyCodeLine{1089   \textcolor{comment}{! x-\/x-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/x-\/x}}
\DoxyCodeLine{1090   \textcolor{comment}{! | |        N       | |}}
\DoxyCodeLine{1091   \textcolor{comment}{! x-\/x   W         E  x-\/x}}
\DoxyCodeLine{1092   \textcolor{comment}{!   |        S         |}}
\DoxyCodeLine{1093   \textcolor{comment}{! x-\/x-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/x-\/x}}
\DoxyCodeLine{1094   \textcolor{comment}{! | |                | |}}
\DoxyCodeLine{1095   \textcolor{comment}{! x-\/x                x-\/x}}
\DoxyCodeLine{1096   \textcolor{comment}{!}}
\DoxyCodeLine{1097   \textcolor{comment}{! For segment points on the west and south, h-\/point indices are incremented}}
\DoxyCodeLine{1098   \textcolor{comment}{! in order to move to the interior cell.}}
\DoxyCodeLine{1099 }
\DoxyCodeLine{1100   \textcolor{keywordflow}{if} (is\_obc > ie\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1101     \textcolor{comment}{! Northern boundary}}
\DoxyCodeLine{1102     isg = isgb + 1}
\DoxyCodeLine{1103     jsg = jsgb}
\DoxyCodeLine{1104     ieg = iegb}
\DoxyCodeLine{1105     jeg = jegb}
\DoxyCodeLine{1106 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1107 }
\DoxyCodeLine{1108   \textcolor{keywordflow}{if} (is\_obc < ie\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1109     \textcolor{comment}{! Southern boundary}}
\DoxyCodeLine{1110     isg = isgb + 1}
\DoxyCodeLine{1111     jsg = jsgb + 1}
\DoxyCodeLine{1112     ieg = iegb}
\DoxyCodeLine{1113     jeg = jegb + 1}
\DoxyCodeLine{1114 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1115 }
\DoxyCodeLine{1116   \textcolor{keywordflow}{if} (js\_obc < je\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1117     \textcolor{comment}{! Eastern boundary}}
\DoxyCodeLine{1118     isg = isgb}
\DoxyCodeLine{1119     jsg = jsgb + 1}
\DoxyCodeLine{1120     ieg = iegb}
\DoxyCodeLine{1121     jeg = jegb}
\DoxyCodeLine{1122 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1123 }
\DoxyCodeLine{1124   \textcolor{keywordflow}{if} (js\_obc > je\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1125     \textcolor{comment}{! Western boundary}}
\DoxyCodeLine{1126     isg = isgb + 1}
\DoxyCodeLine{1127     jsg = jsgb + 1}
\DoxyCodeLine{1128     ieg = iegb + 1}
\DoxyCodeLine{1129     jeg = jegb}
\DoxyCodeLine{1130 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1131 }
\DoxyCodeLine{1132   \textcolor{comment}{! Global space I*\_obc but sorted}}
\DoxyCodeLine{1133   seg\%HI\%IsgB = isgb}
\DoxyCodeLine{1134   seg\%HI\%JegB = jegb}
\DoxyCodeLine{1135   seg\%HI\%IegB = iegb}
\DoxyCodeLine{1136   seg\%HI\%JsgB = jsgb}
\DoxyCodeLine{1137 }
\DoxyCodeLine{1138   seg\%HI\%isg = isg}
\DoxyCodeLine{1139   seg\%HI\%jsg = jsg}
\DoxyCodeLine{1140   seg\%HI\%ieg = ieg}
\DoxyCodeLine{1141   seg\%HI\%jeg = jeg}
\DoxyCodeLine{1142 }
\DoxyCodeLine{1143   \textcolor{comment}{! Move into local index space}}
\DoxyCodeLine{1144   isgb = isgb -\/ g\%idg\_offset}
\DoxyCodeLine{1145   jsgb = jsgb -\/ g\%jdg\_offset}
\DoxyCodeLine{1146   iegb = iegb -\/ g\%idg\_offset}
\DoxyCodeLine{1147   jegb = jegb -\/ g\%jdg\_offset}
\DoxyCodeLine{1148 }
\DoxyCodeLine{1149   isg = isg -\/ g\%idg\_offset}
\DoxyCodeLine{1150   jsg = jsg -\/ g\%jdg\_offset}
\DoxyCodeLine{1151   ieg = ieg -\/ g\%idg\_offset}
\DoxyCodeLine{1152   jeg = jeg -\/ g\%jdg\_offset}
\DoxyCodeLine{1153 }
\DoxyCodeLine{1154   \textcolor{comment}{! This is the i-\/extent of the segment on this PE.}}
\DoxyCodeLine{1155   \textcolor{comment}{! The values are nonsense if the segment is not on this PE.}}
\DoxyCodeLine{1156   seg\%HI\%IsdB = min(max(isgb, g\%HI\%IsdB), g\%HI\%IedB)}
\DoxyCodeLine{1157   seg\%HI\%IedB = min(max(iegb, g\%HI\%IsdB), g\%HI\%IedB)}
\DoxyCodeLine{1158   seg\%HI\%isd = min(max(isg, g\%HI\%isd), g\%HI\%ied)}
\DoxyCodeLine{1159   seg\%HI\%ied = min(max(ieg, g\%HI\%isd), g\%HI\%ied)}
\DoxyCodeLine{1160   seg\%HI\%IscB = min(max(isgb, g\%HI\%IscB), g\%HI\%IecB)}
\DoxyCodeLine{1161   seg\%HI\%IecB = min(max(iegb, g\%HI\%IscB), g\%HI\%IecB)}
\DoxyCodeLine{1162   seg\%HI\%isc = min(max(isg, g\%HI\%isc), g\%HI\%iec)}
\DoxyCodeLine{1163   seg\%HI\%iec = min(max(ieg, g\%HI\%isc), g\%HI\%iec)}
\DoxyCodeLine{1164 }
\DoxyCodeLine{1165   \textcolor{comment}{! This is the j-\/extent of the segment on this PE.}}
\DoxyCodeLine{1166   \textcolor{comment}{! The values are nonsense if the segment is not on this PE.}}
\DoxyCodeLine{1167   seg\%HI\%JsdB = min(max(jsgb, g\%HI\%JsdB), g\%HI\%JedB)}
\DoxyCodeLine{1168   seg\%HI\%JedB = min(max(jegb, g\%HI\%JsdB), g\%HI\%JedB)}
\DoxyCodeLine{1169   seg\%HI\%jsd = min(max(jsg, g\%HI\%jsd), g\%HI\%jed)}
\DoxyCodeLine{1170   seg\%HI\%jed = min(max(jeg, g\%HI\%jsd), g\%HI\%jed)}
\DoxyCodeLine{1171   seg\%HI\%JscB = min(max(jsgb, g\%HI\%JscB), g\%HI\%JecB)}
\DoxyCodeLine{1172   seg\%HI\%JecB = min(max(jegb, g\%HI\%JscB), g\%HI\%JecB)}
\DoxyCodeLine{1173   seg\%HI\%jsc = min(max(jsg, g\%HI\%jsc), g\%HI\%jec)}
\DoxyCodeLine{1174   seg\%HI\%jec = min(max(jeg, g\%HI\%jsc), g\%HI\%jec)}
\DoxyCodeLine{1175 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_aa40e3464225d4e017b1a738995eeb3b2}\label{namespacemom__open__boundary_aa40e3464225d4e017b1a738995eeb3b2}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!setup\_u\_point\_obc@{setup\_u\_point\_obc}}
\index{setup\_u\_point\_obc@{setup\_u\_point\_obc}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{setup\_u\_point\_obc()}{setup\_u\_point\_obc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::setup\+\_\+u\+\_\+point\+\_\+obc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{integer, intent(in)}]{l\+\_\+seg,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF,  }\item[{logical, intent(in)}]{reentrant\+\_\+y }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string starting with \char`\"{}\+I=\char`\"{} and configure placement and type of O\+BC accordingly. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+I=\%,\+J=\%\+:\%,string\char`\"{} \\
\hline
\mbox{\texttt{ in}}  & {\em l\+\_\+seg} & which segment is this? \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & Parameter file handle \\
\hline
\mbox{\texttt{ in}}  & {\em reentrant\+\_\+y} & is the domain reentrant in y? \\
\hline
\end{DoxyParams}


Definition at line 1179 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1180   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1181   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{1182   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1183   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: segment\_str\textcolor{comment}{ !< A string in form of "{}I=\%,J=\%:\%,string"{}}}
\DoxyCodeLine{1184   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)} :: l\_seg\textcolor{comment}{ !< which segment is this?}}
\DoxyCodeLine{1185   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}   :: PF\textcolor{comment}{  !< Parameter file handle}}
\DoxyCodeLine{1186   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}                 :: reentrant\_y\textcolor{comment}{ !< is the domain reentrant in y?}}
\DoxyCodeLine{1187   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1188   \textcolor{keywordtype}{integer} :: I\_obc, Js\_obc, Je\_obc \textcolor{comment}{! Position of segment in global index space}}
\DoxyCodeLine{1189   \textcolor{keywordtype}{integer} :: j, a\_loop}
\DoxyCodeLine{1190   \textcolor{keywordtype}{character(len=32)} :: action\_str(8)}
\DoxyCodeLine{1191   \textcolor{keywordtype}{character(len=128)} :: segment\_param\_str}
\DoxyCodeLine{1192 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)}  :: tnudge}
\DoxyCodeLine{1193   \textcolor{comment}{! This returns the global indices for the segment}}
\DoxyCodeLine{1194   \textcolor{keyword}{call }parse\_segment\_str(g\%ieg, g\%jeg, segment\_str, i\_obc, js\_obc, je\_obc, action\_str, reentrant\_y)}
\DoxyCodeLine{1195 }
\DoxyCodeLine{1196   \textcolor{keyword}{call }setup\_segment\_indices(g, obc\%segment(l\_seg),i\_obc,i\_obc,js\_obc,je\_obc)}
\DoxyCodeLine{1197 }
\DoxyCodeLine{1198   i\_obc = i\_obc -\/ g\%idg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1199   js\_obc = js\_obc -\/ g\%jdg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1200   je\_obc = je\_obc -\/ g\%jdg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1201 }
\DoxyCodeLine{1202   \textcolor{keywordflow}{if} (je\_obc>js\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1203     obc\%segment(l\_seg)\%direction = obc\_direction\_e}
\DoxyCodeLine{1204   \textcolor{keywordflow}{elseif} (je\_obc<js\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1205     obc\%segment(l\_seg)\%direction = obc\_direction\_w}
\DoxyCodeLine{1206     j=js\_obc;js\_obc=je\_obc;je\_obc=j}
\DoxyCodeLine{1207 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1208 }
\DoxyCodeLine{1209   obc\%segment(l\_seg)\%on\_pe = .false.}
\DoxyCodeLine{1210 }
\DoxyCodeLine{1211   \textcolor{keywordflow}{do} a\_loop = 1,8 \textcolor{comment}{! up to 8 options available}}
\DoxyCodeLine{1212     \textcolor{keywordflow}{if} (len\_trim(action\_str(a\_loop)) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1213       cycle}
\DoxyCodeLine{1214     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'FLATHER'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1215       obc\%segment(l\_seg)\%Flather = .true.}
\DoxyCodeLine{1216       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1217       obc\%Flather\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1218       obc\%open\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1219       obc\%segment(l\_seg)\%z\_values\_needed = .true.}
\DoxyCodeLine{1220       obc\%segment(l\_seg)\%u\_values\_needed = .true.}
\DoxyCodeLine{1221     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1222       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1223       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1224       obc\%open\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1225       obc\%radiation\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1226     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1227       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1228       obc\%segment(l\_seg)\%radiation\_tan = .true.}
\DoxyCodeLine{1229       obc\%radiation\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1230     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1231       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1232       obc\%segment(l\_seg)\%radiation\_grad = .true.}
\DoxyCodeLine{1233     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1234       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1235       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1236       obc\%oblique\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1237       obc\%open\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1238     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1239       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1240       obc\%segment(l\_seg)\%oblique\_tan = .true.}
\DoxyCodeLine{1241       obc\%oblique\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1242     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1243       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1244       obc\%segment(l\_seg)\%oblique\_grad = .true.}
\DoxyCodeLine{1245     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1246       obc\%segment(l\_seg)\%nudged = .true.}
\DoxyCodeLine{1247       obc\%nudged\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1248       obc\%segment(l\_seg)\%u\_values\_needed = .true.}
\DoxyCodeLine{1249     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1250       obc\%segment(l\_seg)\%nudged\_tan = .true.}
\DoxyCodeLine{1251       obc\%nudged\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1252       obc\%segment(l\_seg)\%v\_values\_needed = .true.}
\DoxyCodeLine{1253     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1254       obc\%segment(l\_seg)\%nudged\_grad = .true.}
\DoxyCodeLine{1255       obc\%segment(l\_seg)\%g\_values\_needed = .true.}
\DoxyCodeLine{1256     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'GRADIENT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1257       obc\%segment(l\_seg)\%gradient = .true.}
\DoxyCodeLine{1258       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1259       obc\%open\_u\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1260     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1261       obc\%segment(l\_seg)\%specified = .true.}
\DoxyCodeLine{1262       obc\%specified\_u\_BCs\_exist\_globally = .true. \textcolor{comment}{! This avoids deallocation}}
\DoxyCodeLine{1263       obc\%segment(l\_seg)\%u\_values\_needed = .true.}
\DoxyCodeLine{1264     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1265       obc\%segment(l\_seg)\%specified\_tan = .true.}
\DoxyCodeLine{1266       obc\%segment(l\_seg)\%v\_values\_needed = .true.}
\DoxyCodeLine{1267     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1268       obc\%segment(l\_seg)\%specified\_grad = .true.}
\DoxyCodeLine{1269       obc\%segment(l\_seg)\%g\_values\_needed = .true.}
\DoxyCodeLine{1270     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1271       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, setup\_u\_point\_obc: "{}}//\&}
\DoxyCodeLine{1272                      \textcolor{stringliteral}{"{}String '"{}}//trim(action\_str(a\_loop))//\textcolor{stringliteral}{"{}' not understood."{}})}
\DoxyCodeLine{1273 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1274     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%nudged .or. obc\%segment(l\_seg)\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1275       \textcolor{keyword}{write}(segment\_param\_str(1:43),\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3,'\_VELOCITY\_NUDGING\_TIMESCALES')"{}}) l\_seg}
\DoxyCodeLine{1276       \textcolor{keyword}{allocate}(tnudge(2))}
\DoxyCodeLine{1277       \textcolor{keyword}{call }get\_param(pf, mdl, segment\_param\_str(1:43), tnudge, \&}
\DoxyCodeLine{1278                      \textcolor{stringliteral}{"{}Timescales in days for nudging along a segment, "{}}//\&}
\DoxyCodeLine{1279                      \textcolor{stringliteral}{"{}for inflow, then outflow. Setting both to zero should "{}}//\&}
\DoxyCodeLine{1280                      \textcolor{stringliteral}{"{}behave like SIMPLE obcs for the baroclinic velocities."{}}, \&}
\DoxyCodeLine{1281                      fail\_if\_missing=.true., default=0., units=\textcolor{stringliteral}{"{}days"{}}, scale=86400.0*us\%s\_to\_T)}
\DoxyCodeLine{1282       obc\%segment(l\_seg)\%Velocity\_nudging\_timescale\_in = tnudge(1)}
\DoxyCodeLine{1283       obc\%segment(l\_seg)\%Velocity\_nudging\_timescale\_out = tnudge(2)}
\DoxyCodeLine{1284       \textcolor{keyword}{deallocate}(tnudge)}
\DoxyCodeLine{1285 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1286 }
\DoxyCodeLine{1287 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! a\_loop}}
\DoxyCodeLine{1288 }
\DoxyCodeLine{1289   obc\%segment(l\_seg)\%is\_E\_or\_W\_2 = .true.}
\DoxyCodeLine{1290 }
\DoxyCodeLine{1291   \textcolor{keywordflow}{if} (i\_obc<=g\%HI\%IsdB+1 .or. i\_obc>=g\%HI\%IedB-\/1) \textcolor{keywordflow}{return} \textcolor{comment}{! Boundary is not on tile}}
\DoxyCodeLine{1292   \textcolor{keywordflow}{if} (je\_obc<=g\%HI\%JsdB .or. js\_obc>=g\%HI\%JedB) \textcolor{keywordflow}{return} \textcolor{comment}{! Segment is not on tile}}
\DoxyCodeLine{1293 }
\DoxyCodeLine{1294   obc\%segment(l\_seg)\%on\_pe = .true.}
\DoxyCodeLine{1295   obc\%segment(l\_seg)\%is\_E\_or\_W = .true.}
\DoxyCodeLine{1296 }
\DoxyCodeLine{1297   \textcolor{keywordflow}{do} j=g\%HI\%jsd, g\%HI\%jed}
\DoxyCodeLine{1298     \textcolor{keywordflow}{if} (j>js\_obc .and. j<=je\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1299       obc\%segnum\_u(i\_obc,j) = l\_seg}
\DoxyCodeLine{1300 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1301 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1302   obc\%segment(l\_seg)\%Is\_obc = i\_obc}
\DoxyCodeLine{1303   obc\%segment(l\_seg)\%Ie\_obc = i\_obc}
\DoxyCodeLine{1304   obc\%segment(l\_seg)\%Js\_obc = js\_obc}
\DoxyCodeLine{1305   obc\%segment(l\_seg)\%Je\_obc = je\_obc}
\DoxyCodeLine{1306   \textcolor{keyword}{call }allocate\_obc\_segment\_data(obc, obc\%segment(l\_seg))}
\DoxyCodeLine{1307 }
\DoxyCodeLine{1308   \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%oblique .and.  obc\%segment(l\_seg)\%radiation) \&}
\DoxyCodeLine{1309          \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, setup\_u\_point\_obc: \(\backslash\)n"{}}//\&}
\DoxyCodeLine{1310          \textcolor{stringliteral}{"{}Orlanski and Oblique OBC options cannot be used together on one segment."{}})}
\DoxyCodeLine{1311 }
\DoxyCodeLine{1312   \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%u\_values\_needed .or. obc\%segment(l\_seg)\%v\_values\_needed .or. \&}
\DoxyCodeLine{1313       obc\%segment(l\_seg)\%t\_values\_needed .or. obc\%segment(l\_seg)\%s\_values\_needed .or. \&}
\DoxyCodeLine{1314       obc\%segment(l\_seg)\%z\_values\_needed .or. obc\%segment(l\_seg)\%g\_values\_needed) \&}
\DoxyCodeLine{1315     obc\%segment(l\_seg)\%values\_needed = .true.}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a706dd2fb2049757b3b76bf8b481e735c}\label{namespacemom__open__boundary_a706dd2fb2049757b3b76bf8b481e735c}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!setup\_v\_point\_obc@{setup\_v\_point\_obc}}
\index{setup\_v\_point\_obc@{setup\_v\_point\_obc}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{setup\_v\_point\_obc()}{setup\_v\_point\_obc()}}
{\footnotesize\ttfamily subroutine mom\+\_\+open\+\_\+boundary\+::setup\+\_\+v\+\_\+point\+\_\+obc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{character(len=$\ast$), intent(in)}]{segment\+\_\+str,  }\item[{integer, intent(in)}]{l\+\_\+seg,  }\item[{type(\mbox{\hyperlink{structmom__file__parser_1_1param__file__type}{param\+\_\+file\+\_\+type}}), intent(in)}]{PF,  }\item[{logical, intent(in)}]{reentrant\+\_\+x }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Parse an O\+B\+C\+\_\+\+S\+E\+G\+M\+E\+N\+T\+\_\+\%\%\% string starting with \char`\"{}\+J=\char`\"{} and configure placement and type of O\+BC accordingly. 


\begin{DoxyParams}[1]{Parameters}
 & {\em obc} & Open boundary control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em segment\+\_\+str} & A string in form of \char`\"{}\+J=\%,\+I=\%\+:\%,string\char`\"{} \\
\hline
\mbox{\texttt{ in}}  & {\em l\+\_\+seg} & which segment is this? \\
\hline
\mbox{\texttt{ in}}  & {\em pf} & Parameter file handle \\
\hline
\mbox{\texttt{ in}}  & {\em reentrant\+\_\+x} & is the domain reentrant in x? \\
\hline
\end{DoxyParams}


Definition at line 1319 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1320   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< Open boundary control structure}}
\DoxyCodeLine{1321   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{1322   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{1323   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: segment\_str\textcolor{comment}{ !< A string in form of "{}J=\%,I=\%:\%,string"{}}}
\DoxyCodeLine{1324   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)} :: l\_seg\textcolor{comment}{ !< which segment is this?}}
\DoxyCodeLine{1325   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: PF\textcolor{comment}{  !< Parameter file handle}}
\DoxyCodeLine{1326   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)}                 :: reentrant\_x\textcolor{comment}{ !< is the domain reentrant in x?}}
\DoxyCodeLine{1327   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1328   \textcolor{keywordtype}{integer} :: J\_obc, Is\_obc, Ie\_obc \textcolor{comment}{! Position of segment in global index space}}
\DoxyCodeLine{1329   \textcolor{keywordtype}{integer} :: i, a\_loop}
\DoxyCodeLine{1330   \textcolor{keywordtype}{character(len=32)} :: action\_str(8)}
\DoxyCodeLine{1331   \textcolor{keywordtype}{character(len=128)} :: segment\_param\_str}
\DoxyCodeLine{1332 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)}  :: tnudge}
\DoxyCodeLine{1333 }
\DoxyCodeLine{1334   \textcolor{comment}{! This returns the global indices for the segment}}
\DoxyCodeLine{1335   \textcolor{keyword}{call }parse\_segment\_str(g\%ieg, g\%jeg, segment\_str, j\_obc, is\_obc, ie\_obc, action\_str, reentrant\_x)}
\DoxyCodeLine{1336 }
\DoxyCodeLine{1337   \textcolor{keyword}{call }setup\_segment\_indices(g, obc\%segment(l\_seg),is\_obc,ie\_obc,j\_obc,j\_obc)}
\DoxyCodeLine{1338 }
\DoxyCodeLine{1339   j\_obc = j\_obc -\/ g\%jdg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1340   is\_obc = is\_obc -\/ g\%idg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1341   ie\_obc = ie\_obc -\/ g\%idg\_offset \textcolor{comment}{! Convert to local tile indices on this tile}}
\DoxyCodeLine{1342 }
\DoxyCodeLine{1343   \textcolor{keywordflow}{if} (ie\_obc>is\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1344      obc\%segment(l\_seg)\%direction = obc\_direction\_s}
\DoxyCodeLine{1345   \textcolor{keywordflow}{elseif} (ie\_obc<is\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1346      obc\%segment(l\_seg)\%direction = obc\_direction\_n}
\DoxyCodeLine{1347      i=is\_obc;is\_obc=ie\_obc;ie\_obc=i}
\DoxyCodeLine{1348 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1349 }
\DoxyCodeLine{1350   obc\%segment(l\_seg)\%on\_pe = .false.}
\DoxyCodeLine{1351 }
\DoxyCodeLine{1352   \textcolor{keywordflow}{do} a\_loop = 1,8}
\DoxyCodeLine{1353     \textcolor{keywordflow}{if} (len\_trim(action\_str(a\_loop)) == 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1354       cycle}
\DoxyCodeLine{1355     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'FLATHER'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1356       obc\%segment(l\_seg)\%Flather = .true.}
\DoxyCodeLine{1357       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1358       obc\%Flather\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1359       obc\%open\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1360       obc\%segment(l\_seg)\%z\_values\_needed = .true.}
\DoxyCodeLine{1361       obc\%segment(l\_seg)\%v\_values\_needed = .true.}
\DoxyCodeLine{1362     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1363       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1364       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1365       obc\%open\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1366       obc\%radiation\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1367     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1368       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1369       obc\%segment(l\_seg)\%radiation\_tan = .true.}
\DoxyCodeLine{1370       obc\%radiation\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1371     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'ORLANSKI\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1372       obc\%segment(l\_seg)\%radiation = .true.}
\DoxyCodeLine{1373       obc\%segment(l\_seg)\%radiation\_grad = .true.}
\DoxyCodeLine{1374     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1375       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1376       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1377       obc\%oblique\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1378       obc\%open\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1379     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1380       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1381       obc\%segment(l\_seg)\%oblique\_tan = .true.}
\DoxyCodeLine{1382       obc\%oblique\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1383     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'OBLIQUE\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1384       obc\%segment(l\_seg)\%oblique = .true.}
\DoxyCodeLine{1385       obc\%segment(l\_seg)\%oblique\_grad = .true.}
\DoxyCodeLine{1386     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1387       obc\%segment(l\_seg)\%nudged = .true.}
\DoxyCodeLine{1388       obc\%nudged\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1389       obc\%segment(l\_seg)\%v\_values\_needed = .true.}
\DoxyCodeLine{1390     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1391       obc\%segment(l\_seg)\%nudged\_tan = .true.}
\DoxyCodeLine{1392       obc\%nudged\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1393       obc\%segment(l\_seg)\%u\_values\_needed = .true.}
\DoxyCodeLine{1394     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'NUDGED\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1395       obc\%segment(l\_seg)\%nudged\_grad = .true.}
\DoxyCodeLine{1396       obc\%segment(l\_seg)\%g\_values\_needed = .true.}
\DoxyCodeLine{1397     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'GRADIENT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1398       obc\%segment(l\_seg)\%gradient = .true.}
\DoxyCodeLine{1399       obc\%segment(l\_seg)\%open = .true.}
\DoxyCodeLine{1400       obc\%open\_v\_BCs\_exist\_globally = .true.}
\DoxyCodeLine{1401     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1402       obc\%segment(l\_seg)\%specified = .true.}
\DoxyCodeLine{1403       obc\%specified\_v\_BCs\_exist\_globally = .true. \textcolor{comment}{! This avoids deallocation}}
\DoxyCodeLine{1404       obc\%segment(l\_seg)\%v\_values\_needed = .true.}
\DoxyCodeLine{1405     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE\_TAN'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1406       obc\%segment(l\_seg)\%specified\_tan = .true.}
\DoxyCodeLine{1407       obc\%segment(l\_seg)\%u\_values\_needed = .true.}
\DoxyCodeLine{1408     \textcolor{keywordflow}{elseif} (trim(action\_str(a\_loop)) == \textcolor{stringliteral}{'SIMPLE\_GRAD'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1409       obc\%segment(l\_seg)\%specified\_grad = .true.}
\DoxyCodeLine{1410       obc\%segment(l\_seg)\%g\_values\_needed = .true.}
\DoxyCodeLine{1411     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1412       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, setup\_v\_point\_obc: "{}}//\&}
\DoxyCodeLine{1413                      \textcolor{stringliteral}{"{}String '"{}}//trim(action\_str(a\_loop))//\textcolor{stringliteral}{"{}' not understood."{}})}
\DoxyCodeLine{1414 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1415     \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%nudged .or. obc\%segment(l\_seg)\%nudged\_tan) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1416       \textcolor{keyword}{write}(segment\_param\_str(1:43),\textcolor{stringliteral}{"{}('OBC\_SEGMENT\_',i3.3,'\_VELOCITY\_NUDGING\_TIMESCALES')"{}}) l\_seg}
\DoxyCodeLine{1417       \textcolor{keyword}{allocate}(tnudge(2))}
\DoxyCodeLine{1418       \textcolor{keyword}{call }get\_param(pf, mdl, segment\_param\_str(1:43), tnudge, \&}
\DoxyCodeLine{1419                      \textcolor{stringliteral}{"{}Timescales in days for nudging along a segment, "{}}//\&}
\DoxyCodeLine{1420                      \textcolor{stringliteral}{"{}for inflow, then outflow. Setting both to zero should "{}}//\&}
\DoxyCodeLine{1421                      \textcolor{stringliteral}{"{}behave like SIMPLE obcs for the baroclinic velocities."{}}, \&}
\DoxyCodeLine{1422                      fail\_if\_missing=.true., default=0., units=\textcolor{stringliteral}{"{}days"{}}, scale=86400.0*us\%s\_to\_T)}
\DoxyCodeLine{1423       obc\%segment(l\_seg)\%Velocity\_nudging\_timescale\_in = tnudge(1)}
\DoxyCodeLine{1424       obc\%segment(l\_seg)\%Velocity\_nudging\_timescale\_out = tnudge(2)}
\DoxyCodeLine{1425       \textcolor{keyword}{deallocate}(tnudge)}
\DoxyCodeLine{1426 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1427 }
\DoxyCodeLine{1428 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! a\_loop}}
\DoxyCodeLine{1429 }
\DoxyCodeLine{1430   \textcolor{keywordflow}{if} (j\_obc<=g\%HI\%JsdB+1 .or. j\_obc>=g\%HI\%JedB-\/1) \textcolor{keywordflow}{return} \textcolor{comment}{! Boundary is not on tile}}
\DoxyCodeLine{1431   \textcolor{keywordflow}{if} (ie\_obc<=g\%HI\%IsdB .or. is\_obc>=g\%HI\%IedB) \textcolor{keywordflow}{return} \textcolor{comment}{! Segment is not on tile}}
\DoxyCodeLine{1432 }
\DoxyCodeLine{1433   obc\%segment(l\_seg)\%on\_pe = .true.}
\DoxyCodeLine{1434   obc\%segment(l\_seg)\%is\_N\_or\_S = .true.}
\DoxyCodeLine{1435 }
\DoxyCodeLine{1436   \textcolor{keywordflow}{do} i=g\%HI\%isd, g\%HI\%ied}
\DoxyCodeLine{1437     \textcolor{keywordflow}{if} (i>is\_obc .and. i<=ie\_obc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1438       obc\%segnum\_v(i,j\_obc) = l\_seg}
\DoxyCodeLine{1439 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1440 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{1441   obc\%segment(l\_seg)\%Is\_obc = is\_obc}
\DoxyCodeLine{1442   obc\%segment(l\_seg)\%Ie\_obc = ie\_obc}
\DoxyCodeLine{1443   obc\%segment(l\_seg)\%Js\_obc = j\_obc}
\DoxyCodeLine{1444   obc\%segment(l\_seg)\%Je\_obc = j\_obc}
\DoxyCodeLine{1445   \textcolor{keyword}{call }allocate\_obc\_segment\_data(obc, obc\%segment(l\_seg))}
\DoxyCodeLine{1446 }
\DoxyCodeLine{1447   \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%oblique .and.  obc\%segment(l\_seg)\%radiation) \&}
\DoxyCodeLine{1448          \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}MOM\_open\_boundary.F90, setup\_v\_point\_obc: \(\backslash\)n"{}}//\&}
\DoxyCodeLine{1449          \textcolor{stringliteral}{"{}Orlanski and Oblique OBC options cannot be used together on one segment."{}})}
\DoxyCodeLine{1450 }
\DoxyCodeLine{1451   \textcolor{keywordflow}{if} (obc\%segment(l\_seg)\%u\_values\_needed .or. obc\%segment(l\_seg)\%v\_values\_needed .or. \&}
\DoxyCodeLine{1452       obc\%segment(l\_seg)\%t\_values\_needed .or. obc\%segment(l\_seg)\%s\_values\_needed .or. \&}
\DoxyCodeLine{1453       obc\%segment(l\_seg)\%z\_values\_needed .or. obc\%segment(l\_seg)\%g\_values\_needed) \&}
\DoxyCodeLine{1454     obc\%segment(l\_seg)\%values\_needed = .true.}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a2459650f97c35ba541246d1418efb6a1}\label{namespacemom__open__boundary_a2459650f97c35ba541246d1418efb6a1}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!update\_obc\_ramp@{update\_obc\_ramp}}
\index{update\_obc\_ramp@{update\_obc\_ramp}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{update\_obc\_ramp()}{update\_obc\_ramp()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::update\+\_\+obc\+\_\+ramp (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{logical, intent(in), optional}]{activate }\end{DoxyParamCaption})}



Update the O\+BC ramp value as a function of time. If called with the optional argument activate=.true., record the value of Time as the beginning of the ramp period. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & Current model time \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em activate} & Specifiy whether to record the value of Time as the beginning of the ramp period \\
\hline
\end{DoxyParams}


Definition at line 4373 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{4374   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{     !< Current model time}}
\DoxyCodeLine{4375   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{      !< Open boundary structure}}
\DoxyCodeLine{4376   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},       \textcolor{keywordtype}{intent(in)}    :: activate\textcolor{comment}{ !< Specifiy whether to record the value of}}
\DoxyCodeLine{4377 \textcolor{comment}{                                                     !! Time as the beginning of the ramp period}}
\DoxyCodeLine{4378 }
\DoxyCodeLine{4379   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{4380 \textcolor{keywordtype}{  real} :: deltaTime, wghtA}
\DoxyCodeLine{4381   \textcolor{keywordtype}{character(len=12)} :: msg}
\DoxyCodeLine{4382 }
\DoxyCodeLine{4383   \textcolor{keywordflow}{if} (.not. obc\%ramp) \textcolor{keywordflow}{return} \textcolor{comment}{! This indicates the ramping is turned off}}
\DoxyCodeLine{4384 }
\DoxyCodeLine{4385   \textcolor{comment}{! We use the optional argument to indicate this Time should be recorded as the}}
\DoxyCodeLine{4386   \textcolor{comment}{! beginning of the ramp-\/up period.}}
\DoxyCodeLine{4387   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(activate)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4388     \textcolor{keywordflow}{if} (activate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4389       obc\%ramp\_start\_time = time \textcolor{comment}{! Record the current time}}
\DoxyCodeLine{4390       obc\%ramping\_is\_activated = .true.}
\DoxyCodeLine{4391       obc\%trunc\_ramp\_time = obc\%ramp\_timescale \textcolor{comment}{! times 3.0 for tanh}}
\DoxyCodeLine{4392 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{4393 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4394   \textcolor{keywordflow}{if} (.not.obc\%ramping\_is\_activated) \textcolor{keywordflow}{return}}
\DoxyCodeLine{4395   deltatime = max( 0., time\_type\_to\_real( time -\/ obc\%ramp\_start\_time ) )}
\DoxyCodeLine{4396   \textcolor{keywordflow}{if} (deltatime >= obc\%trunc\_ramp\_time) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4397     obc\%ramp\_value = 1.0}
\DoxyCodeLine{4398     obc\%ramp = .false. \textcolor{comment}{! This turns off ramping after this call}}
\DoxyCodeLine{4399   \textcolor{keywordflow}{else}}
\DoxyCodeLine{4400     wghta = min( 1., deltatime / obc\%ramp\_timescale ) \textcolor{comment}{! Linear profile in time}}
\DoxyCodeLine{4401     \textcolor{comment}{!wghtA = wghtA*wghtA ! Convert linear profile to parabolic profile in time}}
\DoxyCodeLine{4402     \textcolor{comment}{!wghtA = wghtA*wghtA*(3. -\/ 2.*wghtA) ! Convert linear profile to cosine profile}}
\DoxyCodeLine{4403     \textcolor{comment}{!wghtA = 1. -\/ ( (1. -\/ wghtA)**2 ) ! Convert linear profile to inverted parabolic profile}}
\DoxyCodeLine{4404     \textcolor{comment}{!wghtA = tanh(wghtA)              ! Convert linear profile to tanh}}
\DoxyCodeLine{4405     obc\%ramp\_value = wghta}
\DoxyCodeLine{4406 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{4407   \textcolor{keyword}{write}(msg(1:12),\textcolor{stringliteral}{'(es12.3)'}) obc\%ramp\_value}
\DoxyCodeLine{4408   \textcolor{keyword}{call }mom\_error(note, \textcolor{stringliteral}{"{}MOM\_open\_boundary: update\_OBC\_ramp set OBC"{}}// \&}
\DoxyCodeLine{4409                        \textcolor{stringliteral}{"{} ramp to "{}}//trim(msg))}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a8d2c8b028b9fc7d65f17155497a0487d}\label{namespacemom__open__boundary_a8d2c8b028b9fc7d65f17155497a0487d}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!update\_obc\_segment\_data@{update\_obc\_segment\_data}}
\index{update\_obc\_segment\_data@{update\_obc\_segment\_data}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{update\_obc\_segment\_data()}{update\_obc\_segment\_data()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::update\+\_\+obc\+\_\+segment\+\_\+data (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{type(\mbox{\hyperlink{structmom__variables_1_1thermo__var__ptrs}{thermo\+\_\+var\+\_\+ptrs}}), intent(in)}]{tv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  g \%ke), intent(inout)}]{h,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})}



Update the O\+BC values on the segments. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & Thermodynamics structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em time} & Model time \\
\hline
\end{DoxyParams}


Definition at line 3731 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{3732   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< Ocean grid structure}}
\DoxyCodeLine{3733   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !<  Ocean vertical grid structure}}
\DoxyCodeLine{3734   \textcolor{keywordtype}{type}(unit\_scale\_type),                     \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{3735   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{  !< Open boundary structure}}
\DoxyCodeLine{3736   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                     \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< Thermodynamics structure}}
\DoxyCodeLine{3737 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(G))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{    !< Thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{3738   \textcolor{keywordtype}{type}(time\_type),                           \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< Model time}}
\DoxyCodeLine{3739   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{3740   \textcolor{keywordtype}{integer} :: c, i, j, k, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{3741   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB, n, m, nz}
\DoxyCodeLine{3742   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"{}update\_OBC\_segment\_data"{}} \textcolor{comment}{! This subroutine's name.}}
\DoxyCodeLine{3743   \textcolor{keywordtype}{character(len=200)} :: filename, OBC\_file, inputdir \textcolor{comment}{! Strings for file/path}}
\DoxyCodeLine{3744   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment => null()}
\DoxyCodeLine{3745   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(4)} :: siz}
\DoxyCodeLine{3746 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: tmp\_buffer\_in => null()  \textcolor{comment}{! Unrotated input}}
\DoxyCodeLine{3747   \textcolor{keywordtype}{integer} :: ni\_seg, nj\_seg  \textcolor{comment}{! number of src gridpoints along the segments}}
\DoxyCodeLine{3748   \textcolor{keywordtype}{integer} :: ni\_buf, nj\_buf  \textcolor{comment}{! Number of filled values in tmp\_buffer}}
\DoxyCodeLine{3749   \textcolor{keywordtype}{integer} :: i2, j2          \textcolor{comment}{! indices for referencing local domain array}}
\DoxyCodeLine{3750   \textcolor{keywordtype}{integer} :: is\_obc, ie\_obc, js\_obc, je\_obc  \textcolor{comment}{! segment indices within local domain}}
\DoxyCodeLine{3751   \textcolor{keywordtype}{integer} :: ishift, jshift  \textcolor{comment}{! offsets for staggered locations}}
\DoxyCodeLine{3752 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: seg\_vel => null()  \textcolor{comment}{! pointer to segment velocity array}}
\DoxyCodeLine{3753 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{pointer} :: seg\_trans => null()  \textcolor{comment}{! pointer to segment transport array}}
\DoxyCodeLine{3754 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{target} :: tmp\_buffer}
\DoxyCodeLine{3755 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: h\_stack}
\DoxyCodeLine{3756   \textcolor{keywordtype}{integer} :: is\_obc2, js\_obc2}
\DoxyCodeLine{3757 \textcolor{keywordtype}{  real} :: net\_H\_src, net\_H\_int, scl\_fac}
\DoxyCodeLine{3758 \textcolor{keywordtype}{  real} :: tidal\_vel, tidal\_elev}
\DoxyCodeLine{3759 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:)}   :: normal\_trans\_bt=>null() \textcolor{comment}{! barotropic transport}}
\DoxyCodeLine{3760   \textcolor{keywordtype}{integer} :: turns      \textcolor{comment}{! Number of index quarter turns}}
\DoxyCodeLine{3761 \textcolor{keywordtype}{  real} :: time\_delta  \textcolor{comment}{! Time since tidal reference date}}
\DoxyCodeLine{3762 }
\DoxyCodeLine{3763   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{3764   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{3765   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{3766   nz=g\%ke}
\DoxyCodeLine{3767 }
\DoxyCodeLine{3768   turns = g\%HI\%turns}
\DoxyCodeLine{3769 }
\DoxyCodeLine{3770   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{3771 }
\DoxyCodeLine{3772   \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) time\_delta = time\_type\_to\_real(time -\/ obc\%time\_ref)}
\DoxyCodeLine{3773 }
\DoxyCodeLine{3774   \textcolor{keywordflow}{do} n = 1, obc\%number\_of\_segments}
\DoxyCodeLine{3775     segment => obc\%segment(n)}
\DoxyCodeLine{3776 }
\DoxyCodeLine{3777     \textcolor{keywordflow}{if} (.not. segment\%on\_pe) cycle \textcolor{comment}{! continue to next segment if not in computational domain}}
\DoxyCodeLine{3778 }
\DoxyCodeLine{3779     \textcolor{comment}{! NOTE: These are in segment\%HI, but defined slightly differently}}
\DoxyCodeLine{3780     ni\_seg = segment\%ie\_obc-\/segment\%is\_obc+1}
\DoxyCodeLine{3781     nj\_seg = segment\%je\_obc-\/segment\%js\_obc+1}
\DoxyCodeLine{3782     is\_obc = max(segment\%is\_obc,isd-\/1)}
\DoxyCodeLine{3783     ie\_obc = min(segment\%ie\_obc,ied)}
\DoxyCodeLine{3784     js\_obc = max(segment\%js\_obc,jsd-\/1)}
\DoxyCodeLine{3785     je\_obc = min(segment\%je\_obc,jed)}
\DoxyCodeLine{3786 }
\DoxyCodeLine{3787 \textcolor{comment}{! Calculate auxiliary fields at staggered locations.}}
\DoxyCodeLine{3788 \textcolor{comment}{! Segment indices are on q points:}}
\DoxyCodeLine{3789 \textcolor{comment}{!}}
\DoxyCodeLine{3790 \textcolor{comment}{!       |-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/|  J\_obc}}
\DoxyCodeLine{3791 \textcolor{comment}{!     Is\_obc                                          Ie\_obc}}
\DoxyCodeLine{3792 \textcolor{comment}{!}}
\DoxyCodeLine{3793 \textcolor{comment}{! i2 has to start at Is\_obc+1 and end at Ie\_obc.}}
\DoxyCodeLine{3794 \textcolor{comment}{! j2 is J\_obc and jshift has to be +1 at both the north and south.}}
\DoxyCodeLine{3795 }
\DoxyCodeLine{3796      \textcolor{comment}{! calculate auxiliary fields at staggered locations}}
\DoxyCodeLine{3797     ishift=0;jshift=0}
\DoxyCodeLine{3798     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3799       \textcolor{keyword}{allocate}(normal\_trans\_bt(segment\%HI\%IsdB:segment\%HI\%IedB,segment\%HI\%jsd:segment\%HI\%jed))}
\DoxyCodeLine{3800       normal\_trans\_bt(:,:)=0.0}
\DoxyCodeLine{3801       \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) ishift=1}
\DoxyCodeLine{3802       i=segment\%HI\%IsdB}
\DoxyCodeLine{3803       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{3804         segment\%Cg(i,j) = sqrt(gv\%g\_prime(1)*g\%bathyT(i+ishift,j))}
\DoxyCodeLine{3805         segment\%Htot(i,j)=0.0}
\DoxyCodeLine{3806         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3807           segment\%h(i,j,k) = h(i+ishift,j,k)}
\DoxyCodeLine{3808           segment\%Htot(i,j)=segment\%Htot(i,j)+segment\%h(i,j,k)}
\DoxyCodeLine{3809 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3810 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3811     else\textcolor{comment}{! (segment\%direction == OBC\_DIRECTION\_N .or. segment\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{3812       \textcolor{keyword}{allocate}(normal\_trans\_bt(segment\%HI\%isd:segment\%HI\%ied,segment\%HI\%JsdB:segment\%HI\%JedB))}
\DoxyCodeLine{3813       normal\_trans\_bt(:,:)=0.0}
\DoxyCodeLine{3814       \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) jshift=1}
\DoxyCodeLine{3815       j=segment\%HI\%JsdB}
\DoxyCodeLine{3816       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{3817         segment\%Cg(i,j) = sqrt(gv\%g\_prime(1)*g\%bathyT(i,j+jshift))}
\DoxyCodeLine{3818         segment\%Htot(i,j)=0.0}
\DoxyCodeLine{3819         \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{3820           segment\%h(i,j,k) = h(i,j+jshift,k)}
\DoxyCodeLine{3821           segment\%Htot(i,j)=segment\%Htot(i,j)+segment\%h(i,j,k)}
\DoxyCodeLine{3822 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{3823 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{3824 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{3825 }
\DoxyCodeLine{3826     \textcolor{keyword}{allocate}(h\_stack(g\%ke))}
\DoxyCodeLine{3827     h\_stack(:) = 0.0}
\DoxyCodeLine{3828     \textcolor{keywordflow}{do} m = 1,segment\%num\_fields}
\DoxyCodeLine{3829       \textcolor{keywordflow}{if} (segment\%field(m)\%fid > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3830         siz(1)=\textcolor{keyword}{size}(segment\%field(m)\%buffer\_src,1)}
\DoxyCodeLine{3831         siz(2)=\textcolor{keyword}{size}(segment\%field(m)\%buffer\_src,2)}
\DoxyCodeLine{3832         siz(3)=\textcolor{keyword}{size}(segment\%field(m)\%buffer\_src,3)}
\DoxyCodeLine{3833         \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(segment\%field(m)\%buffer\_dst)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3834           \textcolor{keywordflow}{if} (siz(3) /= segment\%field(m)\%nk\_src) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'nk\_src inconsistency'})}
\DoxyCodeLine{3835           \textcolor{keywordflow}{if} (segment\%field(m)\%nk\_src > 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3836             \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3837               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3838                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{3839               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3840                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,siz(3))) \textcolor{comment}{! 3rd dim is constituent}}
\DoxyCodeLine{3841               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'} .or. \&}
\DoxyCodeLine{3842                   segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3843                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,siz(3)))  \textcolor{comment}{! 3rd dim is constituent}}
\DoxyCodeLine{3844               \textcolor{keywordflow}{else}}
\DoxyCodeLine{3845                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,g\%ke))}
\DoxyCodeLine{3846 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3847             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3848               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3849                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{3850               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3851                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,siz(3))) \textcolor{comment}{! 3rd dim is constituent}}
\DoxyCodeLine{3852               \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'} .or. \&}
\DoxyCodeLine{3853                   segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3854                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,siz(3))) \textcolor{comment}{! 3rd dim is constituent}}
\DoxyCodeLine{3855               \textcolor{keywordflow}{else}}
\DoxyCodeLine{3856                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{3857 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3858 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3859           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3860             \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3861               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'} .or. \&}
\DoxyCodeLine{3862                   segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3863                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{3864               \textcolor{keywordflow}{else}}
\DoxyCodeLine{3865                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,1))}
\DoxyCodeLine{3866 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3867             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3868               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'} .or. \&}
\DoxyCodeLine{3869                 segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3870                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{3871               \textcolor{keywordflow}{else}}
\DoxyCodeLine{3872                 \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{3873 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3874 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3875 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3876           segment\%field(m)\%buffer\_dst(:,:,:)=0.0}
\DoxyCodeLine{3877 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3878         \textcolor{comment}{! read source data interpolated to the current model time}}
\DoxyCodeLine{3879         \textcolor{comment}{! NOTE: buffer is sized for vertex points, but may be used for faces}}
\DoxyCodeLine{3880         \textcolor{keywordflow}{if} (siz(1)==1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3881           \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3882             \textcolor{keyword}{allocate}(tmp\_buffer(1,nj\_seg*2-\/1,segment\%field(m)\%nk\_src))  \textcolor{comment}{! segment data is currrently on supergrid}}
\DoxyCodeLine{3883           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3884             \textcolor{keyword}{allocate}(tmp\_buffer(1,nj\_seg,segment\%field(m)\%nk\_src))  \textcolor{comment}{! segment data is currrently on supergrid}}
\DoxyCodeLine{3885 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3886         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3887           \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3888             \textcolor{keyword}{allocate}(tmp\_buffer(ni\_seg*2-\/1,1,segment\%field(m)\%nk\_src))  \textcolor{comment}{! segment data is currrently on supergrid}}
\DoxyCodeLine{3889           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3890             \textcolor{keyword}{allocate}(tmp\_buffer(ni\_seg,1,segment\%field(m)\%nk\_src))  \textcolor{comment}{! segment data is currrently on supergrid}}
\DoxyCodeLine{3891 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3892 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3893 }
\DoxyCodeLine{3894         \textcolor{comment}{! TODO: Since we conditionally rotate a subset of tmp\_buffer\_in after}}
\DoxyCodeLine{3895         \textcolor{comment}{!   reading the value, it is currently not possible to use the rotated}}
\DoxyCodeLine{3896         \textcolor{comment}{!   implementation of time\_interp\_external.}}
\DoxyCodeLine{3897         \textcolor{comment}{!   For now, we must explicitly allocate and rotate this array.}}
\DoxyCodeLine{3898         \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3899           \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3900             \textcolor{keyword}{allocate}(tmp\_buffer\_in(\textcolor{keyword}{size}(tmp\_buffer, 2), \textcolor{keyword}{size}(tmp\_buffer, 1), \textcolor{keyword}{size}(tmp\_buffer, 3)))}
\DoxyCodeLine{3901           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3902             \textcolor{keyword}{allocate}(tmp\_buffer\_in(\textcolor{keyword}{size}(tmp\_buffer, 1), \textcolor{keyword}{size}(tmp\_buffer, 2), \textcolor{keyword}{size}(tmp\_buffer, 3)))}
\DoxyCodeLine{3903 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3904         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3905           tmp\_buffer\_in => tmp\_buffer}
\DoxyCodeLine{3906 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3907 }
\DoxyCodeLine{3908         \textcolor{keyword}{call }time\_interp\_external(segment\%field(m)\%fid,time, tmp\_buffer\_in)}
\DoxyCodeLine{3909         \textcolor{comment}{! NOTE: Rotation of face-\/points require that we skip the final value}}
\DoxyCodeLine{3910         \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3911           \textcolor{comment}{! TODO: This is hardcoded for 90 degrees, and needs to be generalized.}}
\DoxyCodeLine{3912           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W \&}
\DoxyCodeLine{3913               .and. .not. (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} \&}
\DoxyCodeLine{3914                   .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3915             nj\_buf = \textcolor{keyword}{size}(tmp\_buffer, 2) -\/ 1}
\DoxyCodeLine{3916             \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in(:nj\_buf,:,:), turns, tmp\_buffer(:,:nj\_buf,:))}
\DoxyCodeLine{3917           \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S \&}
\DoxyCodeLine{3918               .and. .not. (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} \&}
\DoxyCodeLine{3919                   .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3920             ni\_buf = \textcolor{keyword}{size}(tmp\_buffer, 1) -\/ 1}
\DoxyCodeLine{3921             \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in(:,:ni\_buf,:), turns, tmp\_buffer(:ni\_buf,:,:))}
\DoxyCodeLine{3922           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3923             \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in, turns, tmp\_buffer)}
\DoxyCodeLine{3924 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3925 }
\DoxyCodeLine{3926           \textcolor{comment}{! TODO: This is hardcoded for 90 degrees, and needs to be generalized.}}
\DoxyCodeLine{3927           \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} \&}
\DoxyCodeLine{3928               .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'} \&}
\DoxyCodeLine{3929               .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'} \&}
\DoxyCodeLine{3930               .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3931             tmp\_buffer(:,:,:) = -\/tmp\_buffer(:,:,:)}
\DoxyCodeLine{3932 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3933 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3934 }
\DoxyCodeLine{3935         \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3936           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3937             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'} .or. \&}
\DoxyCodeLine{3938                 segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3939               segment\%field(m)\%buffer\_src(is\_obc,:,:) = \&}
\DoxyCodeLine{3940                   tmp\_buffer(1,2*(js\_obc+g\%jdg\_offset)+1:2*(je\_obc+g\%jdg\_offset)+1:2,:)}
\DoxyCodeLine{3941             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3942               segment\%field(m)\%buffer\_src(is\_obc,:,:) = \&}
\DoxyCodeLine{3943                   tmp\_buffer(1,2*(js\_obc+g\%jdg\_offset)+1:2*(je\_obc+g\%jdg\_offset):2,:)}
\DoxyCodeLine{3944 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3945           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3946             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'} .or. \&}
\DoxyCodeLine{3947                 segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3948               segment\%field(m)\%buffer\_src(:,js\_obc,:) = \&}
\DoxyCodeLine{3949                   tmp\_buffer(2*(is\_obc+g\%idg\_offset)+1:2*(ie\_obc+g\%idg\_offset)+1:2,1,:)}
\DoxyCodeLine{3950             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3951               segment\%field(m)\%buffer\_src(:,js\_obc,:) = \&}
\DoxyCodeLine{3952                   tmp\_buffer(2*(is\_obc+g\%idg\_offset)+1:2*(ie\_obc+g\%idg\_offset):2,1,:)}
\DoxyCodeLine{3953 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3954 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3955         \textcolor{keywordflow}{else}}
\DoxyCodeLine{3956           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3957             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'} .or. \&}
\DoxyCodeLine{3958                 segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3959               segment\%field(m)\%buffer\_src(is\_obc,:,:)=tmp\_buffer(1,js\_obc+g\%jdg\_offset+1:je\_obc+g\%jdg\_offset+1,:)}
\DoxyCodeLine{3960             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3961               segment\%field(m)\%buffer\_src(is\_obc,:,:)=tmp\_buffer(1,js\_obc+g\%jdg\_offset+1:je\_obc+g\%jdg\_offset,:)}
\DoxyCodeLine{3962 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3963           \textcolor{keywordflow}{else}}
\DoxyCodeLine{3964             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'} .or. \&}
\DoxyCodeLine{3965                 segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3966               segment\%field(m)\%buffer\_src(:,js\_obc,:)=tmp\_buffer(is\_obc+g\%idg\_offset+1:ie\_obc+g\%idg\_offset+1,1,:)}
\DoxyCodeLine{3967             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3968               segment\%field(m)\%buffer\_src(:,js\_obc,:)=tmp\_buffer(is\_obc+g\%idg\_offset+1:ie\_obc+g\%idg\_offset,1,:)}
\DoxyCodeLine{3969 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3970 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3971 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{3972         \textcolor{comment}{! no dz for tidal variables}}
\DoxyCodeLine{3973         \textcolor{keywordflow}{if} (segment\%field(m)\%nk\_src > 1 .and.\&}
\DoxyCodeLine{3974             (index(segment\%field(m)\%name, \textcolor{stringliteral}{'phase'}) .le. 0 .and. index(segment\%field(m)\%name, \textcolor{stringliteral}{'amp'}) .le. 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3975           \textcolor{keyword}{call }time\_interp\_external(segment\%field(m)\%fid\_dz,time, tmp\_buffer\_in)}
\DoxyCodeLine{3976           \textcolor{keywordflow}{if} (turns /= 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3977             \textcolor{comment}{! TODO: This is hardcoded for 90 degrees, and needs to be generalized.}}
\DoxyCodeLine{3978             \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W \&}
\DoxyCodeLine{3979                 .and. .not. (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3980               nj\_buf = \textcolor{keyword}{size}(tmp\_buffer, 2) -\/ 1}
\DoxyCodeLine{3981               \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in(:nj\_buf,:,:), turns, tmp\_buffer(:,:nj\_buf,:))}
\DoxyCodeLine{3982             \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S \&}
\DoxyCodeLine{3983                 .and. .not. (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3984               ni\_buf = \textcolor{keyword}{size}(tmp\_buffer, 1) -\/ 1}
\DoxyCodeLine{3985               \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in(:,:ni\_buf,:), turns, tmp\_buffer(:ni\_buf,:,:))}
\DoxyCodeLine{3986             \textcolor{keywordflow}{else}}
\DoxyCodeLine{3987               \textcolor{keyword}{call }rotate\_array(tmp\_buffer\_in, turns, tmp\_buffer)}
\DoxyCodeLine{3988 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{3989 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{3990           \textcolor{keywordflow}{if} (obc\%brushcutter\_mode) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3991             \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3992               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{3993                 segment\%field(m)\%dz\_src(is\_obc,:,:) = \&}
\DoxyCodeLine{3994                     tmp\_buffer(1,2*(js\_obc+g\%jdg\_offset)+1:2*(je\_obc+g\%jdg\_offset)+1:2,:)}
\DoxyCodeLine{3995               \textcolor{keywordflow}{else}}
\DoxyCodeLine{3996                 segment\%field(m)\%dz\_src(is\_obc,:,:) = \&}
\DoxyCodeLine{3997                     tmp\_buffer(1,2*(js\_obc+g\%jdg\_offset)+1:2*(je\_obc+g\%jdg\_offset):2,:)}
\DoxyCodeLine{3998 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{3999             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4000               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4001                 segment\%field(m)\%dz\_src(:,js\_obc,:) = \&}
\DoxyCodeLine{4002                     tmp\_buffer(2*(is\_obc+g\%idg\_offset)+1:2*(ie\_obc+g\%idg\_offset)+1:2,1,:)}
\DoxyCodeLine{4003               \textcolor{keywordflow}{else}}
\DoxyCodeLine{4004                 segment\%field(m)\%dz\_src(:,js\_obc,:) = \&}
\DoxyCodeLine{4005                     tmp\_buffer(2*(is\_obc+g\%idg\_offset)+1:2*(ie\_obc+g\%idg\_offset):2,1,:)}
\DoxyCodeLine{4006 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{4007 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4008           \textcolor{keywordflow}{else}}
\DoxyCodeLine{4009             \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4010               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4011                 segment\%field(m)\%dz\_src(is\_obc,:,:)=tmp\_buffer(1,js\_obc+g\%jdg\_offset+1:je\_obc+g\%jdg\_offset+1,:)}
\DoxyCodeLine{4012               \textcolor{keywordflow}{else}}
\DoxyCodeLine{4013                 segment\%field(m)\%dz\_src(is\_obc,:,:)=tmp\_buffer(1,js\_obc+g\%jdg\_offset+1:je\_obc+g\%jdg\_offset,:)}
\DoxyCodeLine{4014 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{4015             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4016               \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4017                 segment\%field(m)\%dz\_src(:,js\_obc,:)=tmp\_buffer(is\_obc+g\%idg\_offset+1:ie\_obc+g\%idg\_offset+1,1,:)}
\DoxyCodeLine{4018               \textcolor{keywordflow}{else}}
\DoxyCodeLine{4019                 segment\%field(m)\%dz\_src(:,js\_obc,:)=tmp\_buffer(is\_obc+g\%idg\_offset+1:ie\_obc+g\%idg\_offset,1,:)}
\DoxyCodeLine{4020 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{4021 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4022 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{4023 }
\DoxyCodeLine{4024           \textcolor{keyword}{call }adjustsegmentetatofitbathymetry(g,gv,us,segment,m)}
\DoxyCodeLine{4025 }
\DoxyCodeLine{4026           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4027             ishift=1}
\DoxyCodeLine{4028             \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_e) ishift=0}
\DoxyCodeLine{4029             i=is\_obc}
\DoxyCodeLine{4030             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4031               \textcolor{comment}{! Do q points for the whole segment}}
\DoxyCodeLine{4032               \textcolor{keywordflow}{do} j=max(js\_obc,jsd),min(je\_obc,jed-\/1)}
\DoxyCodeLine{4033                 \textcolor{comment}{! Using the h remapping approach}}
\DoxyCodeLine{4034                 \textcolor{comment}{! Pretty sure we need to check for source/target grid consistency here}}
\DoxyCodeLine{4035                 segment\%field(m)\%buffer\_dst(i,j,:)=0.0  \textcolor{comment}{! initialize remap destination buffer}}
\DoxyCodeLine{4036                 \textcolor{keywordflow}{if} (g\%mask2dCu(i,j)>0. .and. g\%mask2dCu(i,j+1)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4037                   h\_stack(:) = 0.5*(h(i+ishift,j,:) + h(i+ishift,j+1,:))}
\DoxyCodeLine{4038                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4039                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4040                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4041                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4042                 \textcolor{keywordflow}{elseif} (g\%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4043                   h\_stack(:) = h(i+ishift,j,:)}
\DoxyCodeLine{4044                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4045                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4046                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4047                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4048                 \textcolor{keywordflow}{elseif} (g\%mask2dCu(i,j+1)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4049                   h\_stack(:) = h(i+ishift,j+1,:)}
\DoxyCodeLine{4050                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4051                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4052                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4053                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4054 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{4055 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4056             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4057               \textcolor{keywordflow}{do} j=js\_obc+1,je\_obc}
\DoxyCodeLine{4058                 \textcolor{comment}{! Using the h remapping approach}}
\DoxyCodeLine{4059                 \textcolor{comment}{! Pretty sure we need to check for source/target grid consistency here}}
\DoxyCodeLine{4060                 segment\%field(m)\%buffer\_dst(i,j,:)=0.0  \textcolor{comment}{! initialize remap destination buffer}}
\DoxyCodeLine{4061                 \textcolor{keywordflow}{if} (g\%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4062                   net\_h\_src = sum( segment\%field(m)\%dz\_src(i,j,:) )}
\DoxyCodeLine{4063                   net\_h\_int = sum( h(i+ishift,j,:) )}
\DoxyCodeLine{4064                   scl\_fac = net\_h\_int / net\_h\_src}
\DoxyCodeLine{4065                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4066                        segment\%field(m)\%nk\_src, scl\_fac*segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4067                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4068                        g\%ke, h(i+ishift,j,:), segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4069 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{4070 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4071 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4072           \textcolor{keywordflow}{else}}
\DoxyCodeLine{4073             jshift=1}
\DoxyCodeLine{4074             \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_n) jshift=0}
\DoxyCodeLine{4075             j=js\_obc}
\DoxyCodeLine{4076             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4077               \textcolor{comment}{! Do q points for the whole segment}}
\DoxyCodeLine{4078               \textcolor{keywordflow}{do} i=max(is\_obc,isd),min(ie\_obc,ied-\/1)}
\DoxyCodeLine{4079                 segment\%field(m)\%buffer\_dst(i,j,:)=0.0  \textcolor{comment}{! initialize remap destination buffer}}
\DoxyCodeLine{4080                 \textcolor{keywordflow}{if} (g\%mask2dCv(i,j)>0. .and. g\%mask2dCv(i+1,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4081               \textcolor{comment}{! Using the h remapping approach}}
\DoxyCodeLine{4082               \textcolor{comment}{! Pretty sure we need to check for source/target grid consistency here}}
\DoxyCodeLine{4083                   h\_stack(:) = 0.5*(h(i,j+jshift,:) + h(i+1,j+jshift,:))}
\DoxyCodeLine{4084                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4085                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4086                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4087                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4088                 \textcolor{keywordflow}{elseif} (g\%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4089                   h\_stack(:) = h(i,j+jshift,:)}
\DoxyCodeLine{4090                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4091                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4092                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4093                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4094                 \textcolor{keywordflow}{elseif} (g\%mask2dCv(i+1,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4095                   h\_stack(:) = h(i+1,j+jshift,:)}
\DoxyCodeLine{4096                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4097                        segment\%field(m)\%nk\_src,segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4098                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4099                        g\%ke, h\_stack, segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4100 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{4101 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4102             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4103               \textcolor{keywordflow}{do} i=is\_obc+1,ie\_obc}
\DoxyCodeLine{4104               \textcolor{comment}{! Using the h remapping approach}}
\DoxyCodeLine{4105               \textcolor{comment}{! Pretty sure we need to check for source/target grid consistency here}}
\DoxyCodeLine{4106                 segment\%field(m)\%buffer\_dst(i,j,:)=0.0  \textcolor{comment}{! initialize remap destination buffer}}
\DoxyCodeLine{4107                 \textcolor{keywordflow}{if} (g\%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4108                   net\_h\_src = sum( segment\%field(m)\%dz\_src(i,j,:) )}
\DoxyCodeLine{4109                   net\_h\_int = sum( h(i,j+jshift,:) )}
\DoxyCodeLine{4110                   scl\_fac = net\_h\_int / net\_h\_src}
\DoxyCodeLine{4111                   \textcolor{keyword}{call }remapping\_core\_h(obc\%remap\_CS, \&}
\DoxyCodeLine{4112                        segment\%field(m)\%nk\_src, scl\_fac*segment\%field(m)\%dz\_src(i,j,:), \&}
\DoxyCodeLine{4113                        segment\%field(m)\%buffer\_src(i,j,:), \&}
\DoxyCodeLine{4114                        g\%ke, h(i,j+jshift,:), segment\%field(m)\%buffer\_dst(i,j,:))}
\DoxyCodeLine{4115 \textcolor{keywordflow}{                endif}}
\DoxyCodeLine{4116 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4117 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4118 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{4119         \textcolor{keywordflow}{elseif} (segment\%field(m)\%nk\_src > 1 .and. \&}
\DoxyCodeLine{4120             (index(segment\%field(m)\%name, \textcolor{stringliteral}{'phase'}) > 0 .or. index(segment\%field(m)\%name, \textcolor{stringliteral}{'amp'}) > 0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4121           \textcolor{comment}{! no dz for tidal variables}}
\DoxyCodeLine{4122           segment\%field(m)\%buffer\_dst(:,:,:) = segment\%field(m)\%buffer\_src(:,:,:)}
\DoxyCodeLine{4123         \textcolor{keywordflow}{else}  \textcolor{comment}{! 2d data}}
\DoxyCodeLine{4124           segment\%field(m)\%buffer\_dst(:,:,1) = segment\%field(m)\%buffer\_src(:,:,1)  \textcolor{comment}{! initialize remap destination buffer}}
\DoxyCodeLine{4125 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4126         \textcolor{keyword}{deallocate}(tmp\_buffer)}
\DoxyCodeLine{4127         \textcolor{keywordflow}{if} (turns /= 0) \&}
\DoxyCodeLine{4128           \textcolor{keyword}{deallocate}(tmp\_buffer\_in)}
\DoxyCodeLine{4129       \textcolor{keywordflow}{else} \textcolor{comment}{! fid <= 0 (Uniform value)}}
\DoxyCodeLine{4130         \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(segment\%field(m)\%buffer\_dst)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4131           \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4132             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4133               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4134             \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4135               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{4136             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4137               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,g\%ke))}
\DoxyCodeLine{4138             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4139               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,1))}
\DoxyCodeLine{4140             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'DVDX'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4141               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4142             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSH'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'} \&}
\DoxyCodeLine{4143                 .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4144               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{4145             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4146               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc+1:je\_obc,g\%ke))}
\DoxyCodeLine{4147 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4148           \textcolor{keywordflow}{else}}
\DoxyCodeLine{4149             \textcolor{keywordflow}{if} (segment\%field(m)\%name == \textcolor{stringliteral}{'U'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4150               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4151             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Uamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Uphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4152               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{4153             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4154               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4155             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'Vamp'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'Vphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4156               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{4157             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'DUDY'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4158               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4159             \textcolor{keywordflow}{elseif} (segment\%field(m)\%name == \textcolor{stringliteral}{'SSH'} .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHamp'} \&}
\DoxyCodeLine{4160                 .or. segment\%field(m)\%name == \textcolor{stringliteral}{'SSHphase'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4161               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc:ie\_obc,js\_obc:je\_obc,1))}
\DoxyCodeLine{4162             \textcolor{keywordflow}{else}}
\DoxyCodeLine{4163               \textcolor{keyword}{allocate}(segment\%field(m)\%buffer\_dst(is\_obc+1:ie\_obc,js\_obc:je\_obc,g\%ke))}
\DoxyCodeLine{4164 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4165 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{4166           segment\%field(m)\%buffer\_dst(:,:,:) = segment\%field(m)\%value}
\DoxyCodeLine{4167 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4168 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4169 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{4170     \textcolor{comment}{! Start second loop to update all fields now that data for all fields are available.}}
\DoxyCodeLine{4171     \textcolor{comment}{! (split because tides depend on multiple variables).}}
\DoxyCodeLine{4172     \textcolor{keywordflow}{do} m = 1,segment\%num\_fields}
\DoxyCodeLine{4173       \textcolor{comment}{! if (segment\%field(m)\%fid>0) then}}
\DoxyCodeLine{4174       \textcolor{comment}{! calculate external BT velocity and transport if needed}}
\DoxyCodeLine{4175       \textcolor{keywordflow}{if} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'U'} .or. trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'V'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4176         \textcolor{keywordflow}{if} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'U'} .and. segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4177           i=is\_obc}
\DoxyCodeLine{4178           \textcolor{keywordflow}{do} j=js\_obc+1,je\_obc}
\DoxyCodeLine{4179             normal\_trans\_bt(i,j) = 0.0}
\DoxyCodeLine{4180             tidal\_vel = 0.0}
\DoxyCodeLine{4181             \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4182               \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4183                 tidal\_vel = tidal\_vel + (obc\%tide\_fn(c) * segment\%field(segment\%uamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4184                   cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%uphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4185                       + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4186 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4187 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4188             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4189               segment\%normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T*(segment\%field(m)\%buffer\_dst(i,j,k) + tidal\_vel)}
\DoxyCodeLine{4190               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k)*segment\%h(i,j,k) * g\%dyCu(i,j)}
\DoxyCodeLine{4191               normal\_trans\_bt(i,j) = normal\_trans\_bt(i,j) + segment\%normal\_trans(i,j,k)}
\DoxyCodeLine{4192 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4193             segment\%normal\_vel\_bt(i,j) = normal\_trans\_bt(i,j) \&}
\DoxyCodeLine{4194                 / (max(segment\%Htot(i,j), 1.e-\/12 * gv\%m\_to\_H) * g\%dyCu(i,j))}
\DoxyCodeLine{4195             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_normal\_vel)) segment\%nudged\_normal\_vel(i,j,:) = segment\%normal\_vel(i,j,:)}
\DoxyCodeLine{4196 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4197         \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'V'} .and. segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4198           j=js\_obc}
\DoxyCodeLine{4199           \textcolor{keywordflow}{do} i=is\_obc+1,ie\_obc}
\DoxyCodeLine{4200             normal\_trans\_bt(i,j) = 0.0}
\DoxyCodeLine{4201             tidal\_vel = 0.0}
\DoxyCodeLine{4202             \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4203               \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4204                 tidal\_vel = tidal\_vel + (obc\%tide\_fn(c) * segment\%field(segment\%vamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4205                   cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%vphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4206                       + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4207 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4208 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4209             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4210               segment\%normal\_vel(i,j,k) = us\%m\_s\_to\_L\_T*(segment\%field(m)\%buffer\_dst(i,j,k) + tidal\_vel)}
\DoxyCodeLine{4211               segment\%normal\_trans(i,j,k) = segment\%normal\_vel(i,j,k)*segment\%h(i,j,k) * \&}
\DoxyCodeLine{4212                         g\%dxCv(i,j)}
\DoxyCodeLine{4213               normal\_trans\_bt(i,j) = normal\_trans\_bt(i,j) + segment\%normal\_trans(i,j,k)}
\DoxyCodeLine{4214 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4215             segment\%normal\_vel\_bt(i,j) = normal\_trans\_bt(i,j) \&}
\DoxyCodeLine{4216                 / (max(segment\%Htot(i,j), 1.e-\/12 * gv\%m\_to\_H) * g\%dxCv(i,j))}
\DoxyCodeLine{4217             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_normal\_vel)) segment\%nudged\_normal\_vel(i,j,:) = segment\%normal\_vel(i,j,:)}
\DoxyCodeLine{4218 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4219         \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'V'} .and. segment\%is\_E\_or\_W .and. \&}
\DoxyCodeLine{4220                 \textcolor{keyword}{associated}(segment\%tangential\_vel)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4221           i=is\_obc}
\DoxyCodeLine{4222           \textcolor{keywordflow}{do} j=js\_obc,je\_obc}
\DoxyCodeLine{4223             tidal\_vel = 0.0}
\DoxyCodeLine{4224             \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4225               \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4226                 tidal\_vel = tidal\_vel + (obc\%tide\_fn(c) * segment\%field(segment\%vamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4227                   cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%vphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4228                       + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4229 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4230 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4231             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4232               segment\%tangential\_vel(i,j,k) = us\%m\_s\_to\_L\_T*(segment\%field(m)\%buffer\_dst(i,j,k) + tidal\_vel)}
\DoxyCodeLine{4233 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4234             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_tangential\_vel)) \&}
\DoxyCodeLine{4235               segment\%nudged\_tangential\_vel(i,j,:) = segment\%tangential\_vel(i,j,:)}
\DoxyCodeLine{4236 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4237         \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'U'} .and. segment\%is\_N\_or\_S .and. \&}
\DoxyCodeLine{4238                 \textcolor{keyword}{associated}(segment\%tangential\_vel)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4239           j=js\_obc}
\DoxyCodeLine{4240           \textcolor{keywordflow}{do} i=is\_obc,ie\_obc}
\DoxyCodeLine{4241             tidal\_vel = 0.0}
\DoxyCodeLine{4242             \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4243               \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4244                 tidal\_vel = tidal\_vel + (obc\%tide\_fn(c) * segment\%field(segment\%uamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4245                     cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%uphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4246                         + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4247 \textcolor{keywordflow}{              enddo}}
\DoxyCodeLine{4248 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{4249             \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4250               segment\%tangential\_vel(i,j,k) = us\%m\_s\_to\_L\_T*(segment\%field(m)\%buffer\_dst(i,j,k) + tidal\_vel)}
\DoxyCodeLine{4251 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4252             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_tangential\_vel)) \&}
\DoxyCodeLine{4253               segment\%nudged\_tangential\_vel(i,j,:) = segment\%tangential\_vel(i,j,:)}
\DoxyCodeLine{4254 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4255 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4256       \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'DVDX'} .and. segment\%is\_E\_or\_W .and. \&}
\DoxyCodeLine{4257               \textcolor{keyword}{associated}(segment\%tangential\_grad)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4258         i=is\_obc}
\DoxyCodeLine{4259         \textcolor{keywordflow}{do} j=js\_obc,je\_obc}
\DoxyCodeLine{4260           \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4261             segment\%tangential\_grad(i,j,k) = us\%T\_to\_s*segment\%field(m)\%buffer\_dst(i,j,k)}
\DoxyCodeLine{4262             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_tangential\_grad)) \&}
\DoxyCodeLine{4263               segment\%nudged\_tangential\_grad(i,j,:) = segment\%tangential\_grad(i,j,:)}
\DoxyCodeLine{4264 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4265 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{4266       \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'DUDY'} .and. segment\%is\_N\_or\_S .and. \&}
\DoxyCodeLine{4267               \textcolor{keyword}{associated}(segment\%tangential\_grad)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4268         j=js\_obc}
\DoxyCodeLine{4269         \textcolor{keywordflow}{do} i=is\_obc,ie\_obc}
\DoxyCodeLine{4270           \textcolor{keywordflow}{do} k=1,g\%ke}
\DoxyCodeLine{4271             segment\%tangential\_grad(i,j,k) = us\%T\_to\_s*segment\%field(m)\%buffer\_dst(i,j,k)}
\DoxyCodeLine{4272             \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%nudged\_tangential\_grad)) \&}
\DoxyCodeLine{4273               segment\%nudged\_tangential\_grad(i,j,:) = segment\%tangential\_grad(i,j,:)}
\DoxyCodeLine{4274 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4275 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{4276 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4277 }
\DoxyCodeLine{4278       \textcolor{comment}{! endif}}
\DoxyCodeLine{4279 }
\DoxyCodeLine{4280       \textcolor{comment}{! from this point on, data are entirely on segments -\/ will}}
\DoxyCodeLine{4281       \textcolor{comment}{! write all segment loops as 2d loops.}}
\DoxyCodeLine{4282       \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4283         js\_obc2 = js\_obc+1}
\DoxyCodeLine{4284         is\_obc2 = is\_obc}
\DoxyCodeLine{4285       \textcolor{keywordflow}{else}}
\DoxyCodeLine{4286         js\_obc2 = js\_obc}
\DoxyCodeLine{4287         is\_obc2 = is\_obc+1}
\DoxyCodeLine{4288 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4289       \textcolor{keywordflow}{if} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4290         is\_obc2 = is\_obc+1}
\DoxyCodeLine{4291         js\_obc2 = js\_obc}
\DoxyCodeLine{4292       \textcolor{keywordflow}{else}}
\DoxyCodeLine{4293         is\_obc2 = is\_obc}
\DoxyCodeLine{4294         js\_obc2 = js\_obc+1}
\DoxyCodeLine{4295 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4296 }
\DoxyCodeLine{4297       \textcolor{keywordflow}{if} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'SSH'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4298         \textcolor{keywordflow}{if} (obc\%ramp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4299           \textcolor{keywordflow}{do} j=js\_obc2,je\_obc}
\DoxyCodeLine{4300             \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4301               tidal\_elev = 0.0}
\DoxyCodeLine{4302               \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4303                 \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4304                   tidal\_elev = tidal\_elev + (obc\%tide\_fn(c) * segment\%field(segment\%zamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4305                       cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%zphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4306                           + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4307 \textcolor{keywordflow}{                enddo}}
\DoxyCodeLine{4308 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{4309               segment\%eta(i,j) = gv\%m\_to\_H * obc\%ramp\_value \&}
\DoxyCodeLine{4310                 * (segment\%field(m)\%buffer\_dst(i,j,1) + tidal\_elev)}
\DoxyCodeLine{4311 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4312 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4313         \textcolor{keywordflow}{else}}
\DoxyCodeLine{4314           \textcolor{keywordflow}{do} j=js\_obc2,je\_obc}
\DoxyCodeLine{4315             \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4316               tidal\_elev = 0.0}
\DoxyCodeLine{4317               \textcolor{keywordflow}{if} (obc\%add\_tide\_constituents) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4318                 \textcolor{keywordflow}{do} c=1,obc\%n\_tide\_constituents}
\DoxyCodeLine{4319                   tidal\_elev = tidal\_elev + (obc\%tide\_fn(c) * segment\%field(segment\%zamp\_index)\%buffer\_dst(i,j,c)) * \&}
\DoxyCodeLine{4320                       cos((time\_delta*obc\%tide\_frequencies(c) -\/ segment\%field(segment\%zphase\_index)\%buffer\_dst(i,j,c)) \&}
\DoxyCodeLine{4321                           + (obc\%tide\_eq\_phases(c) + obc\%tide\_un(c)))}
\DoxyCodeLine{4322 \textcolor{keywordflow}{                enddo}}
\DoxyCodeLine{4323 \textcolor{keywordflow}{              endif}}
\DoxyCodeLine{4324               segment\%eta(i,j) = gv\%m\_to\_H * (segment\%field(m)\%buffer\_dst(i,j,1) + tidal\_elev)}
\DoxyCodeLine{4325 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{4326 \textcolor{keywordflow}{          enddo}}
\DoxyCodeLine{4327 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4328 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4329 }
\DoxyCodeLine{4330       \textcolor{keywordflow}{if} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'TEMP'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4331         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%field(m)\%buffer\_dst)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4332           \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js\_obc2, je\_obc; \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4333             segment\%tr\_Reg\%Tr(1)\%t(i,j,k) = segment\%field(m)\%buffer\_dst(i,j,k)}
\DoxyCodeLine{4334 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4335           \textcolor{keywordflow}{if} (.not. segment\%tr\_Reg\%Tr(1)\%is\_initialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4336             \textcolor{comment}{! if the tracer reservoir has not yet been initialized, then set to external value.}}
\DoxyCodeLine{4337             \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js\_obc2, je\_obc; \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4338               segment\%tr\_Reg\%Tr(1)\%tres(i,j,k) = segment\%tr\_Reg\%Tr(1)\%t(i,j,k)}
\DoxyCodeLine{4339 \textcolor{keywordflow}{            enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4340             segment\%tr\_Reg\%Tr(1)\%is\_initialized=.true.}
\DoxyCodeLine{4341 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{4342         \textcolor{keywordflow}{else}}
\DoxyCodeLine{4343           segment\%tr\_Reg\%Tr(1)\%OBC\_inflow\_conc = segment\%field(m)\%value}
\DoxyCodeLine{4344 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4345       \textcolor{keywordflow}{elseif} (trim(segment\%field(m)\%name) == \textcolor{stringliteral}{'SALT'}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4346         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%field(m)\%buffer\_dst)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4347           \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js\_obc2, je\_obc; \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4348             segment\%tr\_Reg\%Tr(2)\%t(i,j,k) = segment\%field(m)\%buffer\_dst(i,j,k)}
\DoxyCodeLine{4349 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4350           \textcolor{keywordflow}{if} (.not. segment\%tr\_Reg\%Tr(2)\%is\_initialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{4351             \textcolor{comment}{!if the tracer reservoir has not yet been initialized, then set to external value.}}
\DoxyCodeLine{4352             \textcolor{keywordflow}{do} k=1,nz; \textcolor{keywordflow}{do} j=js\_obc2, je\_obc; \textcolor{keywordflow}{do} i=is\_obc2,ie\_obc}
\DoxyCodeLine{4353               segment\%tr\_Reg\%Tr(2)\%tres(i,j,k) = segment\%tr\_Reg\%Tr(2)\%t(i,j,k)}
\DoxyCodeLine{4354 \textcolor{keywordflow}{            enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{4355             segment\%tr\_Reg\%Tr(2)\%is\_initialized=.true.}
\DoxyCodeLine{4356 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{4357         \textcolor{keywordflow}{else}}
\DoxyCodeLine{4358           segment\%tr\_Reg\%Tr(2)\%OBC\_inflow\_conc = segment\%field(m)\%value}
\DoxyCodeLine{4359 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{4360 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{4361 }
\DoxyCodeLine{4362 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! end field loop}}
\DoxyCodeLine{4363     \textcolor{keyword}{deallocate}(h\_stack)}
\DoxyCodeLine{4364     \textcolor{keyword}{deallocate}(normal\_trans\_bt)}
\DoxyCodeLine{4365 }
\DoxyCodeLine{4366 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end segment loop}}
\DoxyCodeLine{4367 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__open__boundary_a230cf67375352c9d55b4330180d35d7c}\label{namespacemom__open__boundary_a230cf67375352c9d55b4330180d35d7c}} 
\index{mom\_open\_boundary@{mom\_open\_boundary}!update\_segment\_tracer\_reservoirs@{update\_segment\_tracer\_reservoirs}}
\index{update\_segment\_tracer\_reservoirs@{update\_segment\_tracer\_reservoirs}!mom\_open\_boundary@{mom\_open\_boundary}}
\doxysubsubsection{\texorpdfstring{update\_segment\_tracer\_reservoirs()}{update\_segment\_tracer\_reservoirs()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+open\+\_\+boundary\+::update\+\_\+segment\+\_\+tracer\+\_\+reservoirs (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__verticalgrid_1_1verticalgrid__type}{verticalgrid\+\_\+type}}), intent(in)}]{GV,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{uhr,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(g)), intent(in)}]{vhr,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(g)), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__open__boundary_1_1ocean__obc__type}{ocean\+\_\+obc\+\_\+type}}), pointer}]{O\+BC,  }\item[{real, intent(in)}]{dt,  }\item[{type(\mbox{\hyperlink{structmom__tracer__registry_1_1tracer__registry__type}{tracer\+\_\+registry\+\_\+type}}), pointer}]{Reg }\end{DoxyParamCaption})}



Update the O\+BC tracer reservoirs after the tracers have been updated. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em uhr} & accumulated volume/mass flux through the zonal face \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em vhr} & accumulated volume/mass flux through the meridional face \mbox{[}H L2 $\sim$$>$ m3 or kg\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h} & layer thickness after advection \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & time increment \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
 & {\em reg} & pointer to tracer registry \\
\hline
\end{DoxyParams}


Definition at line 5056 of file M\+O\+M\+\_\+open\+\_\+boundary.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{5057   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< The ocean's grid structure}}
\DoxyCodeLine{5058   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{  !<  Ocean vertical grid structure}}
\DoxyCodeLine{5059 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: uhr\textcolor{comment}{ !< accumulated volume/mass flux through}}
\DoxyCodeLine{5060 \textcolor{comment}{                                                               !! the zonal face [H L2 \string~> m3 or kg]}}
\DoxyCodeLine{5061 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: vhr\textcolor{comment}{ !< accumulated volume/mass flux through}}
\DoxyCodeLine{5062 \textcolor{comment}{                                                               !! the meridional face [H L2 \string~> m3 or kg]}}
\DoxyCodeLine{5063 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{   !< layer thickness after advection}}
\DoxyCodeLine{5064 \textcolor{comment}{                                                               !! [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{5065   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}    :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{5066 \textcolor{keywordtype}{  real},                                      \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{  !< time increment [T \string~> s]}}
\DoxyCodeLine{5067   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}    :: Reg\textcolor{comment}{ !< pointer to tracer registry}}
\DoxyCodeLine{5068   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{5069   \textcolor{keywordtype}{type}(OBC\_segment\_type), \textcolor{keywordtype}{pointer} :: segment=>null()}
\DoxyCodeLine{5070 \textcolor{keywordtype}{  real} :: u\_L\_in, u\_L\_out \textcolor{comment}{! The zonal distance moved in or out of a cell [L \string~> m]}}
\DoxyCodeLine{5071 \textcolor{keywordtype}{  real} :: v\_L\_in, v\_L\_out \textcolor{comment}{! The meridional distance moved in or out of a cell [L \string~> m]}}
\DoxyCodeLine{5072 \textcolor{keywordtype}{  real} :: fac1            \textcolor{comment}{! The denominator of the expression for tracer updates [nondim]}}
\DoxyCodeLine{5073   \textcolor{keywordtype}{integer} :: i, j, k, m, n, ntr, nz}
\DoxyCodeLine{5074   \textcolor{keywordtype}{integer} :: ishift, idir, jshift, jdir}
\DoxyCodeLine{5075 }
\DoxyCodeLine{5076   nz = gv\%ke}
\DoxyCodeLine{5077   ntr = reg\%ntr}
\DoxyCodeLine{5078   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (obc\%OBC\_pe) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} n=1,obc\%number\_of\_segments}
\DoxyCodeLine{5079     segment=>obc\%segment(n)}
\DoxyCodeLine{5080     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(segment\%tr\_Reg)) cycle}
\DoxyCodeLine{5081     \textcolor{keywordflow}{if} (segment\%is\_E\_or\_W) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5082       i = segment\%HI\%IsdB}
\DoxyCodeLine{5083       \textcolor{keywordflow}{do} j=segment\%HI\%jsd,segment\%HI\%jed}
\DoxyCodeLine{5084         \textcolor{comment}{! ishift+I corresponds to the nearest interior tracer cell index}}
\DoxyCodeLine{5085         \textcolor{comment}{! idir switches the sign of the flow so that positive is into the reservoir}}
\DoxyCodeLine{5086         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5087           ishift = 1 ; idir = -\/1}
\DoxyCodeLine{5088         \textcolor{keywordflow}{else}}
\DoxyCodeLine{5089           ishift = 0 ; idir = 1}
\DoxyCodeLine{5090 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{5091         \textcolor{comment}{! Can keep this or take it out, either way}}
\DoxyCodeLine{5092         \textcolor{keywordflow}{if} (g\%mask2dT(i+ishift,j) == 0.0) cycle}
\DoxyCodeLine{5093         \textcolor{comment}{! Update the reservoir tracer concentration implicitly using a Backward-\/Euler timestep}}
\DoxyCodeLine{5094         \textcolor{keywordflow}{do} m=1,ntr ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{5095           u\_l\_out = max(0.0, (idir*uhr(i,j,k))*segment\%Tr\_InvLscale\_out / \&}
\DoxyCodeLine{5096                     ((h(i+ishift,j,k) + gv\%H\_subroundoff)*g\%dyCu(i,j)))}
\DoxyCodeLine{5097           u\_l\_in  = min(0.0, (idir*uhr(i,j,k))*segment\%Tr\_InvLscale\_in  / \&}
\DoxyCodeLine{5098                     ((h(i+ishift,j,k) + gv\%H\_subroundoff)*g\%dyCu(i,j)))}
\DoxyCodeLine{5099           fac1 = 1.0 + (u\_l\_out-\/u\_l\_in)}
\DoxyCodeLine{5100           segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) = (1.0/fac1)*(segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) + \&}
\DoxyCodeLine{5101                             (u\_l\_out*reg\%Tr(m)\%t(i+ishift,j,k) -\/ \&}
\DoxyCodeLine{5102                              u\_l\_in*segment\%tr\_Reg\%Tr(m)\%t(i,j,k)))}
\DoxyCodeLine{5103           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_x)) obc\%tres\_x(i,j,k,m) = segment\%tr\_Reg\%Tr(m)\%tres(i,j,k)}
\DoxyCodeLine{5104 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{5105 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{5106     \textcolor{keywordflow}{elseif} (segment\%is\_N\_or\_S) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5107       j = segment\%HI\%JsdB}
\DoxyCodeLine{5108       \textcolor{keywordflow}{do} i=segment\%HI\%isd,segment\%HI\%ied}
\DoxyCodeLine{5109         \textcolor{comment}{! jshift+J corresponds to the nearest interior tracer cell index}}
\DoxyCodeLine{5110         \textcolor{comment}{! jdir switches the sign of the flow so that positive is into the reservoir}}
\DoxyCodeLine{5111         \textcolor{keywordflow}{if} (segment\%direction == obc\_direction\_s) \textcolor{keywordflow}{then}}
\DoxyCodeLine{5112           jshift = 1 ; jdir = -\/1}
\DoxyCodeLine{5113         \textcolor{keywordflow}{else}}
\DoxyCodeLine{5114           jshift = 0 ; jdir = 1}
\DoxyCodeLine{5115 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{5116         \textcolor{comment}{! Can keep this or take it out, either way}}
\DoxyCodeLine{5117         \textcolor{keywordflow}{if} (g\%mask2dT(i,j+jshift) == 0.0) cycle}
\DoxyCodeLine{5118         \textcolor{comment}{! Update the reservoir tracer concentration implicitly using a Backward-\/Euler timestep}}
\DoxyCodeLine{5119         \textcolor{keywordflow}{do} m=1,ntr ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(segment\%tr\_Reg\%Tr(m)\%tres)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{5120           v\_l\_out = max(0.0, (jdir*vhr(i,j,k))*segment\%Tr\_InvLscale\_out / \&}
\DoxyCodeLine{5121                     ((h(i,j+jshift,k) + gv\%H\_subroundoff)*g\%dxCv(i,j)))}
\DoxyCodeLine{5122           v\_l\_in  = min(0.0, (jdir*vhr(i,j,k))*segment\%Tr\_InvLscale\_in  / \&}
\DoxyCodeLine{5123                     ((h(i,j+jshift,k) + gv\%H\_subroundoff)*g\%dxCv(i,j)))}
\DoxyCodeLine{5124           fac1 = 1.0 + (v\_l\_out-\/v\_l\_in)}
\DoxyCodeLine{5125           segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) = (1.0/fac1)*(segment\%tr\_Reg\%Tr(m)\%tres(i,j,k) + \&}
\DoxyCodeLine{5126                             (v\_l\_out*reg\%Tr(m)\%t(i,j+jshift,k) -\/ \&}
\DoxyCodeLine{5127                              v\_l\_in*segment\%tr\_Reg\%Tr(m)\%t(i,j,k)))}
\DoxyCodeLine{5128           \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc\%tres\_y)) obc\%tres\_y(i,j,k,m) = segment\%tr\_Reg\%Tr(m)\%tres(i,j,k)}
\DoxyCodeLine{5129 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{5130 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{5131 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{5132 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{5133 }

\end{DoxyCode}
