\hypertarget{namespacemom__unit__scaling}{}\section{mom\+\_\+unit\+\_\+scaling Module Reference}
\label{namespacemom__unit__scaling}\index{mom\+\_\+unit\+\_\+scaling@{mom\+\_\+unit\+\_\+scaling}}


\subsection{Detailed Description}
Provides a transparent unit rescaling type to facilitate dimensional consistency testing. \subsection*{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}
\subsection*{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}


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