\hypertarget{MOM__EOS_8F90_source}{}\section{M\+O\+M\+\_\+\+E\+O\+S.\+F90}
\label{MOM__EOS_8F90_source}\index{/home/cermak/src/\+M\+O\+M6/src/equation\+\_\+of\+\_\+state/\+M\+O\+M\+\_\+\+E\+O\+S.\+F90@{/home/cermak/src/\+M\+O\+M6/src/equation\+\_\+of\+\_\+state/\+M\+O\+M\+\_\+\+E\+O\+S.\+F90}}

\begin{DoxyCode}
00001 \textcolor{comment}{!> Provides subroutines for quantities specific to the equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00002}\hyperlink{namespacemom__eos}{00002} \textcolor{keyword}{module} \hyperlink{namespacemom__eos}{mom\_eos}
00003 
00004 \textcolor{comment}{! This file is part of MOM6. See LICENSE.md for the license.}
00005 
00006 \textcolor{keywordtype}{use }mom\_eos\_linear\textcolor{keywordtype}{, only} : calculate\_density\_linear, calculate\_spec\_vol\_linear
00007 \textcolor{keywordtype}{use }mom\_eos\_linear\textcolor{keywordtype}{, only} : calculate\_density\_derivs\_linear
00008 \textcolor{keywordtype}{use }mom\_eos\_linear\textcolor{keywordtype}{, only} : calculate\_specvol\_derivs\_linear, int\_density\_dz\_linear
00009 \textcolor{keywordtype}{use }mom\_eos\_linear\textcolor{keywordtype}{, only} : calculate\_density\_second\_derivs\_linear
00010 \textcolor{keywordtype}{use }mom\_eos\_linear\textcolor{keywordtype}{, only} : calculate\_compress\_linear, int\_spec\_vol\_dp\_linear
00011 \textcolor{keywordtype}{use }mom\_eos\_wright\textcolor{keywordtype}{, only} : calculate\_density\_wright, calculate\_spec\_vol\_wright
00012 \textcolor{keywordtype}{use }mom\_eos\_wright\textcolor{keywordtype}{, only} : calculate\_density\_derivs\_wright
00013 \textcolor{keywordtype}{use }mom\_eos\_wright\textcolor{keywordtype}{, only} : calculate\_specvol\_derivs\_wright, int\_density\_dz\_wright
00014 \textcolor{keywordtype}{use }mom\_eos\_wright\textcolor{keywordtype}{, only} : calculate\_compress\_wright, int\_spec\_vol\_dp\_wright
00015 \textcolor{keywordtype}{use }mom\_eos\_wright\textcolor{keywordtype}{, only} : calculate\_density\_second\_derivs\_wright
00016 \textcolor{keywordtype}{use }mom\_eos\_unesco\textcolor{keywordtype}{, only} : calculate\_density\_unesco, calculate\_spec\_vol\_unesco
00017 \textcolor{keywordtype}{use }mom\_eos\_unesco\textcolor{keywordtype}{, only} : calculate\_density\_derivs\_unesco, calculate\_density\_unesco
00018 \textcolor{keywordtype}{use }mom\_eos\_unesco\textcolor{keywordtype}{, only} : calculate\_compress\_unesco
00019 \textcolor{keywordtype}{use }mom\_eos\_nemo\textcolor{keywordtype}{,   only} : calculate\_density\_nemo
00020 \textcolor{keywordtype}{use }mom\_eos\_nemo\textcolor{keywordtype}{,   only} : calculate\_density\_derivs\_nemo, calculate\_density\_nemo
00021 \textcolor{keywordtype}{use }mom\_eos\_nemo\textcolor{keywordtype}{,   only} : calculate\_compress\_nemo
00022 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : calculate\_density\_teos10, calculate\_spec\_vol\_teos10
00023 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : calculate\_density\_derivs\_teos10
00024 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : calculate\_specvol\_derivs\_teos10
00025 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : calculate\_density\_second\_derivs\_teos10
00026 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : calculate\_compress\_teos10
00027 \textcolor{keywordtype}{use }mom\_eos\_teos10\textcolor{keywordtype}{, only} : gsw\_sp\_from\_sr, gsw\_pt\_from\_ct
00028 \textcolor{keywordtype}{use }mom\_tfreeze\textcolor{keywordtype}{,    only} : calculate\_tfreeze\_linear, calculate\_tfreeze\_millero
00029 \textcolor{keywordtype}{use }mom\_tfreeze\textcolor{keywordtype}{,    only} : calculate\_tfreeze\_teos10
00030 \textcolor{keywordtype}{use }mom\_error\_handler\textcolor{keywordtype}{, only} : mom\_error, fatal, warning, mom\_mesg
00031 \textcolor{keywordtype}{use }mom\_file\_parser\textcolor{keywordtype}{, only} : get\_param, log\_version, param\_file\_type
00032 \textcolor{keywordtype}{use }mom\_hor\_index\textcolor{keywordtype}{,   only} : hor\_index\_type
00033 \textcolor{keywordtype}{use }mom\_string\_functions\textcolor{keywordtype}{, only} : uppercase
00034 \textcolor{keywordtype}{use }\hyperlink{namespacemom__unit__scaling}{mom\_unit\_scaling}\textcolor{keywordtype}{, only} : \hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}
00035 
00036 \textcolor{keywordtype}{implicit none} ; \textcolor{keywordtype}{private}
00037 
00038 \textcolor{preprocessor}{#include <MOM\_memory.h>}
00039 \textcolor{preprocessor}{}
00040 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{eos\_allocate}
00041 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a782d326108e390902e520efc078e8296}{eos\_domain}
00042 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}{eos\_end}
00043 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{eos\_init}
00044 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}{eos\_manual\_init}
00045 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\_quadrature}
00046 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}{eos\_use\_linear}
00047 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}{analytic\_int\_density\_dz}
00048 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}{analytic\_int\_specific\_vol\_dp}
00049 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__compress}{calculate\_compress}
00050 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__density}{calculate\_density}
00051 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__density__derivs}{calculate\_density\_derivs}
00052 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__density__second__derivs}{calculate\_density\_second\_derivs}
00053 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__spec__vol}{calculate\_spec\_vol}
00054 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__specific__vol__derivs}{calculate\_specific\_vol\_derivs}
00055 \textcolor{keywordtype}{public} \hyperlink{interfacemom__eos_1_1calculate__tfreeze}{calculate\_tfreeze}
00056 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}{convert\_temp\_salt\_for\_teos10}
00057 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}{extract\_member\_eos}
00058 \textcolor{keywordtype}{public} gsw\_sp\_from\_sr
00059 \textcolor{keywordtype}{public} gsw\_pt\_from\_ct
00060 \textcolor{keywordtype}{public} \hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{query\_compressible}
00061 
00062 \textcolor{comment}{! A note on unit descriptions in comments: MOM6 uses units that can be rescaled for dimensional}
00063 \textcolor{comment}{! consistency testing. These are noted in comments with units like Z, H, L, and T, along with}
00064 \textcolor{comment}{! their mks counterparts with notation like "a velocity [Z T-1 ~> m s-1]".  If the units}
00065 \textcolor{comment}{! vary with the Boussinesq approximation, the Boussinesq variant is given first.}
00066 \textcolor{comment}{}
00067 \textcolor{comment}{!> Calculates density of sea water from T, S and P}
\Hypertarget{MOM__EOS_8F90_source_l00068}\hyperlink{interfacemom__eos_1_1calculate__density}{00068} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__density}{calculate\_density}
00069   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}{calculate\_density\_scalar}, 
      \hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}, \hyperlink{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}{calculate\_density\_1d}
00070   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}{calculate\_stanley\_density\_scalar}, 
      \hyperlink{namespacemom__eos_a102df91898d116a6b4346f00dc818612}{calculate\_stanley\_density\_array}
00071   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}{calculate\_stanley\_density\_1d}
00072 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__density}{calculate\_density}
00073 \textcolor{comment}{}
00074 \textcolor{comment}{!> Calculates specific volume of sea water from T, S and P}
\Hypertarget{MOM__EOS_8F90_source_l00075}\hyperlink{interfacemom__eos_1_1calculate__spec__vol}{00075} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__spec__vol}{calculate\_spec\_vol}
00076   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}{calc\_spec\_vol\_scalar}, 
      \hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}, &
00077                    \hyperlink{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}{calc\_spec\_vol\_1d}
00078 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__spec__vol}{calculate\_spec\_vol}
00079 \textcolor{comment}{}
00080 \textcolor{comment}{!> Calculate the derivatives of density with temperature and salinity from T, S, and P}
\Hypertarget{MOM__EOS_8F90_source_l00081}\hyperlink{interfacemom__eos_1_1calculate__density__derivs}{00081} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__density__derivs}{calculate\_density\_derivs}
00082   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}{calculate\_density\_derivs\_scalar}, 
      \hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\_density\_derivs\_array}, &
00083                    \hyperlink{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}{calculate\_density\_derivs\_1d}
00084 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__density__derivs}{calculate\_density\_derivs}
00085 \textcolor{comment}{}
00086 \textcolor{comment}{!> Calculate the derivatives of specific volume with temperature and salinity from T, S, and P}
\Hypertarget{MOM__EOS_8F90_source_l00087}\hyperlink{interfacemom__eos_1_1calculate__specific__vol__derivs}{00087} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__specific__vol__derivs}{calculate\_specific\_vol\_derivs}
00088   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\_spec\_vol\_derivs\_array}, 
      \hyperlink{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}{calc\_spec\_vol\_derivs\_1d}
00089 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__specific__vol__derivs}{calculate\_specific\_vol\_derivs}
00090 \textcolor{comment}{}
00091 \textcolor{comment}{!> Calculates the second derivatives of density with various combinations of temperature,}
00092 \textcolor{comment}{!! salinity, and pressure from T, S and P}
\Hypertarget{MOM__EOS_8F90_source_l00093}\hyperlink{interfacemom__eos_1_1calculate__density__second__derivs}{00093} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__density__second__derivs}{calculate\_density\_second\_derivs}
00094   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}{calculate\_density\_second\_derivs\_scalar}, 
      \hyperlink{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}{calculate\_density\_second\_derivs\_array}
00095 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__density__second__derivs}{calculate\_density\_second\_derivs}
00096 \textcolor{comment}{}
00097 \textcolor{comment}{!> Calculates the freezing point of sea water from T, S and P}
\Hypertarget{MOM__EOS_8F90_source_l00098}\hyperlink{interfacemom__eos_1_1calculate__tfreeze}{00098} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__tfreeze}{calculate\_tfreeze}
00099   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}{calculate\_tfreeze\_scalar}, 
      \hyperlink{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}{calculate\_tfreeze\_array}
00100 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__tfreeze}{calculate\_tfreeze}
00101 \textcolor{comment}{}
00102 \textcolor{comment}{!> Calculates the compressibility of water from T, S, and P}
\Hypertarget{MOM__EOS_8F90_source_l00103}\hyperlink{interfacemom__eos_1_1calculate__compress}{00103} \textcolor{keyword}{interface} \hyperlink{interfacemom__eos_1_1calculate__compress}{calculate\_compress}
00104   \textcolor{keyword}{module procedure} \hyperlink{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}{calculate\_compress\_scalar}, 
      \hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{calculate\_compress\_array}
00105 \textcolor{keyword}{end interface }\hyperlink{interfacemom__eos_1_1calculate__compress}{calculate\_compress}
00106 \textcolor{comment}{}
00107 \textcolor{comment}{!> A control structure for the equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00108}\hyperlink{structmom__eos_1_1eos__type}{00108} \textcolor{keyword}{type}, \textcolor{keyword}{public} :: \hyperlink{structmom__eos_1_1eos__type}{eos\_type} ; \textcolor{keywordtype}{private}
\Hypertarget{MOM__EOS_8F90_source_l00109}\hyperlink{structmom__eos_1_1eos__type_a81742f0bb0c349cd480dc9ff30016188}{00109}   \textcolor{keywordtype}{integer} :: form\_of\_eos = 0\textcolor{comment}{ !< The equation of state to use.}
\Hypertarget{MOM__EOS_8F90_source_l00110}\hyperlink{structmom__eos_1_1eos__type_af279a983d343d346970f894ddf82b892}{00110}   \textcolor{keywordtype}{integer} :: form\_of\_tfreeze = 0\textcolor{comment}{ !< The expression for the potential temperature}
00111 \textcolor{comment}{                             !! of the freezing point.}
\Hypertarget{MOM__EOS_8F90_source_l00112}\hyperlink{structmom__eos_1_1eos__type_abb6d8263044f51f1c5e95f578d58d09c}{00112}   \textcolor{keywordtype}{logical} :: \hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\_quadrature}\textcolor{comment}{  !< If true, always use the generic (quadrature)}
00113 \textcolor{comment}{                             !! code for the integrals of density.}
\Hypertarget{MOM__EOS_8F90_source_l00114}\hyperlink{structmom__eos_1_1eos__type_ae7503984d8e945690334bbc7ba022806}{00114}   \textcolor{keywordtype}{logical} :: compressible = .true. \textcolor{comment}{!< If true, in situ density is a function of pressure.}
00115 \textcolor{comment}{! The following parameters are used with the linear equation of state only.}
\Hypertarget{MOM__EOS_8F90_source_l00116}\hyperlink{structmom__eos_1_1eos__type_a239964fa7b3e23c63843af1a67f0fdc3}{00116}   \textcolor{keywordtype}{real} :: rho\_t0\_s0\textcolor{comment}{ !< The density at T=0, S=0 [kg m-3]}
\Hypertarget{MOM__EOS_8F90_source_l00117}\hyperlink{structmom__eos_1_1eos__type_ad81c049585e825808864738d618e71e1}{00117}   \textcolor{keywordtype}{real} :: drho\_dt\textcolor{comment}{   !< The partial derivative of density with temperature [kg m-3 degC-1]}
\Hypertarget{MOM__EOS_8F90_source_l00118}\hyperlink{structmom__eos_1_1eos__type_af89ed9a02091eef0e888fdd95e3ef131}{00118}   \textcolor{keywordtype}{real} :: drho\_ds\textcolor{comment}{   !< The partial derivative of density with salinity [kg m-3 ppt-1]}
00119 \textcolor{comment}{! The following parameters are use with the linear expression for the freezing}
00120 \textcolor{comment}{! point only.}
\Hypertarget{MOM__EOS_8F90_source_l00121}\hyperlink{structmom__eos_1_1eos__type_a89d00515b8521923958de412c5acc261}{00121}   \textcolor{keywordtype}{real} :: tfr\_s0\_p0\textcolor{comment}{ !< The freezing potential temperature at S=0, P=0 [degC]}
\Hypertarget{MOM__EOS_8F90_source_l00122}\hyperlink{structmom__eos_1_1eos__type_a055fedf91c8e6b636ce755cf149d00e5}{00122}   \textcolor{keywordtype}{real} :: dtfr\_ds\textcolor{comment}{   !< The derivative of freezing point with salinity [degC ppt-1]}
\Hypertarget{MOM__EOS_8F90_source_l00123}\hyperlink{structmom__eos_1_1eos__type_aeca13c8f731f013c7ea0341176c4157a}{00123}   \textcolor{keywordtype}{real} :: dtfr\_dp\textcolor{comment}{   !< The derivative of freezing point with pressure [degC Pa-1]}
00124 
00125 \textcolor{comment}{! Unit conversion factors (normally used for dimensional testing but could also allow for}
00126 \textcolor{comment}{! change of units of arguments to functions)}
\Hypertarget{MOM__EOS_8F90_source_l00127}\hyperlink{structmom__eos_1_1eos__type_abcd6a593f26e89da2f49a106bf563ddb}{00127}   \textcolor{keywordtype}{real} :: m\_to\_z = 1.\textcolor{comment}{      !< A constant that translates distances in meters to the units of depth.}
\Hypertarget{MOM__EOS_8F90_source_l00128}\hyperlink{structmom__eos_1_1eos__type_a43f8688f59e2b971ce21bf87e2acc538}{00128}   \textcolor{keywordtype}{real} :: kg\_m3\_to\_r = 1.\textcolor{comment}{  !< A constant that translates kilograms per meter cubed to the units of density.}
\Hypertarget{MOM__EOS_8F90_source_l00129}\hyperlink{structmom__eos_1_1eos__type_afa0808f9aad49c18d38eae1b43ff9b85}{00129}   \textcolor{keywordtype}{real} :: r\_to\_kg\_m3 = 1.\textcolor{comment}{  !< A constant that translates the units of density to kilograms per meter cubed.}
\Hypertarget{MOM__EOS_8F90_source_l00130}\hyperlink{structmom__eos_1_1eos__type_a96840e40a8fe64d1718831823420dc05}{00130}   \textcolor{keywordtype}{real} :: rl2\_t2\_to\_pa = 1.\textcolor{comment}{!< Convert pressures from R L2 T-2 to Pa.}
\Hypertarget{MOM__EOS_8F90_source_l00131}\hyperlink{structmom__eos_1_1eos__type_adb02be322b0aeb7f25954a415f5edf81}{00131}   \textcolor{keywordtype}{real} :: l\_t\_to\_m\_s = 1.\textcolor{comment}{  !< Convert lateral velocities from L T-1 to m s-1.}
00132 
00133 \textcolor{comment}{!  logical :: test\_EOS = .true. ! If true, test the equation of state}
00134 \textcolor{keyword}{end type }\hyperlink{structmom__eos_1_1eos__type}{eos\_type}
00135 
00136 \textcolor{comment}{! The named integers that might be stored in eqn\_of\_state\_type%form\_of\_EOS.}
\Hypertarget{MOM__EOS_8F90_source_l00137}\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{00137} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}, \textcolor{keywordtype}{public} :: \hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear} = 1\textcolor{comment}{ !< A named integer specifying an equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00138}\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{00138} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}, \textcolor{keywordtype}{public} :: \hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco} = 2\textcolor{comment}{ !< A named integer specifying an equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00139}\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{00139} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}, \textcolor{keywordtype}{public} :: \hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright} = 3\textcolor{comment}{ !< A named integer specifying an equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00140}\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{00140} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}, \textcolor{keywordtype}{public} :: \hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10} = 4\textcolor{comment}{ !< A named integer specifying an equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00141}\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{00141} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter}, \textcolor{keywordtype}{public} :: \hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo}   = 5\textcolor{comment}{ !< A named integer specifying an equation of state}
00142 
\Hypertarget{MOM__EOS_8F90_source_l00143}\hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{00143} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\_linear\_string} = \textcolor{stringliteral}{"LINEAR"}\textcolor{comment}{ !< A string for specifying the
       equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00144}\hyperlink{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}{00144} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}{eos\_unesco\_string} = \textcolor{stringliteral}{"UNESCO"}\textcolor{comment}{ !< A string for specifying the
       equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00145}\hyperlink{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}{00145} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}{eos\_wright\_string} = \textcolor{stringliteral}{"WRIGHT"}\textcolor{comment}{ !< A string for specifying the
       equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00146}\hyperlink{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}{00146} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}{eos\_teos10\_string} = \textcolor{stringliteral}{"TEOS10"}\textcolor{comment}{ !< A string for specifying the
       equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00147}\hyperlink{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}{00147} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}{eos\_nemo\_string}   = \textcolor{stringliteral}{"NEMO"}\textcolor{comment}{   !< A string for specifying the
       equation of state}
\Hypertarget{MOM__EOS_8F90_source_l00148}\hyperlink{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}{00148} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}{eos\_default} = \hyperlink{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}{eos\_wright\_string} \textcolor{comment}{!< The default
       equation of state}
00149 
\Hypertarget{MOM__EOS_8F90_source_l00150}\hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{00150} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear} = 1\textcolor{comment}{  !< A named integer specifying a freezing point
       expression}
\Hypertarget{MOM__EOS_8F90_source_l00151}\hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{00151} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\_millero} = 2\textcolor{comment}{ !< A named integer specifying a freezing point
       expression}
\Hypertarget{MOM__EOS_8F90_source_l00152}\hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{00152} \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10} = 3\textcolor{comment}{  !< A named integer specifying a freezing point
       expression}
\Hypertarget{MOM__EOS_8F90_source_l00153}\hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{00153} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string} = \textcolor{stringliteral}{"LINEAR"}\textcolor{comment}{ !< A string for
       specifying the freezing point expression}
\Hypertarget{MOM__EOS_8F90_source_l00154}\hyperlink{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}{00154} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}{tfreeze\_millero\_string} = \textcolor{stringliteral}{"MILLERO\_78"}\textcolor{comment}{ !< A string for
       specifying}
00155 \textcolor{comment}{                                                              !! freezing point expression}
\Hypertarget{MOM__EOS_8F90_source_l00156}\hyperlink{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}{00156} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}{tfreeze\_teos10\_string} = \textcolor{stringliteral}{"TEOS10"}\textcolor{comment}{ !< A string for
       specifying the freezing point expression}
\Hypertarget{MOM__EOS_8F90_source_l00157}\hyperlink{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}{00157} \textcolor{keywordtype}{character*(10)}, \textcolor{keywordtype}{parameter} :: \hyperlink{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}{tfreeze\_default} = 
      \hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string} \textcolor{comment}{!< The default freezing point expression}
00158 
00159 \textcolor{keyword}{contains}
00160 \textcolor{comment}{}
00161 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density of sea water for scalar inputs.}
00162 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned.  The pressure and}
00163 \textcolor{comment}{!! density can be rescaled with the US.  If both the US and scale arguments are present the density}
00164 \textcolor{comment}{!! scaling uses the product of the two scaling factors.}
00165 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}{calculate\_density\_scalar}(T, S, pressure, rho, EOS, rho\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00166}\hyperlink{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}{00166}   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00167   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [ppt]}
00168   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00169   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~> kg
       m-3]}
00170   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{      !< Equation of state structure}
00171   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
00172   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density in}
00173 \textcolor{comment}{                                          !! combination with scaling given by US [various]}
00174 
00175   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00176   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00177 
00178   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00179     \textcolor{stringliteral}{"calculate\_density\_scalar called with an unassociated EOS\_type EOS."})
00180 
00181   p\_scale = eos%RL2\_T2\_to\_Pa
00182 
00183   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00184     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00185       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
00186                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00187     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
00188       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, p\_scale*pressure, rho, rho\_ref)
00189     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00190       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
00191     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00192       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
00193     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
00194       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, p\_scale*pressure, rho, rho\_ref)
00195 \textcolor{keywordflow}{    case default}
00196       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_scalar: EOS is not valid."})
00197 \textcolor{keywordflow}{  end select}
00198 
00199   rho\_scale = eos%kg\_m3\_to\_R
00200   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00201   rho = rho\_scale * rho
00202 
00203 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_ac3bdab784e3535d661c47d1ec8a624fd}{calculate\_density\_scalar}
00204 \textcolor{comment}{}
00205 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density of sea water for scalar inputs}
00206 \textcolor{comment}{!! including the variance of T, S and covariance of T-S.}
00207 \textcolor{comment}{!! The calculation uses only the second order correction in a series as discussed}
00208 \textcolor{comment}{!! in Stanley et al., 2020.}
00209 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned. The}
00210 \textcolor{comment}{!! density can be rescaled using rho\_ref.}
00211 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}{calculate\_stanley\_density\_scalar}(T, S, pressure, Tvar, TScov,
       Svar, rho, EOS, rho\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00212}\hyperlink{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}{00212}   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00213   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [ppt]}
00214   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: Tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the surface
       [degC2]}
00215   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: TScov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC ppt]}
00216   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: Svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00217   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa]}
00218   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~> kg
       m-3]}
00219   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{      !< Equation of state structure}
00220   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
00221   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
00222 \textcolor{comment}{                                          !! from kg m-3 to the desired units [R m3 kg-1]}
00223   \textcolor{comment}{! Local variables}
00224   \textcolor{keywordtype}{real} :: d2RdTT, d2RdST, d2RdSS, d2RdSp, d2RdTp \textcolor{comment}{! Second derivatives of density wrt T,S,p}
00225   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00226   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00227 
00228   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00229     \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar called with an unassociated EOS\_type EOS."})
00230 
00231   p\_scale = eos%RL2\_T2\_to\_Pa
00232 
00233   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00234     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00235       \textcolor{keyword}{call }calculate\_density\_linear(t, s, p\_scale*pressure, rho, &
00236                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00237       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
00238                                                   d2rdtt, d2rdsp, d2rdtp)
00239     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00240       \textcolor{keyword}{call }calculate\_density\_wright(t, s, p\_scale*pressure, rho, rho\_ref)
00241       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
00242                                                   d2rdtt, d2rdsp, d2rdtp)
00243     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00244       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, p\_scale*pressure, rho, rho\_ref)
00245       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
00246                                                   d2rdtt, d2rdsp, d2rdtp)
00247 \textcolor{keywordflow}{    case default}
00248       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
00249 \textcolor{keywordflow}{  end select}
00250 
00251   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00252   rho = rho + ( 0.5 * d2rdtt * tvar + ( d2rdst * tscov + 0.5 * d2rdss * svar ) )
00253 
00254   rho\_scale = eos%kg\_m3\_to\_R
00255   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00256   rho = rho\_scale * rho
00257 
00258 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a66d40148737ef1a3b1ae44917c7fe0c3}{calculate\_stanley\_density\_scalar}
00259 \textcolor{comment}{}
00260 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the density of sea water for 1-D array inputs.}
00261 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned.}
00262 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}(T, S, pressure, rho, start, npts, EOS, rho\_ref,
       scale)
\Hypertarget{MOM__EOS_8F90_source_l00263}\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{00263}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00265   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00266   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3] or [R ~>
       kg m-3]}
00267   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
00268   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
00269   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00270   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3]}
00271   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale
       density}
00272 \textcolor{comment}{                                                !! in combination with scaling given by US [various]}
00273   \textcolor{keywordtype}{integer} :: j
00274 
00275   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00276     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
00277 
00278   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00279     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00280       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
00281                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00282     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
00283       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, pressure, rho, start, npts, rho\_ref)
00284     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00285       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
00286     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00287       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
00288     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
00289     \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts, rho\_ref)
00290 \textcolor{keywordflow}{    case default}
00291       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_array: EOS%form\_of\_EOS is not valid."})
00292 \textcolor{keywordflow}{  end select}
00293 
00294   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
00295     rho(j) = scale * rho(j)
00296 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00297 
00298 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}
00299 \textcolor{comment}{}
00300 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the density of sea water for 1-D array inputs}
00301 \textcolor{comment}{!! including the variance of T, S and covariance of T-S.}
00302 \textcolor{comment}{!! The calculation uses only the second order correction in a series as discussed}
00303 \textcolor{comment}{!! in Stanley et al., 2020.}
00304 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned.}
00305 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a102df91898d116a6b4346f00dc818612}{calculate\_stanley\_density\_array}(T, S, pressure, Tvar, TScov,
       Svar, rho, start, npts, EOS, rho\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00306}\hyperlink{namespacemom__eos_a102df91898d116a6b4346f00dc818612}{00306}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00307   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00308   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa]}
00309   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: Tvar\textcolor{comment}{     !< Variance of potential temperature referenced to the
       surface [degC2]}
00310   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: TScov\textcolor{comment}{    !< Covariance of potential temperature and salinity [degC
       ppt]}
00311   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: Svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00312   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [kg m-3]}
00313   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Start index for computation}
00314   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< Number of point to compute}
00315   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00316   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: rho\_ref\textcolor{comment}{  !< A reference density [kg m-3].}
00317   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale density}
00318 \textcolor{comment}{                                                !! from kg m-3 to the desired units [R m3 kg-1]}
00319   \textcolor{comment}{! Local variables}
00320   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2RdTT, d2RdST, d2RdSS, d2RdSp, d2RdTp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
00321   \textcolor{keywordtype}{integer} :: j
00322 
00323   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00324     \textcolor{stringliteral}{"calculate\_density\_array called with an unassociated EOS\_type EOS."})
00325 
00326   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00327     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00328       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pressure, rho, start, npts, &
00329                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00330       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, d2rdss, d2rdst, &
00331                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00332     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00333       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pressure, rho, start, npts, rho\_ref)
00334       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, d2rdss, d2rdst, &
00335                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00336     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00337       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pressure, rho, start, npts, rho\_ref)
00338       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, d2rdss, d2rdst, &
00339                                                   d2rdtt, d2rdsp, d2rdtp, start, npts)
00340 \textcolor{keywordflow}{    case default}
00341       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_array: EOS%form\_of\_EOS is not valid."})
00342 \textcolor{keywordflow}{  end select}
00343 
00344   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00345   \textcolor{keywordflow}{do} j=start,start+npts-1
00346     rho(j) = rho(j) &
00347              + ( 0.5 * d2rdtt(j) * tvar(j) + ( d2rdst(j) * tscov(j) + 0.5 * d2rdss(j) * svar(j) ) )
00348 \textcolor{keywordflow}{  enddo}
00349 
00350   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
00351     rho(j) = scale * rho(j)
00352 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00353 
00354 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a102df91898d116a6b4346f00dc818612}{calculate\_stanley\_density\_array}
00355 \textcolor{comment}{}
00356 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the density of sea water for 1-D array inputs,}
00357 \textcolor{comment}{!! potentially limiting the domain of indices that are worked on.}
00358 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned.}
00359 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}{calculate\_density\_1d}(T, S, pressure, rho, EOS, dom, rho\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00360}\hyperlink{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}{00360}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00361   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00362   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00363   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
00364   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00365   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
00366 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00367   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
00368   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00369 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
00370   \textcolor{comment}{! Local variables}
00371   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00372   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00373   \textcolor{keywordtype}{real} :: rho\_unscale \textcolor{comment}{! A factor to convert density from R to kg m-3 [kg m-3 R-1 ~> 1]}
00374   \textcolor{keywordtype}{real} :: rho\_reference \textcolor{comment}{! rho\_ref converted to [kg m-3]}
00375   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00376   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00377 
00378   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00379     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
00380 
00381   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00382     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00383   \textcolor{keywordflow}{else}
00384     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
00385 \textcolor{keywordflow}{  endif}
00386 
00387   p\_scale = eos%RL2\_T2\_to\_Pa
00388   rho\_unscale = eos%R\_to\_kg\_m3
00389 
00390   \textcolor{keywordflow}{if} ((p\_scale == 1.0) .and. (rho\_unscale == 1.0)) \textcolor{keywordflow}{then}
00391     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}(t, s, pressure, rho, is, npts, eos, rho\_ref=rho\_ref
      )
00392   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(rho\_ref)) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the same as above, but with some extra work to rescale
       variables.}
00393     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00394     rho\_reference = rho\_unscale*rho\_ref
00395     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}(t, s, pres, rho, is, npts, eos, rho\_ref=
      rho\_reference)
00396   \textcolor{keywordflow}{else}  \textcolor{comment}{! There is rescaling of variables, but rho\_ref is not present. Passing a 0 value of rho\_ref}
00397         \textcolor{comment}{! changes answers at roundoff for some equations of state, like Wright and UNESCO.}
00398     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00399     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a3be8289c391088bdd3af78d272b92521}{calculate\_density\_array}(t, s, pres, rho, is, npts, eos)
00400 \textcolor{keywordflow}{  endif}
00401 
00402   rho\_scale = eos%kg\_m3\_to\_R
00403   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00404   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00405     rho(i) = rho\_scale * rho(i)
00406 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00407 
00408 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a2e78ade3bcba817406479cbbe3941a5f}{calculate\_density\_1d}
00409 \textcolor{comment}{}
00410 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the density of sea water for 1-D array inputs}
00411 \textcolor{comment}{!! including the variance of T, S and covariance of T-S,}
00412 \textcolor{comment}{!! potentially limiting the domain of indices that are worked on.}
00413 \textcolor{comment}{!! The calculation uses only the second order correction in a series as discussed}
00414 \textcolor{comment}{!! in Stanley et al., 2020.}
00415 \textcolor{comment}{!! If rho\_ref is present, the anomaly with respect to rho\_ref is returned.}
00416 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}{calculate\_stanley\_density\_1d}(T, S, pressure, Tvar, TScov, Svar, rho,
       EOS, dom, rho\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00417}\hyperlink{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}{00417}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00418   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00419   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00420   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: Tvar\textcolor{comment}{     !< Variance of potential temperature [degC2]}
00421   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: TScov\textcolor{comment}{    !< Covariance of potential temperature and salinity
       [degC ppt]}
00422   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: Svar\textcolor{comment}{     !< Variance of salinity [ppt2]}
00423   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< Density (in-situ if pressure is local) [R ~> kg m-3]}
00424   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00425   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
00426 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00427   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: rho\_ref\textcolor{comment}{ !< A reference density [kg m-3]}
00428   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00429 \textcolor{comment}{                                                   !! in combination with scaling given by US [various]}
00430   \textcolor{comment}{! Local variables}
00431   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00432   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00433   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(rho))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00434   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: d2RdTT, d2RdST, d2RdSS, d2RdSp, d2RdTp \textcolor{comment}{! Second derivatives of density wrt
       T,S,p}
00435   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00436 
00437   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00438     \textcolor{stringliteral}{"calculate\_density\_1d called with an unassociated EOS\_type EOS."})
00439 
00440   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00441     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00442   \textcolor{keywordflow}{else}
00443     is = 1 ; ie = \textcolor{keyword}{size}(rho) ; npts = 1 + ie - is
00444 \textcolor{keywordflow}{  endif}
00445 
00446   p\_scale = eos%RL2\_T2\_to\_Pa
00447   \textcolor{keywordflow}{do} i=is,ie
00448     pres(i) = p\_scale * pressure(i)
00449 \textcolor{keywordflow}{  enddo}
00450 
00451   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00452     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00453       \textcolor{keyword}{call }calculate\_density\_linear(t, s, pres, rho, 1, npts, &
00454                                     eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, rho\_ref)
00455       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pres, d2rdss, d2rdst, &
00456                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00457     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00458       \textcolor{keyword}{call }calculate\_density\_wright(t, s, pres, rho, 1, npts, rho\_ref)
00459       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pres, d2rdss, d2rdst, &
00460                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00461     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00462       \textcolor{keyword}{call }calculate\_density\_teos10(t, s, pres, rho, 1, npts, rho\_ref)
00463       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pres, d2rdss, d2rdst, &
00464                                                   d2rdtt, d2rdsp, d2rdtp, 1, npts)
00465 \textcolor{keywordflow}{    case default}
00466       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_stanley\_density\_scalar: EOS is not valid."})
00467 \textcolor{keywordflow}{  end select}
00468 
00469   \textcolor{comment}{! Equation 25 of Stanley et al., 2020.}
00470   \textcolor{keywordflow}{do} i=is,ie
00471     rho(i) = rho(i) &
00472              + ( 0.5 * d2rdtt(i) * tvar(i) + ( d2rdst(i) * tscov(i) + 0.5 * d2rdss(i) * svar(i) ) )
00473 \textcolor{keywordflow}{  enddo}
00474 
00475   rho\_scale = eos%kg\_m3\_to\_R
00476   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00477   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00478     rho(i) = rho\_scale * rho(i)
00479 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00480 
00481 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a58b52a452d779c53e6421aaa3eac6e8b}{calculate\_stanley\_density\_1d}
00482 \textcolor{comment}{}
00483 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the specific volume of sea water}
00484 \textcolor{comment}{!! for 1-D array inputs.}
00485 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(T, S, pressure, specvol, start, npts, EOS,
       spv\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00486}\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{00486}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< potential temperature relative to the surface [degC]}
00487   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< salinity [ppt]}
00488   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< pressure [Pa]}
00489   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: specvol\textcolor{comment}{  !< in situ specific volume [kg m-3]}
00490   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< the starting point in the arrays.}
00491   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< the number of values to calculate.}
00492   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00493   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: spv\_ref\textcolor{comment}{  !< A reference specific volume [m3 kg-1]}
00494   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale specific}
00495 \textcolor{comment}{                                                !! volume in combination with scaling given by US [various]}
00496 
00497   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(specvol))}  :: rho   \textcolor{comment}{! Density [kg m-3]}
00498   \textcolor{keywordtype}{integer} :: j
00499 
00500   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00501     \textcolor{stringliteral}{"calculate\_spec\_vol\_array called with an unassociated EOS\_type EOS."})
00502 
00503   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00504     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00505       \textcolor{keyword}{call }calculate\_spec\_vol\_linear(t, s, pressure, specvol, start, npts, &
00506                eos%rho\_T0\_S0, eos%drho\_dT, eos%drho\_dS, spv\_ref)
00507     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
00508       \textcolor{keyword}{call }calculate\_spec\_vol\_unesco(t, s, pressure, specvol, start, npts, spv\_ref)
00509     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00510       \textcolor{keyword}{call }calculate\_spec\_vol\_wright(t, s, pressure, specvol, start, npts, spv\_ref)
00511     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00512       \textcolor{keyword}{call }calculate\_spec\_vol\_teos10(t, s, pressure, specvol, start, npts, spv\_ref)
00513     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
00514       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts)
00515       \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then}
00516         specvol(:) = 1.0 / rho(:) - spv\_ref
00517       \textcolor{keywordflow}{else}
00518         specvol(:) = 1.0 / rho(:)
00519 \textcolor{keywordflow}{      endif}
00520 \textcolor{keywordflow}{    case default}
00521       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_spec\_vol\_array: EOS%form\_of\_EOS is not valid."})
00522 \textcolor{keywordflow}{  end select}
00523 
00524   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
00525     specvol(j) = scale * specvol(j)
00526 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00527 
00528 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}
00529 \textcolor{comment}{}
00530 \textcolor{comment}{!> Calls the appropriate subroutine to calculate specific volume of sea water}
00531 \textcolor{comment}{!! for scalar inputs.}
00532 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}{calc\_spec\_vol\_scalar}(T, S, pressure, specvol, EOS, spv\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00533}\hyperlink{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}{00533}   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00534   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [ppt]}
00535   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00536   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: specvol\textcolor{comment}{  !< In situ? specific volume [m3 kg-1] or [R-1 ~> m3 kg-1]}
00537   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{      !< Equation of state structure}
00538   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: spv\_ref\textcolor{comment}{  !< A reference specific volume [m3 kg-1] or [R-1 m3 kg-1]}
00539   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{    !< A multiplicative factor by which to scale specific}
00540 \textcolor{comment}{                                          !! volume in combination with scaling given by US [various]}
00541 
00542   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(1)} :: Ta, Sa, pres, spv  \textcolor{comment}{! Rescaled single element array versions of the arguments.}
00543   \textcolor{keywordtype}{real} :: spv\_reference \textcolor{comment}{! spv\_ref converted to [m3 kg-1]}
00544   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg R-1 m-3 ~>
       1]}
00545 
00546   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00547     \textcolor{stringliteral}{"calc\_spec\_vol\_scalar called with an unassociated EOS\_type EOS."})
00548 
00549   pres(1) = eos%RL2\_T2\_to\_Pa*pressure
00550   ta(1) = t ; sa(1) = s
00551 
00552   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then}
00553     spv\_reference = eos%kg\_m3\_to\_R*spv\_ref
00554     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(ta, sa, pres, spv, 1, 1, eos, spv\_reference)
00555   \textcolor{keywordflow}{else}
00556     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(ta, sa, pres, spv, 1, 1, eos)
00557 \textcolor{keywordflow}{  endif}
00558   specvol = spv(1)
00559 
00560   spv\_scale = eos%R\_to\_kg\_m3
00561   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
00562   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then}
00563     specvol = spv\_scale * specvol
00564 \textcolor{keywordflow}{  endif}
00565 
00566 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a246056e557a08ce1c697256cd718d99a}{calc\_spec\_vol\_scalar}
00567 \textcolor{comment}{}
00568 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the specific volume of sea water for 1-D array}
00569 \textcolor{comment}{!! inputs, potentially limiting the domain of indices that are worked on.}
00570 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}{calc\_spec\_vol\_1d}(T, S, pressure, specvol, EOS, dom, spv\_ref, scale)
\Hypertarget{MOM__EOS_8F90_source_l00571}\hyperlink{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}{00571}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00572   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00573   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00574   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: specvol\textcolor{comment}{  !< In situ specific volume [R-1 ~> m3 kg-1]}
00575   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00576   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
00577 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00578   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: spv\_ref\textcolor{comment}{ !< A reference specific volume [R-1 ~> m3 kg-1]}
00579   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale}
00580 \textcolor{comment}{                                                       !! output specific volume in combination with}
00581 \textcolor{comment}{                                                       !! scaling given by US [various]}
00582   \textcolor{comment}{! Local variables}
00583   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(specvol))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00584   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00585   \textcolor{keywordtype}{real} :: spv\_unscale \textcolor{comment}{! A factor to convert specific volume from R-1 to m3 kg-1 [m3 kg-1 R ~> 1]}
00586   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg m-3 R-1 ~>
       1]}
00587   \textcolor{keywordtype}{real} :: spv\_reference \textcolor{comment}{! spv\_ref converted to [m3 kg-1]}
00588   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00589 
00590   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00591     \textcolor{stringliteral}{"calc\_spec\_vol\_1d called with an unassociated EOS\_type EOS."})
00592 
00593   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00594     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00595   \textcolor{keywordflow}{else}
00596     is = 1 ; ie = \textcolor{keyword}{size}(specvol) ; npts = 1 + ie - is
00597 \textcolor{keywordflow}{  endif}
00598 
00599   p\_scale = eos%RL2\_T2\_to\_Pa
00600   spv\_unscale = eos%kg\_m3\_to\_R
00601 
00602   \textcolor{keywordflow}{if} ((p\_scale == 1.0) .and. (spv\_unscale == 1.0)) \textcolor{keywordflow}{then}
00603     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(t, s, pressure, specvol, is, npts, eos, spv\_ref)
00604   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(spv\_ref)) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the same as above, but with some extra work to rescale
       variables.}
00605     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00606     spv\_reference = spv\_unscale*spv\_ref
00607     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(t, s, pres, specvol, is, npts, eos, spv\_reference
      )
00608   \textcolor{keywordflow}{else}  \textcolor{comment}{! There is rescaling of variables, but spv\_ref is not present. Passing a 0 value of spv\_ref}
00609         \textcolor{comment}{! changes answers at roundoff for some equations of state, like Wright and UNESCO.}
00610     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00611     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a43d417da1636adb2cd184f76223afded}{calculate\_spec\_vol\_array}(t, s, pres, specvol, is, npts, eos)
00612 \textcolor{keywordflow}{  endif}
00613 
00614   spv\_scale = eos%R\_to\_kg\_m3
00615   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
00616   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00617     specvol(i) = spv\_scale * specvol(i)
00618 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00619 
00620 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_afbb6a11d3b826308ddb1ffe0c5cf32d1}{calc\_spec\_vol\_1d}
00621 
00622 \textcolor{comment}{}
00623 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the freezing point for scalar inputs.}
00624 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}{calculate\_tfreeze\_scalar}(S, pressure, T\_fr, EOS, pres\_scale)
\Hypertarget{MOM__EOS_8F90_source_l00625}\hyperlink{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}{00625}   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{ !< Salinity [ppt]}
00626   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [other]}
00627   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: T\_fr\textcolor{comment}{ !< Freezing point potential temperature referenced}
00628 \textcolor{comment}{                                      !! to the surface [degC]}
00629   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{ !< Equation of state structure}
00630   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure into Pa}
00631 
00632   \textcolor{comment}{! Local variables}
00633   \textcolor{keywordtype}{real} :: p\_scale \textcolor{comment}{! A factor to convert pressure to units of Pa.}
00634 
00635   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00636     \textcolor{stringliteral}{"calculate\_TFreeze\_scalar called with an unassociated EOS\_type EOS."})
00637 
00638   p\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) p\_scale = pres\_scale
00639 
00640   \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
00641     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear})
00642       \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, p\_scale*pressure, t\_fr, eos%TFr\_S0\_P0, &
00643                                     eos%dTFr\_dS, eos%dTFr\_dp)
00644     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\_millero})
00645       \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, p\_scale*pressure, t\_fr)
00646     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10})
00647       \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, p\_scale*pressure, t\_fr)
00648 \textcolor{keywordflow}{    case default}
00649       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
00650 \textcolor{keywordflow}{  end select}
00651 
00652 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_ad46af8402aba49dbdd73817d33e83270}{calculate\_tfreeze\_scalar}
00653 \textcolor{comment}{}
00654 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the freezing point for a 1-D array.}
00655 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}{calculate\_tfreeze\_array}(S, pressure, T\_fr, start, npts, EOS, pres\_scale)
\Hypertarget{MOM__EOS_8F90_source_l00656}\hyperlink{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}{00656}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00657   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [other]}
00658   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: T\_fr\textcolor{comment}{     !< Freezing point potential temperature referenced}
00659 \textcolor{comment}{                                                !! to the surface [degC]}
00660   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Starting index within the array}
00661   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< The number of values to calculate}
00662   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00663   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: pres\_scale\textcolor{comment}{ !< A multiplicative factor to convert pressure into Pa.}
00664 
00665   \textcolor{comment}{! Local variables}
00666   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(pressure))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00667   \textcolor{keywordtype}{real} :: p\_scale \textcolor{comment}{! A factor to convert pressure to units of Pa.}
00668   \textcolor{keywordtype}{integer} :: j
00669 
00670   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00671     \textcolor{stringliteral}{"calculate\_TFreeze\_scalar called with an unassociated EOS\_type EOS."})
00672 
00673   p\_scale = 1.0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(pres\_scale)) p\_scale = pres\_scale
00674 
00675   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
00676     \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
00677       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear})
00678         \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, pressure, t\_fr, start, npts, &
00679                                       eos%TFr\_S0\_P0, eos%dTFr\_dS, eos%dTFr\_dp)
00680       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\_millero})
00681         \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, pressure, t\_fr, start, npts)
00682       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10})
00683         \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, pressure, t\_fr, start, npts)
00684 \textcolor{keywordflow}{      case default}
00685         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
00686 \textcolor{keywordflow}{    end select}
00687   \textcolor{keywordflow}{else}
00688     \textcolor{keywordflow}{do} j=start,start+npts-1 ; pres(j) = p\_scale * pressure(j) ;\textcolor{keywordflow}{ enddo}
00689     \textcolor{keywordflow}{select case} (eos%form\_of\_TFreeze)
00690       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear})
00691         \textcolor{keyword}{call }calculate\_tfreeze\_linear(s, pres, t\_fr, start, npts, &
00692                                       eos%TFr\_S0\_P0, eos%dTFr\_dS, eos%dTFr\_dp)
00693       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\_millero})
00694         \textcolor{keyword}{call }calculate\_tfreeze\_millero(s, pres, t\_fr, start, npts)
00695       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10})
00696         \textcolor{keyword}{call }calculate\_tfreeze\_teos10(s, pres, t\_fr, start, npts)
00697 \textcolor{keywordflow}{      case default}
00698         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_TFreeze\_scalar: form\_of\_TFreeze is not valid."})
00699 \textcolor{keywordflow}{    end select}
00700 \textcolor{keywordflow}{  endif}
00701 
00702 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_ab9669ca4a2e4f3507be7efe047c18ab7}{calculate\_tfreeze\_array}
00703 \textcolor{comment}{}
00704 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.}
00705 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\_density\_derivs\_array}(T, S, pressure, drho\_dT, drho\_dS,
       start, npts, EOS, scale)
\Hypertarget{MOM__EOS_8F90_source_l00706}\hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{00706}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
00707   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00708   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00709   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dT\textcolor{comment}{  !< The partial derivative of density with potential}
00710 \textcolor{comment}{                                                !! temperature [kg m-3 degC-1] or [R degC-1 ~> kg m-3
       degC-1]}
00711   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dS\textcolor{comment}{  !< The partial derivative of density with salinity,}
00712 \textcolor{comment}{                                                !! in [kg m-3 ppt-1] or [R degC-1 ~> kg m-3 ppt-1]}
00713   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: start\textcolor{comment}{    !< Starting index within the array}
00714   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}    :: npts\textcolor{comment}{     !< The number of values to calculate}
00715   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00716   \textcolor{keywordtype}{real},     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00717 \textcolor{comment}{                                                !! in combination with scaling given by US [various]}
00718 
00719   \textcolor{comment}{! Local variables}
00720   \textcolor{keywordtype}{integer} :: j
00721 
00722   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00723     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
00724 
00725   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00726     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00727       \textcolor{keyword}{call }calculate\_density\_derivs\_linear(t, s, pressure, drho\_dt, drho\_ds, eos%Rho\_T0\_S0, &
00728                                            eos%dRho\_dT, eos%dRho\_dS, start, npts)
00729     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
00730       \textcolor{keyword}{call }calculate\_density\_derivs\_unesco(t, s, pressure, drho\_dt, drho\_ds, start, npts)
00731     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00732       \textcolor{keyword}{call }calculate\_density\_derivs\_wright(t, s, pressure, drho\_dt, drho\_ds, start, npts)
00733     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00734       \textcolor{keyword}{call }calculate\_density\_derivs\_teos10(t, s, pressure, drho\_dt, drho\_ds, start, npts)
00735     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
00736       \textcolor{keyword}{call }calculate\_density\_derivs\_nemo(t, s, pressure, drho\_dt, drho\_ds, start, npts)
00737 \textcolor{keywordflow}{    case default}
00738       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs\_array: EOS%form\_of\_EOS is not valid."})
00739 \textcolor{keywordflow}{  end select}
00740 
00741   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
00742     drho\_dt(j) = scale * drho\_dt(j)
00743     drho\_ds(j) = scale * drho\_ds(j)
00744 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif} ;\textcolor{keywordflow}{ endif}
00745 
00746 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\_density\_derivs\_array}
00747 
00748 \textcolor{comment}{}
00749 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density derivatives for 1-D array inputs.}
00750 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}{calculate\_density\_derivs\_1d}(T, S, pressure, drho\_dT, drho\_dS, EOS,
       dom, scale)
\Hypertarget{MOM__EOS_8F90_source_l00751}\hyperlink{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}{00751}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface
       [degC]}
00752   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
00753   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
00754   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: drho\_dT\textcolor{comment}{  !< The partial derivative of density with potential}
00755 \textcolor{comment}{                                                   !! temperature [R degC-1 ~> kg m-3 degC-1]}
00756   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},    \textcolor{keywordtype}{intent(inout)} :: drho\_dS\textcolor{comment}{  !< The partial derivative of density with salinity}
00757 \textcolor{comment}{                                                   !! [R degC-1 ~> kg m-3 ppt-1]}
00758   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
00759   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
00760 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
00761   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00762 \textcolor{comment}{                                                       !! in combination with scaling given by US [various]}
00763   \textcolor{comment}{! Local variables}
00764   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(drho\_dT))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00765   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00766   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00767   \textcolor{keywordtype}{integer} :: i, is, ie, npts
00768 
00769   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00770     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
00771 
00772   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
00773     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
00774   \textcolor{keywordflow}{else}
00775     is = 1 ; ie = \textcolor{keyword}{size}(drho\_dt) ; npts = 1 + ie - is
00776 \textcolor{keywordflow}{  endif}
00777 
00778   p\_scale = eos%RL2\_T2\_to\_Pa
00779 
00780   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
00781     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\_density\_derivs\_array}(t, s, pressure, drho\_dt, drho\_ds, is,
       npts, eos)
00782   \textcolor{keywordflow}{else}
00783     \textcolor{keywordflow}{do} i=is,ie ; pres(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
00784     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a27ec57cbbd2e673d542ba2c8dd44053a}{calculate\_density\_derivs\_array}(t, s, pres, drho\_dt, drho\_ds, is, 
      npts, eos)
00785 \textcolor{keywordflow}{  endif}
00786 
00787   rho\_scale = eos%kg\_m3\_to\_R
00788   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00789   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
00790     drho\_dt(i) = rho\_scale * drho\_dt(i)
00791     drho\_ds(i) = rho\_scale * drho\_ds(i)
00792 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00793 
00794 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_aed3bb20f32c038dbe84bc44442c6e724}{calculate\_density\_derivs\_1d}
00795 
00796 \textcolor{comment}{}
00797 \textcolor{comment}{!> Calls the appropriate subroutines to calculate density derivatives by promoting a scalar}
00798 \textcolor{comment}{!! to a one-element array}
00799 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}{calculate\_density\_derivs\_scalar}(T, S, pressure, drho\_dT, drho\_dS,
       EOS, scale)
\Hypertarget{MOM__EOS_8F90_source_l00800}\hyperlink{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}{00800}   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
00801   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{ !< Salinity [ppt]}
00802   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00803   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: drho\_dT\textcolor{comment}{ !< The partial derivative of density with potential}
00804 \textcolor{comment}{                                         !! temperature [kg m-3 degC-1] or [R degC-1 ~> kg m-3 degC-1]}
00805   \textcolor{keywordtype}{real},           \textcolor{keywordtype}{intent(out)} :: drho\_dS\textcolor{comment}{ !< The partial derivative of density with salinity,}
00806 \textcolor{comment}{                                         !! in [kg m-3 ppt-1] or [R ppt-1 ~> kg m-3 ppt-1]}
00807   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{     !< Equation of state structure}
00808   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: scale\textcolor{comment}{   !< A multiplicative factor by which to scale density}
00809 \textcolor{comment}{                                         !! in combination with scaling given by US [various]}
00810   \textcolor{comment}{! Local variables}
00811   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00812   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00813   \textcolor{keywordtype}{integer} :: j
00814 
00815   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00816     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
00817 
00818   p\_scale = eos%RL2\_T2\_to\_Pa
00819 
00820   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00821     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00822       \textcolor{keyword}{call }calculate\_density\_derivs\_linear(t, s, p\_scale*pressure, drho\_dt, drho\_ds, &
00823                                            eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
00824     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00825       \textcolor{keyword}{call }calculate\_density\_derivs\_wright(t, s, p\_scale*pressure, drho\_dt, drho\_ds)
00826     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00827       \textcolor{keyword}{call }calculate\_density\_derivs\_teos10(t, s, p\_scale*pressure, drho\_dt, drho\_ds)
00828 \textcolor{keywordflow}{    case default}
00829       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs\_scalar: EOS%form\_of\_EOS is not valid."})
00830 \textcolor{keywordflow}{  end select}
00831 
00832   rho\_scale = eos%kg\_m3\_to\_R
00833   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00834   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
00835     drho\_dt = rho\_scale * drho\_dt
00836     drho\_ds = rho\_scale * drho\_ds
00837 \textcolor{keywordflow}{  endif}
00838 
00839 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a06d9d6680e838b965666986e63c980e7}{calculate\_density\_derivs\_scalar}
00840 \textcolor{comment}{}
00841 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density second derivatives for 1-D array inputs.}
00842 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}{calculate\_density\_second\_derivs\_array}(T, S, pressure,
       drho\_dS\_dS, drho\_dS\_dT, drho\_dT\_dT, &
00843                                                  drho\_dS\_dP, drho\_dT\_dP, start, npts, EOS, scale)
\Hypertarget{MOM__EOS_8F90_source_l00844}\hyperlink{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}{00844}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
00845   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{ !< Salinity [ppt]}
00846   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{   !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00847   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dS\_dS\textcolor{comment}{ !< Partial derivative of beta with respect to S}
00848 \textcolor{comment}{                                                  !!  [kg m-3 ppt-2] or [R ppt-2 ~> kg m-3 ppt-2]}
00849   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dS\_dT\textcolor{comment}{ !< Partial derivative of beta with respect to T}
00850 \textcolor{comment}{                                                  !! [kg m-3 ppt-1 degC-1] or [R ppt-1 degC-1 ~> kg m-3
       ppt-1 degC-1]}
00851   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dT\_dT\textcolor{comment}{ !< Partial derivative of alpha with respect to T}
00852 \textcolor{comment}{                                                  !! [kg m-3 degC-2] or [R degC-2 ~> kg m-3 degC-2]}
00853   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dS\_dP\textcolor{comment}{ !< Partial derivative of beta with respect to pressure}
00854 \textcolor{comment}{                                                  !! [kg m-3 ppt-1 Pa-1] or [R ppt-1 Pa-1 ~> kg m-3 ppt-1
       Pa-1]}
00855   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dT\_dP\textcolor{comment}{ !< Partial derivative of alpha with respect to pressure}
00856 \textcolor{comment}{                                                  !! [kg m-3 degC-1 Pa-1] or [R degC-1 Pa-1 ~> kg m-3
       degC-1 Pa-1]}
00857   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{ !< Starting index within the array}
00858   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{  !< The number of values to calculate}
00859   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{   !< Equation of state structure}
00860   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00861 \textcolor{comment}{                                                  !! in combination with scaling given by US [various]}
00862   \textcolor{comment}{! Local variables}
00863   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(pressure))} :: pres  \textcolor{comment}{! Pressure converted to [Pa]}
00864   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00865   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00866   \textcolor{keywordtype}{real} :: I\_p\_scale \textcolor{comment}{! The inverse of the factor to convert pressure to units of Pa [R L2 T-2 Pa-1 ~> 1]}
00867   \textcolor{keywordtype}{integer} :: j
00868 
00869   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00870     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
00871 
00872   p\_scale = eos%RL2\_T2\_to\_Pa
00873 
00874   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
00875     \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00876       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00877         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
00878                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00879       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00880         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
00881                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00882       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00883         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pressure, drho\_ds\_ds, drho\_ds\_dt, &
00884                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00885 \textcolor{keywordflow}{      case default}
00886         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
00887 \textcolor{keywordflow}{    end select}
00888   \textcolor{keywordflow}{else}
00889     \textcolor{keywordflow}{do} j=start,start+npts-1 ; pres(j) = p\_scale * pressure(j) ;\textcolor{keywordflow}{ enddo}
00890     \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00891       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00892         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
00893                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00894       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00895         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
00896                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00897       \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00898         \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, pres, drho\_ds\_ds, drho\_ds\_dt, &
00899                                                     drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp, start, npts)
00900 \textcolor{keywordflow}{      case default}
00901         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
00902 \textcolor{keywordflow}{    end select}
00903 \textcolor{keywordflow}{  endif}
00904 
00905   rho\_scale = eos%kg\_m3\_to\_R
00906   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00907   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=start,start+npts-1
00908     drho\_ds\_ds(j) = rho\_scale * drho\_ds\_ds(j)
00909     drho\_ds\_dt(j) = rho\_scale * drho\_ds\_dt(j)
00910     drho\_dt\_dt(j) = rho\_scale * drho\_dt\_dt(j)
00911     drho\_ds\_dp(j) = rho\_scale * drho\_ds\_dp(j)
00912     drho\_dt\_dp(j) = rho\_scale * drho\_dt\_dp(j)
00913 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
00914 
00915   \textcolor{keywordflow}{if} (p\_scale /= 1.0) \textcolor{keywordflow}{then}
00916     i\_p\_scale = 1.0 / p\_scale
00917     \textcolor{keywordflow}{do} j=start,start+npts-1
00918       drho\_ds\_dp(j) = i\_p\_scale * drho\_ds\_dp(j)
00919       drho\_dt\_dp(j) = i\_p\_scale * drho\_dt\_dp(j)
00920 \textcolor{keywordflow}{    enddo}
00921 \textcolor{keywordflow}{  endif}
00922 
00923 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a8c0fa67a7a4911eb5fa33c5d17b997f9}{calculate\_density\_second\_derivs\_array}
00924 \textcolor{comment}{}
00925 \textcolor{comment}{!> Calls the appropriate subroutine to calculate density second derivatives for scalar nputs.}
00926 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}{calculate\_density\_second\_derivs\_scalar}(T, S, pressure,
       drho\_dS\_dS, drho\_dS\_dT, drho\_dT\_dT, &
00927                                                   drho\_dS\_dP, drho\_dT\_dP, EOS, scale)
\Hypertarget{MOM__EOS_8F90_source_l00928}\hyperlink{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}{00928}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
00929   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{ !< Salinity [ppt]}
00930   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{   !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
00931   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dS\_dS\textcolor{comment}{ !< Partial derivative of beta with respect to S}
00932 \textcolor{comment}{                                  !! [kg m-3 ppt-2] or [R ppt-2 ~> kg m-3 ppt-2]}
00933   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dS\_dT\textcolor{comment}{ !< Partial derivative of beta with respect to T}
00934 \textcolor{comment}{                                  !! [kg m-3 ppt-1 degC-1] or [R ppt-1 degC-1 ~> kg m-3 ppt-1 degC-1]}
00935   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dT\_dT\textcolor{comment}{ !< Partial derivative of alpha with respect to T}
00936 \textcolor{comment}{                                  !! [kg m-3 degC-2] or [R degC-2 ~> kg m-3 degC-2]}
00937   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dS\_dP\textcolor{comment}{ !< Partial derivative of beta with respect to pressure}
00938 \textcolor{comment}{                                  !! [kg m-3 ppt-1 Pa-1] or [R ppt-1 Pa-1 ~> kg m-3 ppt-1 Pa-1]}
00939   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)} :: drho\_dT\_dP\textcolor{comment}{ !< Partial derivative of alpha with respect to pressure}
00940 \textcolor{comment}{                                  !! [kg m-3 degC-1 Pa-1] or [R degC-1 Pa-1 ~> kg m-3 degC-1 Pa-1]}
00941   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer}    :: EOS\textcolor{comment}{ !< Equation of state structure}
00942   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale density}
00943 \textcolor{comment}{                                  !! in combination with scaling given by US [various]}
00944   \textcolor{comment}{! Local variables}
00945   \textcolor{keywordtype}{real} :: rho\_scale \textcolor{comment}{! A factor to convert density from kg m-3 to the desired units [R m3 kg-1 ~> 1]}
00946   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
00947   \textcolor{keywordtype}{real} :: I\_p\_scale \textcolor{comment}{! The inverse of the factor to convert pressure to units of Pa [R L2 T-2 Pa-1 ~> 1]}
00948 
00949   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
00950     \textcolor{stringliteral}{"calculate\_density\_derivs called with an unassociated EOS\_type EOS."})
00951 
00952   p\_scale = eos%RL2\_T2\_to\_Pa
00953 
00954   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
00955     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
00956       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_linear(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
00957                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
00958     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
00959       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_wright(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
00960                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
00961     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
00962       \textcolor{keyword}{call }calculate\_density\_second\_derivs\_teos10(t, s, p\_scale*pressure, drho\_ds\_ds, drho\_ds\_dt, &
00963                                                   drho\_dt\_dt, drho\_ds\_dp, drho\_dt\_dp)
00964 \textcolor{keywordflow}{    case default}
00965       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_density\_derivs: EOS%form\_of\_EOS is not valid."})
00966 \textcolor{keywordflow}{  end select}
00967 
00968   rho\_scale = eos%kg\_m3\_to\_R
00969   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) rho\_scale = rho\_scale * scale
00970   \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
00971     drho\_ds\_ds = rho\_scale * drho\_ds\_ds
00972     drho\_ds\_dt = rho\_scale * drho\_ds\_dt
00973     drho\_dt\_dt = rho\_scale * drho\_dt\_dt
00974     drho\_ds\_dp = rho\_scale * drho\_ds\_dp
00975     drho\_dt\_dp = rho\_scale * drho\_dt\_dp
00976 \textcolor{keywordflow}{  endif}
00977 
00978   \textcolor{keywordflow}{if} (p\_scale /= 1.0) \textcolor{keywordflow}{then}
00979     i\_p\_scale = 1.0 / p\_scale
00980     drho\_ds\_dp = i\_p\_scale * drho\_ds\_dp
00981     drho\_dt\_dp = i\_p\_scale * drho\_dt\_dp
00982 \textcolor{keywordflow}{  endif}
00983 
00984 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a2d7a984ed1c48d9e0ea1046de3eac886}{calculate\_density\_second\_derivs\_scalar}
00985 \textcolor{comment}{}
00986 \textcolor{comment}{!> Calls the appropriate subroutine to calculate specific volume derivatives for an array.}
00987 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\_spec\_vol\_derivs\_array}(T, S, pressure, dSV\_dT, dSV\_dS,
       start, npts, EOS)
\Hypertarget{MOM__EOS_8F90_source_l00988}\hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{00988}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{ !< Potential temperature referenced to the surface [degC]}
00989   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{ !< Salinity [ppt]}
00990   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: pressure\textcolor{comment}{ !< Pressure [Pa]}
00991   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dSV\_dT\textcolor{comment}{ !< The partial derivative of specific volume with potential}
00992 \textcolor{comment}{                                              !! temperature [m3 kg-1 degC-1]}
00993   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dSV\_dS\textcolor{comment}{ !< The partial derivative of specific volume with salinity}
00994 \textcolor{comment}{                                              !! [m3 kg-1 ppt-1]}
00995   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{  !< Starting index within the array}
00996   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{   !< The number of values to calculate}
00997   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{    !< Equation of state structure}
00998 
00999   \textcolor{comment}{! Local variables}
01000   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: press   \textcolor{comment}{! Pressure converted to [Pa]}
01001   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: rho     \textcolor{comment}{! In situ density [kg m-3]}
01002   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: dRho\_dT \textcolor{comment}{! Derivative of density with temperature [kg m-3 degC-1]}
01003   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(T))} :: dRho\_dS \textcolor{comment}{! Derivative of density with salinity [kg m-3 ppt-1]}
01004   \textcolor{keywordtype}{integer} :: j
01005 
01006   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01007     \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_array called with an unassociated EOS\_type EOS."})
01008 
01009   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
01010     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
01011       \textcolor{keyword}{call }calculate\_specvol\_derivs\_linear(t, s, pressure, dsv\_dt, dsv\_ds, start, &
01012                                            npts, eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
01013     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
01014       \textcolor{keyword}{call }calculate\_density\_unesco(t, s, pressure, rho, start, npts)
01015       \textcolor{keyword}{call }calculate\_density\_derivs\_unesco(t, s, pressure, drho\_dt, drho\_ds, start, npts)
01016       \textcolor{keywordflow}{do} j=start,start+npts-1
01017         dsv\_dt(j) = -drho\_dt(j)/(rho(j)**2)
01018         dsv\_ds(j) = -drho\_ds(j)/(rho(j)**2)
01019 \textcolor{keywordflow}{      enddo}
01020     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
01021       \textcolor{keyword}{call }calculate\_specvol\_derivs\_wright(t, s, pressure, dsv\_dt, dsv\_ds, start, npts)
01022     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
01023       \textcolor{keyword}{call }calculate\_specvol\_derivs\_teos10(t, s, pressure, dsv\_dt, dsv\_ds, start, npts)
01024     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
01025       \textcolor{keyword}{call }calculate\_density\_nemo(t, s, pressure, rho, start, npts)
01026       \textcolor{keyword}{call }calculate\_density\_derivs\_nemo(t, s, pressure, drho\_dt, drho\_ds, start, npts)
01027       \textcolor{keywordflow}{do} j=start,start+npts-1
01028         dsv\_dt(j) = -drho\_dt(j)/(rho(j)**2)
01029         dsv\_ds(j) = -drho\_ds(j)/(rho(j)**2)
01030 \textcolor{keywordflow}{      enddo}
01031 \textcolor{keywordflow}{    case default}
01032       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_array: EOS%form\_of\_EOS is not valid."})
01033 \textcolor{keywordflow}{  end select}
01034 
01035 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\_spec\_vol\_derivs\_array}
01036 \textcolor{comment}{}
01037 \textcolor{comment}{!> Calls the appropriate subroutine to calculate specific volume derivatives for 1-d array inputs,}
01038 \textcolor{comment}{!! potentially limiting the domain of indices that are worked on.}
01039 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}{calc\_spec\_vol\_derivs\_1d}(T, S, pressure, dSV\_dT, dSV\_dS, EOS, dom, scale)
\Hypertarget{MOM__EOS_8F90_source_l01040}\hyperlink{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}{01040}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
01041   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: S\textcolor{comment}{        !< Salinity [ppt]}
01042   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}    :: pressure\textcolor{comment}{ !< Pressure [R L2 T-2 ~> Pa]}
01043   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dSV\_dT\textcolor{comment}{   !< The partial derivative of specific volume with potential}
01044 \textcolor{comment}{                                                !! temperature [R-1 degC-1 ~> m3 kg-1 degC-1]}
01045   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: dSV\_dS\textcolor{comment}{   !< The partial derivative of specific volume with salinity}
01046 \textcolor{comment}{                                                !! [R-1 ppt-1 ~> m3 kg-1 ppt-1]}
01047   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{      !< Equation of state structure}
01048   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dom\textcolor{comment}{   !< The domain of indices to work on, taking}
01049 \textcolor{comment}{                                                       !! into account that arrays start at 1.}
01050   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: scale\textcolor{comment}{ !< A multiplicative factor by which to scale
       specific}
01051 \textcolor{comment}{                                                !! volume in combination with scaling given by US [various]}
01052 
01053   \textcolor{comment}{! Local variables}
01054   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(dSV\_dT))} :: press   \textcolor{comment}{! Pressure converted to [Pa]}
01055   \textcolor{keywordtype}{real} :: spv\_scale \textcolor{comment}{! A factor to convert specific volume from m3 kg-1 to the desired units [kg R-1 m-3 ~>
       1]}
01056   \textcolor{keywordtype}{real} :: p\_scale   \textcolor{comment}{! A factor to convert pressure to units of Pa [Pa T2 R-1 L-2 ~> 1]}
01057   \textcolor{keywordtype}{integer} :: i, is, ie, npts
01058 
01059   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01060     \textcolor{stringliteral}{"calculate\_spec\_vol\_derivs\_1d called with an unassociated EOS\_type EOS."})
01061 
01062   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dom)) \textcolor{keywordflow}{then}
01063     is = dom(1) ; ie = dom(2) ; npts = 1 + ie - is
01064   \textcolor{keywordflow}{else}
01065     is = 1 ; ie = \textcolor{keyword}{size}(dsv\_dt) ; npts = 1 + ie - is
01066 \textcolor{keywordflow}{  endif}
01067   p\_scale = eos%RL2\_T2\_to\_Pa
01068 
01069   \textcolor{keywordflow}{if} (p\_scale == 1.0) \textcolor{keywordflow}{then}
01070     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\_spec\_vol\_derivs\_array}(t, s, pressure, dsv\_dt, dsv\_ds, is,
       npts, eos)
01071   \textcolor{keywordflow}{else}
01072     \textcolor{keywordflow}{do} i=is,ie ; press(i) = p\_scale * pressure(i) ;\textcolor{keywordflow}{ enddo}
01073     \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a35f9c33d1aeffbf9986349463bab3b9c}{calculate\_spec\_vol\_derivs\_array}(t, s, press, dsv\_dt, dsv\_ds, is, 
      npts, eos)
01074 \textcolor{keywordflow}{  endif}
01075 
01076   spv\_scale = eos%R\_to\_kg\_m3
01077   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) spv\_scale = spv\_scale * scale
01078   \textcolor{keywordflow}{if} (spv\_scale /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
01079     dsv\_dt(i) = spv\_scale * dsv\_dt(i)
01080     dsv\_ds(i) = spv\_scale * dsv\_ds(i)
01081 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
01082 
01083 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a640c3b2292afd3266caa11243549bbf0}{calc\_spec\_vol\_derivs\_1d}
01084 
01085 \textcolor{comment}{}
01086 \textcolor{comment}{!> Calls the appropriate subroutine to calculate the density and compressibility for 1-D array}
01087 \textcolor{comment}{!! inputs.  If US is present, the units of the inputs and outputs are rescaled.}
01088 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{calculate\_compress\_array}(T, S, press, rho, drho\_dp, start, npts, EOS)
\Hypertarget{MOM__EOS_8F90_source_l01089}\hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{01089}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
01090   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{        !< Salinity [PSU]}
01091   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(in)}  :: press\textcolor{comment}{    !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
01092   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: rho\textcolor{comment}{      !< In situ density [kg m-3] or [R ~> kg m-3]}
01093   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(inout)} :: drho\_dp\textcolor{comment}{  !< The partial derivative of density with pressure}
01094 \textcolor{comment}{                                                !! (also the inverse of the square of sound speed)}
01095 \textcolor{comment}{                                                !! [s2 m-2] or [T2 L-2]}
01096   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: start\textcolor{comment}{    !< Starting index within the array}
01097   \textcolor{keywordtype}{integer},            \textcolor{keywordtype}{intent(in)}  :: npts\textcolor{comment}{     !< The number of values to calculate}
01098   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),     \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{      !< Equation of state structure}
01099 
01100   \textcolor{comment}{! Local variables}
01101   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(size(press))} :: pressure  \textcolor{comment}{! Pressure converted to [Pa]}
01102   \textcolor{keywordtype}{integer} :: i, is, ie
01103 
01104   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01105     \textcolor{stringliteral}{"calculate\_compress called with an unassociated EOS\_type EOS."})
01106 
01107   is = start ; ie = is + npts - 1
01108   \textcolor{keywordflow}{do} i=is,ie ; pressure(i) = eos%RL2\_T2\_to\_Pa * press(i) ;\textcolor{keywordflow}{ enddo}
01109 
01110   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
01111     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
01112       \textcolor{keyword}{call }calculate\_compress\_linear(t, s, pressure, rho, drho\_dp, start, npts, &
01113                                      eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS)
01114     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco})
01115       \textcolor{keyword}{call }calculate\_compress\_unesco(t, s, pressure, rho, drho\_dp, start, npts)
01116     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
01117       \textcolor{keyword}{call }calculate\_compress\_wright(t, s, pressure, rho, drho\_dp, start, npts)
01118     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10})
01119       \textcolor{keyword}{call }calculate\_compress\_teos10(t, s, pressure, rho, drho\_dp, start, npts)
01120     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})
01121       \textcolor{keyword}{call }calculate\_compress\_nemo(t, s, pressure, rho, drho\_dp, start, npts)
01122 \textcolor{keywordflow}{    case default}
01123       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"calculate\_compress: EOS%form\_of\_EOS is not valid."})
01124 \textcolor{keywordflow}{  end select}
01125 
01126   \textcolor{keywordflow}{if} (eos%kg\_m3\_to\_R /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
01127     rho(i) = eos%kg\_m3\_to\_R * rho(i)
01128 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
01129   \textcolor{keywordflow}{if} (eos%L\_T\_to\_m\_s /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} i=is,ie
01130     drho\_dp(i) = eos%L\_T\_to\_m\_s**2 * drho\_dp(i)
01131 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ endif}
01132 
01133 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{calculate\_compress\_array}
01134 \textcolor{comment}{}
01135 \textcolor{comment}{!> Calculate density and compressibility for a scalar. This just promotes the scalar to an array}
01136 \textcolor{comment}{!! with a singleton dimension and calls calculate\_compress\_array.  If US is present, the units of}
01137 \textcolor{comment}{!! the inputs and outputs are rescaled.}
01138 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}{calculate\_compress\_scalar}(T, S, pressure, rho, drho\_dp, EOS)
\Hypertarget{MOM__EOS_8F90_source_l01139}\hyperlink{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}{01139}   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: T\textcolor{comment}{        !< Potential temperature referenced to the surface [degC]}
01140   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: S\textcolor{comment}{        !< Salinity [ppt]}
01141   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(in)}        :: pressure\textcolor{comment}{ !< Pressure [Pa] or [R L2 T-2 ~> Pa]}
01142   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)}       :: rho\textcolor{comment}{      !< In situ density [kg m-3] or [R ~> kg m-3]}
01143   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{intent(out)}       :: drho\_dp\textcolor{comment}{  !< The partial derivative of density with pressure (also the}
01144 \textcolor{comment}{                                      !! inverse of the square of sound speed) [s2 m-2] or [T2 L-2]}
01145   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer} :: EOS\textcolor{comment}{      !< Equation of state structure}
01146 
01147   \textcolor{comment}{! Local variables}
01148   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(1)} :: Ta, Sa, pa, rhoa, drho\_dpa
01149 
01150   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01151     \textcolor{stringliteral}{"calculate\_compress called with an unassociated EOS\_type EOS."})
01152   ta(1) = t ; sa(1) = s; pa(1) = pressure
01153 
01154   \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a3296609bd60bfe7ed2c5eac1170d07a3}{calculate\_compress\_array}(ta, sa, pa, rhoa, drho\_dpa, 1, 1, eos)
01155   rho = rhoa(1) ; drho\_dp = drho\_dpa(1)
01156 
01157 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_ad0986d800c26414dbd19d2b3a541e613}{calculate\_compress\_scalar}
01158 
01159 \textcolor{comment}{}
01160 \textcolor{comment}{!> This subroutine returns a two point integer array indicating the domain of i-indices}
01161 \textcolor{comment}{!! to work on in EOS calls based on information from a hor\_index type}
01162 \textcolor{keyword}{function }\hyperlink{namespacemom__eos_a782d326108e390902e520efc078e8296}{eos\_domain}(HI, halo) \textcolor{keyword}{result}(EOSdom)
\Hypertarget{MOM__EOS_8F90_source_l01163}\hyperlink{namespacemom__eos_a782d326108e390902e520efc078e8296}{01163}   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI\textcolor{comment}{    !< The horizontal index structure}
01164   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\textcolor{comment}{  !< The halo size to work on; missing is equivalent to 0.}
01165   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(2)} :: EOSdom\textcolor{comment}{   !< The index domain that the EOS will work on, taking into account}
01166 \textcolor{comment}{                                    !! that the arrays inside the EOS routines will start at 1.}
01167 
01168   \textcolor{comment}{! Local variables}
01169   \textcolor{keywordtype}{integer} :: halo\_sz
01170 
01171   halo\_sz = 0 ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(halo)) halo\_sz = halo
01172 
01173   eosdom(1) = hi%isc - (hi%isd-1) - halo\_sz
01174   eosdom(2) = hi%iec - (hi%isd-1) + halo\_sz
01175 
01176 \textcolor{keyword}{end function }\hyperlink{namespacemom__eos_a782d326108e390902e520efc078e8296}{eos\_domain}
01177 
01178 \textcolor{comment}{}
01179 \textcolor{comment}{!> Calls the appropriate subroutine to calculate analytical and nearly-analytical}
01180 \textcolor{comment}{!! integrals in pressure across layers of geopotential anomalies, which are}
01181 \textcolor{comment}{!! required for calculating the finite-volume form pressure accelerations in a}
01182 \textcolor{comment}{!! non-Boussinesq model.  There are essentially no free assumptions, apart from the}
01183 \textcolor{comment}{!! use of Boole's rule to do the horizontal integrals, and from a truncation in the}
01184 \textcolor{comment}{!! series for log(1-eps/1+eps) that assumes that |eps| < 0.34.}
01185 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}{analytic\_int\_specific\_vol\_dp}(T, S, p\_t, p\_b, alpha\_ref, HI, EOS, &
01186                                dza, intp\_dza, intx\_dza, inty\_dza, halo\_size, &
01187                                bathyP, dP\_tiny, useMassWghtInterp)
\Hypertarget{MOM__EOS_8F90_source_l01188}\hyperlink{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}{01188}   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI\textcolor{comment}{  !< The horizontal index structure}
01189   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01190                         \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
01191   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01192                         \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{   !< Salinity [ppt]}
01193   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01194                         \textcolor{keywordtype}{intent(in)}  :: p\_t\textcolor{comment}{ !< Pressure at the top of the layer [R L2 T-2 ~> Pa] or [Pa]}
01195   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01196                         \textcolor{keywordtype}{intent(in)}  :: p\_b\textcolor{comment}{ !< Pressure at the bottom of the layer [R L2 T-2 ~> Pa] or [Pa]}
01197   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: alpha\_ref\textcolor{comment}{ !< A mean specific volume that is subtracted out}
01198 \textcolor{comment}{                            !! to reduce the magnitude of each of the integrals [R-1 ~> m3 kg-1]}
01199 \textcolor{comment}{                            !! The calculation is mathematically identical with different values of}
01200 \textcolor{comment}{                            !! alpha\_ref, but this reduces the effects of roundoff.}
01201   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),       \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{ !< Equation of state structure}
01202   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01203                         \textcolor{keywordtype}{intent(inout)} :: dza\textcolor{comment}{ !< The change in the geopotential anomaly across}
01204 \textcolor{comment}{                            !! the layer [L2 T-2 ~> m2 s-2] or [m2 s-2]}
01205   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01206               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intp\_dza\textcolor{comment}{ !< The integral in pressure through the layer of the}
01207 \textcolor{comment}{                            !! geopotential anomaly relative to the anomaly at the bottom of the}
01208 \textcolor{comment}{                            !! layer [R L4 T-4 ~> Pa m2 s-2] or [Pa m2 s-2]}
01209   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed)}, &
01210               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dza\textcolor{comment}{ !< The integral in x of the difference between the}
01211 \textcolor{comment}{                            !! geopotential anomaly at the top and bottom of the layer divided by}
01212 \textcolor{comment}{                            !! the x grid spacing [L2 T-2 ~> m2 s-2] or [m2 s-2]}
01213   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB)}, &
01214               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dza\textcolor{comment}{ !< The integral in y of the difference between the}
01215 \textcolor{comment}{                            !! geopotential anomaly at the top and bottom of the layer divided by}
01216 \textcolor{comment}{                            !! the y grid spacing [L2 T-2 ~> m2 s-2] or [m2 s-2]}
01217   \textcolor{keywordtype}{integer},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: halo\_size\textcolor{comment}{ !< The width of halo points on which to calculate dza.}
01218   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01219               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyP\textcolor{comment}{  !< The pressure at the bathymetry [R L2 T-2 ~> Pa] or [Pa]}
01220   \textcolor{keywordtype}{real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dP\_tiny\textcolor{comment}{ !< A miniscule pressure change with}
01221 \textcolor{comment}{                            !! the same units as p\_t [R L2 T-2 ~> Pa] or [Pa]}
01222   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: useMassWghtInterp\textcolor{comment}{ !< If true, uses mass weighting}
01223 \textcolor{comment}{                            !! to interpolate T/S for top and bottom integrals.}
01224   \textcolor{comment}{! Local variables}
01225   \textcolor{keywordtype}{real} :: pres\_scale    \textcolor{comment}{! A unit conversion factor from the rescaled units of pressure to Pa [Pa T2 R-1 L-2
       ~> 1]}
01226   \textcolor{keywordtype}{real} :: SV\_scale      \textcolor{comment}{! A multiplicative factor by which to scale specific}
01227                         \textcolor{comment}{! volume from m3 kg-1 to the desired units [kg m-3 R-1 ~> 1]}
01228 
01229   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01230     \textcolor{stringliteral}{"int\_specific\_vol\_dp called with an unassociated EOS\_type EOS."})
01231 
01232   \textcolor{comment}{! We should never reach this point with quadrature. EOS\_quadrature indicates that numerical}
01233   \textcolor{comment}{! integration be used instead of analytic. This is a safety check.}
01234   \textcolor{keywordflow}{if} (eos%EOS\_quadrature) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"EOS\_quadrature is set!"})
01235 
01236   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
01237     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
01238       \textcolor{keyword}{call }int\_spec\_vol\_dp\_linear(t, s, p\_t, p\_b, alpha\_ref, hi, eos%kg\_m3\_to\_R*eos%Rho\_T0\_S0, &
01239                                 eos%kg\_m3\_to\_R*eos%dRho\_dT, eos%kg\_m3\_to\_R*eos%dRho\_dS, dza, &
01240                                 intp\_dza, intx\_dza, inty\_dza, halo\_size, &
01241                                 bathyp, dp\_tiny, usemasswghtinterp)
01242     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
01243       \textcolor{keyword}{call }int\_spec\_vol\_dp\_wright(t, s, p\_t, p\_b, alpha\_ref, hi, dza, intp\_dza, intx\_dza, &
01244                                   inty\_dza, halo\_size, bathyp, dp\_tiny, usemasswghtinterp, &
01245                                   sv\_scale=eos%R\_to\_kg\_m3, pres\_scale=eos%RL2\_T2\_to\_Pa)
01246 \textcolor{keywordflow}{    case default}
01247       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"No analytic integration option is available with this EOS!"})
01248 \textcolor{keywordflow}{  end select}
01249 
01250 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a09b6cb637246b8aa287ef7cdb482aaea}{analytic\_int\_specific\_vol\_dp}
01251 \textcolor{comment}{}
01252 \textcolor{comment}{!> This subroutine calculates analytical and nearly-analytical integrals of}
01253 \textcolor{comment}{!! pressure anomalies across layers, which are required for calculating the}
01254 \textcolor{comment}{!! finite-volume form pressure accelerations in a Boussinesq model.}
01255 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}{analytic\_int\_density\_dz}(T, S, z\_t, z\_b, rho\_ref, rho\_0, G\_e, HI, EOS,
       dpa, &
01256                           intz\_dpa, intx\_dpa, inty\_dpa, bathyT, dz\_neglect, useMassWghtInterp)
\Hypertarget{MOM__EOS_8F90_source_l01257}\hyperlink{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}{01257}   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{intent(in)}  :: HI\textcolor{comment}{ !< Ocean horizontal index structure}
01258   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01259                         \textcolor{keywordtype}{intent(in)}  :: T\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
01260   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01261                         \textcolor{keywordtype}{intent(in)}  :: S\textcolor{comment}{   !< Salinity [ppt]}
01262   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01263                         \textcolor{keywordtype}{intent(in)}  :: z\_t\textcolor{comment}{ !< Height at the top of the layer in depth units [Z ~> m]}
01264   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01265                         \textcolor{keywordtype}{intent(in)}  :: z\_b\textcolor{comment}{ !< Height at the bottom of the layer [Z ~> m]}
01266   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_ref\textcolor{comment}{ !< A mean density [R ~> kg m-3] or [kg m-3], that is}
01267 \textcolor{comment}{                                           !! subtracted out to reduce the magnitude of each of the}
01268 \textcolor{comment}{                                           !! integrals.}
01269   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: rho\_0\textcolor{comment}{ !< A density [R ~> kg m-3] or [kg m-3], that is used}
01270 \textcolor{comment}{                                           !! to calculate the pressure (as p~=-z*rho\_0*G\_e)}
01271 \textcolor{comment}{                                           !! used in the equation of state.}
01272   \textcolor{keywordtype}{real},                 \textcolor{keywordtype}{intent(in)}  :: G\_e\textcolor{comment}{ !< The Earth's gravitational acceleration}
01273 \textcolor{comment}{                                           !! [L2 Z-1 T-2 ~> m s-2] or [m2 Z-1 s-2 ~> m s-2]}
01274   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),       \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{ !< Equation of state structure}
01275   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01276                       \textcolor{keywordtype}{intent(inout)} :: dpa\textcolor{comment}{ !< The change in the pressure anomaly}
01277 \textcolor{comment}{                                           !! across the layer [R L2 T-2 ~> Pa] or [Pa]}
01278   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01279             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intz\_dpa\textcolor{comment}{ !< The integral through the thickness of the}
01280 \textcolor{comment}{                                           !! layer of the pressure anomaly relative to the}
01281 \textcolor{comment}{                                           !! anomaly at the top of the layer [R L2 Z T-2 ~> Pa m]}
01282   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%IsdB:HI%IedB,HI%jsd:HI%jed)}, &
01283             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: intx\_dpa\textcolor{comment}{ !< The integral in x of the difference between}
01284 \textcolor{comment}{                                          !! the pressure anomaly at the top and bottom of the}
01285 \textcolor{comment}{                                          !! layer divided by the x grid spacing [R L2 T-2 ~> Pa]}
01286   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%JsdB:HI%JedB)}, &
01287             \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(inout)} :: inty\_dpa\textcolor{comment}{ !< The integral in y of the difference between}
01288 \textcolor{comment}{                                          !! the pressure anomaly at the top and bottom of the}
01289 \textcolor{comment}{                                          !! layer divided by the y grid spacing [R L2 T-2 ~> Pa]}
01290   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed)}, &
01291               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: bathyT\textcolor{comment}{ !< The depth of the bathymetry [Z ~> m]}
01292   \textcolor{keywordtype}{real},       \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: dz\_neglect\textcolor{comment}{ !< A miniscule thickness change [Z ~> m]}
01293   \textcolor{keywordtype}{logical},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: useMassWghtInterp\textcolor{comment}{ !< If true, uses mass weighting to}
01294 \textcolor{comment}{                                           !! interpolate T/S for top and bottom integrals.}
01295   \textcolor{comment}{! Local variables}
01296   \textcolor{keywordtype}{real} :: rho\_scale  \textcolor{comment}{! A multiplicative factor by which to scale density from kg m-3 to the}
01297                      \textcolor{comment}{! desired units [R m3 kg-1 ~> 1]}
01298   \textcolor{keywordtype}{real} :: pres\_scale \textcolor{comment}{! A multiplicative factor to convert pressure into Pa [Pa T2 R-1 L-2 ~> 1]}
01299 
01300   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01301     \textcolor{stringliteral}{"int\_density\_dz called with an unassociated EOS\_type EOS."})
01302 
01303   \textcolor{comment}{! We should never reach this point with quadrature. EOS\_quadrature indicates that numerical}
01304   \textcolor{comment}{! integration be used instead of analytic. This is a safety check.}
01305   \textcolor{keywordflow}{if} (eos%EOS\_quadrature) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"EOS\_quadrature is set!"})
01306 
01307   \textcolor{keywordflow}{select case} (eos%form\_of\_EOS)
01308     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear})
01309       rho\_scale = eos%kg\_m3\_to\_R
01310       \textcolor{keywordflow}{if} (rho\_scale /= 1.0) \textcolor{keywordflow}{then}
01311         \textcolor{keyword}{call }int\_density\_dz\_linear(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
01312                          rho\_scale*eos%Rho\_T0\_S0, rho\_scale*eos%dRho\_dT, rho\_scale*eos%dRho\_dS, &
01313                          dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, dz\_neglect, usemasswghtinterp)
01314       \textcolor{keywordflow}{else}
01315         \textcolor{keyword}{call }int\_density\_dz\_linear(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
01316                          eos%Rho\_T0\_S0, eos%dRho\_dT, eos%dRho\_dS, &
01317                          dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, dz\_neglect, usemasswghtinterp)
01318 \textcolor{keywordflow}{      endif}
01319     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright})
01320       rho\_scale = eos%kg\_m3\_to\_R
01321       pres\_scale = eos%RL2\_T2\_to\_Pa
01322       \textcolor{keywordflow}{if} ((rho\_scale /= 1.0) .or. (pres\_scale /= 1.0)) \textcolor{keywordflow}{then}
01323         \textcolor{keyword}{call }int\_density\_dz\_wright(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
01324                                    dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, &
01325                                    dz\_neglect, usemasswghtinterp, rho\_scale, pres\_scale)
01326       \textcolor{keywordflow}{else}
01327         \textcolor{keyword}{call }int\_density\_dz\_wright(t, s, z\_t, z\_b, rho\_ref, rho\_0, g\_e, hi, &
01328                                    dpa, intz\_dpa, intx\_dpa, inty\_dpa, bathyt, &
01329                                    dz\_neglect, usemasswghtinterp)
01330 \textcolor{keywordflow}{      endif}
01331 \textcolor{keywordflow}{    case default}
01332       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"No analytic integration option is available with this EOS!"})
01333 \textcolor{keywordflow}{  end select}
01334 
01335 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a2787233a5f7a0935206ba2cf4c278aab}{analytic\_int\_density\_dz}
01336 \textcolor{comment}{}
01337 \textcolor{comment}{!> Returns true if the equation of state is compressible (i.e. has pressure dependence)}
01338 \textcolor{keyword}{logical }\textcolor{keyword}{function }\hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{query\_compressible}(EOS)
\Hypertarget{MOM__EOS_8F90_source_l01339}\hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{01339}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer} :: EOS\textcolor{comment}{ !< Equation of state structure}
01340 
01341   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01342     \textcolor{stringliteral}{"query\_compressible called with an unassociated EOS\_type EOS."})
01343 
01344   \hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{query\_compressible} = eos%compressible
01345 \textcolor{keyword}{end function }\hyperlink{namespacemom__eos_aee169aee0e4cbed420782d772282bb69}{query\_compressible}
01346 \textcolor{comment}{}
01347 \textcolor{comment}{!> Initializes EOS\_type by allocating and reading parameters}
01348 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{eos\_init}(param\_file, EOS, US)
\Hypertarget{MOM__EOS_8F90_source_l01349}\hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{01349}   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< Parameter file structure}
01350   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}    :: EOS\textcolor{comment}{ !< Equation of state structure}
01351   \textcolor{keywordtype}{type}(\hyperlink{structmom__unit__scaling_1_1unit__scale__type}{unit\_scale\_type}), \textcolor{keywordtype}{intent(in)} :: US\textcolor{comment}{  !< A dimensional unit scaling type}
01352   \textcolor{keywordtype}{optional} :: us
01353   \textcolor{comment}{! Local variables}
01354 \textcolor{preprocessor}{#include "version\_variable.h"}
01355 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_EOS"} \textcolor{comment}{! This module's name.}
01356   \textcolor{keywordtype}{character(len=40)}  :: tmpstr
01357 
01358   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }\hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{eos\_allocate}(eos)
01359 
01360   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
01361   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
01362 
01363   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EQN\_OF\_STATE"}, tmpstr, &
01364                  \textcolor{stringliteral}{"EQN\_OF\_STATE determines which ocean equation of state "}//&
01365                  \textcolor{stringliteral}{"should be used.  Currently, the valid choices are "}//&
01366                  \textcolor{stringliteral}{'"LINEAR", "UNESCO", "WRIGHT", "NEMO" and "TEOS10". '}//&
01367                  \textcolor{stringliteral}{"This is only used if USE\_EOS is true."}, default=\hyperlink{namespacemom__eos_a3d4e14a920e46cac8cec72c79690de7c}{eos\_default})
01368   \textcolor{keywordflow}{select case} (uppercase(tmpstr))
01369     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\_linear\_string})
01370       eos%form\_of\_EOS = \hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear}
01371     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_aa725e4d064e1dd5cb0c6208096ad05fe}{eos\_unesco\_string})
01372       eos%form\_of\_EOS = \hyperlink{namespacemom__eos_a9eacc16ba79dc66131b54bf31114f35a}{eos\_unesco}
01373     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_acacee5907ae295a83b1a9b65175d5a1e}{eos\_wright\_string})
01374       eos%form\_of\_EOS = \hyperlink{namespacemom__eos_a4bbd0f276fe3878bd01b3ff180fb41c5}{eos\_wright}
01375     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9dc2b7c2c67a47b336de4db21b0c9cf5}{eos\_teos10\_string})
01376       eos%form\_of\_EOS = \hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10}
01377     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a9348dc6c296a8dad0fe5cf27e47119a5}{eos\_nemo\_string})
01378       eos%form\_of\_EOS = \hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo}
01379 \textcolor{keywordflow}{    case default}
01380       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection: EQN\_OF\_STATE "}//&
01381                               trim(tmpstr) // \textcolor{stringliteral}{"in input file is invalid."})
01382 \textcolor{keywordflow}{  end select}
01383   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'interpret\_eos\_selection: equation of state set to "'} // &
01384                 trim(tmpstr)//\textcolor{stringliteral}{'"'}, 5)
01385 
01386   \textcolor{keywordflow}{if} (eos%form\_of\_EOS == \hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear}) \textcolor{keywordflow}{then}
01387     eos%Compressible = .false.
01388     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_T0\_S0"}, eos%Rho\_T0\_S0, &
01389                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(\hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\_linear\_string})//\textcolor{stringliteral}{", "}//&
01390                  \textcolor{stringliteral}{"this is the density at T=0, S=0."}, units=\textcolor{stringliteral}{"kg m-3"}, &
01391                  default=1000.0)
01392     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRHO\_DT"}, eos%dRho\_dT, &
01393                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(\hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\_linear\_string})//\textcolor{stringliteral}{", "}//&
01394                  \textcolor{stringliteral}{"this is the partial derivative of density with "}//&
01395                  \textcolor{stringliteral}{"temperature."}, units=\textcolor{stringliteral}{"kg m-3 K-1"}, default=-0.2)
01396     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DRHO\_DS"}, eos%dRho\_dS, &
01397                  \textcolor{stringliteral}{"When EQN\_OF\_STATE="}//trim(\hyperlink{namespacemom__eos_adba0a32cc2c8f110e58447a29bf885d3}{eos\_linear\_string})//\textcolor{stringliteral}{", "}//&
01398                  \textcolor{stringliteral}{"this is the partial derivative of density with "}//&
01399                  \textcolor{stringliteral}{"salinity."}, units=\textcolor{stringliteral}{"kg m-3 PSU-1"}, default=0.8)
01400 \textcolor{keywordflow}{  endif}
01401 
01402   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EOS\_QUADRATURE"}, eos%EOS\_quadrature, &
01403                  \textcolor{stringliteral}{"If true, always use the generic (quadrature) code "}//&
01404                  \textcolor{stringliteral}{"code for the integrals of density."}, default=.false.)
01405 
01406   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_FORM"}, tmpstr, &
01407                  \textcolor{stringliteral}{"TFREEZE\_FORM determines which expression should be "}//&
01408                  \textcolor{stringliteral}{"used for the freezing point.  Currently, the valid "}//&
01409                  \textcolor{stringliteral}{'choices are "LINEAR", "MILLERO\_78", "TEOS10"'}, &
01410                  default=\hyperlink{namespacemom__eos_a26afc0610c00badaeedddf818c0dc48c}{tfreeze\_default})
01411   \textcolor{keywordflow}{select case} (uppercase(tmpstr))
01412     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string})
01413       eos%form\_of\_TFreeze = \hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear}
01414     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_a3922b6088618d34983c6125e0aa553ad}{tfreeze\_millero\_string})
01415       eos%form\_of\_TFreeze = \hyperlink{namespacemom__eos_a7f361d35806d25ac361fea713b7f0b6f}{tfreeze\_millero}
01416     \textcolor{keywordflow}{case} (\hyperlink{namespacemom__eos_ad96b484fe337e2c37b2b11bcd3cbd7af}{tfreeze\_teos10\_string})
01417       eos%form\_of\_TFreeze = \hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10}
01418 \textcolor{keywordflow}{    case default}
01419       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection:  TFREEZE\_FORM "}//&
01420                               trim(tmpstr) // \textcolor{stringliteral}{"in input file is invalid."})
01421 \textcolor{keywordflow}{  end select}
01422 
01423   \textcolor{keywordflow}{if} (eos%form\_of\_TFreeze == \hyperlink{namespacemom__eos_adcc45ec5c82aaef0aa4d330fa8cbc5c5}{tfreeze\_linear}) \textcolor{keywordflow}{then}
01424     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TFREEZE\_S0\_P0"},eos%TFr\_S0\_P0, &
01425                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(\hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string})//\textcolor{stringliteral}{", "}//&
01426                  \textcolor{stringliteral}{"this is the freezing potential temperature at "}//&
01427                  \textcolor{stringliteral}{"S=0, P=0."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)
01428     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DS"},eos%dTFr\_dS, &
01429                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(\hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string})//\textcolor{stringliteral}{", "}//&
01430                  \textcolor{stringliteral}{"this is the derivative of the freezing potential "}//&
01431                  \textcolor{stringliteral}{"temperature with salinity."}, &
01432                  units=\textcolor{stringliteral}{"deg C PSU-1"}, default=-0.054)
01433     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DTFREEZE\_DP"},eos%dTFr\_dP, &
01434                  \textcolor{stringliteral}{"When TFREEZE\_FORM="}//trim(\hyperlink{namespacemom__eos_ae3ee69a3e4a38b6925b121e3f34d8a15}{tfreeze\_linear\_string})//\textcolor{stringliteral}{", "}//&
01435                  \textcolor{stringliteral}{"this is the derivative of the freezing potential "}//&
01436                  \textcolor{stringliteral}{"temperature with pressure."}, &
01437                  units=\textcolor{stringliteral}{"deg C Pa-1"}, default=0.0)
01438 \textcolor{keywordflow}{  endif}
01439 
01440   \textcolor{keywordflow}{if} ((eos%form\_of\_EOS == \hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10} .OR. eos%form\_of\_EOS == \hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo}) .AND. &
01441       eos%form\_of\_TFreeze /= \hyperlink{namespacemom__eos_abf1f6edc79b67730c9f47e5645069eda}{tfreeze\_teos10}) \textcolor{keywordflow}{then}
01442       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"interpret\_eos\_selection:  EOS\_TEOS10 or EOS\_NEMO \(\backslash\)n"} //&
01443       \textcolor{stringliteral}{"should only be used along with TFREEZE\_FORM = TFREEZE\_TEOS10 ."})
01444 \textcolor{keywordflow}{  endif}
01445 
01446   \textcolor{comment}{! Unit conversions}
01447   eos%m\_to\_Z = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%m\_to\_Z = us%m\_to\_Z
01448   eos%kg\_m3\_to\_R = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%kg\_m3\_to\_R = us%kg\_m3\_to\_R
01449   eos%R\_to\_kg\_m3 = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%R\_to\_kg\_m3 = us%R\_to\_kg\_m3
01450   eos%RL2\_T2\_to\_Pa = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%RL2\_T2\_to\_Pa = us%RL2\_T2\_to\_Pa
01451   eos%L\_T\_to\_m\_s = 1. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(us)) eos%L\_T\_to\_m\_s = us%L\_T\_to\_m\_s
01452 
01453 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a3ab220b9c98dac3b8f6b7c1606b811cf}{eos\_init}
01454 \textcolor{comment}{}
01455 \textcolor{comment}{!> Manually initialized an EOS type (intended for unit testing of routines which need a specific EOS)}
01456 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}{eos\_manual\_init}(EOS, form\_of\_EOS, form\_of\_TFreeze, EOS\_quadrature, Compressible,
       &
01457                            Rho\_T0\_S0, drho\_dT, dRho\_dS, TFr\_S0\_P0, dTFr\_dS, dTFr\_dp)
\Hypertarget{MOM__EOS_8F90_source_l01458}\hyperlink{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}{01458}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),    \textcolor{keywordtype}{pointer}    :: EOS\textcolor{comment}{ !< Equation of state structure}
01459   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: form\_of\_EOS\textcolor{comment}{ !< A coded integer indicating the equation of state to use.}
01460   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: form\_of\_TFreeze\textcolor{comment}{ !< A coded integer indicating the expression for}
01461 \textcolor{comment}{                                       !! the potential temperature of the freezing point.}
01462   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: EOS\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
01463 \textcolor{comment}{                                       !! code for the integrals of density.}
01464   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: Compressible\textcolor{comment}{  !< If true, in situ density is a function of pressure.}
01465   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: Rho\_T0\_S0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
01466   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: drho\_dT\textcolor{comment}{   !< Partial derivative of density with temperature}
01467 \textcolor{comment}{                                             !! in [kg m-3 degC-1]}
01468   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dRho\_dS\textcolor{comment}{   !< Partial derivative of density with salinity}
01469 \textcolor{comment}{                                             !! in [kg m-3 ppt-1]}
01470   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: TFr\_S0\_P0\textcolor{comment}{ !< The freezing potential temperature at S=0, P=0 [degC]}
01471   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dTFr\_dS\textcolor{comment}{   !< The derivative of freezing point with salinity}
01472 \textcolor{comment}{                                             !! in [degC ppt-1]}
01473   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dTFr\_dp\textcolor{comment}{   !< The derivative of freezing point with pressure}
01474 \textcolor{comment}{                                             !! in [degC Pa-1]}
01475 
01476   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_eos    ))  eos%form\_of\_EOS     = form\_of\_eos
01477   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_tfreeze))  eos%form\_of\_TFreeze = form\_of\_tfreeze
01478   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eos\_quadrature ))  eos%EOS\_quadrature  = eos\_quadrature
01479   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compressible   ))  eos%Compressible    = compressible
01480   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_t0\_s0      ))  eos%Rho\_T0\_S0       = rho\_t0\_s0
01481   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_dt        ))  eos%drho\_dT         = drho\_dt
01482   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_ds        ))  eos%dRho\_dS         = drho\_ds
01483   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tfr\_s0\_p0      ))  eos%TFr\_S0\_P0       = tfr\_s0\_p0
01484   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_ds        ))  eos%dTFr\_dS         = dtfr\_ds
01485   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_dp        ))  eos%dTFr\_dp         = dtfr\_dp
01486 
01487 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a949f5bb0744c827bf11cca01316ceed4}{eos\_manual\_init}
01488 \textcolor{comment}{}
01489 \textcolor{comment}{!> Allocates EOS\_type}
01490 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{eos\_allocate}(EOS)
\Hypertarget{MOM__EOS_8F90_source_l01491}\hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{01491}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer} :: EOS\textcolor{comment}{ !< Equation of state structure}
01492 
01493   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{allocate}(eos)
01494 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a1108fb5de7a69d01746df3995f7e3f0d}{eos\_allocate}
01495 \textcolor{comment}{}
01496 \textcolor{comment}{!> Deallocates EOS\_type}
01497 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}{eos\_end}(EOS)
\Hypertarget{MOM__EOS_8F90_source_l01498}\hyperlink{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}{01498}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}), \textcolor{keywordtype}{pointer} :: EOS\textcolor{comment}{ !< Equation of state structure}
01499 
01500   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{deallocate}(eos)
01501 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_acab6a23bef0a98f15f0a479bdd1ec63c}{eos\_end}
01502 \textcolor{comment}{}
01503 \textcolor{comment}{!> Set equation of state structure (EOS) to linear with given coefficients}
01504 \textcolor{comment}{!!}
01505 \textcolor{comment}{!! \(\backslash\)note This routine is primarily for testing and allows a local copy of the}
01506 \textcolor{comment}{!! EOS\_type (EOS argument) to be set to use the linear equation of state}
01507 \textcolor{comment}{!! independent from the rest of the model.}
01508 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}{eos\_use\_linear}(Rho\_T0\_S0, dRho\_dT, dRho\_dS, EOS, use\_quadrature)
\Hypertarget{MOM__EOS_8F90_source_l01509}\hyperlink{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}{01509}   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: Rho\_T0\_S0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
01510   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: dRho\_dT\textcolor{comment}{   !< Partial derivative of density with temperature [kg m-3
       degC-1]}
01511   \textcolor{keywordtype}{real},              \textcolor{keywordtype}{intent(in)} :: dRho\_dS\textcolor{comment}{   !< Partial derivative of density with salinity [kg m-3 ppt-1]}
01512   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: use\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
01513 \textcolor{comment}{                                             !! code for the integrals of density.}
01514   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),    \textcolor{keywordtype}{pointer}    :: EOS\textcolor{comment}{       !< Equation of state structure}
01515 
01516   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01517     \textcolor{stringliteral}{"MOM\_EOS.F90: EOS\_use\_linear() called with an unassociated EOS\_type EOS."})
01518 
01519   eos%form\_of\_EOS = \hyperlink{namespacemom__eos_a230a2f280b1e27ee913e1b3cf4c412b8}{eos\_linear}
01520   eos%Compressible = .false.
01521   eos%Rho\_T0\_S0 = rho\_t0\_s0
01522   eos%dRho\_dT = drho\_dt
01523   eos%dRho\_dS = drho\_ds
01524   eos%EOS\_quadrature = .false.
01525   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(use\_quadrature)) eos%EOS\_quadrature = use\_quadrature
01526 
01527 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_ae608600501a98f8f317d8f27a054327e}{eos\_use\_linear}
01528 
01529 \textcolor{comment}{}
01530 \textcolor{comment}{!> Convert T&S to Absolute Salinity and Conservative Temperature if using TEOS10}
01531 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}{convert\_temp\_salt\_for\_teos10}(T, S, HI, kd, mask\_z, EOS)
\Hypertarget{MOM__EOS_8F90_source_l01532}\hyperlink{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}{01532}   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: kd\textcolor{comment}{  !< The number of layers to work on}
01533   \textcolor{keywordtype}{type}(hor\_index\_type),  \textcolor{keywordtype}{intent(in)}    :: HI\textcolor{comment}{       !< The horizontal index structure}
01534   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
01535                          \textcolor{keywordtype}{intent(inout)} :: T\textcolor{comment}{   !< Potential temperature referenced to the surface [degC]}
01536   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
01537                          \textcolor{keywordtype}{intent(inout)} :: S\textcolor{comment}{   !< Salinity [ppt]}
01538   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(HI%isd:HI%ied,HI%jsd:HI%jed,kd)}, &
01539                          \textcolor{keywordtype}{intent(in)}    :: mask\_z\textcolor{comment}{ !< 3d mask regulating which points to convert.}
01540   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),        \textcolor{keywordtype}{pointer}       :: EOS\textcolor{comment}{ !< Equation of state structure}
01541 
01542   \textcolor{keywordtype}{integer} :: i, j, k
01543   \textcolor{keywordtype}{real} :: gsw\_sr\_from\_sp, gsw\_ct\_from\_pt, gsw\_sa\_from\_sp
01544   \textcolor{keywordtype}{real} :: p
01545 
01546   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(eos)) \textcolor{keyword}{call }mom\_error(fatal, &
01547     \textcolor{stringliteral}{"convert\_temp\_salt\_to\_TEOS10 called with an unassociated EOS\_type EOS."})
01548 
01549   \textcolor{keywordflow}{if} ((eos%form\_of\_EOS /= \hyperlink{namespacemom__eos_afcd60f98ea35c6044d38eb4409b0a083}{eos\_teos10}) .and. (eos%form\_of\_EOS /= 
      \hyperlink{namespacemom__eos_ac37477f774acf511e88e96c036fa8292}{eos\_nemo})) \textcolor{keywordflow}{return}
01550 
01551   \textcolor{keywordflow}{do} k=1,kd ; \textcolor{keywordflow}{do} j=hi%jsc,hi%jec ; \textcolor{keywordflow}{do} i=hi%isc,hi%iec
01552     \textcolor{keywordflow}{if} (mask\_z(i,j,k) >= 1.0) \textcolor{keywordflow}{then}
01553      s(i,j,k) = gsw\_sr\_from\_sp(s(i,j,k))
01554 \textcolor{comment}{!     Get absolute salinity from practical salinity, converting pressures from Pascal to dbar.}
01555 \textcolor{comment}{!     If this option is activated, pressure will need to be added as an argument, and it should be}
01556 \textcolor{comment}{!     moved out into module that is not shared between components, where the ocean\_grid can be used.}
01557 \textcolor{comment}{!     S(i,j,k) = gsw\_sa\_from\_sp(S(i,j,k),pres(i,j,k)*1.0e-4,G%geoLonT(i,j),G%geoLatT(i,j))}
01558      t(i,j,k) = gsw\_ct\_from\_pt(s(i,j,k), t(i,j,k))
01559 \textcolor{keywordflow}{    endif}
01560 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}
01561 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a5b1ff89023e9d7da4074c7c1a71c9a85}{convert\_temp\_salt\_for\_teos10}
01562 \textcolor{comment}{}
01563 \textcolor{comment}{!> Return value of EOS\_quadrature}
01564 \textcolor{keyword}{logical }\textcolor{keyword}{function }\hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\_quadrature}(EOS)
\Hypertarget{MOM__EOS_8F90_source_l01565}\hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{01565}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),    \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{ !< Equation of state structure}
01566 
01567   \hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\_quadrature}  = eos%EOS\_quadrature
01568 
01569 \textcolor{keyword}{end function }\hyperlink{namespacemom__eos_aad531f2540628368c33198bb31d51201}{eos\_quadrature}
01570 \textcolor{comment}{}
01571 \textcolor{comment}{!> Extractor routine for the EOS type if the members need to be accessed outside this module}
01572 \textcolor{keyword}{subroutine }\hyperlink{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}{extract\_member\_eos}(EOS, form\_of\_EOS, form\_of\_TFreeze, EOS\_quadrature,
       Compressible, &
01573                               Rho\_T0\_S0, drho\_dT, dRho\_dS, TFr\_S0\_P0, dTFr\_dS, dTFr\_dp)
\Hypertarget{MOM__EOS_8F90_source_l01574}\hyperlink{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}{01574}   \textcolor{keywordtype}{type}(\hyperlink{structmom__eos_1_1eos__type}{eos\_type}),    \textcolor{keywordtype}{pointer}     :: EOS\textcolor{comment}{ !< Equation of state structure}
01575   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: form\_of\_EOS\textcolor{comment}{ !< A coded integer indicating the equation of state to use.}
01576   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: form\_of\_TFreeze\textcolor{comment}{ !< A coded integer indicating the expression for}
01577 \textcolor{comment}{                                       !! the potential temperature of the freezing point.}
01578   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: EOS\_quadrature\textcolor{comment}{ !< If true, always use the generic (quadrature)}
01579 \textcolor{comment}{                                       !! code for the integrals of density.}
01580   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: Compressible\textcolor{comment}{ !< If true, in situ density is a function of pressure.}
01581   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: Rho\_T0\_S0\textcolor{comment}{ !< Density at T=0 degC and S=0 ppt [kg m-3]}
01582   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: drho\_dT\textcolor{comment}{   !< Partial derivative of density with temperature}
01583 \textcolor{comment}{                                              !! in [kg m-3 degC-1]}
01584   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dRho\_dS\textcolor{comment}{   !< Partial derivative of density with salinity}
01585 \textcolor{comment}{                                              !! in [kg m-3 ppt-1]}
01586   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: TFr\_S0\_P0\textcolor{comment}{ !< The freezing potential temperature at S=0, P=0 [degC]}
01587   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dTFr\_dS\textcolor{comment}{   !< The derivative of freezing point with salinity}
01588 \textcolor{comment}{                                              !! [degC PSU-1]}
01589   \textcolor{keywordtype}{real}   , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dTFr\_dp\textcolor{comment}{   !< The derivative of freezing point with pressure}
01590 \textcolor{comment}{                                              !! [degC Pa-1]}
01591 
01592   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_eos    ))  form\_of\_eos     = eos%form\_of\_EOS
01593   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(form\_of\_tfreeze))  form\_of\_tfreeze = eos%form\_of\_TFreeze
01594   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(eos\_quadrature ))  eos\_quadrature  = eos%EOS\_quadrature
01595   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(compressible   ))  compressible    = eos%Compressible
01596   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(rho\_t0\_s0      ))  rho\_t0\_s0       = eos%Rho\_T0\_S0
01597   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_dt        ))  drho\_dt         = eos%drho\_dT
01598   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(drho\_ds        ))  drho\_ds         = eos%dRho\_dS
01599   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(tfr\_s0\_p0      ))  tfr\_s0\_p0       = eos%TFr\_S0\_P0
01600   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_ds        ))  dtfr\_ds         = eos%dTFr\_dS
01601   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dtfr\_dp        ))  dtfr\_dp         = eos%dTFr\_dp
01602 
01603 \textcolor{keyword}{end subroutine }\hyperlink{namespacemom__eos_a5e15d4f5b758ab149421c33145b0444c}{extract\_member\_eos}
01604 
01605 \textcolor{keyword}{end module }\hyperlink{namespacemom__eos}{mom\_eos}
01606 \textcolor{comment}{}
01607 \textcolor{comment}{!> \(\backslash\)namespace mom\_eos}
01608 \textcolor{comment}{!!}
01609 \textcolor{comment}{!! The MOM\_EOS module is a wrapper for various equations of state (e.g. Linear,}
01610 \textcolor{comment}{!! Wright, UNESCO) and provides a uniform interface to the rest of the model}
01611 \textcolor{comment}{!! independent of which equation of state is being used.}
\end{DoxyCode}
