\hypertarget{namespacemom__hor__index}{}\section{mom\+\_\+hor\+\_\+index Module Reference}
\label{namespacemom__hor__index}\index{mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}}


\subsection{Detailed Description}
Defines the horizontal index type (\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}) used for providing index ranges. 

The \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}} provides the declarations and loop ranges for almost all data with horizontal extent.

Declarations and loop ranges should always be coded with the symmetric memory model in mind. The non-\/symmetric memory mode will then also work, albeit with a different (less efficient) communication pattern.

Using the \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}} HI\+:
\begin{DoxyItemize}
\item declaration of h-\/point data is of the form {\ttfamily h(HI\%isd\+:HI\%ied,HI\%jsd\+:HI\%jed)}
\item declaration of q-\/point data is of the form {\ttfamily q(HI\%IsdB\+:HI\%IedB,HI\%JsdB\+:HI\%JedB)}
\item declaration of u-\/point data is of the form {\ttfamily u(HI\%IsdB\+:HI\%IedB,HI\%jsd\+:HI\%jed)}
\item declaration of v-\/point data is of the form {\ttfamily v(HI\%isd\+:HI\%ied,HI\%JsdB\+:HI\%JedB)}.
\end{DoxyItemize}

For more detail explanation of horizontal indexing see \mbox{\hyperlink{Horizontal_Indexing}{Horizontal indexing and memory}}. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacemom__hor__index_1_1assignment_07_0A_08}{assignment(=)}}
\begin{DoxyCompactList}\small\item\em Copy the contents of one horizontal index type into another. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Container for horizontal index ranges for data, computational and global domains. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__hor__index_a8e3912351dbf2be2659f3561de341f49}{hor\+\_\+index\+\_\+init}} (Domain, HI, param\+\_\+file, local\+\_\+indexing, index\+\_\+offset)
\begin{DoxyCompactList}\small\item\em Sets various index values in a \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__hor__index_a841e01011bd7ebb418e891dad39f0fcc}{hit\+\_\+assign}} (H\+I1, H\+I2)
\begin{DoxyCompactList}\small\item\em H\+I\+T\+\_\+assign copies one \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}} into another. It is accessed via an assignment (=) operator. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__hor__index_a36e9e0a5f546003867db38ae1edbc4fc}{rotate\+\_\+hor\+\_\+index}} (H\+I\+\_\+in, turns, HI)
\begin{DoxyCompactList}\small\item\em Rotate the horizontal index ranges from the input to the output map. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__hor__index_a841e01011bd7ebb418e891dad39f0fcc}\label{namespacemom__hor__index_a841e01011bd7ebb418e891dad39f0fcc}} 
\index{mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}!hit\+\_\+assign@{hit\+\_\+assign}}
\index{hit\+\_\+assign@{hit\+\_\+assign}!mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}}
\subsubsection{\texorpdfstring{hit\+\_\+assign()}{hit\_assign()}}
{\footnotesize\ttfamily subroutine mom\+\_\+hor\+\_\+index\+::hit\+\_\+assign (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(out)}]{H\+I1,  }\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{H\+I2 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



H\+I\+T\+\_\+assign copies one \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}} into another. It is accessed via an assignment (=) operator. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em hi1} & Horizontal index type to copy to\\
\hline
\mbox{\tt in}  & {\em hi2} & Horizontal index type to copy from \\
\hline
\end{DoxyParams}


Definition at line 104 of file M\+O\+M\+\_\+hor\+\_\+index.\+F90.


\begin{DoxyCode}
104   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(out)} :: HI1\textcolor{comment}{ !< Horizontal index type to copy to}
105   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI2\textcolor{comment}{ !< Horizontal index type to copy from}
106   \textcolor{comment}{! This subroutine copies all components of the horizontal array index type}
107   \textcolor{comment}{! variable on the RHS (HI2) to the variable on the LHS (HI1).}
108 
109   hi1%isc = hi2%isc ; hi1%iec = hi2%iec ; hi1%jsc = hi2%jsc ; hi1%jec = hi2%jec
110   hi1%isd = hi2%isd ; hi1%ied = hi2%ied ; hi1%jsd = hi2%jsd ; hi1%jed = hi2%jed
111   hi1%isg = hi2%isg ; hi1%ieg = hi2%ieg ; hi1%jsg = hi2%jsg ; hi1%jeg = hi2%jeg
112 
113   hi1%IscB = hi2%IscB ; hi1%IecB = hi2%IecB ; hi1%JscB = hi2%JscB ; hi1%JecB = hi2%JecB
114   hi1%IsdB = hi2%IsdB ; hi1%IedB = hi2%IedB ; hi1%JsdB = hi2%JsdB ; hi1%JedB = hi2%JedB
115   hi1%IsgB = hi2%IsgB ; hi1%IegB = hi2%IegB ; hi1%JsgB = hi2%JsgB ; hi1%JegB = hi2%JegB
116 
117   hi1%niglobal = hi2%niglobal ; hi1%njglobal = hi2%njglobal
118   hi1%idg\_offset = hi2%idg\_offset ; hi1%jdg\_offset = hi2%jdg\_offset
119   hi1%symmetric = hi2%symmetric
120   hi1%turns = hi2%turns
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__hor__index_a8e3912351dbf2be2659f3561de341f49}\label{namespacemom__hor__index_a8e3912351dbf2be2659f3561de341f49}} 
\index{mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}!hor\+\_\+index\+\_\+init@{hor\+\_\+index\+\_\+init}}
\index{hor\+\_\+index\+\_\+init@{hor\+\_\+index\+\_\+init}!mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}}
\subsubsection{\texorpdfstring{hor\+\_\+index\+\_\+init()}{hor\_index\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+hor\+\_\+index\+::hor\+\_\+index\+\_\+init (\begin{DoxyParamCaption}\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{Domain,  }\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(inout)}]{HI,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{logical, intent(in), optional}]{local\+\_\+indexing,  }\item[{integer, intent(in), optional}]{index\+\_\+offset }\end{DoxyParamCaption})}



Sets various index values in a \mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em domain} & The M\+OM domain from which to extract information.\\
\hline
\mbox{\tt in,out}  & {\em hi} & A horizontal index type to populate with data\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & Parameter file handle\\
\hline
\mbox{\tt in}  & {\em local\+\_\+indexing} & If true, all tracer data domains start at 1\\
\hline
\mbox{\tt in}  & {\em index\+\_\+offset} & A fixed additional offset to all indices \\
\hline
\end{DoxyParams}


Definition at line 64 of file M\+O\+M\+\_\+hor\+\_\+index.\+F90.


\begin{DoxyCode}
64   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: Domain\textcolor{comment}{     !< The MOM domain from which to extract information.}
65   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{intent(inout)} :: HI\textcolor{comment}{         !< A horizontal index type to populate with data}
66   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}
67   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in)}    :: local\_indexing\textcolor{comment}{ !< If true, all tracer data domains start at 1}
68   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in)}    :: index\_offset\textcolor{comment}{   !< A fixed additional offset to all indices}
69 
70 \textcolor{comment}{! This include declares and sets the variable "version".}
71 \textcolor{preprocessor}{#include "version\_variable.h"}
72 \textcolor{preprocessor}{}
73   \textcolor{comment}{! get\_domain\_extent ensures that domains start at 1 for compatibility between}
74   \textcolor{comment}{! static and dynamically allocated arrays.}
75   \textcolor{keyword}{call }get\_domain\_extent(domain, hi%isc, hi%iec, hi%jsc, hi%jec, &
76                          hi%isd, hi%ied, hi%jsd, hi%jed, &
77                          hi%isg, hi%ieg, hi%jsg, hi%jeg, &
78                          hi%idg\_offset, hi%jdg\_offset, hi%symmetric, &
79                          local\_indexing=local\_indexing)
80   \textcolor{keyword}{call }get\_global\_shape(domain, hi%niglobal, hi%njglobal)
81 
82   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
83   \textcolor{keyword}{call }log\_version(param\_file, \textcolor{stringliteral}{"MOM\_hor\_index"}, version, &
84                    \textcolor{stringliteral}{"Sets the horizontal array index types."}, all\_default=.true.)
85 
86   hi%IscB = hi%isc ; hi%JscB = hi%jsc
87   hi%IsdB = hi%isd ; hi%JsdB = hi%jsd
88   hi%IsgB = hi%isg ; hi%JsgB = hi%jsg
89   \textcolor{keywordflow}{if} (hi%symmetric) \textcolor{keywordflow}{then}
90     hi%IscB = hi%isc-1 ; hi%JscB = hi%jsc-1
91     hi%IsdB = hi%isd-1 ; hi%JsdB = hi%jsd-1
92     hi%IsgB = hi%isg-1 ; hi%JsgB = hi%jsg-1
93 \textcolor{keywordflow}{  endif}
94   hi%IecB = hi%iec ; hi%JecB = hi%jec
95   hi%IedB = hi%ied ; hi%JedB = hi%jed
96   hi%IegB = hi%ieg ; hi%JegB = hi%jeg
97 
98   hi%turns = 0
\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__hor__index_a36e9e0a5f546003867db38ae1edbc4fc}\label{namespacemom__hor__index_a36e9e0a5f546003867db38ae1edbc4fc}} 
\index{mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}!rotate\+\_\+hor\+\_\+index@{rotate\+\_\+hor\+\_\+index}}
\index{rotate\+\_\+hor\+\_\+index@{rotate\+\_\+hor\+\_\+index}!mom\+\_\+hor\+\_\+index@{mom\+\_\+hor\+\_\+index}}
\subsubsection{\texorpdfstring{rotate\+\_\+hor\+\_\+index()}{rotate\_hor\_index()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+hor\+\_\+index\+::rotate\+\_\+hor\+\_\+index (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(in)}]{H\+I\+\_\+in,  }\item[{integer, intent(in)}]{turns,  }\item[{type(\mbox{\hyperlink{structmom__hor__index_1_1hor__index__type}{hor\+\_\+index\+\_\+type}}), intent(inout)}]{HI }\end{DoxyParamCaption})}



Rotate the horizontal index ranges from the input to the output map. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em hi\+\_\+in} & Unrotated horizontal indices\\
\hline
\mbox{\tt in}  & {\em turns} & Number of quarter turns\\
\hline
\mbox{\tt in,out}  & {\em hi} & Rotated horizontal indices \\
\hline
\end{DoxyParams}


Definition at line 125 of file M\+O\+M\+\_\+hor\+\_\+index.\+F90.


\begin{DoxyCode}
125   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)} :: HI\_in\textcolor{comment}{   !< Unrotated horizontal indices}
126   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: turns\textcolor{comment}{                !< Number of quarter turns}
127   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(inout)} :: HI\textcolor{comment}{   !< Rotated horizontal indices}
128 
129   \textcolor{keywordflow}{if} (modulo(turns, 2) /= 0) \textcolor{keywordflow}{then}
130     hi%isc = hi\_in%jsc
131     hi%iec = hi\_in%jec
132     hi%jsc = hi\_in%isc
133     hi%jec = hi\_in%iec
134     hi%isd = hi\_in%jsd
135     hi%ied = hi\_in%jed
136     hi%jsd = hi\_in%isd
137     hi%jed = hi\_in%ied
138     hi%isg = hi\_in%jsg
139     hi%ieg = hi\_in%jeg
140     hi%jsg = hi\_in%isg
141     hi%jeg = hi\_in%ieg
142 
143     hi%IscB = hi\_in%JscB
144     hi%IecB = hi\_in%JecB
145     hi%JscB = hi\_in%IscB
146     hi%JecB = hi\_in%IecB
147     hi%IsdB = hi\_in%JsdB
148     hi%IedB = hi\_in%JedB
149     hi%JsdB = hi\_in%IsdB
150     hi%JedB = hi\_in%IedB
151     hi%IsgB = hi\_in%JsgB
152     hi%IegB = hi\_in%JegB
153     hi%JsgB = hi\_in%IsgB
154     hi%JegB = hi\_in%IegB
155 
156     hi%niglobal = hi\_in%njglobal
157     hi%njglobal = hi\_in%niglobal
158     hi%idg\_offset = hi\_in%jdg\_offset
159     hi%jdg\_offset = hi\_in%idg\_offset
160 
161     hi%symmetric = hi\_in%symmetric
162   \textcolor{keywordflow}{else}
163     hi = hi\_in
164 \textcolor{keywordflow}{  endif}
165   hi%turns = hi\_in%turns + turns
\end{DoxyCode}
