\hypertarget{namespacemom__diag__remap}{}\doxysection{mom\+\_\+diag\+\_\+remap Module Reference}
\label{namespacemom__diag__remap}\index{mom\_diag\_remap@{mom\_diag\_remap}}


\doxysubsection{Detailed Description}
provides runtime remapping of diagnostics to z star, sigma and rho vertical coordinates. 

The \mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}} type represents a remapping of diagnostics to a particular vertical coordinate. The module is used by the diag mediator module in the following way\+:
\begin{DoxyEnumerate}
\item \mbox{\hyperlink{namespacemom__diag__remap_a3a3c0c9aaae22cbd2390eb42feafd622}{diag\+\_\+remap\+\_\+init()}} is called to initialize a \mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}} instance.
\item \mbox{\hyperlink{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}{diag\+\_\+remap\+\_\+configure\+\_\+axes()}} is called to read the configuration file and set up the vertical coordinate / axes definitions.
\item \mbox{\hyperlink{namespacemom__diag__remap_aaaa62e290958a9364ffd3d73825ce3f2}{diag\+\_\+remap\+\_\+get\+\_\+axes\+\_\+info()}} returns information needed for the diag mediator to define new axes for the remapped diagnostics.
\item \mbox{\hyperlink{namespacemom__diag__remap_aaa0a887dc724438845e88598d439b20a}{diag\+\_\+remap\+\_\+update()}} is called periodically (whenever h, T or S change) to either create or update the target remapping grids.
\item \mbox{\hyperlink{namespacemom__diag__remap_a125ada6654d47c8d9750b620cdd0af7c}{diag\+\_\+remap\+\_\+do\+\_\+remap()}} is called from within a diag post() to do the remapping before the diagnostic is written out. 
\end{DoxyEnumerate}\doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}
\begin{DoxyCompactList}\small\item\em Represents remapping of diagnostics to a particular vertical coordinate. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a3a3c0c9aaae22cbd2390eb42feafd622}{diag\+\_\+remap\+\_\+init}} (remap\+\_\+cs, coord\+\_\+tuple, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Initialize a diagnostic remapping type with the given vertical coordinate. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a3cfd706c08bbd33ad21b77c6b045a9c5}{diag\+\_\+remap\+\_\+end}} (remap\+\_\+cs)
\begin{DoxyCompactList}\small\item\em De-\/init a diagnostic remapping type. Free allocated memory. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a924b98a931082a788dfdabf86d40f295}{diag\+\_\+remap\+\_\+diag\+\_\+registration\+\_\+closed}} (remap\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Inform that all diagnostics have been registered. If \+\_\+set\+\_\+active() has not been called on the remapping control structure will be disabled. This saves time in the case that a vertical coordinate was configured but no diagnostics which use the coordinate appeared in the diag\+\_\+table. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_ab530334ce02c1bedad08ba84507ee5d1}{diag\+\_\+remap\+\_\+set\+\_\+active}} (remap\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Indicate that this remapping type is actually used by the diag manager. If this is never called then the type will be disabled to save time. See further explanation with diag\+\_\+remap\+\_\+registration\+\_\+closed. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}{diag\+\_\+remap\+\_\+configure\+\_\+axes}} (remap\+\_\+cs, GV, US, param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Configure the vertical axes for a diagnostic remapping control structure. Reads a configuration parameters to determine coordinate generation. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_aaaa62e290958a9364ffd3d73825ce3f2}{diag\+\_\+remap\+\_\+get\+\_\+axes\+\_\+info}} (remap\+\_\+cs, nz, id\+\_\+layer, id\+\_\+interface)
\begin{DoxyCompactList}\small\item\em Get layer and interface axes ids for this coordinate Needed when defining axes groups. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__diag__remap_af12d73b4028ee53365d1bdad8a2baa00}{diag\+\_\+remap\+\_\+axes\+\_\+configured}} (remap\+\_\+cs)
\begin{DoxyCompactList}\small\item\em Whether or not the axes for this vertical coordinated has been configured. Configuration is complete when \mbox{\hyperlink{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}{diag\+\_\+remap\+\_\+configure\+\_\+axes()}} has been successfully called. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_aaa0a887dc724438845e88598d439b20a}{diag\+\_\+remap\+\_\+update}} (remap\+\_\+cs, G, GV, US, h, T, S, eqn\+\_\+of\+\_\+state, h\+\_\+target)
\begin{DoxyCompactList}\small\item\em Build/update target vertical grids for diagnostic remapping. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a125ada6654d47c8d9750b620cdd0af7c}{diag\+\_\+remap\+\_\+do\+\_\+remap}} (remap\+\_\+cs, G, GV, h, staggered\+\_\+in\+\_\+x, staggered\+\_\+in\+\_\+y, mask, field, remapped\+\_\+field)
\begin{DoxyCompactList}\small\item\em Remap diagnostic field to alternative vertical grid. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a5b0f7f8140918d3567bcc568cda0932e}{diag\+\_\+remap\+\_\+calc\+\_\+hmask}} (remap\+\_\+cs, G, mask)
\begin{DoxyCompactList}\small\item\em Calculate masks for target grid. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_ae1d52582964ba4213e0fa9b7ea183c39}{vertically\+\_\+reintegrate\+\_\+diag\+\_\+field}} (remap\+\_\+cs, G, h, h\+\_\+target, staggered\+\_\+in\+\_\+x, staggered\+\_\+in\+\_\+y, mask, field, reintegrated\+\_\+field)
\begin{DoxyCompactList}\small\item\em Vertically re-\/grid an already vertically-\/integrated diagnostic field to alternative vertical grid. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_a058317602b134c09ff42005dfe8b2bc0}{vertically\+\_\+interpolate\+\_\+diag\+\_\+field}} (remap\+\_\+cs, G, h, staggered\+\_\+in\+\_\+x, staggered\+\_\+in\+\_\+y, mask, field, interpolated\+\_\+field)
\begin{DoxyCompactList}\small\item\em Vertically interpolate diagnostic field to alternative vertical grid. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__remap_ae649e9dc9616184266d542bce5d9a452}{horizontally\+\_\+average\+\_\+diag\+\_\+field}} (G, GV, h, staggered\+\_\+in\+\_\+x, staggered\+\_\+in\+\_\+y, is\+\_\+layer, is\+\_\+extensive, field, averaged\+\_\+field, averaged\+\_\+mask)
\begin{DoxyCompactList}\small\item\em Horizontally average field. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__diag__remap_af12d73b4028ee53365d1bdad8a2baa00}\label{namespacemom__diag__remap_af12d73b4028ee53365d1bdad8a2baa00}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_axes\_configured@{diag\_remap\_axes\_configured}}
\index{diag\_remap\_axes\_configured@{diag\_remap\_axes\_configured}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_axes\_configured()}{diag\_remap\_axes\_configured()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+axes\+\_\+configured (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs }\end{DoxyParamCaption})}



Whether or not the axes for this vertical coordinated has been configured. Configuration is complete when \mbox{\hyperlink{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}{diag\+\_\+remap\+\_\+configure\+\_\+axes()}} has been successfully called. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coordinate control structure \\
\hline
\end{DoxyParams}


Definition at line 263 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{263   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(in)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coordinate control structure}}
\DoxyCodeLine{264   \textcolor{keywordtype}{logical} :: diag\_remap\_axes\_configured}
\DoxyCodeLine{265 }
\DoxyCodeLine{266   diag\_remap\_axes\_configured = remap\_cs\%configured}
\DoxyCodeLine{267 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a5b0f7f8140918d3567bcc568cda0932e}\label{namespacemom__diag__remap_a5b0f7f8140918d3567bcc568cda0932e}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_calc\_hmask@{diag\_remap\_calc\_hmask}}
\index{diag\_remap\_calc\_hmask@{diag\_remap\_calc\_hmask}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_calc\_hmask()}{diag\_remap\_calc\_hmask()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+calc\+\_\+hmask (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(\+:,\+:,\+:), intent(out)}]{mask }\end{DoxyParamCaption})}



Calculate masks for target grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coodinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em mask} & h-\/point mask for target grid \mbox{[}nondim\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 447 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{447   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),  \textcolor{keywordtype}{intent(in)}  :: remap\_cs\textcolor{comment}{ !< Diagnostic coodinate control structure}}
\DoxyCodeLine{448   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{    !< Ocean grid structure}}
\DoxyCodeLine{449 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(out)} :: mask\textcolor{comment}{ !< h-\/point mask for target grid [nondim]}}
\DoxyCodeLine{450   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{451 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(remap\_cs\%nz)} :: h\_dest \textcolor{comment}{! Destination thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{452   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{453   \textcolor{keywordtype}{logical} :: mask\_vanished\_layers}
\DoxyCodeLine{454 \textcolor{keywordtype}{  real} :: h\_tot      \textcolor{comment}{! Sum of all thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{455 \textcolor{keywordtype}{  real} :: h\_err      \textcolor{comment}{! An estimate of a negligible thickness [H ~> m or kg m-\/2]}}
\DoxyCodeLine{456 }
\DoxyCodeLine{457   \textcolor{keyword}{call }assert(remap\_cs\%initialized, \textcolor{stringliteral}{'diag\_remap\_calc\_hmask: remap\_cs not initialized.'})}
\DoxyCodeLine{458 }
\DoxyCodeLine{459   \textcolor{comment}{! Only z*-\/like diagnostic coordinates should have a 3d mask}}
\DoxyCodeLine{460   mask\_vanished\_layers = (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'ZSTAR'}))}
\DoxyCodeLine{461   mask(:,:,:) = 0.}
\DoxyCodeLine{462 }
\DoxyCodeLine{463   \textcolor{keywordflow}{do} j=g\%jsc-\/1, g\%jec+1 ; \textcolor{keywordflow}{do} i=g\%isc-\/1, g\%iec+1}
\DoxyCodeLine{464     \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{465       \textcolor{keywordflow}{if} (mask\_vanished\_layers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{466         h\_dest(:) = remap\_cs\%h(i,j,:)}
\DoxyCodeLine{467         h\_tot = 0.}
\DoxyCodeLine{468         h\_err = 0.}
\DoxyCodeLine{469         \textcolor{keywordflow}{do} k=1, remap\_cs\%nz}
\DoxyCodeLine{470           h\_tot = h\_tot + h\_dest(k)}
\DoxyCodeLine{471           \textcolor{comment}{! This is an overestimate of how thick a vanished layer might be, that}}
\DoxyCodeLine{472           \textcolor{comment}{! appears due to round-\/off.}}
\DoxyCodeLine{473           h\_err = h\_err + epsilon(h\_tot) * h\_tot}
\DoxyCodeLine{474           \textcolor{comment}{! Mask out vanished layers}}
\DoxyCodeLine{475           \textcolor{keywordflow}{if} (h\_dest(k)<=8.*h\_err) \textcolor{keywordflow}{then}}
\DoxyCodeLine{476             mask(i,j,k) = 0.}
\DoxyCodeLine{477           \textcolor{keywordflow}{else}}
\DoxyCodeLine{478             mask(i,j,k) = 1.}
\DoxyCodeLine{479 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{480 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{481       \textcolor{keywordflow}{else} \textcolor{comment}{! all layers might contain data}}
\DoxyCodeLine{482         mask(i,j,:) = 1.}
\DoxyCodeLine{483 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{484 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{485 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{486 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}\label{namespacemom__diag__remap_a0f3324e591a16e1ef6e3fc7b9f800270}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_configure\_axes@{diag\_remap\_configure\_axes}}
\index{diag\_remap\_configure\_axes@{diag\_remap\_configure\_axes}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_configure\_axes()}{diag\_remap\_configure\_axes()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+configure\+\_\+axes (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Configure the vertical axes for a diagnostic remapping control structure. Reads a configuration parameters to determine coordinate generation. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diag remap control structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file structure \\
\hline
\end{DoxyParams}


Definition at line 188 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{188   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),   \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diag remap control structure}}
\DoxyCodeLine{189   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{ !< ocean vertical grid structure}}
\DoxyCodeLine{190   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{191   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< Parameter file structure}}
\DoxyCodeLine{192   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{193   \textcolor{keywordtype}{integer} :: nzi(4), nzl(4), k}
\DoxyCodeLine{194   \textcolor{keywordtype}{character(len=200)} :: inputdir, string, filename, int\_varname, layer\_varname}
\DoxyCodeLine{195   \textcolor{keywordtype}{character(len=40)}  :: mod  = \textcolor{stringliteral}{"MOM\_diag\_remap"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{196   \textcolor{keywordtype}{character(len=8)}   :: units, expected\_units}
\DoxyCodeLine{197   \textcolor{keywordtype}{character(len=34)}  :: longname, string2}
\DoxyCodeLine{198 }
\DoxyCodeLine{199   \textcolor{keywordtype}{character(len=256)} :: err\_msg}
\DoxyCodeLine{200   \textcolor{keywordtype}{logical} :: ierr}
\DoxyCodeLine{201 }
\DoxyCodeLine{202 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{allocatable}, \textcolor{keywordtype}{dimension(:)} :: interfaces, layers}
\DoxyCodeLine{203 }
\DoxyCodeLine{204   \textcolor{keyword}{call }initialize\_regridding(remap\_cs\%regrid\_cs, gv, us, gv\%max\_depth, param\_file, mod, \&}
\DoxyCodeLine{205            trim(remap\_cs\%vertical\_coord\_name), \textcolor{stringliteral}{"DIAG\_COORD"}, trim(remap\_cs\%diag\_coord\_name))}
\DoxyCodeLine{206   \textcolor{keyword}{call }set\_regrid\_params(remap\_cs\%regrid\_cs, min\_thickness=0., integrate\_downward\_for\_e=.false.)}
\DoxyCodeLine{207 }
\DoxyCodeLine{208   remap\_cs\%nz = get\_regrid\_size(remap\_cs\%regrid\_cs)}
\DoxyCodeLine{209 }
\DoxyCodeLine{210   \textcolor{keywordflow}{if} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'SIGMA'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{211     units = \textcolor{stringliteral}{'nondim'}}
\DoxyCodeLine{212     longname = \textcolor{stringliteral}{'Fraction'}}
\DoxyCodeLine{213   \textcolor{keywordflow}{elseif} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'RHO'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{214     units = \textcolor{stringliteral}{'kg m-\/3'}}
\DoxyCodeLine{215     longname = \textcolor{stringliteral}{'Target Potential Density'}}
\DoxyCodeLine{216   \textcolor{keywordflow}{else}}
\DoxyCodeLine{217     units = \textcolor{stringliteral}{'meters'}}
\DoxyCodeLine{218     longname = \textcolor{stringliteral}{'Depth'}}
\DoxyCodeLine{219 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{220 }
\DoxyCodeLine{221   \textcolor{comment}{! Make axes objects}}
\DoxyCodeLine{222   \textcolor{keyword}{allocate}(interfaces(remap\_cs\%nz+1))}
\DoxyCodeLine{223   \textcolor{keyword}{allocate}(layers(remap\_cs\%nz))}
\DoxyCodeLine{224 }
\DoxyCodeLine{225   interfaces(:) = getcoordinateinterfaces(remap\_cs\%regrid\_cs)}
\DoxyCodeLine{226   layers(:) = 0.5 * ( interfaces(1:remap\_cs\%nz) + interfaces(2:remap\_cs\%nz+1) )}
\DoxyCodeLine{227 }
\DoxyCodeLine{228   remap\_cs\%interface\_axes\_id = diag\_axis\_init(lowercase(trim(remap\_cs\%diag\_coord\_name))//\textcolor{stringliteral}{'\_i'}, \&}
\DoxyCodeLine{229                                               interfaces, trim(units), \textcolor{stringliteral}{'z'}, \&}
\DoxyCodeLine{230                                               trim(longname)//\textcolor{stringliteral}{' at interface'}, direction=-\/1)}
\DoxyCodeLine{231   remap\_cs\%layer\_axes\_id = diag\_axis\_init(lowercase(trim(remap\_cs\%diag\_coord\_name))//\textcolor{stringliteral}{'\_l'}, \&}
\DoxyCodeLine{232                                           layers, trim(units), \textcolor{stringliteral}{'z'}, \&}
\DoxyCodeLine{233                                           trim(longname)//\textcolor{stringliteral}{' at cell center'}, direction=-\/1, \&}
\DoxyCodeLine{234                                           edges=remap\_cs\%interface\_axes\_id)}
\DoxyCodeLine{235 }
\DoxyCodeLine{236   \textcolor{comment}{! Axes have now been configured.}}
\DoxyCodeLine{237   remap\_cs\%configured = .true.}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keyword}{deallocate}(interfaces)}
\DoxyCodeLine{240   \textcolor{keyword}{deallocate}(layers)}
\DoxyCodeLine{241 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a924b98a931082a788dfdabf86d40f295}\label{namespacemom__diag__remap_a924b98a931082a788dfdabf86d40f295}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_diag\_registration\_closed@{diag\_remap\_diag\_registration\_closed}}
\index{diag\_remap\_diag\_registration\_closed@{diag\_remap\_diag\_registration\_closed}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_diag\_registration\_closed()}{diag\_remap\_diag\_registration\_closed()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+diag\+\_\+registration\+\_\+closed (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs }\end{DoxyParamCaption})}



Inform that all diagnostics have been registered. If \+\_\+set\+\_\+active() has not been called on the remapping control structure will be disabled. This saves time in the case that a vertical coordinate was configured but no diagnostics which use the coordinate appeared in the diag\+\_\+table. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diag remapping control structure \\
\hline
\end{DoxyParams}


Definition at line 167 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{167   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diag remapping control structure}}
\DoxyCodeLine{168 }
\DoxyCodeLine{169   \textcolor{keywordflow}{if} (.not. remap\_cs\%used) \textcolor{keywordflow}{then}}
\DoxyCodeLine{170     \textcolor{keyword}{call }diag\_remap\_end(remap\_cs)}
\DoxyCodeLine{171 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{172 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a125ada6654d47c8d9750b620cdd0af7c}\label{namespacemom__diag__remap_a125ada6654d47c8d9750b620cdd0af7c}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_do\_remap@{diag\_remap\_do\_remap}}
\index{diag\_remap\_do\_remap@{diag\_remap\_do\_remap}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_do\_remap()}{diag\_remap\_do\_remap()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+do\+\_\+remap (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+x,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+y,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{mask,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{remapped\+\_\+field }\end{DoxyParamCaption})}



Remap diagnostic field to alternative vertical grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coodinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The current thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+x} & True is the x-\/axis location is at u or q points \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+y} & True is the y-\/axis location is at v or q points \\
\hline
 & {\em mask} & A mask for the field \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em field} & The diagnostic field to be remapped \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em remapped\+\_\+field} & Field remapped to new coordinate \mbox{[}A\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 352 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{352   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),   \textcolor{keywordtype}{intent(in)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coodinate control structure}}
\DoxyCodeLine{353   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{354   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< ocean vertical grid structure}}
\DoxyCodeLine{355 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{  !< The current thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{356   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: staggered\_in\_x\textcolor{comment}{ !< True is the x-\/axis location is at u or q points}}
\DoxyCodeLine{357   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)} :: staggered\_in\_y\textcolor{comment}{ !< True is the y-\/axis location is at v or q points}}
\DoxyCodeLine{358 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{pointer}    :: mask\textcolor{comment}{ !< A mask for the field [nondim]}}
\DoxyCodeLine{359 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)} :: field(:,:,:)\textcolor{comment}{ !< The diagnostic field to be remapped [A]}}
\DoxyCodeLine{360 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(inout)} :: remapped\_field\textcolor{comment}{ !< Field remapped to new coordinate [A]}}
\DoxyCodeLine{361   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{362 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(remap\_cs\%nz)} :: h\_dest \textcolor{comment}{! Destination thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{363 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(size(h,3))} :: h\_src    \textcolor{comment}{! A column of source thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{364 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Negligible thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{365   \textcolor{keywordtype}{integer} :: nz\_src, nz\_dest}
\DoxyCodeLine{366   \textcolor{keywordtype}{integer} :: i, j, k\textcolor{comment}{                !< Grid index}}
\DoxyCodeLine{367   \textcolor{keywordtype}{integer} :: i1, j1\textcolor{comment}{                 !< 1-\/based index}}
\DoxyCodeLine{368   \textcolor{keywordtype}{integer} :: i\_lo, i\_hi, j\_lo, j\_hi\textcolor{comment}{ !< (uv-\/>h) interpolation indices}}
\DoxyCodeLine{369   \textcolor{keywordtype}{integer} :: shift\textcolor{comment}{                  !< Symmetric offset for 1-\/based indexing}}
\DoxyCodeLine{370 }
\DoxyCodeLine{371   \textcolor{keyword}{call }assert(remap\_cs\%initialized, \textcolor{stringliteral}{'diag\_remap\_do\_remap: remap\_cs not initialized.'})}
\DoxyCodeLine{372   \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(field, 3) == \textcolor{keyword}{size}(h, 3), \&}
\DoxyCodeLine{373               \textcolor{stringliteral}{'diag\_remap\_do\_remap: Remap field and thickness z-\/axes do not match.'})}
\DoxyCodeLine{374 }
\DoxyCodeLine{375   \textcolor{keywordflow}{if} (.not.remap\_cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{376     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{377   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{378     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{379   \textcolor{keywordflow}{else}}
\DoxyCodeLine{380     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{381 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{382 }
\DoxyCodeLine{383   nz\_src = \textcolor{keyword}{size}(field,3)}
\DoxyCodeLine{384   nz\_dest = remap\_cs\%nz}
\DoxyCodeLine{385   remapped\_field(:,:,:) = 0.}
\DoxyCodeLine{386 }
\DoxyCodeLine{387   \textcolor{comment}{! Symmetric grid offset under 1-\/based indexing; see header for details.}}
\DoxyCodeLine{388   shift = 0; \textcolor{keywordflow}{if} (g\%symmetric) shift = 1}
\DoxyCodeLine{389 }
\DoxyCodeLine{390   \textcolor{keywordflow}{if} (staggered\_in\_x .and. .not. staggered\_in\_y) \textcolor{keywordflow}{then}}
\DoxyCodeLine{391     \textcolor{comment}{! U-\/points}}
\DoxyCodeLine{392     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{393       \textcolor{keywordflow}{do} i=g\%iscB, g\%iecB}
\DoxyCodeLine{394         i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{395         i\_lo = i1 -\/ shift; i\_hi = i\_lo + 1}
\DoxyCodeLine{396         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{397           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{398 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{399         h\_src(:) = 0.5 * (h(i\_lo,j,:) + h(i\_hi,j,:))}
\DoxyCodeLine{400         h\_dest(:) = 0.5 * (remap\_cs\%h(i\_lo,j,:) + remap\_cs\%h(i\_hi,j,:))}
\DoxyCodeLine{401         \textcolor{keyword}{call }remapping\_core\_h(remap\_cs\%remap\_cs, \&}
\DoxyCodeLine{402                               nz\_src, h\_src(:), field(i1,j,:), \&}
\DoxyCodeLine{403                               nz\_dest, h\_dest(:), remapped\_field(i1,j,:), \&}
\DoxyCodeLine{404                               h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{405 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{406 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{407   \textcolor{keywordflow}{elseif} (staggered\_in\_y .and. .not. staggered\_in\_x) \textcolor{keywordflow}{then}}
\DoxyCodeLine{408     \textcolor{comment}{! V-\/points}}
\DoxyCodeLine{409     \textcolor{keywordflow}{do} j=g\%jscB, g\%jecB}
\DoxyCodeLine{410       j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{411       j\_lo = j1 -\/ shift; j\_hi = j\_lo + 1}
\DoxyCodeLine{412       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{413         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{414           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{415 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{416         h\_src(:) = 0.5 * (h(i,j\_lo,:) + h(i,j\_hi,:))}
\DoxyCodeLine{417         h\_dest(:) = 0.5 * (remap\_cs\%h(i,j\_lo,:) + remap\_cs\%h(i,j\_hi,:))}
\DoxyCodeLine{418         \textcolor{keyword}{call }remapping\_core\_h(remap\_cs\%remap\_cs, \&}
\DoxyCodeLine{419                               nz\_src, h\_src(:), field(i,j1,:), \&}
\DoxyCodeLine{420                               nz\_dest, h\_dest(:), remapped\_field(i,j1,:), \&}
\DoxyCodeLine{421                               h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{422 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{423 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{424   \textcolor{keywordflow}{elseif} ((.not. staggered\_in\_x) .and. (.not. staggered\_in\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{425     \textcolor{comment}{! H-\/points}}
\DoxyCodeLine{426     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{427       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{428         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{429           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{430 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{431         h\_src(:) = h(i,j,:)}
\DoxyCodeLine{432         h\_dest(:) = remap\_cs\%h(i,j,:)}
\DoxyCodeLine{433         \textcolor{keyword}{call }remapping\_core\_h(remap\_cs\%remap\_cs, \&}
\DoxyCodeLine{434                               nz\_src, h\_src(:), field(i,j,:), \&}
\DoxyCodeLine{435                               nz\_dest, h\_dest(:), remapped\_field(i,j,:), \&}
\DoxyCodeLine{436                               h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{437 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{438 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{439   \textcolor{keywordflow}{else}}
\DoxyCodeLine{440     \textcolor{keyword}{call }assert(.false., \textcolor{stringliteral}{'diag\_remap\_do\_remap: Unsupported axis combination'})}
\DoxyCodeLine{441 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{442 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a3cfd706c08bbd33ad21b77c6b045a9c5}\label{namespacemom__diag__remap_a3cfd706c08bbd33ad21b77c6b045a9c5}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_end@{diag\_remap\_end}}
\index{diag\_remap\_end@{diag\_remap\_end}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_end()}{diag\_remap\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs }\end{DoxyParamCaption})}



De-\/init a diagnostic remapping type. Free allocated memory. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diag remapping control structure \\
\hline
\end{DoxyParams}


Definition at line 151 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{151   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diag remapping control structure}}
\DoxyCodeLine{152 }
\DoxyCodeLine{153   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(remap\_cs\%h)) \textcolor{keyword}{deallocate}(remap\_cs\%h)}
\DoxyCodeLine{154   remap\_cs\%configured = .false.}
\DoxyCodeLine{155   remap\_cs\%initialized = .false.}
\DoxyCodeLine{156   remap\_cs\%used = .false.}
\DoxyCodeLine{157   remap\_cs\%nz = 0}
\DoxyCodeLine{158 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_aaaa62e290958a9364ffd3d73825ce3f2}\label{namespacemom__diag__remap_aaaa62e290958a9364ffd3d73825ce3f2}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_get\_axes\_info@{diag\_remap\_get\_axes\_info}}
\index{diag\_remap\_get\_axes\_info@{diag\_remap\_get\_axes\_info}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_get\_axes\_info()}{diag\_remap\_get\_axes\_info()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+get\+\_\+axes\+\_\+info (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs,  }\item[{integer, intent(out)}]{nz,  }\item[{integer, intent(out)}]{id\+\_\+layer,  }\item[{integer, intent(out)}]{id\+\_\+interface }\end{DoxyParamCaption})}



Get layer and interface axes ids for this coordinate Needed when defining axes groups. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coordinate control structure \\
\hline
\mbox{\texttt{ out}}  & {\em nz} & Number of vertical levels for the coordinate \\
\hline
\mbox{\texttt{ out}}  & {\em id\+\_\+layer} & 1D-\/axes id for layer points \\
\hline
\mbox{\texttt{ out}}  & {\em id\+\_\+interface} & 1D-\/axes id for interface points \\
\hline
\end{DoxyParams}


Definition at line 247 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{247   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(in)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coordinate control structure}}
\DoxyCodeLine{248   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)} :: nz\textcolor{comment}{ !< Number of vertical levels for the coordinate}}
\DoxyCodeLine{249   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)} :: id\_layer\textcolor{comment}{ !< 1D-\/axes id for layer points}}
\DoxyCodeLine{250   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(out)} :: id\_interface\textcolor{comment}{ !< 1D-\/axes id for interface points}}
\DoxyCodeLine{251 }
\DoxyCodeLine{252   nz = remap\_cs\%nz}
\DoxyCodeLine{253   id\_layer = remap\_cs\%layer\_axes\_id}
\DoxyCodeLine{254   id\_interface = remap\_cs\%interface\_axes\_id}
\DoxyCodeLine{255 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a3a3c0c9aaae22cbd2390eb42feafd622}\label{namespacemom__diag__remap_a3a3c0c9aaae22cbd2390eb42feafd622}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_init@{diag\_remap\_init}}
\index{diag\_remap\_init@{diag\_remap\_init}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_init()}{diag\_remap\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs,  }\item[{character(len=$\ast$), intent(in)}]{coord\+\_\+tuple,  }\item[{logical, intent(in)}]{answers\+\_\+2018 }\end{DoxyParamCaption})}



Initialize a diagnostic remapping type with the given vertical coordinate. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diag remapping control structure \\
\hline
\mbox{\texttt{ in}}  & {\em coord\+\_\+tuple} & A string in form of M\+O\+D\+U\+L\+E\+\_\+\+S\+U\+F\+F\+IX P\+A\+R\+A\+M\+E\+T\+E\+R\+\_\+\+S\+U\+F\+F\+IX C\+O\+O\+R\+D\+I\+N\+A\+T\+E\+\_\+\+N\+A\+ME \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true, use the order of arithmetic and expressions for remapping that recover the answers from the end of 2018. Otherwise, use more robust forms of the same expressions. \\
\hline
\end{DoxyParams}


Definition at line 129 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{129   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diag remapping control structure}}
\DoxyCodeLine{130   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{intent(in)}    :: coord\_tuple\textcolor{comment}{ !< A string in form of}}
\DoxyCodeLine{131 \textcolor{comment}{                                                      !! MODULE\_SUFFIX PARAMETER\_SUFFIX COORDINATE\_NAME}}
\DoxyCodeLine{132   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true, use the order of arithmetic and expressions}}
\DoxyCodeLine{133 \textcolor{comment}{                                                      !! for remapping that recover the answers from the end of 2018.}}
\DoxyCodeLine{134 \textcolor{comment}{                                                      !! Otherwise, use more robust forms of the same expressions.}}
\DoxyCodeLine{135 }
\DoxyCodeLine{136   remap\_cs\%diag\_module\_suffix = trim(extractword(coord\_tuple, 1))}
\DoxyCodeLine{137   remap\_cs\%diag\_coord\_name = trim(extractword(coord\_tuple, 2))}
\DoxyCodeLine{138   remap\_cs\%vertical\_coord\_name = trim(extractword(coord\_tuple, 3))}
\DoxyCodeLine{139   remap\_cs\%vertical\_coord = coordinatemode(remap\_cs\%vertical\_coord\_name)}
\DoxyCodeLine{140   remap\_cs\%configured = .false.}
\DoxyCodeLine{141   remap\_cs\%initialized = .false.}
\DoxyCodeLine{142   remap\_cs\%used = .false.}
\DoxyCodeLine{143   remap\_cs\%answers\_2018 = answers\_2018}
\DoxyCodeLine{144   remap\_cs\%nz = 0}
\DoxyCodeLine{145 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_ab530334ce02c1bedad08ba84507ee5d1}\label{namespacemom__diag__remap_ab530334ce02c1bedad08ba84507ee5d1}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_set\_active@{diag\_remap\_set\_active}}
\index{diag\_remap\_set\_active@{diag\_remap\_set\_active}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_set\_active()}{diag\_remap\_set\_active()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+set\+\_\+active (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs }\end{DoxyParamCaption})}



Indicate that this remapping type is actually used by the diag manager. If this is never called then the type will be disabled to save time. See further explanation with diag\+\_\+remap\+\_\+registration\+\_\+closed. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diag remapping control structure \\
\hline
\end{DoxyParams}


Definition at line 179 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{179   \textcolor{keywordtype}{type}(diag\_remap\_ctrl), \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diag remapping control structure}}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   remap\_cs\%used = .true.}
\DoxyCodeLine{182 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_aaa0a887dc724438845e88598d439b20a}\label{namespacemom__diag__remap_aaa0a887dc724438845e88598d439b20a}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!diag\_remap\_update@{diag\_remap\_update}}
\index{diag\_remap\_update@{diag\_remap\_update}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{diag\_remap\_update()}{diag\_remap\_update()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::diag\+\_\+remap\+\_\+update (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(inout)}]{remap\+\_\+cs,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{T,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{S,  }\item[{type(eos\+\_\+type), pointer}]{eqn\+\_\+of\+\_\+state,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{h\+\_\+target }\end{DoxyParamCaption})}



Build/update target vertical grids for diagnostic remapping. 

\begin{DoxyNote}{Note}
The target grids need to be updated whenever sea surface height or layer thicknesses changes. In the case of density-\/based coordinates then technically we should also regenerate the target grid whenever T/S change. 
\end{DoxyNote}

\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em remap\+\_\+cs} & Diagnostic coordinate control structure \\
\hline
 & {\em g} & The ocean\textquotesingle{}s grid type \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em h} & New thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em t} & New temperatures \mbox{[}degC\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s} & New salinities \mbox{[}ppt\mbox{]} \\
\hline
 & {\em eqn\+\_\+of\+\_\+state} & A pointer to the equation of state \\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+target} & The new diagnostic thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 276 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{276   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),   \textcolor{keywordtype}{intent(inout)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coordinate control structure}}
\DoxyCodeLine{277   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{pointer}    :: G\textcolor{comment}{  !< The ocean's grid type}}
\DoxyCodeLine{278   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< ocean vertical grid structure}}
\DoxyCodeLine{279   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{  !< New thickness [H ~> m or kg m-\/2]}}
\DoxyCodeLine{281 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)} :: T\textcolor{comment}{  !< New temperatures [degC]}}
\DoxyCodeLine{282 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(in)} :: S\textcolor{comment}{  !< New salinities [ppt]}}
\DoxyCodeLine{283   \textcolor{keywordtype}{type}(EOS\_type),          \textcolor{keywordtype}{pointer}    :: eqn\_of\_state\textcolor{comment}{ !< A pointer to the equation of state}}
\DoxyCodeLine{284 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)},  \textcolor{keywordtype}{intent(inout)} :: h\_target\textcolor{comment}{  !< The new diagnostic thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{285 }
\DoxyCodeLine{286   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{287 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(remap\_cs\%nz + 1)} :: zInterfaces \textcolor{comment}{! Interface positions [H ~> m or kg m-\/2]}}
\DoxyCodeLine{288 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Negligible thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{289   \textcolor{keywordtype}{integer} :: i, j, k, nz}
\DoxyCodeLine{290 }
\DoxyCodeLine{291   \textcolor{comment}{! Note that coordinateMode('LAYER') is never 'configured' so will}}
\DoxyCodeLine{292   \textcolor{comment}{! always return here.}}
\DoxyCodeLine{293   \textcolor{keywordflow}{if} (.not. remap\_cs\%configured) \textcolor{keywordflow}{then}}
\DoxyCodeLine{294     \textcolor{keywordflow}{return}}
\DoxyCodeLine{295 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{296 }
\DoxyCodeLine{297   \textcolor{keywordflow}{if} (.not.remap\_cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{298     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{299   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{300     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{301   \textcolor{keywordflow}{else}}
\DoxyCodeLine{302     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{303 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{304   nz = remap\_cs\%nz}
\DoxyCodeLine{305 }
\DoxyCodeLine{306   \textcolor{keywordflow}{if} (.not. remap\_cs\%initialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{307     \textcolor{comment}{! Initialize remapping and regridding on the first call}}
\DoxyCodeLine{308     \textcolor{keyword}{call }initialize\_remapping(remap\_cs\%remap\_cs, \textcolor{stringliteral}{'PPM\_IH4'}, boundary\_extrapolation=.false., \&}
\DoxyCodeLine{309                               answers\_2018=remap\_cs\%answers\_2018)}
\DoxyCodeLine{310     remap\_cs\%initialized = .true.}
\DoxyCodeLine{311 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{312 }
\DoxyCodeLine{313   \textcolor{comment}{! Calculate remapping thicknesses for different target grids based on}}
\DoxyCodeLine{314   \textcolor{comment}{! nominal/target interface locations. This happens for every call on the}}
\DoxyCodeLine{315   \textcolor{comment}{! assumption that h, T, S has changed.}}
\DoxyCodeLine{316   \textcolor{keywordflow}{do} j=g\%jsc-\/1, g\%jec+1 ; \textcolor{keywordflow}{do} i=g\%isc-\/1, g\%iec+1}
\DoxyCodeLine{317     \textcolor{keywordflow}{if} (g\%mask2dT(i,j)==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{318       h\_target(i,j,:) = 0.}
\DoxyCodeLine{319       cycle}
\DoxyCodeLine{320 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{321 }
\DoxyCodeLine{322     \textcolor{keywordflow}{if} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'ZSTAR'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{323       \textcolor{keyword}{call }build\_zstar\_column(get\_zlike\_cs(remap\_cs\%regrid\_cs), \&}
\DoxyCodeLine{324                               gv\%Z\_to\_H*g\%bathyT(i,j), sum(h(i,j,:)), \&}
\DoxyCodeLine{325                               zinterfaces, zscale=gv\%Z\_to\_H)}
\DoxyCodeLine{326     \textcolor{keywordflow}{elseif} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'SIGMA'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{327       \textcolor{keyword}{call }build\_sigma\_column(get\_sigma\_cs(remap\_cs\%regrid\_cs), \&}
\DoxyCodeLine{328                               gv\%Z\_to\_H*g\%bathyT(i,j), sum(h(i,j,:)), zinterfaces)}
\DoxyCodeLine{329     \textcolor{keywordflow}{elseif} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'RHO'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{330       \textcolor{keyword}{call }build\_rho\_column(get\_rho\_cs(remap\_cs\%regrid\_cs), g\%ke, \&}
\DoxyCodeLine{331                             gv\%Z\_to\_H*g\%bathyT(i,j), h(i,j,:), t(i,j,:), s(i,j,:), \&}
\DoxyCodeLine{332                             eqn\_of\_state, zinterfaces, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{333     \textcolor{keywordflow}{elseif} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'SLIGHT'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{334 \textcolor{comment}{!     call build\_slight\_column(remap\_cs\%regrid\_cs,remap\_cs\%remap\_cs, nz, \&}}
\DoxyCodeLine{335 \textcolor{comment}{!                           GV\%Z\_to\_H*G\%bathyT(i,j), sum(h(i,j,:)), zInterfaces)}}
\DoxyCodeLine{336       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"diag\_remap\_update: SLIGHT coordinate not coded for diagnostics yet!"})}
\DoxyCodeLine{337     \textcolor{keywordflow}{elseif} (remap\_cs\%vertical\_coord == coordinatemode(\textcolor{stringliteral}{'HYCOM1'})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{338 \textcolor{comment}{!     call build\_hycom1\_column(remap\_cs\%regrid\_cs, nz, \&}}
\DoxyCodeLine{339 \textcolor{comment}{!                           GV\%Z\_to\_H*G\%bathyT(i,j), sum(h(i,j,:)), zInterfaces)}}
\DoxyCodeLine{340       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"diag\_remap\_update: HYCOM1 coordinate not coded for diagnostics yet!"})}
\DoxyCodeLine{341 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{342     \textcolor{keywordflow}{do} k = 1,nz}
\DoxyCodeLine{343       h\_target(i,j,k) = zinterfaces(k) -\/ zinterfaces(k+1)}
\DoxyCodeLine{344 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{345 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{346 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_ae649e9dc9616184266d542bce5d9a452}\label{namespacemom__diag__remap_ae649e9dc9616184266d542bce5d9a452}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!horizontally\_average\_diag\_field@{horizontally\_average\_diag\_field}}
\index{horizontally\_average\_diag\_field@{horizontally\_average\_diag\_field}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{horizontally\_average\_diag\_field()}{horizontally\_average\_diag\_field()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::horizontally\+\_\+average\+\_\+diag\+\_\+field (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+x,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+y,  }\item[{logical, intent(in)}]{is\+\_\+layer,  }\item[{logical, intent(in)}]{is\+\_\+extensive,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field,  }\item[{real, dimension(\+:), intent(inout)}]{averaged\+\_\+field,  }\item[{logical, dimension(\+:), intent(inout)}]{averaged\+\_\+mask }\end{DoxyParamCaption})}



Horizontally average field. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The current thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+x} & True if the x-\/axis location is at u or q points \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+y} & True if the y-\/axis location is at v or q points \\
\hline
\mbox{\texttt{ in}}  & {\em is\+\_\+layer} & True if the z-\/axis location is at h points \\
\hline
\mbox{\texttt{ in}}  & {\em is\+\_\+extensive} & True if the z-\/direction is spatially integrated (over layers) \\
\hline
\mbox{\texttt{ in}}  & {\em field} & The diagnostic field to be remapped \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em averaged\+\_\+field} & Field argument horizontally averaged \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em averaged\+\_\+mask} & Mask for horizontally averaged field \mbox{[}nondim\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 656 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{656   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< Ocean grid structure}}
\DoxyCodeLine{657   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< The ocean vertical grid structure}}
\DoxyCodeLine{658 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{ !< The current thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{659   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_x\textcolor{comment}{ !< True if the x-\/axis location is at u or q points}}
\DoxyCodeLine{660   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_y\textcolor{comment}{ !< True if the y-\/axis location is at v or q points}}
\DoxyCodeLine{661   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: is\_layer\textcolor{comment}{ !< True if the z-\/axis location is at h points}}
\DoxyCodeLine{662   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: is\_extensive\textcolor{comment}{ !< True if the z-\/direction is spatially integrated (over layers)}}
\DoxyCodeLine{663 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: field\textcolor{comment}{ !<  The diagnostic field to be remapped [A]}}
\DoxyCodeLine{664 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},  \textcolor{keywordtype}{intent(inout)} :: averaged\_field\textcolor{comment}{ !< Field argument horizontally averaged [A]}}
\DoxyCodeLine{665   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: averaged\_mask\textcolor{comment}{  !< Mask for horizontally averaged field [nondim]}}
\DoxyCodeLine{666 }
\DoxyCodeLine{667   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{668 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(G\%isc:G\%iec, G\%jsc:G\%jec, size(field,3))} :: volume, stuff}
\DoxyCodeLine{669 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(size(field, 3))} :: vol\_sum, stuff\_sum \textcolor{comment}{! nz+1 is needed for interface averages}}
\DoxyCodeLine{670   \textcolor{keywordtype}{type}(EFP\_type), \textcolor{keywordtype}{dimension(2*size(field,3))} :: sums\_EFP \textcolor{comment}{! Sums of volume or stuff by layer}}
\DoxyCodeLine{671 \textcolor{keywordtype}{  real} :: height  \textcolor{comment}{! An average thickness attributed to an velocity point [H ~> m or kg m-\/2]}}
\DoxyCodeLine{672   \textcolor{keywordtype}{integer} :: i, j, k, nz}
\DoxyCodeLine{673   \textcolor{keywordtype}{integer} :: i1, j1\textcolor{comment}{                 !< 1-\/based index}}
\DoxyCodeLine{674 }
\DoxyCodeLine{675   nz = \textcolor{keyword}{size}(field, 3)}
\DoxyCodeLine{676 }
\DoxyCodeLine{677   \textcolor{comment}{! TODO: These averages could potentially be modified to use the function in}}
\DoxyCodeLine{678   \textcolor{comment}{!       the MOM\_spatial\_means module.}}
\DoxyCodeLine{679   \textcolor{comment}{! NOTE: Reproducible sums must be computed in the original MKS units}}
\DoxyCodeLine{680 }
\DoxyCodeLine{681   \textcolor{keywordflow}{if} (staggered\_in\_x .and. .not. staggered\_in\_y) \textcolor{keywordflow}{then}}
\DoxyCodeLine{682     \textcolor{keywordflow}{if} (is\_layer) \textcolor{keywordflow}{then}}
\DoxyCodeLine{683       \textcolor{comment}{! U-\/points}}
\DoxyCodeLine{684       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{685         vol\_sum(k) = 0.}
\DoxyCodeLine{686         stuff\_sum(k) = 0.}
\DoxyCodeLine{687         \textcolor{keywordflow}{if} (is\_extensive) \textcolor{keywordflow}{then}}
\DoxyCodeLine{688           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{689             i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{690             volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCu(i,j)) * g\%mask2dCu(i,j)}
\DoxyCodeLine{691             stuff(i,j,k) = volume(i,j,k) * field(i1,j,k)}
\DoxyCodeLine{692 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{693         \textcolor{keywordflow}{else} \textcolor{comment}{! Intensive}}
\DoxyCodeLine{694           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{695             i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{696             height = 0.5 * (h(i,j,k) + h(i+1,j,k))}
\DoxyCodeLine{697             volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCu(i,j)) \&}
\DoxyCodeLine{698                 * (gv\%H\_to\_m * height) * g\%mask2dCu(i,j)}
\DoxyCodeLine{699             stuff(i,j,k) = volume(i,j,k) * field(i1,j,k)}
\DoxyCodeLine{700 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{701 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{702 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{703     \textcolor{keywordflow}{else} \textcolor{comment}{! Interface}}
\DoxyCodeLine{704       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{705         \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{706           i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{707           volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCu(i,j)) * g\%mask2dCu(i,j)}
\DoxyCodeLine{708           stuff(i,j,k) = volume(i,j,k) * field(i1,j,k)}
\DoxyCodeLine{709 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{710 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{711 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{712   \textcolor{keywordflow}{elseif} (staggered\_in\_y .and. .not. staggered\_in\_x) \textcolor{keywordflow}{then}}
\DoxyCodeLine{713     \textcolor{keywordflow}{if} (is\_layer) \textcolor{keywordflow}{then}}
\DoxyCodeLine{714       \textcolor{comment}{! V-\/points}}
\DoxyCodeLine{715       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{716         \textcolor{keywordflow}{if} (is\_extensive) \textcolor{keywordflow}{then}}
\DoxyCodeLine{717           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{718             j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{719             volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCv(i,j)) * g\%mask2dCv(i,j)}
\DoxyCodeLine{720             stuff(i,j,k) = volume(i,j,k) * field(i,j1,k)}
\DoxyCodeLine{721 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{722         \textcolor{keywordflow}{else} \textcolor{comment}{! Intensive}}
\DoxyCodeLine{723           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{724             j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{725             height = 0.5 * (h(i,j,k) + h(i,j+1,k))}
\DoxyCodeLine{726             volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCv(i,j)) \&}
\DoxyCodeLine{727                 * (gv\%H\_to\_m * height) * g\%mask2dCv(i,j)}
\DoxyCodeLine{728             stuff(i,j,k) = volume(i,j,k) * field(i,j1,k)}
\DoxyCodeLine{729 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{730 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{731 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{732     \textcolor{keywordflow}{else} \textcolor{comment}{! Interface}}
\DoxyCodeLine{733       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{734         \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{735           j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{736           volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaCv(i,j)) * g\%mask2dCv(i,j)}
\DoxyCodeLine{737           stuff(i,j,k) = volume(i,j,k) * field(i,j1,k)}
\DoxyCodeLine{738 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{739 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{740 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{741   \textcolor{keywordflow}{elseif} ((.not. staggered\_in\_x) .and. (.not. staggered\_in\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{742     \textcolor{keywordflow}{if} (is\_layer) \textcolor{keywordflow}{then}}
\DoxyCodeLine{743       \textcolor{comment}{! H-\/points}}
\DoxyCodeLine{744       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{745         \textcolor{keywordflow}{if} (is\_extensive) \textcolor{keywordflow}{then}}
\DoxyCodeLine{746           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{747             \textcolor{keywordflow}{if} (h(i,j,k) > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{748               volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaT(i,j)) * g\%mask2dT(i,j)}
\DoxyCodeLine{749               stuff(i,j,k) = volume(i,j,k) * field(i,j,k)}
\DoxyCodeLine{750             \textcolor{keywordflow}{else}}
\DoxyCodeLine{751               volume(i,j,k) = 0.}
\DoxyCodeLine{752               stuff(i,j,k) = 0.}
\DoxyCodeLine{753 \textcolor{keywordflow}{            endif}}
\DoxyCodeLine{754 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{755         \textcolor{keywordflow}{else} \textcolor{comment}{! Intensive}}
\DoxyCodeLine{756           \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{757             volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaT(i,j)) \&}
\DoxyCodeLine{758                 * (gv\%H\_to\_m * h(i,j,k)) * g\%mask2dT(i,j)}
\DoxyCodeLine{759             stuff(i,j,k) = volume(i,j,k) * field(i,j,k)}
\DoxyCodeLine{760 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{761 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{762 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{763     \textcolor{keywordflow}{else} \textcolor{comment}{! Interface}}
\DoxyCodeLine{764       \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{765         \textcolor{keywordflow}{do} j=g\%jsc, g\%jec ; \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{766           volume(i,j,k) = (g\%US\%L\_to\_m**2 * g\%areaT(i,j)) * g\%mask2dT(i,j)}
\DoxyCodeLine{767           stuff(i,j,k) = volume(i,j,k) * field(i,j,k)}
\DoxyCodeLine{768 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{769 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{770 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{771   \textcolor{keywordflow}{else}}
\DoxyCodeLine{772     \textcolor{keyword}{call }assert(.false., \textcolor{stringliteral}{'horizontally\_average\_diag\_field: Q point averaging is not coded yet.'})}
\DoxyCodeLine{773 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{774 }
\DoxyCodeLine{775   \textcolor{comment}{! Packing the sums into a single array with a single call to sum across PEs saves reduces}}
\DoxyCodeLine{776   \textcolor{comment}{! the costs of communication.}}
\DoxyCodeLine{777   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{778     sums\_efp(2*k-\/1) = reproducing\_sum\_efp(volume(:,:,k), only\_on\_pe=.true.)}
\DoxyCodeLine{779     sums\_efp(2*k)   = reproducing\_sum\_efp(stuff(:,:,k), only\_on\_pe=.true.)}
\DoxyCodeLine{780 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{781   \textcolor{keyword}{call }efp\_sum\_across\_pes(sums\_efp, 2*nz)}
\DoxyCodeLine{782   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{783     vol\_sum(k) = efp\_to\_real(sums\_efp(2*k-\/1))}
\DoxyCodeLine{784     stuff\_sum(k) = efp\_to\_real(sums\_efp(2*k))}
\DoxyCodeLine{785 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{786 }
\DoxyCodeLine{787   averaged\_mask(:) = .true.}
\DoxyCodeLine{788   \textcolor{keywordflow}{do} k=1,nz}
\DoxyCodeLine{789     \textcolor{keywordflow}{if} (vol\_sum(k) > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{790       averaged\_field(k) = stuff\_sum(k) / vol\_sum(k)}
\DoxyCodeLine{791     \textcolor{keywordflow}{else}}
\DoxyCodeLine{792       averaged\_field(k) = 0.}
\DoxyCodeLine{793       averaged\_mask(k) = .false.}
\DoxyCodeLine{794 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{795 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{796 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_a058317602b134c09ff42005dfe8b2bc0}\label{namespacemom__diag__remap_a058317602b134c09ff42005dfe8b2bc0}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!vertically\_interpolate\_diag\_field@{vertically\_interpolate\_diag\_field}}
\index{vertically\_interpolate\_diag\_field@{vertically\_interpolate\_diag\_field}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{vertically\_interpolate\_diag\_field()}{vertically\_interpolate\_diag\_field()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::vertically\+\_\+interpolate\+\_\+diag\+\_\+field (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+x,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+y,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{mask,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{interpolated\+\_\+field }\end{DoxyParamCaption})}



Vertically interpolate diagnostic field to alternative vertical grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coodinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The current thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+x} & True is the x-\/axis location is at u or q points \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+y} & True is the y-\/axis location is at v or q points \\
\hline
 & {\em mask} & A mask for the field \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em field} & The diagnostic field to be remapped \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em interpolated\+\_\+field} & Field argument remapped to alternative coordinate \mbox{[}A\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 573 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{573   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),  \textcolor{keywordtype}{intent(in)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coodinate control structure}}
\DoxyCodeLine{574   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{   !< Ocean grid structure}}
\DoxyCodeLine{575 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{   !< The current thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{576   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_x\textcolor{comment}{ !< True is the x-\/axis location is at u or q points}}
\DoxyCodeLine{577   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_y\textcolor{comment}{ !< True is the y-\/axis location is at v or q points}}
\DoxyCodeLine{578 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}    :: mask\textcolor{comment}{ !< A mask for the field [nondim]}}
\DoxyCodeLine{579 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: field\textcolor{comment}{ !<  The diagnostic field to be remapped [A]}}
\DoxyCodeLine{580 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: interpolated\_field\textcolor{comment}{ !< Field argument remapped to alternative coordinate [A]}}
\DoxyCodeLine{581   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{582 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(remap\_cs\%nz)} :: h\_dest \textcolor{comment}{! Destination thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{583 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(size(h,3))} :: h\_src    \textcolor{comment}{! A column of source thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{584   \textcolor{keywordtype}{integer} :: nz\_src, nz\_dest}
\DoxyCodeLine{585   \textcolor{keywordtype}{integer} :: i, j, k\textcolor{comment}{                !< Grid index}}
\DoxyCodeLine{586   \textcolor{keywordtype}{integer} :: i1, j1\textcolor{comment}{                 !< 1-\/based index}}
\DoxyCodeLine{587   \textcolor{keywordtype}{integer} :: i\_lo, i\_hi, j\_lo, j\_hi\textcolor{comment}{ !< (uv-\/>h) interpolation indices}}
\DoxyCodeLine{588   \textcolor{keywordtype}{integer} :: shift\textcolor{comment}{                  !< Symmetric offset for 1-\/based indexing}}
\DoxyCodeLine{589 }
\DoxyCodeLine{590   \textcolor{keyword}{call }assert(remap\_cs\%initialized, \textcolor{stringliteral}{'vertically\_interpolate\_diag\_field: remap\_cs not initialized.'})}
\DoxyCodeLine{591   \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(field, 3) == \textcolor{keyword}{size}(h, 3)+1, \&}
\DoxyCodeLine{592               \textcolor{stringliteral}{'vertically\_interpolate\_diag\_field: Remap field and thickness z-\/axes do not match.'})}
\DoxyCodeLine{593 }
\DoxyCodeLine{594   interpolated\_field(:,:,:) = 0.}
\DoxyCodeLine{595 }
\DoxyCodeLine{596   nz\_src = \textcolor{keyword}{size}(h,3)}
\DoxyCodeLine{597   nz\_dest = remap\_cs\%nz}
\DoxyCodeLine{598 }
\DoxyCodeLine{599   \textcolor{comment}{! Symmetric grid offset under 1-\/based indexing; see header for details.}}
\DoxyCodeLine{600   shift = 0; \textcolor{keywordflow}{if} (g\%symmetric) shift = 1}
\DoxyCodeLine{601 }
\DoxyCodeLine{602   \textcolor{keywordflow}{if} (staggered\_in\_x .and. .not. staggered\_in\_y) \textcolor{keywordflow}{then}}
\DoxyCodeLine{603     \textcolor{comment}{! U-\/points}}
\DoxyCodeLine{604     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{605       \textcolor{keywordflow}{do} i=g\%iscB, g\%iecB}
\DoxyCodeLine{606         i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{607         i\_lo = i1 -\/ shift; i\_hi = i\_lo + 1}
\DoxyCodeLine{608         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{609           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{610 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{611         h\_src(:) = 0.5 * (h(i\_lo,j,:) + h(i\_hi,j,:))}
\DoxyCodeLine{612         h\_dest(:) = 0.5 * (remap\_cs\%h(i\_lo,j,:) + remap\_cs\%h(i\_hi,j,:))}
\DoxyCodeLine{613         \textcolor{keyword}{call }interpolate\_column(nz\_src, h\_src, field(i1,j,:), \&}
\DoxyCodeLine{614                                 nz\_dest, h\_dest, 0., interpolated\_field(i1,j,:))}
\DoxyCodeLine{615 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{616 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{617   \textcolor{keywordflow}{elseif} (staggered\_in\_y .and. .not. staggered\_in\_x) \textcolor{keywordflow}{then}}
\DoxyCodeLine{618     \textcolor{comment}{! V-\/points}}
\DoxyCodeLine{619     \textcolor{keywordflow}{do} j=g\%jscB, g\%jecB}
\DoxyCodeLine{620       j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{621       j\_lo = j1 -\/ shift; j\_hi = j\_lo + 1}
\DoxyCodeLine{622       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{623         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{624           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{625 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{626         h\_src(:) = 0.5 * (h(i,j\_lo,:) + h(i,j\_hi,:))}
\DoxyCodeLine{627         h\_dest(:) = 0.5 * (remap\_cs\%h(i,j\_lo,:) + remap\_cs\%h(i,j\_hi,:))}
\DoxyCodeLine{628         \textcolor{keyword}{call }interpolate\_column(nz\_src, h\_src, field(i,j1,:), \&}
\DoxyCodeLine{629                                 nz\_dest, h\_dest, 0., interpolated\_field(i,j1,:))}
\DoxyCodeLine{630 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{631 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{632   \textcolor{keywordflow}{elseif} ((.not. staggered\_in\_x) .and. (.not. staggered\_in\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{633     \textcolor{comment}{! H-\/points}}
\DoxyCodeLine{634     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{635       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{636         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{637           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{638 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{639         h\_src(:) = h(i,j,:)}
\DoxyCodeLine{640         h\_dest(:) = remap\_cs\%h(i,j,:)}
\DoxyCodeLine{641         \textcolor{keyword}{call }interpolate\_column(nz\_src, h\_src, field(i,j,:), \&}
\DoxyCodeLine{642                                 nz\_dest, h\_dest, 0., interpolated\_field(i,j,:))}
\DoxyCodeLine{643 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{644 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{645   \textcolor{keywordflow}{else}}
\DoxyCodeLine{646     \textcolor{keyword}{call }assert(.false., \textcolor{stringliteral}{'vertically\_interpolate\_diag\_field: Q point remapping is not coded yet.'})}
\DoxyCodeLine{647 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{648 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__remap_ae1d52582964ba4213e0fa9b7ea183c39}\label{namespacemom__diag__remap_ae1d52582964ba4213e0fa9b7ea183c39}} 
\index{mom\_diag\_remap@{mom\_diag\_remap}!vertically\_reintegrate\_diag\_field@{vertically\_reintegrate\_diag\_field}}
\index{vertically\_reintegrate\_diag\_field@{vertically\_reintegrate\_diag\_field}!mom\_diag\_remap@{mom\_diag\_remap}}
\doxysubsubsection{\texorpdfstring{vertically\_reintegrate\_diag\_field()}{vertically\_reintegrate\_diag\_field()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+remap\+::vertically\+\_\+reintegrate\+\_\+diag\+\_\+field (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__diag__remap_1_1diag__remap__ctrl}{diag\+\_\+remap\+\_\+ctrl}}), intent(in)}]{remap\+\_\+cs,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{h\+\_\+target,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+x,  }\item[{logical, intent(in)}]{staggered\+\_\+in\+\_\+y,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{mask,  }\item[{real, dimension(\+:,\+:,\+:), intent(in)}]{field,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{reintegrated\+\_\+field }\end{DoxyParamCaption})}



Vertically re-\/grid an already vertically-\/integrated diagnostic field to alternative vertical grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em remap\+\_\+cs} & Diagnostic coodinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & The thicknesses of the source grid \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+target} & The thicknesses of the target grid \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+x} & True is the x-\/axis location is at u or q points \\
\hline
\mbox{\texttt{ in}}  & {\em staggered\+\_\+in\+\_\+y} & True is the y-\/axis location is at v or q points \\
\hline
 & {\em mask} & A mask for the field \mbox{[}nondim\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em field} & The diagnostic field to be remapped \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em reintegrated\+\_\+field} & Field argument remapped to alternative coordinate \mbox{[}A\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 492 of file M\+O\+M\+\_\+diag\+\_\+remap.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{492   \textcolor{keywordtype}{type}(diag\_remap\_ctrl),  \textcolor{keywordtype}{intent(in)} :: remap\_cs\textcolor{comment}{ !< Diagnostic coodinate control structure}}
\DoxyCodeLine{493   \textcolor{keywordtype}{type}(ocean\_grid\_type),  \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{        !< Ocean grid structure}}
\DoxyCodeLine{494 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{        !< The thicknesses of the source grid [H ~> m or kg m-\/2]}}
\DoxyCodeLine{495 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: h\_target\textcolor{comment}{ !< The thicknesses of the target grid [H ~> m or kg m-\/2]}}
\DoxyCodeLine{496   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_x\textcolor{comment}{ !< True is the x-\/axis location is at u or q points}}
\DoxyCodeLine{497   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: staggered\_in\_y\textcolor{comment}{ !< True is the y-\/axis location is at v or q points}}
\DoxyCodeLine{498 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer}    :: mask\textcolor{comment}{     !< A mask for the field [nondim]}}
\DoxyCodeLine{499 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(in)} :: field\textcolor{comment}{    !<  The diagnostic field to be remapped [A]}}
\DoxyCodeLine{500 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: reintegrated\_field\textcolor{comment}{ !< Field argument remapped to alternative coordinate [A]}}
\DoxyCodeLine{501   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{502 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(remap\_cs\%nz)} :: h\_dest \textcolor{comment}{! Destination thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{503 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(size(h,3))} :: h\_src    \textcolor{comment}{! A column of source thicknesses [H ~> m or kg m-\/2]}}
\DoxyCodeLine{504   \textcolor{keywordtype}{integer} :: nz\_src, nz\_dest}
\DoxyCodeLine{505   \textcolor{keywordtype}{integer} :: i, j, k\textcolor{comment}{                !< Grid index}}
\DoxyCodeLine{506   \textcolor{keywordtype}{integer} :: i1, j1\textcolor{comment}{                 !< 1-\/based index}}
\DoxyCodeLine{507   \textcolor{keywordtype}{integer} :: i\_lo, i\_hi, j\_lo, j\_hi\textcolor{comment}{ !< (uv-\/>h) interpolation indices}}
\DoxyCodeLine{508   \textcolor{keywordtype}{integer} :: shift\textcolor{comment}{                  !< Symmetric offset for 1-\/based indexing}}
\DoxyCodeLine{509 }
\DoxyCodeLine{510   \textcolor{keyword}{call }assert(remap\_cs\%initialized, \textcolor{stringliteral}{'vertically\_reintegrate\_diag\_field: remap\_cs not initialized.'})}
\DoxyCodeLine{511   \textcolor{keyword}{call }assert(\textcolor{keyword}{size}(field, 3) == \textcolor{keyword}{size}(h, 3), \&}
\DoxyCodeLine{512               \textcolor{stringliteral}{'vertically\_reintegrate\_diag\_field: Remap field and thickness z-\/axes do not match.'})}
\DoxyCodeLine{513 }
\DoxyCodeLine{514   nz\_src = \textcolor{keyword}{size}(field,3)}
\DoxyCodeLine{515   nz\_dest = remap\_cs\%nz}
\DoxyCodeLine{516   reintegrated\_field(:,:,:) = 0.}
\DoxyCodeLine{517 }
\DoxyCodeLine{518   \textcolor{comment}{! Symmetric grid offset under 1-\/based indexing; see header for details.}}
\DoxyCodeLine{519   shift = 0; \textcolor{keywordflow}{if} (g\%symmetric) shift = 1}
\DoxyCodeLine{520 }
\DoxyCodeLine{521   \textcolor{keywordflow}{if} (staggered\_in\_x .and. .not. staggered\_in\_y) \textcolor{keywordflow}{then}}
\DoxyCodeLine{522     \textcolor{comment}{! U-\/points}}
\DoxyCodeLine{523     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{524       \textcolor{keywordflow}{do} i=g\%iscB, g\%iecB}
\DoxyCodeLine{525         i1 = i -\/ g\%isdB + 1}
\DoxyCodeLine{526         i\_lo = i1 -\/ shift; i\_hi = i\_lo + 1}
\DoxyCodeLine{527         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{528           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{529 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{530         h\_src(:) = 0.5 * (h(i\_lo,j,:) + h(i\_hi,j,:))}
\DoxyCodeLine{531         h\_dest(:) = 0.5 * (h\_target(i\_lo,j,:) + h\_target(i\_hi,j,:))}
\DoxyCodeLine{532         \textcolor{keyword}{call }reintegrate\_column(nz\_src, h\_src, field(i1,j,:), \&}
\DoxyCodeLine{533                                 nz\_dest, h\_dest, 0., reintegrated\_field(i1,j,:))}
\DoxyCodeLine{534 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{535 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{536   \textcolor{keywordflow}{elseif} (staggered\_in\_y .and. .not. staggered\_in\_x) \textcolor{keywordflow}{then}}
\DoxyCodeLine{537     \textcolor{comment}{! V-\/points}}
\DoxyCodeLine{538     \textcolor{keywordflow}{do} j=g\%jscB, g\%jecB}
\DoxyCodeLine{539       j1 = j -\/ g\%jsdB + 1}
\DoxyCodeLine{540       j\_lo = j1 -\/ shift; j\_hi = j\_lo + 1}
\DoxyCodeLine{541       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{542         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{543           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{544 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{545         h\_src(:) = 0.5 * (h(i,j\_lo,:) + h(i,j\_hi,:))}
\DoxyCodeLine{546         h\_dest(:) = 0.5 * (h\_target(i,j\_lo,:) + h\_target(i,j\_hi,:))}
\DoxyCodeLine{547         \textcolor{keyword}{call }reintegrate\_column(nz\_src, h\_src, field(i,j1,:), \&}
\DoxyCodeLine{548                                 nz\_dest, h\_dest, 0., reintegrated\_field(i,j1,:))}
\DoxyCodeLine{549 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{550 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{551   \textcolor{keywordflow}{elseif} ((.not. staggered\_in\_x) .and. (.not. staggered\_in\_y)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{552     \textcolor{comment}{! H-\/points}}
\DoxyCodeLine{553     \textcolor{keywordflow}{do} j=g\%jsc, g\%jec}
\DoxyCodeLine{554       \textcolor{keywordflow}{do} i=g\%isc, g\%iec}
\DoxyCodeLine{555         \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(mask)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{556           \textcolor{keywordflow}{if} (mask(i,j,1) == 0.) cycle}
\DoxyCodeLine{557 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{558         h\_src(:) = h(i,j,:)}
\DoxyCodeLine{559         h\_dest(:) = h\_target(i,j,:)}
\DoxyCodeLine{560         \textcolor{keyword}{call }reintegrate\_column(nz\_src, h\_src, field(i,j,:), \&}
\DoxyCodeLine{561                                 nz\_dest, h\_dest, 0., reintegrated\_field(i,j,:))}
\DoxyCodeLine{562 \textcolor{keywordflow}{      enddo}}
\DoxyCodeLine{563 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{564   \textcolor{keywordflow}{else}}
\DoxyCodeLine{565     \textcolor{keyword}{call }assert(.false., \textcolor{stringliteral}{'vertically\_reintegrate\_diag\_field: Q point remapping is not coded yet.'})}
\DoxyCodeLine{566 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{567 }

\end{DoxyCode}
