\hypertarget{namespacecoord__zlike}{}\doxysection{coord\+\_\+zlike Module Reference}
\label{namespacecoord__zlike}\index{coord\_zlike@{coord\_zlike}}


\doxysubsection{Detailed Description}
Regrid columns for a z-\/like coordinate (z-\/star, z-\/level) \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structcoord__zlike_1_1zlike__cs}{zlike\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure containing required parameters for a z-\/like coordinate. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacecoord__zlike_a873f4fca87825e9bb2e216348634f0a7}{init\+\_\+coord\+\_\+zlike}} (CS, nk, coordinate\+Resolution)
\begin{DoxyCompactList}\small\item\em Initialise a zlike\+\_\+\+CS with pointers to parameters. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacecoord__zlike_ad51a91fb635a0a5c29fa40bc2534f7b4}{end\+\_\+coord\+\_\+zlike}} (CS)
\begin{DoxyCompactList}\small\item\em Deallocates the zlike control structure. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacecoord__zlike_acb2336ed52c2c3ed2509450c61790753}{set\+\_\+zlike\+\_\+params}} (CS, min\+\_\+thickness)
\begin{DoxyCompactList}\small\item\em Set parameters in the zlike structure. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacecoord__zlike_af2bdac8481050f2b0ff7c5fc01f26e1c}{build\+\_\+zstar\+\_\+column}} (CS, depth, total\+\_\+thickness, z\+Interface, z\+\_\+rigid\+\_\+top, eta\+\_\+orig, z\+Scale)
\begin{DoxyCompactList}\small\item\em Builds a z$\ast$ coordinate with a minimum thickness. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacecoord__zlike_af2bdac8481050f2b0ff7c5fc01f26e1c}\label{namespacecoord__zlike_af2bdac8481050f2b0ff7c5fc01f26e1c}} 
\index{coord\_zlike@{coord\_zlike}!build\_zstar\_column@{build\_zstar\_column}}
\index{build\_zstar\_column@{build\_zstar\_column}!coord\_zlike@{coord\_zlike}}
\doxysubsubsection{\texorpdfstring{build\_zstar\_column()}{build\_zstar\_column()}}
{\footnotesize\ttfamily subroutine, public coord\+\_\+zlike\+::build\+\_\+zstar\+\_\+column (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structcoord__zlike_1_1zlike__cs}{zlike\+\_\+cs}}), intent(in)}]{CS,  }\item[{real, intent(in)}]{depth,  }\item[{real, intent(in)}]{total\+\_\+thickness,  }\item[{real, dimension(cs\%nk+1), intent(inout)}]{z\+Interface,  }\item[{real, intent(in), optional}]{z\+\_\+rigid\+\_\+top,  }\item[{real, intent(in), optional}]{eta\+\_\+orig,  }\item[{real, intent(in), optional}]{z\+Scale }\end{DoxyParamCaption})}



Builds a z$\ast$ coordinate with a minimum thickness. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em cs} & Coordinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em depth} & Depth of ocean bottom (positive downward in the output units), units may be \mbox{[}Z $\sim$$>$ m\mbox{]} or \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em total\+\_\+thickness} & Column thickness (positive definite in the same units as depth) \mbox{[}Z $\sim$$>$ m\mbox{]} or \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em zinterface} & Absolute positions of interfaces \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+rigid\+\_\+top} & The height of a rigid top (positive upward in the same units as depth) \mbox{[}Z $\sim$$>$ m\mbox{]} or \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em eta\+\_\+orig} & The actual original height of the top in the same units as depth) \mbox{[}Z $\sim$$>$ m\mbox{]} or \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em zscale} & Scaling factor from the target coordinate resolution in Z to desired units for z\+Interface, perhaps Z\+\_\+to\+\_\+H \\
\hline
\end{DoxyParams}


Definition at line 63 of file coord\+\_\+zlike.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{65   \textcolor{keywordtype}{type}(zlike\_CS),           \textcolor{keywordtype}{intent(in)}    :: CS\textcolor{comment}{ !< Coordinate control structure}}
\DoxyCodeLine{66 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: depth\textcolor{comment}{ !< Depth of ocean bottom (positive downward in the}}
\DoxyCodeLine{67 \textcolor{comment}{                                                   !! output units), units may be [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{68 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: total\_thickness\textcolor{comment}{ !< Column thickness (positive definite in the same}}
\DoxyCodeLine{69 \textcolor{comment}{                                                   !! units as depth) [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{70 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(CS\%nk+1)}, \textcolor{keywordtype}{intent(inout)} :: zInterface\textcolor{comment}{ !< Absolute positions of interfaces}}
\DoxyCodeLine{71 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional},           \textcolor{keywordtype}{intent(in)}    :: z\_rigid\_top\textcolor{comment}{ !< The height of a rigid top (positive upward in the same}}
\DoxyCodeLine{72 \textcolor{comment}{                                                   !! units as depth) [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{73 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional},           \textcolor{keywordtype}{intent(in)}    :: eta\_orig\textcolor{comment}{ !< The actual original height of the top in the same}}
\DoxyCodeLine{74 \textcolor{comment}{                                                   !! units as depth) [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{75 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional},           \textcolor{keywordtype}{intent(in)}    :: zScale\textcolor{comment}{ !< Scaling factor from the target coordinate resolution}}
\DoxyCodeLine{76 \textcolor{comment}{                                                    !! in Z to desired units for zInterface, perhaps Z\_to\_H}}
\DoxyCodeLine{77   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{78 \textcolor{keywordtype}{  real} :: eta   \textcolor{comment}{! Free surface height [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{79 \textcolor{keywordtype}{  real} :: stretching \textcolor{comment}{! A stretching factor for the coordinate [nondim]}}
\DoxyCodeLine{80 \textcolor{keywordtype}{  real} :: dh, min\_thickness, z0\_top, z\_star, z\_scale \textcolor{comment}{! Thicknesses or heights [Z \string~> m] or [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{81   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{82   \textcolor{keywordtype}{logical} :: new\_zstar\_def}
\DoxyCodeLine{83 }
\DoxyCodeLine{84   z\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(zscale)) z\_scale = zscale}
\DoxyCodeLine{85 }
\DoxyCodeLine{86   new\_zstar\_def = .false.}
\DoxyCodeLine{87   min\_thickness = min( cs\%min\_thickness, total\_thickness/real(cs\%nk) )}
\DoxyCodeLine{88   z0\_top = 0.}
\DoxyCodeLine{89   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(z\_rigid\_top)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{90     z0\_top = z\_rigid\_top}
\DoxyCodeLine{91     new\_zstar\_def = .true.}
\DoxyCodeLine{92 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{93 }
\DoxyCodeLine{94   \textcolor{comment}{! Position of free-\/surface (or the rigid top, for which eta \string~ z0\_top)}}
\DoxyCodeLine{95   eta = total\_thickness -\/ depth}
\DoxyCodeLine{96   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eta\_orig)) eta = eta\_orig}
\DoxyCodeLine{97 }
\DoxyCodeLine{98   \textcolor{comment}{! Conventional z* coordinate:}}
\DoxyCodeLine{99   \textcolor{comment}{!   z* = (z-\/eta) / stretching   where stretching = (H+eta)/H}}
\DoxyCodeLine{100   \textcolor{comment}{!   z = eta + stretching * z*}}
\DoxyCodeLine{101   \textcolor{comment}{! The above gives z*(z=eta) = 0, z*(z=-\/H) = -\/H.}}
\DoxyCodeLine{102   \textcolor{comment}{! With a rigid top boundary at eta = z0\_top then}}
\DoxyCodeLine{103   \textcolor{comment}{!   z* = z0 + (z-\/eta) / stretching   where stretching = (H+eta)/(H+z0)}}
\DoxyCodeLine{104   \textcolor{comment}{!   z = eta + stretching * (z*-\/z0) * stretching}}
\DoxyCodeLine{105   stretching = total\_thickness / ( depth + z0\_top )}
\DoxyCodeLine{106 }
\DoxyCodeLine{107   \textcolor{keywordflow}{if} (new\_zstar\_def) \textcolor{keywordflow}{then}}
\DoxyCodeLine{108     \textcolor{comment}{! z\_star is the notional z* coordinate in absence of upper/lower topography}}
\DoxyCodeLine{109     z\_star = 0. \textcolor{comment}{! z*=0 at the free-\/surface}}
\DoxyCodeLine{110     zinterface(1) = eta \textcolor{comment}{! The actual position of the top of the column}}
\DoxyCodeLine{111     \textcolor{keywordflow}{do} k = 2,cs\%nk}
\DoxyCodeLine{112       z\_star = z\_star -\/ cs\%coordinateResolution(k-\/1)*z\_scale}
\DoxyCodeLine{113       \textcolor{comment}{! This ensures that z is below a rigid upper surface (ice shelf bottom)}}
\DoxyCodeLine{114       zinterface(k) = min( eta + stretching * ( z\_star -\/ z0\_top ), z0\_top )}
\DoxyCodeLine{115       \textcolor{comment}{! This ensures that the layer in inflated}}
\DoxyCodeLine{116       zinterface(k) = min( zinterface(k), zinterface(k-\/1) -\/ min\_thickness )}
\DoxyCodeLine{117       \textcolor{comment}{! This ensures that z is above or at the topography}}
\DoxyCodeLine{118       zinterface(k) = max( zinterface(k), -\/depth + real(cs\%nk+1-\/k) * min\_thickness )}
\DoxyCodeLine{119 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{120     zinterface(cs\%nk+1) = -\/depth}
\DoxyCodeLine{121 }
\DoxyCodeLine{122   \textcolor{keywordflow}{else}}
\DoxyCodeLine{123     \textcolor{comment}{! Integrate down from the top for a notional new grid, ignoring topography}}
\DoxyCodeLine{124     \textcolor{comment}{! The starting position is offset by z0\_top which, if z0\_top<0, will place}}
\DoxyCodeLine{125     \textcolor{comment}{! interfaces above the rigid boundary.}}
\DoxyCodeLine{126     zinterface(1) = eta}
\DoxyCodeLine{127     \textcolor{keywordflow}{do} k = 1,cs\%nk}
\DoxyCodeLine{128       dh = stretching * cs\%coordinateResolution(k)*z\_scale \textcolor{comment}{! Notional grid spacing}}
\DoxyCodeLine{129       zinterface(k+1) = zinterface(k) -\/ dh}
\DoxyCodeLine{130 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{131 }
\DoxyCodeLine{132     \textcolor{comment}{! Integrating up from the bottom adjusting interface position to accommodate}}
\DoxyCodeLine{133     \textcolor{comment}{! inflating layers without disturbing the interface above}}
\DoxyCodeLine{134     zinterface(cs\%nk+1) = -\/depth}
\DoxyCodeLine{135     \textcolor{keywordflow}{do} k = cs\%nk,1,-\/1}
\DoxyCodeLine{136       \textcolor{keywordflow}{if} ( zinterface(k) < (zinterface(k+1) + min\_thickness) ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{137         zinterface(k) = zinterface(k+1) + min\_thickness}
\DoxyCodeLine{138 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{139 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{140 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{141 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacecoord__zlike_ad51a91fb635a0a5c29fa40bc2534f7b4}\label{namespacecoord__zlike_ad51a91fb635a0a5c29fa40bc2534f7b4}} 
\index{coord\_zlike@{coord\_zlike}!end\_coord\_zlike@{end\_coord\_zlike}}
\index{end\_coord\_zlike@{end\_coord\_zlike}!coord\_zlike@{coord\_zlike}}
\doxysubsubsection{\texorpdfstring{end\_coord\_zlike()}{end\_coord\_zlike()}}
{\footnotesize\ttfamily subroutine, public coord\+\_\+zlike\+::end\+\_\+coord\+\_\+zlike (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structcoord__zlike_1_1zlike__cs}{zlike\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Deallocates the zlike control structure. 


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


Definition at line 43 of file coord\+\_\+zlike.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{44   \textcolor{keywordtype}{type}(zlike\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Coordinate control structure}}
\DoxyCodeLine{45 }
\DoxyCodeLine{46   \textcolor{comment}{! Nothing to do}}
\DoxyCodeLine{47   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{48   \textcolor{keyword}{deallocate}(cs\%coordinateResolution)}
\DoxyCodeLine{49   \textcolor{keyword}{deallocate}(cs)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacecoord__zlike_a873f4fca87825e9bb2e216348634f0a7}\label{namespacecoord__zlike_a873f4fca87825e9bb2e216348634f0a7}} 
\index{coord\_zlike@{coord\_zlike}!init\_coord\_zlike@{init\_coord\_zlike}}
\index{init\_coord\_zlike@{init\_coord\_zlike}!coord\_zlike@{coord\_zlike}}
\doxysubsubsection{\texorpdfstring{init\_coord\_zlike()}{init\_coord\_zlike()}}
{\footnotesize\ttfamily subroutine, public coord\+\_\+zlike\+::init\+\_\+coord\+\_\+zlike (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structcoord__zlike_1_1zlike__cs}{zlike\+\_\+cs}}), pointer}]{CS,  }\item[{integer, intent(in)}]{nk,  }\item[{real, dimension(\+:), intent(in)}]{coordinate\+Resolution }\end{DoxyParamCaption})}



Initialise a zlike\+\_\+\+CS with pointers to parameters. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Unassociated pointer to hold the control structure \\
\hline
\mbox{\texttt{ in}}  & {\em nk} & Number of levels in the grid \\
\hline
\mbox{\texttt{ in}}  & {\em coordinateresolution} & Target coordinate resolution \mbox{[}Z $\sim$$>$ m\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 29 of file coord\+\_\+zlike.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{30   \textcolor{keywordtype}{type}(zlike\_CS),     \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< Unassociated pointer to hold the control structure}}
\DoxyCodeLine{31   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)} :: nk\textcolor{comment}{ !< Number of levels in the grid}}
\DoxyCodeLine{32 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)} :: coordinateResolution\textcolor{comment}{ !< Target coordinate resolution [Z \string~> m]}}
\DoxyCodeLine{33 }
\DoxyCodeLine{34   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}init\_coord\_zlike: CS already associated!"{}})}
\DoxyCodeLine{35   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{36   \textcolor{keyword}{allocate}(cs\%coordinateResolution(nk))}
\DoxyCodeLine{37 }
\DoxyCodeLine{38   cs\%nk                   = nk}
\DoxyCodeLine{39   cs\%coordinateResolution = coordinateresolution}

\end{DoxyCode}
\mbox{\Hypertarget{namespacecoord__zlike_acb2336ed52c2c3ed2509450c61790753}\label{namespacecoord__zlike_acb2336ed52c2c3ed2509450c61790753}} 
\index{coord\_zlike@{coord\_zlike}!set\_zlike\_params@{set\_zlike\_params}}
\index{set\_zlike\_params@{set\_zlike\_params}!coord\_zlike@{coord\_zlike}}
\doxysubsubsection{\texorpdfstring{set\_zlike\_params()}{set\_zlike\_params()}}
{\footnotesize\ttfamily subroutine, public coord\+\_\+zlike\+::set\+\_\+zlike\+\_\+params (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structcoord__zlike_1_1zlike__cs}{zlike\+\_\+cs}}), pointer}]{CS,  }\item[{real, intent(in), optional}]{min\+\_\+thickness }\end{DoxyParamCaption})}



Set parameters in the zlike structure. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Coordinate control structure \\
\hline
\mbox{\texttt{ in}}  & {\em min\+\_\+thickness} & Minimum allowed thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\end{DoxyParams}


Definition at line 53 of file coord\+\_\+zlike.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{54   \textcolor{keywordtype}{type}(zlike\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{ !< Coordinate control structure}}
\DoxyCodeLine{55 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: min\_thickness\textcolor{comment}{ !< Minimum allowed thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{56 }
\DoxyCodeLine{57   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"{}set\_zlike\_params: CS not associated"{}})}
\DoxyCodeLine{58 }
\DoxyCodeLine{59   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(min\_thickness)) cs\%min\_thickness = min\_thickness}

\end{DoxyCode}
