\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{\texttt{ 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}{0}
\DoxyCodeLine{368 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: val\textcolor{comment}{  !< The value being inverted.}}
\DoxyCodeLine{369 \textcolor{keywordtype}{  real} :: I\_val\textcolor{comment}{            !< The Adcroft reciprocal of val.}}
\DoxyCodeLine{370 }
\DoxyCodeLine{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{\texttt{ in,out}}  & {\em g} & A pointer to the dynamic horizontal grid type \\
\hline
\mbox{\texttt{ in}}  & {\em hi} & A hor\+\_\+index\+\_\+type for array extents \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{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}}
\DoxyCodeLine{177   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{ !< A hor\_index\_type for array extents}}
\DoxyCodeLine{178   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: bathymetry\_at\_vel\textcolor{comment}{ !< If true, there are}}
\DoxyCodeLine{179 \textcolor{comment}{                             !! separate values for the basin depths at velocity}}
\DoxyCodeLine{180 \textcolor{comment}{                             !! points.  Otherwise the effects of topography are}}
\DoxyCodeLine{181 \textcolor{comment}{                             !! entirely determined from thickness points.}}
\DoxyCodeLine{182   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isg, ieg, jsg, jeg}
\DoxyCodeLine{183 }
\DoxyCodeLine{184   \textcolor{comment}{! This subroutine allocates the lateral elements of the dyn\_horgrid\_type that}}
\DoxyCodeLine{185   \textcolor{comment}{! are always used and zeros them out.}}
\DoxyCodeLine{186 }
\DoxyCodeLine{187   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(g)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{188     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"create\_dyn\_horgrid called with an associated horgrid\_type."})}
\DoxyCodeLine{189   \textcolor{keywordflow}{else}}
\DoxyCodeLine{190     \textcolor{keyword}{allocate}(g)}
\DoxyCodeLine{191 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{192 }
\DoxyCodeLine{193   g\%HI = hi}
\DoxyCodeLine{194 }
\DoxyCodeLine{195   g\%isc = hi\%isc ; g\%iec = hi\%iec ; g\%jsc = hi\%jsc ; g\%jec = hi\%jec}
\DoxyCodeLine{196   g\%isd = hi\%isd ; g\%ied = hi\%ied ; g\%jsd = hi\%jsd ; g\%jed = hi\%jed}
\DoxyCodeLine{197   g\%isg = hi\%isg ; g\%ieg = hi\%ieg ; g\%jsg = hi\%jsg ; g\%jeg = hi\%jeg}
\DoxyCodeLine{198 }
\DoxyCodeLine{199   g\%IscB = hi\%IscB ; g\%IecB = hi\%IecB ; g\%JscB = hi\%JscB ; g\%JecB = hi\%JecB}
\DoxyCodeLine{200   g\%IsdB = hi\%IsdB ; g\%IedB = hi\%IedB ; g\%JsdB = hi\%JsdB ; g\%JedB = hi\%JedB}
\DoxyCodeLine{201   g\%IsgB = hi\%IsgB ; g\%IegB = hi\%IegB ; g\%JsgB = hi\%JsgB ; g\%JegB = hi\%JegB}
\DoxyCodeLine{202 }
\DoxyCodeLine{203   g\%idg\_offset = hi\%idg\_offset ; g\%jdg\_offset = hi\%jdg\_offset}
\DoxyCodeLine{204   g\%isd\_global = g\%isd + hi\%idg\_offset ; g\%jsd\_global = g\%jsd + hi\%jdg\_offset}
\DoxyCodeLine{205   g\%symmetric = hi\%symmetric}
\DoxyCodeLine{206 }
\DoxyCodeLine{207   g\%bathymetry\_at\_vel = .false.}
\DoxyCodeLine{208   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(bathymetry\_at\_vel)) g\%bathymetry\_at\_vel = bathymetry\_at\_vel}
\DoxyCodeLine{209 }
\DoxyCodeLine{210   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{211   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{212   isg = g\%isg ; ieg = g\%ieg ; jsg = g\%jsg ; jeg = g\%jeg}
\DoxyCodeLine{213 }
\DoxyCodeLine{214   \textcolor{keyword}{allocate}(g\%dxT(isd:ied,jsd:jed))       ; g\%dxT(:,:) = 0.0}
\DoxyCodeLine{215   \textcolor{keyword}{allocate}(g\%dxCu(isdb:iedb,jsd:jed))    ; g\%dxCu(:,:) = 0.0}
\DoxyCodeLine{216   \textcolor{keyword}{allocate}(g\%dxCv(isd:ied,jsdb:jedb))    ; g\%dxCv(:,:) = 0.0}
\DoxyCodeLine{217   \textcolor{keyword}{allocate}(g\%dxBu(isdb:iedb,jsdb:jedb))  ; g\%dxBu(:,:) = 0.0}
\DoxyCodeLine{218   \textcolor{keyword}{allocate}(g\%IdxT(isd:ied,jsd:jed))      ; g\%IdxT(:,:) = 0.0}
\DoxyCodeLine{219   \textcolor{keyword}{allocate}(g\%IdxCu(isdb:iedb,jsd:jed))   ; g\%IdxCu(:,:) = 0.0}
\DoxyCodeLine{220   \textcolor{keyword}{allocate}(g\%IdxCv(isd:ied,jsdb:jedb))   ; g\%IdxCv(:,:) = 0.0}
\DoxyCodeLine{221   \textcolor{keyword}{allocate}(g\%IdxBu(isdb:iedb,jsdb:jedb)) ; g\%IdxBu(:,:) = 0.0}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{keyword}{allocate}(g\%dyT(isd:ied,jsd:jed))       ; g\%dyT(:,:) = 0.0}
\DoxyCodeLine{224   \textcolor{keyword}{allocate}(g\%dyCu(isdb:iedb,jsd:jed))    ; g\%dyCu(:,:) = 0.0}
\DoxyCodeLine{225   \textcolor{keyword}{allocate}(g\%dyCv(isd:ied,jsdb:jedb))    ; g\%dyCv(:,:) = 0.0}
\DoxyCodeLine{226   \textcolor{keyword}{allocate}(g\%dyBu(isdb:iedb,jsdb:jedb))  ; g\%dyBu(:,:) = 0.0}
\DoxyCodeLine{227   \textcolor{keyword}{allocate}(g\%IdyT(isd:ied,jsd:jed))      ; g\%IdyT(:,:) = 0.0}
\DoxyCodeLine{228   \textcolor{keyword}{allocate}(g\%IdyCu(isdb:iedb,jsd:jed))   ; g\%IdyCu(:,:) = 0.0}
\DoxyCodeLine{229   \textcolor{keyword}{allocate}(g\%IdyCv(isd:ied,jsdb:jedb))   ; g\%IdyCv(:,:) = 0.0}
\DoxyCodeLine{230   \textcolor{keyword}{allocate}(g\%IdyBu(isdb:iedb,jsdb:jedb)) ; g\%IdyBu(:,:) = 0.0}
\DoxyCodeLine{231 }
\DoxyCodeLine{232   \textcolor{keyword}{allocate}(g\%areaT(isd:ied,jsd:jed))       ; g\%areaT(:,:) = 0.0}
\DoxyCodeLine{233   \textcolor{keyword}{allocate}(g\%IareaT(isd:ied,jsd:jed))      ; g\%IareaT(:,:) = 0.0}
\DoxyCodeLine{234   \textcolor{keyword}{allocate}(g\%areaBu(isdb:iedb,jsdb:jedb))  ; g\%areaBu(:,:) = 0.0}
\DoxyCodeLine{235   \textcolor{keyword}{allocate}(g\%IareaBu(isdb:iedb,jsdb:jedb)) ; g\%IareaBu(:,:) = 0.0}
\DoxyCodeLine{236 }
\DoxyCodeLine{237   \textcolor{keyword}{allocate}(g\%mask2dT(isd:ied,jsd:jed))      ; g\%mask2dT(:,:) = 0.0}
\DoxyCodeLine{238   \textcolor{keyword}{allocate}(g\%mask2dCu(isdb:iedb,jsd:jed))   ; g\%mask2dCu(:,:) = 0.0}
\DoxyCodeLine{239   \textcolor{keyword}{allocate}(g\%mask2dCv(isd:ied,jsdb:jedb))   ; g\%mask2dCv(:,:) = 0.0}
\DoxyCodeLine{240   \textcolor{keyword}{allocate}(g\%mask2dBu(isdb:iedb,jsdb:jedb)) ; g\%mask2dBu(:,:) = 0.0}
\DoxyCodeLine{241   \textcolor{keyword}{allocate}(g\%geoLatT(isd:ied,jsd:jed))      ; g\%geoLatT(:,:) = 0.0}
\DoxyCodeLine{242   \textcolor{keyword}{allocate}(g\%geoLatCu(isdb:iedb,jsd:jed))   ; g\%geoLatCu(:,:) = 0.0}
\DoxyCodeLine{243   \textcolor{keyword}{allocate}(g\%geoLatCv(isd:ied,jsdb:jedb))   ; g\%geoLatCv(:,:) = 0.0}
\DoxyCodeLine{244   \textcolor{keyword}{allocate}(g\%geoLatBu(isdb:iedb,jsdb:jedb)) ; g\%geoLatBu(:,:) = 0.0}
\DoxyCodeLine{245   \textcolor{keyword}{allocate}(g\%geoLonT(isd:ied,jsd:jed))      ; g\%geoLonT(:,:) = 0.0}
\DoxyCodeLine{246   \textcolor{keyword}{allocate}(g\%geoLonCu(isdb:iedb,jsd:jed))   ; g\%geoLonCu(:,:) = 0.0}
\DoxyCodeLine{247   \textcolor{keyword}{allocate}(g\%geoLonCv(isd:ied,jsdb:jedb))   ; g\%geoLonCv(:,:) = 0.0}
\DoxyCodeLine{248   \textcolor{keyword}{allocate}(g\%geoLonBu(isdb:iedb,jsdb:jedb)) ; g\%geoLonBu(:,:) = 0.0}
\DoxyCodeLine{249 }
\DoxyCodeLine{250   \textcolor{keyword}{allocate}(g\%dx\_Cv(isd:ied,jsdb:jedb))     ; g\%dx\_Cv(:,:) = 0.0}
\DoxyCodeLine{251   \textcolor{keyword}{allocate}(g\%dy\_Cu(isdb:iedb,jsd:jed))     ; g\%dy\_Cu(:,:) = 0.0}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{keyword}{allocate}(g\%areaCu(isdb:iedb,jsd:jed))  ; g\%areaCu(:,:) = 0.0}
\DoxyCodeLine{254   \textcolor{keyword}{allocate}(g\%areaCv(isd:ied,jsdb:jedb))  ; g\%areaCv(:,:) = 0.0}
\DoxyCodeLine{255   \textcolor{keyword}{allocate}(g\%IareaCu(isdb:iedb,jsd:jed)) ; g\%IareaCu(:,:) = 0.0}
\DoxyCodeLine{256   \textcolor{keyword}{allocate}(g\%IareaCv(isd:ied,jsdb:jedb)) ; g\%IareaCv(:,:) = 0.0}
\DoxyCodeLine{257 }
\DoxyCodeLine{258   \textcolor{keyword}{allocate}(g\%bathyT(isd:ied, jsd:jed)) ; g\%bathyT(:,:) = 0.0}
\DoxyCodeLine{259   \textcolor{keyword}{allocate}(g\%CoriolisBu(isdb:iedb, jsdb:jedb)) ; g\%CoriolisBu(:,:) = 0.0}
\DoxyCodeLine{260   \textcolor{keyword}{allocate}(g\%dF\_dx(isd:ied, jsd:jed)) ; g\%dF\_dx(:,:) = 0.0}
\DoxyCodeLine{261   \textcolor{keyword}{allocate}(g\%dF\_dy(isd:ied, jsd:jed)) ; g\%dF\_dy(:,:) = 0.0}
\DoxyCodeLine{262 }
\DoxyCodeLine{263   \textcolor{keyword}{allocate}(g\%sin\_rot(isd:ied,jsd:jed)) ; g\%sin\_rot(:,:) = 0.0}
\DoxyCodeLine{264   \textcolor{keyword}{allocate}(g\%cos\_rot(isd:ied,jsd:jed)) ; g\%cos\_rot(:,:) = 1.0}
\DoxyCodeLine{265 }
\DoxyCodeLine{266   \textcolor{keywordflow}{if} (g\%bathymetry\_at\_vel) \textcolor{keywordflow}{then}}
\DoxyCodeLine{267     \textcolor{keyword}{allocate}(g\%Dblock\_u(isdb:iedb, jsd:jed)) ; g\%Dblock\_u(:,:) = 0.0}
\DoxyCodeLine{268     \textcolor{keyword}{allocate}(g\%Dopen\_u(isdb:iedb, jsd:jed))  ; g\%Dopen\_u(:,:) = 0.0}
\DoxyCodeLine{269     \textcolor{keyword}{allocate}(g\%Dblock\_v(isd:ied, jsdb:jedb)) ; g\%Dblock\_v(:,:) = 0.0}
\DoxyCodeLine{270     \textcolor{keyword}{allocate}(g\%Dopen\_v(isd:ied, jsdb:jedb))  ; g\%Dopen\_v(:,:) = 0.0}
\DoxyCodeLine{271 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{272 }
\DoxyCodeLine{273   \textcolor{comment}{! gridLonB and gridLatB are used as edge values in some cases, so they}}
\DoxyCodeLine{274   \textcolor{comment}{! always need to use symmetric memory allcoations.}}
\DoxyCodeLine{275   \textcolor{keyword}{allocate}(g\%gridLonT(isg:ieg))   ; g\%gridLonT(:) = 0.0}
\DoxyCodeLine{276   \textcolor{keyword}{allocate}(g\%gridLonB(isg-1:ieg)) ; g\%gridLonB(:) = 0.0}
\DoxyCodeLine{277   \textcolor{keyword}{allocate}(g\%gridLatT(jsg:jeg))   ; g\%gridLatT(:) = 0.0}
\DoxyCodeLine{278   \textcolor{keyword}{allocate}(g\%gridLatB(jsg-1:jeg)) ; g\%gridLatB(:) = 0.0}
\DoxyCodeLine{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}{0}
\DoxyCodeLine{377   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{378 }
\DoxyCodeLine{379   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(g)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{380     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"destroy\_dyn\_horgrid called with an unassociated horgrid\_type."})}
\DoxyCodeLine{381 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{382 }
\DoxyCodeLine{383   \textcolor{keyword}{deallocate}(g\%dxT)  ; \textcolor{keyword}{deallocate}(g\%dxCu)  ; \textcolor{keyword}{deallocate}(g\%dxCv)  ; \textcolor{keyword}{deallocate}(g\%dxBu)}
\DoxyCodeLine{384   \textcolor{keyword}{deallocate}(g\%IdxT) ; \textcolor{keyword}{deallocate}(g\%IdxCu) ; \textcolor{keyword}{deallocate}(g\%IdxCv) ; \textcolor{keyword}{deallocate}(g\%IdxBu)}
\DoxyCodeLine{385 }
\DoxyCodeLine{386   \textcolor{keyword}{deallocate}(g\%dyT)  ; \textcolor{keyword}{deallocate}(g\%dyCu)  ; \textcolor{keyword}{deallocate}(g\%dyCv)  ; \textcolor{keyword}{deallocate}(g\%dyBu)}
\DoxyCodeLine{387   \textcolor{keyword}{deallocate}(g\%IdyT) ; \textcolor{keyword}{deallocate}(g\%IdyCu) ; \textcolor{keyword}{deallocate}(g\%IdyCv) ; \textcolor{keyword}{deallocate}(g\%IdyBu)}
\DoxyCodeLine{388 }
\DoxyCodeLine{389   \textcolor{keyword}{deallocate}(g\%areaT)  ; \textcolor{keyword}{deallocate}(g\%IareaT)}
\DoxyCodeLine{390   \textcolor{keyword}{deallocate}(g\%areaBu) ; \textcolor{keyword}{deallocate}(g\%IareaBu)}
\DoxyCodeLine{391   \textcolor{keyword}{deallocate}(g\%areaCu) ; \textcolor{keyword}{deallocate}(g\%IareaCu)}
\DoxyCodeLine{392   \textcolor{keyword}{deallocate}(g\%areaCv)  ; \textcolor{keyword}{deallocate}(g\%IareaCv)}
\DoxyCodeLine{393 }
\DoxyCodeLine{394   \textcolor{keyword}{deallocate}(g\%mask2dT)  ; \textcolor{keyword}{deallocate}(g\%mask2dCu)}
\DoxyCodeLine{395   \textcolor{keyword}{deallocate}(g\%mask2dCv) ; \textcolor{keyword}{deallocate}(g\%mask2dBu)}
\DoxyCodeLine{396 }
\DoxyCodeLine{397   \textcolor{keyword}{deallocate}(g\%geoLatT)  ; \textcolor{keyword}{deallocate}(g\%geoLatCu)}
\DoxyCodeLine{398   \textcolor{keyword}{deallocate}(g\%geoLatCv) ; \textcolor{keyword}{deallocate}(g\%geoLatBu)}
\DoxyCodeLine{399   \textcolor{keyword}{deallocate}(g\%geoLonT)  ; \textcolor{keyword}{deallocate}(g\%geoLonCu)}
\DoxyCodeLine{400   \textcolor{keyword}{deallocate}(g\%geoLonCv) ; \textcolor{keyword}{deallocate}(g\%geoLonBu)}
\DoxyCodeLine{401 }
\DoxyCodeLine{402   \textcolor{keyword}{deallocate}(g\%dx\_Cv) ; \textcolor{keyword}{deallocate}(g\%dy\_Cu)}
\DoxyCodeLine{403 }
\DoxyCodeLine{404   \textcolor{keyword}{deallocate}(g\%bathyT)  ; \textcolor{keyword}{deallocate}(g\%CoriolisBu)}
\DoxyCodeLine{405   \textcolor{keyword}{deallocate}(g\%dF\_dx)  ; \textcolor{keyword}{deallocate}(g\%dF\_dy)}
\DoxyCodeLine{406   \textcolor{keyword}{deallocate}(g\%sin\_rot) ; \textcolor{keyword}{deallocate}(g\%cos\_rot)}
\DoxyCodeLine{407 }
\DoxyCodeLine{408   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g\%Dblock\_u)) \textcolor{keyword}{deallocate}(g\%Dblock\_u)}
\DoxyCodeLine{409   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g\%Dopen\_u)) \textcolor{keyword}{deallocate}(g\%Dopen\_u)}
\DoxyCodeLine{410   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g\%Dblock\_v)) \textcolor{keyword}{deallocate}(g\%Dblock\_v)}
\DoxyCodeLine{411   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(g\%Dopen\_v)) \textcolor{keyword}{deallocate}(g\%Dopen\_v)}
\DoxyCodeLine{412 }
\DoxyCodeLine{413   \textcolor{keyword}{deallocate}(g\%gridLonT) ; \textcolor{keyword}{deallocate}(g\%gridLatT)}
\DoxyCodeLine{414   \textcolor{keyword}{deallocate}(g\%gridLonB) ; \textcolor{keyword}{deallocate}(g\%gridLatB)}
\DoxyCodeLine{415 }
\DoxyCodeLine{416   \textcolor{keyword}{deallocate}(g\%Domain\%mpp\_domain)}
\DoxyCodeLine{417   \textcolor{keyword}{deallocate}(g\%Domain)}
\DoxyCodeLine{418 }
\DoxyCodeLine{419   \textcolor{keyword}{deallocate}(g)}
\DoxyCodeLine{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{\texttt{ in,out}}  & {\em g} & The dynamic horizontal grid type \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{285   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{286 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: m\_in\_new\_units\textcolor{comment}{ !< The new internal representation of 1 m depth.}}
\DoxyCodeLine{287 }
\DoxyCodeLine{288   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{289 \textcolor{keywordtype}{  real} :: rescale}
\DoxyCodeLine{290   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{291 }
\DoxyCodeLine{292   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{293   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{294 }
\DoxyCodeLine{295   \textcolor{keywordflow}{if} (m\_in\_new\_units == 1.0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{296   \textcolor{keywordflow}{if} (m\_in\_new\_units < 0.0) \&}
\DoxyCodeLine{297     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Negative depth units are not permitted."})}
\DoxyCodeLine{298   \textcolor{keywordflow}{if} (m\_in\_new\_units == 0.0) \&}
\DoxyCodeLine{299     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Zero depth units are not permitted."})}
\DoxyCodeLine{300 }
\DoxyCodeLine{301   rescale = 1.0 / m\_in\_new\_units}
\DoxyCodeLine{302   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{303     g\%bathyT(i,j) = rescale*g\%bathyT(i,j)}
\DoxyCodeLine{304 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{305   \textcolor{keywordflow}{if} (g\%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{306     g\%Dblock\_u(i,j) = rescale*g\%Dblock\_u(i,j) ; g\%Dopen\_u(i,j) = rescale*g\%Dopen\_u(i,j)}
\DoxyCodeLine{307 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{308   \textcolor{keywordflow}{if} (g\%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{309     g\%Dblock\_v(i,j) = rescale*g\%Dblock\_v(i,j) ; g\%Dopen\_v(i,j) = rescale*g\%Dopen\_v(i,j)}
\DoxyCodeLine{310 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{311   g\%max\_depth = rescale*g\%max\_depth}
\DoxyCodeLine{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{\texttt{ in,out}}  & {\em g} & The dynamic horizontal grid type \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{317   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The dynamic horizontal grid type}}
\DoxyCodeLine{318   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{319 \textcolor{comment}{!    Various inverse grid spacings and derived areas are calculated within this}}
\DoxyCodeLine{320 \textcolor{comment}{!  subroutine.}}
\DoxyCodeLine{321 \textcolor{keywordtype}{  real} :: m\_to\_L  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}}
\DoxyCodeLine{322 \textcolor{keywordtype}{  real} :: L\_to\_m  \textcolor{comment}{! A unit conversion factor [L m-1 ~> nondim]}}
\DoxyCodeLine{323   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed}
\DoxyCodeLine{324   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{325   m\_to\_l = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) m\_to\_l = us\%m\_to\_L}
\DoxyCodeLine{326   l\_to\_m = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) l\_to\_m = us\%L\_to\_m}
\DoxyCodeLine{327 }
\DoxyCodeLine{328   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{329   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{330 }
\DoxyCodeLine{331   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{332     \textcolor{keywordflow}{if} (g\%dxT(i,j) < 0.0) g\%dxT(i,j) = 0.0}
\DoxyCodeLine{333     \textcolor{keywordflow}{if} (g\%dyT(i,j) < 0.0) g\%dyT(i,j) = 0.0}
\DoxyCodeLine{334     g\%IdxT(i,j) = adcroft\_reciprocal(g\%dxT(i,j))}
\DoxyCodeLine{335     g\%IdyT(i,j) = adcroft\_reciprocal(g\%dyT(i,j))}
\DoxyCodeLine{336     g\%IareaT(i,j) = adcroft\_reciprocal(g\%areaT(i,j))}
\DoxyCodeLine{337 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{338 }
\DoxyCodeLine{339   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{340     \textcolor{keywordflow}{if} (g\%dxCu(i,j) < 0.0) g\%dxCu(i,j) = 0.0}
\DoxyCodeLine{341     \textcolor{keywordflow}{if} (g\%dyCu(i,j) < 0.0) g\%dyCu(i,j) = 0.0}
\DoxyCodeLine{342     g\%IdxCu(i,j) = adcroft\_reciprocal(g\%dxCu(i,j))}
\DoxyCodeLine{343     g\%IdyCu(i,j) = adcroft\_reciprocal(g\%dyCu(i,j))}
\DoxyCodeLine{344 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{345 }
\DoxyCodeLine{346   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied}
\DoxyCodeLine{347     \textcolor{keywordflow}{if} (g\%dxCv(i,j) < 0.0) g\%dxCv(i,j) = 0.0}
\DoxyCodeLine{348     \textcolor{keywordflow}{if} (g\%dyCv(i,j) < 0.0) g\%dyCv(i,j) = 0.0}
\DoxyCodeLine{349     g\%IdxCv(i,j) = adcroft\_reciprocal(g\%dxCv(i,j))}
\DoxyCodeLine{350     g\%IdyCv(i,j) = adcroft\_reciprocal(g\%dyCv(i,j))}
\DoxyCodeLine{351 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{352 }
\DoxyCodeLine{353   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isdb,iedb}
\DoxyCodeLine{354     \textcolor{keywordflow}{if} (g\%dxBu(i,j) < 0.0) g\%dxBu(i,j) = 0.0}
\DoxyCodeLine{355     \textcolor{keywordflow}{if} (g\%dyBu(i,j) < 0.0) g\%dyBu(i,j) = 0.0}
\DoxyCodeLine{356 }
\DoxyCodeLine{357     g\%IdxBu(i,j) = adcroft\_reciprocal(g\%dxBu(i,j))}
\DoxyCodeLine{358     g\%IdyBu(i,j) = adcroft\_reciprocal(g\%dyBu(i,j))}
\DoxyCodeLine{359     \textcolor{comment}{! areaBu has usually been set to a positive area elsewhere.}}
\DoxyCodeLine{360     \textcolor{keywordflow}{if} (g\%areaBu(i,j) <= 0.0) g\%areaBu(i,j) = g\%dxBu(i,j) * g\%dyBu(i,j)}
\DoxyCodeLine{361     g\%IareaBu(i,j) =  adcroft\_reciprocal(g\%areaBu(i,j))}
\DoxyCodeLine{362 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{363 }

\end{DoxyCode}
