\hypertarget{namespacemom__shared__initialization}{}\section{mom\+\_\+shared\+\_\+initialization Module Reference}
\label{namespacemom__shared__initialization}\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}


\subsection{Detailed Description}
Code that initializes fixed aspects of the model grid, such as horizontal grid metrics, topography and Coriolis, and can be shared between components. \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a9e9d95233423f98871c9e1864563f10d}{mom\+\_\+shared\+\_\+init\+\_\+init}} (PF)
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+shared\+\_\+init\+\_\+init just writes the code version. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a1e501ab8351b666491169c804418e9df}{mom\+\_\+initialize\+\_\+rotation}} (f, G, PF, US)
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+initialize\+\_\+rotation makes the appropriate call to set up the Coriolis parameter. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a4ec3c9951969b11a90acf193a423d893}{mom\+\_\+calculate\+\_\+grad\+\_\+coriolis}} (d\+F\+\_\+dx, d\+F\+\_\+dy, G, US)
\begin{DoxyCompactList}\small\item\em Calculates the components of grad f (Coriolis parameter) \end{DoxyCompactList}\item 
real function, public \mbox{\hyperlink{namespacemom__shared__initialization_aab0fe8b21fe93b75e1bec9c652deb2a0}{diagnosemaximumdepth}} (D, G)
\begin{DoxyCompactList}\small\item\em Return the global maximum ocean bottom depth in the same units as the input depth. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a3b944f383cd2586189347532539656ef}{initialize\+\_\+topography\+\_\+from\+\_\+file}} (D, G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em Read gridded depths from file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a053b97ada59fb2f5893a0bbe592eaac3}{apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file}} (D, G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em Applies a list of topography overrides read from a netcdf file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a852dd7dc66a31abe47dc83b769fb4ae4}{initialize\+\_\+topography\+\_\+named}} (D, G, param\+\_\+file, topog\+\_\+config, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em initialize the bathymetry based on one of several named idealized configurations \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_ae2e3b3c739630c8746c533102b8c5d76}{limit\+\_\+topography}} (D, G, param\+\_\+file, max\+\_\+depth, US)
\begin{DoxyCompactList}\small\item\em limit\+\_\+topography ensures that min\+\_\+depth $<$ D(x,y) $<$ max\+\_\+depth \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a6aa6b883534fee4616137b7174414b8e}{set\+\_\+rotation\+\_\+planetary}} (f, G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the Coriolis parameter for a sphere. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a330014f05a823d5434ad0156d361b6ff}{set\+\_\+rotation\+\_\+beta\+\_\+plane}} (f, G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the Coriolis parameter for a beta-\/plane or f-\/plane. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_acf73ad1980ac8b8253fa085a1d8afc17}{initialize\+\_\+grid\+\_\+rotation\+\_\+angle}} (G, PF)
\begin{DoxyCompactList}\small\item\em initialize\+\_\+grid\+\_\+rotation\+\_\+angle initializes the arrays with the sine and cosine of the angle between logical north on the grid and true north. \end{DoxyCompactList}\item 
real function \mbox{\hyperlink{namespacemom__shared__initialization_ac024655ad7fa6e243ceb90e9daa14388}{modulo\+\_\+around\+\_\+point}} (x, xc, Lx)
\begin{DoxyCompactList}\small\item\em Return the modulo value of x in an interval \mbox{[}xc-\/(Lx/2) xc+(Lx/2)\mbox{]} If Lx$<$=0, then it returns x without applying modulo arithmetic. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_af506ce66cc9fdd478b4e2bd44e594f18}{reset\+\_\+face\+\_\+lengths\+\_\+named}} (G, param\+\_\+file, name, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets the open face lengths at selected points to restrict passages to their observed widths based on a named set of sizes. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a27bab8da74b45855db4466ce4942456f}{reset\+\_\+face\+\_\+lengths\+\_\+file}} (G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets the open face lengths at selected points to restrict passages to their observed widths from a arrays read from a file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_aea0f76e5a7193df606ba3f09703ca30a}{reset\+\_\+face\+\_\+lengths\+\_\+list}} (G, param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em This subroutine sets the open face lengths at selected points to restrict passages to their observed widths from a list read from a file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a49c0443c10514a0d5ce5d8df4d68bce8}{read\+\_\+face\+\_\+length\+\_\+list}} (iounit, filename, num\+\_\+lines, lines)
\begin{DoxyCompactList}\small\item\em This subroutine reads and counts the non-\/blank lines in the face length list file, after removing comments. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_ab4e226886998bcc8a43011bd8ed4dd29}{set\+\_\+velocity\+\_\+depth\+\_\+max}} (G)
\begin{DoxyCompactList}\small\item\em Set the bathymetry at velocity points to be the maximum of the depths at the neighoring tracer points. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a4db4d57d710d61a5e910b437f9ab1455}{set\+\_\+velocity\+\_\+depth\+\_\+min}} (G)
\begin{DoxyCompactList}\small\item\em Set the bathymetry at velocity points to be the minimum of the depths at the neighoring tracer points. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a25f3025f93e75f70fa21f444014345be}{compute\+\_\+global\+\_\+grid\+\_\+integrals}} (G, US)
\begin{DoxyCompactList}\small\item\em Pre-\/compute global integrals of grid quantities (like masked ocean area) for later use in reporting diagnostics. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__shared__initialization_a4375db47a43535f8f2eecd5992a788ea}{write\+\_\+ocean\+\_\+geometry\+\_\+file}} (G, param\+\_\+file, directory, geom\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em Write out a file describing the topography, Coriolis parameter, grid locations and various other fixed fields from the grid. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__shared__initialization_a053b97ada59fb2f5893a0bbe592eaac3}\label{namespacemom__shared__initialization_a053b97ada59fb2f5893a0bbe592eaac3}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file@{apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file}}
\index{apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file@{apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file()}{apply\_topography\_edits\_from\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::apply\+\_\+topography\+\_\+edits\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(inout)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Applies a list of topography overrides read from a netcdf file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt in,out}  & {\em d} & Ocean bottom depth in m or Z if US is present\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 186 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
186   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),           \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
187   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
188                                     \textcolor{keywordtype}{intent(inout)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
189   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
190   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}
191 
192   \textcolor{comment}{! Local variables}
193   \textcolor{keywordtype}{real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}
194   \textcolor{keywordtype}{character(len=200)} :: topo\_edits\_file, inputdir \textcolor{comment}{! Strings for file/path}
195   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"apply\_topography\_edits\_from\_file"} \textcolor{comment}{! This subroutine's name.}
196   \textcolor{keywordtype}{integer} :: n\_edits, n, ashape(5), i, j, ncid, id, ncstatus, iid, jid, zid
197   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: ig, jg
198   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: new\_depth
199 
200   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
201 
202   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
203 
204   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
205   inputdir = slasher(inputdir)
206   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TOPO\_EDITS\_FILE"}, topo\_edits\_file, &
207                  \textcolor{stringliteral}{"The file from which to read a list of i,j,z topography overrides."}, &
208                  default=\textcolor{stringliteral}{""})
209 
210   \textcolor{keywordflow}{if} (len\_trim(topo\_edits\_file)==0) \textcolor{keywordflow}{return}
211 
212   topo\_edits\_file = trim(inputdir)//trim(topo\_edits\_file)
213   \textcolor{keywordflow}{if} (.not.file\_exists(topo\_edits\_file, g%Domain)) \textcolor{keyword}{call }mom\_error(fatal, &
214      \textcolor{stringliteral}{'initialize\_topography\_from\_file: Unable to open '}//trim(topo\_edits\_file))
215 
216   ncstatus = nf90\_open(trim(topo\_edits\_file), nf90\_nowrite, ncid)
217   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
218                                 \textcolor{stringliteral}{'Failed to open '}//trim(topo\_edits\_file))
219 
220   \textcolor{comment}{! Get nEdits}
221   ncstatus = nf90\_inq\_dimid(ncid, \textcolor{stringliteral}{'nEdits'}, id)
222   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
223                                 \textcolor{stringliteral}{'Failed to inq\_dimid nEdits for '}//trim(topo\_edits\_file))
224   ncstatus = nf90\_inquire\_dimension(ncid, id, len=n\_edits)
225   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
226                                 \textcolor{stringliteral}{'Failed to inquire\_dimension nEdits for '}//trim(topo\_edits\_file))
227 
228   \textcolor{comment}{! Read ni}
229   ncstatus = nf90\_inq\_varid(ncid, \textcolor{stringliteral}{'ni'}, id)
230   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
231                                 \textcolor{stringliteral}{'Failed to inq\_varid ni for '}//trim(topo\_edits\_file))
232   ncstatus = nf90\_get\_var(ncid, id, i)
233   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
234                               \textcolor{stringliteral}{'Failed to get\_var ni for '}//trim(topo\_edits\_file))
235   \textcolor{keywordflow}{if} (i /= g%ieg) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
236                               \textcolor{stringliteral}{'Incompatible i-dimension of grid in '}//trim(topo\_edits\_file))
237 
238   \textcolor{comment}{! Read nj}
239   ncstatus = nf90\_inq\_varid(ncid, \textcolor{stringliteral}{'nj'}, id)
240   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
241                                 \textcolor{stringliteral}{'Failed to inq\_varid nj for '}//trim(topo\_edits\_file))
242   ncstatus = nf90\_get\_var(ncid, id, j)
243   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
244                               \textcolor{stringliteral}{'Failed to get\_var nj for '}//trim(topo\_edits\_file))
245   \textcolor{keywordflow}{if} (j /= g%jeg) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
246                               \textcolor{stringliteral}{'Incompatible j-dimension of grid in '}//trim(topo\_edits\_file))
247 
248   \textcolor{comment}{! Read iEdit}
249   ncstatus = nf90\_inq\_varid(ncid, \textcolor{stringliteral}{'iEdit'}, id)
250   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
251                                 \textcolor{stringliteral}{'Failed to inq\_varid iEdit for '}//trim(topo\_edits\_file))
252   \textcolor{keyword}{allocate}(ig(n\_edits))
253   ncstatus = nf90\_get\_var(ncid, id, ig)
254   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
255                               \textcolor{stringliteral}{'Failed to get\_var iEdit for '}//trim(topo\_edits\_file))
256 
257   \textcolor{comment}{! Read jEdit}
258   ncstatus = nf90\_inq\_varid(ncid, \textcolor{stringliteral}{'jEdit'}, id)
259   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
260                                 \textcolor{stringliteral}{'Failed to inq\_varid jEdit for '}//trim(topo\_edits\_file))
261   \textcolor{keyword}{allocate}(jg(n\_edits))
262   ncstatus = nf90\_get\_var(ncid, id, jg)
263   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
264                               \textcolor{stringliteral}{'Failed to get\_var jEdit for '}//trim(topo\_edits\_file))
265 
266   \textcolor{comment}{! Read zEdit}
267   ncstatus = nf90\_inq\_varid(ncid, \textcolor{stringliteral}{'zEdit'}, id)
268   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
269                                 \textcolor{stringliteral}{'Failed to inq\_varid zEdit for '}//trim(topo\_edits\_file))
270   \textcolor{keyword}{allocate}(new\_depth(n\_edits))
271   ncstatus = nf90\_get\_var(ncid, id, new\_depth)
272   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
273                               \textcolor{stringliteral}{'Failed to get\_var zEdit for '}//trim(topo\_edits\_file))
274 
275   \textcolor{comment}{! Close file}
276   ncstatus = nf90\_close(ncid)
277   \textcolor{keywordflow}{if} (ncstatus /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'apply\_topography\_edits\_from\_file: '}//&
278                                 \textcolor{stringliteral}{'Failed to close '}//trim(topo\_edits\_file))
279 
280   \textcolor{keywordflow}{do} n = 1, n\_edits
281     i = ig(n) - g%isd\_global + 2 \textcolor{comment}{! +1 for python indexing and +1 for ig-isd\_global+1}
282     j = jg(n) - g%jsd\_global + 2
283     \textcolor{keywordflow}{if} (i>=g%isc .and. i<=g%iec .and. j>=g%jsc .and. j<=g%jec) \textcolor{keywordflow}{then}
284       \textcolor{keywordflow}{if} (new\_depth(n)/=0.) \textcolor{keywordflow}{then}
285         \textcolor{keyword}{write}(*,\textcolor{stringliteral}{'(a,3i5,f8.2,a,f8.2,2i4)'}) &
286           \textcolor{stringliteral}{'Ocean topography edit: '},n,ig(n),jg(n),d(i,j)/m\_to\_z,\textcolor{stringliteral}{'->'},abs(new\_depth(n)),i,j
287         d(i,j) = abs(m\_to\_z*new\_depth(n)) \textcolor{comment}{! Allows for height-file edits (i.e. converts negatives)}
288       \textcolor{keywordflow}{else}
289         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{' apply\_topography\_edits\_from\_file: '}//&
290           \textcolor{stringliteral}{"A zero depth edit would change the land mask and is not allowed in"}//trim(topo\_edits\_file))
291 \textcolor{keywordflow}{      endif}
292 \textcolor{keywordflow}{    endif}
293 \textcolor{keywordflow}{  enddo}
294 
295   \textcolor{keyword}{deallocate}( ig, jg, new\_depth )
296 
297   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a25f3025f93e75f70fa21f444014345be}\label{namespacemom__shared__initialization_a25f3025f93e75f70fa21f444014345be}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!compute\+\_\+global\+\_\+grid\+\_\+integrals@{compute\+\_\+global\+\_\+grid\+\_\+integrals}}
\index{compute\+\_\+global\+\_\+grid\+\_\+integrals@{compute\+\_\+global\+\_\+grid\+\_\+integrals}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{compute\+\_\+global\+\_\+grid\+\_\+integrals()}{compute\_global\_grid\_integrals()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::compute\+\_\+global\+\_\+grid\+\_\+integrals (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Pre-\/compute global integrals of grid quantities (like masked ocean area) for later use in reporting diagnostics. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 1149 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
1149   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),          \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The dynamic horizontal grid}
1150   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}
1151 
1152   \textcolor{comment}{! Local variables}
1153   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isc:G%iec, G%jsc:G%jec)} :: tmpForSumming
1154   \textcolor{keywordtype}{real} :: area\_scale  \textcolor{comment}{! A scaling factor for area into MKS units}
1155   \textcolor{keywordtype}{integer} :: i,j
1156 
1157   area\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) area\_scale = us%L\_to\_m**2
1158 
1159   tmpforsumming(:,:) = 0.
1160   g%areaT\_global = 0.0 ; g%IareaT\_global = 0.0
1161   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
1162     tmpforsumming(i,j) = area\_scale*g%areaT(i,j) * g%mask2dT(i,j)
1163 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1164   g%areaT\_global = \mbox{\hyperlink{interfacemom__coms_1_1reproducing__sum}{reproducing\_sum}}(tmpforsumming)
1165 
1166   \textcolor{keywordflow}{if} (g%areaT\_global == 0.0) &
1167     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"compute\_global\_grid\_integrals: "}//&
1168                     \textcolor{stringliteral}{"zero ocean area (check topography?)"})
1169 
1170   g%IareaT\_global = 1.0 / (g%areaT\_global)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_aab0fe8b21fe93b75e1bec9c652deb2a0}\label{namespacemom__shared__initialization_aab0fe8b21fe93b75e1bec9c652deb2a0}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!diagnosemaximumdepth@{diagnosemaximumdepth}}
\index{diagnosemaximumdepth@{diagnosemaximumdepth}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{diagnosemaximumdepth()}{diagnosemaximumdepth()}}
{\footnotesize\ttfamily real function, public mom\+\_\+shared\+\_\+initialization\+::diagnosemaximumdepth (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(in)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G }\end{DoxyParamCaption})}



Return the global maximum ocean bottom depth in the same units as the input depth. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt in}  & {\em d} & Ocean bottom depth in m or Z\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The global maximum ocean bottom depth in m or Z 
\end{DoxyReturn}


Definition at line 125 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
125   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
126   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
127                            \textcolor{keywordtype}{intent(in)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z}
128   \textcolor{keywordtype}{real} :: diagnoseMaximumDepth\textcolor{comment}{             !< The global maximum ocean bottom depth in m or Z}
129   \textcolor{comment}{! Local variables}
130   \textcolor{keywordtype}{integer} :: i,j
131   diagnosemaximumdepth = d(g%isc,g%jsc)
132   \textcolor{keywordflow}{do} j=g%jsc, g%jec ; \textcolor{keywordflow}{do} i=g%isc, g%iec
133     diagnosemaximumdepth = max(diagnosemaximumdepth,d(i,j))
134 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
135   \textcolor{keyword}{call }max\_across\_pes(diagnosemaximumdepth)
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_acf73ad1980ac8b8253fa085a1d8afc17}\label{namespacemom__shared__initialization_acf73ad1980ac8b8253fa085a1d8afc17}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!initialize\+\_\+grid\+\_\+rotation\+\_\+angle@{initialize\+\_\+grid\+\_\+rotation\+\_\+angle}}
\index{initialize\+\_\+grid\+\_\+rotation\+\_\+angle@{initialize\+\_\+grid\+\_\+rotation\+\_\+angle}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{initialize\+\_\+grid\+\_\+rotation\+\_\+angle()}{initialize\_grid\_rotation\_angle()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::initialize\+\_\+grid\+\_\+rotation\+\_\+angle (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF }\end{DoxyParamCaption})}



initialize\+\_\+grid\+\_\+rotation\+\_\+angle initializes the arrays with the sine and cosine of the angle between logical north on the grid and true north. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em pf} & A structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


Definition at line 548 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
548   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The dynamic horizontal grid}
549   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{  !< A structure indicating the open file}
550 \textcolor{comment}{                                               !! to parse for model parameter values.}
551 
552   \textcolor{keywordtype}{real}    :: angle, lon\_scale
553   \textcolor{keywordtype}{real}    :: len\_lon    \textcolor{comment}{! The periodic range of longitudes, usually 360 degrees.}
554   \textcolor{keywordtype}{real}    :: pi\_720deg  \textcolor{comment}{! One quarter the conversion factor from degrees to radians.}
555   \textcolor{keywordtype}{real}    :: lonB(2,2)  \textcolor{comment}{! The longitude of a point, shifted to have about the same value.}
556   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_grid\_rotation\_angle"} \textcolor{comment}{! This subroutine's name.}
557   \textcolor{keywordtype}{logical} :: use\_bugs
558   \textcolor{keywordtype}{integer} :: i, j, m, n
559 
560   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"GRID\_ROTATION\_ANGLE\_BUGS"}, use\_bugs, &
561                  \textcolor{stringliteral}{"If true, use an older algorithm to calculate the sine and "}//&
562                  \textcolor{stringliteral}{"cosines needed rotate between grid-oriented directions and "}//&
563                  \textcolor{stringliteral}{"true north and east.  Differences arise at the tripolar fold."}, &
564                  default=.false.)
565 
566   \textcolor{keywordflow}{if} (use\_bugs) \textcolor{keywordflow}{then}
567     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
568       lon\_scale    = cos((g%geoLatBu(i-1,j-1) + g%geoLatBu(i,j-1  ) + &
569                           g%geoLatBu(i-1,j) + g%geoLatBu(i,j)) * atan(1.0)/180)
570       angle        = atan2((g%geoLonBu(i-1,j) + g%geoLonBu(i,j) - &
571                             g%geoLonBu(i-1,j-1) - g%geoLonBu(i,j-1))*lon\_scale, &
572                             g%geoLatBu(i-1,j) + g%geoLatBu(i,j) - &
573                             g%geoLatBu(i-1,j-1) - g%geoLatBu(i,j-1) )
574       g%sin\_rot(i,j) = sin(angle) \textcolor{comment}{! angle is the clockwise angle from lat/lon to ocean}
575       g%cos\_rot(i,j) = cos(angle) \textcolor{comment}{! grid (e.g. angle of ocean "north" from true north)}
576 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
577 
578     \textcolor{comment}{! This is not right at a tripolar or cubed-sphere fold.}
579     \textcolor{keyword}{call }pass\_var(g%cos\_rot, g%Domain)
580     \textcolor{keyword}{call }pass\_var(g%sin\_rot, g%Domain)
581   \textcolor{keywordflow}{else}
582     pi\_720deg = atan(1.0) / 180.0
583     len\_lon = 360.0 ; \textcolor{keywordflow}{if} (g%len\_lon > 0.0) len\_lon = g%len\_lon
584     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
585       \textcolor{keywordflow}{do} n=1,2 ; \textcolor{keywordflow}{do} m=1,2
586         lonb(m,n) = modulo\_around\_point(g%geoLonBu(i+m-2,j+n-2), g%geoLonT(i,j), len\_lon)
587 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
588       lon\_scale = cos(pi\_720deg*((g%geoLatBu(i-1,j-1) + g%geoLatBu(i,j)) + &
589                                  (g%geoLatBu(i,j-1) + g%geoLatBu(i-1,j)) ) )
590       angle = atan2(lon\_scale*((lonb(1,2) - lonb(2,1)) + (lonb(2,2) - lonb(1,1))), &
591                     (g%geoLatBu(i-1,j) - g%geoLatBu(i,j-1)) + &
592                     (g%geoLatBu(i,j) - g%geoLatBu(i-1,j-1)) )
593       g%sin\_rot(i,j) = sin(angle) \textcolor{comment}{! angle is the clockwise angle from lat/lon to ocean}
594       g%cos\_rot(i,j) = cos(angle) \textcolor{comment}{! grid (e.g. angle of ocean "north" from true north)}
595 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
596 
597     \textcolor{keyword}{call }pass\_vector(g%cos\_rot, g%sin\_rot, g%Domain, stagger=agrid)
598 \textcolor{keywordflow}{  endif}
599 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a3b944f383cd2586189347532539656ef}\label{namespacemom__shared__initialization_a3b944f383cd2586189347532539656ef}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!initialize\+\_\+topography\+\_\+from\+\_\+file@{initialize\+\_\+topography\+\_\+from\+\_\+file}}
\index{initialize\+\_\+topography\+\_\+from\+\_\+file@{initialize\+\_\+topography\+\_\+from\+\_\+file}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{initialize\+\_\+topography\+\_\+from\+\_\+file()}{initialize\_topography\_from\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::initialize\+\_\+topography\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Read gridded depths from file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt out}  & {\em d} & Ocean bottom depth in m or Z if US is present\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 141 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
141   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),           \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
142   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
143                                     \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
144   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}
145   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
146   \textcolor{comment}{! Local variables}
147   \textcolor{keywordtype}{real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}
148   \textcolor{keywordtype}{character(len=200)} :: filename, topo\_file, inputdir \textcolor{comment}{! Strings for file/path}
149   \textcolor{keywordtype}{character(len=200)} :: topo\_varname                  \textcolor{comment}{! Variable name in file}
150   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_topography\_from\_file"} \textcolor{comment}{! This subroutine's name.}
151 
152   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
153 
154   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
155 
156   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
157   inputdir = slasher(inputdir)
158   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TOPO\_FILE"}, topo\_file, &
159                  \textcolor{stringliteral}{"The file from which the bathymetry is read."}, &
160                  default=\textcolor{stringliteral}{"topog.nc"})
161   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TOPO\_VARNAME"}, topo\_varname, &
162                  \textcolor{stringliteral}{"The name of the bathymetry variable in TOPO\_FILE."}, &
163                  default=\textcolor{stringliteral}{"depth"})
164 
165   filename = trim(inputdir)//trim(topo\_file)
166   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/TOPO\_FILE"}, filename)
167 
168   \textcolor{keywordflow}{if} (.not.file\_exists(filename, g%Domain)) \textcolor{keyword}{call }mom\_error(fatal, &
169        \textcolor{stringliteral}{" initialize\_topography\_from\_file: Unable to open "}//trim(filename))
170 
171   d(:,:) = -9.e30*m\_to\_z \textcolor{comment}{! Initializing to a very large negative depth (tall mountains) everywhere}
172                          \textcolor{comment}{! before reading from a file should do nothing. However, in the instance of}
173                          \textcolor{comment}{! masked-out PEs, halo regions are not updated when a processor does not}
174                          \textcolor{comment}{! exist. We need to ensure the depth in masked-out PEs appears to be that}
175                          \textcolor{comment}{! of land so this line does that in the halo regions. For non-masked PEs}
176                          \textcolor{comment}{! the halo region is filled properly with a later pass\_var().}
177   \textcolor{keyword}{call }mom\_read\_data(filename, trim(topo\_varname), d, g%Domain, scale=m\_to\_z)
178 
179   \textcolor{keyword}{call }apply\_topography\_edits\_from\_file(d, g, param\_file, us)
180 
181   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a852dd7dc66a31abe47dc83b769fb4ae4}\label{namespacemom__shared__initialization_a852dd7dc66a31abe47dc83b769fb4ae4}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!initialize\+\_\+topography\+\_\+named@{initialize\+\_\+topography\+\_\+named}}
\index{initialize\+\_\+topography\+\_\+named@{initialize\+\_\+topography\+\_\+named}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{initialize\+\_\+topography\+\_\+named()}{initialize\_topography\_named()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::initialize\+\_\+topography\+\_\+named (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{character(len=$\ast$), intent(in)}]{topog\+\_\+config,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



initialize the bathymetry based on one of several named idealized configurations 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt out}  & {\em d} & Ocean bottom depth in m or Z if US is present\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em topog\+\_\+config} & The name of an idealized topographic configuration\\
\hline
\mbox{\tt in}  & {\em max\+\_\+depth} & Maximum depth of model in the units of D\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 302 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
302   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),           \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
303   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
304                                     \textcolor{keywordtype}{intent(out)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
305   \textcolor{keywordtype}{type}(param\_file\_type),            \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< Parameter file structure}
306   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)}  :: topog\_config\textcolor{comment}{ !< The name of an idealized}
307 \textcolor{comment}{                                                              !! topographic configuration}
308   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{  !< Maximum depth of model in the units of D}
309   \textcolor{keywordtype}{type}(unit\_scale\_type),  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
310 
311   \textcolor{comment}{! This subroutine places the bottom depth in m into D(:,:), shaped according to the named config.}
312 
313   \textcolor{comment}{! Local variables}
314   \textcolor{keywordtype}{real} :: m\_to\_Z               \textcolor{comment}{! A dimensional rescaling factor.}
315   \textcolor{keywordtype}{real} :: min\_depth            \textcolor{comment}{! The minimum depth [Z ~> m].}
316   \textcolor{keywordtype}{real} :: PI                   \textcolor{comment}{! 3.1415926... calculated as 4*atan(1)}
317   \textcolor{keywordtype}{real} :: D0                   \textcolor{comment}{! A constant to make the maximum  basin depth MAXIMUM\_DEPTH.}
318   \textcolor{keywordtype}{real} :: expdecay             \textcolor{comment}{! A decay scale of associated with the sloping boundaries [m].}
319   \textcolor{keywordtype}{real} :: Dedge                \textcolor{comment}{! The depth [Z ~> m], at the basin edge}
320 \textcolor{comment}{! real :: south\_lat, west\_lon, len\_lon, len\_lat, Rad\_earth}
321   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
322   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"initialize\_topography\_named"} \textcolor{comment}{! This subroutine's name.}
323   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
324   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
325 
326   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
327   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  MOM\_shared\_initialization.F90, initialize\_topography\_named: "}//&
328                  \textcolor{stringliteral}{"TOPO\_CONFIG = "}//trim(topog\_config), 5)
329 
330   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
331 
332   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
333                  \textcolor{stringliteral}{"The minimum depth of the ocean."}, units=\textcolor{stringliteral}{"m"}, default=0.0, scale=m\_to\_z)
334   \textcolor{keywordflow}{if} (max\_depth<=0.) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_topography\_named: "}// &
335       \textcolor{stringliteral}{"MAXIMUM\_DEPTH has a non-sensical value! Was it set?"})
336 
337   \textcolor{keywordflow}{if} (trim(topog\_config) /= \textcolor{stringliteral}{"flat"}) \textcolor{keywordflow}{then}
338     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EDGE\_DEPTH"}, dedge, &
339                    \textcolor{stringliteral}{"The depth at the edge of one of the named topographies."}, &
340                    units=\textcolor{stringliteral}{"m"}, default=100.0, scale=m\_to\_z)
341 \textcolor{comment}{!   call get\_param(param\_file, mdl, "SOUTHLAT", south\_lat, &}
342 \textcolor{comment}{!                  "The southern latitude of the domain.", units="degrees", &}
343 \textcolor{comment}{!                  fail\_if\_missing=.true.)}
344 \textcolor{comment}{!   call get\_param(param\_file, mdl, "LENLAT", len\_lat, &}
345 \textcolor{comment}{!                  "The latitudinal length of the domain.", units="degrees", &}
346 \textcolor{comment}{!                  fail\_if\_missing=.true.)}
347 \textcolor{comment}{!   call get\_param(param\_file, mdl, "WESTLON", west\_lon, &}
348 \textcolor{comment}{!                  "The western longitude of the domain.", units="degrees", &}
349 \textcolor{comment}{!                  default=0.0)}
350 \textcolor{comment}{!   call get\_param(param\_file, mdl, "LENLON", len\_lon, &}
351 \textcolor{comment}{!                  "The longitudinal length of the domain.", units="degrees", &}
352 \textcolor{comment}{!                  fail\_if\_missing=.true.)}
353 \textcolor{comment}{!   call get\_param(param\_file, mdl, "RAD\_EARTH", Rad\_Earth, &}
354 \textcolor{comment}{!                  "The radius of the Earth.", units="m", default=6.378e6)}
355     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TOPOG\_SLOPE\_SCALE"}, expdecay, &
356                    \textcolor{stringliteral}{"The exponential decay scale used in defining some of "}//&
357                    \textcolor{stringliteral}{"the named topographies."}, units=\textcolor{stringliteral}{"m"}, default=400000.0)
358 \textcolor{keywordflow}{  endif}
359 
360 
361   pi = 4.0*atan(1.0)
362 
363   \textcolor{keywordflow}{if} (trim(topog\_config) == \textcolor{stringliteral}{"flat"}) \textcolor{keywordflow}{then}
364     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je ; d(i,j) = max\_depth ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
365   \textcolor{keywordflow}{elseif} (trim(topog\_config) == \textcolor{stringliteral}{"spoon"}) \textcolor{keywordflow}{then}
366     d0 = (max\_depth - dedge) / &
367              ((1.0 - exp(-0.5*g%len\_lat*g%Rad\_earth*pi/(180.0 *expdecay))) * &
368               (1.0 - exp(-0.5*g%len\_lat*g%Rad\_earth*pi/(180.0 *expdecay))))
369     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
370   \textcolor{comment}{!  This sets a bowl shaped (sort of) bottom topography, with a       !}
371   \textcolor{comment}{!  maximum depth of max\_depth.                                   !}
372       d(i,j) =  dedge + d0 * &
373              (sin(pi * (g%geoLonT(i,j) - (g%west\_lon)) / g%len\_lon) * &
374            (1.0 - exp((g%geoLatT(i,j) - (g%south\_lat+g%len\_lat))*g%Rad\_earth*pi / &
375                       (180.0*expdecay)) ))
376 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
377   \textcolor{keywordflow}{elseif} (trim(topog\_config) == \textcolor{stringliteral}{"bowl"}) \textcolor{keywordflow}{then}
378     d0 = (max\_depth - dedge) / &
379              ((1.0 - exp(-0.5*g%len\_lat*g%Rad\_earth*pi/(180.0 *expdecay))) * &
380               (1.0 - exp(-0.5*g%len\_lat*g%Rad\_earth*pi/(180.0 *expdecay))))
381 
382   \textcolor{comment}{!  This sets a bowl shaped (sort of) bottom topography, with a}
383   \textcolor{comment}{!  maximum depth of max\_depth.}
384     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
385       d(i,j) =  dedge + d0 * &
386              (sin(pi * (g%geoLonT(i,j) - g%west\_lon) / g%len\_lon) * &
387              ((1.0 - exp(-(g%geoLatT(i,j) - g%south\_lat)*g%Rad\_Earth*pi/ &
388                           (180.0*expdecay))) * &
389              (1.0 - exp((g%geoLatT(i,j) - (g%south\_lat+g%len\_lat))* &
390                          g%Rad\_Earth*pi/(180.0*expdecay)))))
391 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
392   \textcolor{keywordflow}{elseif} (trim(topog\_config) == \textcolor{stringliteral}{"halfpipe"}) \textcolor{keywordflow}{then}
393     d0 = max\_depth - dedge
394     \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
395       d(i,j) =  dedge + d0 * abs(sin(pi*(g%geoLatT(i,j) - g%south\_lat)/g%len\_lat))
396 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
397   \textcolor{keywordflow}{else}
398     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"initialize\_topography\_named: "}// &
399       \textcolor{stringliteral}{"Unrecognized topography name "}//trim(topog\_config))
400 \textcolor{keywordflow}{  endif}
401 
402   \textcolor{comment}{! This is here just for safety.  Hopefully it doesn't do anything.}
403   \textcolor{keywordflow}{do} i=is,ie ; \textcolor{keywordflow}{do} j=js,je
404     \textcolor{keywordflow}{if} (d(i,j) > max\_depth) d(i,j) = max\_depth
405     \textcolor{keywordflow}{if} (d(i,j) < min\_depth) d(i,j) = 0.5*min\_depth
406 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
407 
408   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_ae2e3b3c739630c8746c533102b8c5d76}\label{namespacemom__shared__initialization_ae2e3b3c739630c8746c533102b8c5d76}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!limit\+\_\+topography@{limit\+\_\+topography}}
\index{limit\+\_\+topography@{limit\+\_\+topography}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{limit\+\_\+topography()}{limit\_topography()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::limit\+\_\+topography (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(inout)}]{D,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



limit\+\_\+topography ensures that min\+\_\+depth $<$ D(x,y) $<$ max\+\_\+depth 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt in,out}  & {\em d} & Ocean bottom depth in m or Z if US is present\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em max\+\_\+depth} & Maximum depth of model in the units of D\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 415 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
415   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
416   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
417                           \textcolor{keywordtype}{intent(inout)} :: D\textcolor{comment}{ !< Ocean bottom depth in m or Z if US is present}
418   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
419   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: max\_depth\textcolor{comment}{  !< Maximum depth of model in the units of D}
420   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{   !< A dimensional unit scaling type}
421 
422   \textcolor{comment}{! Local variables}
423   \textcolor{keywordtype}{real} :: m\_to\_Z  \textcolor{comment}{! A dimensional rescaling factor.}
424   \textcolor{keywordtype}{integer} :: i, j
425   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"limit\_topography"} \textcolor{comment}{! This subroutine's name.}
426   \textcolor{keywordtype}{real} :: min\_depth, mask\_depth
427 
428   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
429 
430   m\_to\_z = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_z = us%m\_to\_Z
431 
432   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MINIMUM\_DEPTH"}, min\_depth, &
433                  \textcolor{stringliteral}{"If MASKING\_DEPTH is unspecified, then anything shallower than "}//&
434                  \textcolor{stringliteral}{"MINIMUM\_DEPTH is assumed to be land and all fluxes are masked out. "}//&
435                  \textcolor{stringliteral}{"If MASKING\_DEPTH is specified, then all depths shallower than "}//&
436                  \textcolor{stringliteral}{"MINIMUM\_DEPTH but deeper than MASKING\_DEPTH are rounded to MINIMUM\_DEPTH."}, &
437                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=m\_to\_z)
438   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"MASKING\_DEPTH"}, mask\_depth, &
439                  \textcolor{stringliteral}{"The depth below which to mask the ocean as land."}, &
440                  units=\textcolor{stringliteral}{"m"}, default=-9999.0, scale=m\_to\_z, do\_not\_log=.true.)
441 
442 \textcolor{comment}{! Make sure that min\_depth < D(x,y) < max\_depth}
443   \textcolor{keywordflow}{if} (mask\_depth < -9990.*m\_to\_z) \textcolor{keywordflow}{then}
444     \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
445       d(i,j) = min( max( d(i,j), 0.5*min\_depth ), max\_depth )
446 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
447   \textcolor{keywordflow}{else}
448     \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%isd,g%ied
449       \textcolor{keywordflow}{if} (d(i,j)>0.) \textcolor{keywordflow}{then}
450         d(i,j) = min( max( d(i,j), min\_depth ), max\_depth )
451       \textcolor{keywordflow}{else}
452         d(i,j) = 0.
453 \textcolor{keywordflow}{      endif}
454 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
455 \textcolor{keywordflow}{  endif}
456 
457   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_ac024655ad7fa6e243ceb90e9daa14388}\label{namespacemom__shared__initialization_ac024655ad7fa6e243ceb90e9daa14388}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!modulo\+\_\+around\+\_\+point@{modulo\+\_\+around\+\_\+point}}
\index{modulo\+\_\+around\+\_\+point@{modulo\+\_\+around\+\_\+point}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{modulo\+\_\+around\+\_\+point()}{modulo\_around\_point()}}
{\footnotesize\ttfamily real function mom\+\_\+shared\+\_\+initialization\+::modulo\+\_\+around\+\_\+point (\begin{DoxyParamCaption}\item[{real, intent(in)}]{x,  }\item[{real, intent(in)}]{xc,  }\item[{real, intent(in)}]{Lx }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Return the modulo value of x in an interval \mbox{[}xc-\/(Lx/2) xc+(Lx/2)\mbox{]} If Lx$<$=0, then it returns x without applying modulo arithmetic. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em x} & Value to which to apply modulo arithmetic\\
\hline
\mbox{\tt in}  & {\em xc} & Center of modulo range\\
\hline
\mbox{\tt in}  & {\em lx} & Modulo range width\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
x shifted by an integer multiple of Lx to be close to xc. 
\end{DoxyReturn}


Definition at line 606 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
606   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{  !< Value to which to apply modulo arithmetic}
607   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: xc\textcolor{comment}{ !< Center of modulo range}
608   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: Lx\textcolor{comment}{ !< Modulo range width}
609   \textcolor{keywordtype}{real} :: x\_mod\textcolor{comment}{          !< x shifted by an integer multiple of Lx to be close to xc.}
610 
611   \textcolor{keywordflow}{if} (lx > 0.0) \textcolor{keywordflow}{then}
612     x\_mod = modulo(x - (xc - 0.5*lx), lx) + (xc - 0.5*lx)
613   \textcolor{keywordflow}{else}
614     x\_mod = x
615 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a4ec3c9951969b11a90acf193a423d893}\label{namespacemom__shared__initialization_a4ec3c9951969b11a90acf193a423d893}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!mom\+\_\+calculate\+\_\+grad\+\_\+coriolis@{mom\+\_\+calculate\+\_\+grad\+\_\+coriolis}}
\index{mom\+\_\+calculate\+\_\+grad\+\_\+coriolis@{mom\+\_\+calculate\+\_\+grad\+\_\+coriolis}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{mom\+\_\+calculate\+\_\+grad\+\_\+coriolis()}{mom\_calculate\_grad\_coriolis()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::mom\+\_\+calculate\+\_\+grad\+\_\+coriolis (\begin{DoxyParamCaption}\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{d\+F\+\_\+dx,  }\item[{real, dimension(g\%isd\+:g\%ied,g\%jsd\+:g\%jed), intent(out)}]{d\+F\+\_\+dy,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Calculates the components of grad f (Coriolis parameter) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt out}  & {\em df\+\_\+dx} & x-\/component of grad f \mbox{[}T-\/1 L-\/1 $\sim$$>$ s-\/1 m-\/1\mbox{]}\\
\hline
\mbox{\tt out}  & {\em df\+\_\+dy} & y-\/component of grad f \mbox{[}T-\/1 L-\/1 $\sim$$>$ s-\/1 m-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 91 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
91   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),             \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
92   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
93                                       \textcolor{keywordtype}{intent(out)}   :: dF\_dx\textcolor{comment}{ !< x-component of grad f [T-1 L-1 ~> s-1 m-1]}
94   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd:G%ied,G%jsd:G%jed)}, &
95                                       \textcolor{keywordtype}{intent(out)}   :: dF\_dy\textcolor{comment}{ !< y-component of grad f [T-1 L-1 ~> s-1 m-1]}
96   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}
97   \textcolor{comment}{! Local variables}
98   \textcolor{keywordtype}{integer} :: i,j
99   \textcolor{keywordtype}{real} :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
100   \textcolor{keywordtype}{real} :: f1, f2
101 
102   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us%m\_to\_L
103 
104   \textcolor{keywordflow}{if} ((lbound(g%CoriolisBu,1) > g%isc-1) .or. &
105       (lbound(g%CoriolisBu,2) > g%isc-1)) \textcolor{keywordflow}{then}
106     \textcolor{comment}{! The gradient of the Coriolis parameter can not be calculated with this grid.}
107     df\_dx(:,:) = 0.0 ; df\_dy(:,:) = 0.0
108     \textcolor{keywordflow}{return}
109 \textcolor{keywordflow}{  endif}
110 
111   \textcolor{keywordflow}{do} j=g%jsc, g%jec ; \textcolor{keywordflow}{do} i=g%isc, g%iec
112     f1 = 0.5*( g%CoriolisBu(i,j) + g%CoriolisBu(i,j-1) )
113     f2 = 0.5*( g%CoriolisBu(i-1,j) + g%CoriolisBu(i-1,j-1) )
114     df\_dx(i,j) = g%IdxT(i,j) * ( f1 - f2 )
115     f1 = 0.5*( g%CoriolisBu(i,j) + g%CoriolisBu(i-1,j) )
116     f2 = 0.5*( g%CoriolisBu(i,j-1) + g%CoriolisBu(i-1,j-1) )
117     df\_dy(i,j) = g%IdyT(i,j) * ( f1 - f2 )
118 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
119   \textcolor{keyword}{call }pass\_vector(df\_dx, df\_dy, g%Domain, stagger=agrid)
120 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a1e501ab8351b666491169c804418e9df}\label{namespacemom__shared__initialization_a1e501ab8351b666491169c804418e9df}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!mom\+\_\+initialize\+\_\+rotation@{mom\+\_\+initialize\+\_\+rotation}}
\index{mom\+\_\+initialize\+\_\+rotation@{mom\+\_\+initialize\+\_\+rotation}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{mom\+\_\+initialize\+\_\+rotation()}{mom\_initialize\_rotation()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::mom\+\_\+initialize\+\_\+rotation (\begin{DoxyParamCaption}\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(out)}]{f,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



M\+O\+M\+\_\+initialize\+\_\+rotation makes the appropriate call to set up the Coriolis parameter. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt out}  & {\em f} & The Coriolis parameter \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em pf} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 58 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
58   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),                       \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The dynamic horizontal grid type}
59   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, \textcolor{keywordtype}{intent(out)} :: f\textcolor{comment}{  !< The Coriolis parameter [T-1 ~> s-1]}
60   \textcolor{keywordtype}{type}(param\_file\_type),                        \textcolor{keywordtype}{intent(in)}  :: PF\textcolor{comment}{ !< Parameter file structure}
61   \textcolor{keywordtype}{type}(unit\_scale\_type),              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
62 
63 \textcolor{comment}{!   This subroutine makes the appropriate call to set up the Coriolis parameter.}
64 \textcolor{comment}{! This is a separate subroutine so that it can be made public and shared with}
65 \textcolor{comment}{! the ice-sheet code or other components.}
66 \textcolor{comment}{! Set up the Coriolis parameter, f, either analytically or from file.}
67   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_initialize\_rotation"} \textcolor{comment}{! This subroutine's name.}
68   \textcolor{keywordtype}{character(len=200)} :: config
69 
70   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
71   \textcolor{keyword}{call }get\_param(pf, mdl, \textcolor{stringliteral}{"ROTATION"}, config, &
72                  \textcolor{stringliteral}{"This specifies how the Coriolis parameter is specified: \(\backslash\)n"}//&
73                  \textcolor{stringliteral}{" \(\backslash\)t 2omegasinlat - Use twice the planetary rotation rate \(\backslash\)n"}//&
74                  \textcolor{stringliteral}{" \(\backslash\)t\(\backslash\)t times the sine of latitude.\(\backslash\)n"}//&
75                  \textcolor{stringliteral}{" \(\backslash\)t betaplane - Use a beta-plane or f-plane.\(\backslash\)n"}//&
76                  \textcolor{stringliteral}{" \(\backslash\)t USER - call a user modified routine."}, &
77                  default=\textcolor{stringliteral}{"2omegasinlat"})
78   \textcolor{keywordflow}{select case} (trim(config))
79     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"2omegasinlat"}); \textcolor{keyword}{call }set\_rotation\_planetary(f, g, pf, us)
80     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"beta"}); \textcolor{keyword}{call }set\_rotation\_beta\_plane(f, g, pf, us)
81     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"betaplane"}); \textcolor{keyword}{call }set\_rotation\_beta\_plane(f, g, pf, us)
82    \textcolor{comment}{!case ("nonrotating") ! Note from AJA: Missing case?}
83 \textcolor{keywordflow}{    case default} ; \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_initialize: "}// &
84       \textcolor{stringliteral}{"Unrecognized rotation setup "}//trim(config))
85 \textcolor{keywordflow}{  end select}
86   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a9e9d95233423f98871c9e1864563f10d}\label{namespacemom__shared__initialization_a9e9d95233423f98871c9e1864563f10d}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!mom\+\_\+shared\+\_\+init\+\_\+init@{mom\+\_\+shared\+\_\+init\+\_\+init}}
\index{mom\+\_\+shared\+\_\+init\+\_\+init@{mom\+\_\+shared\+\_\+init\+\_\+init}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{mom\+\_\+shared\+\_\+init\+\_\+init()}{mom\_shared\_init\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::mom\+\_\+shared\+\_\+init\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{PF }\end{DoxyParamCaption})}



M\+O\+M\+\_\+shared\+\_\+init\+\_\+init just writes the code version. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em pf} & A structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


Definition at line 43 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
43   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: PF\textcolor{comment}{   !< A structure indicating the open file}
44 \textcolor{comment}{                                                 !! to parse for model parameter values.}
45 
46   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_shared\_initialization"} \textcolor{comment}{! This module's name.}
47 
48 \textcolor{comment}{! This include declares and sets the variable "version".}
49 \textcolor{preprocessor}{#include "version\_variable.h"}
50 \textcolor{preprocessor}{}  \textcolor{keyword}{call }log\_version(pf, mdl, version, &
51    \textcolor{stringliteral}{"Sharable code to initialize time-invariant fields, like bathymetry and Coriolis parameters."})
52 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a49c0443c10514a0d5ce5d8df4d68bce8}\label{namespacemom__shared__initialization_a49c0443c10514a0d5ce5d8df4d68bce8}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!read\+\_\+face\+\_\+length\+\_\+list@{read\+\_\+face\+\_\+length\+\_\+list}}
\index{read\+\_\+face\+\_\+length\+\_\+list@{read\+\_\+face\+\_\+length\+\_\+list}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{read\+\_\+face\+\_\+length\+\_\+list()}{read\_face\_length\_list()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::read\+\_\+face\+\_\+length\+\_\+list (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{iounit,  }\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{integer, intent(out)}]{num\+\_\+lines,  }\item[{character(len=120), dimension(\+:), pointer}]{lines }\end{DoxyParamCaption})}



This subroutine reads and counts the non-\/blank lines in the face length list file, after removing comments. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em iounit} & An open I/O unit number for the file\\
\hline
\mbox{\tt in}  & {\em filename} & The name of the face-\/length file to read\\
\hline
\mbox{\tt out}  & {\em num\+\_\+lines} & The number of non-\/blank lines in the file\\
\hline
 & {\em lines} & The non-\/blank lines, after removing comments \\
\hline
\end{DoxyParams}


Definition at line 1055 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
1055   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{intent(in)}  :: iounit\textcolor{comment}{    !< An open I/O unit number for the file}
1056   \textcolor{keywordtype}{character(len=*)},                 \textcolor{keywordtype}{intent(in)}  :: filename\textcolor{comment}{  !< The name of the face-length file to read}
1057   \textcolor{keywordtype}{integer},                          \textcolor{keywordtype}{intent(out)} :: num\_lines\textcolor{comment}{ !< The number of non-blank lines in the file}
1058   \textcolor{keywordtype}{character(len=120)}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{pointer}     :: lines\textcolor{comment}{  !< The non-blank lines, after removing comments}
1059 
1060   \textcolor{comment}{!   This subroutine reads and counts the non-blank lines in the face length}
1061   \textcolor{comment}{! list file, after removing comments.}
1062   \textcolor{keywordtype}{character(len=120)} :: line, line\_up
1063   \textcolor{keywordtype}{logical} :: found\_u, found\_v
1064   \textcolor{keywordtype}{integer} :: isu, isv, icom, verbose
1065   \textcolor{keywordtype}{integer} :: last
1066 
1067   num\_lines = 0
1068 
1069   \textcolor{keywordflow}{if} (iounit <= 0) \textcolor{keywordflow}{return}
1070   rewind(iounit)
1071   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while}(.true.)
1072     \textcolor{keyword}{read}(iounit, \textcolor{stringliteral}{'(a)'}, end=8, err=9) line
1073     last = len\_trim(line)
1074     \textcolor{comment}{! Eliminate either F90 or C comments from the line.}
1075     icom = index(line(:last), \textcolor{stringliteral}{"!"}) ; \textcolor{keywordflow}{if} (icom > 0) last = icom-1
1076     icom = index(line(:last), \textcolor{stringliteral}{"/*"}) ; \textcolor{keywordflow}{if} (icom > 0) last = icom-1
1077     \textcolor{keywordflow}{if} (last < 1) cycle
1078 
1079     \textcolor{comment}{! Detect keywords}
1080     line\_up = uppercase(line)
1081     found\_u = .false.; found\_v = .false.
1082     isu = index(line\_up(:last), \textcolor{stringliteral}{"U\_WIDTH"} ); \textcolor{keywordflow}{if} (isu > 0) found\_u = .true.
1083     isv = index(line\_up(:last), \textcolor{stringliteral}{"V\_WIDTH"} ); \textcolor{keywordflow}{if} (isv > 0) found\_v = .true.
1084 
1085     \textcolor{keywordflow}{if} (found\_u .and. found\_v) \textcolor{keyword}{call }mom\_error(fatal, &
1086       \textcolor{stringliteral}{"read\_face\_length\_list : both U\_WIDTH and V\_WIDTH found when "}//&
1087       \textcolor{stringliteral}{"reading the line "}//trim(line(:last))//\textcolor{stringliteral}{" in file "}//trim(filename))
1088     \textcolor{keywordflow}{if} (found\_u .or. found\_v) \textcolor{keywordflow}{then}
1089       num\_lines = num\_lines + 1
1090       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(lines)) \textcolor{keywordflow}{then}
1091         lines(num\_lines) = line(1:last)
1092 \textcolor{keywordflow}{      endif}
1093 \textcolor{keywordflow}{    endif}
1094 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! while (.true.)}
1095 
1096 8 \textcolor{keywordflow}{continue}
1097   \textcolor{keywordflow}{return}
1098 
1099 9 \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"read\_face\_length\_list : "}//&
1100                   \textcolor{stringliteral}{"Error while reading file "}//trim(filename))
1101 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a27bab8da74b45855db4466ce4942456f}\label{namespacemom__shared__initialization_a27bab8da74b45855db4466ce4942456f}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!reset\+\_\+face\+\_\+lengths\+\_\+file@{reset\+\_\+face\+\_\+lengths\+\_\+file}}
\index{reset\+\_\+face\+\_\+lengths\+\_\+file@{reset\+\_\+face\+\_\+lengths\+\_\+file}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{reset\+\_\+face\+\_\+lengths\+\_\+file()}{reset\_face\_lengths\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::reset\+\_\+face\+\_\+lengths\+\_\+file (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets the open face lengths at selected points to restrict passages to their observed widths from a arrays read from a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 750 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
750   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The dynamic horizontal grid}
751   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
752   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
753 
754   \textcolor{comment}{! Local variables}
755   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"reset\_face\_lengths\_file"} \textcolor{comment}{! This subroutine's name.}
756   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}
757   \textcolor{keywordtype}{character(len=200)} :: filename, chan\_file, inputdir \textcolor{comment}{! Strings for file/path}
758   \textcolor{keywordtype}{real} :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
759   \textcolor{keywordtype}{real} :: L\_to\_m  \textcolor{comment}{! A unit conversion factor [m L-1 ~> nondim]}
760   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
761   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
762   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
763   \textcolor{comment}{! These checks apply regardless of the chosen option.}
764 
765   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
766   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us%m\_to\_L
767   l\_to\_m = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m = us%L\_to\_m
768 
769   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CHANNEL\_WIDTH\_FILE"}, chan\_file, &
770                  \textcolor{stringliteral}{"The file from which the list of narrowed channels is read."}, &
771                  default=\textcolor{stringliteral}{"ocean\_geometry.nc"})
772   \textcolor{keyword}{call }get\_param(param\_file,  mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
773   inputdir = slasher(inputdir)
774   filename = trim(inputdir)//trim(chan\_file)
775   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/CHANNEL\_WIDTH\_FILE"}, filename)
776 
777   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (.not.file\_exists(filename)) &
778     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{" reset\_face\_lengths\_file: Unable to open "}//&
779                            trim(filename))
780 \textcolor{keywordflow}{  endif}
781 
782   \textcolor{keyword}{call }mom\_read\_vector(filename, \textcolor{stringliteral}{"dyCuo"}, \textcolor{stringliteral}{"dxCvo"}, g%dy\_Cu, g%dx\_Cv, g%Domain, scale=m\_to\_l)
783   \textcolor{keyword}{call }pass\_vector(g%dy\_Cu, g%dx\_Cv, g%Domain, to\_all+scalar\_pair, cgrid\_ne)
784 
785   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
786     \textcolor{keywordflow}{if} (l\_to\_m*g%dy\_Cu(i,j) > l\_to\_m*g%dyCu(i,j)) \textcolor{keywordflow}{then}
787       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("dy\_Cu of ",ES11.4," exceeds unrestricted width of ",ES11.4,&}
788 \textcolor{stringliteral}{}\textcolor{stringliteral}{                   &" by ",ES11.4," at lon/lat of ", ES11.4, ES11.4)'}) &
789                    l\_to\_m*g%dy\_Cu(i,j), l\_to\_m*g%dyCu(i,j), l\_to\_m*g%dy\_Cu(i,j)-l\_to\_m*g%dyCu(i,j), &
790                    g%geoLonCu(i,j), g%geoLatCu(i,j)
791       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"reset\_face\_lengths\_file "}//mesg)
792 \textcolor{keywordflow}{    endif}
793     g%areaCu(i,j) = g%dxCu(i,j) * g%dy\_Cu(i,j)
794     g%IareaCu(i,j) = 0.0
795     \textcolor{keywordflow}{if} (g%areaCu(i,j) > 0.0) g%IareaCu(i,j) = g%mask2dCu(i,j) / (g%areaCu(i,j))
796 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
797 
798   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
799     \textcolor{keywordflow}{if} (l\_to\_m*g%dx\_Cv(i,j) > l\_to\_m*g%dxCv(i,j)) \textcolor{keywordflow}{then}
800       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("dx\_Cv of ",ES11.4," exceeds unrestricted width of ",ES11.4,&}
801 \textcolor{stringliteral}{}\textcolor{stringliteral}{                   &" by ",ES11.4, " at lon/lat of ", ES11.4, ES11.4)'}) &
802                    l\_to\_m*g%dx\_Cv(i,j), l\_to\_m*g%dxCv(i,j), l\_to\_m*g%dx\_Cv(i,j)-l\_to\_m*g%dxCv(i,j), &
803                    g%geoLonCv(i,j), g%geoLatCv(i,j)
804 
805       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"reset\_face\_lengths\_file "}//mesg)
806 \textcolor{keywordflow}{    endif}
807     g%areaCv(i,j) = g%dyCv(i,j) * g%dx\_Cv(i,j)
808     g%IareaCv(i,j) = 0.0
809     \textcolor{keywordflow}{if} (g%areaCv(i,j) > 0.0) g%IareaCv(i,j) = g%mask2dCv(i,j) / (g%areaCv(i,j))
810 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
811 
812   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_aea0f76e5a7193df606ba3f09703ca30a}\label{namespacemom__shared__initialization_aea0f76e5a7193df606ba3f09703ca30a}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!reset\+\_\+face\+\_\+lengths\+\_\+list@{reset\+\_\+face\+\_\+lengths\+\_\+list}}
\index{reset\+\_\+face\+\_\+lengths\+\_\+list@{reset\+\_\+face\+\_\+lengths\+\_\+list}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{reset\+\_\+face\+\_\+lengths\+\_\+list()}{reset\_face\_lengths\_list()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::reset\+\_\+face\+\_\+lengths\+\_\+list (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets the open face lengths at selected points to restrict passages to their observed widths from a list read from a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 820 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
820   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The dynamic horizontal grid}
821   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
822   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{ !< A dimensional unit scaling type}
823 
824   \textcolor{comment}{! Local variables}
825   \textcolor{keywordtype}{character(len=120)}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:)} :: lines => null()
826   \textcolor{keywordtype}{character(len=120)} :: line
827   \textcolor{keywordtype}{character(len=200)} :: filename, chan\_file, inputdir, mesg \textcolor{comment}{! Strings for file/path}
828   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"reset\_face\_lengths\_list"} \textcolor{comment}{! This subroutine's name.}
829   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:,:)} :: &
830     u\_lat => null(), u\_lon => null(), v\_lat => null(), v\_lon => null()
831   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:)} :: &
832     u\_width => null(), v\_width => null()
833   \textcolor{keywordtype}{real}    :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
834   \textcolor{keywordtype}{real}    :: L\_to\_m  \textcolor{comment}{! A unit conversion factor [m L-1 ~> nondim]}
835   \textcolor{keywordtype}{real}    :: lat, lon     \textcolor{comment}{! The latitude and longitude of a point.}
836   \textcolor{keywordtype}{real}    :: len\_lon      \textcolor{comment}{! The periodic range of longitudes, usually 360 degrees.}
837   \textcolor{keywordtype}{real}    :: len\_lat      \textcolor{comment}{! The range of latitudes, usually 180 degrees.}
838   \textcolor{keywordtype}{real}    :: lon\_p, lon\_m \textcolor{comment}{! The longitude of a point shifted by 360 degrees.}
839   \textcolor{keywordtype}{logical} :: check\_360    \textcolor{comment}{! If true, check for longitudes that are shifted by}
840                           \textcolor{comment}{! +/- 360 degrees from the specified range of values.}
841   \textcolor{keywordtype}{logical} :: found\_u, found\_v
842   \textcolor{keywordtype}{logical} :: unit\_in\_use
843   \textcolor{keywordtype}{integer} :: ios, iounit, isu, isv
844   \textcolor{keywordtype}{integer} :: last, num\_lines, nl\_read, ln, npt, u\_pt, v\_pt
845   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
846   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
847   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
848 
849   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
850   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us%m\_to\_L
851   l\_to\_m = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m = us%L\_to\_m
852 
853   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CHANNEL\_LIST\_FILE"}, chan\_file, &
854                  \textcolor{stringliteral}{"The file from which the list of narrowed channels is read."}, &
855                  default=\textcolor{stringliteral}{"MOM\_channel\_list"})
856   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, inputdir, default=\textcolor{stringliteral}{"."})
857   inputdir = slasher(inputdir)
858   filename = trim(inputdir)//trim(chan\_file)
859   \textcolor{keyword}{call }log\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR/CHANNEL\_LIST\_FILE"}, filename)
860   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CHANNEL\_LIST\_360\_LON\_CHECK"}, check\_360, &
861                  \textcolor{stringliteral}{"If true, the channel configuration list works for any "}//&
862                  \textcolor{stringliteral}{"longitudes in the range of -360 to 360."}, default=.true.)
863 
864   \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}
865     \textcolor{comment}{! Open the input file.}
866     \textcolor{keywordflow}{if} (.not.file\_exists(filename)) \textcolor{keyword}{call }mom\_error(fatal, &
867         \textcolor{stringliteral}{" reset\_face\_lengths\_list: Unable to open "}//trim(filename))
868 
869     \textcolor{comment}{! Find an unused unit number.}
870     \textcolor{keywordflow}{do} iounit=10,512
871       \textcolor{keyword}{INQUIRE}(iounit,opened=unit\_in\_use) ; \textcolor{keywordflow}{if} (.not.unit\_in\_use) \textcolor{keywordflow}{exit}
872 \textcolor{keywordflow}{    enddo}
873     \textcolor{keywordflow}{if} (iounit >= 512) \textcolor{keyword}{call }mom\_error(fatal, &
874         \textcolor{stringliteral}{"reset\_face\_lengths\_list: No unused file unit could be found."})
875 
876     \textcolor{comment}{! Open the parameter file.}
877     \textcolor{keyword}{open}(iounit, file=trim(filename), access=\textcolor{stringliteral}{'SEQUENTIAL'}, &
878          form=\textcolor{stringliteral}{'FORMATTED'}, action=\textcolor{stringliteral}{'READ'}, position=\textcolor{stringliteral}{'REWIND'}, iostat=ios)
879     \textcolor{keywordflow}{if} (ios /= 0) \textcolor{keyword}{call }mom\_error(fatal, &
880             \textcolor{stringliteral}{"reset\_face\_lengths\_list: Error opening "}//trim(filename))
881 
882     \textcolor{comment}{! Count the number of u\_width and v\_width entries.}
883     \textcolor{keyword}{call }read\_face\_length\_list(iounit, filename, num\_lines, lines)
884 \textcolor{keywordflow}{  endif}
885 
886   len\_lon = 360.0 ; \textcolor{keywordflow}{if} (g%len\_lon > 0.0) len\_lon = g%len\_lon
887   len\_lat = 180.0 ; \textcolor{keywordflow}{if} (g%len\_lat > 0.0) len\_lat = g%len\_lat
888   \textcolor{comment}{! Broadcast the number of lines and allocate the required space.}
889   \textcolor{keyword}{call }broadcast(num\_lines, root\_pe())
890   u\_pt = 0 ; v\_pt = 0
891   \textcolor{keywordflow}{if} (num\_lines > 0) \textcolor{keywordflow}{then}
892     \textcolor{keyword}{allocate} (lines(num\_lines))
893     \textcolor{keywordflow}{if} (num\_lines > 0) \textcolor{keywordflow}{then}
894       \textcolor{keyword}{allocate}(u\_lat(2,num\_lines)) ; u\_lat(:,:) = -1e34
895       \textcolor{keyword}{allocate}(u\_lon(2,num\_lines)) ; u\_lon(:,:) = -1e34
896       \textcolor{keyword}{allocate}(u\_width(num\_lines)) ; u\_width(:) = -1e34
897 
898       \textcolor{keyword}{allocate}(v\_lat(2,num\_lines)) ; v\_lat(:,:) = -1e34
899       \textcolor{keyword}{allocate}(v\_lon(2,num\_lines)) ; v\_lon(:,:) = -1e34
900       \textcolor{keyword}{allocate}(v\_width(num\_lines)) ; v\_width(:) = -1e34
901 \textcolor{keywordflow}{    endif}
902 
903     \textcolor{comment}{! Actually read the lines.}
904     \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}
905       \textcolor{keyword}{call }read\_face\_length\_list(iounit, filename, nl\_read, lines)
906       \textcolor{keywordflow}{if} (nl\_read /= num\_lines) &
907         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{'reset\_face\_lengths\_list : Found different '}// &
908                   \textcolor{stringliteral}{'number of valid lines on second reading of '}//trim(filename))
909       \textcolor{keyword}{close}(iounit) ; iounit = -1
910 \textcolor{keywordflow}{    endif}
911 
912     \textcolor{comment}{! Broadcast the lines.}
913     \textcolor{keyword}{call }broadcast(lines, 120, root\_pe())
914 
915     \textcolor{comment}{! Populate the u\_width, etc., data.}
916     \textcolor{keywordflow}{do} ln=1,num\_lines
917       line = lines(ln)
918       \textcolor{comment}{! Detect keywords}
919       found\_u = .false.; found\_v = .false.
920       isu = index(uppercase(line), \textcolor{stringliteral}{"U\_WIDTH"} ); \textcolor{keywordflow}{if} (isu > 0) found\_u = .true.
921       isv = index(uppercase(line), \textcolor{stringliteral}{"V\_WIDTH"} ); \textcolor{keywordflow}{if} (isv > 0) found\_v = .true.
922 
923       \textcolor{comment}{! Store and check the relevant values.}
924       \textcolor{keywordflow}{if} (found\_u) \textcolor{keywordflow}{then}
925         u\_pt = u\_pt + 1
926         \textcolor{keyword}{read}(line(isu+8:),*) u\_lon(1:2,u\_pt), u\_lat(1:2,u\_pt), u\_width(u\_pt)
927         \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}
928           \textcolor{keywordflow}{if} (check\_360) \textcolor{keywordflow}{then}
929             \textcolor{keywordflow}{if} ((abs(u\_lon(1,u\_pt)) > len\_lon) .or. (abs(u\_lon(2,u\_pt)) > len\_lon)) &
930               \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-bounds "}//&
931                  \textcolor{stringliteral}{"u-longitude found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
932                  trim(filename))
933             \textcolor{keywordflow}{if} ((abs(u\_lat(1,u\_pt)) > len\_lat) .or. (abs(u\_lat(2,u\_pt)) > len\_lat)) &
934               \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-bounds "}//&
935                  \textcolor{stringliteral}{"u-latitude found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
936                  trim(filename))
937 \textcolor{keywordflow}{          endif}
938           \textcolor{keywordflow}{if} (u\_lat(1,u\_pt) > u\_lat(2,u\_pt)) &
939             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-order "}//&
940                \textcolor{stringliteral}{"u-face latitudes found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
941                trim(filename))
942           \textcolor{keywordflow}{if} (u\_lon(1,u\_pt) > u\_lon(2,u\_pt)) &
943             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-order "}//&
944                \textcolor{stringliteral}{"u-face longitudes found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
945                trim(filename))
946           \textcolor{keywordflow}{if} (u\_width(u\_pt) < 0.0) &
947             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Negative "}//&
948                \textcolor{stringliteral}{"u-width found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
949                trim(filename))
950 \textcolor{keywordflow}{        endif}
951       \textcolor{keywordflow}{elseif} (found\_v) \textcolor{keywordflow}{then}
952         v\_pt = v\_pt + 1
953         \textcolor{keyword}{read}(line(isv+8:),*) v\_lon(1:2,v\_pt), v\_lat(1:2,v\_pt), v\_width(v\_pt)
954         \textcolor{keywordflow}{if} (is\_root\_pe()) \textcolor{keywordflow}{then}
955           \textcolor{keywordflow}{if} (check\_360) \textcolor{keywordflow}{then}
956             \textcolor{keywordflow}{if} ((abs(v\_lon(1,v\_pt)) > len\_lon) .or. (abs(v\_lon(2,v\_pt)) > len\_lon)) &
957               \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-bounds "}//&
958                  \textcolor{stringliteral}{"v-longitude found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
959                  trim(filename))
960             \textcolor{keywordflow}{if} ((abs(v\_lat(1,v\_pt)) > len\_lat) .or. (abs(v\_lat(2,v\_pt)) > len\_lat)) &
961               \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-bounds "}//&
962                  \textcolor{stringliteral}{"v-latitude found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
963                  trim(filename))
964 \textcolor{keywordflow}{          endif}
965           \textcolor{keywordflow}{if} (v\_lat(1,v\_pt) > v\_lat(2,v\_pt)) &
966             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-order "}//&
967                \textcolor{stringliteral}{"v-face latitudes found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
968                trim(filename))
969           \textcolor{keywordflow}{if} (v\_lon(1,v\_pt) > v\_lon(2,v\_pt)) &
970             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Out-of-order "}//&
971                \textcolor{stringliteral}{"v-face longitudes found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
972                trim(filename))
973           \textcolor{keywordflow}{if} (v\_width(v\_pt) < 0.0) &
974             \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"reset\_face\_lengths\_list : Negative "}//&
975                \textcolor{stringliteral}{"v-width found when reading line "}//trim(line)//\textcolor{stringliteral}{" from file "}//&
976                trim(filename))
977 \textcolor{keywordflow}{        endif}
978 \textcolor{keywordflow}{      endif}
979 \textcolor{keywordflow}{    enddo}
980 
981     \textcolor{keyword}{deallocate}(lines)
982 \textcolor{keywordflow}{  endif}
983 
984   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
985     lat = g%geoLatCu(i,j) ; lon = g%geoLonCu(i,j)
986     \textcolor{keywordflow}{if} (check\_360) \textcolor{keywordflow}{then} ; lon\_p = lon+len\_lon ; lon\_m = lon-len\_lon
987     \textcolor{keywordflow}{else} ; lon\_p = lon ; lon\_m = lon ;\textcolor{keywordflow}{ endif}
988 
989     \textcolor{keywordflow}{do} npt=1,u\_pt
990       \textcolor{keywordflow}{if} (((lat >= u\_lat(1,npt)) .and. (lat <= u\_lat(2,npt))) .and. &
991           (((lon >= u\_lon(1,npt)) .and. (lon <= u\_lon(2,npt))) .or. &
992            ((lon\_p >= u\_lon(1,npt)) .and. (lon\_p <= u\_lon(2,npt))) .or. &
993            ((lon\_m >= u\_lon(1,npt)) .and. (lon\_m <= u\_lon(2,npt)))) ) \textcolor{keywordflow}{then}
994 
995         g%dy\_Cu(i,j) = g%mask2dCu(i,j) * m\_to\_l*min(l\_to\_m*g%dyCu(i,j), max(u\_width(npt), 0.0))
996         \textcolor{keywordflow}{if} (j>=g%jsc .and. j<=g%jec .and. i>=g%isc .and. i<=g%iec) \textcolor{keywordflow}{then} \textcolor{comment}{! Limit messages/checking to
       compute domain}
997           \textcolor{keywordflow}{if} ( g%mask2dCu(i,j) == 0.0 )  \textcolor{keywordflow}{then}
998             \textcolor{keyword}{write}(*,\textcolor{stringliteral}{'(A,2F8.2,A,4F8.2,A)'}) \textcolor{stringliteral}{"read\_face\_lengths\_list : G%mask2dCu=0 at "},lat,lon,\textcolor{stringliteral}{" ("},&
999                 u\_lat(1,npt), u\_lat(2,npt), u\_lon(1,npt), u\_lon(2,npt),\textcolor{stringliteral}{") so grid metric is unmodified."}
1000           \textcolor{keywordflow}{else}
1001             \textcolor{keyword}{write}(*,\textcolor{stringliteral}{'(A,2F8.2,A,4F8.2,A5,F9.2,A1)'}) &
1002                   \textcolor{stringliteral}{"read\_face\_lengths\_list : Modifying dy\_Cu gridpoint at "},lat,lon,\textcolor{stringliteral}{" ("},&
1003                   u\_lat(1,npt), u\_lat(2,npt), u\_lon(1,npt), u\_lon(2,npt),\textcolor{stringliteral}{") to "},l\_to\_m*g%dy\_Cu(i,j),\textcolor{stringliteral}{"m"}
1004 \textcolor{keywordflow}{          endif}
1005 \textcolor{keywordflow}{        endif}
1006 \textcolor{keywordflow}{      endif}
1007 \textcolor{keywordflow}{    enddo}
1008 
1009     g%areaCu(i,j) = g%dxCu(i,j) * g%dy\_Cu(i,j)
1010     g%IareaCu(i,j) = 0.0
1011     \textcolor{keywordflow}{if} (g%areaCu(i,j) > 0.0) g%IareaCu(i,j) = g%mask2dCu(i,j) / (g%areaCu(i,j))
1012 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1013 
1014   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
1015     lat = g%geoLatCv(i,j) ; lon = g%geoLonCv(i,j)
1016     \textcolor{keywordflow}{if} (check\_360) \textcolor{keywordflow}{then} ; lon\_p = lon+len\_lon ; lon\_m = lon-len\_lon
1017     \textcolor{keywordflow}{else} ; lon\_p = lon ; lon\_m = lon ;\textcolor{keywordflow}{ endif}
1018 
1019     \textcolor{keywordflow}{do} npt=1,v\_pt
1020       \textcolor{keywordflow}{if} (((lat >= v\_lat(1,npt)) .and. (lat <= v\_lat(2,npt))) .and. &
1021           (((lon >= v\_lon(1,npt)) .and. (lon <= v\_lon(2,npt))) .or. &
1022            ((lon\_p >= v\_lon(1,npt)) .and. (lon\_p <= v\_lon(2,npt))) .or. &
1023            ((lon\_m >= v\_lon(1,npt)) .and. (lon\_m <= v\_lon(2,npt)))) ) \textcolor{keywordflow}{then}
1024         g%dx\_Cv(i,j) = g%mask2dCv(i,j) * m\_to\_l*min(l\_to\_m*g%dxCv(i,j), max(v\_width(npt), 0.0))
1025         \textcolor{keywordflow}{if} (i>=g%isc .and. i<=g%iec .and. j>=g%jsc .and. j<=g%jec) \textcolor{keywordflow}{then} \textcolor{comment}{! Limit messages/checking to
       compute domain}
1026           \textcolor{keywordflow}{if} ( g%mask2dCv(i,j) == 0.0 )  \textcolor{keywordflow}{then}
1027             \textcolor{keyword}{write}(*,\textcolor{stringliteral}{'(A,2F8.2,A,4F8.2,A)'}) \textcolor{stringliteral}{"read\_face\_lengths\_list : G%mask2dCv=0 at "},lat,lon,\textcolor{stringliteral}{" ("},&
1028                   v\_lat(1,npt), v\_lat(2,npt), v\_lon(1,npt), v\_lon(2,npt),\textcolor{stringliteral}{") so grid metric is unmodified."}
1029           \textcolor{keywordflow}{else}
1030             \textcolor{keyword}{write}(*,\textcolor{stringliteral}{'(A,2F8.2,A,4F8.2,A5,F9.2,A1)'}) &
1031                   \textcolor{stringliteral}{"read\_face\_lengths\_list : Modifying dx\_Cv gridpoint at "},lat,lon,\textcolor{stringliteral}{" ("},&
1032                   v\_lat(1,npt), v\_lat(2,npt), v\_lon(1,npt), v\_lon(2,npt),\textcolor{stringliteral}{") to "},l\_to\_m*g%dx\_Cv(i,j),\textcolor{stringliteral}{"m"}
1033 \textcolor{keywordflow}{          endif}
1034 \textcolor{keywordflow}{        endif}
1035 \textcolor{keywordflow}{      endif}
1036 \textcolor{keywordflow}{    enddo}
1037 
1038     g%areaCv(i,j) = g%dyCv(i,j) * g%dx\_Cv(i,j)
1039     g%IareaCv(i,j) = 0.0
1040     \textcolor{keywordflow}{if} (g%areaCv(i,j) > 0.0) g%IareaCv(i,j) = g%mask2dCv(i,j) / (g%areaCv(i,j))
1041 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1042 
1043   \textcolor{keywordflow}{if} (num\_lines > 0) \textcolor{keywordflow}{then}
1044     \textcolor{keyword}{deallocate}(u\_lat) ; \textcolor{keyword}{deallocate}(u\_lon) ; \textcolor{keyword}{deallocate}(u\_width)
1045     \textcolor{keyword}{deallocate}(v\_lat) ; \textcolor{keyword}{deallocate}(v\_lon) ; \textcolor{keyword}{deallocate}(v\_width)
1046 \textcolor{keywordflow}{  endif}
1047 
1048   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_af506ce66cc9fdd478b4e2bd44e594f18}\label{namespacemom__shared__initialization_af506ce66cc9fdd478b4e2bd44e594f18}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!reset\+\_\+face\+\_\+lengths\+\_\+named@{reset\+\_\+face\+\_\+lengths\+\_\+named}}
\index{reset\+\_\+face\+\_\+lengths\+\_\+named@{reset\+\_\+face\+\_\+lengths\+\_\+named}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{reset\+\_\+face\+\_\+lengths\+\_\+named()}{reset\_face\_lengths\_named()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::reset\+\_\+face\+\_\+lengths\+\_\+named (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets the open face lengths at selected points to restrict passages to their observed widths based on a named set of sizes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em name} & The name for the set of face lengths. Only \char`\"{}global\+\_\+1deg\char`\"{} is currently implemented.\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 622 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
622   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The dynamic horizontal grid}
623   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
624   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: name\textcolor{comment}{ !< The name for the set of face lengths. Only "global\_1deg"}
625 \textcolor{comment}{                                                !! is currently implemented.}
626   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
627 
628   \textcolor{comment}{! Local variables}
629   \textcolor{keywordtype}{character(len=256)} :: mesg    \textcolor{comment}{! Message for error messages.}
630   \textcolor{keywordtype}{real} :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
631   \textcolor{keywordtype}{real} :: L\_to\_m  \textcolor{comment}{! A unit conversion factor [m L-1 ~> nondim]}
632   \textcolor{keywordtype}{real}    :: dx\_2 = -1.0, dy\_2 = -1.0
633   \textcolor{keywordtype}{real}    :: pi\_180
634   \textcolor{keywordtype}{integer} :: option = -1
635   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
636   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
637   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
638   pi\_180 = (4.0*atan(1.0))/180.0
639 
640   \textcolor{keywordflow}{select case} ( trim(name) )
641     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"global\_1deg"})    ; option = 1 ; dx\_2 = 0.5*1.0
642 \textcolor{keywordflow}{    case default} ; \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"reset\_face\_lengths\_named: "}//&
643       \textcolor{stringliteral}{"Unrecognized channel configuration name "}//trim(name))
644 \textcolor{keywordflow}{  end select}
645 
646   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us%m\_to\_L
647   l\_to\_m = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m = us%L\_to\_m
648 
649   \textcolor{keywordflow}{if} (option==1) \textcolor{keywordflow}{then} \textcolor{comment}{! 1-degree settings.}
650     \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb  \textcolor{comment}{! Change any u-face lengths within this loop.}
651       dy\_2 = dx\_2 * g%dyCu(i,j)*g%IdxCu(i,j) * cos(pi\_180 * g%geoLatCu(i,j))
652 
653       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-35.5) < dy\_2) .and. (g%geoLonCu(i,j) < -4.5) .and. &
654           (g%geoLonCu(i,j) > -6.5)) &
655         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*12000.0*m\_to\_l   \textcolor{comment}{! Gibraltar}
656 
657       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-12.5) < dy\_2) .and. (abs(g%geoLonCu(i,j)-43.0) < dx\_2)) &
658         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*10000.0*m\_to\_l   \textcolor{comment}{! Red Sea}
659 
660       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-40.5) < dy\_2) .and. (abs(g%geoLonCu(i,j)-26.0) < dx\_2)) &
661         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*5000.0*m\_to\_l   \textcolor{comment}{! Dardanelles}
662 
663       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-41.5) < dy\_2) .and. (abs(g%geoLonCu(i,j)+220.0) < dx\_2)) &
664         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*35000.0*m\_to\_l   \textcolor{comment}{! Tsugaru strait at 140.0e}
665 
666       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-45.5) < dy\_2) .and. (abs(g%geoLonCu(i,j)+217.5) < 0.9)) &
667         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*15000.0*m\_to\_l   \textcolor{comment}{! Betw Hokkaido and Sakhalin at 217&218 = 142e}
668 
669       \textcolor{comment}{! Greater care needs to be taken in the tripolar region.}
670       \textcolor{keywordflow}{if} ((abs(g%geoLatCu(i,j)-80.84) < 0.2) .and. (abs(g%geoLonCu(i,j)+64.9) < 0.8)) &
671         g%dy\_Cu(i,j) = g%mask2dCu(i,j)*38000.0*m\_to\_l   \textcolor{comment}{! Smith Sound in Canadian Arch - tripolar region}
672 
673 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
674 
675     \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied  \textcolor{comment}{! Change any v-face lengths within this loop.}
676       dy\_2 = dx\_2 * g%dyCv(i,j)*g%IdxCv(i,j) * cos(pi\_180 * g%geoLatCv(i,j))
677       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-41.0) < dy\_2) .and. (abs(g%geoLonCv(i,j)-28.5) < dx\_2)) &
678         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*2500.0*m\_to\_l   \textcolor{comment}{! Bosporus - should be 1000.0 m wide.}
679 
680       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-13.0) < dy\_2) .and. (abs(g%geoLonCv(i,j)-42.5) < dx\_2)) &
681         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*10000.0*m\_to\_l   \textcolor{comment}{! Red Sea}
682 
683       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)+2.8) < 0.8) .and. (abs(g%geoLonCv(i,j)+241.5) < dx\_2)) &
684         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*40000.0*m\_to\_l   \textcolor{comment}{! Makassar Straits at 241.5 W = 118.5 E}
685 
686       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-0.56) < 0.5) .and. (abs(g%geoLonCv(i,j)+240.5) < dx\_2)) &
687         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*80000.0*m\_to\_l   \textcolor{comment}{! entry to Makassar Straits at 240.5 W = 119.5 E}
688 
689       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-0.19) < 0.5) .and. (abs(g%geoLonCv(i,j)+230.5) < dx\_2)) &
690         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*25000.0*m\_to\_l   \textcolor{comment}{! Channel betw N Guinea and Halmahara 230.5 W =
       129.5 E}
691 
692       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-0.19) < 0.5) .and. (abs(g%geoLonCv(i,j)+229.5) < dx\_2)) &
693         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*25000.0*m\_to\_l   \textcolor{comment}{! Channel betw N Guinea and Halmahara 229.5 W =
       130.5 E}
694 
695       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-0.0) < 0.25) .and. (abs(g%geoLonCv(i,j)+228.5) < dx\_2)) &
696         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*25000.0*m\_to\_l   \textcolor{comment}{! Channel betw N Guinea and Halmahara 228.5 W =
       131.5 E}
697 
698       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)+8.5) < 0.5) .and. (abs(g%geoLonCv(i,j)+244.5) < dx\_2)) &
699         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*20000.0*m\_to\_l   \textcolor{comment}{! Lombok Straits at 244.5 W = 115.5 E}
700 
701       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)+8.5) < 0.5) .and. (abs(g%geoLonCv(i,j)+235.5) < dx\_2)) &
702         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*20000.0*m\_to\_l   \textcolor{comment}{! Timor Straits at 235.5 W = 124.5 E}
703 
704       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-52.5) < dy\_2) .and. (abs(g%geoLonCv(i,j)+218.5) < dx\_2)) &
705         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*2500.0*m\_to\_l    \textcolor{comment}{! Russia and Sakhalin Straits at 218.5 W = 141.5 E}
706 
707       \textcolor{comment}{! Greater care needs to be taken in the tripolar region.}
708       \textcolor{keywordflow}{if} ((abs(g%geoLatCv(i,j)-76.8) < 0.06) .and. (abs(g%geoLonCv(i,j)+88.7) < dx\_2)) &
709         g%dx\_Cv(i,j) = g%mask2dCv(i,j)*8400.0*m\_to\_l    \textcolor{comment}{! Jones Sound in Canadian Arch - tripolar region}
710 
711 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
712 \textcolor{keywordflow}{  endif}
713 
714   \textcolor{comment}{! These checks apply regardless of the chosen option.}
715 
716   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
717     \textcolor{keywordflow}{if} (l\_to\_m*g%dy\_Cu(i,j) > l\_to\_m*g%dyCu(i,j)) \textcolor{keywordflow}{then}
718       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("dy\_Cu of ",ES11.4," exceeds unrestricted width of ",ES11.4,&}
719 \textcolor{stringliteral}{}\textcolor{stringliteral}{                   &" by ",ES11.4," at lon/lat of ", ES11.4, ES11.4)'}) &
720                    l\_to\_m*g%dy\_Cu(i,j), l\_to\_m*g%dyCu(i,j), l\_to\_m*g%dy\_Cu(i,j)-l\_to\_m*g%dyCu(i,j), &
721                    g%geoLonCu(i,j), g%geoLatCu(i,j)
722       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"reset\_face\_lengths\_named "}//mesg)
723 \textcolor{keywordflow}{    endif}
724     g%areaCu(i,j) = g%dxCu(i,j) * g%dy\_Cu(i,j)
725     g%IareaCu(i,j) = 0.0
726     \textcolor{keywordflow}{if} (g%areaCu(i,j) > 0.0) g%IareaCu(i,j) = g%mask2dCu(i,j) / (g%areaCu(i,j))
727 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
728 
729   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
730     \textcolor{keywordflow}{if} (l\_to\_m*g%dx\_Cv(i,j) > l\_to\_m*g%dxCv(i,j)) \textcolor{keywordflow}{then}
731       \textcolor{keyword}{write}(mesg,\textcolor{stringliteral}{'("dx\_Cv of ",ES11.4," exceeds unrestricted width of ",ES11.4,&}
732 \textcolor{stringliteral}{}\textcolor{stringliteral}{                   &" by ",ES11.4, " at lon/lat of ", ES11.4, ES11.4)'}) &
733                    l\_to\_m*g%dx\_Cv(i,j), l\_to\_m*g%dxCv(i,j), l\_to\_m*g%dx\_Cv(i,j)-l\_to\_m*g%dxCv(i,j), &
734                    g%geoLonCv(i,j), g%geoLatCv(i,j)
735 
736       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"reset\_face\_lengths\_named "}//mesg)
737 \textcolor{keywordflow}{    endif}
738     g%areaCv(i,j) = g%dyCv(i,j) * g%dx\_Cv(i,j)
739     g%IareaCv(i,j) = 0.0
740     \textcolor{keywordflow}{if} (g%areaCv(i,j) > 0.0) g%IareaCv(i,j) = g%mask2dCv(i,j) / (g%areaCv(i,j))
741 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
742 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a330014f05a823d5434ad0156d361b6ff}\label{namespacemom__shared__initialization_a330014f05a823d5434ad0156d361b6ff}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!set\+\_\+rotation\+\_\+beta\+\_\+plane@{set\+\_\+rotation\+\_\+beta\+\_\+plane}}
\index{set\+\_\+rotation\+\_\+beta\+\_\+plane@{set\+\_\+rotation\+\_\+beta\+\_\+plane}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{set\+\_\+rotation\+\_\+beta\+\_\+plane()}{set\_rotation\_beta\_plane()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::set\+\_\+rotation\+\_\+beta\+\_\+plane (\begin{DoxyParamCaption}\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(out)}]{f,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets up the Coriolis parameter for a beta-\/plane or f-\/plane. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt out}  & {\em f} & Coriolis parameter (vertical component) \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 497 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
497   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The dynamic horizontal grid}
498   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
499                           \textcolor{keywordtype}{intent(out)} :: f\textcolor{comment}{  !< Coriolis parameter (vertical component) [T-1 ~> s-1]}
500   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
501   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
502 
503 \textcolor{comment}{! This subroutine sets up the Coriolis parameter for a beta-plane}
504   \textcolor{keywordtype}{integer} :: I, J
505   \textcolor{keywordtype}{real}    :: f\_0    \textcolor{comment}{! The reference value of the Coriolis parameter [T-1 ~> s-1]}
506   \textcolor{keywordtype}{real}    :: beta   \textcolor{comment}{! The meridional gradient of the Coriolis parameter [T-1 m-1 ~> s-1 m-1]}
507   \textcolor{keywordtype}{real}    :: y\_scl, Rad\_Earth
508   \textcolor{keywordtype}{real}    :: T\_to\_s \textcolor{comment}{! A time unit conversion factor}
509   \textcolor{keywordtype}{real}    :: PI
510   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"set\_rotation\_beta\_plane"} \textcolor{comment}{! This subroutine's name.}
511   \textcolor{keywordtype}{character(len=200)} :: axis\_units
512 
513   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
514 
515   t\_to\_s = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) t\_to\_s = us%T\_to\_s
516 
517   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"F\_0"}, f\_0, &
518                  \textcolor{stringliteral}{"The reference value of the Coriolis parameter with the "}//&
519                  \textcolor{stringliteral}{"betaplane option."}, units=\textcolor{stringliteral}{"s-1"}, default=0.0, scale=t\_to\_s)
520   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BETA"}, beta, &
521                  \textcolor{stringliteral}{"The northward gradient of the Coriolis parameter with "}//&
522                  \textcolor{stringliteral}{"the betaplane option."}, units=\textcolor{stringliteral}{"m-1 s-1"}, default=0.0, scale=t\_to\_s)
523   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"AXIS\_UNITS"}, axis\_units, default=\textcolor{stringliteral}{"degrees"})
524 
525   pi = 4.0*atan(1.0)
526   \textcolor{keywordflow}{select case} (axis\_units(1:1))
527     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"d"})
528       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RAD\_EARTH"}, rad\_earth, &
529                    \textcolor{stringliteral}{"The radius of the Earth."}, units=\textcolor{stringliteral}{"m"}, default=6.378e6)
530       y\_scl = rad\_earth/pi
531     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"k"}); y\_scl = 1.e3
532     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"m"}); y\_scl = 1.
533     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"c"}); y\_scl = 1.e-2
534 \textcolor{keywordflow}{    case default} ; \textcolor{keyword}{call }mom\_error(fatal, &
535       \textcolor{stringliteral}{" set\_rotation\_beta\_plane: unknown AXIS\_UNITS = "}//trim(axis\_units))
536 \textcolor{keywordflow}{  end select}
537 
538   \textcolor{keywordflow}{do} i=g%IsdB,g%IedB ; \textcolor{keywordflow}{do} j=g%JsdB,g%JedB
539     f(i,j) = f\_0 + beta * ( g%geoLatBu(i,j) * y\_scl )
540 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
541 
542   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a6aa6b883534fee4616137b7174414b8e}\label{namespacemom__shared__initialization_a6aa6b883534fee4616137b7174414b8e}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!set\+\_\+rotation\+\_\+planetary@{set\+\_\+rotation\+\_\+planetary}}
\index{set\+\_\+rotation\+\_\+planetary@{set\+\_\+rotation\+\_\+planetary}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{set\+\_\+rotation\+\_\+planetary()}{set\_rotation\_planetary()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::set\+\_\+rotation\+\_\+planetary (\begin{DoxyParamCaption}\item[{real, dimension(g\%isdb\+:g\%iedb,g\%jsdb\+:g\%jedb), intent(out)}]{f,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



This subroutine sets up the Coriolis parameter for a sphere. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt out}  & {\em f} & Coriolis parameter (vertical component) \mbox{[}T-\/1 $\sim$$>$ s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 464 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
464   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{  !< The dynamic horizontal grid}
465   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)}, &
466                           \textcolor{keywordtype}{intent(out)} :: f\textcolor{comment}{  !< Coriolis parameter (vertical component) [T-1 ~> s-1]}
467   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
468   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
469 
470 \textcolor{comment}{! This subroutine sets up the Coriolis parameter for a sphere}
471   \textcolor{keywordtype}{character(len=30)} :: mdl = \textcolor{stringliteral}{"set\_rotation\_planetary"} \textcolor{comment}{! This subroutine's name.}
472   \textcolor{keywordtype}{integer} :: I, J
473   \textcolor{keywordtype}{real}    :: PI
474   \textcolor{keywordtype}{real}    :: omega  \textcolor{comment}{! The planetary rotation rate [T-1 ~> s-1]}
475   \textcolor{keywordtype}{real}    :: T\_to\_s \textcolor{comment}{! A time unit conversion factor}
476 
477   \textcolor{keyword}{call }calltree\_enter(trim(mdl)//\textcolor{stringliteral}{"(), MOM\_shared\_initialization.F90"})
478 
479   t\_to\_s = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) t\_to\_s = us%T\_to\_s
480 
481   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"set\_rotation\_planetary"}, \textcolor{stringliteral}{"OMEGA"}, omega, &
482                  \textcolor{stringliteral}{"The rotation rate of the earth."}, units=\textcolor{stringliteral}{"s-1"}, &
483                  default=7.2921e-5, scale=t\_to\_s)
484   pi = 4.0*atan(1.0)
485 
486   \textcolor{keywordflow}{do} i=g%IsdB,g%IedB ; \textcolor{keywordflow}{do} j=g%JsdB,g%JedB
487     f(i,j) = ( 2.0 * omega ) * sin( ( pi * g%geoLatBu(i,j) ) / 180.)
488 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
489 
490   \textcolor{keyword}{call }calltree\_leave(trim(mdl)//\textcolor{stringliteral}{'()'})
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_ab4e226886998bcc8a43011bd8ed4dd29}\label{namespacemom__shared__initialization_ab4e226886998bcc8a43011bd8ed4dd29}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!set\+\_\+velocity\+\_\+depth\+\_\+max@{set\+\_\+velocity\+\_\+depth\+\_\+max}}
\index{set\+\_\+velocity\+\_\+depth\+\_\+max@{set\+\_\+velocity\+\_\+depth\+\_\+max}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{set\+\_\+velocity\+\_\+depth\+\_\+max()}{set\_velocity\_depth\_max()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::set\+\_\+velocity\+\_\+depth\+\_\+max (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G }\end{DoxyParamCaption})}



Set the bathymetry at velocity points to be the maximum of the depths at the neighoring tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid \\
\hline
\end{DoxyParams}


Definition at line 1109 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
1109   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{   !< The dynamic horizontal grid}
1110   \textcolor{comment}{! This subroutine sets the 4 bottom depths at velocity points to be the}
1111   \textcolor{comment}{! maximum of the adjacent depths.}
1112   \textcolor{keywordtype}{integer} :: i, j
1113 
1114   \textcolor{keywordflow}{do} i=g%isd,g%ied-1 ; \textcolor{keywordflow}{do} j=g%jsd,g%jed
1115     g%Dblock\_u(i,j) = g%mask2dCu(i,j) * max(g%bathyT(i,j), g%bathyT(i+1,j))
1116     g%Dopen\_u(i,j) = g%Dblock\_u(i,j)
1117 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1118   \textcolor{keywordflow}{do} i=g%isd,g%ied ; \textcolor{keywordflow}{do} j=g%jsd,g%jed-1
1119     g%Dblock\_v(i,j) = g%mask2dCv(i,j) * max(g%bathyT(i,j), g%bathyT(i,j+1))
1120     g%Dopen\_v(i,j) = g%Dblock\_v(i,j)
1121 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a4db4d57d710d61a5e910b437f9ab1455}\label{namespacemom__shared__initialization_a4db4d57d710d61a5e910b437f9ab1455}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!set\+\_\+velocity\+\_\+depth\+\_\+min@{set\+\_\+velocity\+\_\+depth\+\_\+min}}
\index{set\+\_\+velocity\+\_\+depth\+\_\+min@{set\+\_\+velocity\+\_\+depth\+\_\+min}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{set\+\_\+velocity\+\_\+depth\+\_\+min()}{set\_velocity\_depth\_min()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::set\+\_\+velocity\+\_\+depth\+\_\+min (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G }\end{DoxyParamCaption})}



Set the bathymetry at velocity points to be the minimum of the depths at the neighoring tracer points. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid \\
\hline
\end{DoxyParams}


Definition at line 1129 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
1129   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The dynamic horizontal grid}
1130   \textcolor{comment}{! This subroutine sets the 4 bottom depths at velocity points to be the}
1131   \textcolor{comment}{! minimum of the adjacent depths.}
1132   \textcolor{keywordtype}{integer} :: i, j
1133 
1134   \textcolor{keywordflow}{do} i=g%isd,g%ied-1 ; \textcolor{keywordflow}{do} j=g%jsd,g%jed
1135     g%Dblock\_u(i,j) = g%mask2dCu(i,j) * min(g%bathyT(i,j), g%bathyT(i+1,j))
1136     g%Dopen\_u(i,j) = g%Dblock\_u(i,j)
1137 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1138   \textcolor{keywordflow}{do} i=g%isd,g%ied ; \textcolor{keywordflow}{do} j=g%jsd,g%jed-1
1139     g%Dblock\_v(i,j) = g%mask2dCv(i,j) * min(g%bathyT(i,j), g%bathyT(i,j+1))
1140     g%Dopen\_v(i,j) = g%Dblock\_v(i,j)
1141 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__shared__initialization_a4375db47a43535f8f2eecd5992a788ea}\label{namespacemom__shared__initialization_a4375db47a43535f8f2eecd5992a788ea}} 
\index{mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}!write\+\_\+ocean\+\_\+geometry\+\_\+file@{write\+\_\+ocean\+\_\+geometry\+\_\+file}}
\index{write\+\_\+ocean\+\_\+geometry\+\_\+file@{write\+\_\+ocean\+\_\+geometry\+\_\+file}!mom\+\_\+shared\+\_\+initialization@{mom\+\_\+shared\+\_\+initialization}}
\subsubsection{\texorpdfstring{write\+\_\+ocean\+\_\+geometry\+\_\+file()}{write\_ocean\_geometry\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+shared\+\_\+initialization\+::write\+\_\+ocean\+\_\+geometry\+\_\+file (\begin{DoxyParamCaption}\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{character(len=$\ast$), intent(in)}]{directory,  }\item[{character(len=$\ast$), intent(in), optional}]{geom\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



Write out a file describing the topography, Coriolis parameter, grid locations and various other fixed fields from the grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file structure\\
\hline
\mbox{\tt in}  & {\em directory} & The directory into which to place the geometry file.\\
\hline
\mbox{\tt in}  & {\em geom\+\_\+file} & If present, the name of the geometry file (otherwise the file is \char`\"{}ocean\+\_\+geometry\char`\"{})\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 1178 of file M\+O\+M\+\_\+shared\+\_\+initialization.\+F90.


\begin{DoxyCode}
1178   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),       \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{         !< The dynamic horizontal grid}
1179   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}
1180   \textcolor{keywordtype}{character(len=*)},             \textcolor{keywordtype}{intent(in)}    :: directory\textcolor{comment}{ !< The directory into which to place the
       geometry file.}
1181   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: geom\_file\textcolor{comment}{ !< If present, the name of the geometry file}
1182 \textcolor{comment}{                                                           !! (otherwise the file is "ocean\_geometry")}
1183   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{        !< A dimensional unit scaling type}
1184 
1185   \textcolor{comment}{! Local variables.}
1186   \textcolor{keywordtype}{character(len=240)} :: filepath
1187   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"write\_ocean\_geometry\_file"}
1188   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: nFlds=23
1189   \textcolor{keywordtype}{type}(vardesc) :: vars(nFlds)
1190   \textcolor{keywordtype}{type}(fieldtype) :: fields(nFlds)
1191   \textcolor{keywordtype}{real} :: Z\_to\_m\_scale \textcolor{comment}{! A unit conversion factor from Z to m.}
1192   \textcolor{keywordtype}{real} :: s\_to\_T\_scale \textcolor{comment}{! A unit conversion factor from T-1 to s-1.}
1193   \textcolor{keywordtype}{real} :: L\_to\_m\_scale \textcolor{comment}{! A unit conversion factor from L to m.}
1194   \textcolor{keywordtype}{integer} :: unit
1195   \textcolor{keywordtype}{integer} :: file\_threading
1196   \textcolor{keywordtype}{integer} :: nFlds\_used
1197   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq
1198   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
1199   \textcolor{keywordtype}{logical} :: multiple\_files
1200   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd :G%ied ,G%jsd :G%jed )} :: out\_h
1201   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%JsdB:G%JedB)} :: out\_q
1202   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%IsdB:G%IedB,G%jsd :G%jed )} :: out\_u
1203   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(G%isd :G%ied ,G%JsdB:G%JedB)} :: out\_v
1204 
1205   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{'write\_ocean\_geometry\_file()'})
1206 
1207   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
1208   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
1209   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
1210   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
1211 
1212   z\_to\_m\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) z\_to\_m\_scale = us%Z\_to\_m
1213   s\_to\_t\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) s\_to\_t\_scale = us%s\_to\_T
1214   l\_to\_m\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m\_scale = us%L\_to\_m
1215 
1216 \textcolor{comment}{!   vardesc is a structure defined in MOM\_io.F90.  The elements of}
1217 \textcolor{comment}{! this structure, in order, are:}
1218 \textcolor{comment}{! (1) the variable name for the NetCDF file}
1219 \textcolor{comment}{! (2) the variable's long name}
1220 \textcolor{comment}{! (3) a character indicating the  horizontal grid, which may be '1' (column),}
1221 \textcolor{comment}{!     'h', 'q', 'u', or 'v', for the corresponding C-grid variable}
1222 \textcolor{comment}{! (4) a character indicating the vertical grid, which may be 'L' (layer),}
1223 \textcolor{comment}{!     'i' (interface), or '1' (no vertical location)}
1224 \textcolor{comment}{! (5) a character indicating the time levels of the field, which may be}
1225 \textcolor{comment}{!    's' (snap-shot), 'p' (periodic), or '1' (no time variation)}
1226 \textcolor{comment}{! (6) the variable's units}
1227   vars(1) = var\_desc(\textcolor{stringliteral}{"geolatb"},\textcolor{stringliteral}{"degree"},\textcolor{stringliteral}{"latitude at corner (Bu) points"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1228   vars(2) = var\_desc(\textcolor{stringliteral}{"geolonb"},\textcolor{stringliteral}{"degree"},\textcolor{stringliteral}{"longitude at corner (Bu) points"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1229   vars(3) = var\_desc(\textcolor{stringliteral}{"geolat"},\textcolor{stringliteral}{"degree"}, \textcolor{stringliteral}{"latitude at tracer (T) points"}, \textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1230   vars(4) = var\_desc(\textcolor{stringliteral}{"geolon"},\textcolor{stringliteral}{"degree"},\textcolor{stringliteral}{"longitude at tracer (T) points"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1231   vars(5) = var\_desc(\textcolor{stringliteral}{"D"},\textcolor{stringliteral}{"meter"},\textcolor{stringliteral}{"Basin Depth"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1232   vars(6) = var\_desc(\textcolor{stringliteral}{"f"},\textcolor{stringliteral}{"s-1"},\textcolor{stringliteral}{"Coriolis Parameter"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1233   vars(7) = var\_desc(\textcolor{stringliteral}{"dxCv"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Zonal grid spacing at v points"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1234   vars(8) = var\_desc(\textcolor{stringliteral}{"dyCu"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Meridional grid spacing at u points"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1235   vars(9) = var\_desc(\textcolor{stringliteral}{"dxCu"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Zonal grid spacing at u points"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1236   vars(10)= var\_desc(\textcolor{stringliteral}{"dyCv"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Meridional grid spacing at v points"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1237   vars(11)= var\_desc(\textcolor{stringliteral}{"dxT"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Zonal grid spacing at h points"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1238   vars(12)= var\_desc(\textcolor{stringliteral}{"dyT"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Meridional grid spacing at h points"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1239   vars(13)= var\_desc(\textcolor{stringliteral}{"dxBu"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Zonal grid spacing at q points"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1240   vars(14)= var\_desc(\textcolor{stringliteral}{"dyBu"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Meridional grid spacing at q points"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1241   vars(15)= var\_desc(\textcolor{stringliteral}{"Ah"},\textcolor{stringliteral}{"m2"},\textcolor{stringliteral}{"Area of h cells"},\textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1242   vars(16)= var\_desc(\textcolor{stringliteral}{"Aq"},\textcolor{stringliteral}{"m2"},\textcolor{stringliteral}{"Area of q cells"},\textcolor{stringliteral}{'q'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1243 
1244   vars(17)= var\_desc(\textcolor{stringliteral}{"dxCvo"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Open zonal grid spacing at v points"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1245   vars(18)= var\_desc(\textcolor{stringliteral}{"dyCuo"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Open meridional grid spacing at u points"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1246   vars(19)= var\_desc(\textcolor{stringliteral}{"wet"}, \textcolor{stringliteral}{"nondim"}, \textcolor{stringliteral}{"land or ocean?"}, \textcolor{stringliteral}{'h'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1247 
1248   vars(20) = var\_desc(\textcolor{stringliteral}{"Dblock\_u"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Blocked depth at u points"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1249   vars(21) = var\_desc(\textcolor{stringliteral}{"Dopen\_u"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Open depth at u points"},\textcolor{stringliteral}{'u'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1250   vars(22) = var\_desc(\textcolor{stringliteral}{"Dblock\_v"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Blocked depth at v points"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1251   vars(23) = var\_desc(\textcolor{stringliteral}{"Dopen\_v"},\textcolor{stringliteral}{"m"},\textcolor{stringliteral}{"Open depth at v points"},\textcolor{stringliteral}{'v'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'1'})
1252 
1253 
1254   nflds\_used = 19 ; \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) nflds\_used = 23
1255 
1256   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(geom\_file)) \textcolor{keywordflow}{then}
1257     filepath = trim(directory) // trim(geom\_file)
1258   \textcolor{keywordflow}{else}
1259     filepath = trim(directory) // \textcolor{stringliteral}{"ocean\_geometry"}
1260 \textcolor{keywordflow}{  endif}
1261 
1262   out\_h(:,:) = 0.0
1263   out\_u(:,:) = 0.0
1264   out\_v(:,:) = 0.0
1265   out\_q(:,:) = 0.0
1266 
1267   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PARALLEL\_RESTARTFILES"}, multiple\_files, &
1268                  \textcolor{stringliteral}{"If true, each processor writes its own restart file, "}//&
1269                  \textcolor{stringliteral}{"otherwise a single restart file is generated"}, &
1270                  default=.false.)
1271   file\_threading = single\_file
1272   \textcolor{keywordflow}{if} (multiple\_files) file\_threading = multiple
1273 
1274   \textcolor{keyword}{call }create\_file(unit, trim(filepath), vars, nflds\_used, fields, &
1275                    file\_threading, dg=g)
1276 
1277   \textcolor{keywordflow}{do} j=jsq,jeq; \textcolor{keywordflow}{do} i=isq,ieq; out\_q(i,j) = g%geoLatBu(i,j);\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1278   \textcolor{keyword}{call }write\_field(unit, fields(1), g%Domain%mpp\_domain, out\_q)
1279   \textcolor{keywordflow}{do} j=jsq,jeq; \textcolor{keywordflow}{do} i=isq,ieq; out\_q(i,j) = g%geoLonBu(i,j);\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1280   \textcolor{keyword}{call }write\_field(unit, fields(2), g%Domain%mpp\_domain, out\_q)
1281   \textcolor{keyword}{call }write\_field(unit, fields(3), g%Domain%mpp\_domain, g%geoLatT)
1282   \textcolor{keyword}{call }write\_field(unit, fields(4), g%Domain%mpp\_domain, g%geoLonT)
1283 
1284   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; out\_h(i,j) = z\_to\_m\_scale*g%bathyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1285   \textcolor{keyword}{call }write\_field(unit, fields(5), g%Domain%mpp\_domain, out\_h)
1286   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_q(i,j) = s\_to\_t\_scale*g%CoriolisBu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1287   \textcolor{keyword}{call }write\_field(unit, fields(6), g%Domain%mpp\_domain, out\_q)
1288 
1289   \textcolor{comment}{!   I think that all of these copies are holdovers from a much earlier}
1290   \textcolor{comment}{! ancestor code in which many of the metrics were macros that could have}
1291   \textcolor{comment}{! had reduced dimensions, and that they are no longer needed in MOM6. -RWH}
1292   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie ; out\_v(i,j) = l\_to\_m\_scale*g%dxCv(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1293   \textcolor{keyword}{call }write\_field(unit, fields(7), g%Domain%mpp\_domain, out\_v)
1294   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_u(i,j) = l\_to\_m\_scale*g%dyCu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1295   \textcolor{keyword}{call }write\_field(unit, fields(8), g%Domain%mpp\_domain, out\_u)
1296 
1297   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_u(i,j) = l\_to\_m\_scale*g%dxCu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1298   \textcolor{keyword}{call }write\_field(unit, fields(9), g%Domain%mpp\_domain, out\_u)
1299   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie ; out\_v(i,j) = l\_to\_m\_scale*g%dyCv(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1300   \textcolor{keyword}{call }write\_field(unit, fields(10), g%Domain%mpp\_domain, out\_v)
1301 
1302   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; out\_h(i,j) = l\_to\_m\_scale*g%dxT(i,j);\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1303   \textcolor{keyword}{call }write\_field(unit, fields(11), g%Domain%mpp\_domain, out\_h)
1304   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; out\_h(i,j) = l\_to\_m\_scale*g%dyT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1305   \textcolor{keyword}{call }write\_field(unit, fields(12), g%Domain%mpp\_domain, out\_h)
1306 
1307   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_q(i,j) = l\_to\_m\_scale*g%dxBu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1308   \textcolor{keyword}{call }write\_field(unit, fields(13), g%Domain%mpp\_domain, out\_q)
1309   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_q(i,j) = l\_to\_m\_scale*g%dyBu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1310   \textcolor{keyword}{call }write\_field(unit, fields(14), g%Domain%mpp\_domain, out\_q)
1311 
1312   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; out\_h(i,j) = g%areaT(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1313   \textcolor{keyword}{call }write\_field(unit, fields(15), g%Domain%mpp\_domain, out\_h)
1314   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_q(i,j) = g%areaBu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1315   \textcolor{keyword}{call }write\_field(unit, fields(16), g%Domain%mpp\_domain, out\_q)
1316 
1317   \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie ; out\_v(i,j) = l\_to\_m\_scale*g%dx\_Cv(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1318   \textcolor{keyword}{call }write\_field(unit, fields(17), g%Domain%mpp\_domain, out\_v)
1319   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_u(i,j) = l\_to\_m\_scale*g%dy\_Cu(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1320   \textcolor{keyword}{call }write\_field(unit, fields(18), g%Domain%mpp\_domain, out\_u)
1321   \textcolor{keyword}{call }write\_field(unit, fields(19), g%Domain%mpp\_domain, g%mask2dT)
1322 
1323   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then}
1324     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_u(i,j) = z\_to\_m\_scale*g%Dblock\_u(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1325     \textcolor{keyword}{call }write\_field(unit, fields(20), g%Domain%mpp\_domain, out\_u)
1326     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq ; out\_u(i,j) = z\_to\_m\_scale*g%Dopen\_u(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1327     \textcolor{keyword}{call }write\_field(unit, fields(21), g%Domain%mpp\_domain, out\_u)
1328     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie ; out\_v(i,j) = z\_to\_m\_scale*g%Dblock\_v(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1329     \textcolor{keyword}{call }write\_field(unit, fields(22), g%Domain%mpp\_domain, out\_v)
1330     \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie ; out\_v(i,j) = z\_to\_m\_scale*g%Dopen\_v(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
1331     \textcolor{keyword}{call }write\_field(unit, fields(23), g%Domain%mpp\_domain, out\_v)
1332 \textcolor{keywordflow}{  endif}
1333 
1334   \textcolor{keyword}{call }close\_file(unit)
1335 
1336   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{'write\_ocean\_geometry\_file()'})
\end{DoxyCode}
