\hypertarget{namespacemom__diag__vkernels}{}\doxysection{mom\+\_\+diag\+\_\+vkernels Module Reference}
\label{namespacemom__diag__vkernels}\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}}


\doxysubsection{Detailed Description}
Provides kernels for single-\/column interpolation, re-\/integration (re-\/mapping of integrated quantities) and intensive-\/variable remapping in the vertical. \doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__vkernels_a4f42f472a725a147f8d97a68b2028c5b}{interpolate\+\_\+column}} (nsrc, h\+\_\+src, u\+\_\+src, ndest, h\+\_\+dest, missing\+\_\+value, u\+\_\+dest)
\begin{DoxyCompactList}\small\item\em Linearly interpolate interface data, u\+\_\+src, from grid h\+\_\+src to a grid h\+\_\+dest. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__diag__vkernels_a89369e4bf4b7795f6e384762d11f0d23}{reintegrate\+\_\+column}} (nsrc, h\+\_\+src, uh\+\_\+src, ndest, h\+\_\+dest, missing\+\_\+value, uh\+\_\+dest)
\begin{DoxyCompactList}\small\item\em Conservatively calculate integrated data, uh\+\_\+dest, on grid h\+\_\+dest, from layer-\/integrated data, uh\+\_\+src, on grid h\+\_\+src. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__diag__vkernels_a6001aaa22610f7fd690106fc737775dd}{diag\+\_\+vkernels\+\_\+unit\+\_\+tests}} (verbose)
\begin{DoxyCompactList}\small\item\em Returns true if any unit tests for module M\+O\+M\+\_\+diag\+\_\+vkernels fail. \end{DoxyCompactList}\item 
logical function \mbox{\hyperlink{namespacemom__diag__vkernels_abeef457cda28b20c03a89ad402bcd434}{test\+\_\+interp}} (verbose, missing\+\_\+value, msg, nsrc, h\+\_\+src, u\+\_\+src, ndest, h\+\_\+dest, u\+\_\+true)
\begin{DoxyCompactList}\small\item\em Returns true if a test of \mbox{\hyperlink{namespacemom__diag__vkernels_a4f42f472a725a147f8d97a68b2028c5b}{interpolate\+\_\+column()}} produces the wrong answer. \end{DoxyCompactList}\item 
logical function \mbox{\hyperlink{namespacemom__diag__vkernels_aac7aad5875fcf17273b211c90ac0cbee}{test\+\_\+reintegrate}} (verbose, missing\+\_\+value, msg, nsrc, h\+\_\+src, uh\+\_\+src, ndest, h\+\_\+dest, uh\+\_\+true)
\begin{DoxyCompactList}\small\item\em Returns true if a test of \mbox{\hyperlink{namespacemom__diag__vkernels_a89369e4bf4b7795f6e384762d11f0d23}{reintegrate\+\_\+column()}} produces the wrong answer. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__diag__vkernels_a6001aaa22610f7fd690106fc737775dd}\label{namespacemom__diag__vkernels_a6001aaa22610f7fd690106fc737775dd}} 
\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}!diag\_vkernels\_unit\_tests@{diag\_vkernels\_unit\_tests}}
\index{diag\_vkernels\_unit\_tests@{diag\_vkernels\_unit\_tests}!mom\_diag\_vkernels@{mom\_diag\_vkernels}}
\doxysubsubsection{\texorpdfstring{diag\_vkernels\_unit\_tests()}{diag\_vkernels\_unit\_tests()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+diag\+\_\+vkernels\+::diag\+\_\+vkernels\+\_\+unit\+\_\+tests (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose }\end{DoxyParamCaption})}



Returns true if any unit tests for module M\+O\+M\+\_\+diag\+\_\+vkernels fail. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em verbose} & If true, write results to stdout \\
\hline
\end{DoxyParams}


Definition at line 171 of file M\+O\+M\+\_\+diag\+\_\+vkernels.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{171   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}}
\DoxyCodeLine{172   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{173 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{parameter} :: mv=-\/9.999999999e9 \textcolor{comment}{! Value to use for vanished layers}}
\DoxyCodeLine{174   \textcolor{keywordtype}{logical} :: fail, v}
\DoxyCodeLine{175 }
\DoxyCodeLine{176   v = verbose}
\DoxyCodeLine{177 }
\DoxyCodeLine{178   \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'==== MOM\_diag\_kernels: diag\_vkernels\_unit\_tests =========='}}
\DoxyCodeLine{179   \textcolor{keywordflow}{if} (v) \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'-\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ interpolation tests  -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/'}}
\DoxyCodeLine{180 }
\DoxyCodeLine{181   fail = test\_interp(v,mv,\textcolor{stringliteral}{'Identity: 3 layer'}, \&}
\DoxyCodeLine{182                      3, (/1.,2.,3./), (/1.,2.,3.,4./), \&}
\DoxyCodeLine{183                      3, (/1.,2.,3./), (/1.,2.,3.,4./) )}
\DoxyCodeLine{184   diag\_vkernels\_unit\_tests = fail}
\DoxyCodeLine{185 }
\DoxyCodeLine{186   fail = test\_interp(v,mv,\textcolor{stringliteral}{'A: 3 layer to 2'}, \&}
\DoxyCodeLine{187                      3, (/1.,1.,1./), (/1.,2.,3.,4./), \&}
\DoxyCodeLine{188                      2, (/1.5,1.5/), (/1.,2.5,4./) )}
\DoxyCodeLine{189   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{190 }
\DoxyCodeLine{191   fail = test\_interp(v,mv,\textcolor{stringliteral}{'B: 2 layer to 3'}, \&}
\DoxyCodeLine{192                      2, (/1.5,1.5/), (/1.,4.,7./), \&}
\DoxyCodeLine{193                      3, (/1.,1.,1./), (/1.,3.,5.,7./) )}
\DoxyCodeLine{194   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{195 }
\DoxyCodeLine{196   fail = test\_interp(v,mv,\textcolor{stringliteral}{'C: 3 layer (vanished middle) to 2'}, \&}
\DoxyCodeLine{197                      3, (/1.,0.,2./), (/1.,2.,2.,3./), \&}
\DoxyCodeLine{198                      2, (/1.,2./), (/1.,2.,3./) )}
\DoxyCodeLine{199   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{200 }
\DoxyCodeLine{201   fail = test\_interp(v,mv,\textcolor{stringliteral}{'D: 3 layer (deep) to 3'}, \&}
\DoxyCodeLine{202                      3, (/1.,2.,3./), (/1.,2.,4.,7./), \&}
\DoxyCodeLine{203                      2, (/2.,2./), (/1.,3.,5./) )}
\DoxyCodeLine{204   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{205 }
\DoxyCodeLine{206   fail = test\_interp(v,mv,\textcolor{stringliteral}{'E: 3 layer to 3 (deep)'}, \&}
\DoxyCodeLine{207                      3, (/1.,2.,4./), (/1.,2.,4.,8./), \&}
\DoxyCodeLine{208                      3, (/2.,3.,4./), (/1.,3.,6.,8./) )}
\DoxyCodeLine{209   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{210 }
\DoxyCodeLine{211   fail = test\_interp(v,mv,\textcolor{stringliteral}{'F: 3 layer to 4 with vanished top/botton'}, \&}
\DoxyCodeLine{212                      3, (/1.,2.,4./), (/1.,2.,4.,8./), \&}
\DoxyCodeLine{213                      4, (/0.,2.,5.,0./), (/mv,1.,3.,8.,mv/) )}
\DoxyCodeLine{214   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{215 }
\DoxyCodeLine{216   fail = test\_interp(v,mv,\textcolor{stringliteral}{'Fs: 3 layer to 4 with vanished top/botton (shallow)'}, \&}
\DoxyCodeLine{217                      3, (/1.,2.,4./), (/1.,2.,4.,8./), \&}
\DoxyCodeLine{218                      4, (/0.,2.,4.,0./), (/mv,1.,3.,7.,mv/) )}
\DoxyCodeLine{219   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{220 }
\DoxyCodeLine{221   fail = test\_interp(v,mv,\textcolor{stringliteral}{'Fd: 3 layer to 4 with vanished top/botton (deep)'}, \&}
\DoxyCodeLine{222                      3, (/1.,2.,4./), (/1.,2.,4.,8./), \&}
\DoxyCodeLine{223                      4, (/0.,2.,6.,0./), (/mv,1.,3.,8.,mv/) )}
\DoxyCodeLine{224   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{225 }
\DoxyCodeLine{226   \textcolor{keywordflow}{if} (v) \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'-\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ reintegration tests  -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/ -\/'}}
\DoxyCodeLine{227 }
\DoxyCodeLine{228   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'Identity: 3 layer'}, \&}
\DoxyCodeLine{229                      3, (/1.,2.,3./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{230                      3, (/1.,2.,3./), (/-\/5.,2.,1./) )}
\DoxyCodeLine{231   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{232 }
\DoxyCodeLine{233   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'A: 3 layer to 2'}, \&}
\DoxyCodeLine{234                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{235                      2, (/3.,3./), (/-\/4.,2./) )}
\DoxyCodeLine{236   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{237 }
\DoxyCodeLine{238   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'A: 3 layer to 2 (deep)'}, \&}
\DoxyCodeLine{239                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{240                      2, (/3.,4./), (/-\/4.,2./) )}
\DoxyCodeLine{241   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{242 }
\DoxyCodeLine{243   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'A: 3 layer to 2 (shallow)'}, \&}
\DoxyCodeLine{244                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{245                      2, (/3.,2./), (/-\/4.,1.5/) )}
\DoxyCodeLine{246   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{247 }
\DoxyCodeLine{248   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'B: 3 layer to 4 with vanished top/bottom'}, \&}
\DoxyCodeLine{249                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{250                      4, (/0.,3.,3.,0./), (/0.,-\/4.,2.,0./) )}
\DoxyCodeLine{251   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'C: 3 layer to 4 with vanished top//middle/bottom'}, \&}
\DoxyCodeLine{254                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{255                      5, (/0.,3.,0.,3.,0./), (/0.,-\/4.,0.,2.,0./) )}
\DoxyCodeLine{256   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{257 }
\DoxyCodeLine{258   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'D: 3 layer to 3 (vanished)'}, \&}
\DoxyCodeLine{259                      3, (/2.,2.,2./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{260                      3, (/0.,0.,0./), (/0.,0.,0./) )}
\DoxyCodeLine{261   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{262 }
\DoxyCodeLine{263   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'D: 3 layer (vanished) to 3'}, \&}
\DoxyCodeLine{264                      3, (/0.,0.,0./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{265                      3, (/2.,2.,2./), (/mv, mv, mv/) )}
\DoxyCodeLine{266   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{267 }
\DoxyCodeLine{268   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'D: 3 layer (vanished) to 3 (vanished)'}, \&}
\DoxyCodeLine{269                      3, (/0.,0.,0./), (/-\/5.,2.,1./), \&}
\DoxyCodeLine{270                      3, (/0.,0.,0./), (/mv, mv, mv/) )}
\DoxyCodeLine{271   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{272 }
\DoxyCodeLine{273   fail = test\_reintegrate(v,mv,\textcolor{stringliteral}{'D: 3 layer (vanished) to 3 (vanished)'}, \&}
\DoxyCodeLine{274                      3, (/0.,0.,0./), (/0.,0.,0./), \&}
\DoxyCodeLine{275                      3, (/0.,0.,0./), (/mv, mv, mv/) )}
\DoxyCodeLine{276   diag\_vkernels\_unit\_tests = diag\_vkernels\_unit\_tests .or. fail}
\DoxyCodeLine{277 }
\DoxyCodeLine{278   \textcolor{keywordflow}{if} (.not. fail) \textcolor{keyword}{write}(stdout,*) \textcolor{stringliteral}{'Pass'}}
\DoxyCodeLine{279 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__vkernels_a4f42f472a725a147f8d97a68b2028c5b}\label{namespacemom__diag__vkernels_a4f42f472a725a147f8d97a68b2028c5b}} 
\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}!interpolate\_column@{interpolate\_column}}
\index{interpolate\_column@{interpolate\_column}!mom\_diag\_vkernels@{mom\_diag\_vkernels}}
\doxysubsubsection{\texorpdfstring{interpolate\_column()}{interpolate\_column()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+vkernels\+::interpolate\+\_\+column (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{nsrc,  }\item[{real, dimension(nsrc), intent(in)}]{h\+\_\+src,  }\item[{real, dimension(nsrc+1), intent(in)}]{u\+\_\+src,  }\item[{integer, intent(in)}]{ndest,  }\item[{real, dimension(ndest), intent(in)}]{h\+\_\+dest,  }\item[{real, intent(in)}]{missing\+\_\+value,  }\item[{real, dimension(ndest+1), intent(inout)}]{u\+\_\+dest }\end{DoxyParamCaption})}



Linearly interpolate interface data, u\+\_\+src, from grid h\+\_\+src to a grid h\+\_\+dest. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nsrc} & Number of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+src} & Thickness of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+src} & Values at source cell interfaces \\
\hline
\mbox{\texttt{ in}}  & {\em ndest} & Number of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+dest} & Thickness of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em missing\+\_\+value} & Value to assign in vanished cells \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+dest} & Interpolated value at destination cell interfaces \\
\hline
\end{DoxyParams}


Definition at line 19 of file M\+O\+M\+\_\+diag\+\_\+vkernels.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{19   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)}    :: nsrc\textcolor{comment}{ !< Number of source cells}}
\DoxyCodeLine{20 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},    \textcolor{keywordtype}{intent(in)}    :: h\_src\textcolor{comment}{ !< Thickness of source cells}}
\DoxyCodeLine{21 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc+1)},  \textcolor{keywordtype}{intent(in)}    :: u\_src\textcolor{comment}{ !< Values at source cell interfaces}}
\DoxyCodeLine{22   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)}    :: ndest\textcolor{comment}{ !< Number of destination cells}}
\DoxyCodeLine{23 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)},   \textcolor{keywordtype}{intent(in)}    :: h\_dest\textcolor{comment}{ !< Thickness of destination cells}}
\DoxyCodeLine{24 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: missing\_value\textcolor{comment}{ !< Value to assign in vanished cells}}
\DoxyCodeLine{25 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest+1)}, \textcolor{keywordtype}{intent(inout)} :: u\_dest\textcolor{comment}{ !< Interpolated value at destination cell interfaces}}
\DoxyCodeLine{26   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{27 \textcolor{keywordtype}{  real} :: x\_dest \textcolor{comment}{! Relative position of target interface}}
\DoxyCodeLine{28 \textcolor{keywordtype}{  real} :: dh \textcolor{comment}{! Source cell thickness}}
\DoxyCodeLine{29 \textcolor{keywordtype}{  real} :: u1, u2 \textcolor{comment}{! Values to interpolate between}}
\DoxyCodeLine{30 \textcolor{keywordtype}{  real} :: weight\_a, weight\_b \textcolor{comment}{! Weights for interpolation}}
\DoxyCodeLine{31   \textcolor{keywordtype}{integer} :: k\_src, k\_dest \textcolor{comment}{! Index of cell in src and dest columns}}
\DoxyCodeLine{32   \textcolor{keywordtype}{logical} :: still\_vanished \textcolor{comment}{! Used for figuring out what to mask as missing}}
\DoxyCodeLine{33 }
\DoxyCodeLine{34   \textcolor{comment}{! Initial values for the loop}}
\DoxyCodeLine{35   still\_vanished = .true.}
\DoxyCodeLine{36 }
\DoxyCodeLine{37   \textcolor{comment}{! The following forces the "do while" loop to do one cycle that will set u1, u2, dh.}}
\DoxyCodeLine{38   k\_src = 0}
\DoxyCodeLine{39   dh = 0.}
\DoxyCodeLine{40   x\_dest = 0.}
\DoxyCodeLine{41 }
\DoxyCodeLine{42   \textcolor{keywordflow}{do} k\_dest=1, ndest+1}
\DoxyCodeLine{43     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (dh<=x\_dest .and. k\_src<nsrc)}
\DoxyCodeLine{44       \textcolor{comment}{! Move positions pointers forward until the interval 0 .. dh spans x\_dest.}}
\DoxyCodeLine{45       x\_dest = x\_dest -\/ dh}
\DoxyCodeLine{46       k\_src = k\_src + 1}
\DoxyCodeLine{47       dh = h\_src(k\_src) \textcolor{comment}{! Thickness of layer k\_src}}
\DoxyCodeLine{48 }
\DoxyCodeLine{49       \textcolor{comment}{! Values that will be used for the interpolation.}}
\DoxyCodeLine{50       u1 = u\_src(k\_src) \textcolor{comment}{! Value on left of source cell}}
\DoxyCodeLine{51       u2 = u\_src(k\_src+1) \textcolor{comment}{! Value on right of source cell}}
\DoxyCodeLine{52 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{53 }
\DoxyCodeLine{54     \textcolor{keywordflow}{if} (dh>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{55       weight\_a = max(0., ( dh -\/ x\_dest ) / dh) \textcolor{comment}{! Weight of u1}}
\DoxyCodeLine{56       weight\_b = min(1., x\_dest / dh) \textcolor{comment}{! Weight of u2}}
\DoxyCodeLine{57       u\_dest(k\_dest) = weight\_a * u1 + weight\_b * u2 \textcolor{comment}{! Linear interpolation between u1 and u2}}
\DoxyCodeLine{58     \textcolor{keywordflow}{else}}
\DoxyCodeLine{59       u\_dest(k\_dest) = 0.5 * ( u1 + u2 ) \textcolor{comment}{! For a vanished layer we need to do something reasonable...}}
\DoxyCodeLine{60 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{61 }
\DoxyCodeLine{62     \textcolor{comment}{! Mask vanished layers at the surface which would be under an ice-\/shelf.}}
\DoxyCodeLine{63     \textcolor{comment}{! TODO: Need to figure out what to do for an isopycnal coordinate diagnostic that could}}
\DoxyCodeLine{64     \textcolor{comment}{!       also have vanished layers at the surface.}}
\DoxyCodeLine{65     \textcolor{keywordflow}{if} (k\_dest<=ndest) \textcolor{keywordflow}{then}}
\DoxyCodeLine{66       x\_dest = x\_dest + h\_dest(k\_dest) \textcolor{comment}{! Position of interface k\_dest+1}}
\DoxyCodeLine{67       \textcolor{keywordflow}{if} (still\_vanished .and. h\_dest(k\_dest)==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{68         \textcolor{comment}{! When the layer k\_dest is vanished and all layers above are also vanished, the k\_dest}}
\DoxyCodeLine{69         \textcolor{comment}{! interface value should be missing.}}
\DoxyCodeLine{70         u\_dest(k\_dest) = missing\_value}
\DoxyCodeLine{71       \textcolor{keywordflow}{else}}
\DoxyCodeLine{72         still\_vanished = .false.}
\DoxyCodeLine{73 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{74 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{75 }
\DoxyCodeLine{76 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{77 }
\DoxyCodeLine{78   \textcolor{comment}{! Mask vanished layers on topography}}
\DoxyCodeLine{79   still\_vanished = .true.}
\DoxyCodeLine{80   \textcolor{keywordflow}{do} k\_dest=ndest, 1, -\/1}
\DoxyCodeLine{81     \textcolor{keywordflow}{if} (still\_vanished .and. h\_dest(k\_dest)==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{82       \textcolor{comment}{! When the layer k\_dest is vanished and all layers below are also vanished, the k\_dest+1}}
\DoxyCodeLine{83       \textcolor{comment}{! interface value should be missing.}}
\DoxyCodeLine{84       u\_dest(k\_dest+1) = missing\_value}
\DoxyCodeLine{85     \textcolor{keywordflow}{else}}
\DoxyCodeLine{86       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{87 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{88 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{89 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__vkernels_a89369e4bf4b7795f6e384762d11f0d23}\label{namespacemom__diag__vkernels_a89369e4bf4b7795f6e384762d11f0d23}} 
\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}!reintegrate\_column@{reintegrate\_column}}
\index{reintegrate\_column@{reintegrate\_column}!mom\_diag\_vkernels@{mom\_diag\_vkernels}}
\doxysubsubsection{\texorpdfstring{reintegrate\_column()}{reintegrate\_column()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+diag\+\_\+vkernels\+::reintegrate\+\_\+column (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{nsrc,  }\item[{real, dimension(nsrc), intent(in)}]{h\+\_\+src,  }\item[{real, dimension(nsrc), intent(in)}]{uh\+\_\+src,  }\item[{integer, intent(in)}]{ndest,  }\item[{real, dimension(ndest), intent(in)}]{h\+\_\+dest,  }\item[{real, intent(in)}]{missing\+\_\+value,  }\item[{real, dimension(ndest), intent(inout)}]{uh\+\_\+dest }\end{DoxyParamCaption})}



Conservatively calculate integrated data, uh\+\_\+dest, on grid h\+\_\+dest, from layer-\/integrated data, uh\+\_\+src, on grid h\+\_\+src. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em nsrc} & Number of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+src} & Thickness of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em uh\+\_\+src} & Values at source cell interfaces \\
\hline
\mbox{\texttt{ in}}  & {\em ndest} & Number of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+dest} & Thickness of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em missing\+\_\+value} & Value to assign in vanished cells \\
\hline
\mbox{\texttt{ in,out}}  & {\em uh\+\_\+dest} & Interpolated value at destination cell interfaces \\
\hline
\end{DoxyParams}


Definition at line 94 of file M\+O\+M\+\_\+diag\+\_\+vkernels.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{94   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}    :: nsrc\textcolor{comment}{ !< Number of source cells}}
\DoxyCodeLine{95 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},  \textcolor{keywordtype}{intent(in)}    :: h\_src\textcolor{comment}{ !< Thickness of source cells}}
\DoxyCodeLine{96 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},  \textcolor{keywordtype}{intent(in)}    :: uh\_src\textcolor{comment}{ !< Values at source cell interfaces}}
\DoxyCodeLine{97   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}    :: ndest\textcolor{comment}{ !< Number of destination cells}}
\DoxyCodeLine{98 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)}, \textcolor{keywordtype}{intent(in)}    :: h\_dest\textcolor{comment}{ !< Thickness of destination cells}}
\DoxyCodeLine{99 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)}    :: missing\_value\textcolor{comment}{ !< Value to assign in vanished cells}}
\DoxyCodeLine{100 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)}, \textcolor{keywordtype}{intent(inout)} :: uh\_dest\textcolor{comment}{ !< Interpolated value at destination cell interfaces}}
\DoxyCodeLine{101   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{102 \textcolor{keywordtype}{  real} :: x\_dest \textcolor{comment}{! Relative position of target interface}}
\DoxyCodeLine{103 \textcolor{keywordtype}{  real} :: h\_src\_rem, h\_dest\_rem, dh \textcolor{comment}{! Incremental thicknesses}}
\DoxyCodeLine{104 \textcolor{keywordtype}{  real} :: uh\_src\_rem, uh\_dest\_rem, duh \textcolor{comment}{! Incremental amounts of stuff}}
\DoxyCodeLine{105   \textcolor{keywordtype}{integer} :: k\_src, k\_dest \textcolor{comment}{! Index of cell in src and dest columns}}
\DoxyCodeLine{106   \textcolor{keywordtype}{integer} :: iter}
\DoxyCodeLine{107   \textcolor{keywordtype}{logical} :: src\_ran\_out, src\_exists}
\DoxyCodeLine{108 }
\DoxyCodeLine{109   uh\_dest(:) = missing\_value}
\DoxyCodeLine{110 }
\DoxyCodeLine{111   k\_src = 0}
\DoxyCodeLine{112   k\_dest = 0}
\DoxyCodeLine{113   h\_dest\_rem = 0.}
\DoxyCodeLine{114   h\_src\_rem = 0.}
\DoxyCodeLine{115   src\_ran\_out = .false.}
\DoxyCodeLine{116   src\_exists = .false.}
\DoxyCodeLine{117 }
\DoxyCodeLine{118   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while}(.true.)}
\DoxyCodeLine{119     \textcolor{keywordflow}{if} (h\_src\_rem==0. .and. k\_src<nsrc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{120       \textcolor{comment}{! Supply is empty so move to the next source cell}}
\DoxyCodeLine{121       k\_src = k\_src + 1}
\DoxyCodeLine{122       h\_src\_rem = h\_src(k\_src)}
\DoxyCodeLine{123       uh\_src\_rem = uh\_src(k\_src)}
\DoxyCodeLine{124       \textcolor{keywordflow}{if} (h\_src\_rem==0.) cycle}
\DoxyCodeLine{125       src\_exists = .true. \textcolor{comment}{! This stops us masking out the entire column}}
\DoxyCodeLine{126 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{127     \textcolor{keywordflow}{if} (h\_dest\_rem==0. .and. k\_dest<ndest) \textcolor{keywordflow}{then}}
\DoxyCodeLine{128       \textcolor{comment}{! Sink has no capacity so move to the next destination cell}}
\DoxyCodeLine{129       k\_dest = k\_dest + 1}
\DoxyCodeLine{130       h\_dest\_rem = h\_dest(k\_dest)}
\DoxyCodeLine{131       uh\_dest(k\_dest) = 0.}
\DoxyCodeLine{132       \textcolor{keywordflow}{if} (h\_dest\_rem==0.) cycle}
\DoxyCodeLine{133 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{134     \textcolor{keywordflow}{if} (k\_src==nsrc .and. h\_src\_rem==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{135       \textcolor{keywordflow}{if} (src\_ran\_out) \textcolor{keywordflow}{exit} \textcolor{comment}{! This is the second time implying there is no more src}}
\DoxyCodeLine{136       src\_ran\_out = .true.}
\DoxyCodeLine{137       cycle}
\DoxyCodeLine{138 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{139     duh = 0.}
\DoxyCodeLine{140     \textcolor{keywordflow}{if} (h\_src\_rem<h\_dest\_rem) \textcolor{keywordflow}{then}}
\DoxyCodeLine{141       \textcolor{comment}{! The source cell is fully within the destination cell}}
\DoxyCodeLine{142       dh = h\_src\_rem}
\DoxyCodeLine{143       \textcolor{keywordflow}{if} (dh>0.) duh = uh\_src\_rem}
\DoxyCodeLine{144       h\_src\_rem = 0.}
\DoxyCodeLine{145       uh\_src\_rem = 0.}
\DoxyCodeLine{146       h\_dest\_rem = max(0., h\_dest\_rem -\/ dh)}
\DoxyCodeLine{147     \textcolor{keywordflow}{elseif} (h\_src\_rem>h\_dest\_rem) \textcolor{keywordflow}{then}}
\DoxyCodeLine{148       \textcolor{comment}{! Only part of the source cell can be used up}}
\DoxyCodeLine{149       dh = h\_dest\_rem}
\DoxyCodeLine{150       duh = (dh / h\_src\_rem) * uh\_src\_rem}
\DoxyCodeLine{151       h\_src\_rem = max(0., h\_src\_rem -\/ dh)}
\DoxyCodeLine{152       uh\_src\_rem = uh\_src\_rem -\/ duh}
\DoxyCodeLine{153       h\_dest\_rem = 0.}
\DoxyCodeLine{154     \textcolor{keywordflow}{else} \textcolor{comment}{! h\_src\_rem==h\_dest\_rem}}
\DoxyCodeLine{155       \textcolor{comment}{! The source cell exactly fits the destination cell}}
\DoxyCodeLine{156       duh = uh\_src\_rem}
\DoxyCodeLine{157       h\_src\_rem = 0.}
\DoxyCodeLine{158       uh\_src\_rem = 0.}
\DoxyCodeLine{159       h\_dest\_rem = 0.}
\DoxyCodeLine{160 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{161     uh\_dest(k\_dest) = uh\_dest(k\_dest) + duh}
\DoxyCodeLine{162     \textcolor{keywordflow}{if} (k\_dest==ndest .and. (k\_src==nsrc .or. h\_dest\_rem==0.)) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{163 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{164 }
\DoxyCodeLine{165   \textcolor{keywordflow}{if} (.not. src\_exists) uh\_dest(1:ndest) = missing\_value}
\DoxyCodeLine{166 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__vkernels_abeef457cda28b20c03a89ad402bcd434}\label{namespacemom__diag__vkernels_abeef457cda28b20c03a89ad402bcd434}} 
\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}!test\_interp@{test\_interp}}
\index{test\_interp@{test\_interp}!mom\_diag\_vkernels@{mom\_diag\_vkernels}}
\doxysubsubsection{\texorpdfstring{test\_interp()}{test\_interp()}}
{\footnotesize\ttfamily logical function mom\+\_\+diag\+\_\+vkernels\+::test\+\_\+interp (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{real, intent(in)}]{missing\+\_\+value,  }\item[{character(len=$\ast$), intent(in)}]{msg,  }\item[{integer, intent(in)}]{nsrc,  }\item[{real, dimension(nsrc), intent(in)}]{h\+\_\+src,  }\item[{real, dimension(nsrc+1), intent(in)}]{u\+\_\+src,  }\item[{integer, intent(in)}]{ndest,  }\item[{real, dimension(ndest), intent(in)}]{h\+\_\+dest,  }\item[{real, dimension(ndest+1), intent(in)}]{u\+\_\+true }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns true if a test of \mbox{\hyperlink{namespacemom__diag__vkernels_a4f42f472a725a147f8d97a68b2028c5b}{interpolate\+\_\+column()}} produces the wrong answer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em verbose} & If true, write results to stdout \\
\hline
\mbox{\texttt{ in}}  & {\em missing\+\_\+value} & Value to indicate missing data \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & Message to label test \\
\hline
\mbox{\texttt{ in}}  & {\em nsrc} & Number of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+src} & Thickness of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+src} & Values at source cell interfaces \\
\hline
\mbox{\texttt{ in}}  & {\em ndest} & Number of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+dest} & Thickness of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+true} & Correct value at destination cell interfaces \\
\hline
\end{DoxyParams}


Definition at line 284 of file M\+O\+M\+\_\+diag\+\_\+vkernels.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{284   \textcolor{keywordtype}{logical},                  \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}}
\DoxyCodeLine{285 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< Value to indicate missing data}}
\DoxyCodeLine{286   \textcolor{keywordtype}{character(len=*)},         \textcolor{keywordtype}{intent(in)} :: msg\textcolor{comment}{ !< Message to label test}}
\DoxyCodeLine{287   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)} :: nsrc\textcolor{comment}{ !< Number of source cells}}
\DoxyCodeLine{288 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},    \textcolor{keywordtype}{intent(in)} :: h\_src\textcolor{comment}{ !< Thickness of source cells}}
\DoxyCodeLine{289 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc+1)},  \textcolor{keywordtype}{intent(in)} :: u\_src\textcolor{comment}{ !< Values at source cell interfaces}}
\DoxyCodeLine{290   \textcolor{keywordtype}{integer},                  \textcolor{keywordtype}{intent(in)} :: ndest\textcolor{comment}{ !< Number of destination cells}}
\DoxyCodeLine{291 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)},   \textcolor{keywordtype}{intent(in)} :: h\_dest\textcolor{comment}{ !< Thickness of destination cells}}
\DoxyCodeLine{292 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest+1)}, \textcolor{keywordtype}{intent(in)} :: u\_true\textcolor{comment}{ !< Correct value at destination cell interfaces}}
\DoxyCodeLine{293   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{294 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest+1)} :: u\_dest \textcolor{comment}{! Interpolated value at destination cell interfaces}}
\DoxyCodeLine{295   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{296 \textcolor{keywordtype}{  real} :: error}
\DoxyCodeLine{297   \textcolor{keywordtype}{logical} :: print\_results}
\DoxyCodeLine{298 }
\DoxyCodeLine{299   \textcolor{comment}{! Interpolate from src to dest}}
\DoxyCodeLine{300   \textcolor{keyword}{call }interpolate\_column(nsrc, h\_src, u\_src, ndest, h\_dest, missing\_value, u\_dest)}
\DoxyCodeLine{301 }
\DoxyCodeLine{302   test\_interp = .false.}
\DoxyCodeLine{303   \textcolor{keywordflow}{do} k=1,ndest+1}
\DoxyCodeLine{304     \textcolor{keywordflow}{if} (u\_dest(k)/=u\_true(k)) test\_interp = .true.}
\DoxyCodeLine{305 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{306   \textcolor{keywordflow}{if} (verbose .or. test\_interp) \textcolor{keywordflow}{then}}
\DoxyCodeLine{307     \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(2a)'}) \textcolor{stringliteral}{' Test: '},msg}
\DoxyCodeLine{308     \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(a3,3(a24))'}) \textcolor{stringliteral}{'k'},\textcolor{stringliteral}{'u\_result'},\textcolor{stringliteral}{'u\_true'},\textcolor{stringliteral}{'error'}}
\DoxyCodeLine{309     \textcolor{keywordflow}{do} k=1,ndest+1}
\DoxyCodeLine{310       error = u\_dest(k)-\/u\_true(k)}
\DoxyCodeLine{311       \textcolor{keywordflow}{if} (error==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{312         \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(i3,3(1pe24.16))'}) k,u\_dest(k),u\_true(k),u\_dest(k)-\/u\_true(k)}
\DoxyCodeLine{313       \textcolor{keywordflow}{else}}
\DoxyCodeLine{314         \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(i3,3(1pe24.16),x,a)'}) k,u\_dest(k),u\_true(k),u\_dest(k)-\/u\_true(k),\textcolor{stringliteral}{'<-\/-\/-\/ WRONG!'}}
\DoxyCodeLine{315         \textcolor{keyword}{write}(stderr,\textcolor{stringliteral}{'(i3,3(1pe24.16),x,a)'}) k,u\_dest(k),u\_true(k),u\_dest(k)-\/u\_true(k),\textcolor{stringliteral}{'<-\/-\/-\/ WRONG!'}}
\DoxyCodeLine{316 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{317 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{318 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__diag__vkernels_aac7aad5875fcf17273b211c90ac0cbee}\label{namespacemom__diag__vkernels_aac7aad5875fcf17273b211c90ac0cbee}} 
\index{mom\_diag\_vkernels@{mom\_diag\_vkernels}!test\_reintegrate@{test\_reintegrate}}
\index{test\_reintegrate@{test\_reintegrate}!mom\_diag\_vkernels@{mom\_diag\_vkernels}}
\doxysubsubsection{\texorpdfstring{test\_reintegrate()}{test\_reintegrate()}}
{\footnotesize\ttfamily logical function mom\+\_\+diag\+\_\+vkernels\+::test\+\_\+reintegrate (\begin{DoxyParamCaption}\item[{logical, intent(in)}]{verbose,  }\item[{real, intent(in)}]{missing\+\_\+value,  }\item[{character(len=$\ast$), intent(in)}]{msg,  }\item[{integer, intent(in)}]{nsrc,  }\item[{real, dimension(nsrc), intent(in)}]{h\+\_\+src,  }\item[{real, dimension(nsrc), intent(in)}]{uh\+\_\+src,  }\item[{integer, intent(in)}]{ndest,  }\item[{real, dimension(ndest), intent(in)}]{h\+\_\+dest,  }\item[{real, dimension(ndest), intent(in)}]{uh\+\_\+true }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns true if a test of \mbox{\hyperlink{namespacemom__diag__vkernels_a89369e4bf4b7795f6e384762d11f0d23}{reintegrate\+\_\+column()}} produces the wrong answer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em verbose} & If true, write results to stdout \\
\hline
\mbox{\texttt{ in}}  & {\em missing\+\_\+value} & Value to indicate missing data \\
\hline
\mbox{\texttt{ in}}  & {\em msg} & Message to label test \\
\hline
\mbox{\texttt{ in}}  & {\em nsrc} & Number of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+src} & Thickness of source cells \\
\hline
\mbox{\texttt{ in}}  & {\em uh\+\_\+src} & Values of source cell stuff \\
\hline
\mbox{\texttt{ in}}  & {\em ndest} & Number of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+dest} & Thickness of destination cells \\
\hline
\mbox{\texttt{ in}}  & {\em uh\+\_\+true} & Correct value of destination cell stuff \\
\hline
\end{DoxyParams}


Definition at line 323 of file M\+O\+M\+\_\+diag\+\_\+vkernels.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{323   \textcolor{keywordtype}{logical},                \textcolor{keywordtype}{intent(in)} :: verbose\textcolor{comment}{ !< If true, write results to stdout}}
\DoxyCodeLine{324 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(in)} :: missing\_value\textcolor{comment}{ !< Value to indicate missing data}}
\DoxyCodeLine{325   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)} :: msg\textcolor{comment}{ !< Message to label test}}
\DoxyCodeLine{326   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)} :: nsrc\textcolor{comment}{ !< Number of source cells}}
\DoxyCodeLine{327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},  \textcolor{keywordtype}{intent(in)} :: h\_src\textcolor{comment}{ !< Thickness of source cells}}
\DoxyCodeLine{328 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(nsrc)},  \textcolor{keywordtype}{intent(in)} :: uh\_src\textcolor{comment}{ !< Values of source cell stuff}}
\DoxyCodeLine{329   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)} :: ndest\textcolor{comment}{ !< Number of destination cells}}
\DoxyCodeLine{330 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)}, \textcolor{keywordtype}{intent(in)} :: h\_dest\textcolor{comment}{ !< Thickness of destination cells}}
\DoxyCodeLine{331 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)}, \textcolor{keywordtype}{intent(in)} :: uh\_true\textcolor{comment}{ !< Correct value of destination cell stuff}}
\DoxyCodeLine{332   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{333 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(ndest)} :: uh\_dest \textcolor{comment}{! Reintegrated value on destination cells}}
\DoxyCodeLine{334   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{335 \textcolor{keywordtype}{  real} :: error}
\DoxyCodeLine{336   \textcolor{keywordtype}{logical} :: print\_results}
\DoxyCodeLine{337 }
\DoxyCodeLine{338   \textcolor{comment}{! Interpolate from src to dest}}
\DoxyCodeLine{339   \textcolor{keyword}{call }reintegrate\_column(nsrc, h\_src, uh\_src, ndest, h\_dest, missing\_value, uh\_dest)}
\DoxyCodeLine{340 }
\DoxyCodeLine{341   test\_reintegrate = .false.}
\DoxyCodeLine{342   \textcolor{keywordflow}{do} k=1,ndest}
\DoxyCodeLine{343     \textcolor{keywordflow}{if} (uh\_dest(k)/=uh\_true(k)) test\_reintegrate = .true.}
\DoxyCodeLine{344 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{345   \textcolor{keywordflow}{if} (verbose .or. test\_reintegrate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{346     \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(2a)'}) \textcolor{stringliteral}{' Test: '},msg}
\DoxyCodeLine{347     \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(a3,3(a24))'}) \textcolor{stringliteral}{'k'},\textcolor{stringliteral}{'uh\_result'},\textcolor{stringliteral}{'uh\_true'},\textcolor{stringliteral}{'error'}}
\DoxyCodeLine{348     \textcolor{keywordflow}{do} k=1,ndest}
\DoxyCodeLine{349       error = uh\_dest(k)-\/uh\_true(k)}
\DoxyCodeLine{350       \textcolor{keywordflow}{if} (error==0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{351         \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(i3,3(1pe24.16))'}) k,uh\_dest(k),uh\_true(k),uh\_dest(k)-\/uh\_true(k)}
\DoxyCodeLine{352       \textcolor{keywordflow}{else}}
\DoxyCodeLine{353         \textcolor{keyword}{write}(stdout,\textcolor{stringliteral}{'(i3,3(1pe24.16),x,a)'}) k,uh\_dest(k),uh\_true(k),uh\_dest(k)-\/uh\_true(k),\textcolor{stringliteral}{'<-\/-\/-\/ WRONG!'}}
\DoxyCodeLine{354         \textcolor{keyword}{write}(stderr,\textcolor{stringliteral}{'(i3,3(1pe24.16),x,a)'}) k,uh\_dest(k),uh\_true(k),uh\_dest(k)-\/uh\_true(k),\textcolor{stringliteral}{'<-\/-\/-\/ WRONG!'}}
\DoxyCodeLine{355 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{356 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{357 \textcolor{keywordflow}{  endif}}

\end{DoxyCode}
