\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{\texttt{ out}}  & {\em hi1} & Horizontal index type to copy to \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{104   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(out)} :: HI1\textcolor{comment}{ !< Horizontal index type to copy to}}
\DoxyCodeLine{105   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI2\textcolor{comment}{ !< Horizontal index type to copy from}}
\DoxyCodeLine{106   \textcolor{comment}{! This subroutine copies all components of the horizontal array index type}}
\DoxyCodeLine{107   \textcolor{comment}{! variable on the RHS (HI2) to the variable on the LHS (HI1).}}
\DoxyCodeLine{108 }
\DoxyCodeLine{109   hi1\%isc = hi2\%isc ; hi1\%iec = hi2\%iec ; hi1\%jsc = hi2\%jsc ; hi1\%jec = hi2\%jec}
\DoxyCodeLine{110   hi1\%isd = hi2\%isd ; hi1\%ied = hi2\%ied ; hi1\%jsd = hi2\%jsd ; hi1\%jed = hi2\%jed}
\DoxyCodeLine{111   hi1\%isg = hi2\%isg ; hi1\%ieg = hi2\%ieg ; hi1\%jsg = hi2\%jsg ; hi1\%jeg = hi2\%jeg}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   hi1\%IscB = hi2\%IscB ; hi1\%IecB = hi2\%IecB ; hi1\%JscB = hi2\%JscB ; hi1\%JecB = hi2\%JecB}
\DoxyCodeLine{114   hi1\%IsdB = hi2\%IsdB ; hi1\%IedB = hi2\%IedB ; hi1\%JsdB = hi2\%JsdB ; hi1\%JedB = hi2\%JedB}
\DoxyCodeLine{115   hi1\%IsgB = hi2\%IsgB ; hi1\%IegB = hi2\%IegB ; hi1\%JsgB = hi2\%JsgB ; hi1\%JegB = hi2\%JegB}
\DoxyCodeLine{116 }
\DoxyCodeLine{117   hi1\%niglobal = hi2\%niglobal ; hi1\%njglobal = hi2\%njglobal}
\DoxyCodeLine{118   hi1\%idg\_offset = hi2\%idg\_offset ; hi1\%jdg\_offset = hi2\%jdg\_offset}
\DoxyCodeLine{119   hi1\%symmetric = hi2\%symmetric}
\DoxyCodeLine{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{\texttt{ in}}  & {\em domain} & The M\+OM domain from which to extract information. \\
\hline
\mbox{\texttt{ in,out}}  & {\em hi} & A horizontal index type to populate with data \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle \\
\hline
\mbox{\texttt{ in}}  & {\em local\+\_\+indexing} & If true, all tracer data domains start at 1 \\
\hline
\mbox{\texttt{ 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}{0}
\DoxyCodeLine{64   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: Domain\textcolor{comment}{     !< The MOM domain from which to extract information.}}
\DoxyCodeLine{65   \textcolor{keywordtype}{type}(hor\_index\_type),   \textcolor{keywordtype}{intent(inout)} :: HI\textcolor{comment}{         !< A horizontal index type to populate with data}}
\DoxyCodeLine{66   \textcolor{keywordtype}{type}(param\_file\_type),  \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file handle}}
\DoxyCodeLine{67   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in)}    :: local\_indexing\textcolor{comment}{ !< If true, all tracer data domains start at 1}}
\DoxyCodeLine{68   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in)}    :: index\_offset\textcolor{comment}{   !< A fixed additional offset to all indices}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{71 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{72 \textcolor{preprocessor}{}}
\DoxyCodeLine{73   \textcolor{comment}{! get\_domain\_extent ensures that domains start at 1 for compatibility between}}
\DoxyCodeLine{74   \textcolor{comment}{! static and dynamically allocated arrays.}}
\DoxyCodeLine{75   \textcolor{keyword}{call }get\_domain\_extent(domain, hi\%isc, hi\%iec, hi\%jsc, hi\%jec, \&}
\DoxyCodeLine{76                          hi\%isd, hi\%ied, hi\%jsd, hi\%jed, \&}
\DoxyCodeLine{77                          hi\%isg, hi\%ieg, hi\%jsg, hi\%jeg, \&}
\DoxyCodeLine{78                          hi\%idg\_offset, hi\%jdg\_offset, hi\%symmetric, \&}
\DoxyCodeLine{79                          local\_indexing=local\_indexing)}
\DoxyCodeLine{80   \textcolor{keyword}{call }get\_global\_shape(domain, hi\%niglobal, hi\%njglobal)}
\DoxyCodeLine{81 }
\DoxyCodeLine{82   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{83   \textcolor{keyword}{call }log\_version(param\_file, \textcolor{stringliteral}{"MOM\_hor\_index"}, version, \&}
\DoxyCodeLine{84                    \textcolor{stringliteral}{"Sets the horizontal array index types."}, all\_default=.true.)}
\DoxyCodeLine{85 }
\DoxyCodeLine{86   hi\%IscB = hi\%isc ; hi\%JscB = hi\%jsc}
\DoxyCodeLine{87   hi\%IsdB = hi\%isd ; hi\%JsdB = hi\%jsd}
\DoxyCodeLine{88   hi\%IsgB = hi\%isg ; hi\%JsgB = hi\%jsg}
\DoxyCodeLine{89   \textcolor{keywordflow}{if} (hi\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{90     hi\%IscB = hi\%isc-1 ; hi\%JscB = hi\%jsc-1}
\DoxyCodeLine{91     hi\%IsdB = hi\%isd-1 ; hi\%JsdB = hi\%jsd-1}
\DoxyCodeLine{92     hi\%IsgB = hi\%isg-1 ; hi\%JsgB = hi\%jsg-1}
\DoxyCodeLine{93 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{94   hi\%IecB = hi\%iec ; hi\%JecB = hi\%jec}
\DoxyCodeLine{95   hi\%IedB = hi\%ied ; hi\%JedB = hi\%jed}
\DoxyCodeLine{96   hi\%IegB = hi\%ieg ; hi\%JegB = hi\%jeg}
\DoxyCodeLine{97 }
\DoxyCodeLine{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{\texttt{ in}}  & {\em hi\+\_\+in} & Unrotated horizontal indices \\
\hline
\mbox{\texttt{ in}}  & {\em turns} & Number of quarter turns \\
\hline
\mbox{\texttt{ in,out}}  & {\em hi} & Rotated horizontal indices \\
\hline
\end{DoxyParams}


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


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

\end{DoxyCode}
