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


\subsection{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 \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}
\begin{DoxyCompactList}\small\item\em A\+LE control structure. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \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 \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 \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 \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 \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 \hyperlink{MOM_8F90_source}{M\+O\+M.\+F90}) after the main time integration loop to deallocate the regridding stuff. \end{DoxyCompactList}\item 
subroutine, public \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \hyperlink{namespacemom__ale_a8c448db5dde525b0571809132bf5e075}{ale\+\_\+getcoordinateunits} (CS)
\begin{DoxyCompactList}\small\item\em Query the target coordinate units. \end{DoxyCompactList}\item 
logical function, public \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 \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 \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 \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 \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}


\subsection{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}}
\subsubsection{\texorpdfstring{adjustgridforintegrity()}{adjustgridforintegrity()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::adjustgridforintegrity (\begin{DoxyParamCaption}\item[{type(\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 \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{\tt in}  & {\em g} & Ocean grid informations\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt 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}
293   \textcolor{keywordtype}{type}(ale\_cs),                              \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
294   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
295   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
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}
297 \textcolor{comment}{                                                                  !! are to be adjusted [H ~> m or kg-2]}
298   \textcolor{keyword}{call }inflate\_vanished\_layers\_old( cs%regridCS, g, gv, h(:,:,:) )
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}}
\subsubsection{\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{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em regridcs} & Regridding parameters and options\\
\hline
\mbox{\tt in}  & {\em remapcs} & Remapping parameters and options\\
\hline
\mbox{\tt in,out}  & {\em tv} & Thermodynamical variable structure\\
\hline
\mbox{\tt in,out}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt 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}
616   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{        !< Ocean grid structure}
617   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{       !< Ocean vertical grid structure}
618   \textcolor{keywordtype}{type}(regridding\_cs),                     \textcolor{keywordtype}{intent(in)}    :: regridcs\textcolor{comment}{ !< Regridding parameters and options}
619   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: remapcs\textcolor{comment}{  !< Remapping parameters and options}
620   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{       !< Thermodynamical variable structure}
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}
622 \textcolor{comment}{                                                                     !! last time step [H ~> m or kg-2]}
623   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{    !< If true, show the call tree}
624   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf coverage}
625   \textcolor{comment}{! Local variables}
626   \textcolor{keywordtype}{integer} :: nk, i, j, k
627   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
628   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: h\_new \textcolor{comment}{! The new grid thicknesses}
629   \textcolor{keywordtype}{logical} :: show\_call\_tree, use\_ice\_shelf
630 
631   show\_call\_tree = .false.
632   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
633   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_build\_grid(), MOM\_ALE.F90"})
634   use\_ice\_shelf = .false.
635   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
636     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) use\_ice\_shelf = .true.
637 \textcolor{keywordflow}{  endif}
638 
639   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
640   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
641   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
642      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h )
643   \textcolor{keywordflow}{else}
644      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid )
645 \textcolor{keywordflow}{  endif}
646 
647   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
648   \textcolor{comment}{! one of the 'build\_...' routines above.}
649 \textcolor{comment}{!$OMP parallel do default(none) shared(G,h,h\_new)}
650   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
651     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) h(i,j,:) = h\_new(i,j,:)
652 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
653 
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}}
\subsubsection{\texorpdfstring{ale\+\_\+end()}{ale\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+end (\begin{DoxyParamCaption}\item[{type(\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 \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}
307   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{  !< module control structure}
308 
309   \textcolor{comment}{! Deallocate memory used for the regridding}
310   \textcolor{keyword}{call }end\_remapping( cs%remapCS )
311   \textcolor{keyword}{call }end\_regridding( cs%regridCS )
312 
313   \textcolor{keyword}{deallocate}(cs)
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}}
\subsubsection{\texorpdfstring{ale\+\_\+getcoordinate()}{ale\_getcoordinate()}}
{\footnotesize\ttfamily real function, dimension(cs\%nk+1), public mom\+\_\+ale\+::ale\+\_\+getcoordinate (\begin{DoxyParamCaption}\item[{type(\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}
1207   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{                  !< module control structure}
1208 
1209   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk+1)} :: ale\_getcoordinate
1210   ale\_getcoordinate(:) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
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}}
\subsubsection{\texorpdfstring{ale\+\_\+getcoordinateunits()}{ale\_getcoordinateunits()}}
{\footnotesize\ttfamily character(len=20) function, public mom\+\_\+ale\+::ale\+\_\+getcoordinateunits (\begin{DoxyParamCaption}\item[{type(\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}
1217   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< module control structure}
1218 
1219   \textcolor{keywordtype}{character(len=20)}     :: ale\_getcoordinateunits
1220 
1221   ale\_getcoordinateunits = getcoordinateunits( cs%regridCS )
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}}
\subsubsection{\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(\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This routine is typically called (from initialize\+\_\+\+M\+OM in file \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{\tt in}  & {\em param\+\_\+file} & Parameter file\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt 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}
140   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file}
141   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{         !< Ocean vertical grid structure}
142   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{         !< A dimensional unit scaling type}
143   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
144   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{         !< Module control structure}
145 
146   \textcolor{comment}{! Local variables}
147   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: dz
148   \textcolor{keywordtype}{character(len=40)}               :: mdl = \textcolor{stringliteral}{"MOM\_ALE"} \textcolor{comment}{! This module's name.}
149   \textcolor{keywordtype}{character(len=80)}               :: string \textcolor{comment}{! Temporary strings}
150   \textcolor{keywordtype}{real}                            :: filter\_shallow\_depth, filter\_deep\_depth
151   \textcolor{keywordtype}{logical}       :: default\_2018\_answers
152   \textcolor{keywordtype}{logical}                         :: check\_reconstruction
153   \textcolor{keywordtype}{logical}                         :: check\_remapping
154   \textcolor{keywordtype}{logical}                         :: force\_bounds\_in\_subcell
155   \textcolor{keywordtype}{logical}                         :: local\_logical
156   \textcolor{keywordtype}{logical}                         :: remap\_boundary\_extrap
157 
158   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
159     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ALE\_init called with an associated "}// &
160                             \textcolor{stringliteral}{"control structure."})
161     \textcolor{keywordflow}{return}
162 \textcolor{keywordflow}{  endif}
163   \textcolor{keyword}{allocate}(cs)
164 
165   cs%show\_call\_tree = calltree\_showquery()
166   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_init(), MOM\_ALE.F90"})
167 
168   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_UV\_USING\_OLD\_ALG"}, cs%remap\_uv\_using\_old\_alg, &
169                  \textcolor{stringliteral}{"If true, uses the old remapping-via-a-delta-z method for "}//&
170                  \textcolor{stringliteral}{"remapping u and v. If false, uses the new method that remaps "}//&
171                  \textcolor{stringliteral}{"between grids described by an old and new thickness."}, &
172                  default=.false.)
173 
174   \textcolor{comment}{! Initialize and configure regridding}
175   \textcolor{keyword}{call }ale\_initregridding(gv, us, max\_depth, param\_file, mdl, cs%regridCS)
176 
177   \textcolor{comment}{! Initialize and configure remapping}
178   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, string, &
179                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//&
180                  \textcolor{stringliteral}{"for vertical remapping for all variables. "}//&
181                  \textcolor{stringliteral}{"It can be one of the following schemes: "}//&
182                  trim(remappingschemesdoc), default=remappingdefaultscheme)
183   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_RECONSTRUCTIONS"}, check\_reconstruction, &
184                  \textcolor{stringliteral}{"If true, cell-by-cell reconstructions are checked for "}//&
185                  \textcolor{stringliteral}{"consistency and if non-monotonicity or an inconsistency is "}//&
186                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
187   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_REMAPPING"}, check\_remapping, &
188                  \textcolor{stringliteral}{"If true, the results of remapping are checked for "}//&
189                  \textcolor{stringliteral}{"conservation and new extrema and if an inconsistency is "}//&
190                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUND\_INTERMEDIATE\_VALUES"}, force\_bounds\_in\_subcell, &
192                  \textcolor{stringliteral}{"If true, the values on the intermediate grid used for remapping "}//&
193                  \textcolor{stringliteral}{"are forced to be bounded, which might not be the case due to "}//&
194                  \textcolor{stringliteral}{"round off."}, default=.false.)
195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUNDARY\_EXTRAP"}, remap\_boundary\_extrap, &
196                  \textcolor{stringliteral}{"If true, values at the interfaces of boundary cells are "}//&
197                  \textcolor{stringliteral}{"extrapolated instead of piecewise constant"}, default=.false.)
198   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
199                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
200                  default=.false.)
201   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs%answers\_2018, &
202                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
203                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
204                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
205   \textcolor{keyword}{call }initialize\_remapping( cs%remapCS, string, &
206                              boundary\_extrapolation=remap\_boundary\_extrap, &
207                              check\_reconstruction=check\_reconstruction, &
208                              check\_remapping=check\_remapping, &
209                              force\_bounds\_in\_subcell=force\_bounds\_in\_subcell, &
210                              answers\_2018=cs%answers\_2018)
211 
212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_AFTER\_INITIALIZATION"}, cs%remap\_after\_initialization, &
213                  \textcolor{stringliteral}{"If true, applies regridding and remapping immediately after "}//&
214                  \textcolor{stringliteral}{"initialization so that the state is ALE consistent. This is a "}//&
215                  \textcolor{stringliteral}{"legacy step and should not be needed if the initialization is "}//&
216                  \textcolor{stringliteral}{"consistent with the coordinate mode."}, default=.true.)
217 
218   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_TIME\_SCALE"}, cs%regrid\_time\_scale, &
219                  \textcolor{stringliteral}{"The time-scale used in blending between the current (old) grid "}//&
220                  \textcolor{stringliteral}{"and the target (new) grid. A short time-scale favors the target "}//&
221                  \textcolor{stringliteral}{"grid (0. or anything less than DT\_THERM) has no memory of the old "}//&
222                  \textcolor{stringliteral}{"grid. A very long time-scale makes the model more Lagrangian."}, &
223                  units=\textcolor{stringliteral}{"s"}, default=0., scale=us%s\_to\_T)
224   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH"}, filter\_shallow\_depth, &
225                  \textcolor{stringliteral}{"The depth above which no time-filtering is applied. Above this depth "}//&
226                  \textcolor{stringliteral}{"final grid exactly matches the target (new) grid."}, &
227                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
228   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_DEEP\_DEPTH"}, filter\_deep\_depth, &
229                  \textcolor{stringliteral}{"The depth below which full time-filtering is applied with time-scale "}//&
230                  \textcolor{stringliteral}{"REGRID\_TIME\_SCALE. Between depths REGRID\_FILTER\_SHALLOW\_DEPTH and "}//&
231                  \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH the filter weights adopt a cubic profile."}, &
232                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
233   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, depth\_of\_time\_filter\_shallow=filter\_shallow\_depth, &
234                          depth\_of\_time\_filter\_deep=filter\_deep\_depth)
235   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_USE\_OLD\_DIRECTION"}, local\_logical, &
236                  \textcolor{stringliteral}{"If true, the regridding ntegrates upwards from the bottom for "}//&
237                  \textcolor{stringliteral}{"interface positions, much as the main model does. If false "}//&
238                  \textcolor{stringliteral}{"regridding integrates downward, consistant with the remapping "}//&
239                  \textcolor{stringliteral}{"code."}, default=.true., do\_not\_log=.true.)
240   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, integrate\_downward\_for\_e=.not.local\_logical)
241 
242   \textcolor{comment}{! Keep a record of values for subsequent queries}
243   cs%nk = gv%ke
244 
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}}
\subsubsection{\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{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em max\+\_\+depth} & The maximum depth of the ocean \mbox{[}Z $\sim$$>$ m\mbox{]}.\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & parameter file\\
\hline
\mbox{\tt in}  & {\em mdl} & Name of calling module\\
\hline
\mbox{\tt 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}
1186   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{         !< Ocean vertical grid structure}
1187   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{         !< A dimensional unit scaling type}
1188   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
1189   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< parameter file}
1190   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: mdl\textcolor{comment}{        !< Name of calling module}
1191   \textcolor{keywordtype}{type}(regridding\_cs),     \textcolor{keywordtype}{intent(out)} :: regridcs\textcolor{comment}{   !< Regridding parameters and work arrays}
1192   \textcolor{comment}{! Local variables}
1193   \textcolor{keywordtype}{character(len=30)} :: coord\_mode
1194 
1195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"}, coord\_mode, &
1196                  \textcolor{stringliteral}{"Coordinate mode for vertical regridding. "}//&
1197                  \textcolor{stringliteral}{"Choose among the following possibilities: "}//&
1198                  trim(regriddingcoordinatemodedoc), &
1199                  default=default\_coordinate\_mode, fail\_if\_missing=.true.)
1200 
1201   \textcolor{keyword}{call }initialize\_regridding(regridcs, gv, us, max\_depth, param\_file, mdl, coord\_mode, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''})
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}}
\subsubsection{\texorpdfstring{ale\+\_\+initthicknesstocoord()}{ale\_initthicknesstocoord()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+initthicknesstocoord (\begin{DoxyParamCaption}\item[{type(\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{\tt in,out}  & {\em cs} & module control structure\\
\hline
\mbox{\tt in}  & {\em g} & module grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt 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}
1306   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{intent(inout)}                            :: cs\textcolor{comment}{  !< module control structure}
1307   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}                      :: g\textcolor{comment}{   !< module grid structure}
1308   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}                    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
1309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(out)} :: h\textcolor{comment}{   !< layer thickness [H ~> m or kg m-2]}
1310 
1311   \textcolor{comment}{! Local variables}
1312   \textcolor{keywordtype}{integer} :: i, j, k
1313 
1314   \textcolor{keywordflow}{do} j = g%jsd,g%jed ; \textcolor{keywordflow}{do} i = g%isd,g%ied
1315     h(i,j,:) = gv%Z\_to\_H * getstaticthickness( cs%regridCS, 0., g%bathyT(i,j) )
1316 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
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}}
\subsubsection{\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(\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{\tt in}  & {\em g} & Ocean grid informations\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in,out}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em u} & Zonal velocity field \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v} & Meridional velocity field \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt 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{\tt 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}
322   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
323   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
324   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{  !< A dimensional unit scaling type}
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}
326 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg m-2]}
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 ~> m s-1]}
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 ~> m
       s-1]}
329   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
330   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
331   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
332   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
333   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
334   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf
       coverage}
335   \textcolor{comment}{! Local variables}
336   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
337   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: eta\_preale
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 ~> m or
       kg-2]}
339   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
340   \textcolor{keywordtype}{logical} :: ice\_shelf
341 
342   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
343 
344   ice\_shelf = .false.
345   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) ice\_shelf = .true.
347 \textcolor{keywordflow}{  endif}
348 
349   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main(), MOM\_ALE.F90"})
350 
351   \textcolor{comment}{! These diagnostics of the state before ALE is applied are mostly used for debugging.}
352   \textcolor{keywordflow}{if} (cs%id\_u\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_preale, u,    cs%diag)
353   \textcolor{keywordflow}{if} (cs%id\_v\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_preale, v,    cs%diag)
354   \textcolor{keywordflow}{if} (cs%id\_h\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_preale, h,    cs%diag)
355   \textcolor{keywordflow}{if} (cs%id\_T\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_T\_preale, tv%T, cs%diag)
356   \textcolor{keywordflow}{if} (cs%id\_S\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_S\_preale, tv%S, cs%diag)
357   \textcolor{keywordflow}{if} (cs%id\_e\_preale > 0) \textcolor{keywordflow}{then}
358     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, eta\_preale)
359     \textcolor{keyword}{call }post\_data(cs%id\_e\_preale, eta\_preale, cs%diag)
360 \textcolor{keywordflow}{  endif}
361 
362   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
363     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )
364 \textcolor{keywordflow}{  endif}
365   dzregrid(:,:,:) = 0.0
366 
367   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
368   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
369   \textcolor{keywordflow}{if} (ice\_shelf) \textcolor{keywordflow}{then}
370      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h)
371   \textcolor{keywordflow}{else}
372      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid)
373 \textcolor{keywordflow}{  endif}
374 
375   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )
376 
377   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
378 
379   \textcolor{comment}{! The presence of dt is used for expediency to distinguish whether ALE\_main is being called during init}
380   \textcolor{comment}{! or in the main loop. Tendency diagnostics in remap\_all\_state\_vars also rely on this logic.}
381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
382     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
383 \textcolor{keywordflow}{  endif}
384   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
385   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, -dzregrid, &
386                              u, v, cs%show\_call\_tree, dt )
387 
388   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
389 
390   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
391   \textcolor{comment}{! one of the 'build\_...' routines above.}
392   \textcolor{comment}{!$OMP parallel do default(shared)}
393   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
394     h(i,j,k) = h\_new(i,j,k)
395 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
396 
397   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
398 
399   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
400 
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}}
\subsubsection{\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(\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{\tt in}  & {\em g} & Ocean grid informations\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt 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{\tt 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}
409   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
410   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
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}
412 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
413   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
414   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
415   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
416   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
417   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
418   \textcolor{comment}{! Local variables}
419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
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 ~> m or
       kg-2]}
421   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
422 
423   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
424 
425   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main\_offline(), MOM\_ALE.F90"})
426 
427   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
428     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )
429 \textcolor{keywordflow}{  endif}
430   dzregrid(:,:,:) = 0.0
431 
432   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
433   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
434   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid )
435 
436   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )
437 
438   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
439 
440   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
441 
442   \textcolor{keyword}{call }remap\_all\_state\_vars(cs%remapCS, cs, g, gv, h, h\_new, reg, obc, &
443                             debug=cs%show\_call\_tree, dt=dt )
444 
445   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
446 
447   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
448   \textcolor{comment}{! one of the 'build\_...' routines above.}
449   \textcolor{comment}{!$OMP parallel do default(shared)}
450   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
451     h(i,j,k) = h\_new(i,j,k)
452 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
453 
454   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
455   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
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}}
\subsubsection{\texorpdfstring{ale\+\_\+offline\+\_\+inputs()}{ale\_offline\_inputs()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+offline\+\_\+inputs (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em g} & Ocean grid informations\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em h} & Layer thicknesses\\
\hline
\mbox{\tt in,out}  & {\em tv} & Thermodynamic variable structure\\
\hline
 & {\em reg} & Tracer registry structure\\
\hline
\mbox{\tt in,out}  & {\em uhtr} & Zonal mass fluxes\\
\hline
\mbox{\tt in,out}  & {\em vhtr} & Meridional mass fluxes\\
\hline
\mbox{\tt in,out}  & {\em kd} & Input diffusivites\\
\hline
\mbox{\tt 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}
463   \textcolor{keywordtype}{type}(ale\_cs),                                 \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{    !< Regridding parameters and options}
464   \textcolor{keywordtype}{type}(ocean\_grid\_type),                        \textcolor{keywordtype}{intent(in   )} :: g\textcolor{comment}{     !< Ocean grid informations}
465   \textcolor{keywordtype}{type}(verticalgrid\_type),                      \textcolor{keywordtype}{intent(in   )} :: gv\textcolor{comment}{    !< Ocean vertical grid structure}
466   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},    \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Layer thicknesses}
467   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                        \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{    !< Thermodynamic variable structure}
468   \textcolor{keywordtype}{type}(tracer\_registry\_type),                   \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{   !< Tracer registry structure}
469   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{  !< Zonal mass fluxes}
470   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{  !< Meridional mass fluxes}
471   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)},  \textcolor{keywordtype}{intent(inout)} :: kd\textcolor{comment}{    !< Input diffusivites}
472   \textcolor{keywordtype}{logical},                                      \textcolor{keywordtype}{intent(in   )} :: debug\textcolor{comment}{ !< If true, then turn checksums}
473   \textcolor{keywordtype}{type}(ocean\_obc\_type),                         \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{   !< Open boundary structure}
474   \textcolor{comment}{! Local variables}
475   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
476   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new    \textcolor{comment}{! Layer thicknesses after regridding}
477   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
478   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_src
479   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_dest, uh\_dest
480   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: temp\_vec
481 
482   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
483   dzregrid(:,:,:) = 0.0
484   h\_new(:,:,:) = 0.0
485 
486   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"Before ALE\_offline\_inputs"}, g, h, reg%Tr, reg%ntr)
487 
488   \textcolor{comment}{! Build new grid from the Zstar state onto the requested vertical coordinate. The new grid is stored}
489   \textcolor{comment}{! in h\_new. The old grid is h. Both are needed for the subsequent remapping of variables. Convective}
490   \textcolor{comment}{! adjustment right now is not used because it is unclear what to do with vanished layers}
491   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, conv\_adjust = .false. )
492   \textcolor{keyword}{call }check\_grid( g, gv, h\_new, 0. )
493   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_offline\_inputs)"})
494 
495   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
496   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs%show\_call\_tree )
497   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_inputs)"})
498 
499   \textcolor{comment}{! Reintegrate mass transports from Zstar to the offline vertical coordinate}
500   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=g%iscB,g%iecB
501     \textcolor{keywordflow}{if} (g%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}
502       h\_src(:) = 0.5 * (h(i,j,:) + h(i+1,j,:))
503       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i+1,j,:))
504       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, uhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
505       uhtr(i,j,:) = temp\_vec
506 \textcolor{keywordflow}{    endif}
507 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
508   \textcolor{keywordflow}{do} j=g%jscB,g%jecB ; \textcolor{keywordflow}{do} i=isc,iec
509     \textcolor{keywordflow}{if} (g%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}
510       h\_src(:) = 0.5 * (h(i,j,:) + h(i,j+1,:))
511       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i,j+1,:))
512       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, vhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
513       vhtr(i,j,:) = temp\_vec
514 \textcolor{keywordflow}{    endif}
515 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
516 
517   \textcolor{keywordflow}{do} j = jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
518     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
519       \textcolor{keywordflow}{if} (check\_column\_integrals(nk, h\_src, nk, h\_dest)) \textcolor{keywordflow}{then}
520         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ALE\_offline\_inputs: Kd interpolation columns do not match"})
521 \textcolor{keywordflow}{      endif}
522       \textcolor{keyword}{call }interpolate\_column(nk, h(i,j,:), kd(i,j,:), nk, h\_new(i,j,:), 0., kd(i,j,:))
523 \textcolor{keywordflow}{    endif}
524 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
525 
526   \textcolor{keyword}{call }ale\_remap\_scalar(cs%remapCS, g, gv, nk, h, tv%T, h\_new, tv%T, answers\_2018=cs%answers\_2018)
527   \textcolor{keyword}{call }ale\_remap\_scalar(cs%remapCS, g, gv, nk, h, tv%S, h\_new, tv%S, answers\_2018=cs%answers\_2018)
528 
529   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"After ALE\_offline\_inputs"}, g, h\_new, reg%Tr, reg%ntr)
530 
531   \textcolor{comment}{! Copy over the new layer thicknesses}
532   \textcolor{keywordflow}{do} k = 1,nk  ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
533       h(i,j,k) = h\_new(i,j,k)
534 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
535 
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}}
\subsubsection{\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(\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{\tt in}  & {\em g} & Ocean grid informations\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em tv} & Thermodynamic variable structure\\
\hline
\mbox{\tt 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}
544   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
545   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
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}
547 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
548   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
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}
550 \textcolor{comment}{                                                                        !! last time step  [H ~> m or kg-2]}
551   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
552   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
553   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
554   \textcolor{comment}{! Local variables}
555 
556   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid\textcolor{comment}{ !< The change in grid interface positions}
557   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new\textcolor{comment}{    !< Regridded target thicknesses}
558   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
559 
560   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
561 
562   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final(), MOM\_ALE.F90"})
563   \textcolor{comment}{! Need to make sure that h\_target is consistent with the current offline ALE confiuration}
564   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h\_target, tv, h\_new, dzregrid )
565   \textcolor{keyword}{call }check\_grid( g, gv, h\_target, 0. )
566 
567 
568   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Source and target grids checked
       (ALE\_offline\_tracer\_final)"})
569 
570   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
571 
572   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs%show\_call\_tree )
573 
574   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_offline\_tracer\_final)"})
575 
576   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
577   \textcolor{comment}{! one of the 'build\_...' routines above.}
578   \textcolor{comment}{!$OMP parallel do default(shared)}
579   \textcolor{keywordflow}{do} k = 1,nk
580     \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
581       h(i,j,k) = h\_new(i,j,k)
582 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
583 \textcolor{keywordflow}{  enddo}
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}}
\subsubsection{\texorpdfstring{ale\+\_\+plm\+\_\+edge\+\_\+values()}{ale\_plm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+plm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em cs} & module control structure\\
\hline
\mbox{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em q} & 3d scalar array\\
\hline
\mbox{\tt in}  & {\em bdry\+\_\+extrap} & If true, use high-\/order boundary extrapolation within boundary cells\\
\hline
\mbox{\tt in,out}  & {\em q\+\_\+t} & Scalar at the top edge of each layer\\
\hline
\mbox{\tt 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}
1039   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{   !< module control structure}
1040   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
1041   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
1042   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1043                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
1044   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1045                            \textcolor{keywordtype}{intent(in)}    :: q\textcolor{comment}{    !< 3d scalar array}
1046   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
1047 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
1048   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1049                            \textcolor{keywordtype}{intent(inout)} :: q\_t\textcolor{comment}{  !< Scalar at the top edge of each layer}
1050   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1051                            \textcolor{keywordtype}{intent(inout)} :: q\_b\textcolor{comment}{  !< Scalar at the bottom edge of each layer}
1052   \textcolor{comment}{! Local variables}
1053   \textcolor{keywordtype}{integer} :: i, j, k
1054   \textcolor{keywordtype}{real} :: slp(gv%ke)
1055   \textcolor{keywordtype}{real} :: mslp
1056   \textcolor{keywordtype}{real} :: h\_neglect
1057 
1058   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
1059     h\_neglect = gv%H\_subroundoff
1060   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
1061     h\_neglect = gv%m\_to\_H*1.0e-30
1062   \textcolor{keywordflow}{else}
1063     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30
1064 \textcolor{keywordflow}{  endif}
1065 
1066   \textcolor{comment}{!$OMP parallel do default(shared) private(slp,mslp)}
1067   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
1068     slp(1) = 0.
1069     \textcolor{keywordflow}{do} k = 2, gv%ke-1
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))
1071 \textcolor{keywordflow}{    enddo}
1072     slp(gv%ke) = 0.
1073 
1074     \textcolor{keywordflow}{do} k = 2, gv%ke-1
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))
1076       q\_t(i,j,k) = q(i,j,k) - 0.5 * mslp
1077       q\_b(i,j,k) = q(i,j,k) + 0.5 * mslp
1078 \textcolor{keywordflow}{    enddo}
1079     \textcolor{keywordflow}{if} (bdry\_extrap) \textcolor{keywordflow}{then}
1080       mslp = - plm\_extrapolate\_slope(h(i,j,2), h(i,j,1), h\_neglect, q(i,j,2), q(i,j,1))
1081       q\_t(i,j,1) = q(i,j,1) - 0.5 * mslp
1082       q\_b(i,j,1) = q(i,j,1) + 0.5 * mslp
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))
1084       q\_t(i,j,gv%ke) = q(i,j,gv%ke) - 0.5 * mslp
1085       q\_b(i,j,gv%ke) = q(i,j,gv%ke) + 0.5 * mslp
1086     \textcolor{keywordflow}{else}
1087       q\_t(i,j,1) = q(i,j,1)
1088       q\_b(i,j,1) = q(i,j,1)
1089       q\_t(i,j,gv%ke) = q(i,j,gv%ke)
1090       q\_b(i,j,gv%ke) = q(i,j,gv%ke)
1091 \textcolor{keywordflow}{    endif}
1092 
1093 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
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}}
\subsubsection{\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(\hyperlink{structmom__ale_1_1ale__cs}{ale\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



Initialize diagnostics for the A\+LE module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt in}  & {\em time} & Time structure\\
\hline
\mbox{\tt in}  & {\em g} & Grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt 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}
250   \textcolor{keywordtype}{type}(time\_type),\textcolor{keywordtype}{target},     \textcolor{keywordtype}{intent(in)}  :: time\textcolor{comment}{  !< Time structure}
251   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{     !< Grid structure}
252   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{    !< A dimensional unit scaling type}
253   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{    !< Ocean vertical grid structure}
254   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\textcolor{comment}{  !< Diagnostics control structure}
255   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}                   :: cs\textcolor{comment}{    !< Module control structure}
256 
257   cs%diag => diag
258 
259   \textcolor{comment}{! These diagnostics of the state variables before ALE are useful for}
260   \textcolor{comment}{! debugging the ALE code.}
261   cs%id\_u\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_preale'}, diag%axesCuL, time, &
262       \textcolor{stringliteral}{'Zonal velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
263   cs%id\_v\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_preale'}, diag%axesCvL, time, &
264       \textcolor{stringliteral}{'Meridional velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
265   cs%id\_h\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_preale'}, diag%axesTL, time, &
266       \textcolor{stringliteral}{'Layer Thickness before remapping'}, get\_thickness\_units(gv), &
267       conversion=gv%H\_to\_MKS, v\_extensive=.true.)
268   cs%id\_T\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'T\_preale'}, diag%axesTL, time, &
269       \textcolor{stringliteral}{'Temperature before remapping'}, \textcolor{stringliteral}{'degC'})
270   cs%id\_S\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'S\_preale'}, diag%axesTL, time, &
271       \textcolor{stringliteral}{'Salinity before remapping'}, \textcolor{stringliteral}{'PSU'})
272   cs%id\_e\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_preale'}, diag%axesTi, time, &
273       \textcolor{stringliteral}{'Interface Heights before remapping'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
274 
275   cs%id\_dzRegrid = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dzRegrid'},diag%axesTi,time, &
276       \textcolor{stringliteral}{'Change in interface height due to ALE regridding'}, \textcolor{stringliteral}{'m'}, &
277       conversion=gv%H\_to\_m)
278   cs%id\_vert\_remap\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vert\_remap\_h'}, &
279       diag%axestl, time, \textcolor{stringliteral}{'layer thicknesses after ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
280       conversion=gv%H\_to\_m, v\_extensive=.true.)
281   cs%id\_vert\_remap\_h\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'vert\_remap\_h\_tendency'},diag%axestl,time,
       &
282       \textcolor{stringliteral}{'Layer thicknesses tendency due to ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
283       conversion=gv%H\_to\_m*us%s\_to\_T, v\_extensive = .true.)
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}}
\subsubsection{\texorpdfstring{ale\+\_\+regrid\+\_\+accelerated()}{ale\_regrid\_accelerated()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+regrid\+\_\+accelerated (\begin{DoxyParamCaption}\item[{type(\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{\tt in,out}  & {\em g} & Ocean grid\\
\hline
\mbox{\tt in}  & {\em gv} & Vertical grid\\
\hline
\mbox{\tt in,out}  & {\em h} & Original thicknesses \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em tv} & Thermo vars (T/\+S/\+E\+OS)\\
\hline
\mbox{\tt in}  & {\em n} & Number of times to regrid\\
\hline
\mbox{\tt in,out}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt 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{\tt in}  & {\em dt} & Model timestep to provide a timescale for regridding \mbox{[}T $\sim$$>$ s\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em dzregrid} & Final change in interface positions\\
\hline
\mbox{\tt 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}
660   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< ALE control structure}
661   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< Ocean grid}
662   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< Vertical grid}
663   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
664                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{      !< Original thicknesses [H ~> m or kg-2]}
665   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< Thermo vars (T/S/EOS)}
666   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)}    :: n\textcolor{comment}{      !< Number of times to regrid}
667   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
668                            \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
669   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
670                            \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m s-1]}
671   \textcolor{keywordtype}{type}(ocean\_obc\_type),    \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{    !< Open boundary structure}
672   \textcolor{keywordtype}{type}(tracer\_registry\_type), &
673                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{    !< Tracer registry to remap onto new grid}
674   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Model timestep to provide a timescale for regridding
       [T ~> s]}
675   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
676                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: dzregrid\textcolor{comment}{ !< Final change in interface positions}
677   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: initial\textcolor{comment}{ !< Whether we're being called from an initialization}
678 \textcolor{comment}{                                                    !! routine (and expect diagnostics to work)}
679 
680   \textcolor{comment}{! Local variables}
681   \textcolor{keywordtype}{integer} :: i, j, k, nz
682   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_local \textcolor{comment}{! local/intermediate temp/salt}
683   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_t\_s\_h \textcolor{comment}{! group pass if the coordinate has a stencil}
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}
685   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{target} :: t, s \textcolor{comment}{! local temporary state}
686   \textcolor{comment}{! we have to keep track of the total dzInterface if for some reason}
687   \textcolor{comment}{! we're using the old remapping algorithm for u/v}
688   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzinterface, dzinttotal
689 
690   nz = gv%ke
691 
692   \textcolor{comment}{! initial total interface displacement due to successive regridding}
693   dzinttotal(:,:,:) = 0.
694 
695   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, t, g%domain)
696   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, s, g%domain)
697   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, h\_loc, g%domain)
698 
699   \textcolor{comment}{! copy original temp/salt and set our local tv\_pointers to them}
700   tv\_local = tv
701   t(:,:,:) = tv%T(:,:,:)
702   s(:,:,:) = tv%S(:,:,:)
703   tv\_local%T => t
704   tv\_local%S => s
705 
706   \textcolor{comment}{! get local copy of thickness and save original state for remapping}
707   h\_loc(:,:,:) = h(:,:,:)
708   h\_orig(:,:,:) = h(:,:,:)
709 
710   \textcolor{comment}{! Apply timescale to regridding (for e.g. filtered\_grid\_motion)}
711   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) &
712     \textcolor{keyword}{call }ale\_update\_regrid\_weights(dt, cs)
713 
714   \textcolor{keywordflow}{do} k = 1, n
715     \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s\_h, g%domain)
716 
717     \textcolor{comment}{! generate new grid}
718     \textcolor{keyword}{call }regridding\_main(cs%remapCS, cs%regridCS, g, gv, h\_loc, tv\_local, h, dzinterface)
719     dzinttotal(:,:,:) = dzinttotal(:,:,:) + dzinterface(:,:,:)
720 
721     \textcolor{comment}{! remap from original grid onto new grid}
722     \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
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,:))
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,:))
725 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
726 
727     \textcolor{comment}{! starting grid for next iteration}
728     h\_loc(:,:,:) = h(:,:,:)
729 \textcolor{keywordflow}{  enddo}
730 
731   \textcolor{comment}{! remap all state variables (including those that weren't needed for regridding)}
732   \textcolor{keyword}{call }remap\_all\_state\_vars(cs%remapCS, cs, g, gv, h\_orig, h, reg, obc, dzinttotal, u, v)
733 
734   \textcolor{comment}{! save total dzregrid for diags if needed?}
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}}
\subsubsection{\texorpdfstring{ale\+\_\+remap\+\_\+init\+\_\+conds()}{ale\_remap\_init\_conds()}}
{\footnotesize\ttfamily logical function, public mom\+\_\+ale\+::ale\+\_\+remap\+\_\+init\+\_\+conds (\begin{DoxyParamCaption}\item[{type(\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}
1228   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< module control structure}
1229 
1230   ale\_remap\_init\_conds = .false.
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}}
\subsubsection{\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{\tt in}  & {\em cs} & Remapping control structure\\
\hline
\mbox{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em nk\+\_\+src} & Number of levels on source grid\\
\hline
\mbox{\tt in}  & {\em h\+\_\+src} & Level thickness of source grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt in}  & {\em s\+\_\+src} & Scalar on source grid\\
\hline
\mbox{\tt in}  & {\em h\+\_\+dst} & Level thickness of destination grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em s\+\_\+dst} & Scalar on destination grid\\
\hline
\mbox{\tt in}  & {\em all\+\_\+cells} & If false, only reconstruct for non-\/vanished cells. Use all vanished layers otherwise (default).\\
\hline
\mbox{\tt in}  & {\em old\+\_\+remap} & If true, use the old \char`\"{}remapping\+\_\+core\+\_\+w\char`\"{} method, otherwise use \char`\"{}remapping\+\_\+core\+\_\+h\char`\"{}.\\
\hline
\mbox{\tt 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}
945   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{        !< Remapping control structure}
946   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{         !< Ocean grid structure}
947   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{        !< Ocean vertical grid structure}
948   \textcolor{keywordtype}{integer},                                 \textcolor{keywordtype}{intent(in)}    :: nk\_src\textcolor{comment}{    !< Number of levels on source grid}
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}
950 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
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}
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}
953 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
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}
955   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: all\_cells\textcolor{comment}{ !< If false, only reconstruct for}
956 \textcolor{comment}{                                                                      !! non-vanished cells. Use all
       vanished}
957 \textcolor{comment}{                                                                      !! layers otherwise (default).}
958   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: old\_remap\textcolor{comment}{ !< If true, use the old
       "remapping\_core\_w"}
959 \textcolor{comment}{                                                                      !! method, otherwise use
       "remapping\_core\_h".}
960   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true, use the order of
       arithmetic}
961 \textcolor{comment}{                                                                      !! and expressions that recover the
       answers for}
962 \textcolor{comment}{                                                                      !! remapping from the end of 2018.
       Otherwise,}
963 \textcolor{comment}{                                                                      !! use more robust forms of the same
       expressions.}
964   \textcolor{comment}{! Local variables}
965   \textcolor{keywordtype}{integer} :: i, j, k, n\_points
966   \textcolor{keywordtype}{real} :: dx(gv%ke+1)
967   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
968   \textcolor{keywordtype}{logical} :: ignore\_vanished\_layers, use\_remapping\_core\_w, use\_2018\_remap
969 
970   ignore\_vanished\_layers = .false.
971   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(all\_cells)) ignore\_vanished\_layers = .not. all\_cells
972   use\_remapping\_core\_w = .false.
973   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(old\_remap)) use\_remapping\_core\_w = old\_remap
974   n\_points = nk\_src
975   use\_2018\_remap = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(answers\_2018)) use\_2018\_remap = answers\_2018
976 
977   \textcolor{keywordflow}{if} (.not.use\_2018\_remap) \textcolor{keywordflow}{then}
978     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
979   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
980     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
981   \textcolor{keywordflow}{else}
982     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
983 \textcolor{keywordflow}{  endif}
984 
985   \textcolor{comment}{!$OMP parallel do default(shared) firstprivate(n\_points,dx)}
986   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
987     \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0.) \textcolor{keywordflow}{then}
988       \textcolor{keywordflow}{if} (ignore\_vanished\_layers) \textcolor{keywordflow}{then}
989         n\_points = 0
990         \textcolor{keywordflow}{do} k = 1, nk\_src
991           \textcolor{keywordflow}{if} (h\_src(i,j,k)>0.) n\_points = n\_points + 1
992 \textcolor{keywordflow}{        enddo}
993         s\_dst(i,j,:) = 0.
994 \textcolor{keywordflow}{      endif}
995       \textcolor{keywordflow}{if} (use\_remapping\_core\_w) \textcolor{keywordflow}{then}
996         \textcolor{keyword}{call }dzfromh1h2( n\_points, h\_src(i,j,1:n\_points), gv%ke, h\_dst(i,j,:), dx )
997         \textcolor{keyword}{call }remapping\_core\_w(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
998                               gv%ke, dx, s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
999       \textcolor{keywordflow}{else}
1000         \textcolor{keyword}{call }remapping\_core\_h(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
1001                               gv%ke, h\_dst(i,j,:), s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
1002 \textcolor{keywordflow}{      endif}
1003     \textcolor{keywordflow}{else}
1004       s\_dst(i,j,:) = 0.
1005 \textcolor{keywordflow}{    endif}
1006 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
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}}
\subsubsection{\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(\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{\tt 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}
1236   \textcolor{keywordtype}{real},         \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{ !< Time-step used between ALE calls [T ~> s]}
1237   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< ALE control structure}
1238   \textcolor{comment}{! Local variables}
1239   \textcolor{keywordtype}{real} :: w  \textcolor{comment}{! An implicit weighting estimate.}
1240 
1241   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
1242     w = 0.0
1243     \textcolor{keywordflow}{if} (cs%regrid\_time\_scale > 0.0) \textcolor{keywordflow}{then}
1244       w = cs%regrid\_time\_scale / (cs%regrid\_time\_scale + dt)
1245 \textcolor{keywordflow}{    endif}
1246     \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, old\_grid\_weight=w)
1247 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\texorpdfstring{ale\+\_\+updateverticalgridtype()}{ale\_updateverticalgridtype()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+updateverticalgridtype (\begin{DoxyParamCaption}\item[{type(\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}
1255   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{  !< ALE control structure}
1256   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv\textcolor{comment}{  !< vertical grid information}
1257 
1258   \textcolor{keywordtype}{integer} :: nk
1259 
1260   nk = gv%ke
1261   gv%sInterface(1:nk+1) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
1262   gv%sLayer(1:nk) = 0.5*( gv%sInterface(1:nk) + gv%sInterface(2:nk+1) )
1263   gv%zAxisUnits = getcoordinateunits( cs%regridCS )
1264   gv%zAxisLongName = getcoordinateshortname( cs%regridCS )
1265   gv%direction = -1 \textcolor{comment}{! Because of ferret in z* mode. Need method to set}
1266                     \textcolor{comment}{! as function of coordinae mode.}
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}}
\subsubsection{\texorpdfstring{ale\+\_\+writecoordinatefile()}{ale\_writecoordinatefile()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ale\+\_\+writecoordinatefile (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em gv} & ocean vertical grid structure\\
\hline
\mbox{\tt 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}
1275   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{         !< module control structure}
1276   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{         !< ocean vertical grid structure}
1277   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: directory\textcolor{comment}{  !< directory for writing grid info}
1278 
1279   \textcolor{keywordtype}{character(len=240)} :: filepath
1280   \textcolor{keywordtype}{type}(vardesc)      :: vars(2)
1281   \textcolor{keywordtype}{type}(fieldtype)    :: fields(2)
1282   \textcolor{keywordtype}{integer}            :: unit
1283   \textcolor{keywordtype}{real}               :: ds(gv%ke), dsi(gv%ke+1)
1284 
1285   filepath    = trim(directory) // trim(\textcolor{stringliteral}{"Vertical\_coordinate"})
1286   ds(:)       = getcoordinateresolution( cs%regridCS, undo\_scaling=.true. )
1287   dsi(1)      = 0.5*ds(1)
1288   dsi(2:gv%ke) = 0.5*( ds(1:gv%ke-1) + ds(2:gv%ke) )
1289   dsi(gv%ke+1) = 0.5*ds(gv%ke)
1290 
1291   vars(1) = var\_desc(\textcolor{stringliteral}{'ds'}, getcoordinateunits( cs%regridCS ), &
1292                     \textcolor{stringliteral}{'Layer Coordinate Thickness'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'L'},\textcolor{stringliteral}{'1'})
1293   vars(2) = var\_desc(\textcolor{stringliteral}{'ds\_interface'}, getcoordinateunits( cs%regridCS ), &
1294                     \textcolor{stringliteral}{'Layer Center Coordinate Separation'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'i'},\textcolor{stringliteral}{'1'})
1295 
1296   \textcolor{keyword}{call }create\_file(unit, trim(filepath), vars, 2, fields, single\_file, gv=gv)
1297   \textcolor{keyword}{call }write\_field(unit, fields(1), ds)
1298   \textcolor{keyword}{call }write\_field(unit, fields(2), dsi)
1299   \textcolor{keyword}{call }close\_file(unit)
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}}
\subsubsection{\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{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em h} & Current 3D grid obtained after the last time step \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt 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}
589   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{  !< Ocean grid structure}
590   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{ !< Ocean vertical grid structure}
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}
592 \textcolor{comment}{                                                              !! last time step [H ~> m or kg m-2]}
593   \textcolor{keywordtype}{real},                                      \textcolor{keywordtype}{intent(in)} :: threshold\textcolor{comment}{ !< Value below which to flag issues,}
594 \textcolor{comment}{                                                              !! [H ~> m or kg m-2]}
595   \textcolor{comment}{! Local variables}
596   \textcolor{keywordtype}{integer} :: i, j
597 
598   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
599     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
600       \textcolor{keywordflow}{if} (minval(h(i,j,:)) < threshold) \textcolor{keywordflow}{then}
601         \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'check\_grid: i,j='},i,j,\textcolor{stringliteral}{'h(i,j,:)='},h(i,j,:)
602         \textcolor{keywordflow}{if} (threshold <= 0.) \textcolor{keywordflow}{then}
603           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: negative thickness encountered."})
604         \textcolor{keywordflow}{else}
605           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: too tiny thickness encountered."})
606 \textcolor{keywordflow}{        endif}
607 \textcolor{keywordflow}{      endif}
608 \textcolor{keywordflow}{    endif}
609 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
610 
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}}
\subsubsection{\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(\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{\tt in}  & {\em cs\+\_\+remapping} & Remapping control structure\\
\hline
\mbox{\tt in}  & {\em cs\+\_\+ale} & A\+LE control structure\\
\hline
\mbox{\tt in}  & {\em g} & Ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in}  & {\em h\+\_\+old} & Thickness of source grid \mbox{[}H $\sim$$>$ m or kg-\/2\mbox{]}\\
\hline
\mbox{\tt 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{\tt in}  & {\em dxinterface} & Change in interface position\\
\hline
\mbox{\tt in,out}  & {\em u} & Zonal velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em v} & Meridional velocity \mbox{[}L T-\/1 $\sim$$>$ m s-\/1\mbox{]}\\
\hline
\mbox{\tt in}  & {\em debug} & If true, show the call tree\\
\hline
\mbox{\tt 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}
746   \textcolor{keywordtype}{type}(remapping\_cs),                        \textcolor{keywordtype}{intent(in)}    :: cs\_remapping\textcolor{comment}{ !< Remapping control structure}
747   \textcolor{keywordtype}{type}(ale\_cs),                              \textcolor{keywordtype}{intent(in)}    :: cs\_ale\textcolor{comment}{       !< ALE control structure}
748   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{            !< Ocean grid structure}
749   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{           !< Ocean vertical grid structure}
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}
751 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
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}
753 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
754   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{          !< Tracer registry structure}
755   \textcolor{keywordtype}{type}(ocean\_obc\_type),                      \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{          !< Open boundary structure}
756   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
757                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dxinterface\textcolor{comment}{  !< Change in interface position}
758 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
759   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
760                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
761   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
762                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m
       s-1]}
763   \textcolor{keywordtype}{logical},                         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{  !< If true, show the call tree}
764   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< time step for diagnostics [T ~> s]}
765   \textcolor{comment}{! Local variables}
766   \textcolor{keywordtype}{integer}                                     :: i, j, k, m
767   \textcolor{keywordtype}{integer}                                     :: nz, ntr
768   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke+1)}                    :: dx
769   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h1, u\_column
770   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_conc
771   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_cont
772   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))}           :: work\_2d
773   \textcolor{keywordtype}{real}                                        :: idt \textcolor{comment}{! The inverse of the timestep [T-1 ~> s-1]}
774   \textcolor{keywordtype}{real}                                        :: ppt2mks
775   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h2
776   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
777   \textcolor{keywordtype}{logical}                                     :: show\_call\_tree
778   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}                  :: tr => null()
779 
780   show\_call\_tree = .false.
781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
782   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"remap\_all\_state\_vars(), MOM\_ALE.F90"})
783 
784   \textcolor{comment}{! If remap\_uv\_using\_old\_alg is .true. and u or v is requested, then we must have dxInterface. Otherwise,}
785   \textcolor{comment}{! u and v can be remapped without dxInterface}
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}
787     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"remap\_all\_state\_vars: dxInterface must be present if using old algorithm "}// &
788                           \textcolor{stringliteral}{"and u/v are to be remapped"})
789 \textcolor{keywordflow}{  endif}
790 
791   \textcolor{keywordflow}{if} (.not.cs\_ale%answers\_2018) \textcolor{keywordflow}{then}
792     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
793   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
794     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
795   \textcolor{keywordflow}{else}
796     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
797 \textcolor{keywordflow}{  endif}
798 
799   nz      = gv%ke
800   ppt2mks = 0.001
801 
802   ntr = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) ntr = reg%ntr
803 
804   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
805     idt = 1.0/dt
806     work\_conc(:,:,:) = 0.0
807     work\_cont(:,:,:) = 0.0
808 \textcolor{keywordflow}{  endif}
809 
810   \textcolor{comment}{! Remap tracer}
811   \textcolor{keywordflow}{if} (ntr>0) \textcolor{keywordflow}{then}
812     \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"remapping tracers (remap\_all\_state\_vars)"})
813     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,u\_column,Tr)}
814     \textcolor{keywordflow}{do} m=1,ntr \textcolor{comment}{! For each tracer}
815       tr => reg%Tr(m)
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}
817         \textcolor{comment}{! Build the start and final grids}
818         h1(:) = h\_old(i,j,:)
819         h2(:) = h\_new(i,j,:)
820         \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, tr%t(i,j,:), nz, h2, &
821                               u\_column, h\_neglect, h\_neglect\_edge)
822 
823         \textcolor{comment}{! Intermediate steps for tendency of tracer concentration and tracer content.}
824         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
825           \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
826             \textcolor{keywordflow}{do} k=1,gv%ke
827               work\_conc(i,j,k) = (u\_column(k) - tr%t(i,j,k)) * idt
828 \textcolor{keywordflow}{            enddo}
829 \textcolor{keywordflow}{          endif}
830           \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0 .or. tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
831             \textcolor{keywordflow}{do} k=1,gv%ke
832               work\_cont(i,j,k) = (u\_column(k)*h2(k) - tr%t(i,j,k)*h1(k)) * idt
833 \textcolor{keywordflow}{            enddo}
834 \textcolor{keywordflow}{          endif}
835 \textcolor{keywordflow}{        endif}
836         \textcolor{comment}{! update tracer concentration}
837         tr%t(i,j,:) = u\_column(:)
838 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
839 
840       \textcolor{comment}{! tendency diagnostics.}
841       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
842         \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
843           \textcolor{keyword}{call }post\_data(tr%id\_remap\_conc, work\_conc, cs\_ale%diag)
844 \textcolor{keywordflow}{        endif}
845         \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0) \textcolor{keywordflow}{then}
846           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont, work\_cont, cs\_ale%diag)
847 \textcolor{keywordflow}{        endif}
848         \textcolor{keywordflow}{if} (tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
849           \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
850             work\_2d(i,j) = 0.0
851             \textcolor{keywordflow}{do} k = 1,gv%ke
852               work\_2d(i,j) = work\_2d(i,j) + work\_cont(i,j,k)
853 \textcolor{keywordflow}{            enddo}
854 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
855           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont\_2d, work\_2d, cs\_ale%diag)
856 \textcolor{keywordflow}{        endif}
857 \textcolor{keywordflow}{      endif}
858 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! m=1,ntr}
859 
860 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! endif for ntr > 0}
861 
862   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"tracers remapped (remap\_all\_state\_vars)"})
863 
864   \textcolor{comment}{! Remap u velocity component}
865   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(u) ) \textcolor{keywordflow}{then}
866     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
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}
868       \textcolor{comment}{! Build the start and final grids}
869       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i+1,j,:) )
870       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
871         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i+1,j,:) )
872         \textcolor{keywordflow}{do} k = 1, nz
873           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
874 \textcolor{keywordflow}{        enddo}
875       \textcolor{keywordflow}{else}
876         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i+1,j,:) )
877 \textcolor{keywordflow}{      endif}
878       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
879         \textcolor{keywordflow}{if} (obc%segnum\_u(i,j) .ne. 0) \textcolor{keywordflow}{then}
880           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_u(i,j))%direction == obc\_direction\_e) \textcolor{keywordflow}{then}
881             h1(:) = h\_old(i,j,:)
882             h2(:) = h\_new(i,j,:)
883           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_W)}
884             h1(:) = h\_old(i+1,j,:)
885             h2(:) = h\_new(i+1,j,:)
886 \textcolor{keywordflow}{          endif}
887 \textcolor{keywordflow}{        endif}
888 \textcolor{keywordflow}{      endif}
889       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, u(i,j,:), nz, h2, &
890                             u\_column, h\_neglect, h\_neglect\_edge)
891       u(i,j,:) = u\_column(:)
892 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
893 \textcolor{keywordflow}{  endif}
894 
895   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"u remapped (remap\_all\_state\_vars)"})
896 
897   \textcolor{comment}{! Remap v velocity component}
898   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(v) ) \textcolor{keywordflow}{then}
899     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
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}
901       \textcolor{comment}{! Build the start and final grids}
902       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i,j+1,:) )
903       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
904         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i,j+1,:) )
905         \textcolor{keywordflow}{do} k = 1, nz
906           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
907 \textcolor{keywordflow}{        enddo}
908       \textcolor{keywordflow}{else}
909         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i,j+1,:) )
910 \textcolor{keywordflow}{      endif}
911       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
912         \textcolor{keywordflow}{if} (obc%segnum\_v(i,j) .ne. 0) \textcolor{keywordflow}{then}
913           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_v(i,j))%direction == obc\_direction\_n) \textcolor{keywordflow}{then}
914             h1(:) = h\_old(i,j,:)
915             h2(:) = h\_new(i,j,:)
916           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_S)}
917             h1(:) = h\_old(i,j+1,:)
918             h2(:) = h\_new(i,j+1,:)
919 \textcolor{keywordflow}{          endif}
920 \textcolor{keywordflow}{        endif}
921 \textcolor{keywordflow}{      endif}
922       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, v(i,j,:), nz, h2, &
923                             u\_column, h\_neglect, h\_neglect\_edge)
924       v(i,j,:) = u\_column(:)
925 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
926 \textcolor{keywordflow}{  endif}
927 
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)
929   \textcolor{keywordflow}{if} ((cs\_ale%id\_vert\_remap\_h\_tendency > 0) .and. \textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
930     \textcolor{keywordflow}{do} k = 1, nz ; \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
931       work\_cont(i,j,k) = (h\_new(i,j,k) - h\_old(i,j,k))*idt
932 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
933     \textcolor{keyword}{call }post\_data(cs\_ale%id\_vert\_remap\_h\_tendency, work\_cont, cs\_ale%diag)
934 \textcolor{keywordflow}{  endif}
935   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"v remapped (remap\_all\_state\_vars)"})
936   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"remap\_all\_state\_vars()"})
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}}
\subsubsection{\texorpdfstring{ts\+\_\+plm\+\_\+edge\+\_\+values()}{ts\_plm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ts\+\_\+plm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em cs} & module control structure\\
\hline
\mbox{\tt in,out}  & {\em s\+\_\+t} & Salinity at the top edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em s\+\_\+b} & Salinity at the bottom edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em t\+\_\+t} & Temperature at the top edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em t\+\_\+b} & Temperature at the bottom edge of each layer\\
\hline
\mbox{\tt in}  & {\em tv} & thermodynamics structure\\
\hline
\mbox{\tt in}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt 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}
1014   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
1015   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
1016   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< module control structure}
1017   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1018                            \textcolor{keywordtype}{intent(inout)} :: s\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
1019   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1020                            \textcolor{keywordtype}{intent(inout)} :: s\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
1021   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1022                            \textcolor{keywordtype}{intent(inout)} :: t\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
1023   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1024                            \textcolor{keywordtype}{intent(inout)} :: t\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
1025   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
1026   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1027                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
1028   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
1029 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
1030 
1031   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv%S, bdry\_extrap, s\_t, s\_b )
1032   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv%T, bdry\_extrap, t\_t, t\_b )
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}}
\subsubsection{\texorpdfstring{ts\+\_\+ppm\+\_\+edge\+\_\+values()}{ts\_ppm\_edge\_values()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+ale\+::ts\+\_\+ppm\+\_\+edge\+\_\+values (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em g} & ocean grid structure\\
\hline
\mbox{\tt in}  & {\em gv} & Ocean vertical grid structure\\
\hline
\mbox{\tt in,out}  & {\em cs} & module control structure\\
\hline
\mbox{\tt in,out}  & {\em s\+\_\+t} & Salinity at the top edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em s\+\_\+b} & Salinity at the bottom edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em t\+\_\+t} & Temperature at the top edge of each layer\\
\hline
\mbox{\tt in,out}  & {\em t\+\_\+b} & Temperature at the bottom edge of each layer\\
\hline
\mbox{\tt in}  & {\em tv} & thermodynamics structure\\
\hline
\mbox{\tt in}  & {\em h} & layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]}\\
\hline
\mbox{\tt 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}
1100   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
1101   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
1102   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< module control structure}
1103   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1104                            \textcolor{keywordtype}{intent(inout)} :: s\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
1105   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1106                            \textcolor{keywordtype}{intent(inout)} :: s\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
1107   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1108                            \textcolor{keywordtype}{intent(inout)} :: t\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
1109   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1110                            \textcolor{keywordtype}{intent(inout)} :: t\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
1111   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
1112   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
1113                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thicknesses [H ~> m or kg m-2]}
1114   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
1115 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
1116 
1117   \textcolor{comment}{! Local variables}
1118   \textcolor{keywordtype}{integer} :: i, j, k
1119   \textcolor{keywordtype}{real}    :: htmp(gv%ke) \textcolor{comment}{! A 1-d copy of h [H ~> m or kg m-2]}
1120   \textcolor{keywordtype}{real}    :: tmp(gv%ke)  \textcolor{comment}{! A 1-d copy of a column of temperature [degC] or salinity [ppt]}
1121   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,2)} :: &
1122       ppol\_e            \textcolor{comment}{! Edge value of polynomial in [degC] or [ppt]}
1123   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,3)} :: &
1124       ppol\_coefs        \textcolor{comment}{! Coefficients of polynomial, all in [degC] or [ppt]}
1125   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Tiny thicknesses [H ~> m or kg m-2]}
1126 
1127   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
1128     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
1129   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
1130     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
1131   \textcolor{keywordflow}{else}
1132     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
1133 \textcolor{keywordflow}{  endif}
1134 
1135   \textcolor{comment}{! Determine reconstruction within each column}
1136   \textcolor{comment}{!$OMP parallel do default(shared) private(hTmp,tmp,ppol\_E,ppol\_coefs)}
1137   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
1138 
1139     \textcolor{comment}{! Build current grid}
1140     htmp(:) = h(i,j,:)
1141     tmp(:) = tv%S(i,j,:)
1142 
1143     \textcolor{comment}{! Reconstruct salinity profile}
1144     ppol\_e(:,:) = 0.0
1145     ppol\_coefs(:,:) = 0.0
1146     \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=h\_neglect\_edge, &
1147                                   answers\_2018=cs%answers\_2018 )
1148     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
1149                                   answers\_2018=cs%answers\_2018 )
1150     \textcolor{keywordflow}{if} (bdry\_extrap) &
1151       \textcolor{keyword}{call }ppm\_boundary\_extrapolation( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
1152 
1153     \textcolor{keywordflow}{do} k = 1,gv%ke
1154       s\_t(i,j,k) = ppol\_e(k,1)
1155       s\_b(i,j,k) = ppol\_e(k,2)
1156 \textcolor{keywordflow}{    enddo}
1157 
1158     \textcolor{comment}{! Reconstruct temperature profile}
1159     ppol\_e(:,:) = 0.0
1160     ppol\_coefs(:,:) = 0.0
1161     tmp(:) = tv%T(i,j,:)
1162     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
1163       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=1.0e-10*gv%m\_to\_H, &
1164                                   answers\_2018=cs%answers\_2018 )
1165     \textcolor{keywordflow}{else}
1166       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=gv%H\_subroundoff, &
1167                                   answers\_2018=cs%answers\_2018 )
1168 \textcolor{keywordflow}{    endif}
1169     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
1170                                   answers\_2018=cs%answers\_2018 )
1171     \textcolor{keywordflow}{if} (bdry\_extrap) &
1172       \textcolor{keyword}{call }ppm\_boundary\_extrapolation(gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
1173 
1174     \textcolor{keywordflow}{do} k = 1,gv%ke
1175       t\_t(i,j,k) = ppol\_e(k,1)
1176       t\_b(i,j,k) = ppol\_e(k,2)
1177 \textcolor{keywordflow}{    enddo}
1178 
1179 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1180 
\end{DoxyCode}
