\hypertarget{namespaceregrid__interp}{}\doxysection{regrid\+\_\+interp Module Reference}
\label{namespaceregrid__interp}\index{regrid\_interp@{regrid\_interp}}


\doxysubsection{Detailed Description}
Vertical interpolation for regridding. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structregrid__interp_1_1interp__cs__type}{interp\+\_\+cs\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Control structure for \mbox{\hyperlink{namespaceregrid__interp}{regrid\+\_\+interp}} module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespaceregrid__interp_a3d1406836d089b4553421776277e1339}{regridding\+\_\+set\+\_\+ppolys}} (CS, densities, n0, h0, ppoly0\+\_\+E, ppoly0\+\_\+S, ppoly0\+\_\+coefs, degree, h\+\_\+neglect, h\+\_\+neglect\+\_\+edge)
\begin{DoxyCompactList}\small\item\em Builds an interpolated profile for the densities within each grid cell. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregrid__interp_a52b8ce5b52f9d45f8180c6fd75388174}{interpolate\+\_\+grid}} (n0, h0, x0, ppoly0\+\_\+E, ppoly0\+\_\+coefs, target\+\_\+values, degree, n1, h1, x1, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Given target values (e.\+g., density), build new grid based on polynomial. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregrid__interp_abaef8cc7e1258b61710adbd6fb742122}{build\+\_\+and\+\_\+interpolate\+\_\+grid}} (CS, densities, n0, h0, x0, target\+\_\+values, n1, h1, x1, h\+\_\+neglect, h\+\_\+neglect\+\_\+edge)
\begin{DoxyCompactList}\small\item\em Build a grid by interpolating for target values. \end{DoxyCompactList}\item 
real function \mbox{\hyperlink{namespaceregrid__interp_a30dfad0833745d069498db25c1538238}{get\+\_\+polynomial\+\_\+coordinate}} (N, h, x\+\_\+g, edge\+\_\+values, ppoly\+\_\+coefs, target\+\_\+value, degree, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Given a target value, find corresponding coordinate for given polynomial. \end{DoxyCompactList}\item 
integer function \mbox{\hyperlink{namespaceregrid__interp_ab4d21d91c26022a3e79268be4fe14d44}{interpolation\+\_\+scheme}} (interp\+\_\+scheme)
\begin{DoxyCompactList}\small\item\em Numeric value of interpolation\+\_\+scheme corresponding to scheme name. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregrid__interp_ae77f3027ed51829db5d4ed6dbc744550}{set\+\_\+interp\+\_\+scheme}} (CS, interp\+\_\+scheme)
\begin{DoxyCompactList}\small\item\em Store the interpolation\+\_\+scheme value in the interp\+\_\+\+CS based on the input string. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceregrid__interp_a9ed8b5720d74090e95ca0074240a0d8a}{set\+\_\+interp\+\_\+extrap}} (CS, extrap)
\begin{DoxyCompactList}\small\item\em Store the boundary\+\_\+extrapolation value in the interp\+\_\+\+CS. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespaceregrid__interp_a0ec76d7fa1b5308e54bc44a25dca551c}\label{namespaceregrid__interp_a0ec76d7fa1b5308e54bc44a25dca551c}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a0ec76d7fa1b5308e54bc44a25dca551c}{interpolation\+\_\+p1m\+\_\+h2}} = 0
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$2) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a490ec10b45d4eb0055fd09d5bc787570}\label{namespaceregrid__interp_a490ec10b45d4eb0055fd09d5bc787570}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a490ec10b45d4eb0055fd09d5bc787570}{interpolation\+\_\+p1m\+\_\+h4}} = 1
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$2) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_ad0e6beb11f02b409e4c203c4847a949e}\label{namespaceregrid__interp_ad0e6beb11f02b409e4c203c4847a949e}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_ad0e6beb11f02b409e4c203c4847a949e}{interpolation\+\_\+p1m\+\_\+ih4}} = 2
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$2) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a5854f2a813d5b963987d298ca770a7e7}\label{namespaceregrid__interp_a5854f2a813d5b963987d298ca770a7e7}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a5854f2a813d5b963987d298ca770a7e7}{interpolation\+\_\+plm}} = 3
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$2) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a06cc3d7cc7ce4321646cc5599a83544d}\label{namespaceregrid__interp_a06cc3d7cc7ce4321646cc5599a83544d}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a06cc3d7cc7ce4321646cc5599a83544d}{interpolation\+\_\+ppm\+\_\+h4}} = 4
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$3) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a35916399421e799d1ad987663817350e}\label{namespaceregrid__interp_a35916399421e799d1ad987663817350e}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a35916399421e799d1ad987663817350e}{interpolation\+\_\+ppm\+\_\+ih4}} = 5
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$3) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a201c2e2dd8cc9581406f2e1066caa50b}\label{namespaceregrid__interp_a201c2e2dd8cc9581406f2e1066caa50b}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a201c2e2dd8cc9581406f2e1066caa50b}{interpolation\+\_\+p3m\+\_\+ih4ih3}} = 6
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$4) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_ae72fa5caf83881dda1ec2c4130bcb261}\label{namespaceregrid__interp_ae72fa5caf83881dda1ec2c4130bcb261}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_ae72fa5caf83881dda1ec2c4130bcb261}{interpolation\+\_\+p3m\+\_\+ih6ih5}} = 7
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$4) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a18c34dfd8e5582e94c76fa0dee5c8390}\label{namespaceregrid__interp_a18c34dfd8e5582e94c76fa0dee5c8390}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_a18c34dfd8e5582e94c76fa0dee5c8390}{interpolation\+\_\+pqm\+\_\+ih4ih3}} = 8
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$4) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_acd2d0f29f9e3383c6f97969c028a46cc}\label{namespaceregrid__interp_acd2d0f29f9e3383c6f97969c028a46cc}} 
integer, parameter \mbox{\hyperlink{namespaceregrid__interp_acd2d0f29f9e3383c6f97969c028a46cc}{interpolation\+\_\+pqm\+\_\+ih6ih5}} = 9
\begin{DoxyCompactList}\small\item\em O(h$^\wedge$5) \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_ab5894f4be17b065c3939294014200a32}\label{namespaceregrid__interp_ab5894f4be17b065c3939294014200a32}} 
real, parameter, public \mbox{\hyperlink{namespaceregrid__interp_ab5894f4be17b065c3939294014200a32}{nr\+\_\+offset}} = 1e-\/6
\begin{DoxyCompactList}\small\item\em When the N-\/R algorithm produces an estimate that lies outside \mbox{[}0,1\mbox{]}, the estimate is set to be equal to the boundary location, 0 or 1, plus or minus an offset, respectively, when the derivative is zero at the boundary \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_a6543421d37edc724a8a7928ccf54a21c}\label{namespaceregrid__interp_a6543421d37edc724a8a7928ccf54a21c}} 
integer, parameter, public \mbox{\hyperlink{namespaceregrid__interp_a6543421d37edc724a8a7928ccf54a21c}{nr\+\_\+iterations}} = 8
\begin{DoxyCompactList}\small\item\em Maximum number of Newton-\/\+Raphson iterations. Newton-\/\+Raphson iterations are used to build the new grid by finding the coordinates associated with target densities and interpolations of degree larger than 1. \end{DoxyCompactList}\item 
\mbox{\Hypertarget{namespaceregrid__interp_aa85701b7a23c13c6ac8b19916b13bb3e}\label{namespaceregrid__interp_aa85701b7a23c13c6ac8b19916b13bb3e}} 
real, parameter, public \mbox{\hyperlink{namespaceregrid__interp_aa85701b7a23c13c6ac8b19916b13bb3e}{nr\+\_\+tolerance}} = 1e-\/12
\begin{DoxyCompactList}\small\item\em Tolerance for Newton-\/\+Raphson iterations (stop when increment falls below this) \mbox{[}nondim\mbox{]}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceregrid__interp_abaef8cc7e1258b61710adbd6fb742122}\label{namespaceregrid__interp_abaef8cc7e1258b61710adbd6fb742122}} 
\index{regrid\_interp@{regrid\_interp}!build\_and\_interpolate\_grid@{build\_and\_interpolate\_grid}}
\index{build\_and\_interpolate\_grid@{build\_and\_interpolate\_grid}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{build\_and\_interpolate\_grid()}{build\_and\_interpolate\_grid()}}
{\footnotesize\ttfamily subroutine, public regrid\+\_\+interp\+::build\+\_\+and\+\_\+interpolate\+\_\+grid (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structregrid__interp_1_1interp__cs__type}{interp\+\_\+cs\+\_\+type}}), intent(in)}]{CS,  }\item[{real, dimension(n0), intent(in)}]{densities,  }\item[{integer, intent(in)}]{n0,  }\item[{real, dimension(n0), intent(in)}]{h0,  }\item[{real, dimension(n0+1), intent(in)}]{x0,  }\item[{real, dimension(n1+1), intent(in)}]{target\+\_\+values,  }\item[{integer, intent(in)}]{n1,  }\item[{real, dimension(n1), intent(inout)}]{h1,  }\item[{real, dimension(n1+1), intent(inout)}]{x1,  }\item[{real, intent(in), optional}]{h\+\_\+neglect,  }\item[{real, intent(in), optional}]{h\+\_\+neglect\+\_\+edge }\end{DoxyParamCaption})}



Build a grid by interpolating for target values. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs} & A control structure for \mbox{\hyperlink{namespaceregrid__interp}{regrid\+\_\+interp}} \\
\hline
\mbox{\texttt{ in}}  & {\em n0} & The number of points on the input grid \\
\hline
\mbox{\texttt{ in}}  & {\em n1} & The number of points on the output grid \\
\hline
\mbox{\texttt{ in}}  & {\em densities} & Input cell densities \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em target\+\_\+values} & Target values of interfaces \mbox{[}R $\sim$$>$ kg m-\/3\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h0} & Initial cell widths \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em x0} & Source interface positions \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em h1} & Output cell widths \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em x1} & Target interface positions \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width for the purpose of cell reconstructions \mbox{[}H\mbox{]} in the same units as h0. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect\+\_\+edge} & A negligibly small width for the purpose of edge value calculations \mbox{[}H\mbox{]} in the same units as h0. \\
\hline
\end{DoxyParams}


Definition at line 307 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{309   \textcolor{keywordtype}{type}(interp\_CS\_type),  \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{  !< A control structure for regrid\_interp}}
\DoxyCodeLine{310   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: n0\textcolor{comment}{  !< The number of points on the input grid}}
\DoxyCodeLine{311   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: n1\textcolor{comment}{  !< The number of points on the output grid}}
\DoxyCodeLine{312 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0)},   \textcolor{keywordtype}{intent(in)}    :: densities\textcolor{comment}{ !< Input cell densities [R \string~> kg m-\/3]}}
\DoxyCodeLine{313 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1+1)}, \textcolor{keywordtype}{intent(in)}    :: target\_values\textcolor{comment}{ !< Target values of interfaces [R \string~> kg m-\/3]}}
\DoxyCodeLine{314 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0)},   \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{  !< Initial cell widths [H]}}
\DoxyCodeLine{315 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0+1)}, \textcolor{keywordtype}{intent(in)}    :: x0\textcolor{comment}{  !< Source interface positions [H]}}
\DoxyCodeLine{316 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1)},   \textcolor{keywordtype}{intent(inout)} :: h1\textcolor{comment}{  !< Output cell widths [H]}}
\DoxyCodeLine{317 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1+1)}, \textcolor{keywordtype}{intent(inout)} :: x1\textcolor{comment}{  !< Target interface positions [H]}}
\DoxyCodeLine{318 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width for the}}
\DoxyCodeLine{319 \textcolor{comment}{                                           !! purpose of cell reconstructions [H]}}
\DoxyCodeLine{320 \textcolor{comment}{                                           !! in the same units as h0.}}
\DoxyCodeLine{321 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\_edge\textcolor{comment}{ !< A negligibly small width}}
\DoxyCodeLine{322 \textcolor{comment}{                                           !! for the purpose of edge value calculations [H]}}
\DoxyCodeLine{323 \textcolor{comment}{                                           !! in the same units as h0.}}
\DoxyCodeLine{324 }
\DoxyCodeLine{325 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,2)} :: ppoly0\_E   \textcolor{comment}{! Polynomial edge values [R \string~> kg m-\/3]}}
\DoxyCodeLine{326 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,2)} :: ppoly0\_S   \textcolor{comment}{! Polynomial edge slopes [R H-\/1]}}
\DoxyCodeLine{327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,DEGREE\_MAX+1)} :: ppoly0\_C  \textcolor{comment}{! Polynomial interpolant coeficients on the local 0-\/1 grid [R \string~> kg m-\/3]}}
\DoxyCodeLine{328   \textcolor{keywordtype}{integer} :: degree}
\DoxyCodeLine{329 }
\DoxyCodeLine{330   \textcolor{keyword}{call }regridding\_set\_ppolys(cs, densities, n0, h0, ppoly0\_e, ppoly0\_s, ppoly0\_c, \&}
\DoxyCodeLine{331        degree, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{332   \textcolor{keyword}{call }interpolate\_grid(n0, h0, x0, ppoly0\_e, ppoly0\_c, target\_values, degree, \&}
\DoxyCodeLine{333        n1, h1, x1, answers\_2018=cs\%answers\_2018)}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_a30dfad0833745d069498db25c1538238}\label{namespaceregrid__interp_a30dfad0833745d069498db25c1538238}} 
\index{regrid\_interp@{regrid\_interp}!get\_polynomial\_coordinate@{get\_polynomial\_coordinate}}
\index{get\_polynomial\_coordinate@{get\_polynomial\_coordinate}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{get\_polynomial\_coordinate()}{get\_polynomial\_coordinate()}}
{\footnotesize\ttfamily real function regrid\+\_\+interp\+::get\+\_\+polynomial\+\_\+coordinate (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{N,  }\item[{real, dimension(n), intent(in)}]{h,  }\item[{real, dimension(n+1), intent(in)}]{x\+\_\+g,  }\item[{real, dimension(n,2), intent(in)}]{edge\+\_\+values,  }\item[{real, dimension(n,\mbox{\hyperlink{namespaceregrid__interp_af4013d842f389abc724a0d2f34366eda}{degree\+\_\+max}}+1), intent(in)}]{ppoly\+\_\+coefs,  }\item[{real, intent(in)}]{target\+\_\+value,  }\item[{integer, intent(in)}]{degree,  }\item[{logical, intent(in), optional}]{answers\+\_\+2018 }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Given a target value, find corresponding coordinate for given polynomial. 

Here, \textquotesingle{}ppoly\textquotesingle{} is assumed to be a piecewise discontinuous polynomial of degree \textquotesingle{}degree\textquotesingle{} throughout the domain defined by \textquotesingle{}grid\textquotesingle{}. A target value is given and we need to determine the corresponding grid coordinate to define the new grid.

If the target value is out of range, the grid coordinate is simply set to be equal to one of the boundary coordinates, which results in vanished layers near the boundaries.

IT IS A\+S\+S\+U\+M\+ED T\+H\+AT T\+HE P\+I\+E\+C\+E\+W\+I\+SE P\+O\+L\+Y\+N\+O\+M\+I\+AL IS M\+O\+N\+O\+T\+O\+N\+I\+C\+A\+L\+LY I\+N\+C\+R\+E\+A\+S\+I\+NG. IF T\+H\+IS IS N\+OT T\+HE C\+A\+SE, T\+HE N\+EW G\+R\+ID M\+AY BE I\+L\+L-\/\+D\+E\+F\+I\+N\+ED.

It is assumed that the number of cells defining \textquotesingle{}grid\textquotesingle{} and \textquotesingle{}ppoly\textquotesingle{} are the same. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n} & Number of grid cells \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Grid cell thicknesses \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em x\+\_\+g} & Grid interface locations \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em edge\+\_\+values} & Edge values of interpolating polynomials \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ppoly\+\_\+coefs} & Coefficients of interpolating polynomials \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em target\+\_\+value} & Target value to find position for \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em degree} & Degree of the interpolating polynomials \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true use older, less acccurate expressions. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The position of x\+\_\+g at which target\+\_\+value is found \mbox{[}H\mbox{]} 
\end{DoxyReturn}


Definition at line 352 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{354   \textcolor{comment}{! Arguments}}
\DoxyCodeLine{355   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)} :: N\textcolor{comment}{            !< Number of grid cells}}
\DoxyCodeLine{356 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N)},   \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{            !< Grid cell thicknesses [H]}}
\DoxyCodeLine{357 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N+1)}, \textcolor{keywordtype}{intent(in)} :: x\_g\textcolor{comment}{          !< Grid interface locations [H]}}
\DoxyCodeLine{358 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N,2)}, \textcolor{keywordtype}{intent(in)} :: edge\_values\textcolor{comment}{  !< Edge values of interpolating polynomials [A]}}
\DoxyCodeLine{359 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(N,DEGREE\_MAX+1)}, \textcolor{keywordtype}{intent(in)} :: ppoly\_coefs\textcolor{comment}{  !< Coefficients of interpolating polynomials [A]}}
\DoxyCodeLine{360 \textcolor{keywordtype}{  real},                 \textcolor{keywordtype}{intent(in)} :: target\_value\textcolor{comment}{ !< Target value to find position for [A]}}
\DoxyCodeLine{361   \textcolor{keywordtype}{integer},              \textcolor{keywordtype}{intent(in)} :: degree\textcolor{comment}{       !< Degree of the interpolating polynomials}}
\DoxyCodeLine{362   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: answers\_2018\textcolor{comment}{ !< If true use older, less acccurate expressions.}}
\DoxyCodeLine{363 \textcolor{keywordtype}{  real}                             :: x\_tgt\textcolor{comment}{        !< The position of x\_g at which target\_value is found [H]}}
\DoxyCodeLine{364 }
\DoxyCodeLine{365   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{366 \textcolor{keywordtype}{  real}                        :: xi0         \textcolor{comment}{! normalized target coordinate [nondim]}}
\DoxyCodeLine{367 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(DEGREE\_MAX)} :: a           \textcolor{comment}{! polynomial coefficients [A]}}
\DoxyCodeLine{368 \textcolor{keywordtype}{  real}                        :: numerator}
\DoxyCodeLine{369 \textcolor{keywordtype}{  real}                        :: denominator}
\DoxyCodeLine{370 \textcolor{keywordtype}{  real}                        :: delta       \textcolor{comment}{! Newton-\/Raphson increment [nondim]}}
\DoxyCodeLine{371 \textcolor{comment}{!   real                        :: x           ! global target coordinate}}
\DoxyCodeLine{372 \textcolor{keywordtype}{  real}                        :: eps         \textcolor{comment}{! offset used to get away from boundaries [nondim]}}
\DoxyCodeLine{373 \textcolor{keywordtype}{  real}                        :: grad        \textcolor{comment}{! gradient during N-\/R iterations [A]}}
\DoxyCodeLine{374   \textcolor{keywordtype}{integer} :: i, k, iter  \textcolor{comment}{! loop indices}}
\DoxyCodeLine{375   \textcolor{keywordtype}{integer} :: k\_found     \textcolor{comment}{! index of target cell}}
\DoxyCodeLine{376   \textcolor{keywordtype}{character(len=200)} :: mesg}
\DoxyCodeLine{377   \textcolor{keywordtype}{logical} :: use\_2018\_answers  \textcolor{comment}{! If true use older, less acccurate expressions.}}
\DoxyCodeLine{378 }
\DoxyCodeLine{379   eps = nr\_offset}
\DoxyCodeLine{380   k\_found = -\/1}
\DoxyCodeLine{381   use\_2018\_answers = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(answers\_2018)) use\_2018\_answers = answers\_2018}
\DoxyCodeLine{382 }
\DoxyCodeLine{383   \textcolor{comment}{! If the target value is outside the range of all values, we}}
\DoxyCodeLine{384   \textcolor{comment}{! force the target coordinate to be equal to the lowest or}}
\DoxyCodeLine{385   \textcolor{comment}{! largest value, depending on which bound is overtaken}}
\DoxyCodeLine{386   \textcolor{keywordflow}{if} ( target\_value <= edge\_values(1,1) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{387     x\_tgt = x\_g(1)}
\DoxyCodeLine{388     \textcolor{keywordflow}{return}  \textcolor{comment}{! return because there is no need to look further}}
\DoxyCodeLine{389 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{390 }
\DoxyCodeLine{391   \textcolor{comment}{! Since discontinuous edge values are allowed, we check whether the target}}
\DoxyCodeLine{392   \textcolor{comment}{! value lies between two discontinuous edge values at interior interfaces}}
\DoxyCodeLine{393   \textcolor{keywordflow}{do} k = 2,n}
\DoxyCodeLine{394     \textcolor{keywordflow}{if} ( ( target\_value >= edge\_values(k-\/1,2) ) .AND. ( target\_value <= edge\_values(k,1) ) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{395       x\_tgt = x\_g(k)}
\DoxyCodeLine{396       \textcolor{keywordflow}{return}   \textcolor{comment}{! return because there is no need to look further}}
\DoxyCodeLine{397 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{398 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{399 }
\DoxyCodeLine{400   \textcolor{comment}{! If the target value is outside the range of all values, we}}
\DoxyCodeLine{401   \textcolor{comment}{! force the target coordinate to be equal to the lowest or}}
\DoxyCodeLine{402   \textcolor{comment}{! largest value, depending on which bound is overtaken}}
\DoxyCodeLine{403   \textcolor{keywordflow}{if} ( target\_value >= edge\_values(n,2) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{404     x\_tgt = x\_g(n+1)}
\DoxyCodeLine{405     \textcolor{keywordflow}{return}  \textcolor{comment}{! return because there is no need to look further}}
\DoxyCodeLine{406 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{407 }
\DoxyCodeLine{408   \textcolor{comment}{! At this point, we know that the target value is bounded and does not}}
\DoxyCodeLine{409   \textcolor{comment}{! lie between discontinuous, monotonic edge values. Therefore,}}
\DoxyCodeLine{410   \textcolor{comment}{! there is a unique solution. We loop on all cells and find which one}}
\DoxyCodeLine{411   \textcolor{comment}{! contains the target value. The variable k\_found holds the index value}}
\DoxyCodeLine{412   \textcolor{comment}{! of the cell where the taregt value lies.}}
\DoxyCodeLine{413   \textcolor{keywordflow}{do} k = 1,n}
\DoxyCodeLine{414     \textcolor{keywordflow}{if} ( ( target\_value > edge\_values(k,1) ) .AND. ( target\_value < edge\_values(k,2) ) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{415       k\_found = k}
\DoxyCodeLine{416       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{417 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{418 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{419 }
\DoxyCodeLine{420   \textcolor{comment}{! At this point, 'k\_found' should be strictly positive. If not, this is}}
\DoxyCodeLine{421   \textcolor{comment}{! a major failure because it means we could not find any target cell}}
\DoxyCodeLine{422   \textcolor{comment}{! despite the fact that the target value lies between the extremes. It}}
\DoxyCodeLine{423   \textcolor{comment}{! means there is a major problem with the interpolant. This needs to be}}
\DoxyCodeLine{424   \textcolor{comment}{! reported.}}
\DoxyCodeLine{425   \textcolor{keywordflow}{if} ( k\_found == -\/1 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{426     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Could not find target coordinate'}, target\_value, \textcolor{stringliteral}{'in get\_polynomial\_coordinate. This is '}//\&}
\DoxyCodeLine{427                   \textcolor{stringliteral}{'caused by an inconsistent interpolant (perhaps not monotonically increasing):'}, \&}
\DoxyCodeLine{428                   target\_value, edge\_values(1,1), edge\_values(n,2)}
\DoxyCodeLine{429     \textcolor{keyword}{call }mom\_error( fatal, mesg )}
\DoxyCodeLine{430 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{431 }
\DoxyCodeLine{432   \textcolor{comment}{! Reset all polynomial coefficients to 0 and copy those pertaining to}}
\DoxyCodeLine{433   \textcolor{comment}{! the found cell}}
\DoxyCodeLine{434   a(:) = 0.0}
\DoxyCodeLine{435   \textcolor{keywordflow}{do} i = 1,degree+1}
\DoxyCodeLine{436     a(i) = ppoly\_coefs(k\_found,i)}
\DoxyCodeLine{437 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{438 }
\DoxyCodeLine{439   \textcolor{comment}{! Guess the middle of the cell to start Newton-\/Raphson iterations}}
\DoxyCodeLine{440   xi0 = 0.5}
\DoxyCodeLine{441 }
\DoxyCodeLine{442   \textcolor{comment}{! Newton-\/Raphson iterations}}
\DoxyCodeLine{443   \textcolor{keywordflow}{do} iter = 1,nr\_iterations}
\DoxyCodeLine{444 }
\DoxyCodeLine{445     \textcolor{keywordflow}{if} (use\_2018\_answers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{446       numerator = a(1) + a(2)*xi0 + a(3)*xi0*xi0 + a(4)*xi0*xi0*xi0 + \&}
\DoxyCodeLine{447                   a(5)*xi0*xi0*xi0*xi0 -\/ target\_value}
\DoxyCodeLine{448       denominator = a(2) + 2*a(3)*xi0 + 3*a(4)*xi0*xi0 + 4*a(5)*xi0*xi0*xi0}
\DoxyCodeLine{449     \textcolor{keywordflow}{else}  \textcolor{comment}{! These expressions are mathematicaly equivalent but more accurate.}}
\DoxyCodeLine{450       numerator = (a(1) -\/ target\_value) + xi0*(a(2) + xi0*(a(3) + xi0*(a(4) + a(5)*xi0)))}
\DoxyCodeLine{451       denominator = a(2) + xi0*(2.*a(3) + xi0*(3.*a(4) + 4.*a(5)*xi0))}
\DoxyCodeLine{452 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{453 }
\DoxyCodeLine{454     delta = -\/numerator / denominator}
\DoxyCodeLine{455 }
\DoxyCodeLine{456     xi0 = xi0 + delta}
\DoxyCodeLine{457 }
\DoxyCodeLine{458     \textcolor{comment}{! Check whether new estimate is out of bounds. If the new estimate is}}
\DoxyCodeLine{459     \textcolor{comment}{! indeed out of bounds, we manually set it to be equal to the overtaken}}
\DoxyCodeLine{460     \textcolor{comment}{! bound with a small offset towards the interior when the gradient of}}
\DoxyCodeLine{461     \textcolor{comment}{! the function at the boundary is zero (in which case, the Newton-\/Raphson}}
\DoxyCodeLine{462     \textcolor{comment}{! algorithm does not converge).}}
\DoxyCodeLine{463     \textcolor{keywordflow}{if} ( xi0 < 0.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{464       xi0 = 0.0}
\DoxyCodeLine{465       grad = a(2)}
\DoxyCodeLine{466       \textcolor{keywordflow}{if} ( grad == 0.0 ) xi0 = xi0 + eps}
\DoxyCodeLine{467 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{468 }
\DoxyCodeLine{469     \textcolor{keywordflow}{if} ( xi0 > 1.0 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{470       xi0 = 1.0}
\DoxyCodeLine{471       \textcolor{keywordflow}{if} (use\_2018\_answers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{472         grad = a(2) + 2*a(3) + 3*a(4) + 4*a(5)}
\DoxyCodeLine{473       \textcolor{keywordflow}{else}  \textcolor{comment}{! These expressions are mathematicaly equivalent but more accurate.}}
\DoxyCodeLine{474         grad = a(2) + (2.*a(3) + (3.*a(4) + 4.*a(5)))}
\DoxyCodeLine{475 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{476       \textcolor{keywordflow}{if} ( grad == 0.0 ) xi0 = xi0 -\/ eps}
\DoxyCodeLine{477 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{478 }
\DoxyCodeLine{479     \textcolor{comment}{! break if converged or too many iterations taken}}
\DoxyCodeLine{480     \textcolor{keywordflow}{if} ( abs(delta) < nr\_tolerance ) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{481 \textcolor{keywordflow}{  enddo} \textcolor{comment}{! end Newton-\/Raphson iterations}}
\DoxyCodeLine{482 }
\DoxyCodeLine{483   x\_tgt = x\_g(k\_found) + xi0 * h(k\_found)}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_a52b8ce5b52f9d45f8180c6fd75388174}\label{namespaceregrid__interp_a52b8ce5b52f9d45f8180c6fd75388174}} 
\index{regrid\_interp@{regrid\_interp}!interpolate\_grid@{interpolate\_grid}}
\index{interpolate\_grid@{interpolate\_grid}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{interpolate\_grid()}{interpolate\_grid()}}
{\footnotesize\ttfamily subroutine, public regrid\+\_\+interp\+::interpolate\+\_\+grid (\begin{DoxyParamCaption}\item[{integer, intent(in)}]{n0,  }\item[{real, dimension(n0), intent(in)}]{h0,  }\item[{real, dimension(n0+1), intent(in)}]{x0,  }\item[{real, dimension(n0,2), intent(in)}]{ppoly0\+\_\+E,  }\item[{real, dimension(n0,\mbox{\hyperlink{namespaceregrid__interp_af4013d842f389abc724a0d2f34366eda}{degree\+\_\+max}}+1), intent(in)}]{ppoly0\+\_\+coefs,  }\item[{real, dimension(n1+1), intent(in)}]{target\+\_\+values,  }\item[{integer, intent(in)}]{degree,  }\item[{integer, intent(in)}]{n1,  }\item[{real, dimension(n1), intent(inout)}]{h1,  }\item[{real, dimension(n1+1), intent(inout)}]{x1,  }\item[{logical, intent(in), optional}]{answers\+\_\+2018 }\end{DoxyParamCaption})}



Given target values (e.\+g., density), build new grid based on polynomial. 

Given the grid \textquotesingle{}grid0\textquotesingle{} and the piecewise polynomial interpolant \textquotesingle{}ppoly0\textquotesingle{} (possibly discontinuous), the coordinates of the new grid \textquotesingle{}grid1\textquotesingle{} are determined by finding the corresponding target interface densities. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em n0} & Number of points on source grid \\
\hline
\mbox{\texttt{ in}}  & {\em n1} & Number of points on target grid \\
\hline
\mbox{\texttt{ in}}  & {\em h0} & Thicknesses of source grid cells \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em x0} & Source interface positions \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ppoly0\+\_\+e} & Edge values of interpolating polynomials \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em ppoly0\+\_\+coefs} & Coefficients of interpolating polynomials \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em target\+\_\+values} & Target values of interfaces \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em degree} & Degree of interpolating polynomials \\
\hline
\mbox{\texttt{ in,out}}  & {\em h1} & Thicknesses of target grid cells \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em x1} & Target interface positions \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true use older, less acccurate expressions. \\
\hline
\end{DoxyParams}


Definition at line 270 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{272   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}     :: n0\textcolor{comment}{            !< Number of points on source grid}}
\DoxyCodeLine{273   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}     :: n1\textcolor{comment}{            !< Number of points on target grid}}
\DoxyCodeLine{274 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0)},   \textcolor{keywordtype}{intent(in)}     :: h0\textcolor{comment}{            !< Thicknesses of source grid cells [H]}}
\DoxyCodeLine{275 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0+1)}, \textcolor{keywordtype}{intent(in)}     :: x0\textcolor{comment}{            !< Source interface positions [H]}}
\DoxyCodeLine{276 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,2)}, \textcolor{keywordtype}{intent(in)}     :: ppoly0\_E\textcolor{comment}{      !< Edge values of interpolating polynomials [A]}}
\DoxyCodeLine{277 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,DEGREE\_MAX+1)}, \&}
\DoxyCodeLine{278                           \textcolor{keywordtype}{intent(in)}    :: ppoly0\_coefs\textcolor{comment}{  !< Coefficients of interpolating polynomials [A]}}
\DoxyCodeLine{279 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1+1)},  \textcolor{keywordtype}{intent(in)}    :: target\_values\textcolor{comment}{ !< Target values of interfaces [A]}}
\DoxyCodeLine{280   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}    :: degree\textcolor{comment}{        !< Degree of interpolating polynomials}}
\DoxyCodeLine{281 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1)},    \textcolor{keywordtype}{intent(inout)} :: h1\textcolor{comment}{            !< Thicknesses of target grid cells [H]}}
\DoxyCodeLine{282 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n1+1)},  \textcolor{keywordtype}{intent(inout)} :: x1\textcolor{comment}{            !< Target interface positions [H]}}
\DoxyCodeLine{283   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{  !< If true use older, less acccurate expressions.}}
\DoxyCodeLine{284 }
\DoxyCodeLine{285   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{286   \textcolor{keywordtype}{logical}   :: use\_2018\_answers  \textcolor{comment}{! If true use older, less acccurate expressions.}}
\DoxyCodeLine{287   \textcolor{keywordtype}{integer}        :: k \textcolor{comment}{! loop index}}
\DoxyCodeLine{288 \textcolor{keywordtype}{  real}           :: t \textcolor{comment}{! current interface target density}}
\DoxyCodeLine{289 }
\DoxyCodeLine{290   \textcolor{comment}{! Make sure boundary coordinates of new grid coincide with boundary}}
\DoxyCodeLine{291   \textcolor{comment}{! coordinates of previous grid}}
\DoxyCodeLine{292   x1(1) = x0(1)}
\DoxyCodeLine{293   x1(n1+1) = x0(n0+1)}
\DoxyCodeLine{294 }
\DoxyCodeLine{295   \textcolor{comment}{! Find coordinates for interior target values}}
\DoxyCodeLine{296   \textcolor{keywordflow}{do} k = 2,n1}
\DoxyCodeLine{297     t = target\_values(k)}
\DoxyCodeLine{298     x1(k) = get\_polynomial\_coordinate( n0, h0, x0, ppoly0\_e, ppoly0\_coefs, t, degree, \&}
\DoxyCodeLine{299                                         answers\_2018=answers\_2018 )}
\DoxyCodeLine{300     h1(k-\/1) = x1(k) -\/ x1(k-\/1)}
\DoxyCodeLine{301 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{302   h1(n1) = x1(n1+1) -\/ x1(n1)}
\DoxyCodeLine{303 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_ab4d21d91c26022a3e79268be4fe14d44}\label{namespaceregrid__interp_ab4d21d91c26022a3e79268be4fe14d44}} 
\index{regrid\_interp@{regrid\_interp}!interpolation\_scheme@{interpolation\_scheme}}
\index{interpolation\_scheme@{interpolation\_scheme}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{interpolation\_scheme()}{interpolation\_scheme()}}
{\footnotesize\ttfamily integer function regrid\+\_\+interp\+::interpolation\+\_\+scheme (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{interp\+\_\+scheme }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Numeric value of interpolation\+\_\+scheme corresponding to scheme name. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em interp\+\_\+scheme} & Name of the interpolation scheme Valid values include \char`\"{}\+P1\+M\+\_\+\+H2\char`\"{}, \char`\"{}\+P1\+M\+\_\+\+H4\char`\"{}, \char`\"{}\+P1\+M\+\_\+\+I\+H2\char`\"{}, \char`\"{}\+P\+L\+M\char`\"{}, \char`\"{}\+P\+P\+M\+\_\+\+H4\char`\"{}, \char`\"{}\+P\+P\+M\+\_\+\+I\+H4\char`\"{}, \char`\"{}\+P3\+M\+\_\+\+I\+H4\+I\+H3\char`\"{}, \char`\"{}\+P3\+M\+\_\+\+I\+H6\+I\+H5\char`\"{}, \char`\"{}\+P\+Q\+M\+\_\+\+I\+H4\+I\+H3\char`\"{}, and \char`\"{}\+P\+Q\+M\+\_\+\+I\+H6\+I\+H5\char`\"{} \\
\hline
\end{DoxyParams}


Definition at line 487 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{488   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: interp\_scheme\textcolor{comment}{ !< Name of the interpolation scheme}}
\DoxyCodeLine{489 \textcolor{comment}{        !! Valid values include "{}P1M\_H2"{}, "{}P1M\_H4"{}, "{}P1M\_IH2"{}, "{}PLM"{}, "{}PPM\_H4"{},}}
\DoxyCodeLine{490 \textcolor{comment}{        !!   "{}PPM\_IH4"{}, "{}P3M\_IH4IH3"{}, "{}P3M\_IH6IH5"{}, "{}PQM\_IH4IH3"{}, and "{}PQM\_IH6IH5"{}}}
\DoxyCodeLine{491 }
\DoxyCodeLine{492   \textcolor{keywordflow}{select case} ( uppercase(trim(interp\_scheme)) )}
\DoxyCodeLine{493     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}P1M\_H2"{}});     interpolation\_scheme = interpolation\_p1m\_h2}
\DoxyCodeLine{494     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}P1M\_H4"{}});     interpolation\_scheme = interpolation\_p1m\_h4}
\DoxyCodeLine{495     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}P1M\_IH2"{}});    interpolation\_scheme = interpolation\_p1m\_ih4}
\DoxyCodeLine{496     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}PLM"{}});        interpolation\_scheme = interpolation\_plm}
\DoxyCodeLine{497     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}PPM\_H4"{}});     interpolation\_scheme = interpolation\_ppm\_h4}
\DoxyCodeLine{498     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}PPM\_IH4"{}});    interpolation\_scheme = interpolation\_ppm\_ih4}
\DoxyCodeLine{499     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}P3M\_IH4IH3"{}}); interpolation\_scheme = interpolation\_p3m\_ih4ih3}
\DoxyCodeLine{500     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}P3M\_IH6IH5"{}}); interpolation\_scheme = interpolation\_p3m\_ih6ih5}
\DoxyCodeLine{501     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}PQM\_IH4IH3"{}}); interpolation\_scheme = interpolation\_pqm\_ih4ih3}
\DoxyCodeLine{502     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"{}PQM\_IH6IH5"{}}); interpolation\_scheme = interpolation\_pqm\_ih6ih5}
\DoxyCodeLine{503 \textcolor{keywordflow}{    case default} ; \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}regrid\_interp: "{}}//\&}
\DoxyCodeLine{504      \textcolor{stringliteral}{"{}Unrecognized choice for INTERPOLATION\_SCHEME ("{}}//trim(interp\_scheme)//\textcolor{stringliteral}{"{})."{}})}
\DoxyCodeLine{505 \textcolor{keywordflow}{  end select}}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_a3d1406836d089b4553421776277e1339}\label{namespaceregrid__interp_a3d1406836d089b4553421776277e1339}} 
\index{regrid\_interp@{regrid\_interp}!regridding\_set\_ppolys@{regridding\_set\_ppolys}}
\index{regridding\_set\_ppolys@{regridding\_set\_ppolys}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{regridding\_set\_ppolys()}{regridding\_set\_ppolys()}}
{\footnotesize\ttfamily subroutine, public regrid\+\_\+interp\+::regridding\+\_\+set\+\_\+ppolys (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structregrid__interp_1_1interp__cs__type}{interp\+\_\+cs\+\_\+type}}), intent(in)}]{CS,  }\item[{real, dimension(n0), intent(in)}]{densities,  }\item[{integer, intent(in)}]{n0,  }\item[{real, dimension(n0), intent(in)}]{h0,  }\item[{real, dimension(n0,2), intent(inout)}]{ppoly0\+\_\+E,  }\item[{real, dimension(n0,2), intent(inout)}]{ppoly0\+\_\+S,  }\item[{real, dimension(n0,\mbox{\hyperlink{namespaceregrid__interp_af4013d842f389abc724a0d2f34366eda}{degree\+\_\+max}}+1), intent(inout)}]{ppoly0\+\_\+coefs,  }\item[{integer, intent(inout)}]{degree,  }\item[{real, intent(in), optional}]{h\+\_\+neglect,  }\item[{real, intent(in), optional}]{h\+\_\+neglect\+\_\+edge }\end{DoxyParamCaption})}



Builds an interpolated profile for the densities within each grid cell. 

It may happen that, given a high-\/order interpolator, the number of available layers is insufficient (e.\+g., there are two available layers for a third-\/order P\+PM ih4 scheme). In these cases, we resort to the simplest continuous linear scheme (P1M h2). 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs} & Interpolation control structure \\
\hline
\mbox{\texttt{ in}}  & {\em n0} & Number of cells on source grid \\
\hline
\mbox{\texttt{ in}}  & {\em densities} & Actual cell densities \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h0} & cell widths on source grid \mbox{[}H\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly0\+\_\+e} & Edge value of polynomial \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly0\+\_\+s} & Edge slope of polynomial \mbox{[}A H-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em ppoly0\+\_\+coefs} & Coefficients of polynomial \mbox{[}A\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em degree} & The degree of the polynomials \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect} & A negligibly small width for the purpose of cell reconstructions \mbox{[}H\mbox{]} in the same units as h0. \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+neglect\+\_\+edge} & A negligibly small width for the purpose of edge value calculations \mbox{[}H\mbox{]} in the same units as h0. \\
\hline
\end{DoxyParams}


Definition at line 78 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{80   \textcolor{keywordtype}{type}(interp\_CS\_type),  \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< Interpolation control structure}}
\DoxyCodeLine{81   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: n0\textcolor{comment}{ !< Number of cells on source grid}}
\DoxyCodeLine{82 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0)},   \textcolor{keywordtype}{intent(in)}    :: densities\textcolor{comment}{ !< Actual cell densities [A]}}
\DoxyCodeLine{83 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0)},   \textcolor{keywordtype}{intent(in)}    :: h0\textcolor{comment}{ !< cell widths on source grid [H]}}
\DoxyCodeLine{84 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,2)}, \textcolor{keywordtype}{intent(inout)} :: ppoly0\_E\textcolor{comment}{  !< Edge value of polynomial [A]}}
\DoxyCodeLine{85 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,2)}, \textcolor{keywordtype}{intent(inout)} :: ppoly0\_S\textcolor{comment}{  !< Edge slope of polynomial [A H-\/1]}}
\DoxyCodeLine{86 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(n0,DEGREE\_MAX+1)}, \textcolor{keywordtype}{intent(inout)} :: ppoly0\_coefs\textcolor{comment}{ !< Coefficients of polynomial [A]}}
\DoxyCodeLine{87   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(inout)} :: degree\textcolor{comment}{    !< The degree of the polynomials}}
\DoxyCodeLine{88 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\textcolor{comment}{ !< A negligibly small width for the}}
\DoxyCodeLine{89 \textcolor{comment}{                                             !! purpose of cell reconstructions [H]}}
\DoxyCodeLine{90 \textcolor{comment}{                                             !! in the same units as h0.}}
\DoxyCodeLine{91 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: h\_neglect\_edge\textcolor{comment}{ !< A negligibly small width}}
\DoxyCodeLine{92 \textcolor{comment}{                                             !! for the purpose of edge value calculations [H]}}
\DoxyCodeLine{93 \textcolor{comment}{                                             !! in the same units as h0.}}
\DoxyCodeLine{94   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{95   \textcolor{keywordtype}{logical} :: extrapolate}
\DoxyCodeLine{96 }
\DoxyCodeLine{97   \textcolor{comment}{! Reset piecewise polynomials}}
\DoxyCodeLine{98   ppoly0\_e(:,:) = 0.0}
\DoxyCodeLine{99   ppoly0\_s(:,:) = 0.0}
\DoxyCodeLine{100   ppoly0\_coefs(:,:) = 0.0}
\DoxyCodeLine{101 }
\DoxyCodeLine{102   extrapolate = cs\%boundary\_extrapolation}
\DoxyCodeLine{103 }
\DoxyCodeLine{104   \textcolor{comment}{! Compute the interpolated profile of the density field and build grid}}
\DoxyCodeLine{105   \textcolor{keywordflow}{select case} (cs\%interpolation\_scheme)}
\DoxyCodeLine{106 }
\DoxyCodeLine{107     \textcolor{keywordflow}{case} ( interpolation\_p1m\_h2 )}
\DoxyCodeLine{108       degree = degree\_1}
\DoxyCodeLine{109       \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{110       \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{111       \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{112         \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{113 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{114 }
\DoxyCodeLine{115     \textcolor{keywordflow}{case} ( interpolation\_p1m\_h4 )}
\DoxyCodeLine{116       degree = degree\_1}
\DoxyCodeLine{117       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{118         \textcolor{keyword}{call }edge\_values\_explicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{119       \textcolor{keywordflow}{else}}
\DoxyCodeLine{120         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{121 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{122       \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{123       \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{124         \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{125 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{126 }
\DoxyCodeLine{127     \textcolor{keywordflow}{case} ( interpolation\_p1m\_ih4 )}
\DoxyCodeLine{128       degree = degree\_1}
\DoxyCodeLine{129       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{130         \textcolor{keyword}{call }edge\_values\_implicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{131       \textcolor{keywordflow}{else}}
\DoxyCodeLine{132         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{133 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{134       \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{135       \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{136         \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{137 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{138 }
\DoxyCodeLine{139     \textcolor{keywordflow}{case} ( interpolation\_plm )}
\DoxyCodeLine{140       degree = degree\_1}
\DoxyCodeLine{141       \textcolor{keyword}{call }plm\_reconstruction( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{142       \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{143         \textcolor{keyword}{call }plm\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{144 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{145 }
\DoxyCodeLine{146     \textcolor{keywordflow}{case} ( interpolation\_ppm\_h4 )}
\DoxyCodeLine{147       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{148         degree = degree\_2}
\DoxyCodeLine{149         \textcolor{keyword}{call }edge\_values\_explicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{150         \textcolor{keyword}{call }ppm\_reconstruction( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{151         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{152           \textcolor{keyword}{call }ppm\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, \&}
\DoxyCodeLine{153                                            ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{154 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{155       \textcolor{keywordflow}{else}}
\DoxyCodeLine{156         degree = degree\_1}
\DoxyCodeLine{157         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{158         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{159         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{160           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{161 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{162 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{163 }
\DoxyCodeLine{164     \textcolor{keywordflow}{case} ( interpolation\_ppm\_ih4 )}
\DoxyCodeLine{165       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{166         degree = degree\_2}
\DoxyCodeLine{167         \textcolor{keyword}{call }edge\_values\_implicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{168         \textcolor{keyword}{call }ppm\_reconstruction( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{169         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{170           \textcolor{keyword}{call }ppm\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, \&}
\DoxyCodeLine{171                                            ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{172 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{173       \textcolor{keywordflow}{else}}
\DoxyCodeLine{174         degree = degree\_1}
\DoxyCodeLine{175         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{176         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{177         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{178           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{179 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{180 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{181 }
\DoxyCodeLine{182     \textcolor{keywordflow}{case} ( interpolation\_p3m\_ih4ih3 )}
\DoxyCodeLine{183       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{184         degree = degree\_3}
\DoxyCodeLine{185         \textcolor{keyword}{call }edge\_values\_implicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{186         \textcolor{keyword}{call }edge\_slopes\_implicit\_h3( n0, h0, densities, ppoly0\_s, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{187         \textcolor{keyword}{call }p3m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{188                                 ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{189         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{190           \textcolor{keyword}{call }p3m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{191                                            ppoly0\_coefs, h\_neglect, h\_neglect\_edge )}
\DoxyCodeLine{192 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{193       \textcolor{keywordflow}{else}}
\DoxyCodeLine{194         degree = degree\_1}
\DoxyCodeLine{195         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{196         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{197         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{198           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{199 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{200 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{201 }
\DoxyCodeLine{202     \textcolor{keywordflow}{case} ( interpolation\_p3m\_ih6ih5 )}
\DoxyCodeLine{203       \textcolor{keywordflow}{if} ( n0 >= 6 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{204         degree = degree\_3}
\DoxyCodeLine{205         \textcolor{keyword}{call }edge\_values\_implicit\_h6( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{206         \textcolor{keyword}{call }edge\_slopes\_implicit\_h5( n0, h0, densities, ppoly0\_s, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{207         \textcolor{keyword}{call }p3m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{208                                 ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{209         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{210           \textcolor{keyword}{call }p3m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{211                    ppoly0\_coefs, h\_neglect, h\_neglect\_edge )}
\DoxyCodeLine{212 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{213       \textcolor{keywordflow}{else}}
\DoxyCodeLine{214         degree = degree\_1}
\DoxyCodeLine{215         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{216         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{217         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{218           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{219 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{220 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{221 }
\DoxyCodeLine{222     \textcolor{keywordflow}{case} ( interpolation\_pqm\_ih4ih3 )}
\DoxyCodeLine{223       \textcolor{keywordflow}{if} ( n0 >= 4 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{224         degree = degree\_4}
\DoxyCodeLine{225         \textcolor{keyword}{call }edge\_values\_implicit\_h4( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{226         \textcolor{keyword}{call }edge\_slopes\_implicit\_h3( n0, h0, densities, ppoly0\_s, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{227         \textcolor{keyword}{call }pqm\_reconstruction( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{228                                  ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{229         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{230           \textcolor{keyword}{call }pqm\_boundary\_extrapolation\_v1( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{231                                  ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{232 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{233       \textcolor{keywordflow}{else}}
\DoxyCodeLine{234         degree = degree\_1}
\DoxyCodeLine{235         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{236         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{237         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{238           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{239 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{240 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{241 }
\DoxyCodeLine{242     \textcolor{keywordflow}{case} ( interpolation\_pqm\_ih6ih5 )}
\DoxyCodeLine{243       \textcolor{keywordflow}{if} ( n0 >= 6 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{244         degree = degree\_4}
\DoxyCodeLine{245         \textcolor{keyword}{call }edge\_values\_implicit\_h6( n0, h0, densities, ppoly0\_e, h\_neglect\_edge, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{246         \textcolor{keyword}{call }edge\_slopes\_implicit\_h5( n0, h0, densities, ppoly0\_s, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{247         \textcolor{keyword}{call }pqm\_reconstruction( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{248                                  ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{249         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{250           \textcolor{keyword}{call }pqm\_boundary\_extrapolation\_v1( n0, h0, densities, ppoly0\_e, ppoly0\_s, \&}
\DoxyCodeLine{251                                  ppoly0\_coefs, h\_neglect )}
\DoxyCodeLine{252 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{253       \textcolor{keywordflow}{else}}
\DoxyCodeLine{254         degree = degree\_1}
\DoxyCodeLine{255         \textcolor{keyword}{call }edge\_values\_explicit\_h2( n0, h0, densities, ppoly0\_e )}
\DoxyCodeLine{256         \textcolor{keyword}{call }p1m\_interpolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs, h\_neglect, answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{257         \textcolor{keywordflow}{if} (extrapolate) \textcolor{keywordflow}{then}}
\DoxyCodeLine{258           \textcolor{keyword}{call }p1m\_boundary\_extrapolation( n0, h0, densities, ppoly0\_e, ppoly0\_coefs )}
\DoxyCodeLine{259 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{260 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{261 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{262 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_a9ed8b5720d74090e95ca0074240a0d8a}\label{namespaceregrid__interp_a9ed8b5720d74090e95ca0074240a0d8a}} 
\index{regrid\_interp@{regrid\_interp}!set\_interp\_extrap@{set\_interp\_extrap}}
\index{set\_interp\_extrap@{set\_interp\_extrap}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{set\_interp\_extrap()}{set\_interp\_extrap()}}
{\footnotesize\ttfamily subroutine, public regrid\+\_\+interp\+::set\+\_\+interp\+\_\+extrap (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structregrid__interp_1_1interp__cs__type}{interp\+\_\+cs\+\_\+type}}), intent(inout)}]{CS,  }\item[{logical, intent(in)}]{extrap }\end{DoxyParamCaption})}



Store the boundary\+\_\+extrapolation value in the interp\+\_\+\+CS. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em cs} & A control structure for \mbox{\hyperlink{namespaceregrid__interp}{regrid\+\_\+interp}} \\
\hline
\mbox{\texttt{ in}}  & {\em extrap} & Indicate whether high-\/order boundary extrapolation should be used in boundary cells \\
\hline
\end{DoxyParams}


Definition at line 519 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{520   \textcolor{keywordtype}{type}(interp\_CS\_type), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{  !< A control structure for regrid\_interp}}
\DoxyCodeLine{521   \textcolor{keywordtype}{logical},              \textcolor{keywordtype}{intent(in)}    :: extrap\textcolor{comment}{ !< Indicate whether high-\/order boundary}}
\DoxyCodeLine{522 \textcolor{comment}{                                             !! extrapolation should be used in boundary cells}}
\DoxyCodeLine{523 }
\DoxyCodeLine{524   cs\%boundary\_extrapolation = extrap}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceregrid__interp_ae77f3027ed51829db5d4ed6dbc744550}\label{namespaceregrid__interp_ae77f3027ed51829db5d4ed6dbc744550}} 
\index{regrid\_interp@{regrid\_interp}!set\_interp\_scheme@{set\_interp\_scheme}}
\index{set\_interp\_scheme@{set\_interp\_scheme}!regrid\_interp@{regrid\_interp}}
\doxysubsubsection{\texorpdfstring{set\_interp\_scheme()}{set\_interp\_scheme()}}
{\footnotesize\ttfamily subroutine, public regrid\+\_\+interp\+::set\+\_\+interp\+\_\+scheme (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structregrid__interp_1_1interp__cs__type}{interp\+\_\+cs\+\_\+type}}), intent(inout)}]{CS,  }\item[{character(len=$\ast$), intent(in)}]{interp\+\_\+scheme }\end{DoxyParamCaption})}



Store the interpolation\+\_\+scheme value in the interp\+\_\+\+CS based on the input string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em cs} & A control structure for \mbox{\hyperlink{namespaceregrid__interp}{regrid\+\_\+interp}} \\
\hline
\mbox{\texttt{ in}}  & {\em interp\+\_\+scheme} & Name of the interpolation scheme Valid values include \char`\"{}\+P1\+M\+\_\+\+H2\char`\"{}, \char`\"{}\+P1\+M\+\_\+\+H4\char`\"{}, \char`\"{}\+P1\+M\+\_\+\+I\+H2\char`\"{}, \char`\"{}\+P\+L\+M\char`\"{}, \char`\"{}\+P\+P\+M\+\_\+\+H4\char`\"{}, \char`\"{}\+P\+P\+M\+\_\+\+I\+H4\char`\"{}, \char`\"{}\+P3\+M\+\_\+\+I\+H4\+I\+H3\char`\"{}, \char`\"{}\+P3\+M\+\_\+\+I\+H6\+I\+H5\char`\"{}, \char`\"{}\+P\+Q\+M\+\_\+\+I\+H4\+I\+H3\char`\"{}, and \char`\"{}\+P\+Q\+M\+\_\+\+I\+H6\+I\+H5\char`\"{} \\
\hline
\end{DoxyParams}


Definition at line 509 of file regrid\+\_\+interp.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{510   \textcolor{keywordtype}{type}(interp\_CS\_type), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{  !< A control structure for regrid\_interp}}
\DoxyCodeLine{511   \textcolor{keywordtype}{character(len=*)},     \textcolor{keywordtype}{intent(in)} :: interp\_scheme\textcolor{comment}{ !< Name of the interpolation scheme}}
\DoxyCodeLine{512 \textcolor{comment}{        !! Valid values include "{}P1M\_H2"{}, "{}P1M\_H4"{}, "{}P1M\_IH2"{}, "{}PLM"{}, "{}PPM\_H4"{},}}
\DoxyCodeLine{513 \textcolor{comment}{        !!   "{}PPM\_IH4"{}, "{}P3M\_IH4IH3"{}, "{}P3M\_IH6IH5"{}, "{}PQM\_IH4IH3"{}, and "{}PQM\_IH6IH5"{}}}
\DoxyCodeLine{514 }
\DoxyCodeLine{515   cs\%interpolation\_scheme = interpolation\_scheme(interp\_scheme)}

\end{DoxyCode}
