\hypertarget{namespacemom__ale}{}\doxysection{mom\+\_\+ale Module Reference}
\label{namespacemom__ale}\index{mom\_ale@{mom\_ale}}


\doxysubsection{Detailed Description}
This module contains the main regridding routines. 

Regridding comprises two steps\+:
\begin{DoxyEnumerate}
\item Interpolation and creation of a new grid based on target interface densities (or any other criterion).
\item Remapping of quantities between old grid and new grid.
\end{DoxyEnumerate}

Original module written by Laurent White, 2008.\+06.\+09 \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em A\+LE control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{ale\+\_\+init}} (param\+\_\+file, GV, US, max\+\_\+depth, CS)
\begin{DoxyCompactList}\small\item\em This routine is typically called (from initialize\+\_\+\+M\+OM in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) before the main time integration loop to initialize the regridding stuff. We read the M\+O\+M\+\_\+input file to register the values of different regridding/remapping parameters. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}{ale\+\_\+register\+\_\+diags}} (Time, G, GV, US, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialize diagnostics for the A\+LE module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}{adjustgridforintegrity}} (CS, G, GV, h)
\begin{DoxyCompactList}\small\item\em Crudely adjust (initial) grid for integrity. This routine is typically called (from initialize\+\_\+\+M\+OM in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) before the main time integration loop to initialize the regridding stuff. We read the M\+O\+M\+\_\+input file to register the values of different regridding/remapping parameters. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}{ale\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em End of regridding (memory deallocation). This routine is typically called (from M\+O\+M\+\_\+end in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) after the main time integration loop to deallocate the regridding stuff. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\+\_\+main}} (G, GV, US, h, u, v, tv, Reg, CS, O\+BC, dt, frac\+\_\+shelf\+\_\+h)
\begin{DoxyCompactList}\small\item\em Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\+\_\+main\+\_\+offline}} (G, GV, h, tv, Reg, CS, O\+BC, dt)
\begin{DoxyCompactList}\small\item\em Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\+\_\+offline\+\_\+inputs}} (CS, G, GV, h, tv, Reg, uhtr, vhtr, Kd, debug, O\+BC)
\begin{DoxyCompactList}\small\item\em Regrid/remap stored fields used for offline tracer integrations. These input fields are assumed to have the same layer thicknesses at the end of the last offline interval (which should be a Zstar grid). This routine builds a grid on the runtime specified vertical coordinate. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\+\_\+offline\+\_\+tracer\+\_\+final}} (G, GV, h, tv, h\+\_\+target, Reg, CS, O\+BC)
\begin{DoxyCompactList}\small\item\em Remaps all tracers from h onto h\+\_\+target. This is intended to be called when tracers are done offline. In the case where transports don\textquotesingle{}t quite conserve, we still want to make sure that layer thicknesses offline do not drift too far away from the online model. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\+\_\+grid}} (G, GV, h, threshold)
\begin{DoxyCompactList}\small\item\em Check grid for negative thicknesses. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}{ale\+\_\+build\+\_\+grid}} (G, GV, regrid\+CS, remap\+CS, h, tv, debug, frac\+\_\+shelf\+\_\+h)
\begin{DoxyCompactList}\small\item\em Generates new grid. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\+\_\+regrid\+\_\+accelerated}} (CS, G, GV, h, tv, n, u, v, O\+BC, Reg, dt, dz\+Regrid, initial)
\begin{DoxyCompactList}\small\item\em For a state-\/based coordinate, accelerate the process of regridding by repeatedly applying the grid calculation algorithm. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars}} (C\+S\+\_\+remapping, C\+S\+\_\+\+A\+LE, G, GV, h\+\_\+old, h\+\_\+new, Reg, O\+BC, dx\+Interface, u, v, debug, dt)
\begin{DoxyCompactList}\small\item\em This routine takes care of remapping all variable between the old and the new grids. When velocity components need to be remapped, thicknesses at velocity points are taken to be arithmetic averages of tracer thicknesses. This routine is called during initialization of the model at time=0, to remap initiali conditions to the model grid. It is also called during a time step to update the state. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\+\_\+remap\+\_\+scalar}} (CS, G, GV, nk\+\_\+src, h\+\_\+src, s\+\_\+src, h\+\_\+dst, s\+\_\+dst, all\+\_\+cells, old\+\_\+remap, answers\+\_\+2018)
\begin{DoxyCompactList}\small\item\em Remaps a single scalar between grids described by thicknesses h\+\_\+src and h\+\_\+dst. h\+\_\+dst must be dimensioned as a model array with GVke layers while h\+\_\+src can have an arbitrary number of layers specified by nk\+\_\+src. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{ts\+\_\+plm\+\_\+edge\+\_\+values}} (CS, S\+\_\+t, S\+\_\+b, T\+\_\+t, T\+\_\+b, G, GV, tv, h, bdry\+\_\+extrap)
\begin{DoxyCompactList}\small\item\em Calculate edge values (top and bottom of layer) for T and S consistent with a P\+LM reconstruction in the vertical direction. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\+\_\+plm\+\_\+edge\+\_\+values}} (CS, G, GV, h, Q, bdry\+\_\+extrap, Q\+\_\+t, Q\+\_\+b)
\begin{DoxyCompactList}\small\item\em Calculate edge values (top and bottom of layer) 3d scalar array. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}{ts\+\_\+ppm\+\_\+edge\+\_\+values}} (CS, S\+\_\+t, S\+\_\+b, T\+\_\+t, T\+\_\+b, G, GV, tv, h, bdry\+\_\+extrap)
\begin{DoxyCompactList}\small\item\em Calculate edge values (top and bottom of layer) for T and S consistent with a P\+PM reconstruction in the vertical direction. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\+\_\+initregridding}} (GV, US, max\+\_\+depth, param\+\_\+file, mdl, regrid\+CS)
\begin{DoxyCompactList}\small\item\em Initializes regridding for the main A\+LE algorithm. \end{DoxyCompactList}\item 
real function, dimension(cs\%nk+1), public \mbox{\hyperlink{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}{ale\+\_\+getcoordinate}} (CS)
\begin{DoxyCompactList}\small\item\em Query the target coordinate interfaces positions. \end{DoxyCompactList}\item 
character(len=20) function, public \mbox{\hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{ale\+\_\+getcoordinateunits}} (CS)
\begin{DoxyCompactList}\small\item\em Query the target coordinate units. \end{DoxyCompactList}\item 
logical function, public \mbox{\hyperlink{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}{ale\+\_\+remap\+\_\+init\+\_\+conds}} (CS)
\begin{DoxyCompactList}\small\item\em Returns true if initial conditions should be regridded and remapped. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\+\_\+update\+\_\+regrid\+\_\+weights}} (dt, CS)
\begin{DoxyCompactList}\small\item\em Updates the weights for time filtering the new grid generated in regridding. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}{ale\+\_\+updateverticalgridtype}} (CS, GV)
\begin{DoxyCompactList}\small\item\em Update the vertical grid type with A\+LE information. This subroutine sets information in the vertical\+Grid\+\_\+type to be consistent with the use of A\+LE mode. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}{ale\+\_\+writecoordinatefile}} (CS, GV, directory)
\begin{DoxyCompactList}\small\item\em Write the vertical coordinate information into a file. This subroutine writes out a file containing any available data related to the vertical grid used by the M\+OM ocean model when in A\+LE mode. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}{ale\+\_\+initthicknesstocoord}} (CS, G, GV, h)
\begin{DoxyCompactList}\small\item\em Set h to coordinate values for fixed coordinate systems. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}\label{namespacemom__ale_a870a226e28a2cdafad0537d3365d85af}} 
\index{mom\_ale@{mom\_ale}!adjustgridforintegrity@{adjustgridforintegrity}}
\index{adjustgridforintegrity@{adjustgridforintegrity}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{adjustgridforintegrity()}{adjustgridforintegrity()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::adjustgridforintegrity (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{h }\end{DoxyParamCaption})}



Crudely adjust (initial) grid for integrity. This routine is typically called (from initialize\+\_\+\+M\+OM in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) before the main time integration loop to initialize the regridding stuff. We read the M\+O\+M\+\_\+input file to register the values of different regridding/remapping parameters. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Regridding parameters and options \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid informations \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Current 3D grid thickness that are to be adjusted \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 293 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{293   \textcolor{keywordtype}{type}(ALE\_CS),                              \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and options}}
\DoxyCodeLine{294   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}}
\DoxyCodeLine{295   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}}
\DoxyCodeLine{296 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid thickness that}}
\DoxyCodeLine{297 \textcolor{comment}{                                                                  !! are to be adjusted [H \string~> m or kg-\/2]}}
\DoxyCodeLine{298   \textcolor{keyword}{call }inflate\_vanished\_layers\_old( cs\%regridCS, g, gv, h(:,:,:) )}
\DoxyCodeLine{299 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}\label{namespacemom__ale_ac81ebcd85a340ee69481cffd98848eb1}} 
\index{mom\_ale@{mom\_ale}!ale\_build\_grid@{ale\_build\_grid}}
\index{ale\_build\_grid@{ale\_build\_grid}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_build\_grid()}{ale\_build\_grid()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+build\+\_\+grid (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(regridding\+\_\+cs), intent(in)}]{regrid\+CS,  }\item[{type(remapping\+\_\+cs), intent(in)}]{remap\+CS,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed,  gv \%ke), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{logical, intent(in), optional}]{debug,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{frac\+\_\+shelf\+\_\+h }\end{DoxyParamCaption})}



Generates new grid. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em regridcs} & Regridding parameters and options \\
\hline
\mbox{\texttt{ in}}  & {\em remapcs} & Remapping parameters and options \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamical variable structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em debug} & If true, show the call tree \\
\hline
 & {\em frac\+\_\+shelf\+\_\+h} & Fractional ice shelf coverage \\
\hline
\end{DoxyParams}


Definition at line 616 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{616   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{        !< Ocean grid structure}}
\DoxyCodeLine{617   \textcolor{keywordtype}{type}(verticalGrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{       !< Ocean vertical grid structure}}
\DoxyCodeLine{618   \textcolor{keywordtype}{type}(regridding\_CS),                     \textcolor{keywordtype}{intent(in)}    :: regridCS\textcolor{comment}{ !< Regridding parameters and options}}
\DoxyCodeLine{619   \textcolor{keywordtype}{type}(remapping\_CS),                      \textcolor{keywordtype}{intent(in)}    :: remapCS\textcolor{comment}{  !< Remapping parameters and options}}
\DoxyCodeLine{620   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{       !< Thermodynamical variable structure}}
\DoxyCodeLine{621 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G), SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Current 3D grid obtained after the}}
\DoxyCodeLine{622 \textcolor{comment}{                                                                     !! last time step [H \string~> m or kg-\/2]}}
\DoxyCodeLine{623   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{    !< If true, show the call tree}}
\DoxyCodeLine{624 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf coverage}}
\DoxyCodeLine{625   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{626   \textcolor{keywordtype}{integer} :: nk, i, j, k}
\DoxyCodeLine{627 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}}
\DoxyCodeLine{628 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: h\_new \textcolor{comment}{! The new grid thicknesses}}
\DoxyCodeLine{629   \textcolor{keywordtype}{logical} :: show\_call\_tree, use\_ice\_shelf}
\DoxyCodeLine{630 }
\DoxyCodeLine{631   show\_call\_tree = .false.}
\DoxyCodeLine{632   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug}
\DoxyCodeLine{633   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_build\_grid(), MOM\_ALE.F90"})}
\DoxyCodeLine{634   use\_ice\_shelf = .false.}
\DoxyCodeLine{635   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{636     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) use\_ice\_shelf = .true.}
\DoxyCodeLine{637 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{638 }
\DoxyCodeLine{639   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}}
\DoxyCodeLine{640   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}}
\DoxyCodeLine{641   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{642      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h )}
\DoxyCodeLine{643   \textcolor{keywordflow}{else}}
\DoxyCodeLine{644      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid )}
\DoxyCodeLine{645 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{646 }
\DoxyCodeLine{647   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}}
\DoxyCodeLine{648   \textcolor{comment}{! one of the 'build\_...' routines above.}}
\DoxyCodeLine{649 \textcolor{comment}{!\$OMP parallel do default(none) shared(G,h,h\_new)}}
\DoxyCodeLine{650   \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{651     \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) h(i,j,:) = h\_new(i,j,:)}
\DoxyCodeLine{652 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{653 }
\DoxyCodeLine{654   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_build\_grid()"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}\label{namespacemom__ale_a807a4412504e91df4f21e33afe9779f3}} 
\index{mom\_ale@{mom\_ale}!ale\_end@{ale\_end}}
\index{ale\_end@{ale\_end}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_end()}{ale\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



End of regridding (memory deallocation). This routine is typically called (from M\+O\+M\+\_\+end in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) after the main time integration loop to deallocate the regridding stuff. 


\begin{DoxyParams}{Parameters}
{\em cs} & module control structure \\
\hline
\end{DoxyParams}


Definition at line 307 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{307   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{  !< module control structure}}
\DoxyCodeLine{308 }
\DoxyCodeLine{309   \textcolor{comment}{! Deallocate memory used for the regridding}}
\DoxyCodeLine{310   \textcolor{keyword}{call }end\_remapping( cs\%remapCS )}
\DoxyCodeLine{311   \textcolor{keyword}{call }end\_regridding( cs\%regridCS )}
\DoxyCodeLine{312 }
\DoxyCodeLine{313   \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{314 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}\label{namespacemom__ale_a761eeb0993d81b0cb168aaebbbb2bc07}} 
\index{mom\_ale@{mom\_ale}!ale\_getcoordinate@{ale\_getcoordinate}}
\index{ale\_getcoordinate@{ale\_getcoordinate}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_getcoordinate()}{ale\_getcoordinate()}}
{\footnotesize\ttfamily real function, dimension(cs\%nk+1), public mom\+\_\+ale\+::ale\+\_\+getcoordinate (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Query the target coordinate interfaces positions. 


\begin{DoxyParams}{Parameters}
{\em cs} & module control structure \\
\hline
\end{DoxyParams}


Definition at line 1207 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1207   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{                  !< module control structure}}
\DoxyCodeLine{1208 }
\DoxyCodeLine{1209 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(CS\%nk+1)} :: ALE\_getCoordinate}
\DoxyCodeLine{1210   ale\_getcoordinate(:) = getcoordinateinterfaces( cs\%regridCS, undo\_scaling=.true. )}
\DoxyCodeLine{1211 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}\label{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}} 
\index{mom\_ale@{mom\_ale}!ale\_getcoordinateunits@{ale\_getcoordinateunits}}
\index{ale\_getcoordinateunits@{ale\_getcoordinateunits}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_getcoordinateunits()}{ale\_getcoordinateunits()}}
{\footnotesize\ttfamily character(len=20) function, public mom\+\_\+ale\+::ale\+\_\+getcoordinateunits (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Query the target coordinate units. 


\begin{DoxyParams}{Parameters}
{\em cs} & module control structure \\
\hline
\end{DoxyParams}


Definition at line 1217 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1217   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< module control structure}}
\DoxyCodeLine{1218 }
\DoxyCodeLine{1219   \textcolor{keywordtype}{character(len=20)}     :: ALE\_getCoordinateUnits}
\DoxyCodeLine{1220 }
\DoxyCodeLine{1221   ale\_getcoordinateunits = getcoordinateunits( cs\%regridCS )}
\DoxyCodeLine{1222 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}\label{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}} 
\index{mom\_ale@{mom\_ale}!ale\_init@{ale\_init}}
\index{ale\_init@{ale\_init}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_init()}{ale\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This routine is typically called (from initialize\+\_\+\+M\+OM in file \mbox{\hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}}) before the main time integration loop to initialize the regridding stuff. We read the M\+O\+M\+\_\+input file to register the values of different regridding/remapping parameters. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+depth} & The maximum depth of the ocean \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
 & {\em cs} & Module control structure \\
\hline
\end{DoxyParams}


Definition at line 140 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{140   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file}}
\DoxyCodeLine{141   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{         !< Ocean vertical grid structure}}
\DoxyCodeLine{142   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{         !< A dimensional unit scaling type}}
\DoxyCodeLine{143 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)} :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z \string~> m].}}
\DoxyCodeLine{144   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{         !< Module control structure}}
\DoxyCodeLine{145 }
\DoxyCodeLine{146   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{147 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: dz}
\DoxyCodeLine{148   \textcolor{keywordtype}{character(len=40)}               :: mdl = \textcolor{stringliteral}{"MOM\_ALE"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{149   \textcolor{keywordtype}{character(len=80)}               :: string \textcolor{comment}{! Temporary strings}}
\DoxyCodeLine{150 \textcolor{keywordtype}{  real}                            :: filter\_shallow\_depth, filter\_deep\_depth}
\DoxyCodeLine{151   \textcolor{keywordtype}{logical}       :: default\_2018\_answers}
\DoxyCodeLine{152   \textcolor{keywordtype}{logical}                         :: check\_reconstruction}
\DoxyCodeLine{153   \textcolor{keywordtype}{logical}                         :: check\_remapping}
\DoxyCodeLine{154   \textcolor{keywordtype}{logical}                         :: force\_bounds\_in\_subcell}
\DoxyCodeLine{155   \textcolor{keywordtype}{logical}                         :: local\_logical}
\DoxyCodeLine{156   \textcolor{keywordtype}{logical}                         :: remap\_boundary\_extrap}
\DoxyCodeLine{157 }
\DoxyCodeLine{158   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{159     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ALE\_init called with an associated "}// \&}
\DoxyCodeLine{160                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{161     \textcolor{keywordflow}{return}}
\DoxyCodeLine{162 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{163   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{164 }
\DoxyCodeLine{165   cs\%show\_call\_tree = calltree\_showquery()}
\DoxyCodeLine{166   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_init(), MOM\_ALE.F90"})}
\DoxyCodeLine{167 }
\DoxyCodeLine{168   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_UV\_USING\_OLD\_ALG"}, cs\%remap\_uv\_using\_old\_alg, \&}
\DoxyCodeLine{169                  \textcolor{stringliteral}{"If true, uses the old remapping-\/via-\/a-\/delta-\/z method for "}//\&}
\DoxyCodeLine{170                  \textcolor{stringliteral}{"remapping u and v. If false, uses the new method that remaps "}//\&}
\DoxyCodeLine{171                  \textcolor{stringliteral}{"between grids described by an old and new thickness."}, \&}
\DoxyCodeLine{172                  default=.false.)}
\DoxyCodeLine{173 }
\DoxyCodeLine{174   \textcolor{comment}{! Initialize and configure regridding}}
\DoxyCodeLine{175   \textcolor{keyword}{call }ale\_initregridding(gv, us, max\_depth, param\_file, mdl, cs\%regridCS)}
\DoxyCodeLine{176 }
\DoxyCodeLine{177   \textcolor{comment}{! Initialize and configure remapping}}
\DoxyCodeLine{178   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, string, \&}
\DoxyCodeLine{179                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//\&}
\DoxyCodeLine{180                  \textcolor{stringliteral}{"for vertical remapping for all variables. "}//\&}
\DoxyCodeLine{181                  \textcolor{stringliteral}{"It can be one of the following schemes: "}//\&}
\DoxyCodeLine{182                  trim(remappingschemesdoc), default=remappingdefaultscheme)}
\DoxyCodeLine{183   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_RECONSTRUCTIONS"}, check\_reconstruction, \&}
\DoxyCodeLine{184                  \textcolor{stringliteral}{"If true, cell-\/by-\/cell reconstructions are checked for "}//\&}
\DoxyCodeLine{185                  \textcolor{stringliteral}{"consistency and if non-\/monotonicity or an inconsistency is "}//\&}
\DoxyCodeLine{186                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)}
\DoxyCodeLine{187   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_REMAPPING"}, check\_remapping, \&}
\DoxyCodeLine{188                  \textcolor{stringliteral}{"If true, the results of remapping are checked for "}//\&}
\DoxyCodeLine{189                  \textcolor{stringliteral}{"conservation and new extrema and if an inconsistency is "}//\&}
\DoxyCodeLine{190                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)}
\DoxyCodeLine{191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUND\_INTERMEDIATE\_VALUES"}, force\_bounds\_in\_subcell, \&}
\DoxyCodeLine{192                  \textcolor{stringliteral}{"If true, the values on the intermediate grid used for remapping "}//\&}
\DoxyCodeLine{193                  \textcolor{stringliteral}{"are forced to be bounded, which might not be the case due to "}//\&}
\DoxyCodeLine{194                  \textcolor{stringliteral}{"round off."}, default=.false.)}
\DoxyCodeLine{195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUNDARY\_EXTRAP"}, remap\_boundary\_extrap, \&}
\DoxyCodeLine{196                  \textcolor{stringliteral}{"If true, values at the interfaces of boundary cells are "}//\&}
\DoxyCodeLine{197                  \textcolor{stringliteral}{"extrapolated instead of piecewise constant"}, default=.false.)}
\DoxyCodeLine{198   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{199                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{200                  default=.false.)}
\DoxyCodeLine{201   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs\%answers\_2018, \&}
\DoxyCodeLine{202                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//\&}
\DoxyCodeLine{203                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//\&}
\DoxyCodeLine{204                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)}
\DoxyCodeLine{205   \textcolor{keyword}{call }initialize\_remapping( cs\%remapCS, string, \&}
\DoxyCodeLine{206                              boundary\_extrapolation=remap\_boundary\_extrap, \&}
\DoxyCodeLine{207                              check\_reconstruction=check\_reconstruction, \&}
\DoxyCodeLine{208                              check\_remapping=check\_remapping, \&}
\DoxyCodeLine{209                              force\_bounds\_in\_subcell=force\_bounds\_in\_subcell, \&}
\DoxyCodeLine{210                              answers\_2018=cs\%answers\_2018)}
\DoxyCodeLine{211 }
\DoxyCodeLine{212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_AFTER\_INITIALIZATION"}, cs\%remap\_after\_initialization, \&}
\DoxyCodeLine{213                  \textcolor{stringliteral}{"If true, applies regridding and remapping immediately after "}//\&}
\DoxyCodeLine{214                  \textcolor{stringliteral}{"initialization so that the state is ALE consistent. This is a "}//\&}
\DoxyCodeLine{215                  \textcolor{stringliteral}{"legacy step and should not be needed if the initialization is "}//\&}
\DoxyCodeLine{216                  \textcolor{stringliteral}{"consistent with the coordinate mode."}, default=.true.)}
\DoxyCodeLine{217 }
\DoxyCodeLine{218   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_TIME\_SCALE"}, cs\%regrid\_time\_scale, \&}
\DoxyCodeLine{219                  \textcolor{stringliteral}{"The time-\/scale used in blending between the current (old) grid "}//\&}
\DoxyCodeLine{220                  \textcolor{stringliteral}{"and the target (new) grid. A short time-\/scale favors the target "}//\&}
\DoxyCodeLine{221                  \textcolor{stringliteral}{"grid (0. or anything less than DT\_THERM) has no memory of the old "}//\&}
\DoxyCodeLine{222                  \textcolor{stringliteral}{"grid. A very long time-\/scale makes the model more Lagrangian."}, \&}
\DoxyCodeLine{223                  units=\textcolor{stringliteral}{"s"}, default=0., scale=us\%s\_to\_T)}
\DoxyCodeLine{224   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH"}, filter\_shallow\_depth, \&}
\DoxyCodeLine{225                  \textcolor{stringliteral}{"The depth above which no time-\/filtering is applied. Above this depth "}//\&}
\DoxyCodeLine{226                  \textcolor{stringliteral}{"final grid exactly matches the target (new) grid."}, \&}
\DoxyCodeLine{227                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv\%m\_to\_H)}
\DoxyCodeLine{228   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_DEEP\_DEPTH"}, filter\_deep\_depth, \&}
\DoxyCodeLine{229                  \textcolor{stringliteral}{"The depth below which full time-\/filtering is applied with time-\/scale "}//\&}
\DoxyCodeLine{230                  \textcolor{stringliteral}{"REGRID\_TIME\_SCALE. Between depths REGRID\_FILTER\_SHALLOW\_DEPTH and "}//\&}
\DoxyCodeLine{231                  \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH the filter weights adopt a cubic profile."}, \&}
\DoxyCodeLine{232                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv\%m\_to\_H)}
\DoxyCodeLine{233   \textcolor{keyword}{call }set\_regrid\_params(cs\%regridCS, depth\_of\_time\_filter\_shallow=filter\_shallow\_depth, \&}
\DoxyCodeLine{234                          depth\_of\_time\_filter\_deep=filter\_deep\_depth)}
\DoxyCodeLine{235   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_USE\_OLD\_DIRECTION"}, local\_logical, \&}
\DoxyCodeLine{236                  \textcolor{stringliteral}{"If true, the regridding ntegrates upwards from the bottom for "}//\&}
\DoxyCodeLine{237                  \textcolor{stringliteral}{"interface positions, much as the main model does. If false "}//\&}
\DoxyCodeLine{238                  \textcolor{stringliteral}{"regridding integrates downward, consistant with the remapping "}//\&}
\DoxyCodeLine{239                  \textcolor{stringliteral}{"code."}, default=.true., do\_not\_log=.true.)}
\DoxyCodeLine{240   \textcolor{keyword}{call }set\_regrid\_params(cs\%regridCS, integrate\_downward\_for\_e=.not.local\_logical)}
\DoxyCodeLine{241 }
\DoxyCodeLine{242   \textcolor{comment}{! Keep a record of values for subsequent queries}}
\DoxyCodeLine{243   cs\%nk = gv\%ke}
\DoxyCodeLine{244 }
\DoxyCodeLine{245   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_init()"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}\label{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}} 
\index{mom\_ale@{mom\_ale}!ale\_initregridding@{ale\_initregridding}}
\index{ale\_initregridding@{ale\_initregridding}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_initregridding()}{ale\_initregridding()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+initregridding (\begin{DoxyParamCaption}\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, intent(in)}]{max\+\_\+depth,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{character(len=$\ast$), intent(in)}]{mdl,  }\item[{type(regridding\+\_\+cs), intent(out)}]{regrid\+CS }\end{DoxyParamCaption})}



Initializes regridding for the main A\+LE algorithm. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em max\+\_\+depth} & The maximum depth of the ocean \mbox{[}Z $\sim$$>$ m\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & parameter file \\
\hline
\mbox{\texttt{ in}}  & {\em mdl} & Name of calling module \\
\hline
\mbox{\texttt{ out}}  & {\em regridcs} & Regridding parameters and work arrays \\
\hline
\end{DoxyParams}


Definition at line 1186 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1186   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{         !< Ocean vertical grid structure}}
\DoxyCodeLine{1187   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{         !< A dimensional unit scaling type}}
\DoxyCodeLine{1188 \textcolor{keywordtype}{  real},                    \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z \string~> m].}}
\DoxyCodeLine{1189   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< parameter file}}
\DoxyCodeLine{1190   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: mdl\textcolor{comment}{        !< Name of calling module}}
\DoxyCodeLine{1191   \textcolor{keywordtype}{type}(regridding\_CS),     \textcolor{keywordtype}{intent(out)} :: regridCS\textcolor{comment}{   !< Regridding parameters and work arrays}}
\DoxyCodeLine{1192   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1193   \textcolor{keywordtype}{character(len=30)} :: coord\_mode}
\DoxyCodeLine{1194 }
\DoxyCodeLine{1195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"}, coord\_mode, \&}
\DoxyCodeLine{1196                  \textcolor{stringliteral}{"Coordinate mode for vertical regridding. "}//\&}
\DoxyCodeLine{1197                  \textcolor{stringliteral}{"Choose among the following possibilities: "}//\&}
\DoxyCodeLine{1198                  trim(regriddingcoordinatemodedoc), \&}
\DoxyCodeLine{1199                  default=default\_coordinate\_mode, fail\_if\_missing=.true.)}
\DoxyCodeLine{1200 }
\DoxyCodeLine{1201   \textcolor{keyword}{call }initialize\_regridding(regridcs, gv, us, max\_depth, param\_file, mdl, coord\_mode, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''})}
\DoxyCodeLine{1202 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}\label{namespacemom__ale_a9fa1d63aa2994e74da912ae87e015c3e}} 
\index{mom\_ale@{mom\_ale}!ale\_initthicknesstocoord@{ale\_initthicknesstocoord}}
\index{ale\_initthicknesstocoord@{ale\_initthicknesstocoord}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_initthicknesstocoord()}{ale\_initthicknesstocoord()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+initthicknesstocoord (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), intent(inout)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(out)}]{h }\end{DoxyParamCaption})}



Set h to coordinate values for fixed coordinate systems. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em cs} & module control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & module grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ out}}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 1306 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1306   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{intent(inout)}                            :: CS\textcolor{comment}{  !< module control structure}}
\DoxyCodeLine{1307   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}                      :: G\textcolor{comment}{   !< module grid structure}}
\DoxyCodeLine{1308   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}                    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}}
\DoxyCodeLine{1309 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{   !< layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1310 }
\DoxyCodeLine{1311   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1312   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1313 }
\DoxyCodeLine{1314   \textcolor{keywordflow}{do} j = g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i = g\%isd,g\%ied}
\DoxyCodeLine{1315     h(i,j,:) = gv\%Z\_to\_H * getstaticthickness( cs\%regridCS, 0., g\%bathyT(i,j) )}
\DoxyCodeLine{1316 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1317 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}\label{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}} 
\index{mom\_ale@{mom\_ale}!ale\_main@{ale\_main}}
\index{ale\_main@{ale\_main}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_main()}{ale\_main()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+main (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{h,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{v,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{real, intent(in), optional}]{dt,  }\item[{real, dimension(\+:,\+:), optional, pointer}]{frac\+\_\+shelf\+\_\+h }\end{DoxyParamCaption})}



Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid informations \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & Zonal velocity field \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & Meridional velocity field \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamic variable structure \\
\hline
 & {\em reg} & Tracer registry structure \\
\hline
 & {\em cs} & Regridding parameters and options \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Time step between calls to A\+L\+E\+\_\+main \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
 & {\em frac\+\_\+shelf\+\_\+h} & Fractional ice shelf coverage \\
\hline
\end{DoxyParams}


Definition at line 322 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{322   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}}
\DoxyCodeLine{323   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}}
\DoxyCodeLine{324   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{  !< A dimensional unit scaling type}}
\DoxyCodeLine{325 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}}
\DoxyCodeLine{326 \textcolor{comment}{                                                                   !! last time step [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{327 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{   !< Zonal velocity field [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{328 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{   !< Meridional velocity field [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{329   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}}
\DoxyCodeLine{330   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}}
\DoxyCodeLine{331   \textcolor{keywordtype}{type}(ALE\_CS),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and options}}
\DoxyCodeLine{332   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{333 \textcolor{keywordtype}{  real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main [T \string~> s]}}
\DoxyCodeLine{334 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf coverage}}
\DoxyCodeLine{335   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{336 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}}
\DoxyCodeLine{337 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: eta\_preale}
\DoxyCodeLine{338 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: h\_new \textcolor{comment}{! New 3D grid obtained after last time step [H \string~> m or kg-\/2]}}
\DoxyCodeLine{339   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec}
\DoxyCodeLine{340   \textcolor{keywordtype}{logical} :: ice\_shelf}
\DoxyCodeLine{341 }
\DoxyCodeLine{342   nk = gv\%ke; isc = g\%isc; iec = g\%iec; jsc = g\%jsc; jec = g\%jec}
\DoxyCodeLine{343 }
\DoxyCodeLine{344   ice\_shelf = .false.}
\DoxyCodeLine{345   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) ice\_shelf = .true.}
\DoxyCodeLine{347 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{348 }
\DoxyCodeLine{349   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main(), MOM\_ALE.F90"})}
\DoxyCodeLine{350 }
\DoxyCodeLine{351   \textcolor{comment}{! These diagnostics of the state before ALE is applied are mostly used for debugging.}}
\DoxyCodeLine{352   \textcolor{keywordflow}{if} (cs\%id\_u\_preale > 0) \textcolor{keyword}{call }post\_data(cs\%id\_u\_preale, u,    cs\%diag)}
\DoxyCodeLine{353   \textcolor{keywordflow}{if} (cs\%id\_v\_preale > 0) \textcolor{keyword}{call }post\_data(cs\%id\_v\_preale, v,    cs\%diag)}
\DoxyCodeLine{354   \textcolor{keywordflow}{if} (cs\%id\_h\_preale > 0) \textcolor{keyword}{call }post\_data(cs\%id\_h\_preale, h,    cs\%diag)}
\DoxyCodeLine{355   \textcolor{keywordflow}{if} (cs\%id\_T\_preale > 0) \textcolor{keyword}{call }post\_data(cs\%id\_T\_preale, tv\%T, cs\%diag)}
\DoxyCodeLine{356   \textcolor{keywordflow}{if} (cs\%id\_S\_preale > 0) \textcolor{keyword}{call }post\_data(cs\%id\_S\_preale, tv\%S, cs\%diag)}
\DoxyCodeLine{357   \textcolor{keywordflow}{if} (cs\%id\_e\_preale > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{358     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, eta\_preale)}
\DoxyCodeLine{359     \textcolor{keyword}{call }post\_data(cs\%id\_e\_preale, eta\_preale, cs\%diag)}
\DoxyCodeLine{360 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{361 }
\DoxyCodeLine{362   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{363     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )}
\DoxyCodeLine{364 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{365   dzregrid(:,:,:) = 0.0}
\DoxyCodeLine{366 }
\DoxyCodeLine{367   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}}
\DoxyCodeLine{368   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}}
\DoxyCodeLine{369   \textcolor{keywordflow}{if} (ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{370      \textcolor{keyword}{call }regridding\_main( cs\%remapCS, cs\%regridCS, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h)}
\DoxyCodeLine{371   \textcolor{keywordflow}{else}}
\DoxyCodeLine{372      \textcolor{keyword}{call }regridding\_main( cs\%remapCS, cs\%regridCS, g, gv, h, tv, h\_new, dzregrid)}
\DoxyCodeLine{373 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{374 }
\DoxyCodeLine{375   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )}
\DoxyCodeLine{376 }
\DoxyCodeLine{377   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})}
\DoxyCodeLine{378 }
\DoxyCodeLine{379   \textcolor{comment}{! The presence of dt is used for expediency to distinguish whether ALE\_main is being called during init}}
\DoxyCodeLine{380   \textcolor{comment}{! or in the main loop. Tendency diagnostics in remap\_all\_state\_vars also rely on this logic.}}
\DoxyCodeLine{381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{382     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs\%diag)}
\DoxyCodeLine{383 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{384   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}}
\DoxyCodeLine{385   \textcolor{keyword}{call }remap\_all\_state\_vars( cs\%remapCS, cs, g, gv, h, h\_new, reg, obc, -\/dzregrid, \&}
\DoxyCodeLine{386                              u, v, cs\%show\_call\_tree, dt )}
\DoxyCodeLine{387 }
\DoxyCodeLine{388   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})}
\DoxyCodeLine{389 }
\DoxyCodeLine{390   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}}
\DoxyCodeLine{391   \textcolor{comment}{! one of the 'build\_...' routines above.}}
\DoxyCodeLine{392   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{393   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-\/1,jec+1 ; \textcolor{keywordflow}{do} i = isc-\/1,iec+1}
\DoxyCodeLine{394     h(i,j,k) = h\_new(i,j,k)}
\DoxyCodeLine{395 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{396 }
\DoxyCodeLine{397   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})}
\DoxyCodeLine{398 }
\DoxyCodeLine{399   \textcolor{keywordflow}{if} (cs\%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs\%id\_dzRegrid, dzregrid, cs\%diag)}
\DoxyCodeLine{400 }
\DoxyCodeLine{401 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}\label{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}} 
\index{mom\_ale@{mom\_ale}!ale\_main\_offline@{ale\_main\_offline}}
\index{ale\_main\_offline@{ale\_main\_offline}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_main\_offline()}{ale\_main\_offline()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+main\+\_\+offline (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{real, intent(in), optional}]{dt }\end{DoxyParamCaption})}



Takes care of (1) building a new grid and (2) remapping all variables between the old grid and the new grid. The creation of the new grid can be based on z coordinates, target interface densities, sigma coordinates or any arbitrary coordinate system. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid informations \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamic variable structure \\
\hline
 & {\em reg} & Tracer registry structure \\
\hline
 & {\em cs} & Regridding parameters and options \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Time step between calls to A\+L\+E\+\_\+main \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 409 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{409   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}}
\DoxyCodeLine{410   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}}
\DoxyCodeLine{411 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}}
\DoxyCodeLine{412 \textcolor{comment}{                                                                   !! last time step [H \string~> m or kg-\/2]}}
\DoxyCodeLine{413   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}}
\DoxyCodeLine{414   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}}
\DoxyCodeLine{415   \textcolor{keywordtype}{type}(ALE\_CS),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and options}}
\DoxyCodeLine{416   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{417 \textcolor{keywordtype}{  real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main [T \string~> s]}}
\DoxyCodeLine{418   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{419 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}}
\DoxyCodeLine{420 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))} :: h\_new \textcolor{comment}{! New 3D grid obtained after last time step [H \string~> m or kg-\/2]}}
\DoxyCodeLine{421   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec}
\DoxyCodeLine{422 }
\DoxyCodeLine{423   nk = gv\%ke; isc = g\%isc; iec = g\%iec; jsc = g\%jsc; jec = g\%jec}
\DoxyCodeLine{424 }
\DoxyCodeLine{425   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main\_offline(), MOM\_ALE.F90"})}
\DoxyCodeLine{426 }
\DoxyCodeLine{427   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{428     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )}
\DoxyCodeLine{429 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{430   dzregrid(:,:,:) = 0.0}
\DoxyCodeLine{431 }
\DoxyCodeLine{432   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}}
\DoxyCodeLine{433   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}}
\DoxyCodeLine{434   \textcolor{keyword}{call }regridding\_main( cs\%remapCS, cs\%regridCS, g, gv, h, tv, h\_new, dzregrid )}
\DoxyCodeLine{435 }
\DoxyCodeLine{436   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )}
\DoxyCodeLine{437 }
\DoxyCodeLine{438   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})}
\DoxyCodeLine{439 }
\DoxyCodeLine{440   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}}
\DoxyCodeLine{441 }
\DoxyCodeLine{442   \textcolor{keyword}{call }remap\_all\_state\_vars(cs\%remapCS, cs, g, gv, h, h\_new, reg, obc, \&}
\DoxyCodeLine{443                             debug=cs\%show\_call\_tree, dt=dt )}
\DoxyCodeLine{444 }
\DoxyCodeLine{445   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})}
\DoxyCodeLine{446 }
\DoxyCodeLine{447   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}}
\DoxyCodeLine{448   \textcolor{comment}{! one of the 'build\_...' routines above.}}
\DoxyCodeLine{449   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{450   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-\/1,jec+1 ; \textcolor{keywordflow}{do} i = isc-\/1,iec+1}
\DoxyCodeLine{451     h(i,j,k) = h\_new(i,j,k)}
\DoxyCodeLine{452 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{453 }
\DoxyCodeLine{454   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})}
\DoxyCodeLine{455   \textcolor{keywordflow}{if} (cs\%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs\%id\_dzRegrid, dzregrid, cs\%diag)}
\DoxyCodeLine{456 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}\label{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}} 
\index{mom\_ale@{mom\_ale}!ale\_offline\_inputs@{ale\_offline\_inputs}}
\index{ale\_offline\_inputs@{ale\_offline\_inputs}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_offline\_inputs()}{ale\_offline\_inputs()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+offline\+\_\+inputs (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{uhtr,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{vhtr,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)+1), intent(inout)}]{Kd,  }\item[{logical, intent(in)}]{debug,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC }\end{DoxyParamCaption})}



Regrid/remap stored fields used for offline tracer integrations. These input fields are assumed to have the same layer thicknesses at the end of the last offline interval (which should be a Zstar grid). This routine builds a grid on the runtime specified vertical coordinate. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Regridding parameters and options \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid informations \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Layer thicknesses \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamic variable structure \\
\hline
 & {\em reg} & Tracer registry structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em uhtr} & Zonal mass fluxes \\
\hline
\mbox{\texttt{ in,out}}  & {\em vhtr} & Meridional mass fluxes \\
\hline
\mbox{\texttt{ in,out}}  & {\em kd} & Input diffusivites \\
\hline
\mbox{\texttt{ in}}  & {\em debug} & If true, then turn checksums \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\end{DoxyParams}


Definition at line 463 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{463   \textcolor{keywordtype}{type}(ALE\_CS),                                 \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{    !< Regridding parameters and options}}
\DoxyCodeLine{464   \textcolor{keywordtype}{type}(ocean\_grid\_type),                        \textcolor{keywordtype}{intent(in   )} :: G\textcolor{comment}{     !< Ocean grid informations}}
\DoxyCodeLine{465   \textcolor{keywordtype}{type}(verticalGrid\_type),                      \textcolor{keywordtype}{intent(in   )} :: GV\textcolor{comment}{    !< Ocean vertical grid structure}}
\DoxyCodeLine{466 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},    \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Layer thicknesses}}
\DoxyCodeLine{467   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                        \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{    !< Thermodynamic variable structure}}
\DoxyCodeLine{468   \textcolor{keywordtype}{type}(tracer\_registry\_type),                   \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{   !< Tracer registry structure}}
\DoxyCodeLine{469 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{  !< Zonal mass fluxes}}
\DoxyCodeLine{470 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{  !< Meridional mass fluxes}}
\DoxyCodeLine{471 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)},  \textcolor{keywordtype}{intent(inout)} :: Kd\textcolor{comment}{    !< Input diffusivites}}
\DoxyCodeLine{472   \textcolor{keywordtype}{logical},                                      \textcolor{keywordtype}{intent(in   )} :: debug\textcolor{comment}{ !< If true, then turn checksums}}
\DoxyCodeLine{473   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                         \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{   !< Open boundary structure}}
\DoxyCodeLine{474   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{475   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec}
\DoxyCodeLine{476 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new    \textcolor{comment}{! Layer thicknesses after regridding}}
\DoxyCodeLine{477 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid \textcolor{comment}{! The change in grid interface positions}}
\DoxyCodeLine{478 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_src}
\DoxyCodeLine{479 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_dest, uh\_dest}
\DoxyCodeLine{480 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: temp\_vec}
\DoxyCodeLine{481 }
\DoxyCodeLine{482   nk = gv\%ke; isc = g\%isc; iec = g\%iec; jsc = g\%jsc; jec = g\%jec}
\DoxyCodeLine{483   dzregrid(:,:,:) = 0.0}
\DoxyCodeLine{484   h\_new(:,:,:) = 0.0}
\DoxyCodeLine{485 }
\DoxyCodeLine{486   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"Before ALE\_offline\_inputs"}, g, h, reg\%Tr, reg\%ntr)}
\DoxyCodeLine{487 }
\DoxyCodeLine{488   \textcolor{comment}{! Build new grid from the Zstar state onto the requested vertical coordinate. The new grid is stored}}
\DoxyCodeLine{489   \textcolor{comment}{! in h\_new. The old grid is h. Both are needed for the subsequent remapping of variables. Convective}}
\DoxyCodeLine{490   \textcolor{comment}{! adjustment right now is not used because it is unclear what to do with vanished layers}}
\DoxyCodeLine{491   \textcolor{keyword}{call }regridding\_main( cs\%remapCS, cs\%regridCS, g, gv, h, tv, h\_new, dzregrid, conv\_adjust = .false. )}
\DoxyCodeLine{492   \textcolor{keyword}{call }check\_grid( g, gv, h\_new, 0. )}
\DoxyCodeLine{493   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_offline\_inputs)"})}
\DoxyCodeLine{494 }
\DoxyCodeLine{495   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}}
\DoxyCodeLine{496   \textcolor{keyword}{call }remap\_all\_state\_vars( cs\%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs\%show\_call\_tree )}
\DoxyCodeLine{497   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_inputs)"})}
\DoxyCodeLine{498 }
\DoxyCodeLine{499   \textcolor{comment}{! Reintegrate mass transports from Zstar to the offline vertical coordinate}}
\DoxyCodeLine{500   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=g\%iscB,g\%iecB}
\DoxyCodeLine{501     \textcolor{keywordflow}{if} (g\%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{502       h\_src(:) = 0.5 * (h(i,j,:) + h(i+1,j,:))}
\DoxyCodeLine{503       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i+1,j,:))}
\DoxyCodeLine{504       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, uhtr(i,j,:), nk, h\_dest, 0., temp\_vec)}
\DoxyCodeLine{505       uhtr(i,j,:) = temp\_vec}
\DoxyCodeLine{506 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{507 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{508   \textcolor{keywordflow}{do} j=g\%jscB,g\%jecB ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{509     \textcolor{keywordflow}{if} (g\%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{510       h\_src(:) = 0.5 * (h(i,j,:) + h(i,j+1,:))}
\DoxyCodeLine{511       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i,j+1,:))}
\DoxyCodeLine{512       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, vhtr(i,j,:), nk, h\_dest, 0., temp\_vec)}
\DoxyCodeLine{513       vhtr(i,j,:) = temp\_vec}
\DoxyCodeLine{514 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{515 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{516 }
\DoxyCodeLine{517   \textcolor{keywordflow}{do} j = jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec}
\DoxyCodeLine{518     \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{519       \textcolor{keywordflow}{if} (check\_column\_integrals(nk, h\_src, nk, h\_dest)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{520         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ALE\_offline\_inputs: Kd interpolation columns do not match"})}
\DoxyCodeLine{521 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{522       \textcolor{keyword}{call }interpolate\_column(nk, h(i,j,:), kd(i,j,:), nk, h\_new(i,j,:), 0., kd(i,j,:))}
\DoxyCodeLine{523 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{524 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{525 }
\DoxyCodeLine{526   \textcolor{keyword}{call }ale\_remap\_scalar(cs\%remapCS, g, gv, nk, h, tv\%T, h\_new, tv\%T, answers\_2018=cs\%answers\_2018)}
\DoxyCodeLine{527   \textcolor{keyword}{call }ale\_remap\_scalar(cs\%remapCS, g, gv, nk, h, tv\%S, h\_new, tv\%S, answers\_2018=cs\%answers\_2018)}
\DoxyCodeLine{528 }
\DoxyCodeLine{529   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"After ALE\_offline\_inputs"}, g, h\_new, reg\%Tr, reg\%ntr)}
\DoxyCodeLine{530 }
\DoxyCodeLine{531   \textcolor{comment}{! Copy over the new layer thicknesses}}
\DoxyCodeLine{532   \textcolor{keywordflow}{do} k = 1,nk  ; \textcolor{keywordflow}{do} j = jsc-\/1,jec+1 ; \textcolor{keywordflow}{do} i = isc-\/1,iec+1}
\DoxyCodeLine{533       h(i,j,k) = h\_new(i,j,k)}
\DoxyCodeLine{534 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{535 }
\DoxyCodeLine{536   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_offline\_inputs()"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}\label{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}} 
\index{mom\_ale@{mom\_ale}!ale\_offline\_tracer\_final@{ale\_offline\_tracer\_final}}
\index{ale\_offline\_tracer\_final@{ale\_offline\_tracer\_final}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_offline\_tracer\_final()}{ale\_offline\_tracer\_final()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+offline\+\_\+tracer\+\_\+final (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(inout)}]{h\+\_\+target,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC }\end{DoxyParamCaption})}



Remaps all tracers from h onto h\+\_\+target. This is intended to be called when tracers are done offline. In the case where transports don\textquotesingle{}t quite conserve, we still want to make sure that layer thicknesses offline do not drift too far away from the online model. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid informations \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermodynamic variable structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em h\+\_\+target} & Current 3D grid obtained after last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
 & {\em reg} & Tracer registry structure \\
\hline
 & {\em cs} & Regridding parameters and options \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\end{DoxyParams}


Definition at line 544 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{544   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{   !< Ocean grid informations}}
\DoxyCodeLine{545   \textcolor{keywordtype}{type}(verticalGrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{  !< Ocean vertical grid structure}}
\DoxyCodeLine{546 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid obtained after the}}
\DoxyCodeLine{547 \textcolor{comment}{                                                                   !! last time step [H \string~> m or kg-\/2]}}
\DoxyCodeLine{548   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}}
\DoxyCodeLine{549 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},  \textcolor{keywordtype}{intent(inout)} :: h\_target\textcolor{comment}{ !< Current 3D grid obtained after}}
\DoxyCodeLine{550 \textcolor{comment}{                                                                        !! last time step  [H \string~> m or kg-\/2]}}
\DoxyCodeLine{551   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{ !< Tracer registry structure}}
\DoxyCodeLine{552   \textcolor{keywordtype}{type}(ALE\_CS),                               \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{  !< Regridding parameters and options}}
\DoxyCodeLine{553   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                       \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{ !< Open boundary structure}}
\DoxyCodeLine{554   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{555 }
\DoxyCodeLine{556 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzRegrid\textcolor{comment}{ !< The change in grid interface positions}}
\DoxyCodeLine{557 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new\textcolor{comment}{    !< Regridded target thicknesses}}
\DoxyCodeLine{558   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec}
\DoxyCodeLine{559 }
\DoxyCodeLine{560   nk = gv\%ke; isc = g\%isc; iec = g\%iec; jsc = g\%jsc; jec = g\%jec}
\DoxyCodeLine{561 }
\DoxyCodeLine{562   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final(), MOM\_ALE.F90"})}
\DoxyCodeLine{563   \textcolor{comment}{! Need to make sure that h\_target is consistent with the current offline ALE confiuration}}
\DoxyCodeLine{564   \textcolor{keyword}{call }regridding\_main( cs\%remapCS, cs\%regridCS, g, gv, h\_target, tv, h\_new, dzregrid )}
\DoxyCodeLine{565   \textcolor{keyword}{call }check\_grid( g, gv, h\_target, 0. )}
\DoxyCodeLine{566 }
\DoxyCodeLine{567 }
\DoxyCodeLine{568   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Source and target grids checked (ALE\_offline\_tracer\_final)"})}
\DoxyCodeLine{569 }
\DoxyCodeLine{570   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}}
\DoxyCodeLine{571 }
\DoxyCodeLine{572   \textcolor{keyword}{call }remap\_all\_state\_vars( cs\%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs\%show\_call\_tree )}
\DoxyCodeLine{573 }
\DoxyCodeLine{574   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_offline\_tracer\_final)"})}
\DoxyCodeLine{575 }
\DoxyCodeLine{576   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}}
\DoxyCodeLine{577   \textcolor{comment}{! one of the 'build\_...' routines above.}}
\DoxyCodeLine{578   \textcolor{comment}{!\$OMP parallel do default(shared)}}
\DoxyCodeLine{579   \textcolor{keywordflow}{do} k = 1,nk}
\DoxyCodeLine{580     \textcolor{keywordflow}{do} j = jsc-\/1,jec+1 ; \textcolor{keywordflow}{do} i = isc-\/1,iec+1}
\DoxyCodeLine{581       h(i,j,k) = h\_new(i,j,k)}
\DoxyCodeLine{582 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{583 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{584   \textcolor{keywordflow}{if} (cs\%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final()"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}\label{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}} 
\index{mom\_ale@{mom\_ale}!ale\_plm\_edge\_values@{ale\_plm\_edge\_values}}
\index{ale\_plm\_edge\_values@{ale\_plm\_edge\_values}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_plm\_edge\_values()}{ale\_plm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+plm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{Q,  }\item[{logical, intent(in)}]{bdry\+\_\+extrap,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{Q\+\_\+t,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{Q\+\_\+b }\end{DoxyParamCaption})}



Calculate edge values (top and bottom of layer) 3d scalar array. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs} & module control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em q} & 3d scalar array \\
\hline
\mbox{\texttt{ in}}  & {\em bdry\+\_\+extrap} & If true, use high-\/order boundary extrapolation within boundary cells \\
\hline
\mbox{\texttt{ in,out}}  & {\em q\+\_\+t} & Scalar at the top edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em q\+\_\+b} & Scalar at the bottom edge of each layer \\
\hline
\end{DoxyParams}


Definition at line 1039 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1039   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{   !< module control structure}}
\DoxyCodeLine{1040   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}}
\DoxyCodeLine{1041   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}}
\DoxyCodeLine{1042 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1043                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1044 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1045                            \textcolor{keywordtype}{intent(in)}    :: Q\textcolor{comment}{    !< 3d scalar array}}
\DoxyCodeLine{1046   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-\/order boundary}}
\DoxyCodeLine{1047 \textcolor{comment}{                                                 !! extrapolation within boundary cells}}
\DoxyCodeLine{1048 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1049                            \textcolor{keywordtype}{intent(inout)} :: Q\_t\textcolor{comment}{  !< Scalar at the top edge of each layer}}
\DoxyCodeLine{1050 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1051                            \textcolor{keywordtype}{intent(inout)} :: Q\_b\textcolor{comment}{  !< Scalar at the bottom edge of each layer}}
\DoxyCodeLine{1052   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1053   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1054 \textcolor{keywordtype}{  real} :: slp(GV\%ke)}
\DoxyCodeLine{1055 \textcolor{keywordtype}{  real} :: mslp}
\DoxyCodeLine{1056 \textcolor{keywordtype}{  real} :: h\_neglect}
\DoxyCodeLine{1057 }
\DoxyCodeLine{1058   \textcolor{keywordflow}{if} (.not.cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1059     h\_neglect = gv\%H\_subroundoff}
\DoxyCodeLine{1060   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1061     h\_neglect = gv\%m\_to\_H*1.0e-\/30}
\DoxyCodeLine{1062   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1063     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30}
\DoxyCodeLine{1064 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1065 }
\DoxyCodeLine{1066   \textcolor{comment}{!\$OMP parallel do default(shared) private(slp,mslp)}}
\DoxyCodeLine{1067   \textcolor{keywordflow}{do} j = g\%jsc-\/1,g\%jec+1 ; \textcolor{keywordflow}{do} i = g\%isc-\/1,g\%iec+1}
\DoxyCodeLine{1068     slp(1) = 0.}
\DoxyCodeLine{1069     \textcolor{keywordflow}{do} k = 2, gv\%ke-\/1}
\DoxyCodeLine{1070       slp(k) = plm\_slope\_wa(h(i,j,k-\/1), h(i,j,k), h(i,j,k+1), h\_neglect, q(i,j,k-\/1), q(i,j,k), q(i,j,k+1))}
\DoxyCodeLine{1071 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1072     slp(gv\%ke) = 0.}
\DoxyCodeLine{1073 }
\DoxyCodeLine{1074     \textcolor{keywordflow}{do} k = 2, gv\%ke-\/1}
\DoxyCodeLine{1075       mslp = plm\_monotonized\_slope(q(i,j,k-\/1), q(i,j,k), q(i,j,k+1), slp(k-\/1), slp(k), slp(k+1))}
\DoxyCodeLine{1076       q\_t(i,j,k) = q(i,j,k) -\/ 0.5 * mslp}
\DoxyCodeLine{1077       q\_b(i,j,k) = q(i,j,k) + 0.5 * mslp}
\DoxyCodeLine{1078 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1079     \textcolor{keywordflow}{if} (bdry\_extrap) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1080       mslp = -\/ plm\_extrapolate\_slope(h(i,j,2), h(i,j,1), h\_neglect, q(i,j,2), q(i,j,1))}
\DoxyCodeLine{1081       q\_t(i,j,1) = q(i,j,1) -\/ 0.5 * mslp}
\DoxyCodeLine{1082       q\_b(i,j,1) = q(i,j,1) + 0.5 * mslp}
\DoxyCodeLine{1083       mslp = plm\_extrapolate\_slope(h(i,j,gv\%ke-\/1), h(i,j,gv\%ke), h\_neglect, q(i,j,gv\%ke-\/1), q(i,j,gv\%ke))}
\DoxyCodeLine{1084       q\_t(i,j,gv\%ke) = q(i,j,gv\%ke) -\/ 0.5 * mslp}
\DoxyCodeLine{1085       q\_b(i,j,gv\%ke) = q(i,j,gv\%ke) + 0.5 * mslp}
\DoxyCodeLine{1086     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1087       q\_t(i,j,1) = q(i,j,1)}
\DoxyCodeLine{1088       q\_b(i,j,1) = q(i,j,1)}
\DoxyCodeLine{1089       q\_t(i,j,gv\%ke) = q(i,j,gv\%ke)}
\DoxyCodeLine{1090       q\_b(i,j,gv\%ke) = q(i,j,gv\%ke)}
\DoxyCodeLine{1091 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1092 }
\DoxyCodeLine{1093 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1094 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}\label{namespacemom__ale_ac9b603b29f630dc8498e35a0e5c16a53}} 
\index{mom\_ale@{mom\_ale}!ale\_register\_diags@{ale\_register\_diags}}
\index{ale\_register\_diags@{ale\_register\_diags}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_register\_diags()}{ale\_register\_diags()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+register\+\_\+diags (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in), target}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(diag\+\_\+ctrl), intent(in), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Initialize diagnostics for the A\+LE module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & Time structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & Diagnostics control structure \\
\hline
 & {\em cs} & Module control structure \\
\hline
\end{DoxyParams}


Definition at line 250 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{250   \textcolor{keywordtype}{type}(time\_type),\textcolor{keywordtype}{target},     \textcolor{keywordtype}{intent(in)}  :: Time\textcolor{comment}{  !< Time structure}}
\DoxyCodeLine{251   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}  :: G\textcolor{comment}{     !< Grid structure}}
\DoxyCodeLine{252   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}  :: US\textcolor{comment}{    !< A dimensional unit scaling type}}
\DoxyCodeLine{253   \textcolor{keywordtype}{type}(verticalGrid\_type),    \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{    !< Ocean vertical grid structure}}
\DoxyCodeLine{254   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\textcolor{comment}{  !< Diagnostics control structure}}
\DoxyCodeLine{255   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer}                   :: CS\textcolor{comment}{    !< Module control structure}}
\DoxyCodeLine{256 }
\DoxyCodeLine{257   cs\%diag => diag}
\DoxyCodeLine{258 }
\DoxyCodeLine{259   \textcolor{comment}{! These diagnostics of the state variables before ALE are useful for}}
\DoxyCodeLine{260   \textcolor{comment}{! debugging the ALE code.}}
\DoxyCodeLine{261   cs\%id\_u\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_preale'}, diag\%axesCuL, time, \&}
\DoxyCodeLine{262       \textcolor{stringliteral}{'Zonal velocity before remapping'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{263   cs\%id\_v\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_preale'}, diag\%axesCvL, time, \&}
\DoxyCodeLine{264       \textcolor{stringliteral}{'Meridional velocity before remapping'}, \textcolor{stringliteral}{'m s-\/1'}, conversion=us\%L\_T\_to\_m\_s)}
\DoxyCodeLine{265   cs\%id\_h\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_preale'}, diag\%axesTL, time, \&}
\DoxyCodeLine{266       \textcolor{stringliteral}{'Layer Thickness before remapping'}, get\_thickness\_units(gv), \&}
\DoxyCodeLine{267       conversion=gv\%H\_to\_MKS, v\_extensive=.true.)}
\DoxyCodeLine{268   cs\%id\_T\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'T\_preale'}, diag\%axesTL, time, \&}
\DoxyCodeLine{269       \textcolor{stringliteral}{'Temperature before remapping'}, \textcolor{stringliteral}{'degC'})}
\DoxyCodeLine{270   cs\%id\_S\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'S\_preale'}, diag\%axesTL, time, \&}
\DoxyCodeLine{271       \textcolor{stringliteral}{'Salinity before remapping'}, \textcolor{stringliteral}{'PSU'})}
\DoxyCodeLine{272   cs\%id\_e\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_preale'}, diag\%axesTi, time, \&}
\DoxyCodeLine{273       \textcolor{stringliteral}{'Interface Heights before remapping'}, \textcolor{stringliteral}{'m'}, conversion=us\%Z\_to\_m)}
\DoxyCodeLine{274 }
\DoxyCodeLine{275   cs\%id\_dzRegrid = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dzRegrid'},diag\%axesTi,time, \&}
\DoxyCodeLine{276       \textcolor{stringliteral}{'Change in interface height due to ALE regridding'}, \textcolor{stringliteral}{'m'}, \&}
\DoxyCodeLine{277       conversion=gv\%H\_to\_m)}
\DoxyCodeLine{278   cs\%id\_vert\_remap\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vert\_remap\_h'}, \&}
\DoxyCodeLine{279       diag\%axestl, time, \textcolor{stringliteral}{'layer thicknesses after ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, \&}
\DoxyCodeLine{280       conversion=gv\%H\_to\_m, v\_extensive=.true.)}
\DoxyCodeLine{281   cs\%id\_vert\_remap\_h\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'vert\_remap\_h\_tendency'},diag\%axestl,time, \&}
\DoxyCodeLine{282       \textcolor{stringliteral}{'Layer thicknesses tendency due to ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, \&}
\DoxyCodeLine{283       conversion=gv\%H\_to\_m*us\%s\_to\_T, v\_extensive = .true.)}
\DoxyCodeLine{284 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}\label{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}} 
\index{mom\_ale@{mom\_ale}!ale\_regrid\_accelerated@{ale\_regrid\_accelerated}}
\index{ale\_regrid\_accelerated@{ale\_regrid\_accelerated}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_regrid\_accelerated()}{ale\_regrid\_accelerated()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+regrid\+\_\+accelerated (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(inout)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{integer, intent(in)}]{n,  }\item[{real, dimension( g \%isdb\+: g \%iedb, g \%jsd\+: g \%jed, gv \%ke), intent(inout)}]{u,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsdb\+: g \%jedb, gv \%ke), intent(inout)}]{v,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{type(tracer\+\_\+registry\+\_\+type), optional, pointer}]{Reg,  }\item[{real, intent(in), optional}]{dt,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke+1), intent(inout), optional}]{dz\+Regrid,  }\item[{logical, intent(in), optional}]{initial }\end{DoxyParamCaption})}



For a state-\/based coordinate, accelerate the process of regridding by repeatedly applying the grid calculation algorithm. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & A\+LE control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Ocean grid \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Vertical grid \\
\hline
\mbox{\texttt{ in,out}}  & {\em h} & Original thicknesses \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & Thermo vars (T/\+S/\+E\+OS) \\
\hline
\mbox{\texttt{ in}}  & {\em n} & Number of times to regrid \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
 & {\em reg} & Tracer registry to remap onto new grid \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & Model timestep to provide a timescale for regridding \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em dzregrid} & Final change in interface positions \\
\hline
\mbox{\texttt{ in}}  & {\em initial} & Whether we\textquotesingle{}re being called from an initialization routine (and expect diagnostics to work) \\
\hline
\end{DoxyParams}


Definition at line 660 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{660   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< ALE control structure}}
\DoxyCodeLine{661   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Ocean grid}}
\DoxyCodeLine{662   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{     !< Vertical grid}}
\DoxyCodeLine{663 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{664                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{      !< Original thicknesses [H \string~> m or kg-\/2]}}
\DoxyCodeLine{665   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< Thermo vars (T/S/EOS)}}
\DoxyCodeLine{666   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)}    :: n\textcolor{comment}{      !< Number of times to regrid}}
\DoxyCodeLine{667 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{668                            \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{669 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{670                            \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{671   \textcolor{keywordtype}{type}(ocean\_OBC\_type),    \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{    !< Open boundary structure}}
\DoxyCodeLine{672   \textcolor{keywordtype}{type}(tracer\_registry\_type), \&}
\DoxyCodeLine{673                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{    !< Tracer registry to remap onto new grid}}
\DoxyCodeLine{674 \textcolor{keywordtype}{  real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Model timestep to provide a timescale for regridding [T \string~> s]}}
\DoxyCodeLine{675 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \&}
\DoxyCodeLine{676                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: dzRegrid\textcolor{comment}{ !< Final change in interface positions}}
\DoxyCodeLine{677   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: initial\textcolor{comment}{ !< Whether we're being called from an initialization}}
\DoxyCodeLine{678 \textcolor{comment}{                                                    !! routine (and expect diagnostics to work)}}
\DoxyCodeLine{679 }
\DoxyCodeLine{680   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{681   \textcolor{keywordtype}{integer} :: i, j, k, nz}
\DoxyCodeLine{682   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_local \textcolor{comment}{! local/intermediate temp/salt}}
\DoxyCodeLine{683   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_T\_S\_h \textcolor{comment}{! group pass if the coordinate has a stencil}}
\DoxyCodeLine{684 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}         :: h\_loc, h\_orig \textcolor{comment}{! A working copy of layer thicknesses}}
\DoxyCodeLine{685 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{target} :: T, S \textcolor{comment}{! local temporary state}}
\DoxyCodeLine{686   \textcolor{comment}{! we have to keep track of the total dzInterface if for some reason}}
\DoxyCodeLine{687   \textcolor{comment}{! we're using the old remapping algorithm for u/v}}
\DoxyCodeLine{688 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzInterface, dzIntTotal}
\DoxyCodeLine{689 }
\DoxyCodeLine{690   nz = gv\%ke}
\DoxyCodeLine{691 }
\DoxyCodeLine{692   \textcolor{comment}{! initial total interface displacement due to successive regridding}}
\DoxyCodeLine{693   dzinttotal(:,:,:) = 0.}
\DoxyCodeLine{694 }
\DoxyCodeLine{695   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, t, g\%domain)}
\DoxyCodeLine{696   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, s, g\%domain)}
\DoxyCodeLine{697   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, h\_loc, g\%domain)}
\DoxyCodeLine{698 }
\DoxyCodeLine{699   \textcolor{comment}{! copy original temp/salt and set our local tv\_pointers to them}}
\DoxyCodeLine{700   tv\_local = tv}
\DoxyCodeLine{701   t(:,:,:) = tv\%T(:,:,:)}
\DoxyCodeLine{702   s(:,:,:) = tv\%S(:,:,:)}
\DoxyCodeLine{703   tv\_local\%T => t}
\DoxyCodeLine{704   tv\_local\%S => s}
\DoxyCodeLine{705 }
\DoxyCodeLine{706   \textcolor{comment}{! get local copy of thickness and save original state for remapping}}
\DoxyCodeLine{707   h\_loc(:,:,:) = h(:,:,:)}
\DoxyCodeLine{708   h\_orig(:,:,:) = h(:,:,:)}
\DoxyCodeLine{709 }
\DoxyCodeLine{710   \textcolor{comment}{! Apply timescale to regridding (for e.g. filtered\_grid\_motion)}}
\DoxyCodeLine{711   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \&}
\DoxyCodeLine{712     \textcolor{keyword}{call }ale\_update\_regrid\_weights(dt, cs)}
\DoxyCodeLine{713 }
\DoxyCodeLine{714   \textcolor{keywordflow}{do} k = 1, n}
\DoxyCodeLine{715     \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s\_h, g\%domain)}
\DoxyCodeLine{716 }
\DoxyCodeLine{717     \textcolor{comment}{! generate new grid}}
\DoxyCodeLine{718     \textcolor{keyword}{call }regridding\_main(cs\%remapCS, cs\%regridCS, g, gv, h\_loc, tv\_local, h, dzinterface)}
\DoxyCodeLine{719     dzinttotal(:,:,:) = dzinttotal(:,:,:) + dzinterface(:,:,:)}
\DoxyCodeLine{720 }
\DoxyCodeLine{721     \textcolor{comment}{! remap from original grid onto new grid}}
\DoxyCodeLine{722     \textcolor{keywordflow}{do} j = g\%jsc-\/1,g\%jec+1 ; \textcolor{keywordflow}{do} i = g\%isc-\/1,g\%iec+1}
\DoxyCodeLine{723       \textcolor{keyword}{call }remapping\_core\_h(cs\%remapCS, nz, h\_orig(i,j,:), tv\%S(i,j,:), nz, h(i,j,:), tv\_local\%S(i,j,:))}
\DoxyCodeLine{724       \textcolor{keyword}{call }remapping\_core\_h(cs\%remapCS, nz, h\_orig(i,j,:), tv\%T(i,j,:), nz, h(i,j,:), tv\_local\%T(i,j,:))}
\DoxyCodeLine{725 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{726 }
\DoxyCodeLine{727     \textcolor{comment}{! starting grid for next iteration}}
\DoxyCodeLine{728     h\_loc(:,:,:) = h(:,:,:)}
\DoxyCodeLine{729 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{730 }
\DoxyCodeLine{731   \textcolor{comment}{! remap all state variables (including those that weren't needed for regridding)}}
\DoxyCodeLine{732   \textcolor{keyword}{call }remap\_all\_state\_vars(cs\%remapCS, cs, g, gv, h\_orig, h, reg, obc, dzinttotal, u, v)}
\DoxyCodeLine{733 }
\DoxyCodeLine{734   \textcolor{comment}{! save total dzregrid for diags if needed?}}
\DoxyCodeLine{735   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dzregrid)) dzregrid(:,:,:) = dzinttotal(:,:,:)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}\label{namespacemom__ale_a9e4ec7771d6291fc72884796b23922b3}} 
\index{mom\_ale@{mom\_ale}!ale\_remap\_init\_conds@{ale\_remap\_init\_conds}}
\index{ale\_remap\_init\_conds@{ale\_remap\_init\_conds}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_remap\_init\_conds()}{ale\_remap\_init\_conds()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+ale\+::ale\+\_\+remap\+\_\+init\+\_\+conds (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Returns true if initial conditions should be regridded and remapped. 


\begin{DoxyParams}{Parameters}
{\em cs} & module control structure \\
\hline
\end{DoxyParams}


Definition at line 1228 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1228   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{   !< module control structure}}
\DoxyCodeLine{1229 }
\DoxyCodeLine{1230   ale\_remap\_init\_conds = .false.}
\DoxyCodeLine{1231   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) ale\_remap\_init\_conds = cs\%remap\_after\_initialization}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}\label{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}} 
\index{mom\_ale@{mom\_ale}!ale\_remap\_scalar@{ale\_remap\_scalar}}
\index{ale\_remap\_scalar@{ale\_remap\_scalar}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_remap\_scalar()}{ale\_remap\_scalar()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+remap\+\_\+scalar (\begin{DoxyParamCaption}\item[{type(remapping\+\_\+cs), intent(in)}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{integer, intent(in)}]{nk\+\_\+src,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),nk\+\_\+src), intent(in)}]{h\+\_\+src,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),nk\+\_\+src), intent(in)}]{s\+\_\+src,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h\+\_\+dst,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{s\+\_\+dst,  }\item[{logical, intent(in), optional}]{all\+\_\+cells,  }\item[{logical, intent(in), optional}]{old\+\_\+remap,  }\item[{logical, intent(in), optional}]{answers\+\_\+2018 }\end{DoxyParamCaption})}



Remaps a single scalar between grids described by thicknesses h\+\_\+src and h\+\_\+dst. h\+\_\+dst must be dimensioned as a model array with GVke layers while h\+\_\+src can have an arbitrary number of layers specified by nk\+\_\+src. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs} & Remapping control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em nk\+\_\+src} & Number of levels on source grid \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+src} & Level thickness of source grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em s\+\_\+src} & Scalar on source grid \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+dst} & Level thickness of destination grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em s\+\_\+dst} & Scalar on destination grid \\
\hline
\mbox{\texttt{ in}}  & {\em all\+\_\+cells} & If false, only reconstruct for non-\/vanished cells. Use all vanished layers otherwise (default). \\
\hline
\mbox{\texttt{ in}}  & {\em old\+\_\+remap} & If true, use the old \char`\"{}remapping\+\_\+core\+\_\+w\char`\"{} method, otherwise use \char`\"{}remapping\+\_\+core\+\_\+h\char`\"{}. \\
\hline
\mbox{\texttt{ in}}  & {\em answers\+\_\+2018} & If true, use the order of arithmetic and expressions that recover the answers for remapping from the end of 2018. Otherwise, use more robust forms of the same expressions. \\
\hline
\end{DoxyParams}


Definition at line 945 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{945   \textcolor{keywordtype}{type}(remapping\_CS),                      \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{        !< Remapping control structure}}
\DoxyCodeLine{946   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{         !< Ocean grid structure}}
\DoxyCodeLine{947   \textcolor{keywordtype}{type}(verticalGrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{        !< Ocean vertical grid structure}}
\DoxyCodeLine{948   \textcolor{keywordtype}{integer},                                 \textcolor{keywordtype}{intent(in)}    :: nk\_src\textcolor{comment}{    !< Number of levels on source grid}}
\DoxyCodeLine{949 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_src)}, \textcolor{keywordtype}{intent(in)}    :: h\_src\textcolor{comment}{     !< Level thickness of source grid}}
\DoxyCodeLine{950 \textcolor{comment}{                                                                      !! [H \string~> m or kg-\/2]}}
\DoxyCodeLine{951 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_src)}, \textcolor{keywordtype}{intent(in)}    :: s\_src\textcolor{comment}{     !< Scalar on source grid}}
\DoxyCodeLine{952 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},\textcolor{keywordtype}{intent(in)}   :: h\_dst\textcolor{comment}{     !< Level thickness of destination grid}}
\DoxyCodeLine{953 \textcolor{comment}{                                                                      !! [H \string~> m or kg-\/2]}}
\DoxyCodeLine{954 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},\textcolor{keywordtype}{intent(inout)} :: s\_dst\textcolor{comment}{    !< Scalar on destination grid}}
\DoxyCodeLine{955   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: all\_cells\textcolor{comment}{ !< If false, only reconstruct for}}
\DoxyCodeLine{956 \textcolor{comment}{                                                                      !! non-\/vanished cells. Use all vanished}}
\DoxyCodeLine{957 \textcolor{comment}{                                                                      !! layers otherwise (default).}}
\DoxyCodeLine{958   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: old\_remap\textcolor{comment}{ !< If true, use the old "remapping\_core\_w"}}
\DoxyCodeLine{959 \textcolor{comment}{                                                                      !! method, otherwise use "remapping\_core\_h".}}
\DoxyCodeLine{960   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true, use the order of arithmetic}}
\DoxyCodeLine{961 \textcolor{comment}{                                                                      !! and expressions that recover the answers for}}
\DoxyCodeLine{962 \textcolor{comment}{                                                                      !! remapping from the end of 2018. Otherwise,}}
\DoxyCodeLine{963 \textcolor{comment}{                                                                      !! use more robust forms of the same expressions.}}
\DoxyCodeLine{964   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{965   \textcolor{keywordtype}{integer} :: i, j, k, n\_points}
\DoxyCodeLine{966 \textcolor{keywordtype}{  real} :: dx(GV\%ke+1)}
\DoxyCodeLine{967 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge}
\DoxyCodeLine{968   \textcolor{keywordtype}{logical} :: ignore\_vanished\_layers, use\_remapping\_core\_w, use\_2018\_remap}
\DoxyCodeLine{969 }
\DoxyCodeLine{970   ignore\_vanished\_layers = .false.}
\DoxyCodeLine{971   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(all\_cells)) ignore\_vanished\_layers = .not. all\_cells}
\DoxyCodeLine{972   use\_remapping\_core\_w = .false.}
\DoxyCodeLine{973   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(old\_remap)) use\_remapping\_core\_w = old\_remap}
\DoxyCodeLine{974   n\_points = nk\_src}
\DoxyCodeLine{975   use\_2018\_remap = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(answers\_2018)) use\_2018\_remap = answers\_2018}
\DoxyCodeLine{976 }
\DoxyCodeLine{977   \textcolor{keywordflow}{if} (.not.use\_2018\_remap) \textcolor{keywordflow}{then}}
\DoxyCodeLine{978     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{979   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{980     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{981   \textcolor{keywordflow}{else}}
\DoxyCodeLine{982     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{983 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{984 }
\DoxyCodeLine{985   \textcolor{comment}{!\$OMP parallel do default(shared) firstprivate(n\_points,dx)}}
\DoxyCodeLine{986   \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{987     \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{988       \textcolor{keywordflow}{if} (ignore\_vanished\_layers) \textcolor{keywordflow}{then}}
\DoxyCodeLine{989         n\_points = 0}
\DoxyCodeLine{990         \textcolor{keywordflow}{do} k = 1, nk\_src}
\DoxyCodeLine{991           \textcolor{keywordflow}{if} (h\_src(i,j,k)>0.) n\_points = n\_points + 1}
\DoxyCodeLine{992 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{993         s\_dst(i,j,:) = 0.}
\DoxyCodeLine{994 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{995       \textcolor{keywordflow}{if} (use\_remapping\_core\_w) \textcolor{keywordflow}{then}}
\DoxyCodeLine{996         \textcolor{keyword}{call }dzfromh1h2( n\_points, h\_src(i,j,1:n\_points), gv\%ke, h\_dst(i,j,:), dx )}
\DoxyCodeLine{997         \textcolor{keyword}{call }remapping\_core\_w(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), \&}
\DoxyCodeLine{998                               gv\%ke, dx, s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{999       \textcolor{keywordflow}{else}}
\DoxyCodeLine{1000         \textcolor{keyword}{call }remapping\_core\_h(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), \&}
\DoxyCodeLine{1001                               gv\%ke, h\_dst(i,j,:), s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{1002 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{1003     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1004       s\_dst(i,j,:) = 0.}
\DoxyCodeLine{1005 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1006 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1007 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}\label{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}} 
\index{mom\_ale@{mom\_ale}!ale\_update\_regrid\_weights@{ale\_update\_regrid\_weights}}
\index{ale\_update\_regrid\_weights@{ale\_update\_regrid\_weights}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_update\_regrid\_weights()}{ale\_update\_regrid\_weights()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+update\+\_\+regrid\+\_\+weights (\begin{DoxyParamCaption}\item[{real, intent(in)}]{dt,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Updates the weights for time filtering the new grid generated in regridding. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dt} & Time-\/step used between A\+LE calls \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
 & {\em cs} & A\+LE control structure \\
\hline
\end{DoxyParams}


Definition at line 1236 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1236 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{ !< Time-\/step used between ALE calls [T \string~> s]}}
\DoxyCodeLine{1237   \textcolor{keywordtype}{type}(ALE\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< ALE control structure}}
\DoxyCodeLine{1238   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1239 \textcolor{keywordtype}{  real} :: w  \textcolor{comment}{! An implicit weighting estimate.}}
\DoxyCodeLine{1240 }
\DoxyCodeLine{1241   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1242     w = 0.0}
\DoxyCodeLine{1243     \textcolor{keywordflow}{if} (cs\%regrid\_time\_scale > 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1244       w = cs\%regrid\_time\_scale / (cs\%regrid\_time\_scale + dt)}
\DoxyCodeLine{1245 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1246     \textcolor{keyword}{call }set\_regrid\_params(cs\%regridCS, old\_grid\_weight=w)}
\DoxyCodeLine{1247 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1248 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}\label{namespacemom__ale_a86cb18b00e146a754f09ef6a46cd7878}} 
\index{mom\_ale@{mom\_ale}!ale\_updateverticalgridtype@{ale\_updateverticalgridtype}}
\index{ale\_updateverticalgridtype@{ale\_updateverticalgridtype}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_updateverticalgridtype()}{ale\_updateverticalgridtype()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+updateverticalgridtype (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(verticalgrid\+\_\+type), pointer}]{GV }\end{DoxyParamCaption})}



Update the vertical grid type with A\+LE information. This subroutine sets information in the vertical\+Grid\+\_\+type to be consistent with the use of A\+LE mode. 


\begin{DoxyParams}{Parameters}
{\em cs} & A\+LE control structure \\
\hline
{\em gv} & vertical grid information \\
\hline
\end{DoxyParams}


Definition at line 1255 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1255   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{  !< ALE control structure}}
\DoxyCodeLine{1256   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{pointer} :: GV\textcolor{comment}{  !< vertical grid information}}
\DoxyCodeLine{1257 }
\DoxyCodeLine{1258   \textcolor{keywordtype}{integer} :: nk}
\DoxyCodeLine{1259 }
\DoxyCodeLine{1260   nk = gv\%ke}
\DoxyCodeLine{1261   gv\%sInterface(1:nk+1) = getcoordinateinterfaces( cs\%regridCS, undo\_scaling=.true. )}
\DoxyCodeLine{1262   gv\%sLayer(1:nk) = 0.5*( gv\%sInterface(1:nk) + gv\%sInterface(2:nk+1) )}
\DoxyCodeLine{1263   gv\%zAxisUnits = getcoordinateunits( cs\%regridCS )}
\DoxyCodeLine{1264   gv\%zAxisLongName = getcoordinateshortname( cs\%regridCS )}
\DoxyCodeLine{1265   gv\%direction = -\/1 \textcolor{comment}{! Because of ferret in z* mode. Need method to set}}
\DoxyCodeLine{1266                     \textcolor{comment}{! as function of coordinae mode.}}
\DoxyCodeLine{1267 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}\label{namespacemom__ale_a8a784e56b0acbcda92f7af471d2c980d}} 
\index{mom\_ale@{mom\_ale}!ale\_writecoordinatefile@{ale\_writecoordinatefile}}
\index{ale\_writecoordinatefile@{ale\_writecoordinatefile}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ale\_writecoordinatefile()}{ale\_writecoordinatefile()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+writecoordinatefile (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), pointer}]{CS,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{character(len=$\ast$), intent(in)}]{directory }\end{DoxyParamCaption})}



Write the vertical coordinate information into a file. This subroutine writes out a file containing any available data related to the vertical grid used by the M\+OM ocean model when in A\+LE mode. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & module control structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em directory} & directory for writing grid info \\
\hline
\end{DoxyParams}


Definition at line 1275 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1275   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{pointer}     :: CS\textcolor{comment}{         !< module control structure}}
\DoxyCodeLine{1276   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}  :: GV\textcolor{comment}{         !< ocean vertical grid structure}}
\DoxyCodeLine{1277   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: directory\textcolor{comment}{  !< directory for writing grid info}}
\DoxyCodeLine{1278 }
\DoxyCodeLine{1279   \textcolor{keywordtype}{character(len=240)} :: filepath}
\DoxyCodeLine{1280   \textcolor{keywordtype}{type}(vardesc)      :: vars(2)}
\DoxyCodeLine{1281   \textcolor{keywordtype}{type}(fieldtype)    :: fields(2)}
\DoxyCodeLine{1282   \textcolor{keywordtype}{integer}            :: unit}
\DoxyCodeLine{1283 \textcolor{keywordtype}{  real}               :: ds(GV\%ke), dsi(GV\%ke+1)}
\DoxyCodeLine{1284 }
\DoxyCodeLine{1285   filepath    = trim(directory) // trim(\textcolor{stringliteral}{"Vertical\_coordinate"})}
\DoxyCodeLine{1286   ds(:)       = getcoordinateresolution( cs\%regridCS, undo\_scaling=.true. )}
\DoxyCodeLine{1287   dsi(1)      = 0.5*ds(1)}
\DoxyCodeLine{1288   dsi(2:gv\%ke) = 0.5*( ds(1:gv\%ke-\/1) + ds(2:gv\%ke) )}
\DoxyCodeLine{1289   dsi(gv\%ke+1) = 0.5*ds(gv\%ke)}
\DoxyCodeLine{1290 }
\DoxyCodeLine{1291   vars(1) = var\_desc(\textcolor{stringliteral}{'ds'}, getcoordinateunits( cs\%regridCS ), \&}
\DoxyCodeLine{1292                     \textcolor{stringliteral}{'Layer Coordinate Thickness'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'L'},\textcolor{stringliteral}{'1'})}
\DoxyCodeLine{1293   vars(2) = var\_desc(\textcolor{stringliteral}{'ds\_interface'}, getcoordinateunits( cs\%regridCS ), \&}
\DoxyCodeLine{1294                     \textcolor{stringliteral}{'Layer Center Coordinate Separation'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'i'},\textcolor{stringliteral}{'1'})}
\DoxyCodeLine{1295 }
\DoxyCodeLine{1296   \textcolor{keyword}{call }create\_file(unit, trim(filepath), vars, 2, fields, single\_file, gv=gv)}
\DoxyCodeLine{1297   \textcolor{keyword}{call }write\_field(unit, fields(1), ds)}
\DoxyCodeLine{1298   \textcolor{keyword}{call }write\_field(unit, fields(2), dsi)}
\DoxyCodeLine{1299   \textcolor{keyword}{call }close\_file(unit)}
\DoxyCodeLine{1300 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}\label{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}} 
\index{mom\_ale@{mom\_ale}!check\_grid@{check\_grid}}
\index{check\_grid@{check\_grid}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{check\_grid()}{check\_grid()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+::check\+\_\+grid (\begin{DoxyParamCaption}\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, gv \%ke), intent(in)}]{h,  }\item[{real, intent(in)}]{threshold }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Check grid for negative thicknesses. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em threshold} & Value below which to flag issues, \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 589 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{589   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{  !< Ocean grid structure}}
\DoxyCodeLine{590   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< Ocean vertical grid structure}}
\DoxyCodeLine{591 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{  !< Current 3D grid obtained after the}}
\DoxyCodeLine{592 \textcolor{comment}{                                                              !! last time step [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{593 \textcolor{keywordtype}{  real},                                      \textcolor{keywordtype}{intent(in)} :: threshold\textcolor{comment}{ !< Value below which to flag issues,}}
\DoxyCodeLine{594 \textcolor{comment}{                                                              !! [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{595   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{596   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{597 }
\DoxyCodeLine{598   \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{599     \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{600       \textcolor{keywordflow}{if} (minval(h(i,j,:)) < threshold) \textcolor{keywordflow}{then}}
\DoxyCodeLine{601         \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'check\_grid: i,j='},i,j,\textcolor{stringliteral}{'h(i,j,:)='},h(i,j,:)}
\DoxyCodeLine{602         \textcolor{keywordflow}{if} (threshold <= 0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{603           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: negative thickness encountered."})}
\DoxyCodeLine{604         \textcolor{keywordflow}{else}}
\DoxyCodeLine{605           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: too tiny thickness encountered."})}
\DoxyCodeLine{606 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{607 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{608 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{609 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{610 }
\DoxyCodeLine{611 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}\label{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}} 
\index{mom\_ale@{mom\_ale}!remap\_all\_state\_vars@{remap\_all\_state\_vars}}
\index{remap\_all\_state\_vars@{remap\_all\_state\_vars}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{remap\_all\_state\_vars()}{remap\_all\_state\_vars()}}
{\footnotesize\ttfamily subroutine mom\+\_\+ale\+::remap\+\_\+all\+\_\+state\+\_\+vars (\begin{DoxyParamCaption}\item[{type(remapping\+\_\+cs), intent(in)}]{C\+S\+\_\+remapping,  }\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), intent(in)}]{C\+S\+\_\+\+A\+LE,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h\+\_\+old,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h\+\_\+new,  }\item[{type(tracer\+\_\+registry\+\_\+type), pointer}]{Reg,  }\item[{type(ocean\+\_\+obc\+\_\+type), pointer}]{O\+BC,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)+1), intent(in), optional}]{dx\+Interface,  }\item[{real, dimension(szib\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout), optional}]{u,  }\item[{real, dimension(szi\+\_\+(g),szjb\+\_\+(g),szk\+\_\+(gv)), intent(inout), optional}]{v,  }\item[{logical, intent(in), optional}]{debug,  }\item[{real, intent(in), optional}]{dt }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This routine takes care of remapping all variable between the old and the new grids. When velocity components need to be remapped, thicknesses at velocity points are taken to be arithmetic averages of tracer thicknesses. This routine is called during initialization of the model at time=0, to remap initiali conditions to the model grid. It is also called during a time step to update the state. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs\+\_\+remapping} & Remapping control structure \\
\hline
\mbox{\texttt{ in}}  & {\em cs\+\_\+ale} & A\+LE control structure \\
\hline
\mbox{\texttt{ in}}  & {\em g} & Ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+old} & Thickness of source grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em h\+\_\+new} & Thickness of destination grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]} \\
\hline
 & {\em reg} & Tracer registry structure \\
\hline
 & {\em obc} & Open boundary structure \\
\hline
\mbox{\texttt{ in}}  & {\em dxinterface} & Change in interface position \\
\hline
\mbox{\texttt{ in,out}}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em debug} & If true, show the call tree \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & time step for diagnostics \mbox{[}T $\sim$$>$ s\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 746 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{746   \textcolor{keywordtype}{type}(remapping\_CS),                        \textcolor{keywordtype}{intent(in)}    :: CS\_remapping\textcolor{comment}{ !< Remapping control structure}}
\DoxyCodeLine{747   \textcolor{keywordtype}{type}(ALE\_CS),                              \textcolor{keywordtype}{intent(in)}    :: CS\_ALE\textcolor{comment}{       !< ALE control structure}}
\DoxyCodeLine{748   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{            !< Ocean grid structure}}
\DoxyCodeLine{749   \textcolor{keywordtype}{type}(verticalGrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{           !< Ocean vertical grid structure}}
\DoxyCodeLine{750 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_old\textcolor{comment}{        !< Thickness of source grid}}
\DoxyCodeLine{751 \textcolor{comment}{                                                                           !! [H \string~> m or kg-\/2]}}
\DoxyCodeLine{752 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_new\textcolor{comment}{        !< Thickness of destination grid}}
\DoxyCodeLine{753 \textcolor{comment}{                                                                           !! [H \string~> m or kg-\/2]}}
\DoxyCodeLine{754   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}       :: Reg\textcolor{comment}{          !< Tracer registry structure}}
\DoxyCodeLine{755   \textcolor{keywordtype}{type}(ocean\_OBC\_type),                      \textcolor{keywordtype}{pointer}       :: OBC\textcolor{comment}{          !< Open boundary structure}}
\DoxyCodeLine{756 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, \&}
\DoxyCodeLine{757                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dxInterface\textcolor{comment}{  !< Change in interface position}}
\DoxyCodeLine{758 \textcolor{comment}{                                                                           !! [H \string~> m or kg-\/2]}}
\DoxyCodeLine{759 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{760                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{761 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{762                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-\/1 \string~> m s-\/1]}}
\DoxyCodeLine{763   \textcolor{keywordtype}{logical},                         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{  !< If true, show the call tree}}
\DoxyCodeLine{764 \textcolor{keywordtype}{  real},                            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< time step for diagnostics [T \string~> s]}}
\DoxyCodeLine{765   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{766   \textcolor{keywordtype}{integer}                                     :: i, j, k, m}
\DoxyCodeLine{767   \textcolor{keywordtype}{integer}                                     :: nz, ntr}
\DoxyCodeLine{768 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(GV\%ke+1)}                    :: dx}
\DoxyCodeLine{769 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(GV\%ke)}                      :: h1, u\_column}
\DoxyCodeLine{770 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_conc}
\DoxyCodeLine{771 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_cont}
\DoxyCodeLine{772 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))}           :: work\_2d}
\DoxyCodeLine{773 \textcolor{keywordtype}{  real}                                        :: Idt \textcolor{comment}{! The inverse of the timestep [T-\/1 \string~> s-\/1]}}
\DoxyCodeLine{774 \textcolor{keywordtype}{  real}                                        :: ppt2mks}
\DoxyCodeLine{775 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(GV\%ke)}                      :: h2}
\DoxyCodeLine{776 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge}
\DoxyCodeLine{777   \textcolor{keywordtype}{logical}                                     :: show\_call\_tree}
\DoxyCodeLine{778   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}                  :: Tr => null()}
\DoxyCodeLine{779 }
\DoxyCodeLine{780   show\_call\_tree = .false.}
\DoxyCodeLine{781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug}
\DoxyCodeLine{782   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"remap\_all\_state\_vars(), MOM\_ALE.F90"})}
\DoxyCodeLine{783 }
\DoxyCodeLine{784   \textcolor{comment}{! If remap\_uv\_using\_old\_alg is .true. and u or v is requested, then we must have dxInterface. Otherwise,}}
\DoxyCodeLine{785   \textcolor{comment}{! u and v can be remapped without dxInterface}}
\DoxyCodeLine{786   \textcolor{keywordflow}{if} ( .not. \textcolor{keyword}{present}(dxinterface) .and. (cs\_ale\%remap\_uv\_using\_old\_alg .and. (\textcolor{keyword}{present}(u) .or. \textcolor{keyword}{present}(v))) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{787     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"remap\_all\_state\_vars: dxInterface must be present if using old algorithm "}// \&}
\DoxyCodeLine{788                           \textcolor{stringliteral}{"and u/v are to be remapped"})}
\DoxyCodeLine{789 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{790 }
\DoxyCodeLine{791   \textcolor{keywordflow}{if} (.not.cs\_ale\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{792     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{793   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{794     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{795   \textcolor{keywordflow}{else}}
\DoxyCodeLine{796     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{797 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{798 }
\DoxyCodeLine{799   nz      = gv\%ke}
\DoxyCodeLine{800   ppt2mks = 0.001}
\DoxyCodeLine{801 }
\DoxyCodeLine{802   ntr = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) ntr = reg\%ntr}
\DoxyCodeLine{803 }
\DoxyCodeLine{804   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{805     idt = 1.0/dt}
\DoxyCodeLine{806     work\_conc(:,:,:) = 0.0}
\DoxyCodeLine{807     work\_cont(:,:,:) = 0.0}
\DoxyCodeLine{808 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{809 }
\DoxyCodeLine{810   \textcolor{comment}{! Remap tracer}}
\DoxyCodeLine{811   \textcolor{keywordflow}{if} (ntr>0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{812     \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"remapping tracers (remap\_all\_state\_vars)"})}
\DoxyCodeLine{813     \textcolor{comment}{!\$OMP parallel do default(shared) private(h1,h2,u\_column,Tr)}}
\DoxyCodeLine{814     \textcolor{keywordflow}{do} m=1,ntr \textcolor{comment}{! For each tracer}}
\DoxyCodeLine{815       tr => reg\%Tr(m)}
\DoxyCodeLine{816       \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec ; \textcolor{keywordflow}{if} (g\%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{817         \textcolor{comment}{! Build the start and final grids}}
\DoxyCodeLine{818         h1(:) = h\_old(i,j,:)}
\DoxyCodeLine{819         h2(:) = h\_new(i,j,:)}
\DoxyCodeLine{820         \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, tr\%t(i,j,:), nz, h2, \&}
\DoxyCodeLine{821                               u\_column, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{822 }
\DoxyCodeLine{823         \textcolor{comment}{! Intermediate steps for tendency of tracer concentration and tracer content.}}
\DoxyCodeLine{824         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{825           \textcolor{keywordflow}{if} (tr\%id\_remap\_conc > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{826             \textcolor{keywordflow}{do} k=1,gv\%ke}
\DoxyCodeLine{827               work\_conc(i,j,k) = (u\_column(k) -\/ tr\%t(i,j,k)) * idt}
\DoxyCodeLine{828 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{829 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{830           \textcolor{keywordflow}{if} (tr\%id\_remap\_cont > 0 .or. tr\%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{831             \textcolor{keywordflow}{do} k=1,gv\%ke}
\DoxyCodeLine{832               work\_cont(i,j,k) = (u\_column(k)*h2(k) -\/ tr\%t(i,j,k)*h1(k)) * idt}
\DoxyCodeLine{833 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{834 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{835 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{836         \textcolor{comment}{! update tracer concentration}}
\DoxyCodeLine{837         tr\%t(i,j,:) = u\_column(:)}
\DoxyCodeLine{838 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{839 }
\DoxyCodeLine{840       \textcolor{comment}{! tendency diagnostics.}}
\DoxyCodeLine{841       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{842         \textcolor{keywordflow}{if} (tr\%id\_remap\_conc > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{843           \textcolor{keyword}{call }post\_data(tr\%id\_remap\_conc, work\_conc, cs\_ale\%diag)}
\DoxyCodeLine{844 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{845         \textcolor{keywordflow}{if} (tr\%id\_remap\_cont > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{846           \textcolor{keyword}{call }post\_data(tr\%id\_remap\_cont, work\_cont, cs\_ale\%diag)}
\DoxyCodeLine{847 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{848         \textcolor{keywordflow}{if} (tr\%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{849           \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{850             work\_2d(i,j) = 0.0}
\DoxyCodeLine{851             \textcolor{keywordflow}{do} k = 1,gv\%ke}
\DoxyCodeLine{852               work\_2d(i,j) = work\_2d(i,j) + work\_cont(i,j,k)}
\DoxyCodeLine{853 \textcolor{keywordflow}{            enddo}}
\DoxyCodeLine{854 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{855           \textcolor{keyword}{call }post\_data(tr\%id\_remap\_cont\_2d, work\_2d, cs\_ale\%diag)}
\DoxyCodeLine{856 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{857 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{858 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! m=1,ntr}}
\DoxyCodeLine{859 }
\DoxyCodeLine{860 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! endif for ntr > 0}}
\DoxyCodeLine{861 }
\DoxyCodeLine{862   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"tracers remapped (remap\_all\_state\_vars)"})}
\DoxyCodeLine{863 }
\DoxyCodeLine{864   \textcolor{comment}{! Remap u velocity component}}
\DoxyCodeLine{865   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(u) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{866     \textcolor{comment}{!\$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}}
\DoxyCodeLine{867     \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%iscB,g\%iecB ; \textcolor{keywordflow}{if} (g\%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{868       \textcolor{comment}{! Build the start and final grids}}
\DoxyCodeLine{869       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i+1,j,:) )}
\DoxyCodeLine{870       \textcolor{keywordflow}{if} (cs\_ale\%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}}
\DoxyCodeLine{871         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i+1,j,:) )}
\DoxyCodeLine{872         \textcolor{keywordflow}{do} k = 1, nz}
\DoxyCodeLine{873           h2(k) = max( 0., h1(k) + ( dx(k+1) -\/ dx(k) ) )}
\DoxyCodeLine{874 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{875       \textcolor{keywordflow}{else}}
\DoxyCodeLine{876         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i+1,j,:) )}
\DoxyCodeLine{877 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{878       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{879         \textcolor{keywordflow}{if} (obc\%segnum\_u(i,j) .ne. 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{880           \textcolor{keywordflow}{if} (obc\%segment(obc\%segnum\_u(i,j))\%direction == obc\_direction\_e) \textcolor{keywordflow}{then}}
\DoxyCodeLine{881             h1(:) = h\_old(i,j,:)}
\DoxyCodeLine{882             h2(:) = h\_new(i,j,:)}
\DoxyCodeLine{883           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_W)}}
\DoxyCodeLine{884             h1(:) = h\_old(i+1,j,:)}
\DoxyCodeLine{885             h2(:) = h\_new(i+1,j,:)}
\DoxyCodeLine{886 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{887 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{888 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{889       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, u(i,j,:), nz, h2, \&}
\DoxyCodeLine{890                             u\_column, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{891       u(i,j,:) = u\_column(:)}
\DoxyCodeLine{892 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{893 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{894 }
\DoxyCodeLine{895   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"u remapped (remap\_all\_state\_vars)"})}
\DoxyCodeLine{896 }
\DoxyCodeLine{897   \textcolor{comment}{! Remap v velocity component}}
\DoxyCodeLine{898   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(v) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{899     \textcolor{comment}{!\$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}}
\DoxyCodeLine{900     \textcolor{keywordflow}{do} j = g\%jscB,g\%jecB ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec ; \textcolor{keywordflow}{if} (g\%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}}
\DoxyCodeLine{901       \textcolor{comment}{! Build the start and final grids}}
\DoxyCodeLine{902       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i,j+1,:) )}
\DoxyCodeLine{903       \textcolor{keywordflow}{if} (cs\_ale\%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}}
\DoxyCodeLine{904         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i,j+1,:) )}
\DoxyCodeLine{905         \textcolor{keywordflow}{do} k = 1, nz}
\DoxyCodeLine{906           h2(k) = max( 0., h1(k) + ( dx(k+1) -\/ dx(k) ) )}
\DoxyCodeLine{907 \textcolor{keywordflow}{        enddo}}
\DoxyCodeLine{908       \textcolor{keywordflow}{else}}
\DoxyCodeLine{909         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i,j+1,:) )}
\DoxyCodeLine{910 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{911       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{912         \textcolor{keywordflow}{if} (obc\%segnum\_v(i,j) .ne. 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{913           \textcolor{keywordflow}{if} (obc\%segment(obc\%segnum\_v(i,j))\%direction == obc\_direction\_n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{914             h1(:) = h\_old(i,j,:)}
\DoxyCodeLine{915             h2(:) = h\_new(i,j,:)}
\DoxyCodeLine{916           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC\%segment(n)\%direction == OBC\_DIRECTION\_S)}}
\DoxyCodeLine{917             h1(:) = h\_old(i,j+1,:)}
\DoxyCodeLine{918             h2(:) = h\_new(i,j+1,:)}
\DoxyCodeLine{919 \textcolor{keywordflow}{          endif}}
\DoxyCodeLine{920 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{921 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{922       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, v(i,j,:), nz, h2, \&}
\DoxyCodeLine{923                             u\_column, h\_neglect, h\_neglect\_edge)}
\DoxyCodeLine{924       v(i,j,:) = u\_column(:)}
\DoxyCodeLine{925 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{926 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{927 }
\DoxyCodeLine{928   \textcolor{keywordflow}{if} (cs\_ale\%id\_vert\_remap\_h > 0) \textcolor{keyword}{call }post\_data(cs\_ale\%id\_vert\_remap\_h, h\_old, cs\_ale\%diag)}
\DoxyCodeLine{929   \textcolor{keywordflow}{if} ((cs\_ale\%id\_vert\_remap\_h\_tendency > 0) .and. \textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{930     \textcolor{keywordflow}{do} k = 1, nz ; \textcolor{keywordflow}{do} j = g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i = g\%isc,g\%iec}
\DoxyCodeLine{931       work\_cont(i,j,k) = (h\_new(i,j,k) -\/ h\_old(i,j,k))*idt}
\DoxyCodeLine{932 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{933     \textcolor{keyword}{call }post\_data(cs\_ale\%id\_vert\_remap\_h\_tendency, work\_cont, cs\_ale\%diag)}
\DoxyCodeLine{934 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{935   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"v remapped (remap\_all\_state\_vars)"})}
\DoxyCodeLine{936   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"remap\_all\_state\_vars()"})}
\DoxyCodeLine{937 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_abedb087c760a6ac146735275638db58a}\label{namespacemom__ale_abedb087c760a6ac146735275638db58a}} 
\index{mom\_ale@{mom\_ale}!ts\_plm\_edge\_values@{ts\_plm\_edge\_values}}
\index{ts\_plm\_edge\_values@{ts\_plm\_edge\_values}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ts\_plm\_edge\_values()}{ts\_plm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ts\+\_\+plm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), intent(inout)}]{CS,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{S\+\_\+t,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{S\+\_\+b,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{T\+\_\+t,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{T\+\_\+b,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h,  }\item[{logical, intent(in)}]{bdry\+\_\+extrap }\end{DoxyParamCaption})}



Calculate edge values (top and bottom of layer) for T and S consistent with a P\+LM reconstruction in the vertical direction. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & module control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em s\+\_\+t} & Salinity at the top edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em s\+\_\+b} & Salinity at the bottom edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em t\+\_\+t} & Temperature at the top edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em t\+\_\+b} & Temperature at the bottom edge of each layer \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & thermodynamics structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em bdry\+\_\+extrap} & If true, use high-\/order boundary extrapolation within boundary cells \\
\hline
\end{DoxyParams}


Definition at line 1014 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1014   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}}
\DoxyCodeLine{1015   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}}
\DoxyCodeLine{1016   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< module control structure}}
\DoxyCodeLine{1017 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1018                            \textcolor{keywordtype}{intent(inout)} :: S\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}}
\DoxyCodeLine{1019 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1020                            \textcolor{keywordtype}{intent(inout)} :: S\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}}
\DoxyCodeLine{1021 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1022                            \textcolor{keywordtype}{intent(inout)} :: T\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}}
\DoxyCodeLine{1023 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1024                            \textcolor{keywordtype}{intent(inout)} :: T\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}}
\DoxyCodeLine{1025   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}}
\DoxyCodeLine{1026 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1027                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1028   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-\/order boundary}}
\DoxyCodeLine{1029 \textcolor{comment}{                                                 !! extrapolation within boundary cells}}
\DoxyCodeLine{1030 }
\DoxyCodeLine{1031   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv\%S, bdry\_extrap, s\_t, s\_b )}
\DoxyCodeLine{1032   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv\%T, bdry\_extrap, t\_t, t\_b )}
\DoxyCodeLine{1033 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}\label{namespacemom__ale_a1920c7b1be73d2bf7c5afc29b1b1245b}} 
\index{mom\_ale@{mom\_ale}!ts\_ppm\_edge\_values@{ts\_ppm\_edge\_values}}
\index{ts\_ppm\_edge\_values@{ts\_ppm\_edge\_values}!mom\_ale@{mom\_ale}}
\doxysubsubsection{\texorpdfstring{ts\_ppm\_edge\_values()}{ts\_ppm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ts\+\_\+ppm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}}), intent(inout)}]{CS,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{S\+\_\+t,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{S\+\_\+b,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{T\+\_\+t,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(inout)}]{T\+\_\+b,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{real, dimension(szi\+\_\+(g),szj\+\_\+(g),szk\+\_\+(gv)), intent(in)}]{h,  }\item[{logical, intent(in)}]{bdry\+\_\+extrap }\end{DoxyParamCaption})}



Calculate edge values (top and bottom of layer) for T and S consistent with a P\+PM reconstruction in the vertical direction. Boundary reconstructions are P\+CM unless bdry\+\_\+extrap is true. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & Ocean vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & module control structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em s\+\_\+t} & Salinity at the top edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em s\+\_\+b} & Salinity at the bottom edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em t\+\_\+t} & Temperature at the top edge of each layer \\
\hline
\mbox{\texttt{ in,out}}  & {\em t\+\_\+b} & Temperature at the bottom edge of each layer \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & thermodynamics structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em bdry\+\_\+extrap} & If true, use high-\/order boundary extrapolation within boundary cells \\
\hline
\end{DoxyParams}


Definition at line 1100 of file M\+O\+M\+\_\+\+A\+L\+E.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1100   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< ocean grid structure}}
\DoxyCodeLine{1101   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< Ocean vertical grid structure}}
\DoxyCodeLine{1102   \textcolor{keywordtype}{type}(ALE\_CS),            \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{   !< module control structure}}
\DoxyCodeLine{1103 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1104                            \textcolor{keywordtype}{intent(inout)} :: S\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}}
\DoxyCodeLine{1105 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1106                            \textcolor{keywordtype}{intent(inout)} :: S\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}}
\DoxyCodeLine{1107 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1108                            \textcolor{keywordtype}{intent(inout)} :: T\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}}
\DoxyCodeLine{1109 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1110                            \textcolor{keywordtype}{intent(inout)} :: T\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}}
\DoxyCodeLine{1111   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}}
\DoxyCodeLine{1112 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \&}
\DoxyCodeLine{1113                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1114   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-\/order boundary}}
\DoxyCodeLine{1115 \textcolor{comment}{                                                 !! extrapolation within boundary cells}}
\DoxyCodeLine{1116 }
\DoxyCodeLine{1117   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1118   \textcolor{keywordtype}{integer} :: i, j, k}
\DoxyCodeLine{1119 \textcolor{keywordtype}{  real}    :: hTmp(GV\%ke) \textcolor{comment}{! A 1-\/d copy of h [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1120 \textcolor{keywordtype}{  real}    :: tmp(GV\%ke)  \textcolor{comment}{! A 1-\/d copy of a column of temperature [degC] or salinity [ppt]}}
\DoxyCodeLine{1121 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(CS\%nk,2)} :: \&}
\DoxyCodeLine{1122       ppol\_E            \textcolor{comment}{! Edge value of polynomial in [degC] or [ppt]}}
\DoxyCodeLine{1123 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(CS\%nk,3)} :: \&}
\DoxyCodeLine{1124       ppol\_coefs        \textcolor{comment}{! Coefficients of polynomial, all in [degC] or [ppt]}}
\DoxyCodeLine{1125 \textcolor{keywordtype}{  real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Tiny thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{1126 }
\DoxyCodeLine{1127   \textcolor{keywordflow}{if} (.not.cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1128     h\_neglect = gv\%H\_subroundoff ; h\_neglect\_edge = gv\%H\_subroundoff}
\DoxyCodeLine{1129   \textcolor{keywordflow}{elseif} (gv\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1130     h\_neglect = gv\%m\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%m\_to\_H*1.0e-\/10}
\DoxyCodeLine{1131   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1132     h\_neglect = gv\%kg\_m2\_to\_H*1.0e-\/30 ; h\_neglect\_edge = gv\%kg\_m2\_to\_H*1.0e-\/10}
\DoxyCodeLine{1133 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1134 }
\DoxyCodeLine{1135   \textcolor{comment}{! Determine reconstruction within each column}}
\DoxyCodeLine{1136   \textcolor{comment}{!\$OMP parallel do default(shared) private(hTmp,tmp,ppol\_E,ppol\_coefs)}}
\DoxyCodeLine{1137   \textcolor{keywordflow}{do} j = g\%jsc-\/1,g\%jec+1 ; \textcolor{keywordflow}{do} i = g\%isc-\/1,g\%iec+1}
\DoxyCodeLine{1138 }
\DoxyCodeLine{1139     \textcolor{comment}{! Build current grid}}
\DoxyCodeLine{1140     htmp(:) = h(i,j,:)}
\DoxyCodeLine{1141     tmp(:) = tv\%S(i,j,:)}
\DoxyCodeLine{1142 }
\DoxyCodeLine{1143     \textcolor{comment}{! Reconstruct salinity profile}}
\DoxyCodeLine{1144     ppol\_e(:,:) = 0.0}
\DoxyCodeLine{1145     ppol\_coefs(:,:) = 0.0}
\DoxyCodeLine{1146     \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv\%ke, htmp, tmp, ppol\_e, h\_neglect=h\_neglect\_edge, \&}
\DoxyCodeLine{1147                                   answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{1148     \textcolor{keyword}{call }ppm\_reconstruction( gv\%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, \&}
\DoxyCodeLine{1149                                   answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{1150     \textcolor{keywordflow}{if} (bdry\_extrap) \&}
\DoxyCodeLine{1151       \textcolor{keyword}{call }ppm\_boundary\_extrapolation( gv\%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )}
\DoxyCodeLine{1152 }
\DoxyCodeLine{1153     \textcolor{keywordflow}{do} k = 1,gv\%ke}
\DoxyCodeLine{1154       s\_t(i,j,k) = ppol\_e(k,1)}
\DoxyCodeLine{1155       s\_b(i,j,k) = ppol\_e(k,2)}
\DoxyCodeLine{1156 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1157 }
\DoxyCodeLine{1158     \textcolor{comment}{! Reconstruct temperature profile}}
\DoxyCodeLine{1159     ppol\_e(:,:) = 0.0}
\DoxyCodeLine{1160     ppol\_coefs(:,:) = 0.0}
\DoxyCodeLine{1161     tmp(:) = tv\%T(i,j,:)}
\DoxyCodeLine{1162     \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1163       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv\%ke, htmp, tmp, ppol\_e, h\_neglect=1.0e-\/10*gv\%m\_to\_H, \&}
\DoxyCodeLine{1164                                   answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{1165     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1166       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv\%ke, htmp, tmp, ppol\_e, h\_neglect=gv\%H\_subroundoff, \&}
\DoxyCodeLine{1167                                   answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{1168 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1169     \textcolor{keyword}{call }ppm\_reconstruction( gv\%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, \&}
\DoxyCodeLine{1170                                   answers\_2018=cs\%answers\_2018 )}
\DoxyCodeLine{1171     \textcolor{keywordflow}{if} (bdry\_extrap) \&}
\DoxyCodeLine{1172       \textcolor{keyword}{call }ppm\_boundary\_extrapolation(gv\%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )}
\DoxyCodeLine{1173 }
\DoxyCodeLine{1174     \textcolor{keywordflow}{do} k = 1,gv\%ke}
\DoxyCodeLine{1175       t\_t(i,j,k) = ppol\_e(k,1)}
\DoxyCodeLine{1176       t\_b(i,j,k) = ppol\_e(k,2)}
\DoxyCodeLine{1177 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{1178 }
\DoxyCodeLine{1179 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1180 }

\end{DoxyCode}
