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


This module contains the main regridding routines.  


\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}{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}{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}{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{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{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}{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 \hyperlink{MOM__ALE_8F90_source_l00293}{293} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
00293   \textcolor{keywordtype}{type}(ale\_cs),                              \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
00294   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
00295   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
00296   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{   !< Current 3D grid thickness that}
00297 \textcolor{comment}{                                                                  !! are to be adjusted [H ~> m or kg-2]}
00298   \textcolor{keyword}{call }inflate\_vanished\_layers\_old( cs%regridCS, g, gv, h(:,:,:) )
00299 
\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 \hyperlink{MOM__ALE_8F90_source_l00616}{616} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
00616   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{        !< Ocean grid structure}
00617   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{       !< Ocean vertical grid structure}
00618   \textcolor{keywordtype}{type}(regridding\_cs),                     \textcolor{keywordtype}{intent(in)}    :: regridcs\textcolor{comment}{ !< Regridding parameters and options}
00619   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: remapcs\textcolor{comment}{  !< Remapping parameters and options}
00620   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{       !< Thermodynamical variable structure}
00621   \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}
00622 \textcolor{comment}{                                                                     !! last time step [H ~> m or kg-2]}
00623   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{    !< If true, show the call tree}
00624   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf coverage}
00625   \textcolor{comment}{! Local variables}
00626   \textcolor{keywordtype}{integer} :: nk, i, j, k
00627   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
00628   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: h\_new \textcolor{comment}{! The new grid thicknesses}
00629   \textcolor{keywordtype}{logical} :: show\_call\_tree, use\_ice\_shelf
00630 
00631   show\_call\_tree = .false.
00632   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
00633   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_build\_grid(), MOM\_ALE.F90"})
00634   use\_ice\_shelf = .false.
00635   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
00636     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) use\_ice\_shelf = .true.
00637 \textcolor{keywordflow}{  endif}
00638 
00639   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00640   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00641   \textcolor{keywordflow}{if} (use\_ice\_shelf) \textcolor{keywordflow}{then}
00642      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h )
00643   \textcolor{keywordflow}{else}
00644      \textcolor{keyword}{call }regridding\_main( remapcs, regridcs, g, gv, h, tv, h\_new, dzregrid )
00645 \textcolor{keywordflow}{  endif}
00646 
00647   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00648   \textcolor{comment}{! one of the 'build\_...' routines above.}
00649 \textcolor{comment}{!$OMP parallel do default(none) shared(G,h,h\_new)}
00650   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00651     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) h(i,j,:) = h\_new(i,j,:)
00652 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00653 
00654   \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}{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 \hyperlink{MOM__ALE_8F90_source_l00307}{307} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
00307   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{  !< module control structure}
00308 
00309   \textcolor{comment}{! Deallocate memory used for the regridding}
00310   \textcolor{keyword}{call }end\_remapping( cs%remapCS )
00311   \textcolor{keyword}{call }end\_regridding( cs%regridCS )
00312 
00313   \textcolor{keyword}{deallocate}(cs)
00314 
\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 \hyperlink{MOM__ALE_8F90_source_l01207}{1207} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01207   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{                  !< module control structure}
01208 
01209   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk+1)} :: ale\_getcoordinate
01210   ale\_getcoordinate(:) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
01211 
\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 \hyperlink{MOM__ALE_8F90_source_l01217}{1217} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01217   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< module control structure}
01218 
01219   \textcolor{keywordtype}{character(len=20)}     :: ale\_getcoordinateunits
01220 
01221   ale\_getcoordinateunits = getcoordinateunits( cs%regridCS )
01222 
\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}{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 \hyperlink{MOM__ALE_8F90_source_l00140}{140} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_a4218c92dc4c2ccb2393f98ec2fa0182a}{ale\+\_\+initregridding()}.


\begin{DoxyCode}
00140   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file}
00141   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{         !< Ocean vertical grid structure}
00142   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{         !< A dimensional unit scaling type}
00143   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)} :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
00144   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{         !< Module control structure}
00145 
00146   \textcolor{comment}{! Local variables}
00147   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: dz
00148   \textcolor{keywordtype}{character(len=40)}               :: mdl = \textcolor{stringliteral}{"MOM\_ALE"} \textcolor{comment}{! This module's name.}
00149   \textcolor{keywordtype}{character(len=80)}               :: string \textcolor{comment}{! Temporary strings}
00150   \textcolor{keywordtype}{real}                            :: filter\_shallow\_depth, filter\_deep\_depth
00151   \textcolor{keywordtype}{logical}       :: default\_2018\_answers
00152   \textcolor{keywordtype}{logical}                         :: check\_reconstruction
00153   \textcolor{keywordtype}{logical}                         :: check\_remapping
00154   \textcolor{keywordtype}{logical}                         :: force\_bounds\_in\_subcell
00155   \textcolor{keywordtype}{logical}                         :: local\_logical
00156   \textcolor{keywordtype}{logical}                         :: remap\_boundary\_extrap
00157 
00158   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
00159     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ALE\_init called with an associated "}// &
00160                             \textcolor{stringliteral}{"control structure."})
00161     \textcolor{keywordflow}{return}
00162 \textcolor{keywordflow}{  endif}
00163   \textcolor{keyword}{allocate}(cs)
00164 
00165   cs%show\_call\_tree = calltree\_showquery()
00166   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_init(), MOM\_ALE.F90"})
00167 
00168   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_UV\_USING\_OLD\_ALG"}, cs%remap\_uv\_using\_old\_alg, &
00169                  \textcolor{stringliteral}{"If true, uses the old remapping-via-a-delta-z method for "}//&
00170                  \textcolor{stringliteral}{"remapping u and v. If false, uses the new method that remaps "}//&
00171                  \textcolor{stringliteral}{"between grids described by an old and new thickness."}, &
00172                  default=.false.)
00173 
00174   \textcolor{comment}{! Initialize and configure regridding}
00175   \textcolor{keyword}{call }ale\_initregridding(gv, us, max\_depth, param\_file, mdl, cs%regridCS)
00176 
00177   \textcolor{comment}{! Initialize and configure remapping}
00178   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_SCHEME"}, string, &
00179                  \textcolor{stringliteral}{"This sets the reconstruction scheme used "}//&
00180                  \textcolor{stringliteral}{"for vertical remapping for all variables. "}//&
00181                  \textcolor{stringliteral}{"It can be one of the following schemes: "}//&
00182                  trim(remappingschemesdoc), default=remappingdefaultscheme)
00183   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_RECONSTRUCTIONS"}, check\_reconstruction, &
00184                  \textcolor{stringliteral}{"If true, cell-by-cell reconstructions are checked for "}//&
00185                  \textcolor{stringliteral}{"consistency and if non-monotonicity or an inconsistency is "}//&
00186                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
00187   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FATAL\_CHECK\_REMAPPING"}, check\_remapping, &
00188                  \textcolor{stringliteral}{"If true, the results of remapping are checked for "}//&
00189                  \textcolor{stringliteral}{"conservation and new extrema and if an inconsistency is "}//&
00190                  \textcolor{stringliteral}{"detected then a FATAL error is issued."}, default=.false.)
00191   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUND\_INTERMEDIATE\_VALUES"}, force\_bounds\_in\_subcell, &
00192                  \textcolor{stringliteral}{"If true, the values on the intermediate grid used for remapping "}//&
00193                  \textcolor{stringliteral}{"are forced to be bounded, which might not be the case due to "}//&
00194                  \textcolor{stringliteral}{"round off."}, default=.false.)
00195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_BOUNDARY\_EXTRAP"}, remap\_boundary\_extrap, &
00196                  \textcolor{stringliteral}{"If true, values at the interfaces of boundary cells are "}//&
00197                  \textcolor{stringliteral}{"extrapolated instead of piecewise constant"}, default=.false.)
00198   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
00199                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
00200                  default=.false.)
00201   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAPPING\_2018\_ANSWERS"}, cs%answers\_2018, &
00202                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the "}//&
00203                  \textcolor{stringliteral}{"answers from the end of 2018.  Otherwise, use updated and more robust "}//&
00204                  \textcolor{stringliteral}{"forms of the same expressions."}, default=default\_2018\_answers)
00205   \textcolor{keyword}{call }initialize\_remapping( cs%remapCS, string, &
00206                              boundary\_extrapolation=remap\_boundary\_extrap, &
00207                              check\_reconstruction=check\_reconstruction, &
00208                              check\_remapping=check\_remapping, &
00209                              force\_bounds\_in\_subcell=force\_bounds\_in\_subcell, &
00210                              answers\_2018=cs%answers\_2018)
00211 
00212   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REMAP\_AFTER\_INITIALIZATION"}, cs%remap\_after\_initialization, &
00213                  \textcolor{stringliteral}{"If true, applies regridding and remapping immediately after "}//&
00214                  \textcolor{stringliteral}{"initialization so that the state is ALE consistent. This is a "}//&
00215                  \textcolor{stringliteral}{"legacy step and should not be needed if the initialization is "}//&
00216                  \textcolor{stringliteral}{"consistent with the coordinate mode."}, default=.true.)
00217 
00218   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_TIME\_SCALE"}, cs%regrid\_time\_scale, &
00219                  \textcolor{stringliteral}{"The time-scale used in blending between the current (old) grid "}//&
00220                  \textcolor{stringliteral}{"and the target (new) grid. A short time-scale favors the target "}//&
00221                  \textcolor{stringliteral}{"grid (0. or anything less than DT\_THERM) has no memory of the old "}//&
00222                  \textcolor{stringliteral}{"grid. A very long time-scale makes the model more Lagrangian."}, &
00223                  units=\textcolor{stringliteral}{"s"}, default=0., scale=us%s\_to\_T)
00224   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH"}, filter\_shallow\_depth, &
00225                  \textcolor{stringliteral}{"The depth above which no time-filtering is applied. Above this depth "}//&
00226                  \textcolor{stringliteral}{"final grid exactly matches the target (new) grid."}, &
00227                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
00228   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_FILTER\_DEEP\_DEPTH"}, filter\_deep\_depth, &
00229                  \textcolor{stringliteral}{"The depth below which full time-filtering is applied with time-scale "}//&
00230                  \textcolor{stringliteral}{"REGRID\_TIME\_SCALE. Between depths REGRID\_FILTER\_SHALLOW\_DEPTH and "}//&
00231                  \textcolor{stringliteral}{"REGRID\_FILTER\_SHALLOW\_DEPTH the filter weights adopt a cubic profile."}, &
00232                  units=\textcolor{stringliteral}{"m"}, default=0., scale=gv%m\_to\_H)
00233   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, depth\_of\_time\_filter\_shallow=filter\_shallow\_depth, &
00234                          depth\_of\_time\_filter\_deep=filter\_deep\_depth)
00235   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRID\_USE\_OLD\_DIRECTION"}, local\_logical, &
00236                  \textcolor{stringliteral}{"If true, the regridding ntegrates upwards from the bottom for "}//&
00237                  \textcolor{stringliteral}{"interface positions, much as the main model does. If false "}//&
00238                  \textcolor{stringliteral}{"regridding integrates downward, consistant with the remapping "}//&
00239                  \textcolor{stringliteral}{"code."}, default=.true., do\_not\_log=.true.)
00240   \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, integrate\_downward\_for\_e=.not.local\_logical)
00241 
00242   \textcolor{comment}{! Keep a record of values for subsequent queries}
00243   cs%nk = gv%ke
00244 
00245   \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 \hyperlink{MOM__ALE_8F90_source_l01186}{1186} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_a7e9593dbe4be5138cb83327df05e1d7b}{ale\+\_\+init()}.


\begin{DoxyCode}
01186   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{         !< Ocean vertical grid structure}
01187   \textcolor{keywordtype}{type}(unit\_scale\_type),   \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{         !< A dimensional unit scaling type}
01188   \textcolor{keywordtype}{real},                    \textcolor{keywordtype}{intent(in)}  :: max\_depth\textcolor{comment}{  !< The maximum depth of the ocean [Z ~> m].}
01189   \textcolor{keywordtype}{type}(param\_file\_type),   \textcolor{keywordtype}{intent(in)}  :: param\_file\textcolor{comment}{ !< parameter file}
01190   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: mdl\textcolor{comment}{        !< Name of calling module}
01191   \textcolor{keywordtype}{type}(regridding\_cs),     \textcolor{keywordtype}{intent(out)} :: regridcs\textcolor{comment}{   !< Regridding parameters and work arrays}
01192   \textcolor{comment}{! Local variables}
01193   \textcolor{keywordtype}{character(len=30)} :: coord\_mode
01194 
01195   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"}, coord\_mode, &
01196                  \textcolor{stringliteral}{"Coordinate mode for vertical regridding. "}//&
01197                  \textcolor{stringliteral}{"Choose among the following possibilities: "}//&
01198                  trim(regriddingcoordinatemodedoc), &
01199                  default=default\_coordinate\_mode, fail\_if\_missing=.true.)
01200 
01201   \textcolor{keyword}{call }initialize\_regridding(regridcs, gv, us, max\_depth, param\_file, mdl, coord\_mode, \textcolor{stringliteral}{''}, \textcolor{stringliteral}{''})
01202 
\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 \hyperlink{MOM__ALE_8F90_source_l01306}{1306} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01306   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{intent(inout)}                            :: cs\textcolor{comment}{  !< module control structure}
01307   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}                      :: g\textcolor{comment}{   !< module grid structure}
01308   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}                    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
01309   \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]}
01310 
01311   \textcolor{comment}{! Local variables}
01312   \textcolor{keywordtype}{integer} :: i, j, k
01313 
01314   \textcolor{keywordflow}{do} j = g%jsd,g%jed ; \textcolor{keywordflow}{do} i = g%isd,g%ied
01315     h(i,j,:) = gv%Z\_to\_H * getstaticthickness( cs%regridCS, 0., g%bathyT(i,j) )
01316 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01317 
\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 \hyperlink{MOM__ALE_8F90_source_l00322}{322} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\+\_\+update\+\_\+regrid\+\_\+weights()}, \hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\+\_\+grid()}, and \hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars()}.


\begin{DoxyCode}
00322   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
00323   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
00324   \textcolor{keywordtype}{type}(unit\_scale\_type),                      \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{  !< A dimensional unit scaling type}
00325   \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}
00326 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg m-2]}
00327   \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]}
00328   \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]}
00329   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00330   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
00331   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
00332   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
00333   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
00334   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:)},             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: frac\_shelf\_h\textcolor{comment}{ !< Fractional ice shelf
       coverage}
00335   \textcolor{comment}{! Local variables}
00336   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
00337   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: eta\_preale
00338   \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]}
00339   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00340   \textcolor{keywordtype}{logical} :: ice\_shelf
00341 
00342   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00343 
00344   ice\_shelf = .false.
00345   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(frac\_shelf\_h)) \textcolor{keywordflow}{then}
00346     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(frac\_shelf\_h)) ice\_shelf = .true.
00347 \textcolor{keywordflow}{  endif}
00348 
00349   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main(), MOM\_ALE.F90"})
00350 
00351   \textcolor{comment}{! These diagnostics of the state before ALE is applied are mostly used for debugging.}
00352   \textcolor{keywordflow}{if} (cs%id\_u\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_u\_preale, u,    cs%diag)
00353   \textcolor{keywordflow}{if} (cs%id\_v\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_v\_preale, v,    cs%diag)
00354   \textcolor{keywordflow}{if} (cs%id\_h\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_h\_preale, h,    cs%diag)
00355   \textcolor{keywordflow}{if} (cs%id\_T\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_T\_preale, tv%T, cs%diag)
00356   \textcolor{keywordflow}{if} (cs%id\_S\_preale > 0) \textcolor{keyword}{call }post\_data(cs%id\_S\_preale, tv%S, cs%diag)
00357   \textcolor{keywordflow}{if} (cs%id\_e\_preale > 0) \textcolor{keywordflow}{then}
00358     \textcolor{keyword}{call }find\_eta(h, tv, g, gv, us, eta\_preale)
00359     \textcolor{keyword}{call }post\_data(cs%id\_e\_preale, eta\_preale, cs%diag)
00360 \textcolor{keywordflow}{  endif}
00361 
00362   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00363     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )
00364 \textcolor{keywordflow}{  endif}
00365   dzregrid(:,:,:) = 0.0
00366 
00367   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00368   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00369   \textcolor{keywordflow}{if} (ice\_shelf) \textcolor{keywordflow}{then}
00370      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, frac\_shelf\_h)
00371   \textcolor{keywordflow}{else}
00372      \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid)
00373 \textcolor{keywordflow}{  endif}
00374 
00375   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )
00376 
00377   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
00378 
00379   \textcolor{comment}{! The presence of dt is used for expediency to distinguish whether ALE\_main is being called during init}
00380   \textcolor{comment}{! or in the main loop. Tendency diagnostics in remap\_all\_state\_vars also rely on this logic.}
00381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00382     \textcolor{keyword}{call }diag\_update\_remap\_grids(cs%diag)
00383 \textcolor{keywordflow}{  endif}
00384   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00385   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, -dzregrid, &
00386                              u, v, cs%show\_call\_tree, dt )
00387 
00388   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
00389 
00390   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00391   \textcolor{comment}{! one of the 'build\_...' routines above.}
00392   \textcolor{comment}{!$OMP parallel do default(shared)}
00393   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00394     h(i,j,k) = h\_new(i,j,k)
00395 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00396 
00397   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
00398 
00399   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
00400 
00401 
\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 \hyperlink{MOM__ALE_8F90_source_l00409}{409} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\+\_\+update\+\_\+regrid\+\_\+weights()}, \hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\+\_\+grid()}, and \hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars()}.


\begin{DoxyCode}
00409   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
00410   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
00411   \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}
00412 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
00413   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00414   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
00415   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
00416   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
00417   \textcolor{keywordtype}{real},                             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{  !< Time step between calls to ALE\_main
       [T ~> s]}
00418   \textcolor{comment}{! Local variables}
00419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
00420   \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]}
00421   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00422 
00423   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00424 
00425   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_main\_offline(), MOM\_ALE.F90"})
00426 
00427   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00428     \textcolor{keyword}{call }ale\_update\_regrid\_weights( dt, cs )
00429 \textcolor{keywordflow}{  endif}
00430   dzregrid(:,:,:) = 0.0
00431 
00432   \textcolor{comment}{! Build new grid. The new grid is stored in h\_new. The old grid is h.}
00433   \textcolor{comment}{! Both are needed for the subsequent remapping of variables.}
00434   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid )
00435 
00436   \textcolor{keyword}{call }check\_grid( g, gv, h, 0. )
00437 
00438   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_main)"})
00439 
00440   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00441 
00442   \textcolor{keyword}{call }remap\_all\_state\_vars(cs%remapCS, cs, g, gv, h, h\_new, reg, obc, &
00443                             debug=cs%show\_call\_tree, dt=dt )
00444 
00445   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_main)"})
00446 
00447   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00448   \textcolor{comment}{! one of the 'build\_...' routines above.}
00449   \textcolor{comment}{!$OMP parallel do default(shared)}
00450   \textcolor{keywordflow}{do} k = 1,nk ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00451     h(i,j,k) = h\_new(i,j,k)
00452 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00453 
00454   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ALE\_main()"})
00455   \textcolor{keywordflow}{if} (cs%id\_dzRegrid>0 .and. \textcolor{keyword}{present}(dt)) \textcolor{keyword}{call }post\_data(cs%id\_dzRegrid, dzregrid, cs%diag)
00456 
\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 \hyperlink{MOM__ALE_8F90_source_l00463}{463} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_a3b5aca0afd3590607919a261b241a185}{ale\+\_\+remap\+\_\+scalar()}, \hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\+\_\+grid()}, and \hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars()}.


\begin{DoxyCode}
00463   \textcolor{keywordtype}{type}(ale\_cs),                                 \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{    !< Regridding parameters and options}
00464   \textcolor{keywordtype}{type}(ocean\_grid\_type),                        \textcolor{keywordtype}{intent(in   )} :: g\textcolor{comment}{     !< Ocean grid informations}
00465   \textcolor{keywordtype}{type}(verticalgrid\_type),                      \textcolor{keywordtype}{intent(in   )} :: gv\textcolor{comment}{    !< Ocean vertical grid structure}
00466   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},    \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{     !< Layer thicknesses}
00467   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                        \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{    !< Thermodynamic variable structure}
00468   \textcolor{keywordtype}{type}(tracer\_registry\_type),                   \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{   !< Tracer registry structure}
00469   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: uhtr\textcolor{comment}{  !< Zonal mass fluxes}
00470   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))},   \textcolor{keywordtype}{intent(inout)} :: vhtr\textcolor{comment}{  !< Meridional mass fluxes}
00471   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)},  \textcolor{keywordtype}{intent(inout)} :: kd\textcolor{comment}{    !< Input diffusivites}
00472   \textcolor{keywordtype}{logical},                                      \textcolor{keywordtype}{intent(in   )} :: debug\textcolor{comment}{ !< If true, then turn checksums}
00473   \textcolor{keywordtype}{type}(ocean\_obc\_type),                         \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{   !< Open boundary structure}
00474   \textcolor{comment}{! Local variables}
00475   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00476   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new    \textcolor{comment}{! Layer thicknesses after regridding}
00477   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid \textcolor{comment}{! The change in grid interface positions}
00478   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_src
00479   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: h\_dest, uh\_dest
00480   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZK\_(GV))} :: temp\_vec
00481 
00482   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00483   dzregrid(:,:,:) = 0.0
00484   h\_new(:,:,:) = 0.0
00485 
00486   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"Before ALE\_offline\_inputs"}, g, h, reg%Tr, reg%ntr)
00487 
00488   \textcolor{comment}{! Build new grid from the Zstar state onto the requested vertical coordinate. The new grid is stored}
00489   \textcolor{comment}{! in h\_new. The old grid is h. Both are needed for the subsequent remapping of variables. Convective}
00490   \textcolor{comment}{! adjustment right now is not used because it is unclear what to do with vanished layers}
00491   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h, tv, h\_new, dzregrid, conv\_adjust = .false. )
00492   \textcolor{keyword}{call }check\_grid( g, gv, h\_new, 0. )
00493   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"new grid generated (ALE\_offline\_inputs)"})
00494 
00495   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00496   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs%show\_call\_tree )
00497   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_inputs)"})
00498 
00499   \textcolor{comment}{! Reintegrate mass transports from Zstar to the offline vertical coordinate}
00500   \textcolor{keywordflow}{do} j=jsc,jec ; \textcolor{keywordflow}{do} i=g%iscB,g%iecB
00501     \textcolor{keywordflow}{if} (g%mask2dCu(i,j)>0.) \textcolor{keywordflow}{then}
00502       h\_src(:) = 0.5 * (h(i,j,:) + h(i+1,j,:))
00503       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i+1,j,:))
00504       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, uhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
00505       uhtr(i,j,:) = temp\_vec
00506 \textcolor{keywordflow}{    endif}
00507 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00508   \textcolor{keywordflow}{do} j=g%jscB,g%jecB ; \textcolor{keywordflow}{do} i=isc,iec
00509     \textcolor{keywordflow}{if} (g%mask2dCv(i,j)>0.) \textcolor{keywordflow}{then}
00510       h\_src(:) = 0.5 * (h(i,j,:) + h(i,j+1,:))
00511       h\_dest(:) = 0.5 * (h\_new(i,j,:) + h\_new(i,j+1,:))
00512       \textcolor{keyword}{call }reintegrate\_column(nk, h\_src, vhtr(i,j,:), nk, h\_dest, 0., temp\_vec)
00513       vhtr(i,j,:) = temp\_vec
00514 \textcolor{keywordflow}{    endif}
00515 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00516 
00517   \textcolor{keywordflow}{do} j = jsc,jec ; \textcolor{keywordflow}{do} i=isc,iec
00518     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
00519       \textcolor{keywordflow}{if} (check\_column\_integrals(nk, h\_src, nk, h\_dest)) \textcolor{keywordflow}{then}
00520         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ALE\_offline\_inputs: Kd interpolation columns do not match"})
00521 \textcolor{keywordflow}{      endif}
00522       \textcolor{keyword}{call }interpolate\_column(nk, h(i,j,:), kd(i,j,:), nk, h\_new(i,j,:), 0., kd(i,j,:))
00523 \textcolor{keywordflow}{    endif}
00524 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00525 
00526   \textcolor{keyword}{call }ale\_remap\_scalar(cs%remapCS, g, gv, nk, h, tv%T, h\_new, tv%T, answers\_2018=cs%answers\_2018)
00527   \textcolor{keyword}{call }ale\_remap\_scalar(cs%remapCS, g, gv, nk, h, tv%S, h\_new, tv%S, answers\_2018=cs%answers\_2018)
00528 
00529   \textcolor{keywordflow}{if} (debug) \textcolor{keyword}{call }mom\_tracer\_chkinv(\textcolor{stringliteral}{"After ALE\_offline\_inputs"}, g, h\_new, reg%Tr, reg%ntr)
00530 
00531   \textcolor{comment}{! Copy over the new layer thicknesses}
00532   \textcolor{keywordflow}{do} k = 1,nk  ; \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00533       h(i,j,k) = h\_new(i,j,k)
00534 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00535 
00536   \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 \hyperlink{MOM__ALE_8F90_source_l00544}{544} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_a9b511a4b61f92b735cef1129dff14bcb}{check\+\_\+grid()}, and \hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars()}.


\begin{DoxyCode}
00544   \textcolor{keywordtype}{type}(ocean\_grid\_type),                      \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{   !< Ocean grid informations}
00545   \textcolor{keywordtype}{type}(verticalgrid\_type),                    \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{  !< Ocean vertical grid structure}
00546   \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}
00547 \textcolor{comment}{                                                                   !! last time step [H ~> m or kg-2]}
00548   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                      \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{  !< Thermodynamic variable structure}
00549   \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}
00550 \textcolor{comment}{                                                                        !! last time step  [H ~> m or kg-2]}
00551   \textcolor{keywordtype}{type}(tracer\_registry\_type),                 \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{ !< Tracer registry structure}
00552   \textcolor{keywordtype}{type}(ale\_cs),                               \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{  !< Regridding parameters and options}
00553   \textcolor{keywordtype}{type}(ocean\_obc\_type),                       \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{ !< Open boundary structure}
00554   \textcolor{comment}{! Local variables}
00555 
00556   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV)+1)} :: dzregrid\textcolor{comment}{ !< The change in grid interface positions}
00557   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))}   :: h\_new\textcolor{comment}{    !< Regridded target thicknesses}
00558   \textcolor{keywordtype}{integer} :: nk, i, j, k, isc, iec, jsc, jec
00559 
00560   nk = gv%ke; isc = g%isc; iec = g%iec; jsc = g%jsc; jec = g%jec
00561 
00562   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ALE\_offline\_tracer\_final(), MOM\_ALE.F90"})
00563   \textcolor{comment}{! Need to make sure that h\_target is consistent with the current offline ALE confiuration}
00564   \textcolor{keyword}{call }regridding\_main( cs%remapCS, cs%regridCS, g, gv, h\_target, tv, h\_new, dzregrid )
00565   \textcolor{keyword}{call }check\_grid( g, gv, h\_target, 0. )
00566 
00567 
00568   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"Source and target grids checked
       (ALE\_offline\_tracer\_final)"})
00569 
00570   \textcolor{comment}{! Remap all variables from old grid h onto new grid h\_new}
00571 
00572   \textcolor{keyword}{call }remap\_all\_state\_vars( cs%remapCS, cs, g, gv, h, h\_new, reg, obc, debug=cs%show\_call\_tree )
00573 
00574   \textcolor{keywordflow}{if} (cs%show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"state remapped (ALE\_offline\_tracer\_final)"})
00575 
00576   \textcolor{comment}{! Override old grid with new one. The new grid 'h\_new' is built in}
00577   \textcolor{comment}{! one of the 'build\_...' routines above.}
00578   \textcolor{comment}{!$OMP parallel do default(shared)}
00579   \textcolor{keywordflow}{do} k = 1,nk
00580     \textcolor{keywordflow}{do} j = jsc-1,jec+1 ; \textcolor{keywordflow}{do} i = isc-1,iec+1
00581       h(i,j,k) = h\_new(i,j,k)
00582 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00583 \textcolor{keywordflow}{  enddo}
00584   \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 \hyperlink{MOM__ALE_8F90_source_l01039}{1039} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_abedb087c760a6ac146735275638db58a}{ts\+\_\+plm\+\_\+edge\+\_\+values()}.


\begin{DoxyCode}
01039   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{   !< module control structure}
01040   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
01041   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
01042   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01043                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
01044   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01045                            \textcolor{keywordtype}{intent(in)}    :: q\textcolor{comment}{    !< 3d scalar array}
01046   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01047 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01048   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01049                            \textcolor{keywordtype}{intent(inout)} :: q\_t\textcolor{comment}{  !< Scalar at the top edge of each layer}
01050   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01051                            \textcolor{keywordtype}{intent(inout)} :: q\_b\textcolor{comment}{  !< Scalar at the bottom edge of each layer}
01052   \textcolor{comment}{! Local variables}
01053   \textcolor{keywordtype}{integer} :: i, j, k
01054   \textcolor{keywordtype}{real} :: slp(gv%ke)
01055   \textcolor{keywordtype}{real} :: mslp
01056   \textcolor{keywordtype}{real} :: h\_neglect
01057 
01058   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
01059     h\_neglect = gv%H\_subroundoff
01060   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
01061     h\_neglect = gv%m\_to\_H*1.0e-30
01062   \textcolor{keywordflow}{else}
01063     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30
01064 \textcolor{keywordflow}{  endif}
01065 
01066   \textcolor{comment}{!$OMP parallel do default(shared) private(slp,mslp)}
01067   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
01068     slp(1) = 0.
01069     \textcolor{keywordflow}{do} k = 2, gv%ke-1
01070       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))
01071 \textcolor{keywordflow}{    enddo}
01072     slp(gv%ke) = 0.
01073 
01074     \textcolor{keywordflow}{do} k = 2, gv%ke-1
01075       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))
01076       q\_t(i,j,k) = q(i,j,k) - 0.5 * mslp
01077       q\_b(i,j,k) = q(i,j,k) + 0.5 * mslp
01078 \textcolor{keywordflow}{    enddo}
01079     \textcolor{keywordflow}{if} (bdry\_extrap) \textcolor{keywordflow}{then}
01080       mslp = - plm\_extrapolate\_slope(h(i,j,2), h(i,j,1), h\_neglect, q(i,j,2), q(i,j,1))
01081       q\_t(i,j,1) = q(i,j,1) - 0.5 * mslp
01082       q\_b(i,j,1) = q(i,j,1) + 0.5 * mslp
01083       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))
01084       q\_t(i,j,gv%ke) = q(i,j,gv%ke) - 0.5 * mslp
01085       q\_b(i,j,gv%ke) = q(i,j,gv%ke) + 0.5 * mslp
01086     \textcolor{keywordflow}{else}
01087       q\_t(i,j,1) = q(i,j,1)
01088       q\_b(i,j,1) = q(i,j,1)
01089       q\_t(i,j,gv%ke) = q(i,j,gv%ke)
01090       q\_b(i,j,gv%ke) = q(i,j,gv%ke)
01091 \textcolor{keywordflow}{    endif}
01092 
01093 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01094 
\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 \hyperlink{MOM__ALE_8F90_source_l00250}{250} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
00250   \textcolor{keywordtype}{type}(time\_type),\textcolor{keywordtype}{target},     \textcolor{keywordtype}{intent(in)}  :: time\textcolor{comment}{  !< Time structure}
00251   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(in)}  :: g\textcolor{comment}{     !< Grid structure}
00252   \textcolor{keywordtype}{type}(unit\_scale\_type),      \textcolor{keywordtype}{intent(in)}  :: us\textcolor{comment}{    !< A dimensional unit scaling type}
00253   \textcolor{keywordtype}{type}(verticalgrid\_type),    \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{    !< Ocean vertical grid structure}
00254   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},    \textcolor{keywordtype}{intent(in)}  :: diag\textcolor{comment}{  !< Diagnostics control structure}
00255   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}                   :: cs\textcolor{comment}{    !< Module control structure}
00256 
00257   cs%diag => diag
00258 
00259   \textcolor{comment}{! These diagnostics of the state variables before ALE are useful for}
00260   \textcolor{comment}{! debugging the ALE code.}
00261   cs%id\_u\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'u\_preale'}, diag%axesCuL, time, &
00262       \textcolor{stringliteral}{'Zonal velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
00263   cs%id\_v\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'v\_preale'}, diag%axesCvL, time, &
00264       \textcolor{stringliteral}{'Meridional velocity before remapping'}, \textcolor{stringliteral}{'m s-1'}, conversion=us%L\_T\_to\_m\_s)
00265   cs%id\_h\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'h\_preale'}, diag%axesTL, time, &
00266       \textcolor{stringliteral}{'Layer Thickness before remapping'}, get\_thickness\_units(gv), &
00267       conversion=gv%H\_to\_MKS, v\_extensive=.true.)
00268   cs%id\_T\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'T\_preale'}, diag%axesTL, time, &
00269       \textcolor{stringliteral}{'Temperature before remapping'}, \textcolor{stringliteral}{'degC'})
00270   cs%id\_S\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'S\_preale'}, diag%axesTL, time, &
00271       \textcolor{stringliteral}{'Salinity before remapping'}, \textcolor{stringliteral}{'PSU'})
00272   cs%id\_e\_preale = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'e\_preale'}, diag%axesTi, time, &
00273       \textcolor{stringliteral}{'Interface Heights before remapping'}, \textcolor{stringliteral}{'m'}, conversion=us%Z\_to\_m)
00274 
00275   cs%id\_dzRegrid = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'dzRegrid'},diag%axesTi,time, &
00276       \textcolor{stringliteral}{'Change in interface height due to ALE regridding'}, \textcolor{stringliteral}{'m'}, &
00277       conversion=gv%H\_to\_m)
00278   cs%id\_vert\_remap\_h = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'}, \textcolor{stringliteral}{'vert\_remap\_h'}, &
00279       diag%axestl, time, \textcolor{stringliteral}{'layer thicknesses after ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
00280       conversion=gv%H\_to\_m, v\_extensive=.true.)
00281   cs%id\_vert\_remap\_h\_tendency = register\_diag\_field(\textcolor{stringliteral}{'ocean\_model'},\textcolor{stringliteral}{'vert\_remap\_h\_tendency'},diag%axestl,time,
       &
00282       \textcolor{stringliteral}{'Layer thicknesses tendency due to ALE regridding and remapping'}, \textcolor{stringliteral}{'m'}, &
00283       conversion=gv%H\_to\_m*us%s\_to\_T, v\_extensive = .true.)
00284 
\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 \hyperlink{MOM__ALE_8F90_source_l00660}{660} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_aa892ad9bccb3137ea1f662b317be2611}{ale\+\_\+update\+\_\+regrid\+\_\+weights()}, and \hyperlink{namespacemom__ale_a7d3dbcb0719a85ea0a907279fd444539}{remap\+\_\+all\+\_\+state\+\_\+vars()}.


\begin{DoxyCode}
00660   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< ALE control structure}
00661   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< Ocean grid}
00662   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{     !< Vertical grid}
00663   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
00664                            \textcolor{keywordtype}{intent(inout)} :: h\textcolor{comment}{      !< Original thicknesses [H ~> m or kg-2]}
00665   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{     !< Thermo vars (T/S/EOS)}
00666   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)}    :: n\textcolor{comment}{      !< Number of times to regrid}
00667   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
00668                            \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
00669   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
00670                            \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m s-1]}
00671   \textcolor{keywordtype}{type}(ocean\_obc\_type),    \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{    !< Open boundary structure}
00672   \textcolor{keywordtype}{type}(tracer\_registry\_type), &
00673                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{    !< Tracer registry to remap onto new grid}
00674   \textcolor{keywordtype}{real},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< Model timestep to provide a timescale for regridding
       [T ~> s]}
00675   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
00676                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: dzregrid\textcolor{comment}{ !< Final change in interface positions}
00677   \textcolor{keywordtype}{logical},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: initial\textcolor{comment}{ !< Whether we're being called from an initialization}
00678 \textcolor{comment}{                                                    !! routine (and expect diagnostics to work)}
00679 
00680   \textcolor{comment}{! Local variables}
00681   \textcolor{keywordtype}{integer} :: i, j, k, nz
00682   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_local \textcolor{comment}{! local/intermediate temp/salt}
00683   \textcolor{keywordtype}{type}(group\_pass\_type) :: pass\_t\_s\_h \textcolor{comment}{! group pass if the coordinate has a stencil}
00684   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}         :: h\_loc, h\_orig \textcolor{comment}{! A working copy of layer thicknesses}
00685   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{target} :: t, s \textcolor{comment}{! local temporary state}
00686   \textcolor{comment}{! we have to keep track of the total dzInterface if for some reason}
00687   \textcolor{comment}{! we're using the old remapping algorithm for u/v}
00688   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)} :: dzinterface, dzinttotal
00689 
00690   nz = gv%ke
00691 
00692   \textcolor{comment}{! initial total interface displacement due to successive regridding}
00693   dzinttotal(:,:,:) = 0.
00694 
00695   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, t, g%domain)
00696   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, s, g%domain)
00697   \textcolor{keyword}{call }create\_group\_pass(pass\_t\_s\_h, h\_loc, g%domain)
00698 
00699   \textcolor{comment}{! copy original temp/salt and set our local tv\_pointers to them}
00700   tv\_local = tv
00701   t(:,:,:) = tv%T(:,:,:)
00702   s(:,:,:) = tv%S(:,:,:)
00703   tv\_local%T => t
00704   tv\_local%S => s
00705 
00706   \textcolor{comment}{! get local copy of thickness and save original state for remapping}
00707   h\_loc(:,:,:) = h(:,:,:)
00708   h\_orig(:,:,:) = h(:,:,:)
00709 
00710   \textcolor{comment}{! Apply timescale to regridding (for e.g. filtered\_grid\_motion)}
00711   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) &
00712     \textcolor{keyword}{call }ale\_update\_regrid\_weights(dt, cs)
00713 
00714   \textcolor{keywordflow}{do} k = 1, n
00715     \textcolor{keyword}{call }do\_group\_pass(pass\_t\_s\_h, g%domain)
00716 
00717     \textcolor{comment}{! generate new grid}
00718     \textcolor{keyword}{call }regridding\_main(cs%remapCS, cs%regridCS, g, gv, h\_loc, tv\_local, h, dzinterface)
00719     dzinttotal(:,:,:) = dzinttotal(:,:,:) + dzinterface(:,:,:)
00720 
00721     \textcolor{comment}{! remap from original grid onto new grid}
00722     \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
00723       \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,:))
00724       \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,:))
00725 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
00726 
00727     \textcolor{comment}{! starting grid for next iteration}
00728     h\_loc(:,:,:) = h(:,:,:)
00729 \textcolor{keywordflow}{  enddo}
00730 
00731   \textcolor{comment}{! remap all state variables (including those that weren't needed for regridding)}
00732   \textcolor{keyword}{call }remap\_all\_state\_vars(cs%remapCS, cs, g, gv, h\_orig, h, reg, obc, dzinttotal, u, v)
00733 
00734   \textcolor{comment}{! save total dzregrid for diags if needed?}
00735   \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 \hyperlink{MOM__ALE_8F90_source_l01228}{1228} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01228   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{   !< module control structure}
01229 
01230   ale\_remap\_init\_conds = .false.
01231   \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 \hyperlink{MOM__ALE_8F90_source_l00945}{945} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\+\_\+offline\+\_\+inputs()}.


\begin{DoxyCode}
00945   \textcolor{keywordtype}{type}(remapping\_cs),                      \textcolor{keywordtype}{intent(in)}    :: cs\textcolor{comment}{        !< Remapping control structure}
00946   \textcolor{keywordtype}{type}(ocean\_grid\_type),                   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{         !< Ocean grid structure}
00947   \textcolor{keywordtype}{type}(verticalgrid\_type),                 \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{        !< Ocean vertical grid structure}
00948   \textcolor{keywordtype}{integer},                                 \textcolor{keywordtype}{intent(in)}    :: nk\_src\textcolor{comment}{    !< Number of levels on source grid}
00949   \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}
00950 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
00951   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),nk\_src)}, \textcolor{keywordtype}{intent(in)}    :: s\_src\textcolor{comment}{     !< Scalar on source grid}
00952   \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}
00953 \textcolor{comment}{                                                                      !! [H ~> m or kg-2]}
00954   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))},\textcolor{keywordtype}{intent(inout)} :: s\_dst\textcolor{comment}{    !< Scalar on destination grid}
00955   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: all\_cells\textcolor{comment}{ !< If false, only reconstruct for}
00956 \textcolor{comment}{                                                                      !! non-vanished cells. Use all
       vanished}
00957 \textcolor{comment}{                                                                      !! layers otherwise (default).}
00958   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional},                       \textcolor{keywordtype}{intent(in)}    :: old\_remap\textcolor{comment}{ !< If true, use the old
       "remapping\_core\_w"}
00959 \textcolor{comment}{                                                                      !! method, otherwise use
       "remapping\_core\_h".}
00960   \textcolor{keywordtype}{logical},                       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: answers\_2018\textcolor{comment}{ !< If true, use the order of
       arithmetic}
00961 \textcolor{comment}{                                                                      !! and expressions that recover the
       answers for}
00962 \textcolor{comment}{                                                                      !! remapping from the end of 2018.
       Otherwise,}
00963 \textcolor{comment}{                                                                      !! use more robust forms of the same
       expressions.}
00964   \textcolor{comment}{! Local variables}
00965   \textcolor{keywordtype}{integer} :: i, j, k, n\_points
00966   \textcolor{keywordtype}{real} :: dx(gv%ke+1)
00967   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
00968   \textcolor{keywordtype}{logical} :: ignore\_vanished\_layers, use\_remapping\_core\_w, use\_2018\_remap
00969 
00970   ignore\_vanished\_layers = .false.
00971   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(all\_cells)) ignore\_vanished\_layers = .not. all\_cells
00972   use\_remapping\_core\_w = .false.
00973   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(old\_remap)) use\_remapping\_core\_w = old\_remap
00974   n\_points = nk\_src
00975   use\_2018\_remap = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(answers\_2018)) use\_2018\_remap = answers\_2018
00976 
00977   \textcolor{keywordflow}{if} (.not.use\_2018\_remap) \textcolor{keywordflow}{then}
00978     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
00979   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
00980     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
00981   \textcolor{keywordflow}{else}
00982     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
00983 \textcolor{keywordflow}{  endif}
00984 
00985   \textcolor{comment}{!$OMP parallel do default(shared) firstprivate(n\_points,dx)}
00986   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00987     \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0.) \textcolor{keywordflow}{then}
00988       \textcolor{keywordflow}{if} (ignore\_vanished\_layers) \textcolor{keywordflow}{then}
00989         n\_points = 0
00990         \textcolor{keywordflow}{do} k = 1, nk\_src
00991           \textcolor{keywordflow}{if} (h\_src(i,j,k)>0.) n\_points = n\_points + 1
00992 \textcolor{keywordflow}{        enddo}
00993         s\_dst(i,j,:) = 0.
00994 \textcolor{keywordflow}{      endif}
00995       \textcolor{keywordflow}{if} (use\_remapping\_core\_w) \textcolor{keywordflow}{then}
00996         \textcolor{keyword}{call }dzfromh1h2( n\_points, h\_src(i,j,1:n\_points), gv%ke, h\_dst(i,j,:), dx )
00997         \textcolor{keyword}{call }remapping\_core\_w(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
00998                               gv%ke, dx, s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
00999       \textcolor{keywordflow}{else}
01000         \textcolor{keyword}{call }remapping\_core\_h(cs, n\_points, h\_src(i,j,1:n\_points), s\_src(i,j,1:n\_points), &
01001                               gv%ke, h\_dst(i,j,:), s\_dst(i,j,:), h\_neglect, h\_neglect\_edge)
01002 \textcolor{keywordflow}{      endif}
01003     \textcolor{keywordflow}{else}
01004       s\_dst(i,j,:) = 0.
01005 \textcolor{keywordflow}{    endif}
01006 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01007 
\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 \hyperlink{MOM__ALE_8F90_source_l01236}{1236} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\+\_\+main()}, \hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\+\_\+main\+\_\+offline()}, and \hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\+\_\+regrid\+\_\+accelerated()}.


\begin{DoxyCode}
01236   \textcolor{keywordtype}{real},         \textcolor{keywordtype}{intent(in)} :: dt\textcolor{comment}{ !< Time-step used between ALE calls [T ~> s]}
01237   \textcolor{keywordtype}{type}(ale\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{ !< ALE control structure}
01238   \textcolor{comment}{! Local variables}
01239   \textcolor{keywordtype}{real} :: w  \textcolor{comment}{! An implicit weighting estimate.}
01240 
01241   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
01242     w = 0.0
01243     \textcolor{keywordflow}{if} (cs%regrid\_time\_scale > 0.0) \textcolor{keywordflow}{then}
01244       w = cs%regrid\_time\_scale / (cs%regrid\_time\_scale + dt)
01245 \textcolor{keywordflow}{    endif}
01246     \textcolor{keyword}{call }set\_regrid\_params(cs%regridCS, old\_grid\_weight=w)
01247 \textcolor{keywordflow}{  endif}
01248 
\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 \hyperlink{MOM__ALE_8F90_source_l01255}{1255} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01255   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer} :: cs\textcolor{comment}{  !< ALE control structure}
01256   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{pointer} :: gv\textcolor{comment}{  !< vertical grid information}
01257 
01258   \textcolor{keywordtype}{integer} :: nk
01259 
01260   nk = gv%ke
01261   gv%sInterface(1:nk+1) = getcoordinateinterfaces( cs%regridCS, undo\_scaling=.true. )
01262   gv%sLayer(1:nk) = 0.5*( gv%sInterface(1:nk) + gv%sInterface(2:nk+1) )
01263   gv%zAxisUnits = getcoordinateunits( cs%regridCS )
01264   gv%zAxisLongName = getcoordinateshortname( cs%regridCS )
01265   gv%direction = -1 \textcolor{comment}{! Because of ferret in z* mode. Need method to set}
01266                     \textcolor{comment}{! as function of coordinae mode.}
01267 
\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 \hyperlink{MOM__ALE_8F90_source_l01275}{1275} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01275   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{pointer}     :: cs\textcolor{comment}{         !< module control structure}
01276   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}  :: gv\textcolor{comment}{         !< ocean vertical grid structure}
01277   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)}  :: directory\textcolor{comment}{  !< directory for writing grid info}
01278 
01279   \textcolor{keywordtype}{character(len=240)} :: filepath
01280   \textcolor{keywordtype}{type}(vardesc)      :: vars(2)
01281   \textcolor{keywordtype}{type}(fieldtype)    :: fields(2)
01282   \textcolor{keywordtype}{integer}            :: unit
01283   \textcolor{keywordtype}{real}               :: ds(gv%ke), dsi(gv%ke+1)
01284 
01285   filepath    = trim(directory) // trim(\textcolor{stringliteral}{"Vertical\_coordinate"})
01286   ds(:)       = getcoordinateresolution( cs%regridCS, undo\_scaling=.true. )
01287   dsi(1)      = 0.5*ds(1)
01288   dsi(2:gv%ke) = 0.5*( ds(1:gv%ke-1) + ds(2:gv%ke) )
01289   dsi(gv%ke+1) = 0.5*ds(gv%ke)
01290 
01291   vars(1) = var\_desc(\textcolor{stringliteral}{'ds'}, getcoordinateunits( cs%regridCS ), &
01292                     \textcolor{stringliteral}{'Layer Coordinate Thickness'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'L'},\textcolor{stringliteral}{'1'})
01293   vars(2) = var\_desc(\textcolor{stringliteral}{'ds\_interface'}, getcoordinateunits( cs%regridCS ), &
01294                     \textcolor{stringliteral}{'Layer Center Coordinate Separation'},\textcolor{stringliteral}{'1'},\textcolor{stringliteral}{'i'},\textcolor{stringliteral}{'1'})
01295 
01296   \textcolor{keyword}{call }create\_file(unit, trim(filepath), vars, 2, fields, single\_file, gv=gv)
01297   \textcolor{keyword}{call }write\_field(unit, fields(1), ds)
01298   \textcolor{keyword}{call }write\_field(unit, fields(2), dsi)
01299   \textcolor{keyword}{call }close\_file(unit)
01300 
\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 \hyperlink{MOM__ALE_8F90_source_l00589}{589} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\+\_\+main()}, \hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\+\_\+main\+\_\+offline()}, \hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\+\_\+offline\+\_\+inputs()}, and \hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\+\_\+offline\+\_\+tracer\+\_\+final()}.


\begin{DoxyCode}
00589   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{  !< Ocean grid structure}
00590   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)} :: gv\textcolor{comment}{ !< Ocean vertical grid structure}
00591   \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}
00592 \textcolor{comment}{                                                              !! last time step [H ~> m or kg m-2]}
00593   \textcolor{keywordtype}{real},                                      \textcolor{keywordtype}{intent(in)} :: threshold\textcolor{comment}{ !< Value below which to flag issues,}
00594 \textcolor{comment}{                                                              !! [H ~> m or kg m-2]}
00595   \textcolor{comment}{! Local variables}
00596   \textcolor{keywordtype}{integer} :: i, j
00597 
00598   \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00599     \textcolor{keywordflow}{if} (g%mask2dT(i,j)>0.) \textcolor{keywordflow}{then}
00600       \textcolor{keywordflow}{if} (minval(h(i,j,:)) < threshold) \textcolor{keywordflow}{then}
00601         \textcolor{keyword}{write}(0,*) \textcolor{stringliteral}{'check\_grid: i,j='},i,j,\textcolor{stringliteral}{'h(i,j,:)='},h(i,j,:)
00602         \textcolor{keywordflow}{if} (threshold <= 0.) \textcolor{keywordflow}{then}
00603           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: negative thickness encountered."})
00604         \textcolor{keywordflow}{else}
00605           \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_ALE, check\_grid: too tiny thickness encountered."})
00606 \textcolor{keywordflow}{        endif}
00607 \textcolor{keywordflow}{      endif}
00608 \textcolor{keywordflow}{    endif}
00609 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
00610 
00611 
\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 \hyperlink{MOM__ALE_8F90_source_l00746}{746} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



Referenced by \hyperlink{namespacemom__ale_ac56eac14cd9b8909082c1d4fe4e98152}{ale\+\_\+main()}, \hyperlink{namespacemom__ale_a666f48c8fa163fe717e60bd6ed749a75}{ale\+\_\+main\+\_\+offline()}, \hyperlink{namespacemom__ale_ae95451e2fbd4805eec01d00bebb268b4}{ale\+\_\+offline\+\_\+inputs()}, \hyperlink{namespacemom__ale_aa7a1311028c2cd514b4b5224c5c7fe17}{ale\+\_\+offline\+\_\+tracer\+\_\+final()}, and \hyperlink{namespacemom__ale_a93a3be63e89c22d40356a656790f821f}{ale\+\_\+regrid\+\_\+accelerated()}.


\begin{DoxyCode}
00746   \textcolor{keywordtype}{type}(remapping\_cs),                        \textcolor{keywordtype}{intent(in)}    :: cs\_remapping\textcolor{comment}{ !< Remapping control structure}
00747   \textcolor{keywordtype}{type}(ale\_cs),                              \textcolor{keywordtype}{intent(in)}    :: cs\_ale\textcolor{comment}{       !< ALE control structure}
00748   \textcolor{keywordtype}{type}(ocean\_grid\_type),                     \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{            !< Ocean grid structure}
00749   \textcolor{keywordtype}{type}(verticalgrid\_type),                   \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{           !< Ocean vertical grid structure}
00750   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_old\textcolor{comment}{        !< Thickness of source grid}
00751 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00752   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, \textcolor{keywordtype}{intent(in)}    :: h\_new\textcolor{comment}{        !< Thickness of destination grid}
00753 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00754   \textcolor{keywordtype}{type}(tracer\_registry\_type),                \textcolor{keywordtype}{pointer}       :: reg\textcolor{comment}{          !< Tracer registry structure}
00755   \textcolor{keywordtype}{type}(ocean\_obc\_type),                      \textcolor{keywordtype}{pointer}       :: obc\textcolor{comment}{          !< Open boundary structure}
00756   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV)+1)}, &
00757                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dxinterface\textcolor{comment}{  !< Change in interface position}
00758 \textcolor{comment}{                                                                           !! [H ~> m or kg-2]}
00759   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZIB\_(G),SZJ\_(G),SZK\_(GV))}, &
00760                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: u\textcolor{comment}{      !< Zonal velocity [L T-1 ~> m s-1]}
00761   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJB\_(G),SZK\_(GV))}, &
00762                                    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: v\textcolor{comment}{      !< Meridional velocity [L T-1 ~> m
       s-1]}
00763   \textcolor{keywordtype}{logical},                         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: debug\textcolor{comment}{  !< If true, show the call tree}
00764   \textcolor{keywordtype}{real},                            \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{     !< time step for diagnostics [T ~> s]}
00765   \textcolor{comment}{! Local variables}
00766   \textcolor{keywordtype}{integer}                                     :: i, j, k, m
00767   \textcolor{keywordtype}{integer}                                     :: nz, ntr
00768   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke+1)}                    :: dx
00769   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h1, u\_column
00770   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_conc
00771   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G), SZK\_(GV))} :: work\_cont
00772   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G), SZJ\_(G))}           :: work\_2d
00773   \textcolor{keywordtype}{real}                                        :: idt \textcolor{comment}{! The inverse of the timestep [T-1 ~> s-1]}
00774   \textcolor{keywordtype}{real}                                        :: ppt2mks
00775   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(GV%ke)}                      :: h2
00776   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge
00777   \textcolor{keywordtype}{logical}                                     :: show\_call\_tree
00778   \textcolor{keywordtype}{type}(tracer\_type), \textcolor{keywordtype}{pointer}                  :: tr => null()
00779 
00780   show\_call\_tree = .false.
00781   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(debug)) show\_call\_tree = debug
00782   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"remap\_all\_state\_vars(), MOM\_ALE.F90"})
00783 
00784   \textcolor{comment}{! If remap\_uv\_using\_old\_alg is .true. and u or v is requested, then we must have dxInterface. Otherwise,}
00785   \textcolor{comment}{! u and v can be remapped without dxInterface}
00786   \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}
00787     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"remap\_all\_state\_vars: dxInterface must be present if using old algorithm "}// &
00788                           \textcolor{stringliteral}{"and u/v are to be remapped"})
00789 \textcolor{keywordflow}{  endif}
00790 
00791   \textcolor{keywordflow}{if} (.not.cs\_ale%answers\_2018) \textcolor{keywordflow}{then}
00792     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
00793   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
00794     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
00795   \textcolor{keywordflow}{else}
00796     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
00797 \textcolor{keywordflow}{  endif}
00798 
00799   nz      = gv%ke
00800   ppt2mks = 0.001
00801 
00802   ntr = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(reg)) ntr = reg%ntr
00803 
00804   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00805     idt = 1.0/dt
00806     work\_conc(:,:,:) = 0.0
00807     work\_cont(:,:,:) = 0.0
00808 \textcolor{keywordflow}{  endif}
00809 
00810   \textcolor{comment}{! Remap tracer}
00811   \textcolor{keywordflow}{if} (ntr>0) \textcolor{keywordflow}{then}
00812     \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"remapping tracers (remap\_all\_state\_vars)"})
00813     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,u\_column,Tr)}
00814     \textcolor{keywordflow}{do} m=1,ntr \textcolor{comment}{! For each tracer}
00815       tr => reg%Tr(m)
00816       \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}
00817         \textcolor{comment}{! Build the start and final grids}
00818         h1(:) = h\_old(i,j,:)
00819         h2(:) = h\_new(i,j,:)
00820         \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, tr%t(i,j,:), nz, h2, &
00821                               u\_column, h\_neglect, h\_neglect\_edge)
00822 
00823         \textcolor{comment}{! Intermediate steps for tendency of tracer concentration and tracer content.}
00824         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00825           \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
00826             \textcolor{keywordflow}{do} k=1,gv%ke
00827               work\_conc(i,j,k) = (u\_column(k) - tr%t(i,j,k)) * idt
00828 \textcolor{keywordflow}{            enddo}
00829 \textcolor{keywordflow}{          endif}
00830           \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0 .or. tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
00831             \textcolor{keywordflow}{do} k=1,gv%ke
00832               work\_cont(i,j,k) = (u\_column(k)*h2(k) - tr%t(i,j,k)*h1(k)) * idt
00833 \textcolor{keywordflow}{            enddo}
00834 \textcolor{keywordflow}{          endif}
00835 \textcolor{keywordflow}{        endif}
00836         \textcolor{comment}{! update tracer concentration}
00837         tr%t(i,j,:) = u\_column(:)
00838 \textcolor{keywordflow}{      endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00839 
00840       \textcolor{comment}{! tendency diagnostics.}
00841       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00842         \textcolor{keywordflow}{if} (tr%id\_remap\_conc > 0) \textcolor{keywordflow}{then}
00843           \textcolor{keyword}{call }post\_data(tr%id\_remap\_conc, work\_conc, cs\_ale%diag)
00844 \textcolor{keywordflow}{        endif}
00845         \textcolor{keywordflow}{if} (tr%id\_remap\_cont > 0) \textcolor{keywordflow}{then}
00846           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont, work\_cont, cs\_ale%diag)
00847 \textcolor{keywordflow}{        endif}
00848         \textcolor{keywordflow}{if} (tr%id\_remap\_cont\_2d > 0) \textcolor{keywordflow}{then}
00849           \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00850             work\_2d(i,j) = 0.0
00851             \textcolor{keywordflow}{do} k = 1,gv%ke
00852               work\_2d(i,j) = work\_2d(i,j) + work\_cont(i,j,k)
00853 \textcolor{keywordflow}{            enddo}
00854 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
00855           \textcolor{keyword}{call }post\_data(tr%id\_remap\_cont\_2d, work\_2d, cs\_ale%diag)
00856 \textcolor{keywordflow}{        endif}
00857 \textcolor{keywordflow}{      endif}
00858 \textcolor{keywordflow}{    enddo} \textcolor{comment}{! m=1,ntr}
00859 
00860 \textcolor{keywordflow}{  endif}   \textcolor{comment}{! endif for ntr > 0}
00861 
00862   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"tracers remapped (remap\_all\_state\_vars)"})
00863 
00864   \textcolor{comment}{! Remap u velocity component}
00865   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(u) ) \textcolor{keywordflow}{then}
00866     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
00867     \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}
00868       \textcolor{comment}{! Build the start and final grids}
00869       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i+1,j,:) )
00870       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
00871         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i+1,j,:) )
00872         \textcolor{keywordflow}{do} k = 1, nz
00873           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
00874 \textcolor{keywordflow}{        enddo}
00875       \textcolor{keywordflow}{else}
00876         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i+1,j,:) )
00877 \textcolor{keywordflow}{      endif}
00878       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
00879         \textcolor{keywordflow}{if} (obc%segnum\_u(i,j) .ne. 0) \textcolor{keywordflow}{then}
00880           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_u(i,j))%direction == obc\_direction\_e) \textcolor{keywordflow}{then}
00881             h1(:) = h\_old(i,j,:)
00882             h2(:) = h\_new(i,j,:)
00883           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_W)}
00884             h1(:) = h\_old(i+1,j,:)
00885             h2(:) = h\_new(i+1,j,:)
00886 \textcolor{keywordflow}{          endif}
00887 \textcolor{keywordflow}{        endif}
00888 \textcolor{keywordflow}{      endif}
00889       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, u(i,j,:), nz, h2, &
00890                             u\_column, h\_neglect, h\_neglect\_edge)
00891       u(i,j,:) = u\_column(:)
00892 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00893 \textcolor{keywordflow}{  endif}
00894 
00895   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"u remapped (remap\_all\_state\_vars)"})
00896 
00897   \textcolor{comment}{! Remap v velocity component}
00898   \textcolor{keywordflow}{if} ( \textcolor{keyword}{present}(v) ) \textcolor{keywordflow}{then}
00899     \textcolor{comment}{!$OMP parallel do default(shared) private(h1,h2,dx,u\_column)}
00900     \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}
00901       \textcolor{comment}{! Build the start and final grids}
00902       h1(:) = 0.5 * ( h\_old(i,j,:) + h\_old(i,j+1,:) )
00903       \textcolor{keywordflow}{if} (cs\_ale%remap\_uv\_using\_old\_alg) \textcolor{keywordflow}{then}
00904         dx(:) = 0.5 * ( dxinterface(i,j,:) + dxinterface(i,j+1,:) )
00905         \textcolor{keywordflow}{do} k = 1, nz
00906           h2(k) = max( 0., h1(k) + ( dx(k+1) - dx(k) ) )
00907 \textcolor{keywordflow}{        enddo}
00908       \textcolor{keywordflow}{else}
00909         h2(:) = 0.5 * ( h\_new(i,j,:) + h\_new(i,j+1,:) )
00910 \textcolor{keywordflow}{      endif}
00911       \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(obc)) \textcolor{keywordflow}{then}
00912         \textcolor{keywordflow}{if} (obc%segnum\_v(i,j) .ne. 0) \textcolor{keywordflow}{then}
00913           \textcolor{keywordflow}{if} (obc%segment(obc%segnum\_v(i,j))%direction == obc\_direction\_n) \textcolor{keywordflow}{then}
00914             h1(:) = h\_old(i,j,:)
00915             h2(:) = h\_new(i,j,:)
00916           \textcolor{keywordflow}{else} \textcolor{comment}{! (OBC%segment(n)%direction == OBC\_DIRECTION\_S)}
00917             h1(:) = h\_old(i,j+1,:)
00918             h2(:) = h\_new(i,j+1,:)
00919 \textcolor{keywordflow}{          endif}
00920 \textcolor{keywordflow}{        endif}
00921 \textcolor{keywordflow}{      endif}
00922       \textcolor{keyword}{call }remapping\_core\_h(cs\_remapping, nz, h1, v(i,j,:), nz, h2, &
00923                             u\_column, h\_neglect, h\_neglect\_edge)
00924       v(i,j,:) = u\_column(:)
00925 \textcolor{keywordflow}{    endif} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00926 \textcolor{keywordflow}{  endif}
00927 
00928   \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)
00929   \textcolor{keywordflow}{if} ((cs\_ale%id\_vert\_remap\_h\_tendency > 0) .and. \textcolor{keyword}{present}(dt)) \textcolor{keywordflow}{then}
00930     \textcolor{keywordflow}{do} k = 1, nz ; \textcolor{keywordflow}{do} j = g%jsc,g%jec ; \textcolor{keywordflow}{do} i = g%isc,g%iec
00931       work\_cont(i,j,k) = (h\_new(i,j,k) - h\_old(i,j,k))*idt
00932 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
00933     \textcolor{keyword}{call }post\_data(cs\_ale%id\_vert\_remap\_h\_tendency, work\_cont, cs\_ale%diag)
00934 \textcolor{keywordflow}{  endif}
00935   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_waypoint(\textcolor{stringliteral}{"v remapped (remap\_all\_state\_vars)"})
00936   \textcolor{keywordflow}{if} (show\_call\_tree) \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"remap\_all\_state\_vars()"})
00937 
\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 \hyperlink{MOM__ALE_8F90_source_l01014}{1014} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.



References \hyperlink{namespacemom__ale_a5b71ef6179d04dda51d124e3a7485909}{ale\+\_\+plm\+\_\+edge\+\_\+values()}.


\begin{DoxyCode}
01014   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
01015   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
01016   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< module control structure}
01017   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01018                            \textcolor{keywordtype}{intent(inout)} :: s\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
01019   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01020                            \textcolor{keywordtype}{intent(inout)} :: s\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
01021   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01022                            \textcolor{keywordtype}{intent(inout)} :: t\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
01023   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01024                            \textcolor{keywordtype}{intent(inout)} :: t\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
01025   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
01026   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01027                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thickness [H ~> m or kg m-2]}
01028   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01029 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01030 
01031   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv%S, bdry\_extrap, s\_t, s\_b )
01032   \textcolor{keyword}{call }ale\_plm\_edge\_values( cs, g, gv, h, tv%T, bdry\_extrap, t\_t, t\_b )
01033 
\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 \hyperlink{MOM__ALE_8F90_source_l01100}{1100} of file \hyperlink{MOM__ALE_8F90_source}{M\+O\+M\+\_\+\+A\+L\+E.\+F90}.


\begin{DoxyCode}
01100   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< ocean grid structure}
01101   \textcolor{keywordtype}{type}(verticalgrid\_type), \textcolor{keywordtype}{intent(in)}    :: gv\textcolor{comment}{   !< Ocean vertical grid structure}
01102   \textcolor{keywordtype}{type}(ale\_cs),            \textcolor{keywordtype}{intent(inout)} :: cs\textcolor{comment}{   !< module control structure}
01103   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01104                            \textcolor{keywordtype}{intent(inout)} :: s\_t\textcolor{comment}{  !< Salinity at the top edge of each layer}
01105   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01106                            \textcolor{keywordtype}{intent(inout)} :: s\_b\textcolor{comment}{  !< Salinity at the bottom edge of each layer}
01107   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01108                            \textcolor{keywordtype}{intent(inout)} :: t\_t\textcolor{comment}{  !< Temperature at the top edge of each layer}
01109   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01110                            \textcolor{keywordtype}{intent(inout)} :: t\_b\textcolor{comment}{  !< Temperature at the bottom edge of each layer}
01111   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),   \textcolor{keywordtype}{intent(in)}    :: tv\textcolor{comment}{   !< thermodynamics structure}
01112   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(GV))}, &
01113                            \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{    !< layer thicknesses [H ~> m or kg m-2]}
01114   \textcolor{keywordtype}{logical},                 \textcolor{keywordtype}{intent(in)}    :: bdry\_extrap\textcolor{comment}{ !< If true, use high-order boundary}
01115 \textcolor{comment}{                                                 !! extrapolation within boundary cells}
01116 
01117   \textcolor{comment}{! Local variables}
01118   \textcolor{keywordtype}{integer} :: i, j, k
01119   \textcolor{keywordtype}{real}    :: htmp(gv%ke) \textcolor{comment}{! A 1-d copy of h [H ~> m or kg m-2]}
01120   \textcolor{keywordtype}{real}    :: tmp(gv%ke)  \textcolor{comment}{! A 1-d copy of a column of temperature [degC] or salinity [ppt]}
01121   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,2)} :: &
01122       ppol\_e            \textcolor{comment}{! Edge value of polynomial in [degC] or [ppt]}
01123   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(CS%nk,3)} :: &
01124       ppol\_coefs        \textcolor{comment}{! Coefficients of polynomial, all in [degC] or [ppt]}
01125   \textcolor{keywordtype}{real} :: h\_neglect, h\_neglect\_edge \textcolor{comment}{! Tiny thicknesses [H ~> m or kg m-2]}
01126 
01127   \textcolor{keywordflow}{if} (.not.cs%answers\_2018) \textcolor{keywordflow}{then}
01128     h\_neglect = gv%H\_subroundoff ; h\_neglect\_edge = gv%H\_subroundoff
01129   \textcolor{keywordflow}{elseif} (gv%Boussinesq) \textcolor{keywordflow}{then}
01130     h\_neglect = gv%m\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%m\_to\_H*1.0e-10
01131   \textcolor{keywordflow}{else}
01132     h\_neglect = gv%kg\_m2\_to\_H*1.0e-30 ; h\_neglect\_edge = gv%kg\_m2\_to\_H*1.0e-10
01133 \textcolor{keywordflow}{  endif}
01134 
01135   \textcolor{comment}{! Determine reconstruction within each column}
01136   \textcolor{comment}{!$OMP parallel do default(shared) private(hTmp,tmp,ppol\_E,ppol\_coefs)}
01137   \textcolor{keywordflow}{do} j = g%jsc-1,g%jec+1 ; \textcolor{keywordflow}{do} i = g%isc-1,g%iec+1
01138 
01139     \textcolor{comment}{! Build current grid}
01140     htmp(:) = h(i,j,:)
01141     tmp(:) = tv%S(i,j,:)
01142 
01143     \textcolor{comment}{! Reconstruct salinity profile}
01144     ppol\_e(:,:) = 0.0
01145     ppol\_coefs(:,:) = 0.0
01146     \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=h\_neglect\_edge, &
01147                                   answers\_2018=cs%answers\_2018 )
01148     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
01149                                   answers\_2018=cs%answers\_2018 )
01150     \textcolor{keywordflow}{if} (bdry\_extrap) &
01151       \textcolor{keyword}{call }ppm\_boundary\_extrapolation( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
01152 
01153     \textcolor{keywordflow}{do} k = 1,gv%ke
01154       s\_t(i,j,k) = ppol\_e(k,1)
01155       s\_b(i,j,k) = ppol\_e(k,2)
01156 \textcolor{keywordflow}{    enddo}
01157 
01158     \textcolor{comment}{! Reconstruct temperature profile}
01159     ppol\_e(:,:) = 0.0
01160     ppol\_coefs(:,:) = 0.0
01161     tmp(:) = tv%T(i,j,:)
01162     \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
01163       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=1.0e-10*gv%m\_to\_H, &
01164                                   answers\_2018=cs%answers\_2018 )
01165     \textcolor{keywordflow}{else}
01166       \textcolor{keyword}{call }edge\_values\_implicit\_h4( gv%ke, htmp, tmp, ppol\_e, h\_neglect=gv%H\_subroundoff, &
01167                                   answers\_2018=cs%answers\_2018 )
01168 \textcolor{keywordflow}{    endif}
01169     \textcolor{keyword}{call }ppm\_reconstruction( gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect, &
01170                                   answers\_2018=cs%answers\_2018 )
01171     \textcolor{keywordflow}{if} (bdry\_extrap) &
01172       \textcolor{keyword}{call }ppm\_boundary\_extrapolation(gv%ke, htmp, tmp, ppol\_e, ppol\_coefs, h\_neglect )
01173 
01174     \textcolor{keywordflow}{do} k = 1,gv%ke
01175       t\_t(i,j,k) = ppol\_e(k,1)
01176       t\_b(i,j,k) = ppol\_e(k,2)
01177 \textcolor{keywordflow}{    enddo}
01178 
01179 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
01180 
\end{DoxyCode}
