\hypertarget{namespacemom__unit__scaling}{}\doxysection{mom\+\_\+unit\+\_\+scaling Module Reference}
\label{namespacemom__unit__scaling}\index{mom\_unit\_scaling@{mom\_unit\_scaling}}


\doxysubsection{Detailed Description}
Provides a transparent unit rescaling type to facilitate dimensional consistency testing. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}
\begin{DoxyCompactList}\small\item\em Describes various unit conversion factors. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__unit__scaling_a74867ddf628f93dcee854980e08bbe21}{unit\+\_\+scaling\+\_\+init}} (param\+\_\+file, US)
\begin{DoxyCompactList}\small\item\em Allocates and initializes the ocean model unit scaling type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__unit__scaling_a0d99ae286970838e8f4cd534e3a2744c}{fix\+\_\+restart\+\_\+unit\+\_\+scaling}} (US)
\begin{DoxyCompactList}\small\item\em Set the unit scaling factors for output to restart files to the unit scaling factors for this run. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__unit__scaling_a6b58ce1b6a08d07a84da1257cd8e8694}{unit\+\_\+scaling\+\_\+end}} (US)
\begin{DoxyCompactList}\small\item\em Deallocates a unit scaling structure. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__unit__scaling_a0d99ae286970838e8f4cd534e3a2744c}\label{namespacemom__unit__scaling_a0d99ae286970838e8f4cd534e3a2744c}} 
\index{mom\_unit\_scaling@{mom\_unit\_scaling}!fix\_restart\_unit\_scaling@{fix\_restart\_unit\_scaling}}
\index{fix\_restart\_unit\_scaling@{fix\_restart\_unit\_scaling}!mom\_unit\_scaling@{mom\_unit\_scaling}}
\doxysubsubsection{\texorpdfstring{fix\_restart\_unit\_scaling()}{fix\_restart\_unit\_scaling()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+unit\+\_\+scaling\+::fix\+\_\+restart\+\_\+unit\+\_\+scaling (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), intent(inout)}]{US }\end{DoxyParamCaption})}



Set the unit scaling factors for output to restart files to the unit scaling factors for this run. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 173 of file M\+O\+M\+\_\+unit\+\_\+scaling.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{173   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(inout)} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{174 }
\DoxyCodeLine{175   us\%m\_to\_Z\_restart = us\%m\_to\_Z}
\DoxyCodeLine{176   us\%m\_to\_L\_restart = us\%m\_to\_L}
\DoxyCodeLine{177   us\%s\_to\_T\_restart = us\%s\_to\_T}
\DoxyCodeLine{178   us\%kg\_m3\_to\_R\_restart = us\%kg\_m3\_to\_R}
\DoxyCodeLine{179   us\%J\_kg\_to\_Q\_restart = us\%J\_kg\_to\_Q}
\DoxyCodeLine{180 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__unit__scaling_a6b58ce1b6a08d07a84da1257cd8e8694}\label{namespacemom__unit__scaling_a6b58ce1b6a08d07a84da1257cd8e8694}} 
\index{mom\_unit\_scaling@{mom\_unit\_scaling}!unit\_scaling\_end@{unit\_scaling\_end}}
\index{unit\_scaling\_end@{unit\_scaling\_end}!mom\_unit\_scaling@{mom\_unit\_scaling}}
\doxysubsubsection{\texorpdfstring{unit\_scaling\_end()}{unit\_scaling\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+unit\+\_\+scaling\+::unit\+\_\+scaling\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), pointer}]{US }\end{DoxyParamCaption})}



Deallocates a unit scaling structure. 


\begin{DoxyParams}{Parameters}
{\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 185 of file M\+O\+M\+\_\+unit\+\_\+scaling.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{185   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{pointer} :: US\textcolor{comment}{ !< A dimensional unit scaling type}}
\DoxyCodeLine{186 }
\DoxyCodeLine{187   \textcolor{keyword}{deallocate}( us )}
\DoxyCodeLine{188 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__unit__scaling_a74867ddf628f93dcee854980e08bbe21}\label{namespacemom__unit__scaling_a74867ddf628f93dcee854980e08bbe21}} 
\index{mom\_unit\_scaling@{mom\_unit\_scaling}!unit\_scaling\_init@{unit\_scaling\_init}}
\index{unit\_scaling\_init@{unit\_scaling\_init}!mom\_unit\_scaling@{mom\_unit\_scaling}}
\doxysubsubsection{\texorpdfstring{unit\_scaling\_init()}{unit\_scaling\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+unit\+\_\+scaling\+::unit\+\_\+scaling\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in), optional}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\+\_\+scale\+\_\+type}}), optional, pointer}]{US }\end{DoxyParamCaption})}



Allocates and initializes the ocean model unit scaling type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & Parameter file handle/type \\
\hline
 & {\em us} & A dimensional unit scaling type \\
\hline
\end{DoxyParams}


Definition at line 57 of file M\+O\+M\+\_\+unit\+\_\+scaling.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{57   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file handle/type}}
\DoxyCodeLine{58   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer}    :: US\textcolor{comment}{         !< A dimensional unit scaling type}}
\DoxyCodeLine{59 }
\DoxyCodeLine{60   \textcolor{comment}{! This routine initializes a unit\_scale\_type structure (US).}}
\DoxyCodeLine{61 }
\DoxyCodeLine{62   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{63   \textcolor{keywordtype}{integer} :: Z\_power, L\_power, T\_power, R\_power, Q\_power}
\DoxyCodeLine{64 \textcolor{keywordtype}{  real}    :: Z\_rescale\_factor, L\_rescale\_factor, T\_rescale\_factor, R\_rescale\_factor, Q\_rescale\_factor}
\DoxyCodeLine{65   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{66 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{67 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=16)} :: mdl = \textcolor{stringliteral}{"MOM\_unit\_scaling"}}
\DoxyCodeLine{68 }
\DoxyCodeLine{69   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{present}(us)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{70 }
\DoxyCodeLine{71   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(us)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{72      \textcolor{stringliteral}{'unit\_scaling\_init: called with an associated US pointer.'})}
\DoxyCodeLine{73   \textcolor{keyword}{allocate}(us)}
\DoxyCodeLine{74 }
\DoxyCodeLine{75   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(param\_file)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{76     \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{77     \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \&}
\DoxyCodeLine{78                  \textcolor{stringliteral}{"Parameters for doing unit scaling of variables."}, debugging=.true.)}
\DoxyCodeLine{79     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"Z\_RESCALE\_POWER"}, z\_power, \&}
\DoxyCodeLine{80                  \textcolor{stringliteral}{"An integer power of 2 that is used to rescale the model's "}//\&}
\DoxyCodeLine{81                  \textcolor{stringliteral}{"internal units of depths and heights.  Valid values range from -\/300 to 300."}, \&}
\DoxyCodeLine{82                  units=\textcolor{stringliteral}{"nondim"}, default=0, debuggingparam=.true.)}
\DoxyCodeLine{83     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"L\_RESCALE\_POWER"}, l\_power, \&}
\DoxyCodeLine{84                  \textcolor{stringliteral}{"An integer power of 2 that is used to rescale the model's "}//\&}
\DoxyCodeLine{85                  \textcolor{stringliteral}{"internal units of lateral distances.  Valid values range from -\/300 to 300."}, \&}
\DoxyCodeLine{86                  units=\textcolor{stringliteral}{"nondim"}, default=0, debuggingparam=.true.)}
\DoxyCodeLine{87     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"T\_RESCALE\_POWER"}, t\_power, \&}
\DoxyCodeLine{88                  \textcolor{stringliteral}{"An integer power of 2 that is used to rescale the model's "}//\&}
\DoxyCodeLine{89                  \textcolor{stringliteral}{"internal units of time.  Valid values range from -\/300 to 300."}, \&}
\DoxyCodeLine{90                  units=\textcolor{stringliteral}{"nondim"}, default=0, debuggingparam=.true.)}
\DoxyCodeLine{91     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"R\_RESCALE\_POWER"}, r\_power, \&}
\DoxyCodeLine{92                  \textcolor{stringliteral}{"An integer power of 2 that is used to rescale the model's "}//\&}
\DoxyCodeLine{93                  \textcolor{stringliteral}{"internal units of density.  Valid values range from -\/300 to 300."}, \&}
\DoxyCodeLine{94                  units=\textcolor{stringliteral}{"nondim"}, default=0, debuggingparam=.true.)}
\DoxyCodeLine{95     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"Q\_RESCALE\_POWER"}, q\_power, \&}
\DoxyCodeLine{96                  \textcolor{stringliteral}{"An integer power of 2 that is used to rescale the model's "}//\&}
\DoxyCodeLine{97                    \textcolor{stringliteral}{"internal units of heat content.  Valid values range from -\/300 to 300."}, \&}
\DoxyCodeLine{98                    units=\textcolor{stringliteral}{"nondim"}, default=0, debuggingparam=.true.)}
\DoxyCodeLine{99   \textcolor{keywordflow}{else}}
\DoxyCodeLine{100     z\_power = 0 ; l\_power = 0 ; t\_power = 0 ; r\_power = 0 ; q\_power = 0}
\DoxyCodeLine{101 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{102 }
\DoxyCodeLine{103   \textcolor{keywordflow}{if} (abs(z\_power) > 300) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"unit\_scaling\_init: "}//\&}
\DoxyCodeLine{104                  \textcolor{stringliteral}{"Z\_RESCALE\_POWER is outside of the valid range of -\/300 to 300."})}
\DoxyCodeLine{105   \textcolor{keywordflow}{if} (abs(l\_power) > 300) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"unit\_scaling\_init: "}//\&}
\DoxyCodeLine{106                  \textcolor{stringliteral}{"L\_RESCALE\_POWER is outside of the valid range of -\/300 to 300."})}
\DoxyCodeLine{107   \textcolor{keywordflow}{if} (abs(t\_power) > 300) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"unit\_scaling\_init: "}//\&}
\DoxyCodeLine{108                  \textcolor{stringliteral}{"T\_RESCALE\_POWER is outside of the valid range of -\/300 to 300."})}
\DoxyCodeLine{109   \textcolor{keywordflow}{if} (abs(r\_power) > 300) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"unit\_scaling\_init: "}//\&}
\DoxyCodeLine{110                  \textcolor{stringliteral}{"R\_RESCALE\_POWER is outside of the valid range of -\/300 to 300."})}
\DoxyCodeLine{111   \textcolor{keywordflow}{if} (abs(q\_power) > 300) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"unit\_scaling\_init: "}//\&}
\DoxyCodeLine{112                  \textcolor{stringliteral}{"Q\_RESCALE\_POWER is outside of the valid range of -\/300 to 300."})}
\DoxyCodeLine{113 }
\DoxyCodeLine{114   z\_rescale\_factor = 1.0}
\DoxyCodeLine{115   \textcolor{keywordflow}{if} (z\_power /= 0) z\_rescale\_factor = 2.0**z\_power}
\DoxyCodeLine{116   us\%Z\_to\_m = 1.0 * z\_rescale\_factor}
\DoxyCodeLine{117   us\%m\_to\_Z = 1.0 / z\_rescale\_factor}
\DoxyCodeLine{118 }
\DoxyCodeLine{119   l\_rescale\_factor = 1.0}
\DoxyCodeLine{120   \textcolor{keywordflow}{if} (l\_power /= 0) l\_rescale\_factor = 2.0**l\_power}
\DoxyCodeLine{121   us\%L\_to\_m = 1.0 * l\_rescale\_factor}
\DoxyCodeLine{122   us\%m\_to\_L = 1.0 / l\_rescale\_factor}
\DoxyCodeLine{123 }
\DoxyCodeLine{124   t\_rescale\_factor = 1.0}
\DoxyCodeLine{125   \textcolor{keywordflow}{if} (t\_power /= 0) t\_rescale\_factor = 2.0**t\_power}
\DoxyCodeLine{126   us\%T\_to\_s = 1.0 * t\_rescale\_factor}
\DoxyCodeLine{127   us\%s\_to\_T = 1.0 / t\_rescale\_factor}
\DoxyCodeLine{128 }
\DoxyCodeLine{129   r\_rescale\_factor = 1.0}
\DoxyCodeLine{130   \textcolor{keywordflow}{if} (r\_power /= 0) r\_rescale\_factor = 2.0**r\_power}
\DoxyCodeLine{131   us\%R\_to\_kg\_m3 = 1.0 * r\_rescale\_factor}
\DoxyCodeLine{132   us\%kg\_m3\_to\_R = 1.0 / r\_rescale\_factor}
\DoxyCodeLine{133 }
\DoxyCodeLine{134   q\_rescale\_factor = 1.0}
\DoxyCodeLine{135   \textcolor{keywordflow}{if} (q\_power /= 0) q\_rescale\_factor = 2.0**q\_power}
\DoxyCodeLine{136   us\%Q\_to\_J\_kg = 1.0 * q\_rescale\_factor}
\DoxyCodeLine{137   us\%J\_kg\_to\_Q = 1.0 / q\_rescale\_factor}
\DoxyCodeLine{138 }
\DoxyCodeLine{139   \textcolor{comment}{! These are useful combinations of the fundamental scale conversion factors set above.}}
\DoxyCodeLine{140   us\%Z\_to\_L = us\%Z\_to\_m * us\%m\_to\_L}
\DoxyCodeLine{141   us\%L\_to\_Z = us\%L\_to\_m * us\%m\_to\_Z}
\DoxyCodeLine{142   \textcolor{comment}{! Horizontal velocities:}}
\DoxyCodeLine{143   us\%L\_T\_to\_m\_s = us\%L\_to\_m * us\%s\_to\_T}
\DoxyCodeLine{144   us\%m\_s\_to\_L\_T = us\%m\_to\_L * us\%T\_to\_s}
\DoxyCodeLine{145   \textcolor{comment}{! Horizontal accelerations:}}
\DoxyCodeLine{146   us\%L\_T2\_to\_m\_s2 = us\%L\_to\_m * us\%s\_to\_T**2}
\DoxyCodeLine{147     \textcolor{comment}{! It does not look like US\%m\_s2\_to\_L\_T2 would be used, so it does not exist.}}
\DoxyCodeLine{148   \textcolor{comment}{! Vertical diffusivities and viscosities:}}
\DoxyCodeLine{149   us\%Z2\_T\_to\_m2\_s = us\%Z\_to\_m**2 * us\%s\_to\_T}
\DoxyCodeLine{150   us\%m2\_s\_to\_Z2\_T = us\%m\_to\_Z**2 * us\%T\_to\_s}
\DoxyCodeLine{151   \textcolor{comment}{! Column mass loads:}}
\DoxyCodeLine{152   us\%RZ\_to\_kg\_m2  = us\%R\_to\_kg\_m3 * us\%Z\_to\_m}
\DoxyCodeLine{153     \textcolor{comment}{! It does not seem like US\%kg\_m2\_to\_RZ would be used enough in MOM6 to justify its existence.}}
\DoxyCodeLine{154   \textcolor{comment}{! Vertical mass fluxes:}}
\DoxyCodeLine{155   us\%kg\_m2s\_to\_RZ\_T = us\%kg\_m3\_to\_R * us\%m\_to\_Z * us\%T\_to\_s}
\DoxyCodeLine{156   us\%RZ\_T\_to\_kg\_m2s = us\%R\_to\_kg\_m3 * us\%Z\_to\_m * us\%s\_to\_T}
\DoxyCodeLine{157   \textcolor{comment}{! Turbulent kinetic energy vertical fluxes:}}
\DoxyCodeLine{158   us\%RZ3\_T3\_to\_W\_m2 = us\%R\_to\_kg\_m3 * us\%Z\_to\_m**3 * us\%s\_to\_T**3}
\DoxyCodeLine{159   us\%W\_m2\_to\_RZ3\_T3 = us\%kg\_m3\_to\_R * us\%m\_to\_Z**3 * us\%T\_to\_s**3}
\DoxyCodeLine{160   \textcolor{comment}{! Vertical heat fluxes:}}
\DoxyCodeLine{161   us\%W\_m2\_to\_QRZ\_T = us\%J\_kg\_to\_Q * us\%kg\_m3\_to\_R * us\%m\_to\_Z * us\%T\_to\_s}
\DoxyCodeLine{162   us\%QRZ\_T\_to\_W\_m2 = us\%Q\_to\_J\_kg * us\%R\_to\_kg\_m3 * us\%Z\_to\_m * us\%s\_to\_T}
\DoxyCodeLine{163   \textcolor{comment}{! Pressures:}}
\DoxyCodeLine{164   us\%RL2\_T2\_to\_Pa = us\%R\_to\_kg\_m3 * us\%L\_T\_to\_m\_s**2}
\DoxyCodeLine{165     \textcolor{comment}{! It does not seem like US\%Pa\_to\_RL2\_T2 would be used enough in MOM6 to justify its existence.}}
\DoxyCodeLine{166   \textcolor{comment}{! US\%Pa\_to\_RL2\_T2 = US\%kg\_m3\_to\_R * US\%m\_s\_to\_L\_T**2}}
\DoxyCodeLine{167 }

\end{DoxyCode}
