\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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \hyperlink{namespacemom__surface__forcing_a874e58e3fe4113ff8faa728eaa0735f5}{wind\+\_\+forcing\+\_\+from\+\_\+file} (sfc\+\_\+state, forces, day, G, US, CS)
\item 
subroutine \hyperlink{namespacemom__surface__forcing_a55cfedbce92592fa4a8b1947bcaa69da}{wind\+\_\+forcing\+\_\+by\+\_\+data\+\_\+override} (sfc\+\_\+state, forces, day, G, US, CS)
\item 
subroutine \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 \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 \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 \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 \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 \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 \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 \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 \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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
1396   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
1397 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
1398   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1399   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
1400   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
1401 \textcolor{comment}{                                               !! the fluxes apply [s]}
1402   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
1403   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
1404   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1405 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
1406   \textcolor{comment}{! Local variables}
1407   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
1408   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_const, MOM\_surface\_forcing.F90"})
1409   is  = g%isc ; ie  = g%iec ; js  = g%jsc ; je  = g%jec
1410 
1411   \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1412     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1413       fluxes%evap(i,j)                 = 0.0
1414       fluxes%lprec(i,j)                = 0.0
1415       fluxes%fprec(i,j)                = 0.0
1416       fluxes%vprec(i,j)                = 0.0
1417       fluxes%lrunoff(i,j)              = 0.0
1418       fluxes%frunoff(i,j)              = 0.0
1419       fluxes%lw(i,j)                   = 0.0
1420       fluxes%latent(i,j)               = 0.0
1421       fluxes%sens(i,j)                 = cs%constantHeatForcing * g%mask2dT(i,j)
1422       fluxes%sw(i,j)                   = 0.0
1423       fluxes%latent\_evap\_diag(i,j)     = 0.0
1424       fluxes%latent\_fprec\_diag(i,j)    = 0.0
1425       fluxes%latent\_frunoff\_diag(i,j)  = 0.0
1426 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1427   \textcolor{keywordflow}{else}
1428     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1429       fluxes%buoy(i,j) = 0.0
1430 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1431 \textcolor{keywordflow}{  endif}
1432 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
1170   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
1171 \textcolor{comment}{                                                  !! describe the surface state of the ocean.}
1172   \textcolor{keywordtype}{type}(forcing),            \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1173   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
1174   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
1175 \textcolor{comment}{                                                  !! the fluxes apply [s]}
1176   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
1177   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
1178   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1179 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
1180   \textcolor{comment}{! Local variables}
1181   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: &
1182     temp, &       \textcolor{comment}{! A 2-d temporary work array with various units.}
1183     sst\_anom, &   \textcolor{comment}{! Instantaneous sea surface temperature anomalies from a}
1184                   \textcolor{comment}{! target (observed) value [degC].}
1185     sss\_anom, &   \textcolor{comment}{! Instantaneous sea surface salinity anomalies from a target}
1186                   \textcolor{comment}{! (observed) value [ppt].}
1187     sss\_mean      \textcolor{comment}{! A (mean?) salinity about which to normalize local salinity}
1188                   \textcolor{comment}{! anomalies when calculating restorative precipitation}
1189                   \textcolor{comment}{! anomalies [ppt].}
1190   \textcolor{keywordtype}{real} :: kg\_m2\_s\_conversion  \textcolor{comment}{! A combination of unit conversion factors for rescaling}
1191                               \textcolor{comment}{! mass fluxes [R Z s m2 kg-1 T-1 ~> 1].}
1192   \textcolor{keywordtype}{real} :: rhoxcp \textcolor{comment}{! The mean density times the heat capacity [Q R degC-1 ~> J m-3 degC-1].}
1193 
1194   \textcolor{keywordtype}{integer} :: time\_lev\_daily     \textcolor{comment}{! The time levels to read for fields with}
1195   \textcolor{keywordtype}{integer} :: time\_lev\_monthly   \textcolor{comment}{! daily and montly cycles.}
1196   \textcolor{keywordtype}{integer} :: itime\_lev           \textcolor{comment}{! The time level that is used for a field.}
1197 
1198   \textcolor{keywordtype}{integer} :: days, seconds
1199   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isd, ied, jsd, jed
1200   \textcolor{keywordtype}{integer} :: is\_in, ie\_in, js\_in, je\_in
1201 
1202   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_data\_override, MOM\_surface\_forcing.F90"})
1203 
1204   is  = g%isc ; ie  = g%iec ; js  = g%jsc ; je  = g%jec
1205   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
1206   kg\_m2\_s\_conversion = us%kg\_m2s\_to\_RZ\_T
1207 
1208   \textcolor{keywordflow}{if} (cs%use\_temperature) rhoxcp = cs%Rho0 * fluxes%C\_p
1209 
1210   \textcolor{keywordflow}{if} (.not.cs%dataOverrideIsInitialized) \textcolor{keywordflow}{then}
1211     \textcolor{keyword}{call }data\_override\_init(ocean\_domain\_in=g%Domain%mpp\_domain)
1212     cs%dataOverrideIsInitialized = .true.
1213 \textcolor{keywordflow}{  endif}
1214 
1215   is\_in = g%isc - g%isd + 1
1216   ie\_in = g%iec - g%isd + 1
1217   js\_in = g%jsc - g%jsd + 1
1218   je\_in = g%jec - g%jsd + 1
1219 
1220   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'lw'}, fluxes%lw(:,:), day, &
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}
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
1223     fluxes%lw(i,j) = fluxes%lw(i,j) * us%W\_m2\_to\_QRZ\_T
1224 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
1225   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'evap'}, fluxes%evap(:,:), day, &
1226        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)
1227 
1228   \textcolor{comment}{! note the sign convention}
1229   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1230     \textcolor{comment}{! The normal convention is that fluxes%evap positive into the ocean}
1231     \textcolor{comment}{! but evap is normally a positive quantity in the files}
1232     \textcolor{comment}{! This conversion is dangerous because it is not clear whether the data files have been read!}
1233     fluxes%evap(i,j) = -kg\_m2\_s\_conversion*fluxes%evap(i,j)
1234     fluxes%latent(i,j)           = cs%latent\_heat\_vapor*fluxes%evap(i,j)
1235     fluxes%latent\_evap\_diag(i,j) = fluxes%latent(i,j)
1236 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1237 
1238   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'sens'}, fluxes%sens(:,:), day, &
1239        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)
1240 
1241   \textcolor{comment}{! note the sign convention}
1242   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1243      fluxes%sens(i,j) = -us%W\_m2\_to\_QRZ\_T * fluxes%sens(i,j)  \textcolor{comment}{! Normal convention is positive into the
       ocean}
1244                                            \textcolor{comment}{! but sensible is normally a positive quantity in the files}
1245 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1246 
1247   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'sw'}, fluxes%sw(:,:), day, &
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}
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
1250     fluxes%sw(i,j) = fluxes%sw(i,j) * us%W\_m2\_to\_QRZ\_T
1251 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
1252 
1253   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'snow'}, fluxes%fprec(:,:), day, &
1254        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}
1255 
1256   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'rain'}, fluxes%lprec(:,:), day, &
1257        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}
1258 
1259   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'runoff'}, fluxes%lrunoff(:,:), day, &
1260        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}
1261 
1262   \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'calving'}, fluxes%frunoff(:,:), day, &
1263        is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in) \textcolor{comment}{! scale=kg\_m2\_s\_conversion}
1264 
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
1266     fluxes%lprec(i,j) = fluxes%lprec(i,j) * kg\_m2\_s\_conversion
1267     fluxes%fprec(i,j) = fluxes%fprec(i,j) * kg\_m2\_s\_conversion
1268     fluxes%lrunoff(i,j) = fluxes%lrunoff(i,j) * kg\_m2\_s\_conversion
1269     fluxes%frunoff(i,j) = fluxes%frunoff(i,j) * kg\_m2\_s\_conversion
1270 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
1271 
1272 \textcolor{comment}{!     Read the SST and SSS fields for damping.}
1273   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then} \textcolor{comment}{!#CTRL# .or. associated(CS%ctrl\_forcing\_CSp)) then}
1274      \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'SST\_restore'}, cs%T\_restore(:,:), day, &
1275           is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)
1276 
1277      \textcolor{keyword}{call }data\_override(\textcolor{stringliteral}{'OCN'}, \textcolor{stringliteral}{'SSS\_restore'}, cs%S\_restore(:,:), day, &
1278           is\_in=is\_in, ie\_in=ie\_in, js\_in=js\_in, je\_in=je\_in)
1279 
1280 \textcolor{keywordflow}{  endif}
1281 
1282   \textcolor{comment}{! restoring boundary fluxes}
1283   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
1284     \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1285       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1286         \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
1287           fluxes%heat\_added(i,j) = g%mask2dT(i,j) * &
1288               ((cs%T\_Restore(i,j) - sfc\_state%SST(i,j)) * rhoxcp * cs%Flux\_const\_T)
1289           fluxes%vprec(i,j) = - (cs%Rho0*cs%Flux\_const\_S) * &
1290               (cs%S\_Restore(i,j) - sfc\_state%SSS(i,j)) / &
1291               (0.5*(sfc\_state%SSS(i,j) + cs%S\_Restore(i,j)))
1292         \textcolor{keywordflow}{else}
1293           fluxes%heat\_added(i,j) = 0.0
1294           fluxes%vprec(i,j)      = 0.0
1295 \textcolor{keywordflow}{        endif}
1296 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1297     \textcolor{keywordflow}{else}
1298       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1299         \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
1300           fluxes%buoy(i,j) = (cs%Dens\_Restore(i,j) - sfc\_state%sfc\_density(i,j)) * &
1301                              (cs%G\_Earth * cs%Flux\_const / cs%Rho0)
1302         \textcolor{keywordflow}{else}
1303           fluxes%buoy(i,j) = 0.0
1304 \textcolor{keywordflow}{        endif}
1305 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1306 \textcolor{keywordflow}{    endif}
1307   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}
1308     \textcolor{keywordflow}{if} (.not.cs%use\_temperature) \textcolor{keywordflow}{then}
1309       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing in MOM\_surface\_forcing: "}// &
1310                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})
1311 \textcolor{keywordflow}{    endif}
1312 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}
1313 
1314 
1315   \textcolor{comment}{! mask out land points and compute heat content of water fluxes}
1316   \textcolor{comment}{! assume liquid precip enters ocean at SST}
1317   \textcolor{comment}{! assume frozen precip enters ocean at 0degC}
1318   \textcolor{comment}{! assume liquid runoff enters ocean at SST}
1319   \textcolor{comment}{! assume solid runoff (calving) enters ocean at 0degC}
1320   \textcolor{comment}{! mass leaving ocean has heat\_content determined in MOM\_diabatic\_driver.F90}
1321   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1322     fluxes%evap(i,j)    = fluxes%evap(i,j)    * g%mask2dT(i,j)
1323     fluxes%lprec(i,j)   = fluxes%lprec(i,j)   * g%mask2dT(i,j)
1324     fluxes%fprec(i,j)   = fluxes%fprec(i,j)   * g%mask2dT(i,j)
1325     fluxes%lrunoff(i,j) = fluxes%lrunoff(i,j) * g%mask2dT(i,j)
1326     fluxes%frunoff(i,j) = fluxes%frunoff(i,j) * g%mask2dT(i,j)
1327     fluxes%lw(i,j)      = fluxes%lw(i,j)      * g%mask2dT(i,j)
1328     fluxes%latent(i,j)  = fluxes%latent(i,j)  * g%mask2dT(i,j)
1329     fluxes%sens(i,j)    = fluxes%sens(i,j)    * g%mask2dT(i,j)
1330     fluxes%sw(i,j)      = fluxes%sw(i,j)      * g%mask2dT(i,j)
1331 
1332     fluxes%latent\_evap\_diag(i,j)     = fluxes%latent\_evap\_diag(i,j) * g%mask2dT(i,j)
1333     fluxes%latent\_fprec\_diag(i,j)    = -fluxes%fprec(i,j)*cs%latent\_heat\_fusion
1334     fluxes%latent\_frunoff\_diag(i,j)  = -fluxes%frunoff(i,j)*cs%latent\_heat\_fusion
1335 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
1336 
1337 
1338 \textcolor{comment}{!#CTRL# if (associated(CS%ctrl\_forcing\_CSp)) then}
1339 \textcolor{comment}{!#CTRL#   do j=js,je ; do i=is,ie}
1340 \textcolor{comment}{!#CTRL#     SST\_anom(i,j) = sfc\_state%SST(i,j) - CS%T\_Restore(i,j)}
1341 \textcolor{comment}{!#CTRL#     SSS\_anom(i,j) = sfc\_state%SSS(i,j) - CS%S\_Restore(i,j)}
1342 \textcolor{comment}{!#CTRL#     SSS\_mean(i,j) = 0.5*(sfc\_state%SSS(i,j) + CS%S\_Restore(i,j))}
1343 \textcolor{comment}{!#CTRL#   enddo ; enddo}
1344 \textcolor{comment}{!#CTRL#   call apply\_ctrl\_forcing(SST\_anom, SSS\_anom, SSS\_mean, fluxes%heat\_added, &}
1345 \textcolor{comment}{!#CTRL#                           fluxes%vprec, day, dt, G, CS%ctrl\_forcing\_CSp)}
1346 \textcolor{comment}{!#CTRL# endif}
1347 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
892   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
893 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
894   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
895   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
896   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
897 \textcolor{comment}{                                               !! the fluxes apply [s]}
898   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
899   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
900   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
901 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
902   \textcolor{comment}{! Local variables}
903   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G))} :: &
904     temp, &       \textcolor{comment}{! A 2-d temporary work array with various units.}
905     sst\_anom, &   \textcolor{comment}{! Instantaneous sea surface temperature anomalies from a}
906                   \textcolor{comment}{! target (observed) value [degC].}
907     sss\_anom, &   \textcolor{comment}{! Instantaneous sea surface salinity anomalies from a target}
908                   \textcolor{comment}{! (observed) value [ppt].}
909     sss\_mean      \textcolor{comment}{! A (mean?) salinity about which to normalize local salinity}
910                   \textcolor{comment}{! anomalies when calculating restorative precipitation}
911                   \textcolor{comment}{! anomalies [ppt].}
912 
913   \textcolor{keywordtype}{real} :: kg\_m2\_s\_conversion  \textcolor{comment}{! A combination of unit conversion factors for rescaling}
914                               \textcolor{comment}{! mass fluxes [R Z s m2 kg-1 T-1 ~> 1].}
915   \textcolor{keywordtype}{real} :: rhoxcp \textcolor{comment}{! reference density times heat capacity [Q R degC-1 ~> J m-3 degC-1]}
916 
917   \textcolor{keywordtype}{integer} :: time\_lev\_daily     \textcolor{comment}{! time levels to read for fields with daily cycle}
918   \textcolor{keywordtype}{integer} :: time\_lev\_monthly   \textcolor{comment}{! time levels to read for fields with monthly cycle}
919   \textcolor{keywordtype}{integer} :: time\_lev           \textcolor{comment}{! time level that for a field}
920 
921   \textcolor{keywordtype}{integer} :: days, seconds
922   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
923 
924   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_from\_files, MOM\_surface\_forcing.F90"})
925 
926   is  = g%isc ; ie  = g%iec ; js  = g%jsc ; je = g%jec
927   kg\_m2\_s\_conversion = us%kg\_m2s\_to\_RZ\_T
928 
929   \textcolor{keywordflow}{if} (cs%use\_temperature) rhoxcp = cs%Rho0 * fluxes%C\_p
930 
931   \textcolor{comment}{! Read the buoyancy forcing file}
932   \textcolor{keyword}{call }get\_time(day, seconds, days)
933 
934   time\_lev\_daily = days - 365*floor(\textcolor{keywordtype}{real(days)} / 365.0)
935 
936   \textcolor{keywordflow}{if} (time\_lev\_daily < 31) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 0
937   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 59)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 1
938   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 90)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 2
939   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 120) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 3
940   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 151) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 4
941   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 181) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 5
942   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 212) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 6
943   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 243) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 7
944   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 273) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 8
945   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 304) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 9
946   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 334) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 10
947   \textcolor{keywordflow}{else} ; time\_lev\_monthly = 11
948 \textcolor{keywordflow}{  endif}
949 
950   time\_lev\_daily   = time\_lev\_daily  +1
951   time\_lev\_monthly = time\_lev\_monthly+1
952 
953   \textcolor{keywordflow}{if} (time\_lev\_daily /= cs%buoy\_last\_lev\_read) \textcolor{keywordflow}{then}
954 
955     \textcolor{comment}{! longwave}
956     \textcolor{keywordflow}{select case} (cs%LW\_nlev)
957       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
958       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
959 \textcolor{keywordflow}{      case default} ; time\_lev = 1
960 \textcolor{keywordflow}{    end select}
961     \textcolor{keyword}{call }mom\_read\_data(cs%longwave\_file, cs%LW\_var, fluxes%lw(:,:), &
962                        g%Domain, timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
963     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
964       \textcolor{keyword}{call }mom\_read\_data(cs%longwaveup\_file, \textcolor{stringliteral}{"lwup\_sfc"}, temp(:,:), g%Domain, &
965                          timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
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}
967 \textcolor{keywordflow}{    endif}
968     cs%LW\_last\_lev = time\_lev
969 
970     \textcolor{comment}{! evaporation}
971     \textcolor{keywordflow}{select case} (cs%evap\_nlev)
972       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
973       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
974 \textcolor{keywordflow}{      case default} ; time\_lev = 1
975 \textcolor{keywordflow}{    end select}
976     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
977       \textcolor{keyword}{call }mom\_read\_data(cs%evaporation\_file, cs%evap\_var, fluxes%evap(:,:), &
978                      g%Domain, timelevel=time\_lev, scale=-kg\_m2\_s\_conversion)
979       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
980         fluxes%latent(i,j)           = cs%latent\_heat\_vapor*fluxes%evap(i,j)
981         fluxes%latent\_evap\_diag(i,j) = fluxes%latent(i,j)
982 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
983     \textcolor{keywordflow}{else}
984       \textcolor{keyword}{call }mom\_read\_data(cs%evaporation\_file, cs%evap\_var, fluxes%evap(:,:), &
985                      g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
986 \textcolor{keywordflow}{    endif}
987     cs%evap\_last\_lev = time\_lev
988 
989     \textcolor{keywordflow}{select case} (cs%latent\_nlev)
990       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
991       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
992 \textcolor{keywordflow}{      case default} ; time\_lev = 1
993 \textcolor{keywordflow}{    end select}
994     \textcolor{keywordflow}{if} (.not.cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
995       \textcolor{keyword}{call }mom\_read\_data(cs%latentheat\_file, cs%latent\_var, fluxes%latent(:,:), &
996                      g%Domain, timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
997       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
998         fluxes%latent\_evap\_diag(i,j) = fluxes%latent(i,j)
999 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1000 \textcolor{keywordflow}{    endif}
1001     cs%latent\_last\_lev = time\_lev
1002 
1003     \textcolor{keywordflow}{select case} (cs%sens\_nlev)
1004       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1005       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1006 \textcolor{keywordflow}{      case default} ; time\_lev = 1
1007 \textcolor{keywordflow}{    end select}
1008     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1009       \textcolor{keyword}{call }mom\_read\_data(cs%sensibleheat\_file, cs%sens\_var, fluxes%sens(:,:), &
1010                      g%Domain, timelevel=time\_lev, scale=-us%W\_m2\_to\_QRZ\_T)
1011     \textcolor{keywordflow}{else}
1012       \textcolor{keyword}{call }mom\_read\_data(cs%sensibleheat\_file, cs%sens\_var, fluxes%sens(:,:), &
1013                      g%Domain, timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
1014 \textcolor{keywordflow}{    endif}
1015     cs%sens\_last\_lev = time\_lev
1016 
1017     \textcolor{keywordflow}{select case} (cs%SW\_nlev)
1018       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1019       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1020 \textcolor{keywordflow}{      case default} ; time\_lev = 1
1021 \textcolor{keywordflow}{    end select}
1022     \textcolor{keyword}{call }mom\_read\_data(cs%shortwave\_file, cs%SW\_var, fluxes%sw(:,:), g%Domain, &
1023                        timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
1024     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1025       \textcolor{keyword}{call }mom\_read\_data(cs%shortwaveup\_file, \textcolor{stringliteral}{"swup\_sfc"}, temp(:,:), g%Domain, &
1026                          timelevel=time\_lev, scale=us%W\_m2\_to\_QRZ\_T)
1027       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1028         fluxes%sw(i,j) = fluxes%sw(i,j) - temp(i,j)
1029 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1030 \textcolor{keywordflow}{    endif}
1031     cs%SW\_last\_lev = time\_lev
1032 
1033     \textcolor{keywordflow}{select case} (cs%precip\_nlev)
1034       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1035       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1036 \textcolor{keywordflow}{      case default} ; time\_lev = 1
1037 \textcolor{keywordflow}{    end select}
1038     \textcolor{keyword}{call }mom\_read\_data(cs%snow\_file, cs%snow\_var, &
1039              fluxes%fprec(:,:), g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1040     \textcolor{keyword}{call }mom\_read\_data(cs%rain\_file, cs%rain\_var, &
1041              fluxes%lprec(:,:), g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1042     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1043       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1044         fluxes%lprec(i,j) = fluxes%lprec(i,j) - fluxes%fprec(i,j)
1045 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1046 \textcolor{keywordflow}{    endif}
1047     cs%precip\_last\_lev = time\_lev
1048 
1049     \textcolor{keywordflow}{select case} (cs%runoff\_nlev)
1050       \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1051       \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1052 \textcolor{keywordflow}{      case default} ; time\_lev = 1
1053 \textcolor{keywordflow}{    end select}
1054     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1055       \textcolor{keyword}{call }mom\_read\_data(cs%runoff\_file, cs%lrunoff\_var, temp(:,:), &
1056                      g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1057       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1058         fluxes%lrunoff(i,j) = temp(i,j)*us%m\_to\_L**2*g%IareaT(i,j)
1059 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1060       \textcolor{keyword}{call }mom\_read\_data(cs%runoff\_file, cs%frunoff\_var, temp(:,:), &
1061                      g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1062       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1063         fluxes%frunoff(i,j) = temp(i,j)*us%m\_to\_L**2*g%IareaT(i,j)
1064 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1065     \textcolor{keywordflow}{else}
1066       \textcolor{keyword}{call }mom\_read\_data(cs%runoff\_file, cs%lrunoff\_var, fluxes%lrunoff(:,:), &
1067                      g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1068       \textcolor{keyword}{call }mom\_read\_data(cs%runoff\_file, cs%frunoff\_var, fluxes%frunoff(:,:), &
1069                      g%Domain, timelevel=time\_lev, scale=kg\_m2\_s\_conversion)
1070 \textcolor{keywordflow}{    endif}
1071     cs%runoff\_last\_lev = time\_lev
1072 
1073 \textcolor{comment}{!     Read the SST and SSS fields for damping.}
1074     \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then} \textcolor{comment}{!#CTRL# .or. associated(CS%ctrl\_forcing\_CSp)) then}
1075       \textcolor{keywordflow}{select case} (cs%SST\_nlev)
1076         \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1077         \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1078 \textcolor{keywordflow}{        case default} ; time\_lev = 1
1079 \textcolor{keywordflow}{      end select}
1080       \textcolor{keyword}{call }mom\_read\_data(cs%SSTrestore\_file, cs%SST\_restore\_var, &
1081                cs%T\_Restore(:,:), g%Domain, timelevel=time\_lev)
1082       cs%SST\_last\_lev = time\_lev
1083 
1084       \textcolor{keywordflow}{select case} (cs%SSS\_nlev)
1085         \textcolor{keywordflow}{case} (12)    ; time\_lev = time\_lev\_monthly
1086         \textcolor{keywordflow}{case} (365)   ; time\_lev = time\_lev\_daily
1087 \textcolor{keywordflow}{        case default} ; time\_lev = 1
1088 \textcolor{keywordflow}{      end select}
1089       \textcolor{keyword}{call }mom\_read\_data(cs%salinityrestore\_file, cs%SSS\_restore\_var, &
1090                cs%S\_Restore(:,:), g%Domain, timelevel=time\_lev)
1091       cs%SSS\_last\_lev = time\_lev
1092 \textcolor{keywordflow}{    endif}
1093     cs%buoy\_last\_lev\_read = time\_lev\_daily
1094 
1095     \textcolor{comment}{! mask out land points and compute heat content of water fluxes}
1096     \textcolor{comment}{! assume liquid precip enters ocean at SST}
1097     \textcolor{comment}{! assume frozen precip enters ocean at 0degC}
1098     \textcolor{comment}{! assume liquid runoff enters ocean at SST}
1099     \textcolor{comment}{! assume solid runoff (calving) enters ocean at 0degC}
1100     \textcolor{comment}{! mass leaving the ocean has heat\_content determined in MOM\_diabatic\_driver.F90}
1101     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1102       fluxes%evap(i,j)    = fluxes%evap(i,j)    * g%mask2dT(i,j)
1103       fluxes%lprec(i,j)   = fluxes%lprec(i,j)   * g%mask2dT(i,j)
1104       fluxes%fprec(i,j)   = fluxes%fprec(i,j)   * g%mask2dT(i,j)
1105       fluxes%lrunoff(i,j) = fluxes%lrunoff(i,j) * g%mask2dT(i,j)
1106       fluxes%frunoff(i,j) = fluxes%frunoff(i,j) * g%mask2dT(i,j)
1107       fluxes%lw(i,j)      = fluxes%lw(i,j)      * g%mask2dT(i,j)
1108       fluxes%sens(i,j)    = fluxes%sens(i,j)    * g%mask2dT(i,j)
1109       fluxes%sw(i,j)      = fluxes%sw(i,j)      * g%mask2dT(i,j)
1110       fluxes%latent(i,j)  = fluxes%latent(i,j)  * g%mask2dT(i,j)
1111 
1112       fluxes%latent\_evap\_diag(i,j)     = fluxes%latent\_evap\_diag(i,j) * g%mask2dT(i,j)
1113       fluxes%latent\_fprec\_diag(i,j)    = -fluxes%fprec(i,j)*cs%latent\_heat\_fusion
1114       fluxes%latent\_frunoff\_diag(i,j)  = -fluxes%frunoff(i,j)*cs%latent\_heat\_fusion
1115 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1116 
1117 \textcolor{keywordflow}{  endif} \textcolor{comment}{! time\_lev /= CS%buoy\_last\_lev\_read}
1118 
1119 
1120   \textcolor{comment}{! restoring surface boundary fluxes}
1121   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
1122 
1123     \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1124       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1125         \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
1126           fluxes%heat\_added(i,j) = g%mask2dT(i,j) * &
1127               ((cs%T\_Restore(i,j) - sfc\_state%SST(i,j)) * rhoxcp * cs%Flux\_const\_T)
1128           fluxes%vprec(i,j) = - (cs%Rho0*cs%Flux\_const\_S) * &
1129               (cs%S\_Restore(i,j) - sfc\_state%SSS(i,j)) / &
1130               (0.5*(sfc\_state%SSS(i,j) + cs%S\_Restore(i,j)))
1131         \textcolor{keywordflow}{else}
1132           fluxes%heat\_added(i,j) = 0.0
1133           fluxes%vprec(i,j)      = 0.0
1134 \textcolor{keywordflow}{        endif}
1135 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1136     \textcolor{keywordflow}{else}
1137       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1138         \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
1139           fluxes%buoy(i,j) = (cs%Dens\_Restore(i,j) - sfc\_state%sfc\_density(i,j)) * &
1140                              (cs%G\_Earth * cs%Flux\_const / cs%Rho0)
1141         \textcolor{keywordflow}{else}
1142           fluxes%buoy(i,j) = 0.0
1143 \textcolor{keywordflow}{        endif}
1144 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1145 \textcolor{keywordflow}{    endif}
1146 
1147   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}
1148     \textcolor{keywordflow}{if} (.not.cs%use\_temperature) \textcolor{keywordflow}{then}
1149       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing in MOM\_surface\_forcing: "}// &
1150                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})
1151 \textcolor{keywordflow}{    endif}
1152 
1153 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}
1154 
1155 \textcolor{comment}{!#CTRL# if (associated(CS%ctrl\_forcing\_CSp)) then}
1156 \textcolor{comment}{!#CTRL#   do j=js,je ; do i=is,ie}
1157 \textcolor{comment}{!#CTRL#     SST\_anom(i,j) = sfc\_state%SST(i,j) - CS%T\_Restore(i,j)}
1158 \textcolor{comment}{!#CTRL#     SSS\_anom(i,j) = sfc\_state%SSS(i,j) - CS%S\_Restore(i,j)}
1159 \textcolor{comment}{!#CTRL#     SSS\_mean(i,j) = 0.5*(sfc\_state%SSS(i,j) + CS%S\_Restore(i,j))}
1160 \textcolor{comment}{!#CTRL#   enddo ; enddo}
1161 \textcolor{comment}{!#CTRL#   call apply\_ctrl\_forcing(SST\_anom, SSS\_anom, SSS\_mean, fluxes%heat\_added, &}
1162 \textcolor{comment}{!#CTRL#                           fluxes%vprec, day, dt, G, CS%ctrl\_forcing\_CSp)}
1163 \textcolor{comment}{!#CTRL# endif}
1164 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
1439   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
1440 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
1441   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1442   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
1443   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
1444 \textcolor{comment}{                                               !! the fluxes apply [s]}
1445   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
1446   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
1447   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1448 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
1449   \textcolor{comment}{! Local variables}
1450   \textcolor{keywordtype}{real} :: y, t\_restore, s\_restore
1451   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
1452 
1453   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_linear, MOM\_surface\_forcing.F90"})
1454   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
1455 
1456   \textcolor{comment}{! This case has no surface buoyancy forcing.}
1457   \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1458     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1459       fluxes%evap(i,j)                 = 0.0
1460       fluxes%lprec(i,j)                = 0.0
1461       fluxes%fprec(i,j)                = 0.0
1462       fluxes%vprec(i,j)                = 0.0
1463       fluxes%lrunoff(i,j)              = 0.0
1464       fluxes%frunoff(i,j)              = 0.0
1465       fluxes%lw(i,j)                   = 0.0
1466       fluxes%latent(i,j)               = 0.0
1467       fluxes%sens(i,j)                 = 0.0
1468       fluxes%sw(i,j)                   = 0.0
1469       fluxes%latent\_evap\_diag(i,j)     = 0.0
1470       fluxes%latent\_fprec\_diag(i,j)    = 0.0
1471       fluxes%latent\_frunoff\_diag(i,j)  = 0.0
1472 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1473   \textcolor{keywordflow}{else}
1474     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1475       fluxes%buoy(i,j) = 0.0
1476 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1477 \textcolor{keywordflow}{  endif}
1478 
1479   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
1480     \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1481       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1482         y = (g%geoLatCu(i,j)-cs%South\_lat)/cs%len\_lat
1483         t\_restore = cs%T\_south + (cs%T\_north-cs%T\_south)*y
1484         s\_restore = cs%S\_south + (cs%S\_north-cs%S\_south)*y
1485         \textcolor{keywordflow}{if} (g%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}
1486           fluxes%heat\_added(i,j) = g%mask2dT(i,j) * &
1487               ((t\_restore - sfc\_state%SST(i,j)) * ((cs%Rho0 * fluxes%C\_p) * cs%Flux\_const))
1488           fluxes%vprec(i,j) = - (cs%Rho0*cs%Flux\_const) * &
1489               (s\_restore - sfc\_state%SSS(i,j)) / &
1490               (0.5*(sfc\_state%SSS(i,j) + s\_restore))
1491         \textcolor{keywordflow}{else}
1492           fluxes%heat\_added(i,j) = 0.0
1493           fluxes%vprec(i,j)      = 0.0
1494 \textcolor{keywordflow}{        endif}
1495 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
1496     \textcolor{keywordflow}{else}
1497       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing\_linear in MOM\_surface\_forcing: "}// &
1498                      \textcolor{stringliteral}{"RESTOREBUOY to linear not written yet."})
1499      \textcolor{comment}{!do j=js,je ; do i=is,ie}
1500      \textcolor{comment}{!  if (G%mask2dT(i,j) > 0) then}
1501      \textcolor{comment}{!    fluxes%buoy(i,j) = (CS%Dens\_Restore(i,j) - sfc\_state%sfc\_density(i,j)) * &}
1502      \textcolor{comment}{!                       (CS%G\_Earth * CS%Flux\_const / CS%Rho0)}
1503      \textcolor{comment}{!  else}
1504      \textcolor{comment}{!    fluxes%buoy(i,j) = 0.0}
1505      \textcolor{comment}{!  endif}
1506      \textcolor{comment}{!enddo ; enddo}
1507 \textcolor{keywordflow}{    endif}
1508   \textcolor{keywordflow}{else}                                              \textcolor{comment}{! not RESTOREBUOY}
1509     \textcolor{keywordflow}{if} (.not.cs%use\_temperature) \textcolor{keywordflow}{then}
1510       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"buoyancy\_forcing\_linear in MOM\_surface\_forcing: "}// &
1511                      \textcolor{stringliteral}{"The fluxes need to be defined without RESTOREBUOY."})
1512 \textcolor{keywordflow}{    endif}
1513 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}
1514 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]}\\
\hline
\mbox{\tt 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}
1353   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
1354 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
1355   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1356   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
1357   \textcolor{keywordtype}{real},                  \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
1358 \textcolor{comment}{                                               !! the fluxes apply [s]}
1359   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
1360   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1361 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
1362   \textcolor{comment}{! Local variables}
1363   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
1364 
1365   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"buoyancy\_forcing\_zero, MOM\_surface\_forcing.F90"})
1366   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
1367 
1368   \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1369     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1370       fluxes%evap(i,j)                 = 0.0
1371       fluxes%lprec(i,j)                = 0.0
1372       fluxes%fprec(i,j)                = 0.0
1373       fluxes%vprec(i,j)                = 0.0
1374       fluxes%lrunoff(i,j)              = 0.0
1375       fluxes%frunoff(i,j)              = 0.0
1376       fluxes%lw(i,j)                   = 0.0
1377       fluxes%latent(i,j)               = 0.0
1378       fluxes%sens(i,j)                 = 0.0
1379       fluxes%sw(i,j)                   = 0.0
1380       fluxes%latent\_evap\_diag(i,j)     = 0.0
1381       fluxes%latent\_fprec\_diag(i,j)    = 0.0
1382       fluxes%latent\_frunoff\_diag(i,j)  = 0.0
1383 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1384   \textcolor{keywordflow}{else}
1385     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
1386       fluxes%buoy(i,j) = 0.0
1387 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1388 \textcolor{keywordflow}{  endif}
1389 
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(\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{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em time} & model time at this call; needed for mpp\+\_\+write calls\\
\hline
\mbox{\tt in}  & {\em directory} & directory into which to write these restart files\\
\hline
\mbox{\tt in}  & {\em time\+\_\+stamped} & If true, the restart file names include a unique time stamp; the default is false.\\
\hline
\mbox{\tt 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}
1521   \textcolor{keywordtype}{type}(surface\_forcing\_cs),   \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1522 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}
1523   \textcolor{keywordtype}{type}(ocean\_grid\_type),      \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
1524   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< model time at this call; needed for mpp\_write calls}
1525   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(in)}    :: directory\textcolor{comment}{ !< directory into which to write these restart
       files}
1526   \textcolor{keywordtype}{logical},          \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: time\_stamped\textcolor{comment}{ !< If true, the restart file names}
1527 \textcolor{comment}{                                                    !! include a unique time stamp; the  default is false.}
1528   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: filename\_suffix\textcolor{comment}{ !< optional suffix (e.g., a time-stamp)}
1529 \textcolor{comment}{                                                    !! to append to the restart fname}
1530 
1531   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{return}
1532   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(cs%restart\_CSp)) \textcolor{keywordflow}{return}
1533 
1534   \textcolor{keyword}{call }save\_restart(directory, time, g, cs%restart\_CSp, time\_stamped)
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & Time used for determining the fluxes.\\
\hline
\mbox{\tt in,out}  & {\em g} & Grid structure.\\
\hline
\mbox{\tt 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}
538   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
539 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
540   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
541   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{    !< Time used for determining the fluxes.}
542   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< Grid structure.}
543   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
544   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< pointer to control struct returned by}
545 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}
546   \textcolor{comment}{! Local variables}
547   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
548   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed, isdb, iedb, jsdb, jedb
549   \textcolor{keywordtype}{real} :: pi, i\_rho, y
550   \textcolor{keywordtype}{real} :: tau\_max  \textcolor{comment}{! The magnitude of the wind stress [R Z L T-2 ~> Pa]}
551   \textcolor{keywordtype}{real} :: off
552 
553   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
554   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
555   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
556   isdb = g%IsdB ; iedb = g%IedB ; jsdb = g%JsdB ; jedb = g%JedB
557 
558   \textcolor{comment}{! Allocate the forcing arrays, if necessary.}
559   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true.)
560 
561   \textcolor{comment}{!  Set the surface wind stresses, in units of Pa.  A positive taux}
562   \textcolor{comment}{!  accelerates the ocean to the (pseudo-)east.}
563 
564   \textcolor{comment}{!  The i-loop extends to is-1 so that taux can be used later in the}
565   \textcolor{comment}{! calculation of ustar - otherwise the lower bound would be Isq.}
566   pi = 4.0*atan(1.0)
567   forces%taux(:,:) = 0.0
568   tau\_max = 0.2 * us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z
569   off = 0.02
570   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
571     y = (g%geoLatT(i,j)-g%south\_lat)/g%len\_lat
572 
573     \textcolor{keywordflow}{if} (y <= 0.29) \textcolor{keywordflow}{then}
574       forces%taux(i,j) = forces%taux(i,j) + tau\_max * ( (1/0.29)*y - ( 1/(2*pi) )*sin( (2*pi*y) / 0.29 ) )
575 \textcolor{keywordflow}{    endif}
576     \textcolor{keywordflow}{if} ((y > 0.29) .and. (y <= (0.8-off))) \textcolor{keywordflow}{then}
577       forces%taux(i,j) = forces%taux(i,j) + tau\_max *(0.35+0.65*cos(pi*(y-0.29)/(0.51-off))  )
578 \textcolor{keywordflow}{    endif}
579     \textcolor{keywordflow}{if} ((y > (0.8-off)) .and. (y <= (1-off))) \textcolor{keywordflow}{then}
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)) 
      ) )
581 \textcolor{keywordflow}{    endif}
582     forces%taux(i,j) = g%mask2dCu(i,j) * forces%taux(i,j)
583 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
584 
585   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
586     forces%tauy(i,j) = g%mask2dCv(i,j) * 0.0
587 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
588 
589   \textcolor{comment}{! Set the surface friction velocity, in units of m s-1.  ustar is always positive.}
590   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keywordflow}{then}
591     i\_rho = us%L\_to\_Z / cs%Rho0
592     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
593       forces%ustar(i,j) = sqrt( (cs%gust\_const + &
594             sqrt(0.5*((forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2) + &
595                       (forces%taux(i-1,j)**2 + forces%taux(i,j)**2))) ) * i\_rho )
596 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
597 \textcolor{keywordflow}{  endif}
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{\tt in}  & {\em x} & non-\/dimensional position\\
\hline
\mbox{\tt in}  & {\em l} & non-\/dimensional width \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
658   \textcolor{keywordtype}{real} , \textcolor{keywordtype}{intent(in)} :: x\textcolor{comment}{       !< non-dimensional position}
659   \textcolor{keywordtype}{real} , \textcolor{keywordtype}{intent(in)} :: l\textcolor{comment}{       !< non-dimensional width}
660   \textcolor{keywordtype}{real} :: s
661 
662   s = x/l
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & Time used for determining the fluxes.\\
\hline
\mbox{\tt in,out}  & {\em g} & Grid structure.\\
\hline
\mbox{\tt 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}
603   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
604 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
605   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
606   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{    !< Time used for determining the fluxes.}
607   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{      !< Grid structure.}
608   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{     !< A dimensional unit scaling type}
609   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{     !< pointer to control struct returned by}
610 \textcolor{comment}{                                                    !! a previous surface\_forcing\_init call}
611   \textcolor{comment}{! Local variables}
612   \textcolor{keywordtype}{integer} :: i, j, kseg
613   \textcolor{keywordtype}{real} :: lon, lat, i\_rho, y, l
614 \textcolor{comment}{! real :: ydata(7) = (/ -70., -45., -15., 0., 15., 45., 70. /)}
615 \textcolor{comment}{! real :: taudt(7) = (/ 0., 0.2, -0.1, -0.02, -0.1, 0.1, 0. /)}
616 
617   \textcolor{comment}{! Allocate the forcing arrays, if necessary.}
618   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true.)
619 
620   kseg = 1
621   \textcolor{keywordflow}{do} j=g%jsd,g%jed ; \textcolor{keywordflow}{do} i=g%IsdB,g%IedB
622     lon = g%geoLonCu(i,j)
623     lat = g%geoLatCu(i,j)
624 
625     \textcolor{comment}{! Find segment k s.t. ydata(k)<= lat < ydata(k+1)}
626     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (lat>=cs%scurves\_ydata(kseg+1) .and. kseg<6)
627       kseg = kseg+1
628 \textcolor{keywordflow}{    enddo}
629     \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (lat<cs%scurves\_ydata(kseg) .and. kseg>1)
630       kseg = kseg-1
631 \textcolor{keywordflow}{    enddo}
632 
633     y = lat - cs%scurves\_ydata(kseg)
634     l = cs%scurves\_ydata(kseg+1) - cs%scurves\_ydata(kseg)
635     forces%taux(i,j) = cs%scurves\_taux(kseg) +  &
636                        ( cs%scurves\_taux(kseg+1) - cs%scurves\_taux(kseg) ) * scurve(y, l)
637     forces%taux(i,j) = g%mask2dCu(i,j) * forces%taux(i,j)
638 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
639 
640   \textcolor{keywordflow}{do} j=g%JsdB,g%JedB ; \textcolor{keywordflow}{do} i=g%isd,g%ied
641     forces%tauy(i,j) = g%mask2dCv(i,j) * 0.0
642 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
643 
644   \textcolor{comment}{! Set the surface friction velocity, in units of m s-1.  ustar is always positive.}
645   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keywordflow}{then}
646     i\_rho = us%L\_to\_Z / cs%Rho0
647     \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
648       forces%ustar(i,j) = sqrt( (cs%gust\_const + &
649             sqrt(0.5*((forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2) + &
650                       (forces%taux(i-1,j)**2 + forces%taux(i,j)**2))) ) * i\_rho )
651 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
652 \textcolor{keywordflow}{  endif}
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in,out}  & {\em fluxes} & A structure containing thermodynamic forcing fields\\
\hline
\mbox{\tt in}  & {\em day\+\_\+start} & The start time of the fluxes\\
\hline
\mbox{\tt in}  & {\em day\+\_\+interval} & Length of time over which these fluxes applied\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
223   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
224 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}
225   \textcolor{keywordtype}{type}(mech\_forcing),    \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
226   \textcolor{keywordtype}{type}(forcing),         \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
227   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\_start\textcolor{comment}{ !< The start time of the fluxes}
228   \textcolor{keywordtype}{type}(time\_type),       \textcolor{keywordtype}{intent(in)}    :: day\_interval\textcolor{comment}{ !< Length of time over which these fluxes applied}
229   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
230   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
231   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
232 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
233   \textcolor{comment}{! Local variables}
234   \textcolor{keywordtype}{real} :: dt                     \textcolor{comment}{! length of time over which fluxes applied [s]}
235   \textcolor{keywordtype}{type}(time\_type) :: day\_center  \textcolor{comment}{! central time of the fluxes.}
236   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed
237   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
238 
239   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_forcing)
240   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"set\_forcing, MOM\_surface\_forcing.F90"})
241 
242   day\_center = day\_start + day\_interval/2
243   dt = time\_type\_to\_real(day\_interval)
244 
245   \textcolor{keywordflow}{if} (cs%first\_call\_set\_forcing) \textcolor{keywordflow}{then}
246     \textcolor{comment}{! Allocate memory for the mechanical and thermodyanmic forcing fields.}
247     \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true., ustar=.true., press=.true.)
248 
249     \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, ustar=.true., fix\_accum\_bug=cs%fix\_ustar\_gustless\_bug)
250     \textcolor{keywordflow}{if} (trim(cs%buoy\_config) /= \textcolor{stringliteral}{"NONE"}) \textcolor{keywordflow}{then}
251       \textcolor{keywordflow}{if} ( cs%use\_temperature ) \textcolor{keywordflow}{then}
252         \textcolor{keyword}{call }allocate\_forcing\_type(g, fluxes, water=.true., heat=.true., press=.true.)
253         \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
254           \textcolor{keyword}{call }safe\_alloc\_ptr(cs%T\_Restore,isd, ied, jsd, jed)
255           \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%heat\_added, isd, ied, jsd, jed)
256           \textcolor{keyword}{call }safe\_alloc\_ptr(cs%S\_Restore, isd, ied, jsd, jed)
257 \textcolor{keywordflow}{        endif}
258       \textcolor{keywordflow}{else} \textcolor{comment}{! CS%use\_temperature false.}
259         \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%buoy, isd, ied, jsd, jed)
260 
261         \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keyword}{call }safe\_alloc\_ptr(cs%Dens\_Restore, isd, ied, jsd, jed)
262 \textcolor{keywordflow}{      endif}  \textcolor{comment}{! endif for  CS%use\_temperature}
263 \textcolor{keywordflow}{    endif}
264 \textcolor{keywordflow}{  endif}
265 
266   \textcolor{comment}{! calls to various wind options}
267   \textcolor{keywordflow}{if} (cs%variable\_winds .or. cs%first\_call\_set\_forcing) \textcolor{keywordflow}{then}
268 
269     \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}
270       \textcolor{keyword}{call }wind\_forcing\_from\_file(sfc\_state, forces, day\_center, g, us, cs)
271     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"data\_override"}) \textcolor{keywordflow}{then}
272       \textcolor{keyword}{call }wind\_forcing\_by\_data\_override(sfc\_state, forces, day\_center, g, us, cs)
273     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"2gyre"}) \textcolor{keywordflow}{then}
274       \textcolor{keyword}{call }wind\_forcing\_2gyre(sfc\_state, forces, day\_center, g, us, cs)
275     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"1gyre"}) \textcolor{keywordflow}{then}
276       \textcolor{keyword}{call }wind\_forcing\_1gyre(sfc\_state, forces, day\_center, g, us, cs)
277     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"gyres"}) \textcolor{keywordflow}{then}
278       \textcolor{keyword}{call }wind\_forcing\_gyres(sfc\_state, forces, day\_center, g, us, cs)
279     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"zero"}) \textcolor{keywordflow}{then}
280       \textcolor{keyword}{call }wind\_forcing\_const(sfc\_state, forces, 0., 0., day\_center, g, us, cs)
281     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}
282       \textcolor{keyword}{call }wind\_forcing\_const(sfc\_state, forces, cs%tau\_x0, cs%tau\_y0, day\_center, g, us, cs)
283     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"Neverworld"} .or. trim(cs%wind\_config) == \textcolor{stringliteral}{"Neverland"}) \textcolor{keywordflow}{then}
284       \textcolor{keyword}{call }neverworld\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs)
285     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"scurves"}) \textcolor{keywordflow}{then}
286       \textcolor{keyword}{call }scurve\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs)
287     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"ideal\_hurr"}) \textcolor{keywordflow}{then}
288       \textcolor{keyword}{call }idealized\_hurricane\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs
      %idealized\_hurricane\_CSp)
289     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"SCM\_ideal\_hurr"}) \textcolor{keywordflow}{then}
290       \textcolor{keyword}{call }scm\_idealized\_hurricane\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs
      %idealized\_hurricane\_CSp)
291     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}
292       \textcolor{keyword}{call }scm\_cvmix\_tests\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs%SCM\_CVmix\_tests\_CSp)
293     \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"USER"}) \textcolor{keywordflow}{then}
294       \textcolor{keyword}{call }user\_wind\_forcing(sfc\_state, forces, day\_center, g, us, cs%user\_forcing\_CSp)
295     \textcolor{keywordflow}{elseif} (cs%variable\_winds .and. .not.cs%first\_call\_set\_forcing) \textcolor{keywordflow}{then}
296       \textcolor{keyword}{call }mom\_error(fatal, &
297        \textcolor{stringliteral}{"MOM\_surface\_forcing: Variable winds defined with no wind config"})
298     \textcolor{keywordflow}{else}
299        \textcolor{keyword}{call }mom\_error(fatal, &
300        \textcolor{stringliteral}{"MOM\_surface\_forcing:Unrecognized wind config "}//trim(cs%wind\_config))
301 \textcolor{keywordflow}{    endif}
302 \textcolor{keywordflow}{  endif}
303 
304   \textcolor{comment}{! calls to various buoyancy forcing options}
305   \textcolor{keywordflow}{if} (cs%restorebuoy .and. .not.cs%variable\_buoyforce) \textcolor{keywordflow}{then}
306     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"With RESTOREBUOY = True, VARIABLE\_BUOYFORCE = True should be used. "}//&
307                           \textcolor{stringliteral}{"Otherwise, this can lead to diverging solutions when a simulation "}//&
308                           \textcolor{stringliteral}{"is continued using a restart file."})
309 \textcolor{keywordflow}{  endif}
310 
311   \textcolor{keywordflow}{if} ((cs%variable\_buoyforce .or. cs%first\_call\_set\_forcing) .and. &
312       (.not.cs%adiabatic)) \textcolor{keywordflow}{then}
313     \textcolor{keywordflow}{if} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}
314       \textcolor{keyword}{call }buoyancy\_forcing\_from\_files(sfc\_state, fluxes, day\_center, dt, g, us, cs)
315     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"data\_override"}) \textcolor{keywordflow}{then}
316       \textcolor{keyword}{call }buoyancy\_forcing\_from\_data\_override(sfc\_state, fluxes, day\_center, dt, g, us, cs)
317     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"zero"}) \textcolor{keywordflow}{then}
318       \textcolor{keyword}{call }buoyancy\_forcing\_zero(sfc\_state, fluxes, day\_center, dt, g, cs)
319     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}
320       \textcolor{keyword}{call }buoyancy\_forcing\_const(sfc\_state, fluxes, day\_center, dt, g, us, cs)
321     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"linear"}) \textcolor{keywordflow}{then}
322       \textcolor{keyword}{call }buoyancy\_forcing\_linear(sfc\_state, fluxes, day\_center, dt, g, us, cs)
323     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"MESO"}) \textcolor{keywordflow}{then}
324       \textcolor{keyword}{call }meso\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs%MESO\_forcing\_CSp)
325     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}
326       \textcolor{keyword}{call }scm\_cvmix\_tests\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, g, us, cs%SCM\_CVmix\_tests\_CSp)
327     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"USER"}) \textcolor{keywordflow}{then}
328       \textcolor{keyword}{call }user\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs%user\_forcing\_CSp)
329     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"BFB"}) \textcolor{keywordflow}{then}
330       \textcolor{keyword}{call }bfb\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs%BFB\_forcing\_CSp)
331     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"dumbbell"}) \textcolor{keywordflow}{then}
332       \textcolor{keyword}{call }dumbbell\_buoyancy\_forcing(sfc\_state, fluxes, day\_center, dt, g, us, cs%dumbbell\_forcing\_CSp)
333     \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"NONE"}) \textcolor{keywordflow}{then}
334       \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"MOM\_surface\_forcing: buoyancy forcing has been set to omitted."})
335     \textcolor{keywordflow}{elseif} (cs%variable\_buoyforce .and. .not.cs%first\_call\_set\_forcing) \textcolor{keywordflow}{then}
336       \textcolor{keyword}{call }mom\_error(fatal, &
337        \textcolor{stringliteral}{"MOM\_surface\_forcing: Variable buoy defined with no buoy config."})
338     \textcolor{keywordflow}{else}
339        \textcolor{keyword}{call }mom\_error(fatal, &
340        \textcolor{stringliteral}{"MOM\_surface\_forcing: Unrecognized buoy config "}//trim(cs%buoy\_config))
341 \textcolor{keywordflow}{    endif}
342 \textcolor{keywordflow}{  endif}
343 
344   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%tracer\_flow\_CSp)) \textcolor{keywordflow}{then}
345     \textcolor{keyword}{call }call\_tracer\_set\_forcing(sfc\_state, fluxes, day\_start, day\_interval, g, cs%tracer\_flow\_CSp)
346 \textcolor{keywordflow}{  endif}
347 
348   \textcolor{comment}{! Allow for user-written code to alter the fluxes after all the above}
349   \textcolor{keyword}{call }user\_alter\_forcing(sfc\_state, fluxes, day\_center, g, cs%urf\_CS)
350 
351   \textcolor{comment}{! Fields that exist in both the forcing and mech\_forcing types must be copied.}
352   \textcolor{keywordflow}{if} (cs%variable\_winds .or. cs%first\_call\_set\_forcing) \textcolor{keywordflow}{then}
353     \textcolor{keyword}{call }copy\_common\_forcing\_fields(forces, fluxes, g)
354     \textcolor{keyword}{call }set\_derived\_forcing\_fields(forces, fluxes, g, us, cs%Rho0)
355 \textcolor{keywordflow}{  endif}
356 
357   \textcolor{keywordflow}{if} ((cs%variable\_buoyforce .or. cs%first\_call\_set\_forcing) .and. &
358       (.not.cs%adiabatic)) \textcolor{keywordflow}{then}
359     \textcolor{keyword}{call }set\_net\_mass\_forcing(fluxes, forces, g, us)
360 \textcolor{keywordflow}{  endif}
361 
362   cs%first\_call\_set\_forcing = .false.
363 
364   \textcolor{keyword}{call }cpu\_clock\_end(id\_clock\_forcing)
365   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"set\_forcing"})
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(\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{\tt 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}
1967   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1968 \textcolor{comment}{                                               !! a previous surface\_forcing\_init call}
1969   \textcolor{keywordtype}{type}(forcing), \textcolor{keywordtype}{optional},  \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}
1970 \textcolor{comment}{! Arguments:  CS - A pointer to the control structure returned by a previous}
1971 \textcolor{comment}{!                  call to surface\_forcing\_init, it will be deallocated here.}
1972 \textcolor{comment}{!  (inout)    fluxes - A structure containing pointers to any possible}
1973 \textcolor{comment}{!                     forcing fields.  Unused fields have NULL ptrs.}
1974 
1975   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fluxes)) \textcolor{keyword}{call }deallocate\_forcing\_type(fluxes)
1976 
1977 \textcolor{comment}{!#CTRL#  call controlled\_forcing\_end(CS%ctrl\_forcing\_CSp)}
1978 
1979   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{deallocate}(cs)
1980   cs => null()
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(\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{\tt in}  & {\em time} & The current model time\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters\\
\hline
\mbox{\tt 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}
1540   \textcolor{keywordtype}{type}(time\_type),              \textcolor{keywordtype}{intent(in)}    :: time\textcolor{comment}{ !< The current model time}
1541   \textcolor{keywordtype}{type}(ocean\_grid\_type),        \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
1542   \textcolor{keywordtype}{type}(unit\_scale\_type),        \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
1543   \textcolor{keywordtype}{type}(param\_file\_type),        \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
1544   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},      \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< structure used to regulate diagnostic output}
1545   \textcolor{keywordtype}{type}(surface\_forcing\_cs),     \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
1546 \textcolor{comment}{                                                      !! a previous surface\_forcing\_init call}
1547   \textcolor{keywordtype}{type}(tracer\_flow\_control\_cs), \textcolor{keywordtype}{pointer}       :: tracer\_flow\_csp\textcolor{comment}{ !< Forcing for tracers?}
1548 
1549   \textcolor{comment}{! Local variables}
1550   \textcolor{keywordtype}{type}(directories)  :: dirs
1551   \textcolor{keywordtype}{logical}            :: new\_sim
1552   \textcolor{keywordtype}{type}(time\_type)    :: time\_frc
1553   \textcolor{comment}{! This include declares and sets the variable "version".}
1554 \textcolor{preprocessor}{# include "version\_variable.h"}
1555 \textcolor{preprocessor}{}  \textcolor{keywordtype}{real} :: flux\_const\_default \textcolor{comment}{! The unscaled value of FLUXCONST [m day-1]}
1556   \textcolor{keywordtype}{logical} :: default\_2018\_answers
1557   \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_surface\_forcing"} \textcolor{comment}{! This module's name.}
1558   \textcolor{keywordtype}{character(len=200)} :: filename, gust\_file \textcolor{comment}{! The name of the gustiness input file.}
1559 
1560   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
1561     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"surface\_forcing\_init called with an associated "}// &
1562                             \textcolor{stringliteral}{"control structure."})
1563     \textcolor{keywordflow}{return}
1564 \textcolor{keywordflow}{  endif}
1565   \textcolor{keyword}{allocate}(cs)
1566 
1567   id\_clock\_forcing=cpu\_clock\_id(\textcolor{stringliteral}{'(Ocean surface forcing)'}, grain=clock\_module)
1568   \textcolor{keyword}{call }cpu\_clock\_begin(id\_clock\_forcing)
1569 
1570   cs%diag => diag
1571   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(tracer\_flow\_csp)) cs%tracer\_flow\_CSp => tracer\_flow\_csp
1572 
1573   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
1574   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{''})
1575   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, cs%use\_temperature, &
1576                  \textcolor{stringliteral}{"If true, Temperature and salinity are used as state "}//&
1577                  \textcolor{stringliteral}{"variables."}, default=.true.)
1578   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, cs%inputdir, &
1579                  \textcolor{stringliteral}{"The directory in which all input files are found."}, &
1580                  default=\textcolor{stringliteral}{"."})
1581   cs%inputdir = slasher(cs%inputdir)
1582 
1583   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ADIABATIC"}, cs%adiabatic, &
1584                  \textcolor{stringliteral}{"There are no diapycnal mass fluxes if ADIABATIC is "}//&
1585                  \textcolor{stringliteral}{"true. This assumes that KD = KDML = 0.0 and that "}//&
1586                  \textcolor{stringliteral}{"there is no buoyancy forcing, but makes the model "}//&
1587                  \textcolor{stringliteral}{"faster by eliminating subroutine calls."}, default=.false.)
1588   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VARIABLE\_WINDS"}, cs%variable\_winds, &
1589                  \textcolor{stringliteral}{"If true, the winds vary in time after the initialization."}, &
1590                  default=.true.)
1591   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"VARIABLE\_BUOYFORCE"}, cs%variable\_buoyforce, &
1592                  \textcolor{stringliteral}{"If true, the buoyancy forcing varies in time after the "}//&
1593                  \textcolor{stringliteral}{"initialization of the model."}, default=.true.)
1594 
1595   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"BUOY\_CONFIG"}, cs%buoy\_config, &
1596                  \textcolor{stringliteral}{"The character string that indicates how buoyancy forcing "}//&
1597                  \textcolor{stringliteral}{"is specified. Valid options include (file), (zero), "}//&
1598                  \textcolor{stringliteral}{"(linear), (USER), (BFB) and (NONE)."}, default=\textcolor{stringliteral}{"zero"})
1599   \textcolor{keywordflow}{if} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}
1600     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ARCHAIC\_OMIP\_FORCING\_FILE"}, cs%archaic\_OMIP\_file, &
1601                  \textcolor{stringliteral}{"If true, use the forcing variable decomposition from "}//&
1602                  \textcolor{stringliteral}{"the old German OMIP prescription that predated CORE. If "}//&
1603                  \textcolor{stringliteral}{"false, use the variable groupings available from MOM "}//&
1604                  \textcolor{stringliteral}{"output diagnostics of forcing variables."}, default=.true.)
1605     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1606       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVEDOWN\_FILE"}, cs%longwave\_file, &
1607                  \textcolor{stringliteral}{"The file with the downward longwave heat flux, in "}//&
1608                  \textcolor{stringliteral}{"variable lwdn\_sfc."}, fail\_if\_missing=.true.)
1609       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVEUP\_FILE"}, cs%longwaveup\_file, &
1610                  \textcolor{stringliteral}{"The file with the upward longwave heat flux, in "}//&
1611                  \textcolor{stringliteral}{"variable lwup\_sfc."}, fail\_if\_missing=.true.)
1612       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAPORATION\_FILE"}, cs%evaporation\_file, &
1613                  \textcolor{stringliteral}{"The file with the evaporative moisture flux, in "}//&
1614                  \textcolor{stringliteral}{"variable evap."}, fail\_if\_missing=.true.)
1615       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLEHEAT\_FILE"}, cs%sensibleheat\_file, &
1616                  \textcolor{stringliteral}{"The file with the sensible heat flux, in "}//&
1617                  \textcolor{stringliteral}{"variable shflx."}, fail\_if\_missing=.true.)
1618       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVEUP\_FILE"}, cs%shortwaveup\_file, &
1619                  \textcolor{stringliteral}{"The file with the upward shortwave heat flux."}, &
1620                  fail\_if\_missing=.true.)
1621       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVEDOWN\_FILE"}, cs%shortwave\_file, &
1622                  \textcolor{stringliteral}{"The file with the downward shortwave heat flux."}, &
1623                  fail\_if\_missing=.true.)
1624       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FILE"}, cs%snow\_file, &
1625                  \textcolor{stringliteral}{"The file with the downward frozen precip flux, in "}//&
1626                  \textcolor{stringliteral}{"variable snow."}, fail\_if\_missing=.true.)
1627       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PRECIP\_FILE"}, cs%rain\_file, &
1628                  \textcolor{stringliteral}{"The file with the downward total precip flux, in "}//&
1629                  \textcolor{stringliteral}{"variable precip."}, fail\_if\_missing=.true.)
1630       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FRESHDISCHARGE\_FILE"}, cs%runoff\_file, &
1631                  \textcolor{stringliteral}{"The file with the fresh and frozen runoff/calving fluxes, "}//&
1632                  \textcolor{stringliteral}{"invariables disch\_w and disch\_s."}, fail\_if\_missing=.true.)
1633 
1634       \textcolor{comment}{! These variable names are hard-coded, per the archaic OMIP conventions.}
1635       cs%latentheat\_file = cs%evaporation\_file ; cs%latent\_var = \textcolor{stringliteral}{"evap"}
1636       cs%LW\_var = \textcolor{stringliteral}{"lwdn\_sfc"}; cs%SW\_var = \textcolor{stringliteral}{"swdn\_sfc"}; cs%sens\_var = \textcolor{stringliteral}{"shflx"}
1637       cs%evap\_var = \textcolor{stringliteral}{"evap"}; cs%rain\_var = \textcolor{stringliteral}{"precip"}; cs%snow\_var = \textcolor{stringliteral}{"snow"}
1638       cs%lrunoff\_var = \textcolor{stringliteral}{"disch\_w"}; cs%frunoff\_var = \textcolor{stringliteral}{"disch\_s"}
1639 
1640     \textcolor{keywordflow}{else}
1641       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVE\_FILE"}, cs%longwave\_file, &
1642                  \textcolor{stringliteral}{"The file with the longwave heat flux, in the variable "}//&
1643                  \textcolor{stringliteral}{"given by LONGWAVE\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1644       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LONGWAVE\_FORCING\_VAR"}, cs%LW\_var, &
1645                  \textcolor{stringliteral}{"The variable with the longwave forcing field."}, default=\textcolor{stringliteral}{"LW"})
1646 
1647       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVE\_FILE"}, cs%shortwave\_file, &
1648                  \textcolor{stringliteral}{"The file with the shortwave heat flux, in the variable "}//&
1649                  \textcolor{stringliteral}{"given by SHORTWAVE\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1650       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVE\_FORCING\_VAR"}, cs%SW\_var, &
1651                  \textcolor{stringliteral}{"The variable with the shortwave forcing field."}, default=\textcolor{stringliteral}{"SW"})
1652 
1653       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAPORATION\_FILE"}, cs%evaporation\_file, &
1654                  \textcolor{stringliteral}{"The file with the evaporative moisture flux, in the "}//&
1655                  \textcolor{stringliteral}{"variable given by EVAP\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1656       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"EVAP\_FORCING\_VAR"}, cs%evap\_var, &
1657                  \textcolor{stringliteral}{"The variable with the evaporative moisture flux."}, &
1658                  default=\textcolor{stringliteral}{"evap"})
1659 
1660       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENTHEAT\_FILE"}, cs%latentheat\_file, &
1661                  \textcolor{stringliteral}{"The file with the latent heat flux, in the variable "}//&
1662                  \textcolor{stringliteral}{"given by LATENT\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1663       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_FORCING\_VAR"}, cs%latent\_var, &
1664                  \textcolor{stringliteral}{"The variable with the latent heat flux."}, default=\textcolor{stringliteral}{"latent"})
1665 
1666       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLEHEAT\_FILE"}, cs%sensibleheat\_file, &
1667                  \textcolor{stringliteral}{"The file with the sensible heat flux, in the variable "}//&
1668                  \textcolor{stringliteral}{"given by SENSIBLE\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1669       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLE\_FORCING\_VAR"}, cs%sens\_var, &
1670                  \textcolor{stringliteral}{"The variable with the sensible heat flux."}, default=\textcolor{stringliteral}{"sensible"})
1671 
1672       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RAIN\_FILE"}, cs%rain\_file, &
1673                  \textcolor{stringliteral}{"The file with the liquid precipitation flux, in the "}//&
1674                  \textcolor{stringliteral}{"variable given by RAIN\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1675       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RAIN\_FORCING\_VAR"}, cs%rain\_var, &
1676                  \textcolor{stringliteral}{"The variable with the liquid precipitation flux."}, &
1677                  default=\textcolor{stringliteral}{"liq\_precip"})
1678       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FILE"}, cs%snow\_file, &
1679                  \textcolor{stringliteral}{"The file with the frozen precipitation flux, in the "}//&
1680                  \textcolor{stringliteral}{"variable given by SNOW\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1681       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SNOW\_FORCING\_VAR"}, cs%snow\_var, &
1682                  \textcolor{stringliteral}{"The variable with the frozen precipitation flux."}, &
1683                  default=\textcolor{stringliteral}{"froz\_precip"})
1684 
1685       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RUNOFF\_FILE"}, cs%runoff\_file, &
1686                  \textcolor{stringliteral}{"The file with the fresh and frozen runoff/calving "}//&
1687                  \textcolor{stringliteral}{"fluxes, in variables given by LIQ\_RUNOFF\_FORCING\_VAR "}//&
1688                  \textcolor{stringliteral}{"and FROZ\_RUNOFF\_FORCING\_VAR."}, fail\_if\_missing=.true.)
1689       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LIQ\_RUNOFF\_FORCING\_VAR"}, cs%lrunoff\_var, &
1690                  \textcolor{stringliteral}{"The variable with the liquid runoff flux."}, &
1691                  default=\textcolor{stringliteral}{"liq\_runoff"})
1692       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FROZ\_RUNOFF\_FORCING\_VAR"}, cs%frunoff\_var, &
1693                  \textcolor{stringliteral}{"The variable with the frozen runoff flux."}, &
1694                  default=\textcolor{stringliteral}{"froz\_runoff"})
1695 \textcolor{keywordflow}{    endif}
1696 
1697     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSTRESTORE\_FILE"}, cs%SSTrestore\_file, &
1698                  \textcolor{stringliteral}{"The file with the SST toward which to restore in the "}//&
1699                  \textcolor{stringliteral}{"variable given by SST\_RESTORE\_VAR."}, fail\_if\_missing=.true.)
1700     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SALINITYRESTORE\_FILE"}, cs%salinityrestore\_file, &
1701                  \textcolor{stringliteral}{"The file with the surface salinity toward which to "}//&
1702                  \textcolor{stringliteral}{"restore in the variable given by SSS\_RESTORE\_VAR."}, &
1703                  fail\_if\_missing=.true.)
1704 
1705     \textcolor{keywordflow}{if} (cs%archaic\_OMIP\_file) \textcolor{keywordflow}{then}
1706       cs%SST\_restore\_var = \textcolor{stringliteral}{"TEMP"} ; cs%SSS\_restore\_var = \textcolor{stringliteral}{"SALT"}
1707     \textcolor{keywordflow}{else}
1708       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_RESTORE\_VAR"}, cs%SST\_restore\_var, &
1709                  \textcolor{stringliteral}{"The variable with the SST toward which to restore."}, &
1710                  default=\textcolor{stringliteral}{"SST"})
1711       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_RESTORE\_VAR"}, cs%SSS\_restore\_var, &
1712                  \textcolor{stringliteral}{"The variable with the SSS toward which to restore."}, &
1713                  default=\textcolor{stringliteral}{"SSS"})
1714 \textcolor{keywordflow}{    endif}
1715 
1716     \textcolor{comment}{! Add inputdir to the file names.}
1717     cs%shortwave\_file = trim(cs%inputdir)//trim(cs%shortwave\_file)
1718     cs%longwave\_file = trim(cs%inputdir)//trim(cs%longwave\_file)
1719     cs%sensibleheat\_file = trim(cs%inputdir)//trim(cs%sensibleheat\_file)
1720     cs%latentheat\_file = trim(cs%inputdir)//trim(cs%latentheat\_file)
1721     cs%evaporation\_file = trim(cs%inputdir)//trim(cs%evaporation\_file)
1722     cs%snow\_file = trim(cs%inputdir)//trim(cs%snow\_file)
1723     cs%rain\_file = trim(cs%inputdir)//trim(cs%rain\_file)
1724     cs%runoff\_file = trim(cs%inputdir)//trim(cs%runoff\_file)
1725 
1726     cs%shortwaveup\_file = trim(cs%inputdir)//trim(cs%shortwaveup\_file)
1727     cs%longwaveup\_file = trim(cs%inputdir)//trim(cs%longwaveup\_file)
1728 
1729     cs%SSTrestore\_file = trim(cs%inputdir)//trim(cs%SSTrestore\_file)
1730     cs%salinityrestore\_file = trim(cs%inputdir)//trim(cs%salinityrestore\_file)
1731   \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}
1732     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLE\_HEAT\_FLUX"}, cs%constantHeatForcing, &
1733                  \textcolor{stringliteral}{"A constant heat forcing (positive into ocean) applied "}//&
1734                  \textcolor{stringliteral}{"through the sensible heat flux field. "}, &
1735                  units=\textcolor{stringliteral}{'W/m2'}, scale=us%W\_m2\_to\_QRZ\_T, fail\_if\_missing=.true.)
1736 \textcolor{keywordflow}{  endif}
1737   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_CONFIG"}, cs%wind\_config, &
1738                  \textcolor{stringliteral}{"The character string that indicates how wind forcing "}//&
1739                  \textcolor{stringliteral}{"is specified. Valid options include (file), (2gyre), "}//&
1740                  \textcolor{stringliteral}{"(1gyre), (gyres), (zero), and (USER)."}, default=\textcolor{stringliteral}{"zero"})
1741   \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}
1742     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_FILE"}, cs%wind\_file, &
1743                  \textcolor{stringliteral}{"The file in which the wind stresses are found in "}//&
1744                  \textcolor{stringliteral}{"variables STRESS\_X and STRESS\_Y."}, fail\_if\_missing=.true.)
1745     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_X\_VAR"},cs%stress\_x\_var, &
1746                  \textcolor{stringliteral}{"The name of the x-wind stress variable in WIND\_FILE."}, &
1747                  default=\textcolor{stringliteral}{"STRESS\_X"})
1748     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_Y\_VAR"}, cs%stress\_y\_var, &
1749                  \textcolor{stringliteral}{"The name of the y-wind stress variable in WIND\_FILE."}, &
1750                  default=\textcolor{stringliteral}{"STRESS\_Y"})
1751     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_STAGGER"},cs%wind\_stagger, &
1752                  \textcolor{stringliteral}{"A character indicating how the wind stress components "}//&
1753                  \textcolor{stringliteral}{"are staggered in WIND\_FILE.  This may be A or C for now."}, &
1754                  default=\textcolor{stringliteral}{"C"})
1755     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WINDSTRESS\_SCALE"}, cs%wind\_scale, &
1756                  \textcolor{stringliteral}{"A value by which the wind stresses in WIND\_FILE are rescaled."}, &
1757                  default=1.0, units=\textcolor{stringliteral}{"nondim"})
1758     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USTAR\_FORCING\_VAR"}, cs%ustar\_var, &
1759                  \textcolor{stringliteral}{"The name of the friction velocity variable in WIND\_FILE "}//&
1760                  \textcolor{stringliteral}{"or blank to get ustar from the wind stresses plus the "}//&
1761                  \textcolor{stringliteral}{"gustiness."}, default=\textcolor{stringliteral}{" "}, units=\textcolor{stringliteral}{"nondim"})
1762     cs%wind\_file = trim(cs%inputdir) // trim(cs%wind\_file)
1763 \textcolor{keywordflow}{  endif}
1764   \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"gyres"}) \textcolor{keywordflow}{then}
1765     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_CONST"}, cs%gyres\_taux\_const, &
1766                  \textcolor{stringliteral}{"With the gyres wind\_config, the constant offset in the "}//&
1767                  \textcolor{stringliteral}{"zonal wind stress profile: "}//&
1768                  \textcolor{stringliteral}{"  A in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, &
1769                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)
1770     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_SIN\_AMP"},cs%gyres\_taux\_sin\_amp, &
1771                  \textcolor{stringliteral}{"With the gyres wind\_config, the sine amplitude in the "}//&
1772                  \textcolor{stringliteral}{"zonal wind stress profile: "}//&
1773                  \textcolor{stringliteral}{"  B in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, &
1774                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)
1775     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_COS\_AMP"},cs%gyres\_taux\_cos\_amp, &
1776                  \textcolor{stringliteral}{"With the gyres wind\_config, the cosine amplitude in "}//&
1777                  \textcolor{stringliteral}{"the zonal wind stress profile: "}//&
1778                  \textcolor{stringliteral}{"  C in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, &
1779                  units=\textcolor{stringliteral}{"Pa"}, default=0.0)
1780     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"TAUX\_N\_PIS"},cs%gyres\_taux\_n\_pis, &
1781                  \textcolor{stringliteral}{"With the gyres wind\_config, the number of gyres in "}//&
1782                  \textcolor{stringliteral}{"the zonal wind stress profile: "}//&
1783                  \textcolor{stringliteral}{"  n in taux = A + B*sin(n*pi*y/L) + C*cos(n*pi*y/L)."}, &
1784                  units=\textcolor{stringliteral}{"nondim"}, default=0.0)
1785     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DEFAULT\_2018\_ANSWERS"}, default\_2018\_answers, &
1786                  \textcolor{stringliteral}{"This sets the default value for the various \_2018\_ANSWERS parameters."}, &
1787                  default=.false.)
1788     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_GYRES\_2018\_ANSWERS"}, cs%answers\_2018, &
1789                  \textcolor{stringliteral}{"If true, use the order of arithmetic and expressions that recover the answers "}//&
1790                  \textcolor{stringliteral}{"from the end of 2018.  Otherwise, use expressions for the gyre friction velocities "}//&
1791                  \textcolor{stringliteral}{"that are rotationally invariant and more likely to be the same between compilers."}, &
1792                  default=default\_2018\_answers)
1793   \textcolor{keywordflow}{else}
1794     cs%answers\_2018 = .false.
1795 \textcolor{keywordflow}{  endif}
1796   \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"scurves"}) \textcolor{keywordflow}{then}
1797     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_SCURVES\_LATS"}, cs%scurves\_ydata, &
1798                  \textcolor{stringliteral}{"A list of latitudes defining a piecewise scurve profile "}//&
1799                  \textcolor{stringliteral}{"for zonal wind stress."}, &
1800                  units=\textcolor{stringliteral}{"degrees N"}, fail\_if\_missing=.true.)
1801     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"WIND\_SCURVES\_TAUX"}, cs%scurves\_taux, &
1802                  \textcolor{stringliteral}{"A list of zonal wind stress values at latitudes "}//&
1803                  \textcolor{stringliteral}{"WIND\_SCURVES\_LATS defining a piecewise scurve profile."}, &
1804                  units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)
1805 \textcolor{keywordflow}{  endif}
1806   \textcolor{keywordflow}{if} ((trim(cs%wind\_config) == \textcolor{stringliteral}{"2gyre"}) .or. &
1807       (trim(cs%wind\_config) == \textcolor{stringliteral}{"1gyre"}) .or. &
1808       (trim(cs%wind\_config) == \textcolor{stringliteral}{"gyres"}) .or. &
1809       (trim(cs%buoy\_config) == \textcolor{stringliteral}{"linear"})) \textcolor{keywordflow}{then}
1810     cs%south\_lat = g%south\_lat
1811     cs%len\_lat = g%len\_lat
1812 \textcolor{keywordflow}{  endif}
1813 
1814   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs%Rho0, &
1815                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//&
1816                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//&
1817                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//&
1818                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, &
1819                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0, scale=us%kg\_m3\_to\_R)
1820   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTOREBUOY"}, cs%restorebuoy, &
1821                  \textcolor{stringliteral}{"If true, the buoyancy fluxes drive the model back "}//&
1822                  \textcolor{stringliteral}{"toward some specified surface state with a rate "}//&
1823                  \textcolor{stringliteral}{"given by FLUXCONST."}, default= .false.)
1824   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_FUSION"}, cs%latent\_heat\_fusion, &
1825                  \textcolor{stringliteral}{"The latent heat of fusion."}, default=hlf, &
1826                  units=\textcolor{stringliteral}{"J/kg"}, scale=us%J\_kg\_to\_Q)
1827   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"LATENT\_HEAT\_VAPORIZATION"}, cs%latent\_heat\_vapor, &
1828                  \textcolor{stringliteral}{"The latent heat of fusion."}, default=hlv, units=\textcolor{stringliteral}{"J/kg"}, scale=us%J\_kg\_to\_Q)
1829   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
1830     \textcolor{comment}{! These three variables use non-standard time units, but are rescaled as they are read.}
1831     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST"}, cs%Flux\_const, &
1832                  \textcolor{stringliteral}{"The constant that relates the restoring surface fluxes to the relative "}//&
1833                  \textcolor{stringliteral}{"surface anomalies (akin to a piston velocity).  Note the non-MKS units."}, &
1834                  default=0.0, units=\textcolor{stringliteral}{"m day-1"}, scale=us%m\_to\_Z*us%T\_to\_s/86400.0, &
1835                  unscaled=flux\_const\_default)
1836 
1837     \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
1838       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST\_T"}, cs%Flux\_const\_T, &
1839            \textcolor{stringliteral}{"The constant that relates the restoring surface temperature "}//&
1840            \textcolor{stringliteral}{"flux to the relative surface anomaly (akin to a piston "}//&
1841            \textcolor{stringliteral}{"velocity).  Note the non-MKS units."}, &
1842            units=\textcolor{stringliteral}{"m day-1"}, scale=us%m\_to\_Z*us%T\_to\_s/86400.0, &
1843            default=flux\_const\_default)
1844       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST\_S"}, cs%Flux\_const\_S, &
1845            \textcolor{stringliteral}{"The constant that relates the restoring surface salinity "}//&
1846            \textcolor{stringliteral}{"flux to the relative surface anomaly (akin to a piston "}//&
1847            \textcolor{stringliteral}{"velocity).  Note the non-MKS units."}, &
1848            units=\textcolor{stringliteral}{"m day-1"}, scale=us%m\_to\_Z*us%T\_to\_s/86400.0, &
1849            default=flux\_const\_default)
1850 \textcolor{keywordflow}{    endif}
1851 
1852     \textcolor{keywordflow}{if} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"linear"}) \textcolor{keywordflow}{then}
1853       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_NORTH"}, cs%T\_north, &
1854                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface temperature "}//&
1855                  \textcolor{stringliteral}{"at the northern end of the domain toward which to "}//&
1856                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)
1857       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SST\_SOUTH"}, cs%T\_south, &
1858                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface temperature "}//&
1859                  \textcolor{stringliteral}{"at the southern end of the domain toward which to "}//&
1860                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"deg C"}, default=0.0)
1861       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_NORTH"}, cs%S\_north, &
1862                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface salinity "}//&
1863                  \textcolor{stringliteral}{"at the northern end of the domain toward which to "}//&
1864                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"PSU"}, default=35.0)
1865       \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSS\_SOUTH"}, cs%S\_south, &
1866                  \textcolor{stringliteral}{"With buoy\_config linear, the sea surface salinity "}//&
1867                  \textcolor{stringliteral}{"at the southern end of the domain toward which to "}//&
1868                  \textcolor{stringliteral}{"to restore."}, units=\textcolor{stringliteral}{"PSU"}, default=35.0)
1869 \textcolor{keywordflow}{    endif}
1870 \textcolor{keywordflow}{  endif}
1871   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs%G\_Earth, &
1872                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, &
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)
1874 
1875   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_CONST"}, cs%gust\_const, &
1876                  \textcolor{stringliteral}{"The background gustiness in the winds."}, &
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)
1878   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FIX\_USTAR\_GUSTLESS\_BUG"}, cs%fix\_ustar\_gustless\_bug, &
1879                  \textcolor{stringliteral}{"If true correct a bug in the time-averaging of the gustless wind friction velocity"}, &
1880                  default=.true.)
1881   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"READ\_GUST\_2D"}, cs%read\_gust\_2d, &
1882                  \textcolor{stringliteral}{"If true, use a 2-dimensional gustiness supplied from "}//&
1883                  \textcolor{stringliteral}{"an input file"}, default=.false.)
1884   \textcolor{keywordflow}{if} (cs%read\_gust\_2d) \textcolor{keywordflow}{then}
1885     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_2D\_FILE"}, gust\_file, &
1886                  \textcolor{stringliteral}{"The file in which the wind gustiness is found in "}//&
1887                  \textcolor{stringliteral}{"variable gustiness."}, fail\_if\_missing=.true.)
1888     \textcolor{keyword}{call }safe\_alloc\_ptr(cs%gust,g%isd,g%ied,g%jsd,g%jed)
1889     filename = trim(cs%inputdir) // trim(gust\_file)
1890     \textcolor{keyword}{call }mom\_read\_data(filename,\textcolor{stringliteral}{'gustiness'},cs%gust,g%domain, timelevel=1, &
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}
1892 \textcolor{keywordflow}{  endif}
1893 
1894 \textcolor{comment}{!  All parameter settings are now known.}
1895 
1896   \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"USER"} .or. trim(cs%buoy\_config) == \textcolor{stringliteral}{"USER"} ) \textcolor{keywordflow}{then}
1897     \textcolor{keyword}{call }user\_surface\_forcing\_init(time, g, us, param\_file, diag, cs%user\_forcing\_CSp)
1898   \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"BFB"} ) \textcolor{keywordflow}{then}
1899     \textcolor{keyword}{call }bfb\_surface\_forcing\_init(time, g, us, param\_file, diag, cs%BFB\_forcing\_CSp)
1900   \textcolor{keywordflow}{elseif} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"dumbbell"} ) \textcolor{keywordflow}{then}
1901     \textcolor{keyword}{call }dumbbell\_surface\_forcing\_init(time, g, us, param\_file, diag, cs%dumbbell\_forcing\_CSp)
1902   \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"MESO"} .or. trim(cs%buoy\_config) == \textcolor{stringliteral}{"MESO"} ) \textcolor{keywordflow}{then}
1903     \textcolor{keyword}{call }meso\_surface\_forcing\_init(time, g, us, param\_file, diag, cs%MESO\_forcing\_CSp)
1904   \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"ideal\_hurr"} .or.&
1905           trim(cs%wind\_config) == \textcolor{stringliteral}{"SCM\_ideal\_hurr"}) \textcolor{keywordflow}{then}
1906     \textcolor{keyword}{call }idealized\_hurricane\_wind\_init(time, g, us, param\_file, cs%idealized\_hurricane\_CSp)
1907   \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"const"}) \textcolor{keywordflow}{then}
1908     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_WIND\_TAUX"}, cs%tau\_x0, &
1909                  \textcolor{stringliteral}{"With wind\_config const, this is the constant zonal "}//&
1910                  \textcolor{stringliteral}{"wind-stress"}, units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)
1911     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"CONST\_WIND\_TAUY"}, cs%tau\_y0, &
1912                  \textcolor{stringliteral}{"With wind\_config const, this is the constant meridional "}//&
1913                  \textcolor{stringliteral}{"wind-stress"}, units=\textcolor{stringliteral}{"Pa"}, fail\_if\_missing=.true.)
1914   \textcolor{keywordflow}{elseif} (trim(cs%wind\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"} .or. &
1915           trim(cs%buoy\_config) == \textcolor{stringliteral}{"SCM\_CVmix\_tests"}) \textcolor{keywordflow}{then}
1916     \textcolor{keyword}{call }scm\_cvmix\_tests\_surface\_forcing\_init(time, g, param\_file, cs%SCM\_CVmix\_tests\_CSp)
1917 \textcolor{keywordflow}{  endif}
1918 
1919   \textcolor{keyword}{call }register\_forcing\_type\_diags(time, diag, us, cs%use\_temperature, cs%handles)
1920 
1921   \textcolor{comment}{! Set up any restart fields associated with the forcing.}
1922   \textcolor{keyword}{call }restart\_init(param\_file, cs%restart\_CSp, \textcolor{stringliteral}{"MOM\_forcing.res"})
1923 \textcolor{comment}{!#CTRL#  call register\_ctrl\_forcing\_restarts(G, param\_file, CS%ctrl\_forcing\_CSp, &}
1924 \textcolor{comment}{!#CTRL#                                      CS%restart\_CSp)}
1925   \textcolor{keyword}{call }restart\_init\_end(cs%restart\_CSp)
1926 
1927   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs%restart\_CSp)) \textcolor{keywordflow}{then}
1928     \textcolor{keyword}{call }get\_mom\_input(dirs=dirs)
1929 
1930     new\_sim = .false.
1931     \textcolor{keywordflow}{if} ((dirs%input\_filename(1:1) == \textcolor{stringliteral}{'n'}) .and. &
1932         (len\_trim(dirs%input\_filename) == 1)) new\_sim = .true.
1933     \textcolor{keywordflow}{if} (.not.new\_sim) \textcolor{keywordflow}{then}
1934       \textcolor{keyword}{call }restore\_state(dirs%input\_filename, dirs%restart\_input\_dir, time\_frc, &
1935                          g, cs%restart\_CSp)
1936 \textcolor{keywordflow}{    endif}
1937 \textcolor{keywordflow}{  endif}
1938 
1939   \textcolor{comment}{! Determine how many time levels are in each forcing variable.}
1940   \textcolor{keywordflow}{if} (trim(cs%buoy\_config) == \textcolor{stringliteral}{"file"}) \textcolor{keywordflow}{then}
1941     cs%SW\_nlev = num\_timelevels(cs%shortwave\_file, cs%SW\_var, min\_dims=3)
1942     cs%LW\_nlev = num\_timelevels(cs%longwave\_file, cs%LW\_var, min\_dims=3)
1943     cs%latent\_nlev = num\_timelevels(cs%latentheat\_file, cs%latent\_var, 3)
1944     cs%sens\_nlev = num\_timelevels(cs%sensibleheat\_file, cs%sens\_var, min\_dims=3)
1945 
1946     cs%evap\_nlev = num\_timelevels(cs%evaporation\_file, cs%evap\_var, min\_dims=3)
1947     cs%precip\_nlev = num\_timelevels(cs%rain\_file, cs%rain\_var, min\_dims=3)
1948     cs%runoff\_nlev = num\_timelevels(cs%runoff\_file, cs%lrunoff\_var, 3)
1949 
1950     cs%SST\_nlev = num\_timelevels(cs%SSTrestore\_file, cs%SST\_restore\_var, 3)
1951     cs%SSS\_nlev = num\_timelevels(cs%salinityrestore\_file, cs%SSS\_restore\_var, 3)
1952 \textcolor{keywordflow}{  endif}
1953 
1954   \textcolor{keywordflow}{if} (trim(cs%wind\_config) == \textcolor{stringliteral}{"file"}) &
1955     cs%wind\_nlev = num\_timelevels(cs%wind\_file, cs%stress\_x\_var, min\_dims=3)
1956 
1957 \textcolor{comment}{!#CTRL#  call controlled\_forcing\_init(Time, G, param\_file, diag, CS%ctrl\_forcing\_CSp)}
1958 
1959   \textcolor{keyword}{call }user\_revise\_forcing\_init(param\_file, cs%urf\_CS)
1960 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
452   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
453 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
454   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
455   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
456   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
457   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
458   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
459 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
460   \textcolor{comment}{! Local variables}
461   \textcolor{keywordtype}{real} :: pi
462   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
463 
464   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_1gyre, MOM\_surface\_forcing.F90"})
465   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec
466   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
467 
468   \textcolor{comment}{! set the steady surface wind stresses, in units of Pa.}
469   pi = 4.0*atan(1.0)
470 
471   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
472     forces%taux(i,j) = -0.2*us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z * &
473                        cos(pi*(g%geoLatCu(i,j)-cs%South\_lat)/cs%len\_lat)
474 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
475 
476   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
477     forces%tauy(i,j) = 0.0
478 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
479 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
418   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
419 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
420   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
421   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
422   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
423   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
424   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
425 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
426   \textcolor{comment}{! Local variables}
427   \textcolor{keywordtype}{real} :: pi
428   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
429 
430   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_2gyre, MOM\_surface\_forcing.F90"})
431   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec
432   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
433 
434   \textcolor{comment}{!set the steady surface wind stresses, in units of Pa.}
435   pi = 4.0*atan(1.0)
436 
437   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
438     forces%taux(i,j) = 0.1*us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z * &
439                       (1.0 - cos(2.0*pi*(g%geoLatCu(i,j)-cs%South\_lat) / cs%len\_lat))
440 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
441 
442   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
443     forces%tauy(i,j) = 0.0
444 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
445 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
823   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
824 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
825   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
826   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
827   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
828   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
829   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
830 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
831   \textcolor{comment}{! Local variables}
832   \textcolor{keywordtype}{real} :: temp\_x(szi\_(g),szj\_(g)) \textcolor{comment}{! Pseudo-zonal and psuedo-meridional}
833   \textcolor{keywordtype}{real} :: temp\_y(szi\_(g),szj\_(g)) \textcolor{comment}{! wind stresses at h-points [Pa].}
834   \textcolor{keywordtype}{real} :: temp\_ustar(szi\_(g),szj\_(g)) \textcolor{comment}{! ustar [m s-1] (not rescaled).}
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]}
836   \textcolor{keywordtype}{integer} :: i, j, is\_in, ie\_in, js\_in, je\_in
837   \textcolor{keywordtype}{logical} :: read\_ustar
838 
839   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_by\_data\_override, MOM\_surface\_forcing.F90"})
840 
841   \textcolor{keywordflow}{if} (.not.cs%dataOverrideIsInitialized) \textcolor{keywordflow}{then}
842     \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true., ustar=.true., press=.true.)
843     \textcolor{keyword}{call }data\_override\_init(ocean\_domain\_in=g%Domain%mpp\_domain)
844     cs%dataOverrideIsInitialized = .true.
845 \textcolor{keywordflow}{  endif}
846 
847   is\_in = g%isc - g%isd + 1 ; ie\_in = g%iec - g%isd + 1
848   js\_in = g%jsc - g%jsd + 1 ; je\_in = g%jec - g%jsd + 1
849   pa\_conversion = us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z
850 
851   temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0
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)
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)
854   \textcolor{keyword}{call }pass\_vector(temp\_x, temp\_y, g%Domain, to\_all, agrid)
855   \textcolor{comment}{! Ignore CS%wind\_scale when using data\_override ?????}
856   \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc-1,g%IecB
857     forces%taux(i,j) = pa\_conversion * 0.5 * (temp\_x(i,j) + temp\_x(i+1,j))
858 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
859   \textcolor{keywordflow}{do} j=g%jsc-1,g%JecB ; \textcolor{keywordflow}{do} i=g%isc,g%iec
860     forces%tauy(i,j) = pa\_conversion * 0.5 * (temp\_y(i,j) + temp\_y(i,j+1))
861 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
862 
863   read\_ustar = (len\_trim(cs%ustar\_var) > 0) \textcolor{comment}{! Need better control higher up ????}
864   \textcolor{keywordflow}{if} (read\_ustar) \textcolor{keywordflow}{then}
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}
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)
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}
868   \textcolor{keywordflow}{else}
869     \textcolor{keywordflow}{if} (cs%read\_gust\_2d) \textcolor{keywordflow}{then}
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)
871       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
872         forces%ustar(i,j) = sqrt((pa\_conversion * sqrt(temp\_x(i,j)*temp\_x(i,j) + &
873             temp\_y(i,j)*temp\_y(i,j)) + cs%gust(i,j)) * us%L\_to\_Z / cs%Rho0)
874 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
875     \textcolor{keywordflow}{else}
876       \textcolor{keywordflow}{do} j=g%jsc,g%jec ; \textcolor{keywordflow}{do} i=g%isc,g%iec
877         forces%ustar(i,j) = sqrt(us%L\_to\_Z * (pa\_conversion*sqrt(temp\_x(i,j)*temp\_x(i,j) + &
878             temp\_y(i,j)*temp\_y(i,j))/cs%Rho0 + cs%gust\_const/cs%Rho0 ))
879 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
880 \textcolor{keywordflow}{    endif}
881 \textcolor{keywordflow}{  endif}
882 
883   \textcolor{keyword}{call }pass\_vector(forces%taux, forces%tauy, g%Domain, to\_all)
884 \textcolor{comment}{! call pass\_var(forces%ustar, G%Domain, To\_All)     Not needed  ?????}
885 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em tau\+\_\+x0} & The zonal wind stress \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em tau\+\_\+y0} & The meridional wind stress \mbox{[}Pa\mbox{]}\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
371   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
372 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
373   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
374   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: tau\_x0\textcolor{comment}{ !< The zonal wind stress [Pa]}
375   \textcolor{keywordtype}{real},                     \textcolor{keywordtype}{intent(in)}    :: tau\_y0\textcolor{comment}{ !< The meridional wind stress [Pa]}
376   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
377   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
378   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
379   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
380 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
381   \textcolor{comment}{! Local variables}
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]}
383   \textcolor{keywordtype}{real} :: mag\_tau
384   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
385 
386   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_const, MOM\_surface\_forcing.F90"})
387   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec
388   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
389   pa\_conversion = us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z
390 
391   \textcolor{comment}{!set steady surface wind stresses, in units of Pa.}
392   mag\_tau = pa\_conversion * sqrt( tau\_x0**2 + tau\_y0**2)
393 
394   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
395     forces%taux(i,j) = tau\_x0 * pa\_conversion
396 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
397 
398   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
399     forces%tauy(i,j) = tau\_y0 * pa\_conversion
400 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
401 
402   \textcolor{keywordflow}{if} (cs%read\_gust\_2d) \textcolor{keywordflow}{then}
403     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
404       forces%ustar(i,j) = sqrt( us%L\_to\_Z * ( mag\_tau + cs%gust(i,j) ) / cs%Rho0 )
405 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
406   \textcolor{keywordflow}{else}
407     \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
408       forces%ustar(i,j) = sqrt( us%L\_to\_Z * ( mag\_tau + cs%gust\_const ) / cs%Rho0 )
409 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
410 \textcolor{keywordflow}{  endif}
411 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
668   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
669 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
670   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
671   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
672   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
673   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
674   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
675 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
676   \textcolor{comment}{! Local variables}
677   \textcolor{keywordtype}{character(len=200)} :: filename  \textcolor{comment}{! The name of the input file.}
678   \textcolor{keywordtype}{real}    :: temp\_x(szi\_(g),szj\_(g)) \textcolor{comment}{! Pseudo-zonal and psuedo-meridional}
679   \textcolor{keywordtype}{real}    :: temp\_y(szi\_(g),szj\_(g)) \textcolor{comment}{! wind stresses at h-points [R L Z T-1 ~> Pa].}
680   \textcolor{keywordtype}{real}    :: pa\_conversion           \textcolor{comment}{! A unit conversion factor from Pa to the internal wind stress}
681                                      \textcolor{comment}{! units [R Z L T-2 Pa-1 ~> 1]}
682   \textcolor{keywordtype}{integer} :: time\_lev\_daily          \textcolor{comment}{! The time levels to read for fields with}
683   \textcolor{keywordtype}{integer} :: time\_lev\_monthly        \textcolor{comment}{! daily and montly cycles.}
684   \textcolor{keywordtype}{integer} :: time\_lev                \textcolor{comment}{! The time level that is used for a field.}
685   \textcolor{keywordtype}{integer} :: days, seconds
686   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
687   \textcolor{keywordtype}{logical} :: read\_ustar
688 
689   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_from\_file, MOM\_surface\_forcing.F90"})
690   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec
691   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
692   pa\_conversion = us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z
693 
694   \textcolor{keyword}{call }get\_time(day, seconds, days)
695   time\_lev\_daily = days - 365*floor(\textcolor{keywordtype}{real(days)} / 365.0)
696 
697   \textcolor{keywordflow}{if} (time\_lev\_daily < 31) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 0
698   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 59)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 1
699   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 90)  \textcolor{keywordflow}{then} ; time\_lev\_monthly = 2
700   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 120) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 3
701   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 151) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 4
702   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 181) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 5
703   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 212) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 6
704   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 243) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 7
705   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 273) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 8
706   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 304) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 9
707   \textcolor{keywordflow}{elseif} (time\_lev\_daily < 334) \textcolor{keywordflow}{then} ; time\_lev\_monthly = 10
708   \textcolor{keywordflow}{else} ; time\_lev\_monthly = 11
709 \textcolor{keywordflow}{  endif}
710 
711   time\_lev\_daily = time\_lev\_daily+1
712   time\_lev\_monthly = time\_lev\_monthly+1
713 
714   \textcolor{keywordflow}{select case} (cs%wind\_nlev)
715     \textcolor{keywordflow}{case} (12) ; time\_lev = time\_lev\_monthly
716     \textcolor{keywordflow}{case} (365) ; time\_lev = time\_lev\_daily
717 \textcolor{keywordflow}{    case default} ; time\_lev = 1
718 \textcolor{keywordflow}{  end select}
719 
720   \textcolor{keywordflow}{if} (time\_lev /= cs%wind\_last\_lev) \textcolor{keywordflow}{then}
721     filename = trim(cs%wind\_file)
722     read\_ustar = (len\_trim(cs%ustar\_var) > 0)
723 \textcolor{comment}{!    if (is\_root\_pe()) &}
724 \textcolor{comment}{!      write(*,'("Wind\_forcing Reading time level ",I," last was ",I,".")')&}
725 \textcolor{comment}{!           time\_lev-1,CS%wind\_last\_lev-1}
726     \textcolor{keywordflow}{select case} ( uppercase(cs%wind\_stagger(1:1)) )
727     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"A"})
728       temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0
729       \textcolor{keyword}{call }mom\_read\_vector(filename, cs%stress\_x\_var, cs%stress\_y\_var, &
730                            temp\_x(:,:), temp\_y(:,:), g%Domain, stagger=agrid, &
731                            timelevel=time\_lev, scale=pa\_conversion)
732 
733       \textcolor{keyword}{call }pass\_vector(temp\_x, temp\_y, g%Domain, to\_all, agrid)
734       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
735         forces%taux(i,j) = 0.5 * cs%wind\_scale * (temp\_x(i,j) + temp\_x(i+1,j))
736 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
737       \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
738         forces%tauy(i,j) = 0.5 * cs%wind\_scale * (temp\_y(i,j) + temp\_y(i,j+1))
739 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
740 
741       \textcolor{keywordflow}{if} (.not.read\_ustar) \textcolor{keywordflow}{then}
742         \textcolor{keywordflow}{if} (cs%read\_gust\_2d) \textcolor{keywordflow}{then}
743           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
744             forces%ustar(i,j) = sqrt((cs%gust(i,j) + &
745                     sqrt(temp\_x(i,j)*temp\_x(i,j) + temp\_y(i,j)*temp\_y(i,j))) * us%L\_to\_Z / cs%Rho0)
746 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
747         \textcolor{keywordflow}{else}
748           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
749             forces%ustar(i,j) = sqrt(us%L\_to\_Z * (cs%gust\_const/cs%Rho0 + &
750                     sqrt(temp\_x(i,j)*temp\_x(i,j) + temp\_y(i,j)*temp\_y(i,j)) / cs%Rho0) )
751 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
752 \textcolor{keywordflow}{        endif}
753 \textcolor{keywordflow}{      endif}
754     \textcolor{keywordflow}{case} (\textcolor{stringliteral}{"C"})
755       \textcolor{keywordflow}{if} (g%symmetric) \textcolor{keywordflow}{then}
756         \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(g%Domain\_aux)) \textcolor{keyword}{call }mom\_error(fatal, &
757           \textcolor{stringliteral}{" wind\_forcing\_from\_file with C-grid input and symmetric memory "}//&
758           \textcolor{stringliteral}{" called with a non-associated auxiliary domain in the grid type."})
759         \textcolor{comment}{!   Read the data as though symmetric memory were not being used, and}
760         \textcolor{comment}{! then translate it appropriately.}
761         temp\_x(:,:) = 0.0 ; temp\_y(:,:) = 0.0
762         \textcolor{keyword}{call }mom\_read\_vector(filename, cs%stress\_x\_var, cs%stress\_y\_var, &
763                              temp\_x(:,:), temp\_y(:,:), &
764                              g%Domain\_aux, stagger=cgrid\_ne, timelevel=time\_lev, &
765                              scale=pa\_conversion)
766         \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
767           forces%taux(i,j) = cs%wind\_scale * temp\_x(i,j)
768           forces%tauy(i,j) = cs%wind\_scale * temp\_y(i,j)
769 \textcolor{keywordflow}{        enddo} ;\textcolor{keywordflow}{ enddo}
770         \textcolor{keyword}{call }fill\_symmetric\_edges(forces%taux, forces%tauy, g%Domain, stagger=cgrid\_ne)
771       \textcolor{keywordflow}{else}
772         \textcolor{keyword}{call }mom\_read\_vector(filename, cs%stress\_x\_var, cs%stress\_y\_var, &
773                              forces%taux(:,:), forces%tauy(:,:), &
774                              g%Domain, stagger=cgrid\_ne, timelevel=time\_lev, &
775                              scale=pa\_conversion)
776 
777         \textcolor{keywordflow}{if} (cs%wind\_scale /= 1.0) \textcolor{keywordflow}{then}
778           \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=isq,ieq
779             forces%taux(i,j) = cs%wind\_scale * forces%taux(i,j)
780 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
781           \textcolor{keywordflow}{do} j=jsq,jeq ; \textcolor{keywordflow}{do} i=is,ie
782             forces%tauy(i,j) = cs%wind\_scale * forces%tauy(i,j)
783 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
784 \textcolor{keywordflow}{        endif}
785 \textcolor{keywordflow}{      endif}
786 
787       \textcolor{keyword}{call }pass\_vector(forces%taux, forces%tauy, g%Domain, to\_all)
788       \textcolor{keywordflow}{if} (.not.read\_ustar) \textcolor{keywordflow}{then}
789         \textcolor{keywordflow}{if} (cs%read\_gust\_2d) \textcolor{keywordflow}{then}
790           \textcolor{keywordflow}{do} j=js, je ; \textcolor{keywordflow}{do} i=is, ie
791             forces%ustar(i,j) = sqrt((cs%gust(i,j) + &
792                     sqrt(0.5*((forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2) + &
793                               (forces%taux(i-1,j)**2 + forces%taux(i,j)**2))) ) * us%L\_to\_Z / cs%Rho0 )
794 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
795         \textcolor{keywordflow}{else}
796           \textcolor{keywordflow}{do} j=js, je ; \textcolor{keywordflow}{do} i=is, ie
797             forces%ustar(i,j) = sqrt(us%L\_to\_Z * ( (cs%gust\_const/cs%Rho0) + &
798                     sqrt(0.5*((forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2) + &
799                               (forces%taux(i-1,j)**2 + forces%taux(i,j)**2)))/cs%Rho0))
800 \textcolor{keywordflow}{          enddo} ;\textcolor{keywordflow}{ enddo}
801 \textcolor{keywordflow}{        endif}
802 \textcolor{keywordflow}{      endif}
803 \textcolor{keywordflow}{    case default}
804       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"wind\_forcing\_from\_file: Unrecognized stagger "}//&
805                       trim(cs%wind\_stagger)//\textcolor{stringliteral}{" is not 'A' or 'C'."})
806 \textcolor{keywordflow}{    end select}
807 
808     \textcolor{keywordflow}{if} (read\_ustar) \textcolor{keywordflow}{then}
809       \textcolor{keyword}{call }mom\_read\_data(filename, cs%Ustar\_var, forces%ustar(:,:), &
810                          g%Domain, timelevel=time\_lev, scale=us%m\_to\_Z*us%T\_to\_s)
811 \textcolor{keywordflow}{    endif}
812 
813     cs%wind\_last\_lev = time\_lev
814 
815 \textcolor{keywordflow}{  endif} \textcolor{comment}{! time\_lev /= CS%wind\_last\_lev}
816 
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(\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em forces} & A structure with the driving mechanical forces\\
\hline
\mbox{\tt in}  & {\em day} & The time of the fluxes\\
\hline
\mbox{\tt in}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt 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}
485   \textcolor{keywordtype}{type}(surface),            \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
486 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
487   \textcolor{keywordtype}{type}(mech\_forcing),       \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
488   \textcolor{keywordtype}{type}(time\_type),          \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
489   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
490   \textcolor{keywordtype}{type}(unit\_scale\_type),    \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
491   \textcolor{keywordtype}{type}(surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< pointer to control struct returned by}
492 \textcolor{comment}{                                                  !! a previous surface\_forcing\_init call}
493   \textcolor{comment}{! Local variables}
494   \textcolor{keywordtype}{real} :: pi, y, i\_rho
495   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
496 
497   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"wind\_forcing\_gyres, MOM\_surface\_forcing.F90"})
498   is   = g%isc  ; ie   = g%iec  ; js   = g%jsc  ; je   = g%jec
499   isq  = g%IscB ; ieq  = g%IecB ; jsq  = g%JscB ; jeq  = g%JecB
500 
501   \textcolor{comment}{! steady surface wind stresses [Pa]}
502   pi = 4.0*atan(1.0)
503 
504   \textcolor{keywordflow}{do} j=js-1,je+1 ; \textcolor{keywordflow}{do} i=is-1,ieq
505     y = (g%geoLatCu(i,j)-cs%South\_lat) / cs%len\_lat
506     forces%taux(i,j) = us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z * &
507             (cs%gyres\_taux\_const +                            &
508              (   cs%gyres\_taux\_sin\_amp*sin(cs%gyres\_taux\_n\_pis*pi*y)    &
509                + cs%gyres\_taux\_cos\_amp*cos(cs%gyres\_taux\_n\_pis*pi*y) ))
510 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
511 
512   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is-1,ie+1
513     forces%tauy(i,j) = 0.0
514 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
515 
516   \textcolor{comment}{! set the friction velocity}
517   \textcolor{keywordflow}{if} (cs%answers\_2018) \textcolor{keywordflow}{then}
518     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
519       forces%ustar(i,j) = sqrt(us%L\_to\_Z * ((cs%gust\_const/cs%Rho0) + &
520               sqrt(0.5*(forces%tauy(i,j-1)*forces%tauy(i,j-1) + forces%tauy(i,j)*forces%tauy(i,j) + &
521                         forces%taux(i-1,j)*forces%taux(i-1,j) + forces%taux(i,j)*forces%taux(i,j)))/cs%Rho0
      ) )
522 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
523   \textcolor{keywordflow}{else}
524     i\_rho = us%L\_to\_Z / cs%Rho0
525     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
526       forces%ustar(i,j) = sqrt( (cs%gust\_const + &
527             sqrt(0.5*((forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2) + &
528                       (forces%taux(i-1,j)**2 + forces%taux(i,j)**2))) ) * i\_rho )
529 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
530 \textcolor{keywordflow}{  endif}
531 
532   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"wind\_forcing\_gyres"})
\end{DoxyCode}
