\hypertarget{namespacemom__grid}{}\section{mom\+\_\+grid Module Reference}
\label{namespacemom__grid}\index{mom\+\_\+grid@{mom\+\_\+grid}}


\subsection{Detailed Description}
Provides the ocean grid type. 

Grid metrics and their inverses are labelled according to their staggered location on a Arakawa C (or B) grid.


\begin{DoxyItemize}
\item Metrics centered on h-\/ or T-\/points are labelled T, e.\+g. dxT is the distance across the cell in the x-\/direction.
\item Metrics centered on u-\/points are labelled Cu (C-\/grid u location). e.\+g. dy\+Cu is the y-\/distance between two corners of a T-\/cell.
\item Metrics centered on v-\/points are labelled Cv (C-\/grid v location). e.\+g. dy\+Cv is the y-\/distance between two -\/points.
\item Metrics centered on q-\/points are labelled Bu (B-\/grid u,v location). e.\+g. area\+Bu is the area centered on a q-\/point.
\end{DoxyItemize}

 location on an T-\/cell and around a q-\/point."

Areas centered at T-\/, u-\/, v-\/ and q-\/ points are {\ttfamily areaT}, {\ttfamily area\+Cu}, {\ttfamily area\+Cv} and {\ttfamily area\+Bu} respectively.

The reciprocal of metrics are pre-\/calculated and also stored in the \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}} with a I prepended to the name. For example, {\ttfamily 1./areaT} is called {\ttfamily IareaT}, and {\ttfamily 1./dy\+Cv} is {\ttfamily Idy\+Cv}.

Geographic latitude and longitude (or model coordinates if not on a sphere) are stored in {\ttfamily geo\+LatT}, {\ttfamily geo\+LonT} for T-\/points. u-\/, v-\/ and q-\/ point coordinates are follow same pattern of replacing T with Cu, Cv and Bu respectively.

Each location also has a 2D mask indicating whether the entire column is land or ocean. {\ttfamily mask2dT} is 1 if the column is wet or 0 if the T-\/cell is land. {\ttfamily mask2d\+Cu} is 1 if both neighboring column are ocean, and 0 if either is land. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Ocean grid type. See \mbox{\hyperlink{namespacemom__grid}{mom\+\_\+grid}} for details. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a1de9705f83b687ad9a711630a95fe52c}{mom\+\_\+grid\+\_\+init}} (G, param\+\_\+file, US, HI, global\+\_\+indexing, bathymetry\+\_\+at\+\_\+vel)
\begin{DoxyCompactList}\small\item\em M\+O\+M\+\_\+grid\+\_\+init initializes the ocean grid array sizes and grid memory. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a2ef4227cc0bc03d2937270fcc14d7354}{rescale\+\_\+grid\+\_\+bathymetry}} (G, m\+\_\+in\+\_\+new\+\_\+units)
\begin{DoxyCompactList}\small\item\em rescale\+\_\+grid\+\_\+bathymetry permits a change in the internal units for the bathymetry on the grid, both rescaling the depths and recording the new internal units. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a1ed8ca50737525ff437bdb349c8d701f}{set\+\_\+derived\+\_\+metrics}} (G, US)
\begin{DoxyCompactList}\small\item\em set\+\_\+derived\+\_\+metrics calculates metric terms that are derived from other metrics. \end{DoxyCompactList}\item 
real function \mbox{\hyperlink{namespacemom__grid_a49cb0213b535091f3c12e9152fbbda03}{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 
logical function, public \mbox{\hyperlink{namespacemom__grid_a7d20103f37477e32f1a4a7b7570af144}{ispointincell}} (G, i, j, x, y)
\begin{DoxyCompactList}\small\item\em Returns true if the coordinates (x,y) are within the h-\/cell (i,j) \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a9d2aac0ba53c9072f5f37d9bf97187b2}{set\+\_\+first\+\_\+direction}} (G, y\+\_\+first)
\begin{DoxyCompactList}\small\item\em Store an integer indicating which direction to work on first. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a1cee4daea572d4efd1565b24ca652a2d}{get\+\_\+global\+\_\+grid\+\_\+size}} (G, niglobal, njglobal)
\begin{DoxyCompactList}\small\item\em Return global shape of horizontal grid. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__grid_a4a0b721d65abedfe5208a1e0904cd327}{allocate\+\_\+metrics}} (G)
\begin{DoxyCompactList}\small\item\em Allocate memory used by the \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}} and related structures. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__grid_a889221e5714c3935f276c28dffe5e460}{mom\+\_\+grid\+\_\+end}} (G)
\begin{DoxyCompactList}\small\item\em Release memory used by the \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}} and related structures. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__grid_a49cb0213b535091f3c12e9152fbbda03}\label{namespacemom__grid_a49cb0213b535091f3c12e9152fbbda03}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!adcroft\+\_\+reciprocal@{adcroft\+\_\+reciprocal}}
\index{adcroft\+\_\+reciprocal@{adcroft\+\_\+reciprocal}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{adcroft\+\_\+reciprocal()}{adcroft\_reciprocal()}}
{\footnotesize\ttfamily real function mom\+\_\+grid\+::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 466 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
466   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)} :: val\textcolor{comment}{  !< The value being inverted.}
467   \textcolor{keywordtype}{real} :: I\_val\textcolor{comment}{            !< The Adcroft reciprocal of val.}
468 
469   i\_val = 0.0 ; \textcolor{keywordflow}{if} (val /= 0.0) i\_val = 1.0/val
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a4a0b721d65abedfe5208a1e0904cd327}\label{namespacemom__grid_a4a0b721d65abedfe5208a1e0904cd327}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!allocate\+\_\+metrics@{allocate\+\_\+metrics}}
\index{allocate\+\_\+metrics@{allocate\+\_\+metrics}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{allocate\+\_\+metrics()}{allocate\_metrics()}}
{\footnotesize\ttfamily subroutine mom\+\_\+grid\+::allocate\+\_\+metrics (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Allocate memory used by the \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}} and related structures. 


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


Definition at line 527 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
527   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The horizontal grid type}
528   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB, isg, ieg, jsg, jeg
529 
530   \textcolor{comment}{! This subroutine allocates the lateral elements of the ocean\_grid\_type that}
531   \textcolor{comment}{! are always used and zeros them out.}
532 
533   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
534   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
535   isg = g%isg ; ieg = g%ieg ; jsg = g%jsg ; jeg = g%jeg
536 
537   alloc\_(g%dxT(isd:ied,jsd:jed))       ; g%dxT(:,:) = 0.0
538   alloc\_(g%dxCu(isdb:iedb,jsd:jed))    ; g%dxCu(:,:) = 0.0
539   alloc\_(g%dxCv(isd:ied,jsdb:jedb))    ; g%dxCv(:,:) = 0.0
540   alloc\_(g%dxBu(isdb:iedb,jsdb:jedb))  ; g%dxBu(:,:) = 0.0
541   alloc\_(g%IdxT(isd:ied,jsd:jed))      ; g%IdxT(:,:) = 0.0
542   alloc\_(g%IdxCu(isdb:iedb,jsd:jed))   ; g%IdxCu(:,:) = 0.0
543   alloc\_(g%IdxCv(isd:ied,jsdb:jedb))   ; g%IdxCv(:,:) = 0.0
544   alloc\_(g%IdxBu(isdb:iedb,jsdb:jedb)) ; g%IdxBu(:,:) = 0.0
545 
546   alloc\_(g%dyT(isd:ied,jsd:jed))       ; g%dyT(:,:) = 0.0
547   alloc\_(g%dyCu(isdb:iedb,jsd:jed))    ; g%dyCu(:,:) = 0.0
548   alloc\_(g%dyCv(isd:ied,jsdb:jedb))    ; g%dyCv(:,:) = 0.0
549   alloc\_(g%dyBu(isdb:iedb,jsdb:jedb))  ; g%dyBu(:,:) = 0.0
550   alloc\_(g%IdyT(isd:ied,jsd:jed))      ; g%IdyT(:,:) = 0.0
551   alloc\_(g%IdyCu(isdb:iedb,jsd:jed))   ; g%IdyCu(:,:) = 0.0
552   alloc\_(g%IdyCv(isd:ied,jsdb:jedb))   ; g%IdyCv(:,:) = 0.0
553   alloc\_(g%IdyBu(isdb:iedb,jsdb:jedb)) ; g%IdyBu(:,:) = 0.0
554 
555   alloc\_(g%areaT(isd:ied,jsd:jed))       ; g%areaT(:,:) = 0.0
556   alloc\_(g%IareaT(isd:ied,jsd:jed))      ; g%IareaT(:,:) = 0.0
557   alloc\_(g%areaBu(isdb:iedb,jsdb:jedb))  ; g%areaBu(:,:) = 0.0
558   alloc\_(g%IareaBu(isdb:iedb,jsdb:jedb)) ; g%IareaBu(:,:) = 0.0
559 
560   alloc\_(g%mask2dT(isd:ied,jsd:jed))      ; g%mask2dT(:,:) = 0.0
561   alloc\_(g%mask2dCu(isdb:iedb,jsd:jed))   ; g%mask2dCu(:,:) = 0.0
562   alloc\_(g%mask2dCv(isd:ied,jsdb:jedb))   ; g%mask2dCv(:,:) = 0.0
563   alloc\_(g%mask2dBu(isdb:iedb,jsdb:jedb)) ; g%mask2dBu(:,:) = 0.0
564   alloc\_(g%geoLatT(isd:ied,jsd:jed))      ; g%geoLatT(:,:) = 0.0
565   alloc\_(g%geoLatCu(isdb:iedb,jsd:jed))   ; g%geoLatCu(:,:) = 0.0
566   alloc\_(g%geoLatCv(isd:ied,jsdb:jedb))   ; g%geoLatCv(:,:) = 0.0
567   alloc\_(g%geoLatBu(isdb:iedb,jsdb:jedb)) ; g%geoLatBu(:,:) = 0.0
568   alloc\_(g%geoLonT(isd:ied,jsd:jed))      ; g%geoLonT(:,:) = 0.0
569   alloc\_(g%geoLonCu(isdb:iedb,jsd:jed))   ; g%geoLonCu(:,:) = 0.0
570   alloc\_(g%geoLonCv(isd:ied,jsdb:jedb))   ; g%geoLonCv(:,:) = 0.0
571   alloc\_(g%geoLonBu(isdb:iedb,jsdb:jedb)) ; g%geoLonBu(:,:) = 0.0
572 
573   alloc\_(g%dx\_Cv(isd:ied,jsdb:jedb))     ; g%dx\_Cv(:,:) = 0.0
574   alloc\_(g%dy\_Cu(isdb:iedb,jsd:jed))     ; g%dy\_Cu(:,:) = 0.0
575 
576   alloc\_(g%areaCu(isdb:iedb,jsd:jed))  ; g%areaCu(:,:) = 0.0
577   alloc\_(g%areaCv(isd:ied,jsdb:jedb))  ; g%areaCv(:,:) = 0.0
578   alloc\_(g%IareaCu(isdb:iedb,jsd:jed)) ; g%IareaCu(:,:) = 0.0
579   alloc\_(g%IareaCv(isd:ied,jsdb:jedb)) ; g%IareaCv(:,:) = 0.0
580 
581   alloc\_(g%bathyT(isd:ied, jsd:jed)) ; g%bathyT(:,:) = 0.0
582   alloc\_(g%CoriolisBu(isdb:iedb, jsdb:jedb)) ; g%CoriolisBu(:,:) = 0.0
583   alloc\_(g%dF\_dx(isd:ied, jsd:jed)) ; g%dF\_dx(:,:) = 0.0
584   alloc\_(g%dF\_dy(isd:ied, jsd:jed)) ; g%dF\_dy(:,:) = 0.0
585 
586   alloc\_(g%sin\_rot(isd:ied,jsd:jed)) ; g%sin\_rot(:,:) = 0.0
587   alloc\_(g%cos\_rot(isd:ied,jsd:jed)) ; g%cos\_rot(:,:) = 1.0
588 
589   \textcolor{keyword}{allocate}(g%gridLonT(isg:ieg))   ; g%gridLonT(:) = 0.0
590   \textcolor{keyword}{allocate}(g%gridLonB(g%IsgB:g%IegB)) ; g%gridLonB(:) = 0.0
591   \textcolor{keyword}{allocate}(g%gridLatT(jsg:jeg))   ; g%gridLatT(:) = 0.0
592   \textcolor{keyword}{allocate}(g%gridLatB(g%JsgB:g%JegB)) ; g%gridLatB(:) = 0.0
593 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a1cee4daea572d4efd1565b24ca652a2d}\label{namespacemom__grid_a1cee4daea572d4efd1565b24ca652a2d}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!get\+\_\+global\+\_\+grid\+\_\+size@{get\+\_\+global\+\_\+grid\+\_\+size}}
\index{get\+\_\+global\+\_\+grid\+\_\+size@{get\+\_\+global\+\_\+grid\+\_\+size}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{get\+\_\+global\+\_\+grid\+\_\+size()}{get\_global\_grid\_size()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::get\+\_\+global\+\_\+grid\+\_\+size (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{integer, intent(out)}]{niglobal,  }\item[{integer, intent(out)}]{njglobal }\end{DoxyParamCaption})}



Return global shape of horizontal grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The horizontal grid type\\
\hline
\mbox{\tt out}  & {\em niglobal} & i-\/index global size of grid\\
\hline
\mbox{\tt out}  & {\em njglobal} & j-\/index global size of grid \\
\hline
\end{DoxyParams}


Definition at line 517 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
517   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The horizontal grid type}
518   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(out)}   :: niglobal\textcolor{comment}{ !< i-index global size of grid}
519   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(out)}   :: njglobal\textcolor{comment}{ !< j-index global size of grid}
520 
521   \textcolor{keyword}{call }get\_global\_shape(g%domain, niglobal, njglobal)
522 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a7d20103f37477e32f1a4a7b7570af144}\label{namespacemom__grid_a7d20103f37477e32f1a4a7b7570af144}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!ispointincell@{ispointincell}}
\index{ispointincell@{ispointincell}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{ispointincell()}{ispointincell()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+grid\+::ispointincell (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(in)}]{G,  }\item[{integer, intent(in)}]{i,  }\item[{integer, intent(in)}]{j,  }\item[{real, intent(in)}]{x,  }\item[{real, intent(in)}]{y }\end{DoxyParamCaption})}



Returns true if the coordinates (x,y) are within the h-\/cell (i,j) 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em g} & Grid type\\
\hline
\mbox{\tt in}  & {\em i} & i index of cell to test\\
\hline
\mbox{\tt in}  & {\em j} & j index of cell to test\\
\hline
\mbox{\tt in}  & {\em x} & x coordinate of point\\
\hline
\mbox{\tt in}  & {\em y} & y coordinate of point \\
\hline
\end{DoxyParams}


Definition at line 474 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
474   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Grid type}
475   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: i\textcolor{comment}{ !< i index of cell to test}
476   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: j\textcolor{comment}{ !< j index of cell to test}
477   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{ !< x coordinate of point}
478   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)} :: y\textcolor{comment}{ !< y coordinate of point}
479   \textcolor{comment}{! Local variables}
480   \textcolor{keywordtype}{real} :: xNE, xNW, xSE, xSW, yNE, yNW, ySE, ySW
481   \textcolor{keywordtype}{real} :: p0, p1, p2, p3, l0, l1, l2, l3
482   ispointincell = .false.
483   xne = g%geoLonBu(i  ,j  ) ; yne = g%geoLatBu(i  ,j  )
484   xnw = g%geoLonBu(i-1,j  ) ; ynw = g%geoLatBu(i-1,j  )
485   xse = g%geoLonBu(i  ,j-1) ; yse = g%geoLatBu(i  ,j-1)
486   xsw = g%geoLonBu(i-1,j-1) ; ysw = g%geoLatBu(i-1,j-1)
487   \textcolor{comment}{! This is a crude calculation that assume a geographic coordinate system}
488   \textcolor{keywordflow}{if} (x<min(xne,xnw,xse,xsw) .or. x>max(xne,xnw,xse,xsw) .or. &
489       y<min(yne,ynw,yse,ysw) .or. y>max(yne,ynw,yse,ysw) ) \textcolor{keywordflow}{then}
490     \textcolor{keywordflow}{return} \textcolor{comment}{! Avoid the more complicated calculation}
491 \textcolor{keywordflow}{  endif}
492   l0 = (x-xsw)*(yse-ysw) - (y-ysw)*(xse-xsw)
493   l1 = (x-xse)*(yne-yse) - (y-yse)*(xne-xse)
494   l2 = (x-xne)*(ynw-yne) - (y-yne)*(xnw-xne)
495   l3 = (x-xnw)*(ysw-ynw) - (y-ynw)*(xsw-xnw)
496 
497   p0 = sign(1., l0) ; \textcolor{keywordflow}{if} (l0 == 0.) p0=0.
498   p1 = sign(1., l1) ; \textcolor{keywordflow}{if} (l1 == 0.) p1=0.
499   p2 = sign(1., l2) ; \textcolor{keywordflow}{if} (l2 == 0.) p2=0.
500   p3 = sign(1., l3) ; \textcolor{keywordflow}{if} (l3 == 0.) p3=0.
501 
502   \textcolor{keywordflow}{if} ( (abs(p0)+abs(p2)) + (abs(p1)+abs(p3)) == abs((p0+p2) + (p1+p3)) ) \textcolor{keywordflow}{then}
503     ispointincell=.true.
504 \textcolor{keywordflow}{  endif}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a889221e5714c3935f276c28dffe5e460}\label{namespacemom__grid_a889221e5714c3935f276c28dffe5e460}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!mom\+\_\+grid\+\_\+end@{mom\+\_\+grid\+\_\+end}}
\index{mom\+\_\+grid\+\_\+end@{mom\+\_\+grid\+\_\+end}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{mom\+\_\+grid\+\_\+end()}{mom\_grid\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::mom\+\_\+grid\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G }\end{DoxyParamCaption})}



Release memory used by the \mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}} and related structures. 


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


Definition at line 598 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
598   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{ !< The horizontal grid type}
599 
600   dealloc\_(g%dxT)  ; dealloc\_(g%dxCu)  ; dealloc\_(g%dxCv)  ; dealloc\_(g%dxBu)
601   dealloc\_(g%IdxT) ; dealloc\_(g%IdxCu) ; dealloc\_(g%IdxCv) ; dealloc\_(g%IdxBu)
602 
603   dealloc\_(g%dyT)  ; dealloc\_(g%dyCu)  ; dealloc\_(g%dyCv)  ; dealloc\_(g%dyBu)
604   dealloc\_(g%IdyT) ; dealloc\_(g%IdyCu) ; dealloc\_(g%IdyCv) ; dealloc\_(g%IdyBu)
605 
606   dealloc\_(g%areaT)  ; dealloc\_(g%IareaT)
607   dealloc\_(g%areaBu) ; dealloc\_(g%IareaBu)
608   dealloc\_(g%areaCu) ; dealloc\_(g%IareaCu)
609   dealloc\_(g%areaCv)  ; dealloc\_(g%IareaCv)
610 
611   dealloc\_(g%mask2dT)  ; dealloc\_(g%mask2dCu)
612   dealloc\_(g%mask2dCv) ; dealloc\_(g%mask2dBu)
613 
614   dealloc\_(g%geoLatT)  ; dealloc\_(g%geoLatCu)
615   dealloc\_(g%geoLatCv) ; dealloc\_(g%geoLatBu)
616   dealloc\_(g%geoLonT)  ; dealloc\_(g%geoLonCu)
617   dealloc\_(g%geoLonCv) ; dealloc\_(g%geoLonBu)
618 
619   dealloc\_(g%dx\_Cv) ; dealloc\_(g%dy\_Cu)
620 
621   dealloc\_(g%bathyT)  ; dealloc\_(g%CoriolisBu)
622   dealloc\_(g%dF\_dx)  ; dealloc\_(g%dF\_dy)
623   dealloc\_(g%sin\_rot) ; dealloc\_(g%cos\_rot)
624 
625   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then}
626     dealloc\_(g%Dblock\_u) ; dealloc\_(g%Dopen\_u)
627     dealloc\_(g%Dblock\_v) ; dealloc\_(g%Dopen\_v)
628 \textcolor{keywordflow}{  endif}
629 
630   \textcolor{keyword}{deallocate}(g%gridLonT) ; \textcolor{keyword}{deallocate}(g%gridLatT)
631   \textcolor{keyword}{deallocate}(g%gridLonB) ; \textcolor{keyword}{deallocate}(g%gridLatB)
632 
633   \textcolor{keyword}{deallocate}(g%Domain%mpp\_domain)
634   \textcolor{keyword}{deallocate}(g%Domain)
635 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a1de9705f83b687ad9a711630a95fe52c}\label{namespacemom__grid_a1de9705f83b687ad9a711630a95fe52c}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!mom\+\_\+grid\+\_\+init@{mom\+\_\+grid\+\_\+init}}
\index{mom\+\_\+grid\+\_\+init@{mom\+\_\+grid\+\_\+init}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{mom\+\_\+grid\+\_\+init()}{mom\_grid\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::mom\+\_\+grid\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(unit\+\_\+scale\+\_\+type), optional, pointer}]{US,  }\item[{type(hor\+\_\+index\+\_\+type), intent(in), optional}]{HI,  }\item[{logical, intent(in), optional}]{global\+\_\+indexing,  }\item[{logical, intent(in), optional}]{bathymetry\+\_\+at\+\_\+vel }\end{DoxyParamCaption})}



M\+O\+M\+\_\+grid\+\_\+init initializes the ocean grid array sizes and grid memory. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The horizontal grid type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file handle\\
\hline
 & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em hi} & A hor\+\_\+index\+\_\+type for array extents\\
\hline
\mbox{\tt in}  & {\em global\+\_\+indexing} & If true use global index values instead of having the data domain on each processor start at 1.\\
\hline
\mbox{\tt in}  & {\em bathymetry\+\_\+at\+\_\+vel} & If true, there are separate values for the ocean bottom depths at velocity points. Otherwise the effects of topography are entirely determined from thickness points. \\
\hline
\end{DoxyParams}


Definition at line 184 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
184   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{          !< The horizontal grid type}
185   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}
186   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer} :: US\textcolor{comment}{ !< A dimensional unit scaling type}
187   \textcolor{keywordtype}{type}(hor\_index\_type), &
188                   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: HI\textcolor{comment}{ !< A hor\_index\_type for array extents}
189   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: global\_indexing\textcolor{comment}{ !< If true use global index}
190 \textcolor{comment}{                             !! values instead of having the data domain on each}
191 \textcolor{comment}{                             !! processor start at 1.}
192   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: bathymetry\_at\_vel\textcolor{comment}{ !< If true, there are}
193 \textcolor{comment}{                             !! separate values for the ocean bottom depths at}
194 \textcolor{comment}{                             !! velocity points.  Otherwise the effects of topography}
195 \textcolor{comment}{                             !! are entirely determined from thickness points.}
196 
197   \textcolor{comment}{! Local variables}
198   \textcolor{keywordtype}{real} :: mean\_SeaLev\_scale
199   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, nk
200   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
201   \textcolor{keywordtype}{integer} :: ied\_max, jed\_max
202   \textcolor{keywordtype}{integer} :: niblock, njblock, nihalo, njhalo, nblocks, n, i, j
203   \textcolor{keywordtype}{logical} :: local\_indexing  \textcolor{comment}{! If false use global index values instead of having}
204                              \textcolor{comment}{! the data domain on each processor start at 1.}
205   \textcolor{comment}{! This include declares and sets the variable "version".}
206 \textcolor{preprocessor}{# include "version\_variable.h"}
207 \textcolor{preprocessor}{}
208   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: ibegin, iend, jbegin, jend
209   \textcolor{keywordtype}{character(len=40)}  :: mod\_nm  = \textcolor{stringliteral}{"MOM\_grid"} \textcolor{comment}{! This module's name.}
210 
211 
212   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
213   \textcolor{keyword}{call }get\_param(param\_file, mod\_nm, \textcolor{stringliteral}{"REFERENCE\_HEIGHT"}, g%Z\_ref, default=0.0, do\_not\_log=.true.)
214   \textcolor{keyword}{call }log\_version(param\_file, mod\_nm, version, &
215                    \textcolor{stringliteral}{"Parameters providing information about the lateral grid."}, &
216                    log\_to\_all=.true., layout=.true., all\_default=(g%Z\_ref==0.0))
217 
218   \textcolor{keyword}{call }get\_param(param\_file, mod\_nm, \textcolor{stringliteral}{"NIBLOCK"}, niblock, \textcolor{stringliteral}{"The number of blocks "}// &
219                  \textcolor{stringliteral}{"in the x-direction on each processor (for openmp)."}, default=1, &
220                  layoutparam=.true.)
221   \textcolor{keyword}{call }get\_param(param\_file, mod\_nm, \textcolor{stringliteral}{"NJBLOCK"}, njblock, \textcolor{stringliteral}{"The number of blocks "}// &
222                  \textcolor{stringliteral}{"in the y-direction on each processor (for openmp)."}, default=1, &
223                  layoutparam=.true.)
224   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(us)) g%US => us ;\textcolor{keywordflow}{ endif}
225 
226   mean\_sealev\_scale = 1.0 ;  \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(g%US)) mean\_sealev\_scale = g%US%m\_to\_Z
227   \textcolor{keyword}{call }get\_param(param\_file, mod\_nm, \textcolor{stringliteral}{"REFERENCE\_HEIGHT"}, g%Z\_ref, &
228                  \textcolor{stringliteral}{"A reference value for geometric height fields, such as bathyT."}, &
229                  units=\textcolor{stringliteral}{"m"}, default=0.0, scale=mean\_sealev\_scale)
230 
231   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(hi)) \textcolor{keywordflow}{then}
232     g%HI = hi
233 
234     g%isc = hi%isc ; g%iec = hi%iec ; g%jsc = hi%jsc ; g%jec = hi%jec
235     g%isd = hi%isd ; g%ied = hi%ied ; g%jsd = hi%jsd ; g%jed = hi%jed
236     g%isg = hi%isg ; g%ieg = hi%ieg ; g%jsg = hi%jsg ; g%jeg = hi%jeg
237 
238     g%IscB = hi%IscB ; g%IecB = hi%IecB ; g%JscB = hi%JscB ; g%JecB = hi%JecB
239     g%IsdB = hi%IsdB ; g%IedB = hi%IedB ; g%JsdB = hi%JsdB ; g%JedB = hi%JedB
240     g%IsgB = hi%IsgB ; g%IegB = hi%IegB ; g%JsgB = hi%JsgB ; g%JegB = hi%JegB
241 
242     g%idg\_offset = hi%idg\_offset ; g%jdg\_offset = hi%jdg\_offset
243     g%isd\_global = g%isd + hi%idg\_offset ; g%jsd\_global = g%jsd + hi%jdg\_offset
244     g%symmetric = hi%symmetric
245   \textcolor{keywordflow}{else}
246     local\_indexing = .true.
247     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(global\_indexing)) local\_indexing = .not.global\_indexing
248     \textcolor{keyword}{call }hor\_index\_init(g%Domain, g%HI, param\_file, &
249                         local\_indexing=local\_indexing)
250 
251     \textcolor{comment}{! get\_domain\_extent ensures that domains start at 1 for compatibility between}
252     \textcolor{comment}{! static and dynamically allocated arrays, unless global\_indexing is true.}
253     \textcolor{keyword}{call }get\_domain\_extent(g%Domain, g%isc, g%iec, g%jsc, g%jec, &
254                            g%isd, g%ied, g%jsd, g%jed, &
255                            g%isg, g%ieg, g%jsg, g%jeg, &
256                            g%idg\_offset, g%jdg\_offset, g%symmetric, &
257                            local\_indexing=local\_indexing)
258     g%isd\_global = g%isd+g%idg\_offset ; g%jsd\_global = g%jsd+g%jdg\_offset
259 \textcolor{keywordflow}{  endif}
260 
261   g%nonblocking\_updates = g%Domain%nonblocking\_updates
262 
263   \textcolor{comment}{! Set array sizes for fields that are discretized at tracer cell boundaries.}
264   g%IscB = g%isc ; g%JscB = g%jsc
265   g%IsdB = g%isd ; g%JsdB = g%jsd
266   g%IsgB = g%isg ; g%JsgB = g%jsg
267   \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
268     g%IscB = g%isc-1 ; g%JscB = g%jsc-1
269     g%IsdB = g%isd-1 ; g%JsdB = g%jsd-1
270     g%IsgB = g%isg-1 ; g%JsgB = g%jsg-1
271 \textcolor{keywordflow}{  endif}
272   g%IecB = g%iec ; g%JecB = g%jec
273   g%IedB = g%ied ; g%JedB = g%jed
274   g%IegB = g%ieg ; g%JegB = g%jeg
275 
276   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"  MOM\_grid.F90, MOM\_grid\_init: allocating metrics"}, 5)
277 
278   \textcolor{keyword}{call }allocate\_metrics(g)
279 
280   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
281   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
282 
283   g%bathymetry\_at\_vel = .false.
284   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(bathymetry\_at\_vel)) g%bathymetry\_at\_vel = bathymetry\_at\_vel
285   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then}
286     alloc\_(g%Dblock\_u(isdb:iedb, jsd:jed)) ; g%Dblock\_u(:,:) = 0.0
287     alloc\_(g%Dopen\_u(isdb:iedb, jsd:jed))  ; g%Dopen\_u(:,:) = 0.0
288     alloc\_(g%Dblock\_v(isd:ied, jsdb:jedb)) ; g%Dblock\_v(:,:) = 0.0
289     alloc\_(g%Dopen\_v(isd:ied, jsdb:jedb))  ; g%Dopen\_v(:,:) = 0.0
290 \textcolor{keywordflow}{  endif}
291 
292 \textcolor{comment}{! setup block indices.}
293   nihalo = g%Domain%nihalo
294   njhalo = g%Domain%njhalo
295   nblocks = niblock * njblock
296   \textcolor{keywordflow}{if} (nblocks < 1) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_grid\_init: "} // &
297        \textcolor{stringliteral}{"nblocks(=NI\_BLOCK*NJ\_BLOCK) must be no less than 1"})
298 
299   \textcolor{keyword}{allocate}(ibegin(niblock), iend(niblock), jbegin(njblock), jend(njblock))
300   \textcolor{keyword}{call }compute\_block\_extent(g%HI%isc,g%HI%iec,niblock,ibegin,iend)
301   \textcolor{keyword}{call }compute\_block\_extent(g%HI%jsc,g%HI%jec,njblock,jbegin,jend)
302   \textcolor{comment}{!-- make sure the last block is the largest.}
303   \textcolor{keywordflow}{do} i = 1, niblock-1
304     \textcolor{keywordflow}{if} (iend(i)-ibegin(i) > iend(niblock)-ibegin(niblock) ) \textcolor{keyword}{call }mom\_error(fatal, &
305        \textcolor{stringliteral}{"MOM\_grid\_init: the last block size in x-direction is not the largest"})
306 \textcolor{keywordflow}{  enddo}
307   \textcolor{keywordflow}{do} j = 1, njblock-1
308     \textcolor{keywordflow}{if} (jend(j)-jbegin(j) > jend(njblock)-jbegin(njblock) ) \textcolor{keyword}{call }mom\_error(fatal, &
309        \textcolor{stringliteral}{"MOM\_grid\_init: the last block size in y-direction is not the largest"})
310 \textcolor{keywordflow}{  enddo}
311 
312   g%nblocks = nblocks
313   \textcolor{keyword}{allocate}(g%Block(nblocks))
314   ied\_max = 1 ; jed\_max = 1
315   \textcolor{keywordflow}{do} n = 1,nblocks
316     \textcolor{comment}{! Copy all information from the array index type describing the local grid.}
317     g%Block(n) = g%HI
318 
319     i = mod((n-1), niblock) + 1
320     j = (n-1)/niblock + 1
321     \textcolor{comment}{!--- isd and jsd are always 1 for each block to permit array reuse.}
322     g%Block(n)%isd = 1 ; g%Block(n)%jsd = 1
323     g%Block(n)%isc = g%Block(n)%isd+nihalo
324     g%Block(n)%jsc = g%Block(n)%jsd+njhalo
325     g%Block(n)%iec = g%Block(n)%isc + iend(i) - ibegin(i)
326     g%Block(n)%jec = g%Block(n)%jsc + jend(j) - jbegin(j)
327     g%Block(n)%ied = g%Block(n)%iec + nihalo
328     g%Block(n)%jed = g%Block(n)%jec + njhalo
329     g%Block(n)%IscB = g%Block(n)%isc; g%Block(n)%IecB = g%Block(n)%iec
330     g%Block(n)%JscB = g%Block(n)%jsc; g%Block(n)%JecB = g%Block(n)%jec
331     \textcolor{comment}{!   For symmetric memory domains, the first block will have the extra point}
332     \textcolor{comment}{! at the lower boundary of its computational domain.}
333     \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
334       \textcolor{keywordflow}{if} (i==1) g%Block(n)%IscB = g%Block(n)%IscB-1
335       \textcolor{keywordflow}{if} (j==1) g%Block(n)%JscB = g%Block(n)%JscB-1
336 \textcolor{keywordflow}{    endif}
337     g%Block(n)%IsdB = g%Block(n)%isd; g%Block(n)%IedB = g%Block(n)%ied
338     g%Block(n)%JsdB = g%Block(n)%jsd; g%Block(n)%JedB = g%Block(n)%jed
339     \textcolor{comment}{!--- For symmetric memory domain, every block will have an extra point}
340     \textcolor{comment}{!--- at the lower boundary of its data domain.}
341     \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
342       g%Block(n)%IsdB = g%Block(n)%IsdB-1
343       g%Block(n)%JsdB = g%Block(n)%JsdB-1
344 \textcolor{keywordflow}{    endif}
345     g%Block(n)%idg\_offset = (ibegin(i) - g%Block(n)%isc) + g%HI%idg\_offset
346     g%Block(n)%jdg\_offset = (jbegin(j) - g%Block(n)%jsc) + g%HI%jdg\_offset
347     \textcolor{comment}{! Find the largest values of ied and jed so that all blocks will have the}
348     \textcolor{comment}{! same size in memory.}
349     ied\_max = max(ied\_max, g%Block(n)%ied)
350     jed\_max = max(jed\_max, g%Block(n)%jed)
351 \textcolor{keywordflow}{  enddo}
352 
353   \textcolor{comment}{! Reset all of the data domain sizes to match the largest for array reuse,}
354   \textcolor{comment}{! recalling that all block have isd=jed=1 for array reuse.}
355   \textcolor{keywordflow}{do} n = 1,nblocks
356     g%Block(n)%ied = ied\_max ; g%Block(n)%IedB = ied\_max
357     g%Block(n)%jed = jed\_max ; g%Block(n)%JedB = jed\_max
358 \textcolor{keywordflow}{  enddo}
359 
360   \textcolor{comment}{!-- do some bounds error checking}
361   \textcolor{keywordflow}{if} ( g%block(nblocks)%ied+g%block(nblocks)%idg\_offset > g%HI%ied + g%HI%idg\_offset ) &
362         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_grid\_init: G%ied\_bk > G%ied"})
363   \textcolor{keywordflow}{if} ( g%block(nblocks)%jed+g%block(nblocks)%jdg\_offset > g%HI%jed + g%HI%jdg\_offset ) &
364         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_grid\_init: G%jed\_bk > G%jed"})
365 
366   \textcolor{keyword}{call }get\_domain\_extent\_dsamp2(g%Domain, g%HId2%isc, g%HId2%iec, g%HId2%jsc, g%HId2%jec,&
367                                           g%HId2%isd, g%HId2%ied, g%HId2%jsd, g%HId2%jed,&
368                                           g%HId2%isg, g%HId2%ieg, g%HId2%jsg, g%HId2%jeg)
369 
370   \textcolor{comment}{! Set array sizes for fields that are discretized at tracer cell boundaries.}
371   g%HId2%IscB = g%HId2%isc ; g%HId2%JscB = g%HId2%jsc
372   g%HId2%IsdB = g%HId2%isd ; g%HId2%JsdB = g%HId2%jsd
373   g%HId2%IsgB = g%HId2%isg ; g%HId2%JsgB = g%HId2%jsg
374   \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
375     g%HId2%IscB = g%HId2%isc-1 ; g%HId2%JscB = g%HId2%jsc-1
376     g%HId2%IsdB = g%HId2%isd-1 ; g%HId2%JsdB = g%HId2%jsd-1
377     g%HId2%IsgB = g%HId2%isg-1 ; g%HId2%JsgB = g%HId2%jsg-1
378 \textcolor{keywordflow}{  endif}
379   g%HId2%IecB = g%HId2%iec ; g%HId2%JecB = g%HId2%jec
380   g%HId2%IedB = g%HId2%ied ; g%HId2%JedB = g%HId2%jed
381   g%HId2%IegB = g%HId2%ieg ; g%HId2%JegB = g%HId2%jeg
382 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a2ef4227cc0bc03d2937270fcc14d7354}\label{namespacemom__grid_a2ef4227cc0bc03d2937270fcc14d7354}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!rescale\+\_\+grid\+\_\+bathymetry@{rescale\+\_\+grid\+\_\+bathymetry}}
\index{rescale\+\_\+grid\+\_\+bathymetry@{rescale\+\_\+grid\+\_\+bathymetry}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{rescale\+\_\+grid\+\_\+bathymetry()}{rescale\_grid\_bathymetry()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::rescale\+\_\+grid\+\_\+bathymetry (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{real, intent(in)}]{m\+\_\+in\+\_\+new\+\_\+units }\end{DoxyParamCaption})}



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


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


Definition at line 388 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
388   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The horizontal grid structure}
389   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: m\_in\_new\_units\textcolor{comment}{ !< The new internal representation of 1 m depth.}
390 
391   \textcolor{comment}{! Local variables}
392   \textcolor{keywordtype}{real} :: rescale
393   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB
394 
395   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
396   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
397 
398   \textcolor{keywordflow}{if} (m\_in\_new\_units == 1.0) \textcolor{keywordflow}{return}
399   \textcolor{keywordflow}{if} (m\_in\_new\_units < 0.0) &
400     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Negative depth units are not permitted."})
401   \textcolor{keywordflow}{if} (m\_in\_new\_units == 0.0) &
402     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"rescale\_grid\_bathymetry: Zero depth units are not permitted."})
403 
404   rescale = 1.0 / m\_in\_new\_units
405   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
406     g%bathyT(i,j) = rescale*g%bathyT(i,j)
407 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
408   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
409     g%Dblock\_u(i,j) = rescale*g%Dblock\_u(i,j) ; g%Dopen\_u(i,j) = rescale*g%Dopen\_u(i,j)
410 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
411   \textcolor{keywordflow}{if} (g%bathymetry\_at\_vel) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
412     g%Dblock\_v(i,j) = rescale*g%Dblock\_v(i,j) ; g%Dopen\_v(i,j) = rescale*g%Dopen\_v(i,j)
413 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
414   g%max\_depth = rescale*g%max\_depth
415 
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a1ed8ca50737525ff437bdb349c8d701f}\label{namespacemom__grid_a1ed8ca50737525ff437bdb349c8d701f}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!set\+\_\+derived\+\_\+metrics@{set\+\_\+derived\+\_\+metrics}}
\index{set\+\_\+derived\+\_\+metrics@{set\+\_\+derived\+\_\+metrics}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{set\+\_\+derived\+\_\+metrics()}{set\_derived\_metrics()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::set\+\_\+derived\+\_\+metrics (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US }\end{DoxyParamCaption})}



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


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


Definition at line 420 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
420   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{  !< The horizontal grid structure}
421   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}
422 \textcolor{comment}{!    Various inverse grid spacings and derived areas are calculated within this}
423 \textcolor{comment}{!  subroutine.}
424   \textcolor{keywordtype}{integer} :: i, j, isd, ied, jsd, jed
425   \textcolor{keywordtype}{integer} :: IsdB, IedB, JsdB, JedB
426 
427   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
428   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
429 
430   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isd,ied
431     \textcolor{keywordflow}{if} (g%dxT(i,j) < 0.0) g%dxT(i,j) = 0.0
432     \textcolor{keywordflow}{if} (g%dyT(i,j) < 0.0) g%dyT(i,j) = 0.0
433     g%IdxT(i,j) = adcroft\_reciprocal(g%dxT(i,j))
434     g%IdyT(i,j) = adcroft\_reciprocal(g%dyT(i,j))
435     g%IareaT(i,j) = adcroft\_reciprocal(g%areaT(i,j))
436 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
437 
438   \textcolor{keywordflow}{do} j=jsd,jed ; \textcolor{keywordflow}{do} i=isdb,iedb
439     \textcolor{keywordflow}{if} (g%dxCu(i,j) < 0.0) g%dxCu(i,j) = 0.0
440     \textcolor{keywordflow}{if} (g%dyCu(i,j) < 0.0) g%dyCu(i,j) = 0.0
441     g%IdxCu(i,j) = adcroft\_reciprocal(g%dxCu(i,j))
442     g%IdyCu(i,j) = adcroft\_reciprocal(g%dyCu(i,j))
443 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
444 
445   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isd,ied
446     \textcolor{keywordflow}{if} (g%dxCv(i,j) < 0.0) g%dxCv(i,j) = 0.0
447     \textcolor{keywordflow}{if} (g%dyCv(i,j) < 0.0) g%dyCv(i,j) = 0.0
448     g%IdxCv(i,j) = adcroft\_reciprocal(g%dxCv(i,j))
449     g%IdyCv(i,j) = adcroft\_reciprocal(g%dyCv(i,j))
450 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
451 
452   \textcolor{keywordflow}{do} j=jsdb,jedb ; \textcolor{keywordflow}{do} i=isdb,iedb
453     \textcolor{keywordflow}{if} (g%dxBu(i,j) < 0.0) g%dxBu(i,j) = 0.0
454     \textcolor{keywordflow}{if} (g%dyBu(i,j) < 0.0) g%dyBu(i,j) = 0.0
455 
456     g%IdxBu(i,j) = adcroft\_reciprocal(g%dxBu(i,j))
457     g%IdyBu(i,j) = adcroft\_reciprocal(g%dyBu(i,j))
458     \textcolor{comment}{! areaBu has usually been set to a positive area elsewhere.}
459     \textcolor{keywordflow}{if} (g%areaBu(i,j) <= 0.0) g%areaBu(i,j) = g%dxBu(i,j) * g%dyBu(i,j)
460     g%IareaBu(i,j) =  adcroft\_reciprocal(g%areaBu(i,j))
461 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__grid_a9d2aac0ba53c9072f5f37d9bf97187b2}\label{namespacemom__grid_a9d2aac0ba53c9072f5f37d9bf97187b2}} 
\index{mom\+\_\+grid@{mom\+\_\+grid}!set\+\_\+first\+\_\+direction@{set\+\_\+first\+\_\+direction}}
\index{set\+\_\+first\+\_\+direction@{set\+\_\+first\+\_\+direction}!mom\+\_\+grid@{mom\+\_\+grid}}
\subsubsection{\texorpdfstring{set\+\_\+first\+\_\+direction()}{set\_first\_direction()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+grid\+::set\+\_\+first\+\_\+direction (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__grid_1_1ocean__grid__type}{ocean\+\_\+grid\+\_\+type}}), intent(inout)}]{G,  }\item[{integer, intent(in)}]{y\+\_\+first }\end{DoxyParamCaption})}



Store an integer indicating which direction to work on first. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em y\+\_\+first} & The first direction to store \\
\hline
\end{DoxyParams}


Definition at line 509 of file M\+O\+M\+\_\+grid.\+F90.


\begin{DoxyCode}
509   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}
510   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)} :: y\_first\textcolor{comment}{ !< The first direction to store}
511 
512   g%first\_direction = y\_first
\end{DoxyCode}
