\hypertarget{namespaceplm__functions}{}\section{plm\+\_\+functions Module Reference}
\label{namespaceplm__functions}\index{plm\_functions@{plm\_functions}}


\subsection{Detailed Description}
Piecewise linear reconstruction functions. 

Date of creation\+: 2008.\+06.\+06 L. White.

This module contains routines that handle one-\/dimensionnal finite volume reconstruction using the piecewise linear method (P\+LM). \subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
real elemental pure function, public \mbox{\hyperlink{namespaceplm__functions_a072affa78922591148b954fa63872246}{plm\+\_\+slope\+\_\+wa}} (h\+\_\+l, h\+\_\+c, h\+\_\+r, h\+\_\+neglect, u\+\_\+l, u\+\_\+c, u\+\_\+r)
\begin{DoxyCompactList}\small\item\em Returns a limited P\+LM slope following White and Adcroft, 2008. \mbox{[}units of u\mbox{]} Note that this is not the same as the Colella and Woodward method. \end{DoxyCompactList}\item 
real elemental pure function, public \mbox{\hyperlink{namespaceplm__functions_a29d2baec39200c5aa448c79181a16f4f}{plm\+\_\+slope\+\_\+cw}} (h\+\_\+l, h\+\_\+c, h\+\_\+r, h\+\_\+neglect, u\+\_\+l, u\+\_\+c, u\+\_\+r)
\begin{DoxyCompactList}\small\item\em Returns a limited P\+LM slope following Colella and Woodward 1984. \end{DoxyCompactList}\item 
real elemental pure function, public \mbox{\hyperlink{namespaceplm__functions_a497e5e73108e08afcb4e2186710ae094}{plm\+\_\+monotonized\+\_\+slope}} (u\+\_\+l, u\+\_\+c, u\+\_\+r, s\+\_\+l, s\+\_\+c, s\+\_\+r)
\begin{DoxyCompactList}\small\item\em Returns a limited P\+LM slope following Colella and Woodward 1984. \end{DoxyCompactList}\item 
real elemental pure function, public \mbox{\hyperlink{namespaceplm__functions_a42fbf62545902eeb6c9e035763496b07}{plm\+\_\+extrapolate\+\_\+slope}} (h\+\_\+l, h\+\_\+c, h\+\_\+neglect, u\+\_\+l, u\+\_\+c)
\begin{DoxyCompactList}\small\item\em Returns a P\+LM slope using h2 extrapolation from a cell to the left. Use the negative to extrapolate from the a cell to the right. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceplm__functions_a0e3a6bedfb3064ed8fae8c8449649054}{plm\+\_\+reconstruction}} (N, h, u, edge\+\_\+values, ppoly\+\_\+coef, h\+\_\+neglect)
\begin{DoxyCompactList}\small\item\em Reconstruction by linear polynomials within each cell. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceplm__functions_a85e83fd8ad314548d861d5048dad8f72}{plm\+\_\+boundary\+\_\+extrapolation}} (N, h, u, edge\+\_\+values, ppoly\+\_\+coef, h\+\_\+neglect)
\begin{DoxyCompactList}\small\item\em Reconstruction by linear polynomials within boundary cells. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceplm__functions_abc6a0167b8f90d1d1a95c0dec6921053}\label{namespaceplm__functions_abc6a0167b8f90d1d1a95c0dec6921053}} 
real, parameter \mbox{\hyperlink{namespaceplm__functions_abc6a0167b8f90d1d1a95c0dec6921053}{hneglect\+\_\+dflt}} = 1.E-\/30
\begin{DoxyCompactList}\small\item\em Default negligible cell thickness. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceplm__functions_a85e83fd8ad314548d861d5048dad8f72}\label{namespaceplm__functions_a85e83fd8ad314548d861d5048dad8f72}} 
\index{plm\_functions@{plm\_functions}!plm\_boundary\_extrapolation@{plm\_boundary\_extrapolation}}
\index{plm\_boundary\_extrapolation@{plm\_boundary\_extrapolation}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_boundary\_extrapolation()}{plm\_boundary\_extrapolation()}}
{\footnotesize\ttfamily subroutine, public plm\+\_\+functions\+::plm\+\_\+boundary\+\_\+extrapolation (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(\+:), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(in)}]{u,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{edge\+\_\+values,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{ppoly\+\_\+coef,  }\item[{real, intent(in), optional}]{h\+\_\+neglect }\end{DoxyParamCaption})}



Reconstruction by linear polynomials within boundary cells. 

The left and right edge values in the left and right boundary cells, respectively, are estimated using a linear extrapolation within the cells.

This extrapolation is E\+X\+A\+CT when the underlying profile is linear.

It is assumed that the size of the array \textquotesingle{}u\textquotesingle{} is equal to the number of cells defining \textquotesingle{}grid\textquotesingle{} and \textquotesingle{}ppoly\textquotesingle{}. No consistency check is performed here. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & cell widths (size N) \\
\hline
\mbox{\texttt{ in}}  & {\em u} & cell averages (size N) \\
\hline
\mbox{\texttt{ in,out}}  & {\em edge\+\_\+values} & edge values of piecewise polynomials, with the same units as u. \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly\+\_\+coef} & coefficients of piecewise polynomials, mainly with the same units as u. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width for the purpose of cell reconstructions in the same units as h \\
\hline
\end{DoxyParams}


Definition at line 269 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{269   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: N\textcolor{comment}{ !< Number of cells}}
\DoxyCodeLine{270 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{ !< cell widths (size N)}}
\DoxyCodeLine{271 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{ !< cell averages (size N)}}
\DoxyCodeLine{272 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: edge\_values\textcolor{comment}{ !< edge values of piecewise polynomials,}}
\DoxyCodeLine{273 \textcolor{comment}{                                           !! with the same units as u.}}
\DoxyCodeLine{274 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: ppoly\_coef\textcolor{comment}{ !< coefficients of piecewise polynomials, mainly}}
\DoxyCodeLine{275 \textcolor{comment}{                                           !! with the same units as u.}}
\DoxyCodeLine{276 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width for}}
\DoxyCodeLine{277 \textcolor{comment}{                                           !! the purpose of cell reconstructions}}
\DoxyCodeLine{278 \textcolor{comment}{                                           !! in the same units as h}}
\DoxyCodeLine{279   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{280 \textcolor{keywordtype}{  real}    :: slope                \textcolor{comment}{! retained PLM slope}}
\DoxyCodeLine{281 \textcolor{keywordtype}{  real}    :: hNeglect}
\DoxyCodeLine{282 }
\DoxyCodeLine{283   hneglect = hneglect\_dflt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(h\_neglect)) hneglect = h\_neglect}
\DoxyCodeLine{284 }
\DoxyCodeLine{285   \textcolor{comment}{! Extrapolate from 2 to 1 to estimate slope}}
\DoxyCodeLine{286   slope = - plm\_extrapolate\_slope( h(2), h(1), hneglect, u(2), u(1) )}
\DoxyCodeLine{287 }
\DoxyCodeLine{288   edge\_values(1,1) = u(1) - 0.5 * slope}
\DoxyCodeLine{289   edge\_values(1,2) = u(1) + 0.5 * slope}
\DoxyCodeLine{290 }
\DoxyCodeLine{291   ppoly\_coef(1,1) = edge\_values(1,1)}
\DoxyCodeLine{292   ppoly\_coef(1,2) = edge\_values(1,2) - edge\_values(1,1)}
\DoxyCodeLine{293 }
\DoxyCodeLine{294   \textcolor{comment}{! Extrapolate from N-1 to N to estimate slope}}
\DoxyCodeLine{295   slope = plm\_extrapolate\_slope( h(n-1), h(n), hneglect, u(n-1), u(n) )}
\DoxyCodeLine{296 }
\DoxyCodeLine{297   edge\_values(n,1) = u(n) - 0.5 * slope}
\DoxyCodeLine{298   edge\_values(n,2) = u(n) + 0.5 * slope}
\DoxyCodeLine{299 }
\DoxyCodeLine{300   ppoly\_coef(n,1) = edge\_values(n,1)}
\DoxyCodeLine{301   ppoly\_coef(n,2) = edge\_values(n,2) - edge\_values(n,1)}
\DoxyCodeLine{302 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceplm__functions_a42fbf62545902eeb6c9e035763496b07}\label{namespaceplm__functions_a42fbf62545902eeb6c9e035763496b07}} 
\index{plm\_functions@{plm\_functions}!plm\_extrapolate\_slope@{plm\_extrapolate\_slope}}
\index{plm\_extrapolate\_slope@{plm\_extrapolate\_slope}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_extrapolate\_slope()}{plm\_extrapolate\_slope()}}
{\footnotesize\ttfamily real elemental pure function, public plm\+\_\+functions\+::plm\+\_\+extrapolate\+\_\+slope (\begin{DoxyParamCaption}\item[{real, intent(in)}]{h\+\_\+l,  }\item[{real, intent(in)}]{h\+\_\+c,  }\item[{real, intent(in)}]{h\+\_\+neglect,  }\item[{real, intent(in)}]{u\+\_\+l,  }\item[{real, intent(in)}]{u\+\_\+c }\end{DoxyParamCaption})}



Returns a P\+LM slope using h2 extrapolation from a cell to the left. Use the negative to extrapolate from the a cell to the right. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em h\+\_\+l} & Thickness of left cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+c} & Thickness of center cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligible thickness \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+l} & Value of left cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+c} & Value of center cell \mbox{[}units of u\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 161 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{161 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_l\textcolor{comment}{ !< Thickness of left cell [units of grid thickness]}}
\DoxyCodeLine{162 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_c\textcolor{comment}{ !< Thickness of center cell [units of grid thickness]}}
\DoxyCodeLine{163 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_neglect\textcolor{comment}{ !< A negligible thickness [units of grid thickness]}}
\DoxyCodeLine{164 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_l\textcolor{comment}{ !< Value of left cell [units of u]}}
\DoxyCodeLine{165 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_c\textcolor{comment}{ !< Value of center cell [units of u]}}
\DoxyCodeLine{166   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{167 \textcolor{keywordtype}{  real} :: left\_edge \textcolor{comment}{! Left edge value [units of u]}}
\DoxyCodeLine{168 \textcolor{keywordtype}{  real} :: hl, hc \textcolor{comment}{! Left and central cell thicknesses [units of grid thickness]}}
\DoxyCodeLine{169 }
\DoxyCodeLine{170   \textcolor{comment}{! Avoid division by zero for vanished cells}}
\DoxyCodeLine{171    hl = h\_l + h\_neglect}
\DoxyCodeLine{172    hc = h\_c + h\_neglect}
\DoxyCodeLine{173 }
\DoxyCodeLine{174   \textcolor{comment}{! The h2 scheme is used to compute the left edge value}}
\DoxyCodeLine{175   left\_edge = (u\_l*hc + u\_c*hl) / (hl + hc)}
\DoxyCodeLine{176 }
\DoxyCodeLine{177   plm\_extrapolate\_slope = 2.0 * ( u\_c - left\_edge )}
\DoxyCodeLine{178 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceplm__functions_a497e5e73108e08afcb4e2186710ae094}\label{namespaceplm__functions_a497e5e73108e08afcb4e2186710ae094}} 
\index{plm\_functions@{plm\_functions}!plm\_monotonized\_slope@{plm\_monotonized\_slope}}
\index{plm\_monotonized\_slope@{plm\_monotonized\_slope}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_monotonized\_slope()}{plm\_monotonized\_slope()}}
{\footnotesize\ttfamily real elemental pure function, public plm\+\_\+functions\+::plm\+\_\+monotonized\+\_\+slope (\begin{DoxyParamCaption}\item[{real, intent(in)}]{u\+\_\+l,  }\item[{real, intent(in)}]{u\+\_\+c,  }\item[{real, intent(in)}]{u\+\_\+r,  }\item[{real, intent(in)}]{s\+\_\+l,  }\item[{real, intent(in)}]{s\+\_\+c,  }\item[{real, intent(in)}]{s\+\_\+r }\end{DoxyParamCaption})}



Returns a limited P\+LM slope following Colella and Woodward 1984. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em u\+\_\+l} & Value of left cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+c} & Value of center cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+r} & Value of right cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+l} & P\+LM slope of left cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+c} & P\+LM slope of center cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+r} & P\+LM slope of right cell \mbox{[}units of u\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 122 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{122 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_l\textcolor{comment}{ !< Value of left cell [units of u]}}
\DoxyCodeLine{123 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_c\textcolor{comment}{ !< Value of center cell [units of u]}}
\DoxyCodeLine{124 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_r\textcolor{comment}{ !< Value of right cell [units of u]}}
\DoxyCodeLine{125 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: s\_l\textcolor{comment}{ !< PLM slope of left cell [units of u]}}
\DoxyCodeLine{126 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: s\_c\textcolor{comment}{ !< PLM slope of center cell [units of u]}}
\DoxyCodeLine{127 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: s\_r\textcolor{comment}{ !< PLM slope of right cell [units of u]}}
\DoxyCodeLine{128   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{129 \textcolor{keywordtype}{  real} :: e\_r, e\_l, edge \textcolor{comment}{! Right, left and temporary edge values [units of u]}}
\DoxyCodeLine{130 \textcolor{keywordtype}{  real} :: almost\_two \textcolor{comment}{! The number 2, almost.}}
\DoxyCodeLine{131 \textcolor{keywordtype}{  real} :: slp \textcolor{comment}{! Magnitude of PLM central slope [units of u]}}
\DoxyCodeLine{132 }
\DoxyCodeLine{133   almost\_two = 2. * ( 1. - epsilon(s\_c) )}
\DoxyCodeLine{134 }
\DoxyCodeLine{135   \textcolor{comment}{! Edge values of neighbors abutting this cell}}
\DoxyCodeLine{136   e\_r = u\_l + 0.5*s\_l}
\DoxyCodeLine{137   e\_l = u\_r - 0.5*s\_r}
\DoxyCodeLine{138   slp = abs(s\_c)}
\DoxyCodeLine{139 }
\DoxyCodeLine{140   \textcolor{comment}{! Check that left edge is between right edge of cell to the left and this cell mean}}
\DoxyCodeLine{141   edge = u\_c - 0.5 * s\_c}
\DoxyCodeLine{142   \textcolor{keywordflow}{if} ( ( edge - e\_r ) * ( u\_c - edge ) < 0. ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{143     edge = 0.5 * ( edge + e\_r )}
\DoxyCodeLine{144     slp = min( slp, abs( edge - u\_c ) * almost\_two )}
\DoxyCodeLine{145 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{146 }
\DoxyCodeLine{147   \textcolor{comment}{! Check that right edge is between left edge of cell to the right and this cell mean}}
\DoxyCodeLine{148   edge = u\_c + 0.5 * s\_c}
\DoxyCodeLine{149   \textcolor{keywordflow}{if} ( ( edge - u\_c ) * ( e\_l - edge ) < 0. ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{150     edge = 0.5 * ( edge + e\_l )}
\DoxyCodeLine{151     slp = min( slp, abs( edge - u\_c ) * almost\_two )}
\DoxyCodeLine{152 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{153 }
\DoxyCodeLine{154   plm\_monotonized\_slope = sign( slp, s\_c )}
\DoxyCodeLine{155 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceplm__functions_a0e3a6bedfb3064ed8fae8c8449649054}\label{namespaceplm__functions_a0e3a6bedfb3064ed8fae8c8449649054}} 
\index{plm\_functions@{plm\_functions}!plm\_reconstruction@{plm\_reconstruction}}
\index{plm\_reconstruction@{plm\_reconstruction}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_reconstruction()}{plm\_reconstruction()}}
{\footnotesize\ttfamily subroutine, public plm\+\_\+functions\+::plm\+\_\+reconstruction (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(\+:), intent(in)}]{h,  }\item[{real, dimension(\+:), intent(in)}]{u,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{edge\+\_\+values,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{ppoly\+\_\+coef,  }\item[{real, intent(in), optional}]{h\+\_\+neglect }\end{DoxyParamCaption})}



Reconstruction by linear polynomials within each cell. 

It is assumed that the size of the array \textquotesingle{}u\textquotesingle{} is equal to the number of cells defining \textquotesingle{}grid\textquotesingle{} and \textquotesingle{}ppoly\textquotesingle{}. No consistency check is performed here. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & cell widths (size N) \\
\hline
\mbox{\texttt{ in}}  & {\em u} & cell averages (size N) \\
\hline
\mbox{\texttt{ in,out}}  & {\em edge\+\_\+values} & edge values of piecewise polynomials, with the same units as u. \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly\+\_\+coef} & coefficients of piecewise polynomials, mainly with the same units as u. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width for the purpose of cell reconstructions in the same units as h \\
\hline
\end{DoxyParams}


Definition at line 187 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{187   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)}    :: N\textcolor{comment}{ !< Number of cells}}
\DoxyCodeLine{188 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{ !< cell widths (size N)}}
\DoxyCodeLine{189 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},   \textcolor{keywordtype}{intent(in)}    :: u\textcolor{comment}{ !< cell averages (size N)}}
\DoxyCodeLine{190 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: edge\_values\textcolor{comment}{ !< edge values of piecewise polynomials,}}
\DoxyCodeLine{191 \textcolor{comment}{                                           !! with the same units as u.}}
\DoxyCodeLine{192 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{intent(inout)} :: ppoly\_coef\textcolor{comment}{ !< coefficients of piecewise polynomials, mainly}}
\DoxyCodeLine{193 \textcolor{comment}{                                           !! with the same units as u.}}
\DoxyCodeLine{194 \textcolor{keywordtype}{  real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width for}}
\DoxyCodeLine{195 \textcolor{comment}{                                           !! the purpose of cell reconstructions}}
\DoxyCodeLine{196 \textcolor{comment}{                                           !! in the same units as h}}
\DoxyCodeLine{197 }
\DoxyCodeLine{198   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{199   \textcolor{keywordtype}{integer}       :: k                    \textcolor{comment}{! loop index}}
\DoxyCodeLine{200 \textcolor{keywordtype}{  real}          :: u\_l, u\_c, u\_r        \textcolor{comment}{! left, center and right cell averages}}
\DoxyCodeLine{201 \textcolor{keywordtype}{  real}          :: h\_l, h\_c, h\_r, h\_cn  \textcolor{comment}{! left, center and right cell widths}}
\DoxyCodeLine{202 \textcolor{keywordtype}{  real}          :: slope                \textcolor{comment}{! retained PLM slope}}
\DoxyCodeLine{203 \textcolor{keywordtype}{  real}          :: a, b                 \textcolor{comment}{! auxiliary variables}}
\DoxyCodeLine{204 \textcolor{keywordtype}{  real}          :: u\_min, u\_max, e\_l, e\_r, edge}
\DoxyCodeLine{205 \textcolor{keywordtype}{  real}          :: almost\_one}
\DoxyCodeLine{206 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N)} :: slp, mslp}
\DoxyCodeLine{207 \textcolor{keywordtype}{  real}    :: hNeglect}
\DoxyCodeLine{208 }
\DoxyCodeLine{209   hneglect = hneglect\_dflt ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(h\_neglect)) hneglect = h\_neglect}
\DoxyCodeLine{210 }
\DoxyCodeLine{211   almost\_one = 1. - epsilon(slope)}
\DoxyCodeLine{212 }
\DoxyCodeLine{213   \textcolor{comment}{! Loop on interior cells}}
\DoxyCodeLine{214   \textcolor{keywordflow}{do} k = 2,n-1}
\DoxyCodeLine{215     slp(k) = plm\_slope\_wa(h(k-1), h(k), h(k+1), hneglect, u(k-1), u(k), u(k+1))}
\DoxyCodeLine{216 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end loop on interior cells}}
\DoxyCodeLine{217 }
\DoxyCodeLine{218   \textcolor{comment}{! Boundary cells use PCM. Extrapolation is handled after monotonization.}}
\DoxyCodeLine{219   slp(1) = 0.}
\DoxyCodeLine{220   slp(n) = 0.}
\DoxyCodeLine{221 }
\DoxyCodeLine{222   \textcolor{comment}{! This loop adjusts the slope so that edge values are monotonic.}}
\DoxyCodeLine{223   \textcolor{keywordflow}{do} k = 2, n-1}
\DoxyCodeLine{224     mslp(k) = plm\_monotonized\_slope( u(k-1), u(k), u(k+1), slp(k-1), slp(k), slp(k+1) )}
\DoxyCodeLine{225 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end loop on interior cells}}
\DoxyCodeLine{226   mslp(1) = 0.}
\DoxyCodeLine{227   mslp(n) = 0.}
\DoxyCodeLine{228 }
\DoxyCodeLine{229   \textcolor{comment}{! Store and return edge values and polynomial coefficients.}}
\DoxyCodeLine{230   edge\_values(1,1) = u(1)}
\DoxyCodeLine{231   edge\_values(1,2) = u(1)}
\DoxyCodeLine{232   ppoly\_coef(1,1) = u(1)}
\DoxyCodeLine{233   ppoly\_coef(1,2) = 0.}
\DoxyCodeLine{234   \textcolor{keywordflow}{do} k = 2, n-1}
\DoxyCodeLine{235     slope = mslp(k)}
\DoxyCodeLine{236     u\_l = u(k) - 0.5 * slope \textcolor{comment}{! Left edge value of cell k}}
\DoxyCodeLine{237     u\_r = u(k) + 0.5 * slope \textcolor{comment}{! Right edge value of cell k}}
\DoxyCodeLine{238 }
\DoxyCodeLine{239     edge\_values(k,1) = u\_l}
\DoxyCodeLine{240     edge\_values(k,2) = u\_r}
\DoxyCodeLine{241     ppoly\_coef(k,1) = u\_l}
\DoxyCodeLine{242     ppoly\_coef(k,2) = ( u\_r - u\_l )}
\DoxyCodeLine{243     \textcolor{comment}{! Check to see if this evaluation of the polynomial at x=1 would be}}
\DoxyCodeLine{244     \textcolor{comment}{! monotonic w.r.t. the next cell's edge value. If not, scale back!}}
\DoxyCodeLine{245     edge = ppoly\_coef(k,2) + ppoly\_coef(k,1)}
\DoxyCodeLine{246     e\_r = u(k+1) - 0.5 * sign( mslp(k+1), slp(k+1) )}
\DoxyCodeLine{247     \textcolor{keywordflow}{if} ( (edge-u(k))*(e\_r-edge)<0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{248       ppoly\_coef(k,2) = ppoly\_coef(k,2) * almost\_one}
\DoxyCodeLine{249 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{250 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{251   edge\_values(n,1) = u(n)}
\DoxyCodeLine{252   edge\_values(n,2) = u(n)}
\DoxyCodeLine{253   ppoly\_coef(n,1) = u(n)}
\DoxyCodeLine{254   ppoly\_coef(n,2) = 0.}
\DoxyCodeLine{255 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceplm__functions_a29d2baec39200c5aa448c79181a16f4f}\label{namespaceplm__functions_a29d2baec39200c5aa448c79181a16f4f}} 
\index{plm\_functions@{plm\_functions}!plm\_slope\_cw@{plm\_slope\_cw}}
\index{plm\_slope\_cw@{plm\_slope\_cw}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_slope\_cw()}{plm\_slope\_cw()}}
{\footnotesize\ttfamily real elemental pure function, public plm\+\_\+functions\+::plm\+\_\+slope\+\_\+cw (\begin{DoxyParamCaption}\item[{real, intent(in)}]{h\+\_\+l,  }\item[{real, intent(in)}]{h\+\_\+c,  }\item[{real, intent(in)}]{h\+\_\+r,  }\item[{real, intent(in)}]{h\+\_\+neglect,  }\item[{real, intent(in)}]{u\+\_\+l,  }\item[{real, intent(in)}]{u\+\_\+c,  }\item[{real, intent(in)}]{u\+\_\+r }\end{DoxyParamCaption})}



Returns a limited P\+LM slope following Colella and Woodward 1984. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em h\+\_\+l} & Thickness of left cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+c} & Thickness of center cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+r} & Thickness of right cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligible thickness \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+l} & Value of left cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+c} & Value of center cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+r} & Value of right cell \mbox{[}units of u\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 68 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{68 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_l\textcolor{comment}{ !< Thickness of left cell [units of grid thickness]}}
\DoxyCodeLine{69 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_c\textcolor{comment}{ !< Thickness of center cell [units of grid thickness]}}
\DoxyCodeLine{70 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_r\textcolor{comment}{ !< Thickness of right cell [units of grid thickness]}}
\DoxyCodeLine{71 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_neglect\textcolor{comment}{ !< A negligible thickness [units of grid thickness]}}
\DoxyCodeLine{72 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_l\textcolor{comment}{ !< Value of left cell [units of u]}}
\DoxyCodeLine{73 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_c\textcolor{comment}{ !< Value of center cell [units of u]}}
\DoxyCodeLine{74 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_r\textcolor{comment}{ !< Value of right cell [units of u]}}
\DoxyCodeLine{75   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{76 \textcolor{keywordtype}{  real} :: sigma\_l, sigma\_c, sigma\_r \textcolor{comment}{! Left, central and right slope estimates as}}
\DoxyCodeLine{77                                     \textcolor{comment}{! differences across the cell [units of u]}}
\DoxyCodeLine{78 \textcolor{keywordtype}{  real} :: u\_min, u\_max \textcolor{comment}{! Minimum and maximum value across cell [units of u]}}
\DoxyCodeLine{79 \textcolor{keywordtype}{  real} :: h\_cn \textcolor{comment}{! Thickness of center cell [units of grid thickness]}}
\DoxyCodeLine{80 }
\DoxyCodeLine{81   h\_cn = h\_c + h\_neglect}
\DoxyCodeLine{82 }
\DoxyCodeLine{83   \textcolor{comment}{! Side differences}}
\DoxyCodeLine{84   sigma\_r = u\_r - u\_c}
\DoxyCodeLine{85   sigma\_l = u\_c - u\_l}
\DoxyCodeLine{86 }
\DoxyCodeLine{87   \textcolor{comment}{! This is the second order slope given by equation 1.7 of}}
\DoxyCodeLine{88   \textcolor{comment}{! Piecewise Parabolic Method, Colella and Woodward (1984),}}
\DoxyCodeLine{89   \textcolor{comment}{! http://dx.doi.org/10.1016/0021-991(84)90143-8.}}
\DoxyCodeLine{90   \textcolor{comment}{! For uniform resolution it simplifies to ( u\_r - u\_l )/2 .}}
\DoxyCodeLine{91   sigma\_c = ( h\_c / ( h\_cn + ( h\_l + h\_r ) ) ) * ( \&}
\DoxyCodeLine{92                 ( 2.*h\_l + h\_c ) / ( h\_r + h\_cn ) * sigma\_r \&}
\DoxyCodeLine{93               + ( 2.*h\_r + h\_c ) / ( h\_l + h\_cn ) * sigma\_l )}
\DoxyCodeLine{94 }
\DoxyCodeLine{95   \textcolor{comment}{! Limit slope so that reconstructions are bounded by neighbors}}
\DoxyCodeLine{96   u\_min = min( u\_l, u\_c, u\_r )}
\DoxyCodeLine{97   u\_max = max( u\_l, u\_c, u\_r )}
\DoxyCodeLine{98   \textcolor{keywordflow}{if} ( (sigma\_l * sigma\_r) > 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{99     \textcolor{comment}{! This limits the slope so that the edge values are bounded by the}}
\DoxyCodeLine{100     \textcolor{comment}{! two cell averages spanning the edge.}}
\DoxyCodeLine{101     plm\_slope\_cw = sign( min( abs(sigma\_c), 2.*min( u\_c - u\_min, u\_max - u\_c ) ), sigma\_c )}
\DoxyCodeLine{102   \textcolor{keywordflow}{else}}
\DoxyCodeLine{103     \textcolor{comment}{! Extrema in the mean values require a PCM reconstruction avoid generating}}
\DoxyCodeLine{104     \textcolor{comment}{! larger extreme values.}}
\DoxyCodeLine{105     plm\_slope\_cw = 0.0}
\DoxyCodeLine{106 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{107 }
\DoxyCodeLine{108   \textcolor{comment}{! This block tests to see if roundoff causes edge values to be out of bounds}}
\DoxyCodeLine{109   \textcolor{keywordflow}{if} (u\_c - 0.5*abs(plm\_slope\_cw) < u\_min .or.  u\_c + 0.5*abs(plm\_slope\_cw) > u\_max) \textcolor{keywordflow}{then}}
\DoxyCodeLine{110     plm\_slope\_cw = plm\_slope\_cw * ( 1. - epsilon(plm\_slope\_cw) )}
\DoxyCodeLine{111 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   \textcolor{comment}{! An attempt to avoid inconsistency when the values become unrepresentable.}}
\DoxyCodeLine{114   \textcolor{comment}{! \#\#\# The following 1.E-140 is dimensionally inconsistent. A newer version of}}
\DoxyCodeLine{115   \textcolor{comment}{! PLM is progress that will avoid the need for such rounding.}}
\DoxyCodeLine{116   \textcolor{keywordflow}{if} (abs(plm\_slope\_cw) < 1.e-140) plm\_slope\_cw = 0.}
\DoxyCodeLine{117 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceplm__functions_a072affa78922591148b954fa63872246}\label{namespaceplm__functions_a072affa78922591148b954fa63872246}} 
\index{plm\_functions@{plm\_functions}!plm\_slope\_wa@{plm\_slope\_wa}}
\index{plm\_slope\_wa@{plm\_slope\_wa}!plm\_functions@{plm\_functions}}
\subsubsection{\texorpdfstring{plm\_slope\_wa()}{plm\_slope\_wa()}}
{\footnotesize\ttfamily real elemental pure function, public plm\+\_\+functions\+::plm\+\_\+slope\+\_\+wa (\begin{DoxyParamCaption}\item[{real, intent(in)}]{h\+\_\+l,  }\item[{real, intent(in)}]{h\+\_\+c,  }\item[{real, intent(in)}]{h\+\_\+r,  }\item[{real, intent(in)}]{h\+\_\+neglect,  }\item[{real, intent(in)}]{u\+\_\+l,  }\item[{real, intent(in)}]{u\+\_\+c,  }\item[{real, intent(in)}]{u\+\_\+r }\end{DoxyParamCaption})}



Returns a limited P\+LM slope following White and Adcroft, 2008. \mbox{[}units of u\mbox{]} Note that this is not the same as the Colella and Woodward method. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em h\+\_\+l} & Thickness of left cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+c} & Thickness of center cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+r} & Thickness of right cell \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligible thickness \mbox{[}units of grid thickness\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+l} & Value of left cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+c} & Value of center cell \mbox{[}units of u\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+r} & Value of right cell \mbox{[}units of u\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 22 of file P\+L\+M\+\_\+functions.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{22 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_l\textcolor{comment}{ !< Thickness of left cell [units of grid thickness]}}
\DoxyCodeLine{23 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_c\textcolor{comment}{ !< Thickness of center cell [units of grid thickness]}}
\DoxyCodeLine{24 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_r\textcolor{comment}{ !< Thickness of right cell [units of grid thickness]}}
\DoxyCodeLine{25 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: h\_neglect\textcolor{comment}{ !< A negligible thickness [units of grid thickness]}}
\DoxyCodeLine{26 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_l\textcolor{comment}{ !< Value of left cell [units of u]}}
\DoxyCodeLine{27 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_c\textcolor{comment}{ !< Value of center cell [units of u]}}
\DoxyCodeLine{28 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{intent(in)} :: u\_r\textcolor{comment}{ !< Value of right cell [units of u]}}
\DoxyCodeLine{29   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{30 \textcolor{keywordtype}{  real} :: sigma\_l, sigma\_c, sigma\_r \textcolor{comment}{! Left, central and right slope estimates as}}
\DoxyCodeLine{31                                     \textcolor{comment}{! differences across the cell [units of u]}}
\DoxyCodeLine{32 \textcolor{keywordtype}{  real} :: u\_min, u\_max \textcolor{comment}{! Minimum and maximum value across cell [units of u]}}
\DoxyCodeLine{33 }
\DoxyCodeLine{34   \textcolor{comment}{! Side differences}}
\DoxyCodeLine{35   sigma\_r = u\_r - u\_c}
\DoxyCodeLine{36   sigma\_l = u\_c - u\_l}
\DoxyCodeLine{37 }
\DoxyCodeLine{38   \textcolor{comment}{! Quasi-second order difference}}
\DoxyCodeLine{39   sigma\_c = 2.0 * ( u\_r - u\_l ) * ( h\_c / ( h\_l + 2.0*h\_c + h\_r + h\_neglect) )}
\DoxyCodeLine{40 }
\DoxyCodeLine{41   \textcolor{comment}{! Limit slope so that reconstructions are bounded by neighbors}}
\DoxyCodeLine{42   u\_min = min( u\_l, u\_c, u\_r )}
\DoxyCodeLine{43   u\_max = max( u\_l, u\_c, u\_r )}
\DoxyCodeLine{44   \textcolor{keywordflow}{if} ( (sigma\_l * sigma\_r) > 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{45     \textcolor{comment}{! This limits the slope so that the edge values are bounded by the}}
\DoxyCodeLine{46     \textcolor{comment}{! two cell averages spanning the edge.}}
\DoxyCodeLine{47     plm\_slope\_wa = sign( min( abs(sigma\_c), 2.*min( u\_c - u\_min, u\_max - u\_c ) ), sigma\_c )}
\DoxyCodeLine{48   \textcolor{keywordflow}{else}}
\DoxyCodeLine{49     \textcolor{comment}{! Extrema in the mean values require a PCM reconstruction avoid generating}}
\DoxyCodeLine{50     \textcolor{comment}{! larger extreme values.}}
\DoxyCodeLine{51     plm\_slope\_wa = 0.0}
\DoxyCodeLine{52 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{53 }
\DoxyCodeLine{54   \textcolor{comment}{! This block tests to see if roundoff causes edge values to be out of bounds}}
\DoxyCodeLine{55   \textcolor{keywordflow}{if} (u\_c - 0.5*abs(plm\_slope\_wa) < u\_min .or.  u\_c + 0.5*abs(plm\_slope\_wa) > u\_max) \textcolor{keywordflow}{then}}
\DoxyCodeLine{56     plm\_slope\_wa = plm\_slope\_wa * ( 1. - epsilon(plm\_slope\_wa) )}
\DoxyCodeLine{57 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{58 }
\DoxyCodeLine{59   \textcolor{comment}{! An attempt to avoid inconsistency when the values become unrepresentable.}}
\DoxyCodeLine{60   \textcolor{comment}{! \#\#\# The following 1.E-140 is dimensionally inconsistent. A newer version of}}
\DoxyCodeLine{61   \textcolor{comment}{! PLM is progress that will avoid the need for such rounding.}}
\DoxyCodeLine{62   \textcolor{keywordflow}{if} (abs(plm\_slope\_wa) < 1.e-140) plm\_slope\_wa = 0.}
\DoxyCodeLine{63 }

\end{DoxyCode}
