\hypertarget{namespacemom__dyn__horgrid}{}\section{mom\+\_\+dyn\+\_\+horgrid Module Reference}
\label{namespacemom__dyn__horgrid}\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}


\subsection{Detailed Description}
Contains a shareable dynamic type for describing horizontal grids and metric data and utilty routines that work on this type. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Describes the horizontal ocean grid with only dynamic memory arrays. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__dyn__horgrid_a6dd89718602439a6bca59608e0f7e9f5}{create\+\_\+dyn\+\_\+horgrid}} (G, HI, bathymetry\+\_\+at\+\_\+vel)
\begin{DoxyCompactList}\small\item\em Allocate memory used by the \mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}} and related structures. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dyn__horgrid_a4c2c545c65e12084cd863f0cade973f2}{rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry}} (G, m\+\_\+in\+\_\+new\+\_\+units)
\begin{DoxyCompactList}\small\item\em rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry permits a change in the internal units for the bathymetry on the grid, both rescaling the depths and recording the new internal depth units. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dyn__horgrid_a26c1389a380922c7c5d946cff3a9b11a}{set\+\_\+derived\+\_\+dyn\+\_\+horgrid}} (G, US)
\begin{DoxyCompactList}\small\item\em set\+\_\+derived\+\_\+dyn\+\_\+horgrid calculates metric terms that are derived from other metrics. \end{DoxyCompactList}\item 
real function \mbox{\hyperlink{namespacemom__dyn__horgrid_aa6579f50769698067defbc3c676e0191}{adcroft\+\_\+reciprocal}} (val)
\begin{DoxyCompactList}\small\item\em Adcroft\+\_\+reciprocal(x) = 1/x for $\vert$x$\vert$$>$0 or 0 for x=0. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__dyn__horgrid_a23c063bf0f2d5e5e96569a6bc5f8f382}{destroy\+\_\+dyn\+\_\+horgrid}} (G)
\begin{DoxyCompactList}\small\item\em Release memory used by the \mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}} and related structures. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__dyn__horgrid_aa6579f50769698067defbc3c676e0191}\label{namespacemom__dyn__horgrid_aa6579f50769698067defbc3c676e0191}} 
\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}!adcroft\+\_\+reciprocal@{adcroft\+\_\+reciprocal}}
\index{adcroft\+\_\+reciprocal@{adcroft\+\_\+reciprocal}!mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}
\subsubsection{\texorpdfstring{adcroft\+\_\+reciprocal()}{adcroft\_reciprocal()}}
{\footnotesize\ttfamily real function mom\+\_\+dyn\+\_\+horgrid\+::adcroft\+\_\+reciprocal (\begin{DoxyParamCaption}\item[{real, intent(in)}]{val }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Adcroft\+\_\+reciprocal(x) = 1/x for $\vert$x$\vert$$>$0 or 0 for x=0. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em val} & The value being inverted.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The Adcroft reciprocal of val. 
\end{DoxyReturn}


Definition at line 368 of file M\+O\+M\+\_\+dyn\+\_\+horgrid.\+F90.


\begin{DoxyCode}
368   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: val\textcolor{comment}{  !< The value being inverted.}
369   \textcolor{keywordtype}{real} :: I\_val\textcolor{comment}{            !< The Adcroft reciprocal of val.}
370 
371   i\_val = 0.0 ; \textcolor{keywordflow}{if} (val /= 0.0) i\_val = 1.0/val
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dyn__horgrid_a6dd89718602439a6bca59608e0f7e9f5}\label{namespacemom__dyn__horgrid_a6dd89718602439a6bca59608e0f7e9f5}} 
\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}!create\+\_\+dyn\+\_\+horgrid@{create\+\_\+dyn\+\_\+horgrid}}
\index{create\+\_\+dyn\+\_\+horgrid@{create\+\_\+dyn\+\_\+horgrid}!mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}
\subsubsection{\texorpdfstring{create\+\_\+dyn\+\_\+horgrid()}{create\_dyn\_horgrid()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dyn\+\_\+horgrid\+::create\+\_\+dyn\+\_\+horgrid (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout), pointer}]{G,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in)}]{HI,  }\item[{logical, intent(in), optional}]{bathymetry\+\_\+at\+\_\+vel }\end{DoxyParamCaption})}



Allocate memory used by the \mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}} and related structures. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & A pointer to the dynamic horizontal grid type\\
\hline
\mbox{\tt in}  & {\em hi} & A hor\+\_\+index\+\_\+type for array extents\\
\hline
\mbox{\tt in}  & {\em bathymetry\+\_\+at\+\_\+vel} & If true, there are separate values for the basin depths at velocity points. Otherwise the effects of topography are entirely determined from thickness points. \\
\hline
\end{DoxyParams}


Definition at line 176 of file M\+O\+M\+\_\+dyn\+\_\+horgrid.\+F90.


\begin{DoxyCode}
176   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< A pointer to the dynamic horizontal grid type}
177   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{ !< A hor\_index\_type for array extents}
178   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: bathymetry\_at\_vel\textcolor{comment}{ !< If true, there are}
179 \textcolor{comment}{                             !! separate values for the basin depths at velocity}
180 \textcolor{comment}{                             !! points.  Otherwise the effects of topography are}
181 \textcolor{comment}{                             !! entirely determined from thickness points.}
182   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isg, ieg, jsg, jeg
183 
184   \textcolor{comment}{! This subroutine allocates the lateral elements of the dyn\_horgrid\_type that}
185   \textcolor{comment}{! are always used and zeros them out.}
186 
187   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(g)) \textcolor{keywordflow}{then}
188     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"create\_dyn\_horgrid called with an associated horgrid\_type."})
189   \textcolor{keywordflow}{else}
190     \textcolor{keyword}{allocate}(g)
191 \textcolor{keywordflow}{  endif}
192 
193   g%HI = hi
194 
195   g%isc = hi%isc ; g%iec = hi%iec ; g%jsc = hi%jsc ; g%jec = hi%jec
196   g%isd = hi%isd ; g%ied = hi%ied ; g%jsd = hi%jsd ; g%jed = hi%jed
197   g%isg = hi%isg ; g%ieg = hi%ieg ; g%jsg = hi%jsg ; g%jeg = hi%jeg
198 
199   g%IscB = hi%IscB ; g%IecB = hi%IecB ; g%JscB = hi%JscB ; g%JecB = hi%JecB
200   g%IsdB = hi%IsdB ; g%IedB = hi%IedB ; g%JsdB = hi%JsdB ; g%JedB = hi%JedB
201   g%IsgB = hi%IsgB ; g%IegB = hi%IegB ; g%JsgB = hi%JsgB ; g%JegB = hi%JegB
202 
203   g%idg\_offset = hi%idg\_offset ; g%jdg\_offset = hi%jdg\_offset
204   g%isd\_global = g%isd + hi%idg\_offset ; g%jsd\_global = g%jsd + hi%jdg\_offset
205   g%symmetric = hi%symmetric
206 
207   g%bathymetry\_at\_vel = .false.
208   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(bathymetry\_at\_vel)) g%bathymetry\_at\_vel = bathymetry\_at\_vel
209 
210   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
211   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
212   isg = g%isg ; ieg = g%ieg ; jsg = g%jsg ; jeg = g%jeg
213 
214   \textcolor{keyword}{allocate}(g%dxT(isd:ied,jsd:jed))       ; g%dxT(:,:) = 0.0
215   \textcolor{keyword}{allocate}(g%dxCu(isdb:iedb,jsd:jed))    ; g%dxCu(:,:) = 0.0
216   \textcolor{keyword}{allocate}(g%dxCv(isd:ied,jsdb:jedb))    ; g%dxCv(:,:) = 0.0
217   \textcolor{keyword}{allocate}(g%dxBu(isdb:iedb,jsdb:jedb))  ; g%dxBu(:,:) = 0.0
218   \textcolor{keyword}{allocate}(g%IdxT(isd:ied,jsd:jed))      ; g%IdxT(:,:) = 0.0
219   \textcolor{keyword}{allocate}(g%IdxCu(isdb:iedb,jsd:jed))   ; g%IdxCu(:,:) = 0.0
220   \textcolor{keyword}{allocate}(g%IdxCv(isd:ied,jsdb:jedb))   ; g%IdxCv(:,:) = 0.0
221   \textcolor{keyword}{allocate}(g%IdxBu(isdb:iedb,jsdb:jedb)) ; g%IdxBu(:,:) = 0.0
222 
223   \textcolor{keyword}{allocate}(g%dyT(isd:ied,jsd:jed))       ; g%dyT(:,:) = 0.0
224   \textcolor{keyword}{allocate}(g%dyCu(isdb:iedb,jsd:jed))    ; g%dyCu(:,:) = 0.0
225   \textcolor{keyword}{allocate}(g%dyCv(isd:ied,jsdb:jedb))    ; g%dyCv(:,:) = 0.0
226   \textcolor{keyword}{allocate}(g%dyBu(isdb:iedb,jsdb:jedb))  ; g%dyBu(:,:) = 0.0
227   \textcolor{keyword}{allocate}(g%IdyT(isd:ied,jsd:jed))      ; g%IdyT(:,:) = 0.0
228   \textcolor{keyword}{allocate}(g%IdyCu(isdb:iedb,jsd:jed))   ; g%IdyCu(:,:) = 0.0
229   \textcolor{keyword}{allocate}(g%IdyCv(isd:ied,jsdb:jedb))   ; g%IdyCv(:,:) = 0.0
230   \textcolor{keyword}{allocate}(g%IdyBu(isdb:iedb,jsdb:jedb)) ; g%IdyBu(:,:) = 0.0
231 
232   \textcolor{keyword}{allocate}(g%areaT(isd:ied,jsd:jed))       ; g%areaT(:,:) = 0.0
233   \textcolor{keyword}{allocate}(g%IareaT(isd:ied,jsd:jed))      ; g%IareaT(:,:) = 0.0
234   \textcolor{keyword}{allocate}(g%areaBu(isdb:iedb,jsdb:jedb))  ; g%areaBu(:,:) = 0.0
235   \textcolor{keyword}{allocate}(g%IareaBu(isdb:iedb,jsdb:jedb)) ; g%IareaBu(:,:) = 0.0
236 
237   \textcolor{keyword}{allocate}(g%mask2dT(isd:ied,jsd:jed))      ; g%mask2dT(:,:) = 0.0
238   \textcolor{keyword}{allocate}(g%mask2dCu(isdb:iedb,jsd:jed))   ; g%mask2dCu(:,:) = 0.0
239   \textcolor{keyword}{allocate}(g%mask2dCv(isd:ied,jsdb:jedb))   ; g%mask2dCv(:,:) = 0.0
240   \textcolor{keyword}{allocate}(g%mask2dBu(isdb:iedb,jsdb:jedb)) ; g%mask2dBu(:,:) = 0.0
241   \textcolor{keyword}{allocate}(g%geoLatT(isd:ied,jsd:jed))      ; g%geoLatT(:,:) = 0.0
242   \textcolor{keyword}{allocate}(g%geoLatCu(isdb:iedb,jsd:jed))   ; g%geoLatCu(:,:) = 0.0
243   \textcolor{keyword}{allocate}(g%geoLatCv(isd:ied,jsdb:jedb))   ; g%geoLatCv(:,:) = 0.0
244   \textcolor{keyword}{allocate}(g%geoLatBu(isdb:iedb,jsdb:jedb)) ; g%geoLatBu(:,:) = 0.0
245   \textcolor{keyword}{allocate}(g%geoLonT(isd:ied,jsd:jed))      ; g%geoLonT(:,:) = 0.0
246   \textcolor{keyword}{allocate}(g%geoLonCu(isdb:iedb,jsd:jed))   ; g%geoLonCu(:,:) = 0.0
247   \textcolor{keyword}{allocate}(g%geoLonCv(isd:ied,jsdb:jedb))   ; g%geoLonCv(:,:) = 0.0
248   \textcolor{keyword}{allocate}(g%geoLonBu(isdb:iedb,jsdb:jedb)) ; g%geoLonBu(:,:) = 0.0
249 
250   \textcolor{keyword}{allocate}(g%dx\_Cv(isd:ied,jsdb:jedb))     ; g%dx\_Cv(:,:) = 0.0
251   \textcolor{keyword}{allocate}(g%dy\_Cu(isdb:iedb,jsd:jed))     ; g%dy\_Cu(:,:) = 0.0
252 
253   \textcolor{keyword}{allocate}(g%areaCu(isdb:iedb,jsd:jed))  ; g%areaCu(:,:) = 0.0
254   \textcolor{keyword}{allocate}(g%areaCv(isd:ied,jsdb:jedb))  ; g%areaCv(:,:) = 0.0
255   \textcolor{keyword}{allocate}(g%IareaCu(isdb:iedb,jsd:jed)) ; g%IareaCu(:,:) = 0.0
256   \textcolor{keyword}{allocate}(g%IareaCv(isd:ied,jsdb:jedb)) ; g%IareaCv(:,:) = 0.0
257 
258   \textcolor{keyword}{allocate}(g%bathyT(isd:ied, jsd:jed)) ; g%bathyT(:,:) = 0.0
259   \textcolor{keyword}{allocate}(g%CoriolisBu(isdb:iedb, jsdb:jedb)) ; g%CoriolisBu(:,:) = 0.0
260   \textcolor{keyword}{allocate}(g%dF\_dx(isd:ied, jsd:jed)) ; g%dF\_dx(:,:) = 0.0
261   \textcolor{keyword}{allocate}(g%dF\_dy(isd:ied, jsd:jed)) ; g%dF\_dy(:,:) = 0.0
262 
263   \textcolor{keyword}{allocate}(g%sin\_rot(isd:ied,jsd:jed)) ; g%sin\_rot(:,:) = 0.0
264   \textcolor{keyword}{allocate}(g%cos\_rot(isd:ied,jsd:jed)) ; g%cos\_rot(:,:) = 1.0
265 
266   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then}
267     \textcolor{keyword}{allocate}(g%Dblock\_u(isdb:iedb, jsd:jed)) ; g%Dblock\_u(:,:) = 0.0
268     \textcolor{keyword}{allocate}(g%Dopen\_u(isdb:iedb, jsd:jed))  ; g%Dopen\_u(:,:) = 0.0
269     \textcolor{keyword}{allocate}(g%Dblock\_v(isd:ied, jsdb:jedb)) ; g%Dblock\_v(:,:) = 0.0
270     \textcolor{keyword}{allocate}(g%Dopen\_v(isd:ied, jsdb:jedb))  ; g%Dopen\_v(:,:) = 0.0
271 \textcolor{keywordflow}{  endif}
272 
273   \textcolor{comment}{! gridLonB and gridLatB are used as edge values in some cases, so they}
274   \textcolor{comment}{! always need to use symmetric memory allcoations.}
275   \textcolor{keyword}{allocate}(g%gridLonT(isg:ieg))   ; g%gridLonT(:) = 0.0
276   \textcolor{keyword}{allocate}(g%gridLonB(isg-1:ieg)) ; g%gridLonB(:) = 0.0
277   \textcolor{keyword}{allocate}(g%gridLatT(jsg:jeg))   ; g%gridLatT(:) = 0.0
278   \textcolor{keyword}{allocate}(g%gridLatB(jsg-1:jeg)) ; g%gridLatB(:) = 0.0
279 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dyn__horgrid_a23c063bf0f2d5e5e96569a6bc5f8f382}\label{namespacemom__dyn__horgrid_a23c063bf0f2d5e5e96569a6bc5f8f382}} 
\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}!destroy\+\_\+dyn\+\_\+horgrid@{destroy\+\_\+dyn\+\_\+horgrid}}
\index{destroy\+\_\+dyn\+\_\+horgrid@{destroy\+\_\+dyn\+\_\+horgrid}!mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}
\subsubsection{\texorpdfstring{destroy\+\_\+dyn\+\_\+horgrid()}{destroy\_dyn\_horgrid()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dyn\+\_\+horgrid\+::destroy\+\_\+dyn\+\_\+horgrid (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), pointer}]{G }\end{DoxyParamCaption})}



Release memory used by the \mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}} and related structures. 


\begin{DoxyParams}{Parameters}
{\em g} & The dynamic horizontal grid type \\
\hline
\end{DoxyParams}


Definition at line 377 of file M\+O\+M\+\_\+dyn\+\_\+horgrid.\+F90.


\begin{DoxyCode}
377   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
378 
379   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(g)) \textcolor{keywordflow}{then}
380     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"destroy\_dyn\_horgrid called with an unassociated horgrid\_type."})
381 \textcolor{keywordflow}{  endif}
382 
383   \textcolor{keyword}{deallocate}(g%dxT)  ; \textcolor{keyword}{deallocate}(g%dxCu)  ; \textcolor{keyword}{deallocate}(g%dxCv)  ; \textcolor{keyword}{deallocate}(g%dxBu)
384   \textcolor{keyword}{deallocate}(g%IdxT) ; \textcolor{keyword}{deallocate}(g%IdxCu) ; \textcolor{keyword}{deallocate}(g%IdxCv) ; \textcolor{keyword}{deallocate}(g%IdxBu)
385 
386   \textcolor{keyword}{deallocate}(g%dyT)  ; \textcolor{keyword}{deallocate}(g%dyCu)  ; \textcolor{keyword}{deallocate}(g%dyCv)  ; \textcolor{keyword}{deallocate}(g%dyBu)
387   \textcolor{keyword}{deallocate}(g%IdyT) ; \textcolor{keyword}{deallocate}(g%IdyCu) ; \textcolor{keyword}{deallocate}(g%IdyCv) ; \textcolor{keyword}{deallocate}(g%IdyBu)
388 
389   \textcolor{keyword}{deallocate}(g%areaT)  ; \textcolor{keyword}{deallocate}(g%IareaT)
390   \textcolor{keyword}{deallocate}(g%areaBu) ; \textcolor{keyword}{deallocate}(g%IareaBu)
391   \textcolor{keyword}{deallocate}(g%areaCu) ; \textcolor{keyword}{deallocate}(g%IareaCu)
392   \textcolor{keyword}{deallocate}(g%areaCv)  ; \textcolor{keyword}{deallocate}(g%IareaCv)
393 
394   \textcolor{keyword}{deallocate}(g%mask2dT)  ; \textcolor{keyword}{deallocate}(g%mask2dCu)
395   \textcolor{keyword}{deallocate}(g%mask2dCv) ; \textcolor{keyword}{deallocate}(g%mask2dBu)
396 
397   \textcolor{keyword}{deallocate}(g%geoLatT)  ; \textcolor{keyword}{deallocate}(g%geoLatCu)
398   \textcolor{keyword}{deallocate}(g%geoLatCv) ; \textcolor{keyword}{deallocate}(g%geoLatBu)
399   \textcolor{keyword}{deallocate}(g%geoLonT)  ; \textcolor{keyword}{deallocate}(g%geoLonCu)
400   \textcolor{keyword}{deallocate}(g%geoLonCv) ; \textcolor{keyword}{deallocate}(g%geoLonBu)
401 
402   \textcolor{keyword}{deallocate}(g%dx\_Cv) ; \textcolor{keyword}{deallocate}(g%dy\_Cu)
403 
404   \textcolor{keyword}{deallocate}(g%bathyT)  ; \textcolor{keyword}{deallocate}(g%CoriolisBu)
405   \textcolor{keyword}{deallocate}(g%dF\_dx)  ; \textcolor{keyword}{deallocate}(g%dF\_dy)
406   \textcolor{keyword}{deallocate}(g%sin\_rot) ; \textcolor{keyword}{deallocate}(g%cos\_rot)
407 
408   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g%Dblock\_u)) \textcolor{keyword}{deallocate}(g%Dblock\_u)
409   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g%Dopen\_u)) \textcolor{keyword}{deallocate}(g%Dopen\_u)
410   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g%Dblock\_v)) \textcolor{keyword}{deallocate}(g%Dblock\_v)
411   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g%Dopen\_v)) \textcolor{keyword}{deallocate}(g%Dopen\_v)
412 
413   \textcolor{keyword}{deallocate}(g%gridLonT) ; \textcolor{keyword}{deallocate}(g%gridLatT)
414   \textcolor{keyword}{deallocate}(g%gridLonB) ; \textcolor{keyword}{deallocate}(g%gridLatB)
415 
416   \textcolor{keyword}{deallocate}(g%Domain%mpp\_domain)
417   \textcolor{keyword}{deallocate}(g%Domain)
418 
419   \textcolor{keyword}{deallocate}(g)
420 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dyn__horgrid_a4c2c545c65e12084cd863f0cade973f2}\label{namespacemom__dyn__horgrid_a4c2c545c65e12084cd863f0cade973f2}} 
\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}!rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry@{rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry}}
\index{rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry@{rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry}!mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}
\subsubsection{\texorpdfstring{rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry()}{rescale\_dyn\_horgrid\_bathymetry()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dyn\+\_\+horgrid\+::rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, intent(in)}]{m\+\_\+in\+\_\+new\+\_\+units }\end{DoxyParamCaption})}



rescale\+\_\+dyn\+\_\+horgrid\+\_\+bathymetry permits a change in the internal units for the bathymetry on the grid, both rescaling the depths and recording the new internal depth units. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The dynamic horizontal grid type\\
\hline
\mbox{\tt in}  & {\em m\+\_\+in\+\_\+new\+\_\+units} & The new internal representation of 1 m depth. \\
\hline
\end{DoxyParams}


Definition at line 285 of file M\+O\+M\+\_\+dyn\+\_\+horgrid.\+F90.


\begin{DoxyCode}
285   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
286   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(in)}    :: m\_in\_new\_units\textcolor{comment}{ !< The new internal representation of 1 m depth.}
287 
288   \textcolor{comment}{! Local variables}
289   \textcolor{keywordtype}{real} :: rescale
290   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
291 
292   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
293   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
294 
295   \textcolor{keywordflow}{if} (m\_in\_new\_units == 1.0) \textcolor{keywordflow}{return}
296   \textcolor{keywordflow}{if} (m\_in\_new\_units < 0.0) &
297     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Negative depth units are not permitted."})
298   \textcolor{keywordflow}{if} (m\_in\_new\_units == 0.0) &
299     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Zero depth units are not permitted."})
300 
301   rescale = 1.0 / m\_in\_new\_units
302   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
303     g%bathyT(i,j) = rescale*g%bathyT(i,j)
304 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
305   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
306     g%Dblock\_u(i,j) = rescale*g%Dblock\_u(i,j) ; g%Dopen\_u(i,j) = rescale*g%Dopen\_u(i,j)
307 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
308   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
309     g%Dblock\_v(i,j) = rescale*g%Dblock\_v(i,j) ; g%Dopen\_v(i,j) = rescale*g%Dopen\_v(i,j)
310 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
311   g%max\_depth = rescale*g%max\_depth
312 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__dyn__horgrid_a26c1389a380922c7c5d946cff3a9b11a}\label{namespacemom__dyn__horgrid_a26c1389a380922c7c5d946cff3a9b11a}} 
\index{mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}!set\+\_\+derived\+\_\+dyn\+\_\+horgrid@{set\+\_\+derived\+\_\+dyn\+\_\+horgrid}}
\index{set\+\_\+derived\+\_\+dyn\+\_\+horgrid@{set\+\_\+derived\+\_\+dyn\+\_\+horgrid}!mom\+\_\+dyn\+\_\+horgrid@{mom\+\_\+dyn\+\_\+horgrid}}
\subsubsection{\texorpdfstring{set\+\_\+derived\+\_\+dyn\+\_\+horgrid()}{set\_derived\_dyn\_horgrid()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+dyn\+\_\+horgrid\+::set\+\_\+derived\+\_\+dyn\+\_\+horgrid (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__dyn__horgrid_1_1dyn__horgrid__type}{dyn\+\_\+horgrid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in), optional}]{US }\end{DoxyParamCaption})}



set\+\_\+derived\+\_\+dyn\+\_\+horgrid calculates metric terms that are derived from other metrics. 


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


Definition at line 317 of file M\+O\+M\+\_\+dyn\+\_\+horgrid.\+F90.


\begin{DoxyCode}
317   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}
318   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
319 \textcolor{comment}{!    Various inverse grid spacings and derived areas are calculated within this}
320 \textcolor{comment}{!  subroutine.}
321   \textcolor{keywordtype}{real} :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
322   \textcolor{keywordtype}{real} :: L\_to\_m  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}
323   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed
324   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
325   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us%m\_to\_L
326   l\_to\_m = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m = us%L\_to\_m
327 
328   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
329   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
330 
331   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
332     \textcolor{keywordflow}{if} (g%dxT(i,j) < 0.0) g%dxT(i,j) = 0.0
333     \textcolor{keywordflow}{if} (g%dyT(i,j) < 0.0) g%dyT(i,j) = 0.0
334     g%IdxT(i,j) = adcroft\_reciprocal(g%dxT(i,j))
335     g%IdyT(i,j) = adcroft\_reciprocal(g%dyT(i,j))
336     g%IareaT(i,j) = adcroft\_reciprocal(g%areaT(i,j))
337 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
338 
339   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
340     \textcolor{keywordflow}{if} (g%dxCu(i,j) < 0.0) g%dxCu(i,j) = 0.0
341     \textcolor{keywordflow}{if} (g%dyCu(i,j) < 0.0) g%dyCu(i,j) = 0.0
342     g%IdxCu(i,j) = adcroft\_reciprocal(g%dxCu(i,j))
343     g%IdyCu(i,j) = adcroft\_reciprocal(g%dyCu(i,j))
344 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
345 
346   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
347     \textcolor{keywordflow}{if} (g%dxCv(i,j) < 0.0) g%dxCv(i,j) = 0.0
348     \textcolor{keywordflow}{if} (g%dyCv(i,j) < 0.0) g%dyCv(i,j) = 0.0
349     g%IdxCv(i,j) = adcroft\_reciprocal(g%dxCv(i,j))
350     g%IdyCv(i,j) = adcroft\_reciprocal(g%dyCv(i,j))
351 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
352 
353   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isdb,iedb
354     \textcolor{keywordflow}{if} (g%dxBu(i,j) < 0.0) g%dxBu(i,j) = 0.0
355     \textcolor{keywordflow}{if} (g%dyBu(i,j) < 0.0) g%dyBu(i,j) = 0.0
356 
357     g%IdxBu(i,j) = adcroft\_reciprocal(g%dxBu(i,j))
358     g%IdyBu(i,j) = adcroft\_reciprocal(g%dyBu(i,j))
359     \textcolor{comment}{! areaBu has usually been set to a positive area elsewhere.}
360     \textcolor{keywordflow}{if} (g%areaBu(i,j) <= 0.0) g%areaBu(i,j) = g%dxBu(i,j) * g%dyBu(i,j)
361     g%IareaBu(i,j) =  adcroft\_reciprocal(g%areaBu(i,j))
362 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
363 
\end{DoxyCode}
