\hypertarget{namespacemom__surface__forcing}{}\section{mom\+\_\+surface\+\_\+forcing Module Reference}
\label{namespacemom__surface__forcing}\index{mom\_surface\_forcing@{mom\_surface\_forcing}}


\subsection{Detailed Description}
Functions that calculate the surface wind stresses and fluxes of buoyancy or temperature/salinity andfresh water, in ocean-\/only (solo) mode. 

These functions are called every time step, even if the wind stresses or buoyancy fluxes are constant in time -\/ in that case these routines return quickly without doing anything. In addition, any I/O of forcing fields is controlled by surface\+\_\+forcing\+\_\+init, located in this file. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Structure containing pointers to the forcing fields that may be used to drive M\+OM. All fluxes are positive into the ocean. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__surface__forcing_a8bf2faba72a8fbe4a187981d50c99337}{set\+\_\+forcing}} (sfc\+\_\+state, forces, fluxes, day\+\_\+start, day\+\_\+interval, G, US, CS)
\begin{DoxyCompactList}\small\item\em Calls subroutines in this file to get surface forcing fields. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a5b732920d6d30c41b67686388775470e}{wind\+\_\+forcing\+\_\+const}} (sfc\+\_\+state, forces, tau\+\_\+x0, tau\+\_\+y0, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the surface wind stresses to constant values. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a845d75d43ebb4695675548aeb2c88b99}{wind\+\_\+forcing\+\_\+2gyre}} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the surface wind stresses to set up two idealized gyres. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a8981e402dd77c42fdd3dbc9322c1d575}{wind\+\_\+forcing\+\_\+1gyre}} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the surface wind stresses to set up a single idealized gyre. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a0b914b24fbfe91a3138e94f284fd359b}{wind\+\_\+forcing\+\_\+gyres}} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the surface wind stresses to set up idealized gyres. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a192b142ae856c166e8d821f5ee71dc82}{neverworld\+\_\+wind\+\_\+forcing}} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the surface wind stresses, forcestaux and forcestauy for the Neverworld forcing configuration. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a3d61abc8488ee22667089efcf49bdfc8}{scurve\+\_\+wind\+\_\+forcing}} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets the zonal wind stresses to a piecewise series of s-\/curves. \end{DoxyCompactList}\item 
real function \mbox{\hyperlink{namespacemom__surface__forcing_aa9a029f1dfbb40b5e30428d545563388}{scurve}} (x, L)
\begin{DoxyCompactList}\small\item\em Returns the value of a cosine-\/bell function evaluated at x/L. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a874e58e3fe4113ff8faa728eaa0735f5}{wind\+\_\+forcing\+\_\+from\+\_\+file}} (sfc\+\_\+state, forces, day, G, US, CS)
\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a55cfedbce92592fa4a8b1947bcaa69da}{wind\+\_\+forcing\+\_\+by\+\_\+data\+\_\+override}} (sfc\+\_\+state, forces, day, G, US, CS)
\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a01a06028c87fa3567748652c91de39fe}{buoyancy\+\_\+forcing\+\_\+from\+\_\+files}} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em Specifies zero surface bouyancy fluxes from input files. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_aae90a5a100863b1c2cb4e930e6bf22a9}{buoyancy\+\_\+forcing\+\_\+from\+\_\+data\+\_\+override}} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em Specifies zero surface bouyancy fluxes from data over-\/ride. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_aa898503e8349fda86bc2568b8cce95f3}{buoyancy\+\_\+forcing\+\_\+zero}} (sfc\+\_\+state, fluxes, day, dt, G, CS)
\begin{DoxyCompactList}\small\item\em This subroutine specifies zero surface bouyancy fluxes. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_aa656580ba5659f6cdb203799312eaa35}{buoyancy\+\_\+forcing\+\_\+const}} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets up spatially and temporally constant surface heat fluxes. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_aad38755ede5df899000281e73b1c3075}{buoyancy\+\_\+forcing\+\_\+linear}} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em Sets surface fluxes of heat and salinity by restoring to temperature and salinity profiles that vary linearly with latitude. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__surface__forcing_a938b99b53ae2b01b468c9c4eaeb595d2}{forcing\+\_\+save\+\_\+restart}} (CS, G, Time, directory, time\+\_\+stamped, filename\+\_\+suffix)
\begin{DoxyCompactList}\small\item\em Save a restart file for the forcing fields. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__surface__forcing_a791cb2bd2daa4fd3f036b121995bfb6c}{surface\+\_\+forcing\+\_\+init}} (Time, G, US, param\+\_\+file, diag, CS, tracer\+\_\+flow\+\_\+\+C\+Sp)
\begin{DoxyCompactList}\small\item\em Initialize the surface forcing module. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__surface__forcing_a645590ad6b9208812337b6ccbed1d01a}{surface\+\_\+forcing\+\_\+end}} (CS, fluxes)
\begin{DoxyCompactList}\small\item\em Deallocate memory associated with the surface forcing module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemom__surface__forcing_a9aef55fceb662e4fca82a5c95c8eeaad}\label{namespacemom__surface__forcing_a9aef55fceb662e4fca82a5c95c8eeaad}} 
integer \mbox{\hyperlink{namespacemom__surface__forcing_a9aef55fceb662e4fca82a5c95c8eeaad}{id\+\_\+clock\+\_\+forcing}}
\begin{DoxyCompactList}\small\item\em A C\+PU time clock. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__surface__forcing_aa656580ba5659f6cdb203799312eaa35}\label{namespacemom__surface__forcing_aa656580ba5659f6cdb203799312eaa35}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!buoyancy\_forcing\_const@{buoyancy\_forcing\_const}}
\index{buoyancy\_forcing\_const@{buoyancy\_forcing\_const}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{buoyancy\_forcing\_const()}{buoyancy\_forcing\_const()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::buoyancy\+\_\+forcing\+\_\+const (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets up spatially and temporally constant surface heat fluxes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 1396 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1396   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{1397 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{1398   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{1399   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{1400 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{1401 \textcolor{comment}{                                               !! the fluxes apply [s]}}
\DoxyCodeLine{1402   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1403   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1404   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1405 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1406   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1407   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1408   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_const, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{1409   is  = g\%isc ; ie  = g\%iec ; js  = g\%jsc ; je  = g\%jec}
\DoxyCodeLine{1410 }
\DoxyCodeLine{1411   \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1412     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1413       fluxes\%evap(i,j)                 = 0.0}
\DoxyCodeLine{1414       fluxes\%lprec(i,j)                = 0.0}
\DoxyCodeLine{1415       fluxes\%fprec(i,j)                = 0.0}
\DoxyCodeLine{1416       fluxes\%vprec(i,j)                = 0.0}
\DoxyCodeLine{1417       fluxes\%lrunoff(i,j)              = 0.0}
\DoxyCodeLine{1418       fluxes\%frunoff(i,j)              = 0.0}
\DoxyCodeLine{1419       fluxes\%lw(i,j)                   = 0.0}
\DoxyCodeLine{1420       fluxes\%latent(i,j)               = 0.0}
\DoxyCodeLine{1421       fluxes\%sens(i,j)                 = cs\%constantHeatForcing * g\%mask2dT(i,j)}
\DoxyCodeLine{1422       fluxes\%sw(i,j)                   = 0.0}
\DoxyCodeLine{1423       fluxes\%latent\_evap\_diag(i,j)     = 0.0}
\DoxyCodeLine{1424       fluxes\%latent\_fprec\_diag(i,j)    = 0.0}
\DoxyCodeLine{1425       fluxes\%latent\_frunoff\_diag(i,j)  = 0.0}
\DoxyCodeLine{1426 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1427   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1428     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1429       fluxes\%buoy(i,j) = 0.0}
\DoxyCodeLine{1430 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1431 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1432 }
\DoxyCodeLine{1433   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"buoyancy\_forcing\_const"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_aae90a5a100863b1c2cb4e930e6bf22a9}\label{namespacemom__surface__forcing_aae90a5a100863b1c2cb4e930e6bf22a9}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!buoyancy\_forcing\_from\_data\_override@{buoyancy\_forcing\_from\_data\_override}}
\index{buoyancy\_forcing\_from\_data\_override@{buoyancy\_forcing\_from\_data\_override}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{buoyancy\_forcing\_from\_data\_override()}{buoyancy\_forcing\_from\_data\_override()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::buoyancy\+\_\+forcing\+\_\+from\+\_\+data\+\_\+override (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Specifies zero surface bouyancy fluxes from data over-\/ride. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 1170 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1170   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{1171 \textcolor{comment}{                                                  !! describe the surface state of the ocean.}}
\DoxyCodeLine{1172   \textcolor{keywordtype}{type}(forcing),            \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{1173   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{1174 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{1175 \textcolor{comment}{                                                  !! the fluxes apply [s]}}
\DoxyCodeLine{1176   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1177   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{1178   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1179 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1180   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1181 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{1182     temp, \&       \textcolor{comment}{! A 2-d temporary work array with various units.}}
\DoxyCodeLine{1183     SST\_anom, \&   \textcolor{comment}{! Instantaneous sea surface temperature anomalies from a}}
\DoxyCodeLine{1184                   \textcolor{comment}{! target (observed) value [degC].}}
\DoxyCodeLine{1185     sss\_anom, \&   \textcolor{comment}{! Instantaneous sea surface salinity anomalies from a target}}
\DoxyCodeLine{1186                   \textcolor{comment}{! (observed) value [ppt].}}
\DoxyCodeLine{1187     sss\_mean      \textcolor{comment}{! A (mean?) salinity about which to normalize local salinity}}
\DoxyCodeLine{1188                   \textcolor{comment}{! anomalies when calculating restorative precipitation}}
\DoxyCodeLine{1189                   \textcolor{comment}{! anomalies [ppt].}}
\DoxyCodeLine{1190 \textcolor{keywordtype}{  real} :: kg\_m2\_s\_conversion  \textcolor{comment}{! A combination of unit conversion factors for rescaling}}
\DoxyCodeLine{1191                               \textcolor{comment}{! mass fluxes [R Z s m2 kg-1 T-1 ~> 1].}}
\DoxyCodeLine{1192 \textcolor{keywordtype}{  real} :: rhoXcp \textcolor{comment}{! The mean density times the heat capacity [Q R degC-1 ~> J m-3 degC-1].}}
\DoxyCodeLine{1193 }
\DoxyCodeLine{1194   \textcolor{keywordtype}{integer} :: time\_lev\_daily     \textcolor{comment}{! The time levels to read for fields with}}
\DoxyCodeLine{1195   \textcolor{keywordtype}{integer} :: time\_lev\_monthly   \textcolor{comment}{! daily and montly cycles.}}
\DoxyCodeLine{1196   \textcolor{keywordtype}{integer} :: itime\_lev           \textcolor{comment}{! The time level that is used for a field.}}
\DoxyCodeLine{1197 }
\DoxyCodeLine{1198   \textcolor{keywordtype}{integer} :: days, seconds}
\DoxyCodeLine{1199   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed}
\DoxyCodeLine{1200   \textcolor{keywordtype}{integer} :: is\_in, ie\_in, js\_in, je\_in}
\DoxyCodeLine{1201 }
\DoxyCodeLine{1202   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_data\_override, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{1203 }
\DoxyCodeLine{1204   is  = g\%isc ; ie  = g\%iec ; js  = g\%jsc ; je  = g\%jec}
\DoxyCodeLine{1205   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{1206   kg\_m2\_s\_conversion = us\%kg\_m2s\_to\_RZ\_T}
\DoxyCodeLine{1207 }
\DoxyCodeLine{1208   \textcolor{keywordflow}{if} (cs\%use\_temperature) rhoxcp = cs\%Rho0 * fluxes\%C\_p}
\DoxyCodeLine{1209 }
\DoxyCodeLine{1210   \textcolor{keywordflow}{if} (.not.cs\%dataOverrideIsInitialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1211     \textcolor{keyword}{call }data\_override\_init(ocean\_domain\_in=g\%Domain\%mpp\_domain)}
\DoxyCodeLine{1212     cs\%dataOverrideIsInitialized = .true.}
\DoxyCodeLine{1213 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1214 }
\DoxyCodeLine{1215   is\_in = g\%isc - g\%isd + 1}
\DoxyCodeLine{1216   ie\_in = g\%iec - g\%isd + 1}
\DoxyCodeLine{1217   js\_in = g\%jsc - g\%jsd + 1}
\DoxyCodeLine{1218   je\_in = g\%jec - g\%jsd + 1}
\DoxyCodeLine{1219 }
\DoxyCodeLine{1220   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'lw'}, fluxes\%lw(:,:), day, \&}
\DoxyCodeLine{1221        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=US\%W\_m2\_to\_QRZ\_T}}
\DoxyCodeLine{1222   \textcolor{keywordflow}{if} (us\%QRZ\_T\_to\_W\_m2 /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1223     fluxes\%lw(i,j) = fluxes\%lw(i,j) * us\%W\_m2\_to\_QRZ\_T}
\DoxyCodeLine{1224 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1225   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'evap'}, fluxes\%evap(:,:), day, \&}
\DoxyCodeLine{1226        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{1227 }
\DoxyCodeLine{1228   \textcolor{comment}{! note the sign convention}}
\DoxyCodeLine{1229   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1230     \textcolor{comment}{! The normal convention is that fluxes\%evap positive into the ocean}}
\DoxyCodeLine{1231     \textcolor{comment}{! but evap is normally a positive quantity in the files}}
\DoxyCodeLine{1232     \textcolor{comment}{! This conversion is dangerous because it is not clear whether the data files have been read!}}
\DoxyCodeLine{1233     fluxes\%evap(i,j) = -kg\_m2\_s\_conversion*fluxes\%evap(i,j)}
\DoxyCodeLine{1234     fluxes\%latent(i,j)           = cs\%latent\_heat\_vapor*fluxes\%evap(i,j)}
\DoxyCodeLine{1235     fluxes\%latent\_evap\_diag(i,j) = fluxes\%latent(i,j)}
\DoxyCodeLine{1236 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1237 }
\DoxyCodeLine{1238   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'sens'}, fluxes\%sens(:,:), day, \&}
\DoxyCodeLine{1239        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{1240 }
\DoxyCodeLine{1241   \textcolor{comment}{! note the sign convention}}
\DoxyCodeLine{1242   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1243      fluxes\%sens(i,j) = -us\%W\_m2\_to\_QRZ\_T * fluxes\%sens(i,j)  \textcolor{comment}{! Normal convention is positive into the ocean}}
\DoxyCodeLine{1244                                            \textcolor{comment}{! but sensible is normally a positive quantity in the files}}
\DoxyCodeLine{1245 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1246 }
\DoxyCodeLine{1247   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'sw'}, fluxes\%sw(:,:), day, \&}
\DoxyCodeLine{1248        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=US\%W\_m2\_to\_QRZ\_T}}
\DoxyCodeLine{1249   \textcolor{keywordflow}{if} (us\%QRZ\_T\_to\_W\_m2 /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1250     fluxes\%sw(i,j) = fluxes\%sw(i,j) * us\%W\_m2\_to\_QRZ\_T}
\DoxyCodeLine{1251 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1252 }
\DoxyCodeLine{1253   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'snow'}, fluxes\%fprec(:,:), day, \&}
\DoxyCodeLine{1254        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}}
\DoxyCodeLine{1255 }
\DoxyCodeLine{1256   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'rain'}, fluxes\%lprec(:,:), day, \&}
\DoxyCodeLine{1257        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}}
\DoxyCodeLine{1258 }
\DoxyCodeLine{1259   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'runoff'}, fluxes\%lrunoff(:,:), day, \&}
\DoxyCodeLine{1260        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}}
\DoxyCodeLine{1261 }
\DoxyCodeLine{1262   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'calving'}, fluxes\%frunoff(:,:), day, \&}
\DoxyCodeLine{1263        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}}
\DoxyCodeLine{1264 }
\DoxyCodeLine{1265   \textcolor{keywordflow}{if} (kg\_m2\_s\_conversion /= 1.0) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1266     fluxes\%lprec(i,j) = fluxes\%lprec(i,j) * kg\_m2\_s\_conversion}
\DoxyCodeLine{1267     fluxes\%fprec(i,j) = fluxes\%fprec(i,j) * kg\_m2\_s\_conversion}
\DoxyCodeLine{1268     fluxes\%lrunoff(i,j) = fluxes\%lrunoff(i,j) * kg\_m2\_s\_conversion}
\DoxyCodeLine{1269     fluxes\%frunoff(i,j) = fluxes\%frunoff(i,j) * kg\_m2\_s\_conversion}
\DoxyCodeLine{1270 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1271 }
\DoxyCodeLine{1272 \textcolor{comment}{!     Read the SST and SSS fields for damping.}}
\DoxyCodeLine{1273   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then} \textcolor{comment}{!\#CTRL\# .or. associated(CS\%ctrl\_forcing\_CSp)) then}}
\DoxyCodeLine{1274      \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'SST\_restore'}, cs\%T\_restore(:,:), day, \&}
\DoxyCodeLine{1275           is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{1276 }
\DoxyCodeLine{1277      \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'SSS\_restore'}, cs\%S\_restore(:,:), day, \&}
\DoxyCodeLine{1278           is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{1279 }
\DoxyCodeLine{1280 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1281 }
\DoxyCodeLine{1282   \textcolor{comment}{! restoring boundary fluxes}}
\DoxyCodeLine{1283   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1284     \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1285       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1286         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1287           fluxes\%heat\_added(i,j) = g\%mask2dT(i,j) * \&}
\DoxyCodeLine{1288               ((cs\%T\_Restore(i,j) - sfc\_state\%SST(i,j)) * rhoxcp * cs\%Flux\_const\_T)}
\DoxyCodeLine{1289           fluxes\%vprec(i,j) = - (cs\%Rho0*cs\%Flux\_const\_S) * \&}
\DoxyCodeLine{1290               (cs\%S\_Restore(i,j) - sfc\_state\%SSS(i,j)) / \&}
\DoxyCodeLine{1291               (0.5*(sfc\_state\%SSS(i,j) + cs\%S\_Restore(i,j)))}
\DoxyCodeLine{1292         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1293           fluxes\%heat\_added(i,j) = 0.0}
\DoxyCodeLine{1294           fluxes\%vprec(i,j)      = 0.0}
\DoxyCodeLine{1295 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1296 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1297     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1298       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1299         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1300           fluxes\%buoy(i,j) = (cs\%Dens\_Restore(i,j) - sfc\_state\%sfc\_density(i,j)) * \&}
\DoxyCodeLine{1301                              (cs\%G\_Earth * cs\%Flux\_const / cs\%Rho0)}
\DoxyCodeLine{1302         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1303           fluxes\%buoy(i,j) = 0.0}
\DoxyCodeLine{1304 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1305 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1306 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1307   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}}
\DoxyCodeLine{1308     \textcolor{keywordflow}{if} (.not.cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1309       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing in MOM\_surface\_forcing: "}// \&}
\DoxyCodeLine{1310                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})}
\DoxyCodeLine{1311 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1312 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}}
\DoxyCodeLine{1313 }
\DoxyCodeLine{1314 }
\DoxyCodeLine{1315   \textcolor{comment}{! mask out land points and compute heat content of water fluxes}}
\DoxyCodeLine{1316   \textcolor{comment}{! assume liquid precip enters ocean at SST}}
\DoxyCodeLine{1317   \textcolor{comment}{! assume frozen precip enters ocean at 0degC}}
\DoxyCodeLine{1318   \textcolor{comment}{! assume liquid runoff enters ocean at SST}}
\DoxyCodeLine{1319   \textcolor{comment}{! assume solid runoff (calving) enters ocean at 0degC}}
\DoxyCodeLine{1320   \textcolor{comment}{! mass leaving ocean has heat\_content determined in MOM\_diabatic\_driver.F90}}
\DoxyCodeLine{1321   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1322     fluxes\%evap(i,j)    = fluxes\%evap(i,j)    * g\%mask2dT(i,j)}
\DoxyCodeLine{1323     fluxes\%lprec(i,j)   = fluxes\%lprec(i,j)   * g\%mask2dT(i,j)}
\DoxyCodeLine{1324     fluxes\%fprec(i,j)   = fluxes\%fprec(i,j)   * g\%mask2dT(i,j)}
\DoxyCodeLine{1325     fluxes\%lrunoff(i,j) = fluxes\%lrunoff(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1326     fluxes\%frunoff(i,j) = fluxes\%frunoff(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1327     fluxes\%lw(i,j)      = fluxes\%lw(i,j)      * g\%mask2dT(i,j)}
\DoxyCodeLine{1328     fluxes\%latent(i,j)  = fluxes\%latent(i,j)  * g\%mask2dT(i,j)}
\DoxyCodeLine{1329     fluxes\%sens(i,j)    = fluxes\%sens(i,j)    * g\%mask2dT(i,j)}
\DoxyCodeLine{1330     fluxes\%sw(i,j)      = fluxes\%sw(i,j)      * g\%mask2dT(i,j)}
\DoxyCodeLine{1331 }
\DoxyCodeLine{1332     fluxes\%latent\_evap\_diag(i,j)     = fluxes\%latent\_evap\_diag(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1333     fluxes\%latent\_fprec\_diag(i,j)    = -fluxes\%fprec(i,j)*cs\%latent\_heat\_fusion}
\DoxyCodeLine{1334     fluxes\%latent\_frunoff\_diag(i,j)  = -fluxes\%frunoff(i,j)*cs\%latent\_heat\_fusion}
\DoxyCodeLine{1335 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1336 }
\DoxyCodeLine{1337 }
\DoxyCodeLine{1338 \textcolor{comment}{!\#CTRL\# if (associated(CS\%ctrl\_forcing\_CSp)) then}}
\DoxyCodeLine{1339 \textcolor{comment}{!\#CTRL\#   do j=js,je ; do i=is,ie}}
\DoxyCodeLine{1340 \textcolor{comment}{!\#CTRL\#     SST\_anom(i,j) = sfc\_state\%SST(i,j) - CS\%T\_Restore(i,j)}}
\DoxyCodeLine{1341 \textcolor{comment}{!\#CTRL\#     SSS\_anom(i,j) = sfc\_state\%SSS(i,j) - CS\%S\_Restore(i,j)}}
\DoxyCodeLine{1342 \textcolor{comment}{!\#CTRL\#     SSS\_mean(i,j) = 0.5*(sfc\_state\%SSS(i,j) + CS\%S\_Restore(i,j))}}
\DoxyCodeLine{1343 \textcolor{comment}{!\#CTRL\#   enddo ; enddo}}
\DoxyCodeLine{1344 \textcolor{comment}{!\#CTRL\#   call apply\_ctrl\_forcing(SST\_anom, SSS\_anom, SSS\_mean, fluxes\%heat\_added, \&}}
\DoxyCodeLine{1345 \textcolor{comment}{!\#CTRL\#                           fluxes\%vprec, day, dt, G, CS\%ctrl\_forcing\_CSp)}}
\DoxyCodeLine{1346 \textcolor{comment}{!\#CTRL\# endif}}
\DoxyCodeLine{1347 }
\DoxyCodeLine{1348   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_data\_override"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a01a06028c87fa3567748652c91de39fe}\label{namespacemom__surface__forcing_a01a06028c87fa3567748652c91de39fe}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!buoyancy\_forcing\_from\_files@{buoyancy\_forcing\_from\_files}}
\index{buoyancy\_forcing\_from\_files@{buoyancy\_forcing\_from\_files}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{buoyancy\_forcing\_from\_files()}{buoyancy\_forcing\_from\_files()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::buoyancy\+\_\+forcing\+\_\+from\+\_\+files (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Specifies zero surface bouyancy fluxes from input files. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 892 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{892   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{893 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{894   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{895   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{896 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{897 \textcolor{comment}{                                               !! the fluxes apply [s]}}
\DoxyCodeLine{898   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{899   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{900   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{901 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{902   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{903 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: \&}
\DoxyCodeLine{904     temp, \&       \textcolor{comment}{! A 2-d temporary work array with various units.}}
\DoxyCodeLine{905     SST\_anom, \&   \textcolor{comment}{! Instantaneous sea surface temperature anomalies from a}}
\DoxyCodeLine{906                   \textcolor{comment}{! target (observed) value [degC].}}
\DoxyCodeLine{907     sss\_anom, \&   \textcolor{comment}{! Instantaneous sea surface salinity anomalies from a target}}
\DoxyCodeLine{908                   \textcolor{comment}{! (observed) value [ppt].}}
\DoxyCodeLine{909     sss\_mean      \textcolor{comment}{! A (mean?) salinity about which to normalize local salinity}}
\DoxyCodeLine{910                   \textcolor{comment}{! anomalies when calculating restorative precipitation}}
\DoxyCodeLine{911                   \textcolor{comment}{! anomalies [ppt].}}
\DoxyCodeLine{912 }
\DoxyCodeLine{913 \textcolor{keywordtype}{  real} :: kg\_m2\_s\_conversion  \textcolor{comment}{! A combination of unit conversion factors for rescaling}}
\DoxyCodeLine{914                               \textcolor{comment}{! mass fluxes [R Z s m2 kg-1 T-1 ~> 1].}}
\DoxyCodeLine{915 \textcolor{keywordtype}{  real} :: rhoXcp \textcolor{comment}{! reference density times heat capacity [Q R degC-1 ~> J m-3 degC-1]}}
\DoxyCodeLine{916 }
\DoxyCodeLine{917   \textcolor{keywordtype}{integer} :: time\_lev\_daily     \textcolor{comment}{! time levels to read for fields with daily cycle}}
\DoxyCodeLine{918   \textcolor{keywordtype}{integer} :: time\_lev\_monthly   \textcolor{comment}{! time levels to read for fields with monthly cycle}}
\DoxyCodeLine{919   \textcolor{keywordtype}{integer} :: time\_lev           \textcolor{comment}{! time level that for a field}}
\DoxyCodeLine{920 }
\DoxyCodeLine{921   \textcolor{keywordtype}{integer} :: days, seconds}
\DoxyCodeLine{922   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{923 }
\DoxyCodeLine{924   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_files, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{925 }
\DoxyCodeLine{926   is  = g\%isc ; ie  = g\%iec ; js  = g\%jsc ; je = g\%jec}
\DoxyCodeLine{927   kg\_m2\_s\_conversion = us\%kg\_m2s\_to\_RZ\_T}
\DoxyCodeLine{928 }
\DoxyCodeLine{929   \textcolor{keywordflow}{if} (cs\%use\_temperature) rhoxcp = cs\%Rho0 * fluxes\%C\_p}
\DoxyCodeLine{930 }
\DoxyCodeLine{931   \textcolor{comment}{! Read the buoyancy forcing file}}
\DoxyCodeLine{932   \textcolor{keyword}{call }get\_time(day, seconds, days)}
\DoxyCodeLine{933 }
\DoxyCodeLine{934   time\_lev\_daily = days - 365*floor(real(days) / 365.0)}
\DoxyCodeLine{935 }
\DoxyCodeLine{936   \textcolor{keywordflow}{if} (time\_lev\_daily < 31) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 0}
\DoxyCodeLine{937   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 59)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 1}
\DoxyCodeLine{938   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 90)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 2}
\DoxyCodeLine{939   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 120) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 3}
\DoxyCodeLine{940   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 151) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 4}
\DoxyCodeLine{941   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 181) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 5}
\DoxyCodeLine{942   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 212) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 6}
\DoxyCodeLine{943   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 243) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 7}
\DoxyCodeLine{944   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 273) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 8}
\DoxyCodeLine{945   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 304) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 9}
\DoxyCodeLine{946   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 334) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 10}
\DoxyCodeLine{947   \textcolor{keywordflow}{else} ; time\_lev\_monthly = 11}
\DoxyCodeLine{948 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{949 }
\DoxyCodeLine{950   time\_lev\_daily   = time\_lev\_daily  +1}
\DoxyCodeLine{951   time\_lev\_monthly = time\_lev\_monthly+1}
\DoxyCodeLine{952 }
\DoxyCodeLine{953   \textcolor{keywordflow}{if} (time\_lev\_daily /= cs\%buoy\_last\_lev\_read) \textcolor{keywordflow}{then}}
\DoxyCodeLine{954 }
\DoxyCodeLine{955     \textcolor{comment}{! longwave}}
\DoxyCodeLine{956     \textcolor{keywordflow}{select case} (cs\%LW\_nlev)}
\DoxyCodeLine{957       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{958       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{959 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{960 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{961     \textcolor{keyword}{call }mom\_read\_data(cs\%longwave\_file, cs\%LW\_var, fluxes\%lw(:,:), \&}
\DoxyCodeLine{962                        g\%Domain, timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{963     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{964       \textcolor{keyword}{call }mom\_read\_data(cs\%longwaveup\_file, \textcolor{stringliteral}{"lwup\_sfc"}, temp(:,:), g\%Domain, \&}
\DoxyCodeLine{965                          timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{966       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie ; fluxes\%LW(i,j) = fluxes\%LW(i,j) - temp(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{967 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{968     cs\%LW\_last\_lev = time\_lev}
\DoxyCodeLine{969 }
\DoxyCodeLine{970     \textcolor{comment}{! evaporation}}
\DoxyCodeLine{971     \textcolor{keywordflow}{select case} (cs\%evap\_nlev)}
\DoxyCodeLine{972       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{973       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{974 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{975 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{976     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{977       \textcolor{keyword}{call }mom\_read\_data(cs\%evaporation\_file, cs\%evap\_var, fluxes\%evap(:,:), \&}
\DoxyCodeLine{978                      g\%Domain, timelevel=time\_lev, scale=-kg\_m2\_s\_conversion)}
\DoxyCodeLine{979       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{980         fluxes\%latent(i,j)           = cs\%latent\_heat\_vapor*fluxes\%evap(i,j)}
\DoxyCodeLine{981         fluxes\%latent\_evap\_diag(i,j) = fluxes\%latent(i,j)}
\DoxyCodeLine{982 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{983     \textcolor{keywordflow}{else}}
\DoxyCodeLine{984       \textcolor{keyword}{call }mom\_read\_data(cs\%evaporation\_file, cs\%evap\_var, fluxes\%evap(:,:), \&}
\DoxyCodeLine{985                      g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{986 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{987     cs\%evap\_last\_lev = time\_lev}
\DoxyCodeLine{988 }
\DoxyCodeLine{989     \textcolor{keywordflow}{select case} (cs\%latent\_nlev)}
\DoxyCodeLine{990       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{991       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{992 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{993 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{994     \textcolor{keywordflow}{if} (.not.cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{995       \textcolor{keyword}{call }mom\_read\_data(cs\%latentheat\_file, cs\%latent\_var, fluxes\%latent(:,:), \&}
\DoxyCodeLine{996                      g\%Domain, timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{997       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{998         fluxes\%latent\_evap\_diag(i,j) = fluxes\%latent(i,j)}
\DoxyCodeLine{999 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1000 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1001     cs\%latent\_last\_lev = time\_lev}
\DoxyCodeLine{1002 }
\DoxyCodeLine{1003     \textcolor{keywordflow}{select case} (cs\%sens\_nlev)}
\DoxyCodeLine{1004       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1005       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1006 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{1007 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{1008     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1009       \textcolor{keyword}{call }mom\_read\_data(cs\%sensibleheat\_file, cs\%sens\_var, fluxes\%sens(:,:), \&}
\DoxyCodeLine{1010                      g\%Domain, timelevel=time\_lev, scale=-us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{1011     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1012       \textcolor{keyword}{call }mom\_read\_data(cs\%sensibleheat\_file, cs\%sens\_var, fluxes\%sens(:,:), \&}
\DoxyCodeLine{1013                      g\%Domain, timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{1014 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1015     cs\%sens\_last\_lev = time\_lev}
\DoxyCodeLine{1016 }
\DoxyCodeLine{1017     \textcolor{keywordflow}{select case} (cs\%SW\_nlev)}
\DoxyCodeLine{1018       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1019       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1020 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{1021 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{1022     \textcolor{keyword}{call }mom\_read\_data(cs\%shortwave\_file, cs\%SW\_var, fluxes\%sw(:,:), g\%Domain, \&}
\DoxyCodeLine{1023                        timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{1024     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1025       \textcolor{keyword}{call }mom\_read\_data(cs\%shortwaveup\_file, \textcolor{stringliteral}{"swup\_sfc"}, temp(:,:), g\%Domain, \&}
\DoxyCodeLine{1026                          timelevel=time\_lev, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{1027       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1028         fluxes\%sw(i,j) = fluxes\%sw(i,j) - temp(i,j)}
\DoxyCodeLine{1029 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1030 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1031     cs\%SW\_last\_lev = time\_lev}
\DoxyCodeLine{1032 }
\DoxyCodeLine{1033     \textcolor{keywordflow}{select case} (cs\%precip\_nlev)}
\DoxyCodeLine{1034       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1035       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1036 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{1037 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{1038     \textcolor{keyword}{call }mom\_read\_data(cs\%snow\_file, cs\%snow\_var, \&}
\DoxyCodeLine{1039              fluxes\%fprec(:,:), g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1040     \textcolor{keyword}{call }mom\_read\_data(cs\%rain\_file, cs\%rain\_var, \&}
\DoxyCodeLine{1041              fluxes\%lprec(:,:), g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1042     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1043       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1044         fluxes\%lprec(i,j) = fluxes\%lprec(i,j) - fluxes\%fprec(i,j)}
\DoxyCodeLine{1045 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1046 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1047     cs\%precip\_last\_lev = time\_lev}
\DoxyCodeLine{1048 }
\DoxyCodeLine{1049     \textcolor{keywordflow}{select case} (cs\%runoff\_nlev)}
\DoxyCodeLine{1050       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1051       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1052 \textcolor{keywordflow}{      case default} ; time\_lev = 1}
\DoxyCodeLine{1053 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{1054     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1055       \textcolor{keyword}{call }mom\_read\_data(cs\%runoff\_file, cs\%lrunoff\_var, temp(:,:), \&}
\DoxyCodeLine{1056                      g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1057       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1058         fluxes\%lrunoff(i,j) = temp(i,j)*us\%m\_to\_L**2*g\%IareaT(i,j)}
\DoxyCodeLine{1059 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1060       \textcolor{keyword}{call }mom\_read\_data(cs\%runoff\_file, cs\%frunoff\_var, temp(:,:), \&}
\DoxyCodeLine{1061                      g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1062       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1063         fluxes\%frunoff(i,j) = temp(i,j)*us\%m\_to\_L**2*g\%IareaT(i,j)}
\DoxyCodeLine{1064 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1065     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1066       \textcolor{keyword}{call }mom\_read\_data(cs\%runoff\_file, cs\%lrunoff\_var, fluxes\%lrunoff(:,:), \&}
\DoxyCodeLine{1067                      g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1068       \textcolor{keyword}{call }mom\_read\_data(cs\%runoff\_file, cs\%frunoff\_var, fluxes\%frunoff(:,:), \&}
\DoxyCodeLine{1069                      g\%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)}
\DoxyCodeLine{1070 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1071     cs\%runoff\_last\_lev = time\_lev}
\DoxyCodeLine{1072 }
\DoxyCodeLine{1073 \textcolor{comment}{!     Read the SST and SSS fields for damping.}}
\DoxyCodeLine{1074     \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then} \textcolor{comment}{!\#CTRL\# .or. associated(CS\%ctrl\_forcing\_CSp)) then}}
\DoxyCodeLine{1075       \textcolor{keywordflow}{select case} (cs\%SST\_nlev)}
\DoxyCodeLine{1076         \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1077         \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1078 \textcolor{keywordflow}{        case default} ; time\_lev = 1}
\DoxyCodeLine{1079 \textcolor{keywordflow}{      end select}}
\DoxyCodeLine{1080       \textcolor{keyword}{call }mom\_read\_data(cs\%SSTrestore\_file, cs\%SST\_restore\_var, \&}
\DoxyCodeLine{1081                cs\%T\_Restore(:,:), g\%Domain, timelevel=time\_lev)}
\DoxyCodeLine{1082       cs\%SST\_last\_lev = time\_lev}
\DoxyCodeLine{1083 }
\DoxyCodeLine{1084       \textcolor{keywordflow}{select case} (cs\%SSS\_nlev)}
\DoxyCodeLine{1085         \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{1086         \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{1087 \textcolor{keywordflow}{        case default} ; time\_lev = 1}
\DoxyCodeLine{1088 \textcolor{keywordflow}{      end select}}
\DoxyCodeLine{1089       \textcolor{keyword}{call }mom\_read\_data(cs\%salinityrestore\_file, cs\%SSS\_restore\_var, \&}
\DoxyCodeLine{1090                cs\%S\_Restore(:,:), g\%Domain, timelevel=time\_lev)}
\DoxyCodeLine{1091       cs\%SSS\_last\_lev = time\_lev}
\DoxyCodeLine{1092 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1093     cs\%buoy\_last\_lev\_read = time\_lev\_daily}
\DoxyCodeLine{1094 }
\DoxyCodeLine{1095     \textcolor{comment}{! mask out land points and compute heat content of water fluxes}}
\DoxyCodeLine{1096     \textcolor{comment}{! assume liquid precip enters ocean at SST}}
\DoxyCodeLine{1097     \textcolor{comment}{! assume frozen precip enters ocean at 0degC}}
\DoxyCodeLine{1098     \textcolor{comment}{! assume liquid runoff enters ocean at SST}}
\DoxyCodeLine{1099     \textcolor{comment}{! assume solid runoff (calving) enters ocean at 0degC}}
\DoxyCodeLine{1100     \textcolor{comment}{! mass leaving the ocean has heat\_content determined in MOM\_diabatic\_driver.F90}}
\DoxyCodeLine{1101     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1102       fluxes\%evap(i,j)    = fluxes\%evap(i,j)    * g\%mask2dT(i,j)}
\DoxyCodeLine{1103       fluxes\%lprec(i,j)   = fluxes\%lprec(i,j)   * g\%mask2dT(i,j)}
\DoxyCodeLine{1104       fluxes\%fprec(i,j)   = fluxes\%fprec(i,j)   * g\%mask2dT(i,j)}
\DoxyCodeLine{1105       fluxes\%lrunoff(i,j) = fluxes\%lrunoff(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1106       fluxes\%frunoff(i,j) = fluxes\%frunoff(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1107       fluxes\%lw(i,j)      = fluxes\%lw(i,j)      * g\%mask2dT(i,j)}
\DoxyCodeLine{1108       fluxes\%sens(i,j)    = fluxes\%sens(i,j)    * g\%mask2dT(i,j)}
\DoxyCodeLine{1109       fluxes\%sw(i,j)      = fluxes\%sw(i,j)      * g\%mask2dT(i,j)}
\DoxyCodeLine{1110       fluxes\%latent(i,j)  = fluxes\%latent(i,j)  * g\%mask2dT(i,j)}
\DoxyCodeLine{1111 }
\DoxyCodeLine{1112       fluxes\%latent\_evap\_diag(i,j)     = fluxes\%latent\_evap\_diag(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{1113       fluxes\%latent\_fprec\_diag(i,j)    = -fluxes\%fprec(i,j)*cs\%latent\_heat\_fusion}
\DoxyCodeLine{1114       fluxes\%latent\_frunoff\_diag(i,j)  = -fluxes\%frunoff(i,j)*cs\%latent\_heat\_fusion}
\DoxyCodeLine{1115 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1116 }
\DoxyCodeLine{1117 \textcolor{keywordflow}{  endif} \textcolor{comment}{! time\_lev /= CS\%buoy\_last\_lev\_read}}
\DoxyCodeLine{1118 }
\DoxyCodeLine{1119 }
\DoxyCodeLine{1120   \textcolor{comment}{! restoring surface boundary fluxes}}
\DoxyCodeLine{1121   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1122 }
\DoxyCodeLine{1123     \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1124       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1125         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1126           fluxes\%heat\_added(i,j) = g\%mask2dT(i,j) * \&}
\DoxyCodeLine{1127               ((cs\%T\_Restore(i,j) - sfc\_state\%SST(i,j)) * rhoxcp * cs\%Flux\_const\_T)}
\DoxyCodeLine{1128           fluxes\%vprec(i,j) = - (cs\%Rho0*cs\%Flux\_const\_S) * \&}
\DoxyCodeLine{1129               (cs\%S\_Restore(i,j) - sfc\_state\%SSS(i,j)) / \&}
\DoxyCodeLine{1130               (0.5*(sfc\_state\%SSS(i,j) + cs\%S\_Restore(i,j)))}
\DoxyCodeLine{1131         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1132           fluxes\%heat\_added(i,j) = 0.0}
\DoxyCodeLine{1133           fluxes\%vprec(i,j)      = 0.0}
\DoxyCodeLine{1134 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1135 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1136     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1137       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1138         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1139           fluxes\%buoy(i,j) = (cs\%Dens\_Restore(i,j) - sfc\_state\%sfc\_density(i,j)) * \&}
\DoxyCodeLine{1140                              (cs\%G\_Earth * cs\%Flux\_const / cs\%Rho0)}
\DoxyCodeLine{1141         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1142           fluxes\%buoy(i,j) = 0.0}
\DoxyCodeLine{1143 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1144 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1145 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1146 }
\DoxyCodeLine{1147   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}}
\DoxyCodeLine{1148     \textcolor{keywordflow}{if} (.not.cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1149       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing in MOM\_surface\_forcing: "}// \&}
\DoxyCodeLine{1150                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})}
\DoxyCodeLine{1151 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1152 }
\DoxyCodeLine{1153 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}}
\DoxyCodeLine{1154 }
\DoxyCodeLine{1155 \textcolor{comment}{!\#CTRL\# if (associated(CS\%ctrl\_forcing\_CSp)) then}}
\DoxyCodeLine{1156 \textcolor{comment}{!\#CTRL\#   do j=js,je ; do i=is,ie}}
\DoxyCodeLine{1157 \textcolor{comment}{!\#CTRL\#     SST\_anom(i,j) = sfc\_state\%SST(i,j) - CS\%T\_Restore(i,j)}}
\DoxyCodeLine{1158 \textcolor{comment}{!\#CTRL\#     SSS\_anom(i,j) = sfc\_state\%SSS(i,j) - CS\%S\_Restore(i,j)}}
\DoxyCodeLine{1159 \textcolor{comment}{!\#CTRL\#     SSS\_mean(i,j) = 0.5*(sfc\_state\%SSS(i,j) + CS\%S\_Restore(i,j))}}
\DoxyCodeLine{1160 \textcolor{comment}{!\#CTRL\#   enddo ; enddo}}
\DoxyCodeLine{1161 \textcolor{comment}{!\#CTRL\#   call apply\_ctrl\_forcing(SST\_anom, SSS\_anom, SSS\_mean, fluxes\%heat\_added, \&}}
\DoxyCodeLine{1162 \textcolor{comment}{!\#CTRL\#                           fluxes\%vprec, day, dt, G, CS\%ctrl\_forcing\_CSp)}}
\DoxyCodeLine{1163 \textcolor{comment}{!\#CTRL\# endif}}
\DoxyCodeLine{1164 }
\DoxyCodeLine{1165   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_files"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_aad38755ede5df899000281e73b1c3075}\label{namespacemom__surface__forcing_aad38755ede5df899000281e73b1c3075}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!buoyancy\_forcing\_linear@{buoyancy\_forcing\_linear}}
\index{buoyancy\_forcing\_linear@{buoyancy\_forcing\_linear}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{buoyancy\_forcing\_linear()}{buoyancy\_forcing\_linear()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::buoyancy\+\_\+forcing\+\_\+linear (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets surface fluxes of heat and salinity by restoring to temperature and salinity profiles that vary linearly with latitude. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 1439 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1439   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{1440 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{1441   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{1442   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{1443 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{1444 \textcolor{comment}{                                               !! the fluxes apply [s]}}
\DoxyCodeLine{1445   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1446   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1447   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1448 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1449   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1450 \textcolor{keywordtype}{  real} :: y, T\_restore, S\_restore}
\DoxyCodeLine{1451   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1452 }
\DoxyCodeLine{1453   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_linear, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{1454   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1455 }
\DoxyCodeLine{1456   \textcolor{comment}{! This case has no surface buoyancy forcing.}}
\DoxyCodeLine{1457   \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1458     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1459       fluxes\%evap(i,j)                 = 0.0}
\DoxyCodeLine{1460       fluxes\%lprec(i,j)                = 0.0}
\DoxyCodeLine{1461       fluxes\%fprec(i,j)                = 0.0}
\DoxyCodeLine{1462       fluxes\%vprec(i,j)                = 0.0}
\DoxyCodeLine{1463       fluxes\%lrunoff(i,j)              = 0.0}
\DoxyCodeLine{1464       fluxes\%frunoff(i,j)              = 0.0}
\DoxyCodeLine{1465       fluxes\%lw(i,j)                   = 0.0}
\DoxyCodeLine{1466       fluxes\%latent(i,j)               = 0.0}
\DoxyCodeLine{1467       fluxes\%sens(i,j)                 = 0.0}
\DoxyCodeLine{1468       fluxes\%sw(i,j)                   = 0.0}
\DoxyCodeLine{1469       fluxes\%latent\_evap\_diag(i,j)     = 0.0}
\DoxyCodeLine{1470       fluxes\%latent\_fprec\_diag(i,j)    = 0.0}
\DoxyCodeLine{1471       fluxes\%latent\_frunoff\_diag(i,j)  = 0.0}
\DoxyCodeLine{1472 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1473   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1474     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1475       fluxes\%buoy(i,j) = 0.0}
\DoxyCodeLine{1476 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1477 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1478 }
\DoxyCodeLine{1479   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1480     \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1481       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1482         y = (g\%geoLatCu(i,j)-cs\%South\_lat)/cs\%len\_lat}
\DoxyCodeLine{1483         t\_restore = cs\%T\_south + (cs\%T\_north-cs\%T\_south)*y}
\DoxyCodeLine{1484         s\_restore = cs\%S\_south + (cs\%S\_north-cs\%S\_south)*y}
\DoxyCodeLine{1485         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1486           fluxes\%heat\_added(i,j) = g\%mask2dT(i,j) * \&}
\DoxyCodeLine{1487               ((t\_restore - sfc\_state\%SST(i,j)) * ((cs\%Rho0 * fluxes\%C\_p) * cs\%Flux\_const))}
\DoxyCodeLine{1488           fluxes\%vprec(i,j) = - (cs\%Rho0*cs\%Flux\_const) * \&}
\DoxyCodeLine{1489               (s\_restore - sfc\_state\%SSS(i,j)) / \&}
\DoxyCodeLine{1490               (0.5*(sfc\_state\%SSS(i,j) + s\_restore))}
\DoxyCodeLine{1491         \textcolor{keywordflow}{else}}
\DoxyCodeLine{1492           fluxes\%heat\_added(i,j) = 0.0}
\DoxyCodeLine{1493           fluxes\%vprec(i,j)      = 0.0}
\DoxyCodeLine{1494 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{1495 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1496     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1497       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing\_linear in MOM\_surface\_forcing: "}// \&}
\DoxyCodeLine{1498                      \textcolor{stringliteral}{"RESTOREBUOY to linear not written yet."})}
\DoxyCodeLine{1499      \textcolor{comment}{!do j=js,je ; do i=is,ie}}
\DoxyCodeLine{1500      \textcolor{comment}{!  if (G\%mask2dT(i,j) > 0) then}}
\DoxyCodeLine{1501      \textcolor{comment}{!    fluxes\%buoy(i,j) = (CS\%Dens\_Restore(i,j) - sfc\_state\%sfc\_density(i,j)) * \&}}
\DoxyCodeLine{1502      \textcolor{comment}{!                       (CS\%G\_Earth * CS\%Flux\_const / CS\%Rho0)}}
\DoxyCodeLine{1503      \textcolor{comment}{!  else}}
\DoxyCodeLine{1504      \textcolor{comment}{!    fluxes\%buoy(i,j) = 0.0}}
\DoxyCodeLine{1505      \textcolor{comment}{!  endif}}
\DoxyCodeLine{1506      \textcolor{comment}{!enddo ; enddo}}
\DoxyCodeLine{1507 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1508   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}}
\DoxyCodeLine{1509     \textcolor{keywordflow}{if} (.not.cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1510       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing\_linear in MOM\_surface\_forcing: "}// \&}
\DoxyCodeLine{1511                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})}
\DoxyCodeLine{1512 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1513 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}}
\DoxyCodeLine{1514 }
\DoxyCodeLine{1515   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"buoyancy\_forcing\_linear"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_aa898503e8349fda86bc2568b8cce95f3}\label{namespacemom__surface__forcing_aa898503e8349fda86bc2568b8cce95f3}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!buoyancy\_forcing\_zero@{buoyancy\_forcing\_zero}}
\index{buoyancy\_forcing\_zero@{buoyancy\_forcing\_zero}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{buoyancy\_forcing\_zero()}{buoyancy\_forcing\_zero()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::buoyancy\+\_\+forcing\+\_\+zero (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine specifies zero surface bouyancy fluxes. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 1353 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1353   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{1354 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{1355   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{1356   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{1357 \textcolor{keywordtype}{  real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{1358 \textcolor{comment}{                                               !! the fluxes apply [s]}}
\DoxyCodeLine{1359   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1360   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1361 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1362   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1363   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{1364 }
\DoxyCodeLine{1365   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_zero, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{1366   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1367 }
\DoxyCodeLine{1368   \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1369     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1370       fluxes\%evap(i,j)                 = 0.0}
\DoxyCodeLine{1371       fluxes\%lprec(i,j)                = 0.0}
\DoxyCodeLine{1372       fluxes\%fprec(i,j)                = 0.0}
\DoxyCodeLine{1373       fluxes\%vprec(i,j)                = 0.0}
\DoxyCodeLine{1374       fluxes\%lrunoff(i,j)              = 0.0}
\DoxyCodeLine{1375       fluxes\%frunoff(i,j)              = 0.0}
\DoxyCodeLine{1376       fluxes\%lw(i,j)                   = 0.0}
\DoxyCodeLine{1377       fluxes\%latent(i,j)               = 0.0}
\DoxyCodeLine{1378       fluxes\%sens(i,j)                 = 0.0}
\DoxyCodeLine{1379       fluxes\%sw(i,j)                   = 0.0}
\DoxyCodeLine{1380       fluxes\%latent\_evap\_diag(i,j)     = 0.0}
\DoxyCodeLine{1381       fluxes\%latent\_fprec\_diag(i,j)    = 0.0}
\DoxyCodeLine{1382       fluxes\%latent\_frunoff\_diag(i,j)  = 0.0}
\DoxyCodeLine{1383 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1384   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1385     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{1386       fluxes\%buoy(i,j) = 0.0}
\DoxyCodeLine{1387 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1388 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1389 }
\DoxyCodeLine{1390   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"buoyancy\_forcing\_zero"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a938b99b53ae2b01b468c9c4eaeb595d2}\label{namespacemom__surface__forcing_a938b99b53ae2b01b468c9c4eaeb595d2}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!forcing\_save\_restart@{forcing\_save\_restart}}
\index{forcing\_save\_restart@{forcing\_save\_restart}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{forcing\_save\_restart()}{forcing\_save\_restart()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+surface\+\_\+forcing\+::forcing\+\_\+save\+\_\+restart (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{character(len=$\ast$), intent(in)}]{directory,  }\item[{logical, intent(in), optional}]{time\+\_\+stamped,  }\item[{character(len=$\ast$), intent(in), optional}]{filename\+\_\+suffix }\end{DoxyParamCaption})}



Save a restart file for the forcing fields. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em time} & model time at this call; needed for mpp\+\_\+write calls \\
\hline
\mbox{\texttt{ in}}  & {\em directory} & directory into which to write these restart files \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+stamped} & If true, the restart file names include a unique time stamp; the default is false. \\
\hline
\mbox{\texttt{ in}}  & {\em filename\+\_\+suffix} & optional suffix (e.\+g., a time-\/stamp) to append to the restart fname \\
\hline
\end{DoxyParams}


Definition at line 1521 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1521   \textcolor{keywordtype}{type}(surface\_forcing\_CS),   \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1522 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1523   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1524   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< model time at this call; needed for mpp\_write calls}}
\DoxyCodeLine{1525   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(in)}    :: directory\textcolor{comment}{ !< directory into which to write these restart files}}
\DoxyCodeLine{1526   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: time\_stamped\textcolor{comment}{ !< If true, the restart file names}}
\DoxyCodeLine{1527 \textcolor{comment}{                                                    !! include a unique time stamp; the  default is false.}}
\DoxyCodeLine{1528   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: filename\_suffix\textcolor{comment}{ !< optional suffix (e.g., a time-stamp)}}
\DoxyCodeLine{1529 \textcolor{comment}{                                                    !! to append to the restart fname}}
\DoxyCodeLine{1530 }
\DoxyCodeLine{1531   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1532   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs\%restart\_CSp)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1533 }
\DoxyCodeLine{1534   \textcolor{keyword}{call }save\_restart(directory, time, g, cs\%restart\_CSp, time\_stamped)}
\DoxyCodeLine{1535 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a192b142ae856c166e8d821f5ee71dc82}\label{namespacemom__surface__forcing_a192b142ae856c166e8d821f5ee71dc82}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!neverworld\_wind\_forcing@{neverworld\_wind\_forcing}}
\index{neverworld\_wind\_forcing@{neverworld\_wind\_forcing}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{neverworld\_wind\_forcing()}{neverworld\_wind\_forcing()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::neverworld\+\_\+wind\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the surface wind stresses, forcestaux and forcestauy for the Neverworld forcing configuration. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time used for determining the fluxes. \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 538 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{538   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{539 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{540   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{541   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{    !< Time used for determining the fluxes.}}
\DoxyCodeLine{542   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Grid structure.}}
\DoxyCodeLine{543   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{544   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< pointer to control struct returned by}}
\DoxyCodeLine{545 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{546   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{547   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{548   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, IsdB, IedB, JsdB, JedB}
\DoxyCodeLine{549 \textcolor{keywordtype}{  real} :: PI, I\_rho, y}
\DoxyCodeLine{550 \textcolor{keywordtype}{  real} :: tau\_max  \textcolor{comment}{! The magnitude of the wind stress [R Z L T-2 ~> Pa]}}
\DoxyCodeLine{551 \textcolor{keywordtype}{  real} :: off}
\DoxyCodeLine{552 }
\DoxyCodeLine{553   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{554   isq = g\%IscB ; ieq = g\%IecB ; jsq = g\%JscB ; jeq = g\%JecB}
\DoxyCodeLine{555   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{556   isdb = g\%IsdB ; iedb = g\%IedB ; jsdb = g\%JsdB ; jedb = g\%JedB}
\DoxyCodeLine{557 }
\DoxyCodeLine{558   \textcolor{comment}{! Allocate the forcing arrays, if necessary.}}
\DoxyCodeLine{559   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true.)}
\DoxyCodeLine{560 }
\DoxyCodeLine{561   \textcolor{comment}{!  Set the surface wind stresses, in units of Pa.  A positive taux}}
\DoxyCodeLine{562   \textcolor{comment}{!  accelerates the ocean to the (pseudo-)east.}}
\DoxyCodeLine{563 }
\DoxyCodeLine{564   \textcolor{comment}{!  The i-loop extends to is-1 so that taux can be used later in the}}
\DoxyCodeLine{565   \textcolor{comment}{! calculation of ustar - otherwise the lower bound would be Isq.}}
\DoxyCodeLine{566   pi = 4.0*atan(1.0)}
\DoxyCodeLine{567   forces\%taux(:,:) = 0.0}
\DoxyCodeLine{568   tau\_max = 0.2 * us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z}
\DoxyCodeLine{569   off = 0.02}
\DoxyCodeLine{570   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{571     y = (g\%geoLatT(i,j)-g\%south\_lat)/g\%len\_lat}
\DoxyCodeLine{572 }
\DoxyCodeLine{573     \textcolor{keywordflow}{if} (y <= 0.29) \textcolor{keywordflow}{then}}
\DoxyCodeLine{574       forces\%taux(i,j) = forces\%taux(i,j) + tau\_max * ( (1/0.29)*y - ( 1/(2*pi) )*sin( (2*pi*y) / 0.29 ) )}
\DoxyCodeLine{575 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{576     \textcolor{keywordflow}{if} ((y > 0.29) .and. (y <= (0.8-off))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{577       forces\%taux(i,j) = forces\%taux(i,j) + tau\_max *(0.35+0.65*cos(pi*(y-0.29)/(0.51-off))  )}
\DoxyCodeLine{578 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{579     \textcolor{keywordflow}{if} ((y > (0.8-off)) .and. (y <= (1-off))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{580       forces\%taux(i,j) = forces\%taux(i,j) + tau\_max *( 1.5*( (y-1+off) - (0.1/pi)*sin(10.0*pi*(y-0.8+off)) ) )}
\DoxyCodeLine{581 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{582     forces\%taux(i,j) = g\%mask2dCu(i,j) * forces\%taux(i,j)}
\DoxyCodeLine{583 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{584 }
\DoxyCodeLine{585   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{586     forces\%tauy(i,j) = g\%mask2dCv(i,j) * 0.0}
\DoxyCodeLine{587 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{588 }
\DoxyCodeLine{589   \textcolor{comment}{! Set the surface friction velocity, in units of m s-1.  ustar is always positive.}}
\DoxyCodeLine{590   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%ustar)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{591     i\_rho = us\%L\_to\_Z / cs\%Rho0}
\DoxyCodeLine{592     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{593       forces\%ustar(i,j) = sqrt( (cs\%gust\_const + \&}
\DoxyCodeLine{594             sqrt(0.5*((forces\%tauy(i,j-1)**2 + forces\%tauy(i,j)**2) + \&}
\DoxyCodeLine{595                       (forces\%taux(i-1,j)**2 + forces\%taux(i,j)**2))) ) * i\_rho )}
\DoxyCodeLine{596 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{597 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{598 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_aa9a029f1dfbb40b5e30428d545563388}\label{namespacemom__surface__forcing_aa9a029f1dfbb40b5e30428d545563388}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!scurve@{scurve}}
\index{scurve@{scurve}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{scurve()}{scurve()}}
{\footnotesize\ttfamily real function mom\+\_\+surface\+\_\+forcing\+::scurve (\begin{DoxyParamCaption}\item[{real, intent(in)}]{x,  }\item[{real, intent(in)}]{L }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns the value of a cosine-\/bell function evaluated at x/L. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em x} & non-\/dimensional position \\
\hline
\mbox{\texttt{ in}}  & {\em l} & non-\/dimensional width \\
\hline
\end{DoxyParams}


Definition at line 658 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{658 \textcolor{keywordtype}{  real} , \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{       !< non-dimensional position}}
\DoxyCodeLine{659 \textcolor{keywordtype}{  real} , \textcolor{keywordtype}{intent(in)} :: L\textcolor{comment}{       !< non-dimensional width}}
\DoxyCodeLine{660 \textcolor{keywordtype}{  real} :: s}
\DoxyCodeLine{661 }
\DoxyCodeLine{662   s = x/l}
\DoxyCodeLine{663   scurve = (3. - 2.*s) * (s*s)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a3d61abc8488ee22667089efcf49bdfc8}\label{namespacemom__surface__forcing_a3d61abc8488ee22667089efcf49bdfc8}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!scurve\_wind\_forcing@{scurve\_wind\_forcing}}
\index{scurve\_wind\_forcing@{scurve\_wind\_forcing}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{scurve\_wind\_forcing()}{scurve\_wind\_forcing()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::scurve\+\_\+wind\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the zonal wind stresses to a piecewise series of s-\/curves. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em day} & Time used for determining the fluxes. \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & Grid structure. \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 603 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{603   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{604 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{605   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{606   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{    !< Time used for determining the fluxes.}}
\DoxyCodeLine{607   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{      !< Grid structure.}}
\DoxyCodeLine{608   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{     !< A dimensional unit scaling type}}
\DoxyCodeLine{609   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{     !< pointer to control struct returned by}}
\DoxyCodeLine{610 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{611   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{612   \textcolor{keywordtype}{integer} :: i, j, kseg}
\DoxyCodeLine{613 \textcolor{keywordtype}{  real} :: lon, lat, I\_rho, y, L}
\DoxyCodeLine{614 \textcolor{comment}{! real :: ydata(7) = (/ -70., -45., -15., 0., 15., 45., 70. /)}}
\DoxyCodeLine{615 \textcolor{comment}{! real :: taudt(7) = (/ 0., 0.2, -0.1, -0.02, -0.1, 0.1, 0. /)}}
\DoxyCodeLine{616 }
\DoxyCodeLine{617   \textcolor{comment}{! Allocate the forcing arrays, if necessary.}}
\DoxyCodeLine{618   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true.)}
\DoxyCodeLine{619 }
\DoxyCodeLine{620   kseg = 1}
\DoxyCodeLine{621   \textcolor{keywordflow}{do} j=g\%jsd,g\%jed ; \textcolor{keywordflow}{do} i=g\%IsdB,g\%IedB}
\DoxyCodeLine{622     lon = g\%geoLonCu(i,j)}
\DoxyCodeLine{623     lat = g\%geoLatCu(i,j)}
\DoxyCodeLine{624 }
\DoxyCodeLine{625     \textcolor{comment}{! Find segment k s.t. ydata(k)<= lat < ydata(k+1)}}
\DoxyCodeLine{626     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (lat>=cs\%scurves\_ydata(kseg+1) .and. kseg<6)}
\DoxyCodeLine{627       kseg = kseg+1}
\DoxyCodeLine{628 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{629     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (lat<cs\%scurves\_ydata(kseg) .and. kseg>1)}
\DoxyCodeLine{630       kseg = kseg-1}
\DoxyCodeLine{631 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{632 }
\DoxyCodeLine{633     y = lat - cs\%scurves\_ydata(kseg)}
\DoxyCodeLine{634     l = cs\%scurves\_ydata(kseg+1) - cs\%scurves\_ydata(kseg)}
\DoxyCodeLine{635     forces\%taux(i,j) = cs\%scurves\_taux(kseg) +  \&}
\DoxyCodeLine{636                        ( cs\%scurves\_taux(kseg+1) - cs\%scurves\_taux(kseg) ) * scurve(y, l)}
\DoxyCodeLine{637     forces\%taux(i,j) = g\%mask2dCu(i,j) * forces\%taux(i,j)}
\DoxyCodeLine{638 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{639 }
\DoxyCodeLine{640   \textcolor{keywordflow}{do} j=g\%JsdB,g\%JedB ; \textcolor{keywordflow}{do} i=g\%isd,g\%ied}
\DoxyCodeLine{641     forces\%tauy(i,j) = g\%mask2dCv(i,j) * 0.0}
\DoxyCodeLine{642 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{643 }
\DoxyCodeLine{644   \textcolor{comment}{! Set the surface friction velocity, in units of m s-1.  ustar is always positive.}}
\DoxyCodeLine{645   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%ustar)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{646     i\_rho = us\%L\_to\_Z / cs\%Rho0}
\DoxyCodeLine{647     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{648       forces\%ustar(i,j) = sqrt( (cs\%gust\_const + \&}
\DoxyCodeLine{649             sqrt(0.5*((forces\%tauy(i,j-1)**2 + forces\%tauy(i,j)**2) + \&}
\DoxyCodeLine{650                       (forces\%taux(i-1,j)**2 + forces\%taux(i,j)**2))) ) * i\_rho )}
\DoxyCodeLine{651 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{652 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{653 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a8bf2faba72a8fbe4a187981d50c99337}\label{namespacemom__surface__forcing_a8bf2faba72a8fbe4a187981d50c99337}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!set\_forcing@{set\_forcing}}
\index{set\_forcing@{set\_forcing}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{set\_forcing()}{set\_forcing()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+surface\+\_\+forcing\+::set\+\_\+forcing (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(forcing), intent(inout)}]{fluxes,  }\item[{type(time\+\_\+type), intent(in)}]{day\+\_\+start,  }\item[{type(time\+\_\+type), intent(in)}]{day\+\_\+interval,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Calls subroutines in this file to get surface forcing fields. 

It also allocates and initializes the fields in the forcing and mech\+\_\+forcing types the first time it is called. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day\+\_\+start} & The start time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em day\+\_\+interval} & Length of time over which these fluxes applied \\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 223 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{223   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{224 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{225   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{226   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{227   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\_start\textcolor{comment}{ !< The start time of the fluxes}}
\DoxyCodeLine{228   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\_interval\textcolor{comment}{ !< Length of time over which these fluxes applied}}
\DoxyCodeLine{229   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{230   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{231   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{232 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{233   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{234 \textcolor{keywordtype}{  real} :: dt                     \textcolor{comment}{! length of time over which fluxes applied [s]}}
\DoxyCodeLine{235   \textcolor{keywordtype}{type}(time\_type) :: day\_center  \textcolor{comment}{! central time of the fluxes.}}
\DoxyCodeLine{236   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{237   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_forcing)}
\DoxyCodeLine{240   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"set\_forcing, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{241 }
\DoxyCodeLine{242   day\_center = day\_start + day\_interval/2}
\DoxyCodeLine{243   dt = time\_type\_to\_real(day\_interval)}
\DoxyCodeLine{244 }
\DoxyCodeLine{245   \textcolor{keywordflow}{if} (cs\%first\_call\_set\_forcing) \textcolor{keywordflow}{then}}
\DoxyCodeLine{246     \textcolor{comment}{! Allocate memory for the mechanical and thermodyanmic forcing fields.}}
\DoxyCodeLine{247     \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true., ustar=.true., press=.true.)}
\DoxyCodeLine{248 }
\DoxyCodeLine{249     \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, ustar=.true., fix\_accum\_bug=cs\%fix\_ustar\_gustless\_bug)}
\DoxyCodeLine{250     \textcolor{keywordflow}{if} (trim(cs\%buoy\_config) /= \textcolor{stringliteral}{"NONE"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{251       \textcolor{keywordflow}{if} ( cs\%use\_temperature ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{252         \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, water=.true., heat=.true., press=.true.)}
\DoxyCodeLine{253         \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{254           \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%T\_Restore,isd, ied, jsd, jed)}
\DoxyCodeLine{255           \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%heat\_added, isd, ied, jsd, jed)}
\DoxyCodeLine{256           \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%S\_Restore, isd, ied, jsd, jed)}
\DoxyCodeLine{257 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{258       \textcolor{keywordflow}{else} \textcolor{comment}{! CS\%use\_temperature false.}}
\DoxyCodeLine{259         \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%buoy, isd, ied, jsd, jed)}
\DoxyCodeLine{260 }
\DoxyCodeLine{261         \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%Dens\_Restore, isd, ied, jsd, jed)}
\DoxyCodeLine{262 \textcolor{keywordflow}{      endif}  \textcolor{comment}{! endif for  CS\%use\_temperature}}
\DoxyCodeLine{263 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{264 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{265 }
\DoxyCodeLine{266   \textcolor{comment}{! calls to various wind options}}
\DoxyCodeLine{267   \textcolor{keywordflow}{if} (cs\%variable\_winds .or. cs\%first\_call\_set\_forcing) \textcolor{keywordflow}{then}}
\DoxyCodeLine{268 }
\DoxyCodeLine{269     \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{270       \textcolor{keyword}{call }wind\_forcing\_from\_file(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{271     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"data\_override"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{272       \textcolor{keyword}{call }wind\_forcing\_by\_data\_override(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{273     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"2gyre"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{274       \textcolor{keyword}{call }wind\_forcing\_2gyre(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{275     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"1gyre"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{276       \textcolor{keyword}{call }wind\_forcing\_1gyre(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{277     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"gyres"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{278       \textcolor{keyword}{call }wind\_forcing\_gyres(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{279     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"zero"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{280       \textcolor{keyword}{call }wind\_forcing\_const(sfc\_state, forces, 0., 0., day\_center, g, us, cs)}
\DoxyCodeLine{281     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{282       \textcolor{keyword}{call }wind\_forcing\_const(sfc\_state, forces, cs\%tau\_x0, cs\%tau\_y0, day\_center, g, us, cs)}
\DoxyCodeLine{283     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"Neverworld"} .or. trim(cs\%wind\_config) == \textcolor{stringliteral}{"Neverland"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{284       \textcolor{keyword}{call }neverworld\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{285     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"scurves"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{286       \textcolor{keyword}{call }scurve\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs)}
\DoxyCodeLine{287     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"ideal\_hurr"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{288       \textcolor{keyword}{call }idealized\_hurricane\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs\%idealized\_hurricane\_CSp)}
\DoxyCodeLine{289     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"SCM\_ideal\_hurr"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{290       \textcolor{keyword}{call }scm\_idealized\_hurricane\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs\%idealized\_hurricane\_CSp)}
\DoxyCodeLine{291     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{292       \textcolor{keyword}{call }scm\_cvmix\_tests\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs\%SCM\_CVmix\_tests\_CSp)}
\DoxyCodeLine{293     \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"USER"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{294       \textcolor{keyword}{call }user\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs\%user\_forcing\_CSp)}
\DoxyCodeLine{295     \textcolor{keywordflow}{elseif} (cs\%variable\_winds .and. .not.cs\%first\_call\_set\_forcing) \textcolor{keywordflow}{then}}
\DoxyCodeLine{296       \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{297        \textcolor{stringliteral}{"MOM\_surface\_forcing: Variable winds defined with no wind config"})}
\DoxyCodeLine{298     \textcolor{keywordflow}{else}}
\DoxyCodeLine{299        \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{300        \textcolor{stringliteral}{"MOM\_surface\_forcing:Unrecognized wind config "}//trim(cs\%wind\_config))}
\DoxyCodeLine{301 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{302 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{303 }
\DoxyCodeLine{304   \textcolor{comment}{! calls to various buoyancy forcing options}}
\DoxyCodeLine{305   \textcolor{keywordflow}{if} (cs\%restorebuoy .and. .not.cs\%variable\_buoyforce) \textcolor{keywordflow}{then}}
\DoxyCodeLine{306     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"With RESTOREBUOY = True, VARIABLE\_BUOYFORCE = True should be used. "}//\&}
\DoxyCodeLine{307                           \textcolor{stringliteral}{"Otherwise, this can lead to diverging solutions when a simulation "}//\&}
\DoxyCodeLine{308                           \textcolor{stringliteral}{"is continued using a restart file."})}
\DoxyCodeLine{309 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{310 }
\DoxyCodeLine{311   \textcolor{keywordflow}{if} ((cs\%variable\_buoyforce .or. cs\%first\_call\_set\_forcing) .and. \&}
\DoxyCodeLine{312       (.not.cs\%adiabatic)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{313     \textcolor{keywordflow}{if} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{314       \textcolor{keyword}{call }buoyancy\_forcing\_from\_files(sfc\_state, fluxes, day\_center, dt, g, us, cs)}
\DoxyCodeLine{315     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"data\_override"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{316       \textcolor{keyword}{call }buoyancy\_forcing\_from\_data\_override(sfc\_state, fluxes, day\_center, dt, g, us, cs)}
\DoxyCodeLine{317     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"zero"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{318       \textcolor{keyword}{call }buoyancy\_forcing\_zero(sfc\_state, fluxes, day\_center, dt, g, cs)}
\DoxyCodeLine{319     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{320       \textcolor{keyword}{call }buoyancy\_forcing\_const(sfc\_state, fluxes, day\_center, dt, g, us, cs)}
\DoxyCodeLine{321     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"linear"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{322       \textcolor{keyword}{call }buoyancy\_forcing\_linear(sfc\_state, fluxes, day\_center, dt, g, us, cs)}
\DoxyCodeLine{323     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"MESO"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{324       \textcolor{keyword}{call }meso\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs\%MESO\_forcing\_CSp)}
\DoxyCodeLine{325     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{326       \textcolor{keyword}{call }scm\_cvmix\_tests\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, g, us, cs\%SCM\_CVmix\_tests\_CSp)}
\DoxyCodeLine{327     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"USER"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{328       \textcolor{keyword}{call }user\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs\%user\_forcing\_CSp)}
\DoxyCodeLine{329     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"BFB"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{330       \textcolor{keyword}{call }bfb\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs\%BFB\_forcing\_CSp)}
\DoxyCodeLine{331     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"dumbbell"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{332       \textcolor{keyword}{call }dumbbell\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs\%dumbbell\_forcing\_CSp)}
\DoxyCodeLine{333     \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"NONE"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{334       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_surface\_forcing: buoyancy forcing has been set to omitted."})}
\DoxyCodeLine{335     \textcolor{keywordflow}{elseif} (cs\%variable\_buoyforce .and. .not.cs\%first\_call\_set\_forcing) \textcolor{keywordflow}{then}}
\DoxyCodeLine{336       \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{337        \textcolor{stringliteral}{"MOM\_surface\_forcing: Variable buoy defined with no buoy config."})}
\DoxyCodeLine{338     \textcolor{keywordflow}{else}}
\DoxyCodeLine{339        \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{340        \textcolor{stringliteral}{"MOM\_surface\_forcing: Unrecognized buoy config "}//trim(cs\%buoy\_config))}
\DoxyCodeLine{341 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{342 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{343 }
\DoxyCodeLine{344   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%tracer\_flow\_CSp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{345     \textcolor{keyword}{call }call\_tracer\_set\_forcing(sfc\_state, fluxes, day\_start, day\_interval, g, cs\%tracer\_flow\_CSp)}
\DoxyCodeLine{346 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{347 }
\DoxyCodeLine{348   \textcolor{comment}{! Allow for user-written code to alter the fluxes after all the above}}
\DoxyCodeLine{349   \textcolor{keyword}{call }user\_alter\_forcing(sfc\_state, fluxes, day\_center, g, cs\%urf\_CS)}
\DoxyCodeLine{350 }
\DoxyCodeLine{351   \textcolor{comment}{! Fields that exist in both the forcing and mech\_forcing types must be copied.}}
\DoxyCodeLine{352   \textcolor{keywordflow}{if} (cs\%variable\_winds .or. cs\%first\_call\_set\_forcing) \textcolor{keywordflow}{then}}
\DoxyCodeLine{353     \textcolor{keyword}{call }copy\_common\_forcing\_fields(forces, fluxes, g)}
\DoxyCodeLine{354     \textcolor{keyword}{call }set\_derived\_forcing\_fields(forces, fluxes, g, us, cs\%Rho0)}
\DoxyCodeLine{355 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{356 }
\DoxyCodeLine{357   \textcolor{keywordflow}{if} ((cs\%variable\_buoyforce .or. cs\%first\_call\_set\_forcing) .and. \&}
\DoxyCodeLine{358       (.not.cs\%adiabatic)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{359     \textcolor{keyword}{call }set\_net\_mass\_forcing(fluxes, forces, g, us)}
\DoxyCodeLine{360 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{361 }
\DoxyCodeLine{362   cs\%first\_call\_set\_forcing = .false.}
\DoxyCodeLine{363 }
\DoxyCodeLine{364   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_forcing)}
\DoxyCodeLine{365   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"set\_forcing"})}
\DoxyCodeLine{366 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a645590ad6b9208812337b6ccbed1d01a}\label{namespacemom__surface__forcing_a645590ad6b9208812337b6ccbed1d01a}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!surface\_forcing\_end@{surface\_forcing\_end}}
\index{surface\_forcing\_end@{surface\_forcing\_end}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{surface\_forcing\_end()}{surface\_forcing\_end()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::surface\+\_\+forcing\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS,  }\item[{type(forcing), intent(inout), optional}]{fluxes }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Deallocate memory associated with the surface forcing module. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\end{DoxyParams}


Definition at line 1967 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1967   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}    :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1968 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1969   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{1970 \textcolor{comment}{! Arguments:  CS - A pointer to the control structure returned by a previous}}
\DoxyCodeLine{1971 \textcolor{comment}{!                  call to surface\_forcing\_init, it will be deallocated here.}}
\DoxyCodeLine{1972 \textcolor{comment}{!  (inout)    fluxes - A structure containing pointers to any possible}}
\DoxyCodeLine{1973 \textcolor{comment}{!                     forcing fields.  Unused fields have NULL ptrs.}}
\DoxyCodeLine{1974 }
\DoxyCodeLine{1975   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keyword}{call }deallocate\_forcing\_type(fluxes)}
\DoxyCodeLine{1976 }
\DoxyCodeLine{1977 \textcolor{comment}{!\#CTRL\#  call controlled\_forcing\_end(CS\%ctrl\_forcing\_CSp)}}
\DoxyCodeLine{1978 }
\DoxyCodeLine{1979   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{deallocate}(cs)}
\DoxyCodeLine{1980   cs => null()}
\DoxyCodeLine{1981 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a791cb2bd2daa4fd3f036b121995bfb6c}\label{namespacemom__surface__forcing_a791cb2bd2daa4fd3f036b121995bfb6c}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!surface\_forcing\_init@{surface\_forcing\_init}}
\index{surface\_forcing\_init@{surface\_forcing\_init}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{surface\_forcing\_init()}{surface\_forcing\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+surface\+\_\+forcing\+::surface\+\_\+forcing\+\_\+init (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file,  }\item[{type(diag\+\_\+ctrl), intent(inout), target}]{diag,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS,  }\item[{type(tracer\+\_\+flow\+\_\+control\+\_\+cs), pointer}]{tracer\+\_\+flow\+\_\+\+C\+Sp }\end{DoxyParamCaption})}



Initialize the surface forcing module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & structure used to regulate diagnostic output \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
 & {\em tracer\+\_\+flow\+\_\+csp} & Forcing for tracers? \\
\hline
\end{DoxyParams}


Definition at line 1540 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1540   \textcolor{keywordtype}{type}(time\_type),              \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{1541   \textcolor{keywordtype}{type}(ocean\_grid\_type),        \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{1542   \textcolor{keywordtype}{type}(unit\_scale\_type),        \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{1543   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}}
\DoxyCodeLine{1544   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},      \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< structure used to regulate diagnostic output}}
\DoxyCodeLine{1545   \textcolor{keywordtype}{type}(surface\_forcing\_CS),     \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{1546 \textcolor{comment}{                                                      !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{1547   \textcolor{keywordtype}{type}(tracer\_flow\_control\_CS), \textcolor{keywordtype}{pointer}       :: tracer\_flow\_CSp\textcolor{comment}{ !< Forcing for tracers?}}
\DoxyCodeLine{1548 }
\DoxyCodeLine{1549   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{1550   \textcolor{keywordtype}{type}(directories)  :: dirs}
\DoxyCodeLine{1551   \textcolor{keywordtype}{logical}            :: new\_sim}
\DoxyCodeLine{1552   \textcolor{keywordtype}{type}(time\_type)    :: Time\_frc}
\DoxyCodeLine{1553   \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1554 \textcolor{preprocessor}{\# include "version\_variable.h"}}
\DoxyCodeLine{1555 \textcolor{preprocessor}{}\textcolor{keywordtype}{  real} :: flux\_const\_default \textcolor{comment}{! The unscaled value of FLUXCONST [m day-1]}}
\DoxyCodeLine{1556   \textcolor{keywordtype}{logical} :: default\_2018\_answers}
\DoxyCodeLine{1557   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_surface\_forcing"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1558   \textcolor{keywordtype}{character(len=200)} :: filename, gust\_file \textcolor{comment}{! The name of the gustiness input file.}}
\DoxyCodeLine{1559 }
\DoxyCodeLine{1560   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1561     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"surface\_forcing\_init called with an associated "}// \&}
\DoxyCodeLine{1562                             \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{1563     \textcolor{keywordflow}{return}}
\DoxyCodeLine{1564 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1565   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{1566 }
\DoxyCodeLine{1567   id\_clock\_forcing=cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean surface forcing)'}, grain=clock\_module)}
\DoxyCodeLine{1568   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_forcing)}
\DoxyCodeLine{1569 }
\DoxyCodeLine{1570   cs\%diag => diag}
\DoxyCodeLine{1571   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tracer\_flow\_csp)) cs\%tracer\_flow\_CSp => tracer\_flow\_csp}
\DoxyCodeLine{1572 }
\DoxyCodeLine{1573   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{1574   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{''})}
\DoxyCodeLine{1575   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, cs\%use\_temperature, \&}
\DoxyCodeLine{1576                  \textcolor{stringliteral}{"If true, Temperature and salinity are used as state "}//\&}
\DoxyCodeLine{1577                  \textcolor{stringliteral}{"variables."}, default=.true.)}
\DoxyCodeLine{1578   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, cs\%inputdir, \&}
\DoxyCodeLine{1579                  \textcolor{stringliteral}{"The directory in which all input files are found."}, \&}
\DoxyCodeLine{1580                  default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{1581   cs\%inputdir = slasher(cs\%inputdir)}
\DoxyCodeLine{1582 }
\DoxyCodeLine{1583   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADIABATIC"}, cs\%adiabatic, \&}
\DoxyCodeLine{1584                  \textcolor{stringliteral}{"There are no diapycnal mass fluxes if ADIABATIC is "}//\&}
\DoxyCodeLine{1585                  \textcolor{stringliteral}{"true. This assumes that KD = KDML = 0.0 and that "}//\&}
\DoxyCodeLine{1586                  \textcolor{stringliteral}{"there is no buoyancy forcing, but makes the model "}//\&}
\DoxyCodeLine{1587                  \textcolor{stringliteral}{"faster by eliminating subroutine calls."}, default=.false.)}
\DoxyCodeLine{1588   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VARIABLE\_WINDS"}, cs\%variable\_winds, \&}
\DoxyCodeLine{1589                  \textcolor{stringliteral}{"If true, the winds vary in time after the initialization."}, \&}
\DoxyCodeLine{1590                  default=.true.)}
\DoxyCodeLine{1591   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VARIABLE\_BUOYFORCE"}, cs\%variable\_buoyforce, \&}
\DoxyCodeLine{1592                  \textcolor{stringliteral}{"If true, the buoyancy forcing varies in time after the "}//\&}
\DoxyCodeLine{1593                  \textcolor{stringliteral}{"initialization of the model."}, default=.true.)}
\DoxyCodeLine{1594 }
\DoxyCodeLine{1595   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BUOY\_CONFIG"}, cs\%buoy\_config, \&}
\DoxyCodeLine{1596                  \textcolor{stringliteral}{"The character string that indicates how buoyancy forcing "}//\&}
\DoxyCodeLine{1597                  \textcolor{stringliteral}{"is specified. Valid options include (file), (zero), "}//\&}
\DoxyCodeLine{1598                  \textcolor{stringliteral}{"(linear), (USER), (BFB) and (NONE)."}, default=\textcolor{stringliteral}{"zero"})}
\DoxyCodeLine{1599   \textcolor{keywordflow}{if} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1600     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ARCHAIC\_OMIP\_FORCING\_FILE"}, cs\%archaic\_OMIP\_file, \&}
\DoxyCodeLine{1601                  \textcolor{stringliteral}{"If true, use the forcing variable decomposition from "}//\&}
\DoxyCodeLine{1602                  \textcolor{stringliteral}{"the old German OMIP prescription that predated CORE. If "}//\&}
\DoxyCodeLine{1603                  \textcolor{stringliteral}{"false, use the variable groupings available from MOM "}//\&}
\DoxyCodeLine{1604                  \textcolor{stringliteral}{"output diagnostics of forcing variables."}, default=.true.)}
\DoxyCodeLine{1605     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1606       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVEDOWN\_FILE"}, cs\%longwave\_file, \&}
\DoxyCodeLine{1607                  \textcolor{stringliteral}{"The file with the downward longwave heat flux, in "}//\&}
\DoxyCodeLine{1608                  \textcolor{stringliteral}{"variable lwdn\_sfc."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1609       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVEUP\_FILE"}, cs\%longwaveup\_file, \&}
\DoxyCodeLine{1610                  \textcolor{stringliteral}{"The file with the upward longwave heat flux, in "}//\&}
\DoxyCodeLine{1611                  \textcolor{stringliteral}{"variable lwup\_sfc."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1612       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAPORATION\_FILE"}, cs\%evaporation\_file, \&}
\DoxyCodeLine{1613                  \textcolor{stringliteral}{"The file with the evaporative moisture flux, in "}//\&}
\DoxyCodeLine{1614                  \textcolor{stringliteral}{"variable evap."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1615       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLEHEAT\_FILE"}, cs\%sensibleheat\_file, \&}
\DoxyCodeLine{1616                  \textcolor{stringliteral}{"The file with the sensible heat flux, in "}//\&}
\DoxyCodeLine{1617                  \textcolor{stringliteral}{"variable shflx."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1618       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVEUP\_FILE"}, cs\%shortwaveup\_file, \&}
\DoxyCodeLine{1619                  \textcolor{stringliteral}{"The file with the upward shortwave heat flux."}, \&}
\DoxyCodeLine{1620                  fail\_if\_missing=.true.)}
\DoxyCodeLine{1621       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVEDOWN\_FILE"}, cs\%shortwave\_file, \&}
\DoxyCodeLine{1622                  \textcolor{stringliteral}{"The file with the downward shortwave heat flux."}, \&}
\DoxyCodeLine{1623                  fail\_if\_missing=.true.)}
\DoxyCodeLine{1624       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FILE"}, cs\%snow\_file, \&}
\DoxyCodeLine{1625                  \textcolor{stringliteral}{"The file with the downward frozen precip flux, in "}//\&}
\DoxyCodeLine{1626                  \textcolor{stringliteral}{"variable snow."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1627       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PRECIP\_FILE"}, cs\%rain\_file, \&}
\DoxyCodeLine{1628                  \textcolor{stringliteral}{"The file with the downward total precip flux, in "}//\&}
\DoxyCodeLine{1629                  \textcolor{stringliteral}{"variable precip."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1630       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FRESHDISCHARGE\_FILE"}, cs\%runoff\_file, \&}
\DoxyCodeLine{1631                  \textcolor{stringliteral}{"The file with the fresh and frozen runoff/calving fluxes, "}//\&}
\DoxyCodeLine{1632                  \textcolor{stringliteral}{"invariables disch\_w and disch\_s."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1633 }
\DoxyCodeLine{1634       \textcolor{comment}{! These variable names are hard-coded, per the archaic OMIP conventions.}}
\DoxyCodeLine{1635       cs\%latentheat\_file = cs\%evaporation\_file ; cs\%latent\_var = \textcolor{stringliteral}{"evap"}}
\DoxyCodeLine{1636       cs\%LW\_var = \textcolor{stringliteral}{"lwdn\_sfc"}; cs\%SW\_var = \textcolor{stringliteral}{"swdn\_sfc"}; cs\%sens\_var = \textcolor{stringliteral}{"shflx"}}
\DoxyCodeLine{1637       cs\%evap\_var = \textcolor{stringliteral}{"evap"}; cs\%rain\_var = \textcolor{stringliteral}{"precip"}; cs\%snow\_var = \textcolor{stringliteral}{"snow"}}
\DoxyCodeLine{1638       cs\%lrunoff\_var = \textcolor{stringliteral}{"disch\_w"}; cs\%frunoff\_var = \textcolor{stringliteral}{"disch\_s"}}
\DoxyCodeLine{1639 }
\DoxyCodeLine{1640     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1641       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVE\_FILE"}, cs\%longwave\_file, \&}
\DoxyCodeLine{1642                  \textcolor{stringliteral}{"The file with the longwave heat flux, in the variable "}//\&}
\DoxyCodeLine{1643                  \textcolor{stringliteral}{"given by LONGWAVE\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1644       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVE\_FORCING\_VAR"}, cs\%LW\_var, \&}
\DoxyCodeLine{1645                  \textcolor{stringliteral}{"The variable with the longwave forcing field."}, default=\textcolor{stringliteral}{"LW"})}
\DoxyCodeLine{1646 }
\DoxyCodeLine{1647       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVE\_FILE"}, cs\%shortwave\_file, \&}
\DoxyCodeLine{1648                  \textcolor{stringliteral}{"The file with the shortwave heat flux, in the variable "}//\&}
\DoxyCodeLine{1649                  \textcolor{stringliteral}{"given by SHORTWAVE\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1650       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVE\_FORCING\_VAR"}, cs\%SW\_var, \&}
\DoxyCodeLine{1651                  \textcolor{stringliteral}{"The variable with the shortwave forcing field."}, default=\textcolor{stringliteral}{"SW"})}
\DoxyCodeLine{1652 }
\DoxyCodeLine{1653       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAPORATION\_FILE"}, cs\%evaporation\_file, \&}
\DoxyCodeLine{1654                  \textcolor{stringliteral}{"The file with the evaporative moisture flux, in the "}//\&}
\DoxyCodeLine{1655                  \textcolor{stringliteral}{"variable given by EVAP\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1656       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAP\_FORCING\_VAR"}, cs\%evap\_var, \&}
\DoxyCodeLine{1657                  \textcolor{stringliteral}{"The variable with the evaporative moisture flux."}, \&}
\DoxyCodeLine{1658                  default=\textcolor{stringliteral}{"evap"})}
\DoxyCodeLine{1659 }
\DoxyCodeLine{1660       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENTHEAT\_FILE"}, cs\%latentheat\_file, \&}
\DoxyCodeLine{1661                  \textcolor{stringliteral}{"The file with the latent heat flux, in the variable "}//\&}
\DoxyCodeLine{1662                  \textcolor{stringliteral}{"given by LATENT\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1663       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_FORCING\_VAR"}, cs\%latent\_var, \&}
\DoxyCodeLine{1664                  \textcolor{stringliteral}{"The variable with the latent heat flux."}, default=\textcolor{stringliteral}{"latent"})}
\DoxyCodeLine{1665 }
\DoxyCodeLine{1666       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLEHEAT\_FILE"}, cs\%sensibleheat\_file, \&}
\DoxyCodeLine{1667                  \textcolor{stringliteral}{"The file with the sensible heat flux, in the variable "}//\&}
\DoxyCodeLine{1668                  \textcolor{stringliteral}{"given by SENSIBLE\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1669       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLE\_FORCING\_VAR"}, cs\%sens\_var, \&}
\DoxyCodeLine{1670                  \textcolor{stringliteral}{"The variable with the sensible heat flux."}, default=\textcolor{stringliteral}{"sensible"})}
\DoxyCodeLine{1671 }
\DoxyCodeLine{1672       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RAIN\_FILE"}, cs\%rain\_file, \&}
\DoxyCodeLine{1673                  \textcolor{stringliteral}{"The file with the liquid precipitation flux, in the "}//\&}
\DoxyCodeLine{1674                  \textcolor{stringliteral}{"variable given by RAIN\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1675       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RAIN\_FORCING\_VAR"}, cs\%rain\_var, \&}
\DoxyCodeLine{1676                  \textcolor{stringliteral}{"The variable with the liquid precipitation flux."}, \&}
\DoxyCodeLine{1677                  default=\textcolor{stringliteral}{"liq\_precip"})}
\DoxyCodeLine{1678       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FILE"}, cs\%snow\_file, \&}
\DoxyCodeLine{1679                  \textcolor{stringliteral}{"The file with the frozen precipitation flux, in the "}//\&}
\DoxyCodeLine{1680                  \textcolor{stringliteral}{"variable given by SNOW\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1681       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FORCING\_VAR"}, cs\%snow\_var, \&}
\DoxyCodeLine{1682                  \textcolor{stringliteral}{"The variable with the frozen precipitation flux."}, \&}
\DoxyCodeLine{1683                  default=\textcolor{stringliteral}{"froz\_precip"})}
\DoxyCodeLine{1684 }
\DoxyCodeLine{1685       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RUNOFF\_FILE"}, cs\%runoff\_file, \&}
\DoxyCodeLine{1686                  \textcolor{stringliteral}{"The file with the fresh and frozen runoff/calving "}//\&}
\DoxyCodeLine{1687                  \textcolor{stringliteral}{"fluxes, in variables given by LIQ\_RUNOFF\_FORCING\_VAR "}//\&}
\DoxyCodeLine{1688                  \textcolor{stringliteral}{"and FROZ\_RUNOFF\_FORCING\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1689       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LIQ\_RUNOFF\_FORCING\_VAR"}, cs\%lrunoff\_var, \&}
\DoxyCodeLine{1690                  \textcolor{stringliteral}{"The variable with the liquid runoff flux."}, \&}
\DoxyCodeLine{1691                  default=\textcolor{stringliteral}{"liq\_runoff"})}
\DoxyCodeLine{1692       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FROZ\_RUNOFF\_FORCING\_VAR"}, cs\%frunoff\_var, \&}
\DoxyCodeLine{1693                  \textcolor{stringliteral}{"The variable with the frozen runoff flux."}, \&}
\DoxyCodeLine{1694                  default=\textcolor{stringliteral}{"froz\_runoff"})}
\DoxyCodeLine{1695 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1696 }
\DoxyCodeLine{1697     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSTRESTORE\_FILE"}, cs\%SSTrestore\_file, \&}
\DoxyCodeLine{1698                  \textcolor{stringliteral}{"The file with the SST toward which to restore in the "}//\&}
\DoxyCodeLine{1699                  \textcolor{stringliteral}{"variable given by SST\_RESTORE\_VAR."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1700     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SALINITYRESTORE\_FILE"}, cs\%salinityrestore\_file, \&}
\DoxyCodeLine{1701                  \textcolor{stringliteral}{"The file with the surface salinity toward which to "}//\&}
\DoxyCodeLine{1702                  \textcolor{stringliteral}{"restore in the variable given by SSS\_RESTORE\_VAR."}, \&}
\DoxyCodeLine{1703                  fail\_if\_missing=.true.)}
\DoxyCodeLine{1704 }
\DoxyCodeLine{1705     \textcolor{keywordflow}{if} (cs\%archaic\_OMIP\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1706       cs\%SST\_restore\_var = \textcolor{stringliteral}{"TEMP"} ; cs\%SSS\_restore\_var = \textcolor{stringliteral}{"SALT"}}
\DoxyCodeLine{1707     \textcolor{keywordflow}{else}}
\DoxyCodeLine{1708       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_RESTORE\_VAR"}, cs\%SST\_restore\_var, \&}
\DoxyCodeLine{1709                  \textcolor{stringliteral}{"The variable with the SST toward which to restore."}, \&}
\DoxyCodeLine{1710                  default=\textcolor{stringliteral}{"SST"})}
\DoxyCodeLine{1711       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_RESTORE\_VAR"}, cs\%SSS\_restore\_var, \&}
\DoxyCodeLine{1712                  \textcolor{stringliteral}{"The variable with the SSS toward which to restore."}, \&}
\DoxyCodeLine{1713                  default=\textcolor{stringliteral}{"SSS"})}
\DoxyCodeLine{1714 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1715 }
\DoxyCodeLine{1716     \textcolor{comment}{! Add inputdir to the file names.}}
\DoxyCodeLine{1717     cs\%shortwave\_file = trim(cs\%inputdir)//trim(cs\%shortwave\_file)}
\DoxyCodeLine{1718     cs\%longwave\_file = trim(cs\%inputdir)//trim(cs\%longwave\_file)}
\DoxyCodeLine{1719     cs\%sensibleheat\_file = trim(cs\%inputdir)//trim(cs\%sensibleheat\_file)}
\DoxyCodeLine{1720     cs\%latentheat\_file = trim(cs\%inputdir)//trim(cs\%latentheat\_file)}
\DoxyCodeLine{1721     cs\%evaporation\_file = trim(cs\%inputdir)//trim(cs\%evaporation\_file)}
\DoxyCodeLine{1722     cs\%snow\_file = trim(cs\%inputdir)//trim(cs\%snow\_file)}
\DoxyCodeLine{1723     cs\%rain\_file = trim(cs\%inputdir)//trim(cs\%rain\_file)}
\DoxyCodeLine{1724     cs\%runoff\_file = trim(cs\%inputdir)//trim(cs\%runoff\_file)}
\DoxyCodeLine{1725 }
\DoxyCodeLine{1726     cs\%shortwaveup\_file = trim(cs\%inputdir)//trim(cs\%shortwaveup\_file)}
\DoxyCodeLine{1727     cs\%longwaveup\_file = trim(cs\%inputdir)//trim(cs\%longwaveup\_file)}
\DoxyCodeLine{1728 }
\DoxyCodeLine{1729     cs\%SSTrestore\_file = trim(cs\%inputdir)//trim(cs\%SSTrestore\_file)}
\DoxyCodeLine{1730     cs\%salinityrestore\_file = trim(cs\%inputdir)//trim(cs\%salinityrestore\_file)}
\DoxyCodeLine{1731   \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1732     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLE\_HEAT\_FLUX"}, cs\%constantHeatForcing, \&}
\DoxyCodeLine{1733                  \textcolor{stringliteral}{"A constant heat forcing (positive into ocean) applied "}//\&}
\DoxyCodeLine{1734                  \textcolor{stringliteral}{"through the sensible heat flux field. "}, \&}
\DoxyCodeLine{1735                  units=\textcolor{stringliteral}{'W/m2'}, scale=us\%W\_m2\_to\_QRZ\_T, fail\_if\_missing=.true.)}
\DoxyCodeLine{1736 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1737   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_CONFIG"}, cs\%wind\_config, \&}
\DoxyCodeLine{1738                  \textcolor{stringliteral}{"The character string that indicates how wind forcing "}//\&}
\DoxyCodeLine{1739                  \textcolor{stringliteral}{"is specified. Valid options include (file), (2gyre), "}//\&}
\DoxyCodeLine{1740                  \textcolor{stringliteral}{"(1gyre), (gyres), (zero), and (USER)."}, default=\textcolor{stringliteral}{"zero"})}
\DoxyCodeLine{1741   \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1742     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_FILE"}, cs\%wind\_file, \&}
\DoxyCodeLine{1743                  \textcolor{stringliteral}{"The file in which the wind stresses are found in "}//\&}
\DoxyCodeLine{1744                  \textcolor{stringliteral}{"variables STRESS\_X and STRESS\_Y."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1745     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_X\_VAR"},cs\%stress\_x\_var, \&}
\DoxyCodeLine{1746                  \textcolor{stringliteral}{"The name of the x-wind stress variable in WIND\_FILE."}, \&}
\DoxyCodeLine{1747                  default=\textcolor{stringliteral}{"STRESS\_X"})}
\DoxyCodeLine{1748     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_Y\_VAR"}, cs\%stress\_y\_var, \&}
\DoxyCodeLine{1749                  \textcolor{stringliteral}{"The name of the y-wind stress variable in WIND\_FILE."}, \&}
\DoxyCodeLine{1750                  default=\textcolor{stringliteral}{"STRESS\_Y"})}
\DoxyCodeLine{1751     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_STAGGER"},cs\%wind\_stagger, \&}
\DoxyCodeLine{1752                  \textcolor{stringliteral}{"A character indicating how the wind stress components "}//\&}
\DoxyCodeLine{1753                  \textcolor{stringliteral}{"are staggered in WIND\_FILE.  This may be A or C for now."}, \&}
\DoxyCodeLine{1754                  default=\textcolor{stringliteral}{"C"})}
\DoxyCodeLine{1755     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_SCALE"}, cs\%wind\_scale, \&}
\DoxyCodeLine{1756                  \textcolor{stringliteral}{"A value by which the wind stresses in WIND\_FILE are rescaled."}, \&}
\DoxyCodeLine{1757                  default=1.0, units=\textcolor{stringliteral}{"nondim"})}
\DoxyCodeLine{1758     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USTAR\_FORCING\_VAR"}, cs\%ustar\_var, \&}
\DoxyCodeLine{1759                  \textcolor{stringliteral}{"The name of the friction velocity variable in WIND\_FILE "}//\&}
\DoxyCodeLine{1760                  \textcolor{stringliteral}{"or blank to get ustar from the wind stresses plus the "}//\&}
\DoxyCodeLine{1761                  \textcolor{stringliteral}{"gustiness."}, default=\textcolor{stringliteral}{" "}, units=\textcolor{stringliteral}{"nondim"})}
\DoxyCodeLine{1762     cs\%wind\_file = trim(cs\%inputdir) // trim(cs\%wind\_file)}
\DoxyCodeLine{1763 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1764   \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"gyres"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1765     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_CONST"}, cs\%gyres\_taux\_const, \&}
\DoxyCodeLine{1766                  \textcolor{stringliteral}{"With the gyres wind\_config, the constant offset in the "}//\&}
\DoxyCodeLine{1767                  \textcolor{stringliteral}{"zonal wind stress profile: "}//\&}
\DoxyCodeLine{1768                  \textcolor{stringliteral}{"  A in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, \&}
\DoxyCodeLine{1769                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)}
\DoxyCodeLine{1770     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_SIN\_AMP"},cs\%gyres\_taux\_sin\_amp, \&}
\DoxyCodeLine{1771                  \textcolor{stringliteral}{"With the gyres wind\_config, the sine amplitude in the "}//\&}
\DoxyCodeLine{1772                  \textcolor{stringliteral}{"zonal wind stress profile: "}//\&}
\DoxyCodeLine{1773                  \textcolor{stringliteral}{"  B in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, \&}
\DoxyCodeLine{1774                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)}
\DoxyCodeLine{1775     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_COS\_AMP"},cs\%gyres\_taux\_cos\_amp, \&}
\DoxyCodeLine{1776                  \textcolor{stringliteral}{"With the gyres wind\_config, the cosine amplitude in "}//\&}
\DoxyCodeLine{1777                  \textcolor{stringliteral}{"the zonal wind stress profile: "}//\&}
\DoxyCodeLine{1778                  \textcolor{stringliteral}{"  C in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, \&}
\DoxyCodeLine{1779                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)}
\DoxyCodeLine{1780     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_N\_PIS"},cs\%gyres\_taux\_n\_pis, \&}
\DoxyCodeLine{1781                  \textcolor{stringliteral}{"With the gyres wind\_config, the number of gyres in "}//\&}
\DoxyCodeLine{1782                  \textcolor{stringliteral}{"the zonal wind stress profile: "}//\&}
\DoxyCodeLine{1783                  \textcolor{stringliteral}{"  n in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, \&}
\DoxyCodeLine{1784                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)}
\DoxyCodeLine{1785     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, \&}
\DoxyCodeLine{1786                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, \&}
\DoxyCodeLine{1787                  default=.false.)}
\DoxyCodeLine{1788     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_GYRES\_2018\_ANSWERS"}, cs\%answers\_2018, \&}
\DoxyCodeLine{1789                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the answers "}//\&}
\DoxyCodeLine{1790                  \textcolor{stringliteral}{"from the end of 2018.  Otherwise, use expressions for the gyre friction velocities "}//\&}
\DoxyCodeLine{1791                  \textcolor{stringliteral}{"that are rotationally invariant and more likely to be the same between compilers."}, \&}
\DoxyCodeLine{1792                  default=default\_2018\_answers)}
\DoxyCodeLine{1793   \textcolor{keywordflow}{else}}
\DoxyCodeLine{1794     cs\%answers\_2018 = .false.}
\DoxyCodeLine{1795 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1796   \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"scurves"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1797     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_SCURVES\_LATS"}, cs\%scurves\_ydata, \&}
\DoxyCodeLine{1798                  \textcolor{stringliteral}{"A list of latitudes defining a piecewise scurve profile "}//\&}
\DoxyCodeLine{1799                  \textcolor{stringliteral}{"for zonal wind stress."}, \&}
\DoxyCodeLine{1800                  units=\textcolor{stringliteral}{"degrees N"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1801     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_SCURVES\_TAUX"}, cs\%scurves\_taux, \&}
\DoxyCodeLine{1802                  \textcolor{stringliteral}{"A list of zonal wind stress values at latitudes "}//\&}
\DoxyCodeLine{1803                  \textcolor{stringliteral}{"WIND\_SCURVES\_LATS defining a piecewise scurve profile."}, \&}
\DoxyCodeLine{1804                  units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1805 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1806   \textcolor{keywordflow}{if} ((trim(cs\%wind\_config) == \textcolor{stringliteral}{"2gyre"}) .or. \&}
\DoxyCodeLine{1807       (trim(cs\%wind\_config) == \textcolor{stringliteral}{"1gyre"}) .or. \&}
\DoxyCodeLine{1808       (trim(cs\%wind\_config) == \textcolor{stringliteral}{"gyres"}) .or. \&}
\DoxyCodeLine{1809       (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"linear"})) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1810     cs\%south\_lat = g\%south\_lat}
\DoxyCodeLine{1811     cs\%len\_lat = g\%len\_lat}
\DoxyCodeLine{1812 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1813 }
\DoxyCodeLine{1814   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs\%Rho0, \&}
\DoxyCodeLine{1815                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//\&}
\DoxyCodeLine{1816                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//\&}
\DoxyCodeLine{1817                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//\&}
\DoxyCodeLine{1818                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, \&}
\DoxyCodeLine{1819                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{1820   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTOREBUOY"}, cs\%restorebuoy, \&}
\DoxyCodeLine{1821                  \textcolor{stringliteral}{"If true, the buoyancy fluxes drive the model back "}//\&}
\DoxyCodeLine{1822                  \textcolor{stringliteral}{"toward some specified surface state with a rate "}//\&}
\DoxyCodeLine{1823                  \textcolor{stringliteral}{"given by FLUXCONST."}, default= .false.)}
\DoxyCodeLine{1824   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_FUSION"}, cs\%latent\_heat\_fusion, \&}
\DoxyCodeLine{1825                  \textcolor{stringliteral}{"The latent heat of fusion."}, default=hlf, \&}
\DoxyCodeLine{1826                  units=\textcolor{stringliteral}{"J/kg"}, scale=us\%J\_kg\_to\_Q)}
\DoxyCodeLine{1827   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_VAPORIZATION"}, cs\%latent\_heat\_vapor, \&}
\DoxyCodeLine{1828                  \textcolor{stringliteral}{"The latent heat of fusion."}, default=hlv, units=\textcolor{stringliteral}{"J/kg"}, scale=us\%J\_kg\_to\_Q)}
\DoxyCodeLine{1829   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1830     \textcolor{comment}{! These three variables use non-standard time units, but are rescaled as they are read.}}
\DoxyCodeLine{1831     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST"}, cs\%Flux\_const, \&}
\DoxyCodeLine{1832                  \textcolor{stringliteral}{"The constant that relates the restoring surface fluxes to the relative "}//\&}
\DoxyCodeLine{1833                  \textcolor{stringliteral}{"surface anomalies (akin to a piston velocity).  Note the non-MKS units."}, \&}
\DoxyCodeLine{1834                  default=0.0, units=\textcolor{stringliteral}{"m day-1"}, scale=us\%m\_to\_Z*us\%T\_to\_s/86400.0, \&}
\DoxyCodeLine{1835                  unscaled=flux\_const\_default)}
\DoxyCodeLine{1836 }
\DoxyCodeLine{1837     \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1838       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST\_T"}, cs\%Flux\_const\_T, \&}
\DoxyCodeLine{1839            \textcolor{stringliteral}{"The constant that relates the restoring surface temperature "}//\&}
\DoxyCodeLine{1840            \textcolor{stringliteral}{"flux to the relative surface anomaly (akin to a piston "}//\&}
\DoxyCodeLine{1841            \textcolor{stringliteral}{"velocity).  Note the non-MKS units."}, \&}
\DoxyCodeLine{1842            units=\textcolor{stringliteral}{"m day-1"}, scale=us\%m\_to\_Z*us\%T\_to\_s/86400.0, \&}
\DoxyCodeLine{1843            default=flux\_const\_default)}
\DoxyCodeLine{1844       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST\_S"}, cs\%Flux\_const\_S, \&}
\DoxyCodeLine{1845            \textcolor{stringliteral}{"The constant that relates the restoring surface salinity "}//\&}
\DoxyCodeLine{1846            \textcolor{stringliteral}{"flux to the relative surface anomaly (akin to a piston "}//\&}
\DoxyCodeLine{1847            \textcolor{stringliteral}{"velocity).  Note the non-MKS units."}, \&}
\DoxyCodeLine{1848            units=\textcolor{stringliteral}{"m day-1"}, scale=us\%m\_to\_Z*us\%T\_to\_s/86400.0, \&}
\DoxyCodeLine{1849            default=flux\_const\_default)}
\DoxyCodeLine{1850 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1851 }
\DoxyCodeLine{1852     \textcolor{keywordflow}{if} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"linear"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1853       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_NORTH"}, cs\%T\_north, \&}
\DoxyCodeLine{1854                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface temperature "}//\&}
\DoxyCodeLine{1855                  \textcolor{stringliteral}{"at the northern end of the domain toward which to "}//\&}
\DoxyCodeLine{1856                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)}
\DoxyCodeLine{1857       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_SOUTH"}, cs\%T\_south, \&}
\DoxyCodeLine{1858                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface temperature "}//\&}
\DoxyCodeLine{1859                  \textcolor{stringliteral}{"at the southern end of the domain toward which to "}//\&}
\DoxyCodeLine{1860                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)}
\DoxyCodeLine{1861       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_NORTH"}, cs\%S\_north, \&}
\DoxyCodeLine{1862                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface salinity "}//\&}
\DoxyCodeLine{1863                  \textcolor{stringliteral}{"at the northern end of the domain toward which to "}//\&}
\DoxyCodeLine{1864                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"PSU"}, default=35.0)}
\DoxyCodeLine{1865       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_SOUTH"}, cs\%S\_south, \&}
\DoxyCodeLine{1866                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface salinity "}//\&}
\DoxyCodeLine{1867                  \textcolor{stringliteral}{"at the southern end of the domain toward which to "}//\&}
\DoxyCodeLine{1868                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"PSU"}, default=35.0)}
\DoxyCodeLine{1869 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1870 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1871   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs\%G\_Earth, \&}
\DoxyCodeLine{1872                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, \&}
\DoxyCodeLine{1873                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80, scale=us\%m\_to\_L**2*us\%Z\_to\_m*us\%T\_to\_s**2)}
\DoxyCodeLine{1874 }
\DoxyCodeLine{1875   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_CONST"}, cs\%gust\_const, \&}
\DoxyCodeLine{1876                  \textcolor{stringliteral}{"The background gustiness in the winds."}, \&}
\DoxyCodeLine{1877                  units=\textcolor{stringliteral}{"Pa"}, default=0.0, scale=us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z)}
\DoxyCodeLine{1878   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FIX\_USTAR\_GUSTLESS\_BUG"}, cs\%fix\_ustar\_gustless\_bug, \&}
\DoxyCodeLine{1879                  \textcolor{stringliteral}{"If true correct a bug in the time-averaging of the gustless wind friction velocity"}, \&}
\DoxyCodeLine{1880                  default=.true.)}
\DoxyCodeLine{1881   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_GUST\_2D"}, cs\%read\_gust\_2d, \&}
\DoxyCodeLine{1882                  \textcolor{stringliteral}{"If true, use a 2-dimensional gustiness supplied from "}//\&}
\DoxyCodeLine{1883                  \textcolor{stringliteral}{"an input file"}, default=.false.)}
\DoxyCodeLine{1884   \textcolor{keywordflow}{if} (cs\%read\_gust\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1885     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_2D\_FILE"}, gust\_file, \&}
\DoxyCodeLine{1886                  \textcolor{stringliteral}{"The file in which the wind gustiness is found in "}//\&}
\DoxyCodeLine{1887                  \textcolor{stringliteral}{"variable gustiness."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1888     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%gust,g\%isd,g\%ied,g\%jsd,g\%jed)}
\DoxyCodeLine{1889     filename = trim(cs\%inputdir) // trim(gust\_file)}
\DoxyCodeLine{1890     \textcolor{keyword}{call }mom\_read\_data(filename,\textcolor{stringliteral}{'gustiness'},cs\%gust,g\%domain, timelevel=1, \&}
\DoxyCodeLine{1891                    scale=us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z) \textcolor{comment}{! units in file should be Pa}}
\DoxyCodeLine{1892 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1893 }
\DoxyCodeLine{1894 \textcolor{comment}{!  All parameter settings are now known.}}
\DoxyCodeLine{1895 }
\DoxyCodeLine{1896   \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"USER"} .or. trim(cs\%buoy\_config) == \textcolor{stringliteral}{"USER"} ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1897     \textcolor{keyword}{call }user\_surface\_forcing\_init(time, g, us, param\_file, diag, cs\%user\_forcing\_CSp)}
\DoxyCodeLine{1898   \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"BFB"} ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1899     \textcolor{keyword}{call }bfb\_surface\_forcing\_init(time, g, us, param\_file, diag, cs\%BFB\_forcing\_CSp)}
\DoxyCodeLine{1900   \textcolor{keywordflow}{elseif} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"dumbbell"} ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1901     \textcolor{keyword}{call }dumbbell\_surface\_forcing\_init(time, g, us, param\_file, diag, cs\%dumbbell\_forcing\_CSp)}
\DoxyCodeLine{1902   \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"MESO"} .or. trim(cs\%buoy\_config) == \textcolor{stringliteral}{"MESO"} ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1903     \textcolor{keyword}{call }meso\_surface\_forcing\_init(time, g, us, param\_file, diag, cs\%MESO\_forcing\_CSp)}
\DoxyCodeLine{1904   \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"ideal\_hurr"} .or.\&}
\DoxyCodeLine{1905           trim(cs\%wind\_config) == \textcolor{stringliteral}{"SCM\_ideal\_hurr"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1906     \textcolor{keyword}{call }idealized\_hurricane\_wind\_init(time, g, us, param\_file, cs\%idealized\_hurricane\_CSp)}
\DoxyCodeLine{1907   \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1908     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_WIND\_TAUX"}, cs\%tau\_x0, \&}
\DoxyCodeLine{1909                  \textcolor{stringliteral}{"With wind\_config const, this is the constant zonal "}//\&}
\DoxyCodeLine{1910                  \textcolor{stringliteral}{"wind-stress"}, units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1911     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_WIND\_TAUY"}, cs\%tau\_y0, \&}
\DoxyCodeLine{1912                  \textcolor{stringliteral}{"With wind\_config const, this is the constant meridional "}//\&}
\DoxyCodeLine{1913                  \textcolor{stringliteral}{"wind-stress"}, units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{1914   \textcolor{keywordflow}{elseif} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"} .or. \&}
\DoxyCodeLine{1915           trim(cs\%buoy\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1916     \textcolor{keyword}{call }scm\_cvmix\_tests\_surface\_forcing\_init(time, g, param\_file, cs\%SCM\_CVmix\_tests\_CSp)}
\DoxyCodeLine{1917 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1918 }
\DoxyCodeLine{1919   \textcolor{keyword}{call }register\_forcing\_type\_diags(time, diag, us, cs\%use\_temperature, cs\%handles)}
\DoxyCodeLine{1920 }
\DoxyCodeLine{1921   \textcolor{comment}{! Set up any restart fields associated with the forcing.}}
\DoxyCodeLine{1922   \textcolor{keyword}{call }restart\_init(param\_file, cs\%restart\_CSp, \textcolor{stringliteral}{"MOM\_forcing.res"})}
\DoxyCodeLine{1923 \textcolor{comment}{!\#CTRL\#  call register\_ctrl\_forcing\_restarts(G, param\_file, CS\%ctrl\_forcing\_CSp, \&}}
\DoxyCodeLine{1924 \textcolor{comment}{!\#CTRL\#                                      CS\%restart\_CSp)}}
\DoxyCodeLine{1925   \textcolor{keyword}{call }restart\_init\_end(cs\%restart\_CSp)}
\DoxyCodeLine{1926 }
\DoxyCodeLine{1927   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs\%restart\_CSp)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1928     \textcolor{keyword}{call }get\_mom\_input(dirs=dirs)}
\DoxyCodeLine{1929 }
\DoxyCodeLine{1930     new\_sim = .false.}
\DoxyCodeLine{1931     \textcolor{keywordflow}{if} ((dirs\%input\_filename(1:1) == \textcolor{stringliteral}{'n'}) .and. \&}
\DoxyCodeLine{1932         (len\_trim(dirs\%input\_filename) == 1)) new\_sim = .true.}
\DoxyCodeLine{1933     \textcolor{keywordflow}{if} (.not.new\_sim) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1934       \textcolor{keyword}{call }restore\_state(dirs\%input\_filename, dirs\%restart\_input\_dir, time\_frc, \&}
\DoxyCodeLine{1935                          g, cs\%restart\_CSp)}
\DoxyCodeLine{1936 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{1937 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1938 }
\DoxyCodeLine{1939   \textcolor{comment}{! Determine how many time levels are in each forcing variable.}}
\DoxyCodeLine{1940   \textcolor{keywordflow}{if} (trim(cs\%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1941     cs\%SW\_nlev = num\_timelevels(cs\%shortwave\_file, cs\%SW\_var, min\_dims=3)}
\DoxyCodeLine{1942     cs\%LW\_nlev = num\_timelevels(cs\%longwave\_file, cs\%LW\_var, min\_dims=3)}
\DoxyCodeLine{1943     cs\%latent\_nlev = num\_timelevels(cs\%latentheat\_file, cs\%latent\_var, 3)}
\DoxyCodeLine{1944     cs\%sens\_nlev = num\_timelevels(cs\%sensibleheat\_file, cs\%sens\_var, min\_dims=3)}
\DoxyCodeLine{1945 }
\DoxyCodeLine{1946     cs\%evap\_nlev = num\_timelevels(cs\%evaporation\_file, cs\%evap\_var, min\_dims=3)}
\DoxyCodeLine{1947     cs\%precip\_nlev = num\_timelevels(cs\%rain\_file, cs\%rain\_var, min\_dims=3)}
\DoxyCodeLine{1948     cs\%runoff\_nlev = num\_timelevels(cs\%runoff\_file, cs\%lrunoff\_var, 3)}
\DoxyCodeLine{1949 }
\DoxyCodeLine{1950     cs\%SST\_nlev = num\_timelevels(cs\%SSTrestore\_file, cs\%SST\_restore\_var, 3)}
\DoxyCodeLine{1951     cs\%SSS\_nlev = num\_timelevels(cs\%salinityrestore\_file, cs\%SSS\_restore\_var, 3)}
\DoxyCodeLine{1952 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1953 }
\DoxyCodeLine{1954   \textcolor{keywordflow}{if} (trim(cs\%wind\_config) == \textcolor{stringliteral}{"file"}) \&}
\DoxyCodeLine{1955     cs\%wind\_nlev = num\_timelevels(cs\%wind\_file, cs\%stress\_x\_var, min\_dims=3)}
\DoxyCodeLine{1956 }
\DoxyCodeLine{1957 \textcolor{comment}{!\#CTRL\#  call controlled\_forcing\_init(Time, G, param\_file, diag, CS\%ctrl\_forcing\_CSp)}}
\DoxyCodeLine{1958 }
\DoxyCodeLine{1959   \textcolor{keyword}{call }user\_revise\_forcing\_init(param\_file, cs\%urf\_CS)}
\DoxyCodeLine{1960 }
\DoxyCodeLine{1961   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_forcing)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a8981e402dd77c42fdd3dbc9322c1d575}\label{namespacemom__surface__forcing_a8981e402dd77c42fdd3dbc9322c1d575}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_1gyre@{wind\_forcing\_1gyre}}
\index{wind\_forcing\_1gyre@{wind\_forcing\_1gyre}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_1gyre()}{wind\_forcing\_1gyre()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+1gyre (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the surface wind stresses to set up a single idealized gyre. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 452 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{452   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{453 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{454   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{455   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{456   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{457   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{458   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{459 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{460   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{461 \textcolor{keywordtype}{  real} :: PI}
\DoxyCodeLine{462   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{463 }
\DoxyCodeLine{464   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_1gyre, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{465   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{466   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{467 }
\DoxyCodeLine{468   \textcolor{comment}{! set the steady surface wind stresses, in units of Pa.}}
\DoxyCodeLine{469   pi = 4.0*atan(1.0)}
\DoxyCodeLine{470 }
\DoxyCodeLine{471   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{472     forces\%taux(i,j) = -0.2*us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z * \&}
\DoxyCodeLine{473                        cos(pi*(g\%geoLatCu(i,j)-cs\%South\_lat)/cs\%len\_lat)}
\DoxyCodeLine{474 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{475 }
\DoxyCodeLine{476   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{477     forces\%tauy(i,j) = 0.0}
\DoxyCodeLine{478 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{479 }
\DoxyCodeLine{480   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_1gyre"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a845d75d43ebb4695675548aeb2c88b99}\label{namespacemom__surface__forcing_a845d75d43ebb4695675548aeb2c88b99}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_2gyre@{wind\_forcing\_2gyre}}
\index{wind\_forcing\_2gyre@{wind\_forcing\_2gyre}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_2gyre()}{wind\_forcing\_2gyre()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+2gyre (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the surface wind stresses to set up two idealized gyres. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 418 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{418   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{419 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{420   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{421   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{422   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{423   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{424   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{425 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{426   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{427 \textcolor{keywordtype}{  real} :: PI}
\DoxyCodeLine{428   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{429 }
\DoxyCodeLine{430   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_2gyre, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{431   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{432   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{433 }
\DoxyCodeLine{434   \textcolor{comment}{!set the steady surface wind stresses, in units of Pa.}}
\DoxyCodeLine{435   pi = 4.0*atan(1.0)}
\DoxyCodeLine{436 }
\DoxyCodeLine{437   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{438     forces\%taux(i,j) = 0.1*us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z * \&}
\DoxyCodeLine{439                       (1.0 - cos(2.0*pi*(g\%geoLatCu(i,j)-cs\%South\_lat) / cs\%len\_lat))}
\DoxyCodeLine{440 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{441 }
\DoxyCodeLine{442   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{443     forces\%tauy(i,j) = 0.0}
\DoxyCodeLine{444 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{445 }
\DoxyCodeLine{446   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_2gyre"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a55cfedbce92592fa4a8b1947bcaa69da}\label{namespacemom__surface__forcing_a55cfedbce92592fa4a8b1947bcaa69da}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_by\_data\_override@{wind\_forcing\_by\_data\_override}}
\index{wind\_forcing\_by\_data\_override@{wind\_forcing\_by\_data\_override}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_by\_data\_override()}{wind\_forcing\_by\_data\_override()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+by\+\_\+data\+\_\+override (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 823 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{823   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{824 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{825   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{826   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{827   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{828   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{829   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{830 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{831   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{832 \textcolor{keywordtype}{  real} :: temp\_x(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! Pseudo-zonal and psuedo-meridional}}
\DoxyCodeLine{833 \textcolor{keywordtype}{  real} :: temp\_y(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! wind stresses at h-points [Pa].}}
\DoxyCodeLine{834 \textcolor{keywordtype}{  real} :: temp\_ustar(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! ustar [m s-1] (not rescaled).}}
\DoxyCodeLine{835 \textcolor{keywordtype}{  real} :: Pa\_conversion \textcolor{comment}{! A unit conversion factor from Pa to the internal units [R Z L T-2 Pa-1 ~> 1]}}
\DoxyCodeLine{836   \textcolor{keywordtype}{integer} :: i, j, is\_in, ie\_in, js\_in, je\_in}
\DoxyCodeLine{837   \textcolor{keywordtype}{logical} :: read\_uStar}
\DoxyCodeLine{838 }
\DoxyCodeLine{839   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_by\_data\_override, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{840 }
\DoxyCodeLine{841   \textcolor{keywordflow}{if} (.not.cs\%dataOverrideIsInitialized) \textcolor{keywordflow}{then}}
\DoxyCodeLine{842     \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true., ustar=.true., press=.true.)}
\DoxyCodeLine{843     \textcolor{keyword}{call }data\_override\_init(ocean\_domain\_in=g\%Domain\%mpp\_domain)}
\DoxyCodeLine{844     cs\%dataOverrideIsInitialized = .true.}
\DoxyCodeLine{845 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{846 }
\DoxyCodeLine{847   is\_in = g\%isc - g\%isd + 1 ; ie\_in = g\%iec - g\%isd + 1}
\DoxyCodeLine{848   js\_in = g\%jsc - g\%jsd + 1 ; je\_in = g\%jec - g\%jsd + 1}
\DoxyCodeLine{849   pa\_conversion = us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z}
\DoxyCodeLine{850 }
\DoxyCodeLine{851   temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0}
\DoxyCodeLine{852   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'taux'}, temp\_x, day, is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{853   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'tauy'}, temp\_y, day, is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{854   \textcolor{keyword}{call }pass\_vector(temp\_x, temp\_y, g\%Domain, to\_all, agrid)}
\DoxyCodeLine{855   \textcolor{comment}{! Ignore CS\%wind\_scale when using data\_override ?????}}
\DoxyCodeLine{856   \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc-1,g\%IecB}
\DoxyCodeLine{857     forces\%taux(i,j) = pa\_conversion * 0.5 * (temp\_x(i,j) + temp\_x(i+1,j))}
\DoxyCodeLine{858 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{859   \textcolor{keywordflow}{do} j=g\%jsc-1,g\%JecB ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{860     forces\%tauy(i,j) = pa\_conversion * 0.5 * (temp\_y(i,j) + temp\_y(i,j+1))}
\DoxyCodeLine{861 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{862 }
\DoxyCodeLine{863   read\_ustar = (len\_trim(cs\%ustar\_var) > 0) \textcolor{comment}{! Need better control higher up ????}}
\DoxyCodeLine{864   \textcolor{keywordflow}{if} (read\_ustar) \textcolor{keywordflow}{then}}
\DoxyCodeLine{865     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec ; temp\_ustar(i,j) = us\%Z\_to\_m*us\%s\_to\_T*forces\%ustar(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{866     \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'ustar'}, temp\_ustar, day, is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{867     \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec ; forces\%ustar(i,j) = us\%m\_to\_Z*us\%T\_to\_s*temp\_ustar(i,j) ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{868   \textcolor{keywordflow}{else}}
\DoxyCodeLine{869     \textcolor{keywordflow}{if} (cs\%read\_gust\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{870       \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'gust'}, cs\%gust, day, is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)}
\DoxyCodeLine{871       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{872         forces\%ustar(i,j) = sqrt((pa\_conversion * sqrt(temp\_x(i,j)*temp\_x(i,j) + \&}
\DoxyCodeLine{873             temp\_y(i,j)*temp\_y(i,j)) + cs\%gust(i,j)) * us\%L\_to\_Z / cs\%Rho0)}
\DoxyCodeLine{874 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{875     \textcolor{keywordflow}{else}}
\DoxyCodeLine{876       \textcolor{keywordflow}{do} j=g\%jsc,g\%jec ; \textcolor{keywordflow}{do} i=g\%isc,g\%iec}
\DoxyCodeLine{877         forces\%ustar(i,j) = sqrt(us\%L\_to\_Z * (pa\_conversion*sqrt(temp\_x(i,j)*temp\_x(i,j) + \&}
\DoxyCodeLine{878             temp\_y(i,j)*temp\_y(i,j))/cs\%Rho0 + cs\%gust\_const/cs\%Rho0 ))}
\DoxyCodeLine{879 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{880 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{881 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{882 }
\DoxyCodeLine{883   \textcolor{keyword}{call }pass\_vector(forces\%taux, forces\%tauy, g\%Domain, to\_all)}
\DoxyCodeLine{884 \textcolor{comment}{! call pass\_var(forces\%ustar, G\%Domain, To\_All)     Not needed  ?????}}
\DoxyCodeLine{885 }
\DoxyCodeLine{886   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_by\_data\_override"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a5b732920d6d30c41b67686388775470e}\label{namespacemom__surface__forcing_a5b732920d6d30c41b67686388775470e}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_const@{wind\_forcing\_const}}
\index{wind\_forcing\_const@{wind\_forcing\_const}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_const()}{wind\_forcing\_const()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+const (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{real, intent(in)}]{tau\+\_\+x0,  }\item[{real, intent(in)}]{tau\+\_\+y0,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the surface wind stresses to constant values. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em tau\+\_\+x0} & The zonal wind stress \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tau\+\_\+y0} & The meridional wind stress \mbox{[}Pa\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 371 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{371   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{372 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{373   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{374 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: tau\_x0\textcolor{comment}{ !< The zonal wind stress [Pa]}}
\DoxyCodeLine{375 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: tau\_y0\textcolor{comment}{ !< The meridional wind stress [Pa]}}
\DoxyCodeLine{376   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{377   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{378   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{379   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{380 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{381   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{382 \textcolor{keywordtype}{  real} :: Pa\_conversion \textcolor{comment}{! A unit conversion factor from Pa to the internal units [R Z L T-2 Pa-1 ~> 1]}}
\DoxyCodeLine{383 \textcolor{keywordtype}{  real} :: mag\_tau}
\DoxyCodeLine{384   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{385 }
\DoxyCodeLine{386   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_const, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{387   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{388   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{389   pa\_conversion = us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z}
\DoxyCodeLine{390 }
\DoxyCodeLine{391   \textcolor{comment}{!set steady surface wind stresses, in units of Pa.}}
\DoxyCodeLine{392   mag\_tau = pa\_conversion * sqrt( tau\_x0**2 + tau\_y0**2)}
\DoxyCodeLine{393 }
\DoxyCodeLine{394   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{395     forces\%taux(i,j) = tau\_x0 * pa\_conversion}
\DoxyCodeLine{396 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{397 }
\DoxyCodeLine{398   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{399     forces\%tauy(i,j) = tau\_y0 * pa\_conversion}
\DoxyCodeLine{400 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{401 }
\DoxyCodeLine{402   \textcolor{keywordflow}{if} (cs\%read\_gust\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{403     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%ustar)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{404       forces\%ustar(i,j) = sqrt( us\%L\_to\_Z * ( mag\_tau + cs\%gust(i,j) ) / cs\%Rho0 )}
\DoxyCodeLine{405 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{406   \textcolor{keywordflow}{else}}
\DoxyCodeLine{407     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces\%ustar)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{408       forces\%ustar(i,j) = sqrt( us\%L\_to\_Z * ( mag\_tau + cs\%gust\_const ) / cs\%Rho0 )}
\DoxyCodeLine{409 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{410 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{411 }
\DoxyCodeLine{412   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_const"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a874e58e3fe4113ff8faa728eaa0735f5}\label{namespacemom__surface__forcing_a874e58e3fe4113ff8faa728eaa0735f5}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_from\_file@{wind\_forcing\_from\_file}}
\index{wind\_forcing\_from\_file@{wind\_forcing\_from\_file}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_from\_file()}{wind\_forcing\_from\_file()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+from\+\_\+file (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\texttt{ in,out}}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type\\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 668 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{668   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{669 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{670   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{671   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{672   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{673   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{674   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{675 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{676   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{677   \textcolor{keywordtype}{character(len=200)} :: filename  \textcolor{comment}{! The name of the input file.}}
\DoxyCodeLine{678 \textcolor{keywordtype}{  real}    :: temp\_x(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! Pseudo-zonal and psuedo-meridional}}
\DoxyCodeLine{679 \textcolor{keywordtype}{  real}    :: temp\_y(SZI\_(G),SZJ\_(G)) \textcolor{comment}{! wind stresses at h-points [R L Z T-1 ~> Pa].}}
\DoxyCodeLine{680 \textcolor{keywordtype}{  real}    :: Pa\_conversion           \textcolor{comment}{! A unit conversion factor from Pa to the internal wind stress}}
\DoxyCodeLine{681                                      \textcolor{comment}{! units [R Z L T-2 Pa-1 ~> 1]}}
\DoxyCodeLine{682   \textcolor{keywordtype}{integer} :: time\_lev\_daily          \textcolor{comment}{! The time levels to read for fields with}}
\DoxyCodeLine{683   \textcolor{keywordtype}{integer} :: time\_lev\_monthly        \textcolor{comment}{! daily and montly cycles.}}
\DoxyCodeLine{684   \textcolor{keywordtype}{integer} :: time\_lev                \textcolor{comment}{! The time level that is used for a field.}}
\DoxyCodeLine{685   \textcolor{keywordtype}{integer} :: days, seconds}
\DoxyCodeLine{686   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{687   \textcolor{keywordtype}{logical} :: read\_Ustar}
\DoxyCodeLine{688 }
\DoxyCodeLine{689   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_from\_file, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{690   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{691   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{692   pa\_conversion = us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z}
\DoxyCodeLine{693 }
\DoxyCodeLine{694   \textcolor{keyword}{call }get\_time(day, seconds, days)}
\DoxyCodeLine{695   time\_lev\_daily = days - 365*floor(real(days) / 365.0)}
\DoxyCodeLine{696 }
\DoxyCodeLine{697   \textcolor{keywordflow}{if} (time\_lev\_daily < 31) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 0}
\DoxyCodeLine{698   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 59)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 1}
\DoxyCodeLine{699   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 90)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 2}
\DoxyCodeLine{700   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 120) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 3}
\DoxyCodeLine{701   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 151) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 4}
\DoxyCodeLine{702   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 181) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 5}
\DoxyCodeLine{703   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 212) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 6}
\DoxyCodeLine{704   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 243) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 7}
\DoxyCodeLine{705   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 273) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 8}
\DoxyCodeLine{706   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 304) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 9}
\DoxyCodeLine{707   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 334) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 10}
\DoxyCodeLine{708   \textcolor{keywordflow}{else} ; time\_lev\_monthly = 11}
\DoxyCodeLine{709 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{710 }
\DoxyCodeLine{711   time\_lev\_daily = time\_lev\_daily+1}
\DoxyCodeLine{712   time\_lev\_monthly = time\_lev\_monthly+1}
\DoxyCodeLine{713 }
\DoxyCodeLine{714   \textcolor{keywordflow}{select case} (cs\%wind\_nlev)}
\DoxyCodeLine{715     \textcolor{keywordflow}{case} (12) ; time\_lev = time\_lev\_monthly}
\DoxyCodeLine{716     \textcolor{keywordflow}{case} (365) ; time\_lev = time\_lev\_daily}
\DoxyCodeLine{717 \textcolor{keywordflow}{    case default} ; time\_lev = 1}
\DoxyCodeLine{718 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{719 }
\DoxyCodeLine{720   \textcolor{keywordflow}{if} (time\_lev /= cs\%wind\_last\_lev) \textcolor{keywordflow}{then}}
\DoxyCodeLine{721     filename = trim(cs\%wind\_file)}
\DoxyCodeLine{722     read\_ustar = (len\_trim(cs\%ustar\_var) > 0)}
\DoxyCodeLine{723 \textcolor{comment}{!    if (is\_root\_pe()) \&}}
\DoxyCodeLine{724 \textcolor{comment}{!      write(*,'("Wind\_forcing Reading time level ",I," last was ",I,".")')\&}}
\DoxyCodeLine{725 \textcolor{comment}{!           time\_lev-1,CS\%wind\_last\_lev-1}}
\DoxyCodeLine{726     \textcolor{keywordflow}{select case} ( uppercase(cs\%wind\_stagger(1:1)) )}
\DoxyCodeLine{727     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"A"})}
\DoxyCodeLine{728       temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0}
\DoxyCodeLine{729       \textcolor{keyword}{call }mom\_read\_vector(filename, cs\%stress\_x\_var, cs\%stress\_y\_var, \&}
\DoxyCodeLine{730                            temp\_x(:,:), temp\_y(:,:), g\%Domain, stagger=agrid, \&}
\DoxyCodeLine{731                            timelevel=time\_lev, scale=pa\_conversion)}
\DoxyCodeLine{732 }
\DoxyCodeLine{733       \textcolor{keyword}{call }pass\_vector(temp\_x, temp\_y, g\%Domain, to\_all, agrid)}
\DoxyCodeLine{734       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{735         forces\%taux(i,j) = 0.5 * cs\%wind\_scale * (temp\_x(i,j) + temp\_x(i+1,j))}
\DoxyCodeLine{736 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{737       \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{738         forces\%tauy(i,j) = 0.5 * cs\%wind\_scale * (temp\_y(i,j) + temp\_y(i,j+1))}
\DoxyCodeLine{739 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{740 }
\DoxyCodeLine{741       \textcolor{keywordflow}{if} (.not.read\_ustar) \textcolor{keywordflow}{then}}
\DoxyCodeLine{742         \textcolor{keywordflow}{if} (cs\%read\_gust\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{743           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{744             forces\%ustar(i,j) = sqrt((cs\%gust(i,j) + \&}
\DoxyCodeLine{745                     sqrt(temp\_x(i,j)*temp\_x(i,j) + temp\_y(i,j)*temp\_y(i,j))) * us\%L\_to\_Z / cs\%Rho0)}
\DoxyCodeLine{746 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{747         \textcolor{keywordflow}{else}}
\DoxyCodeLine{748           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{749             forces\%ustar(i,j) = sqrt(us\%L\_to\_Z * (cs\%gust\_const/cs\%Rho0 + \&}
\DoxyCodeLine{750                     sqrt(temp\_x(i,j)*temp\_x(i,j) + temp\_y(i,j)*temp\_y(i,j)) / cs\%Rho0) )}
\DoxyCodeLine{751 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{752 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{753 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{754     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"C"})}
\DoxyCodeLine{755       \textcolor{keywordflow}{if} (g\%symmetric) \textcolor{keywordflow}{then}}
\DoxyCodeLine{756         \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(g\%Domain\_aux)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{757           \textcolor{stringliteral}{" wind\_forcing\_from\_file with C-grid input and symmetric memory "}//\&}
\DoxyCodeLine{758           \textcolor{stringliteral}{" called with a non-associated auxiliary domain in the grid type."})}
\DoxyCodeLine{759         \textcolor{comment}{!   Read the data as though symmetric memory were not being used, and}}
\DoxyCodeLine{760         \textcolor{comment}{! then translate it appropriately.}}
\DoxyCodeLine{761         temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0}
\DoxyCodeLine{762         \textcolor{keyword}{call }mom\_read\_vector(filename, cs\%stress\_x\_var, cs\%stress\_y\_var, \&}
\DoxyCodeLine{763                              temp\_x(:,:), temp\_y(:,:), \&}
\DoxyCodeLine{764                              g\%Domain\_aux, stagger=cgrid\_ne, timelevel=time\_lev, \&}
\DoxyCodeLine{765                              scale=pa\_conversion)}
\DoxyCodeLine{766         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{767           forces\%taux(i,j) = cs\%wind\_scale * temp\_x(i,j)}
\DoxyCodeLine{768           forces\%tauy(i,j) = cs\%wind\_scale * temp\_y(i,j)}
\DoxyCodeLine{769 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{770         \textcolor{keyword}{call }fill\_symmetric\_edges(forces\%taux, forces\%tauy, g\%Domain, stagger=cgrid\_ne)}
\DoxyCodeLine{771       \textcolor{keywordflow}{else}}
\DoxyCodeLine{772         \textcolor{keyword}{call }mom\_read\_vector(filename, cs\%stress\_x\_var, cs\%stress\_y\_var, \&}
\DoxyCodeLine{773                              forces\%taux(:,:), forces\%tauy(:,:), \&}
\DoxyCodeLine{774                              g\%Domain, stagger=cgrid\_ne, timelevel=time\_lev, \&}
\DoxyCodeLine{775                              scale=pa\_conversion)}
\DoxyCodeLine{776 }
\DoxyCodeLine{777         \textcolor{keywordflow}{if} (cs\%wind\_scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{778           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq}
\DoxyCodeLine{779             forces\%taux(i,j) = cs\%wind\_scale * forces\%taux(i,j)}
\DoxyCodeLine{780 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{781           \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{782             forces\%tauy(i,j) = cs\%wind\_scale * forces\%tauy(i,j)}
\DoxyCodeLine{783 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{784 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{785 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{786 }
\DoxyCodeLine{787       \textcolor{keyword}{call }pass\_vector(forces\%taux, forces\%tauy, g\%Domain, to\_all)}
\DoxyCodeLine{788       \textcolor{keywordflow}{if} (.not.read\_ustar) \textcolor{keywordflow}{then}}
\DoxyCodeLine{789         \textcolor{keywordflow}{if} (cs\%read\_gust\_2d) \textcolor{keywordflow}{then}}
\DoxyCodeLine{790           \textcolor{keywordflow}{do} j=js, je ; \textcolor{keywordflow}{do} i=is, ie}
\DoxyCodeLine{791             forces\%ustar(i,j) = sqrt((cs\%gust(i,j) + \&}
\DoxyCodeLine{792                     sqrt(0.5*((forces\%tauy(i,j-1)**2 + forces\%tauy(i,j)**2) + \&}
\DoxyCodeLine{793                               (forces\%taux(i-1,j)**2 + forces\%taux(i,j)**2))) ) * us\%L\_to\_Z / cs\%Rho0 )}
\DoxyCodeLine{794 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{795         \textcolor{keywordflow}{else}}
\DoxyCodeLine{796           \textcolor{keywordflow}{do} j=js, je ; \textcolor{keywordflow}{do} i=is, ie}
\DoxyCodeLine{797             forces\%ustar(i,j) = sqrt(us\%L\_to\_Z * ( (cs\%gust\_const/cs\%Rho0) + \&}
\DoxyCodeLine{798                     sqrt(0.5*((forces\%tauy(i,j-1)**2 + forces\%tauy(i,j)**2) + \&}
\DoxyCodeLine{799                               (forces\%taux(i-1,j)**2 + forces\%taux(i,j)**2)))/cs\%Rho0))}
\DoxyCodeLine{800 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{801 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{802 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{803 \textcolor{keywordflow}{    case default}}
\DoxyCodeLine{804       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"wind\_forcing\_from\_file: Unrecognized stagger "}//\&}
\DoxyCodeLine{805                       trim(cs\%wind\_stagger)//\textcolor{stringliteral}{" is not 'A' or 'C'."})}
\DoxyCodeLine{806 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{807 }
\DoxyCodeLine{808     \textcolor{keywordflow}{if} (read\_ustar) \textcolor{keywordflow}{then}}
\DoxyCodeLine{809       \textcolor{keyword}{call }mom\_read\_data(filename, cs\%Ustar\_var, forces\%ustar(:,:), \&}
\DoxyCodeLine{810                          g\%Domain, timelevel=time\_lev, scale=us\%m\_to\_Z*us\%T\_to\_s)}
\DoxyCodeLine{811 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{812 }
\DoxyCodeLine{813     cs\%wind\_last\_lev = time\_lev}
\DoxyCodeLine{814 }
\DoxyCodeLine{815 \textcolor{keywordflow}{  endif} \textcolor{comment}{! time\_lev /= CS\%wind\_last\_lev}}
\DoxyCodeLine{816 }
\DoxyCodeLine{817   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_from\_file"})}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__surface__forcing_a0b914b24fbfe91a3138e94f284fd359b}\label{namespacemom__surface__forcing_a0b914b24fbfe91a3138e94f284fd359b}} 
\index{mom\_surface\_forcing@{mom\_surface\_forcing}!wind\_forcing\_gyres@{wind\_forcing\_gyres}}
\index{wind\_forcing\_gyres@{wind\_forcing\_gyres}!mom\_surface\_forcing@{mom\_surface\_forcing}}
\subsubsection{\texorpdfstring{wind\_forcing\_gyres()}{wind\_forcing\_gyres()}}
{\footnotesize\ttfamily subroutine mom\+\_\+surface\+\_\+forcing\+::wind\+\_\+forcing\+\_\+gyres (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(mech\+\_\+forcing), intent(inout)}]{forces,  }\item[{type(time\+\_\+type), intent(in)}]{day,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{type(\mbox{\hyperlink{structmom__surface__forcing_1_1surface__forcing__cs}{surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Sets the surface wind stresses to set up idealized gyres. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em forces} & A structure with the driving mechanical forces \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & pointer to control struct returned by a previous surface\+\_\+forcing\+\_\+init call \\
\hline
\end{DoxyParams}


Definition at line 485 of file M\+O\+M\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{485   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{486 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}}
\DoxyCodeLine{487   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}}
\DoxyCodeLine{488   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{489   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{490   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{491   \textcolor{keywordtype}{type}(surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< pointer to control struct returned by}}
\DoxyCodeLine{492 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}}
\DoxyCodeLine{493   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{494 \textcolor{keywordtype}{  real} :: PI, y, I\_rho}
\DoxyCodeLine{495   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, Isq, Ieq, Jsq, Jeq}
\DoxyCodeLine{496 }
\DoxyCodeLine{497   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_gyres, MOM\_surface\_forcing.F90"})}
\DoxyCodeLine{498   is   = g\%isc  ; ie   = g\%iec  ; js   = g\%jsc  ; je   = g\%jec}
\DoxyCodeLine{499   isq  = g\%IscB ; ieq  = g\%IecB ; jsq  = g\%JscB ; jeq  = g\%JecB}
\DoxyCodeLine{500 }
\DoxyCodeLine{501   \textcolor{comment}{! steady surface wind stresses [Pa]}}
\DoxyCodeLine{502   pi = 4.0*atan(1.0)}
\DoxyCodeLine{503 }
\DoxyCodeLine{504   \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ieq}
\DoxyCodeLine{505     y = (g\%geoLatCu(i,j)-cs\%South\_lat) / cs\%len\_lat}
\DoxyCodeLine{506     forces\%taux(i,j) = us\%kg\_m3\_to\_R*us\%m\_s\_to\_L\_T**2*us\%L\_to\_Z * \&}
\DoxyCodeLine{507             (cs\%gyres\_taux\_const +                            \&}
\DoxyCodeLine{508              (   cs\%gyres\_taux\_sin\_amp*sin(cs\%gyres\_taux\_n\_pis*pi*y)    \&}
\DoxyCodeLine{509                + cs\%gyres\_taux\_cos\_amp*cos(cs\%gyres\_taux\_n\_pis*pi*y) ))}
\DoxyCodeLine{510 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{511 }
\DoxyCodeLine{512   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is-1,ie+1}
\DoxyCodeLine{513     forces\%tauy(i,j) = 0.0}
\DoxyCodeLine{514 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{515 }
\DoxyCodeLine{516   \textcolor{comment}{! set the friction velocity}}
\DoxyCodeLine{517   \textcolor{keywordflow}{if} (cs\%answers\_2018) \textcolor{keywordflow}{then}}
\DoxyCodeLine{518     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{519       forces\%ustar(i,j) = sqrt(us\%L\_to\_Z * ((cs\%gust\_const/cs\%Rho0) + \&}
\DoxyCodeLine{520               sqrt(0.5*(forces\%tauy(i,j-1)*forces\%tauy(i,j-1) + forces\%tauy(i,j)*forces\%tauy(i,j) + \&}
\DoxyCodeLine{521                         forces\%taux(i-1,j)*forces\%taux(i-1,j) + forces\%taux(i,j)*forces\%taux(i,j)))/cs\%Rho0) )}
\DoxyCodeLine{522 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{523   \textcolor{keywordflow}{else}}
\DoxyCodeLine{524     i\_rho = us\%L\_to\_Z / cs\%Rho0}
\DoxyCodeLine{525     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{526       forces\%ustar(i,j) = sqrt( (cs\%gust\_const + \&}
\DoxyCodeLine{527             sqrt(0.5*((forces\%tauy(i,j-1)**2 + forces\%tauy(i,j)**2) + \&}
\DoxyCodeLine{528                       (forces\%taux(i-1,j)**2 + forces\%taux(i,j)**2))) ) * i\_rho )}
\DoxyCodeLine{529 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{530 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{531 }
\DoxyCodeLine{532   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_gyres"})}

\end{DoxyCode}
