\hypertarget{namespaceuser__surface__forcing}{}\section{user\+\_\+surface\+\_\+forcing Module Reference}
\label{namespaceuser__surface__forcing}\index{user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}}


\subsection{Detailed Description}
Template for user to code up surface forcing. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \hyperlink{structuser__surface__forcing_1_1user__surface__forcing__cs}{user\+\_\+surface\+\_\+forcing\+\_\+cs}
\begin{DoxyCompactList}\small\item\em This control structure should be used to store any run-\/time variables associated with the user-\/specified forcing. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \hyperlink{namespaceuser__surface__forcing_ab7000fa60504156e2933a31ae55cc6d8}{user\+\_\+wind\+\_\+forcing} (sfc\+\_\+state, forces, day, G, US, CS)
\begin{DoxyCompactList}\small\item\em This subroutine sets the surface wind stresses, forcestaux and forcestauy, in \mbox{[}R Z L T-\/2 $\sim$$>$ Pa\mbox{]}. These are the stresses in the direction of the model grid (i.\+e. the same direction as the u-\/ and v-\/ velocities). \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceuser__surface__forcing_a44447e7ebe04c58d8f3af532600c9cfe}{user\+\_\+buoyancy\+\_\+forcing} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em This subroutine specifies the current surface fluxes of buoyancy or temperature and fresh water. It may also be modified to add surface fluxes of user provided tracers. \end{DoxyCompactList}\item 
subroutine, public \hyperlink{namespaceuser__surface__forcing_aa2b1be0da515f2b1f2fecc000e85af74}{user\+\_\+surface\+\_\+forcing\+\_\+init} (Time, G, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em This subroutine initializes the U\+S\+E\+R\+\_\+surface\+\_\+forcing module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceuser__surface__forcing_a44447e7ebe04c58d8f3af532600c9cfe}\label{namespaceuser__surface__forcing_a44447e7ebe04c58d8f3af532600c9cfe}} 
\index{user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}!user\+\_\+buoyancy\+\_\+forcing@{user\+\_\+buoyancy\+\_\+forcing}}
\index{user\+\_\+buoyancy\+\_\+forcing@{user\+\_\+buoyancy\+\_\+forcing}!user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}}
\subsubsection{\texorpdfstring{user\+\_\+buoyancy\+\_\+forcing()}{user\_buoyancy\_forcing()}}
{\footnotesize\ttfamily subroutine, public user\+\_\+surface\+\_\+forcing\+::user\+\_\+buoyancy\+\_\+forcing (\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{structuser__surface__forcing_1_1user__surface__forcing__cs}{user\+\_\+surface\+\_\+forcing\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine specifies the current surface fluxes of buoyancy or temperature and fresh water. It may also be modified to add surface fluxes of user provided tracers. 


\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} & A pointer to the control structure returned by a previous call to user\+\_\+surface\+\_\+forcing\+\_\+init \\
\hline
\end{DoxyParams}


Definition at line 103 of file user\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}
103   \textcolor{keywordtype}{type}(surface),                 \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
104 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
105   \textcolor{keywordtype}{type}(forcing),                 \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing
       fields}
106   \textcolor{keywordtype}{type}(time\_type),               \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
107   \textcolor{keywordtype}{real},                          \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}
108 \textcolor{comment}{                                                       !! the fluxes apply [s]}
109   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(in)}    :: g\textcolor{comment}{    !< The ocean's grid structure}
110   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
111   \textcolor{keywordtype}{type}(user\_surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< A pointer to the control structure returned}
112 \textcolor{comment}{                                                       !! by a previous call to user\_surface\_forcing\_init}
113 
114 \textcolor{comment}{!    This subroutine specifies the current surface fluxes of buoyancy or}
115 \textcolor{comment}{!  temperature and fresh water.  It may also be modified to add}
116 \textcolor{comment}{!  surface fluxes of user provided tracers.}
117 
118 \textcolor{comment}{!    When temperature is used, there are long list of fluxes that need to be}
119 \textcolor{comment}{!  set - essentially the same as for a full coupled model, but most of these}
120 \textcolor{comment}{!  can be simply set to zero.  The net fresh water flux should probably be}
121 \textcolor{comment}{!  set in fluxes%evap and fluxes%lprec, with any salinity restoring}
122 \textcolor{comment}{!  appearing in fluxes%vprec, and the other water flux components}
123 \textcolor{comment}{!  (fprec, lrunoff and frunoff) left as arrays full of zeros.}
124 \textcolor{comment}{!  Evap is usually negative and precip is usually positive.  All heat fluxes}
125 \textcolor{comment}{!  are in W m-2 and positive for heat going into the ocean.  All fresh water}
126 \textcolor{comment}{!  fluxes are in [R Z T-1 ~> kg m-2 s-1] and positive for water moving into the ocean.}
127 
128   \textcolor{comment}{! Local variables}
129   \textcolor{keywordtype}{real} :: temp\_restore   \textcolor{comment}{! The temperature that is being restored toward [degC].}
130   \textcolor{keywordtype}{real} :: salin\_restore  \textcolor{comment}{! The salinity that is being restored toward [ppt]}
131   \textcolor{keywordtype}{real} :: density\_restore  \textcolor{comment}{! The potential density that is being restored}
132                          \textcolor{comment}{! toward [R ~> kg m-3].}
133   \textcolor{keywordtype}{real} :: rhoxcp         \textcolor{comment}{! The mean density times the heat capacity [Q R degC-1 ~> J m-3 degC-1].}
134   \textcolor{keywordtype}{real} :: buoy\_rest\_const  \textcolor{comment}{! A constant relating density anomalies to the}
135                            \textcolor{comment}{! restoring buoyancy flux [L2 m3 T-3 kg-1 ~> m5 s-3 kg-1].}
136 
137   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je
138   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed
139 
140   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
141   isd = g%isd ; ied = g%ied ; jsd = g%jsd ; jed = g%jed
142 
143   \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}
144   \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}
145   \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"User\_buoyancy\_surface\_forcing: "} // &
146     \textcolor{stringliteral}{"User forcing routine called without modification."} )
147 
148   \textcolor{comment}{! Allocate and zero out the forcing arrays, as necessary.  This portion is}
149   \textcolor{comment}{! usually not changed.}
150   \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
151     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%evap, isd, ied, jsd, jed)
152     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%lprec, isd, ied, jsd, jed)
153     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%fprec, isd, ied, jsd, jed)
154     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%lrunoff, isd, ied, jsd, jed)
155     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%frunoff, isd, ied, jsd, jed)
156     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%vprec, isd, ied, jsd, jed)
157 
158     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%sw, isd, ied, jsd, jed)
159     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%lw, isd, ied, jsd, jed)
160     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%latent, isd, ied, jsd, jed)
161     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%sens, isd, ied, jsd, jed)
162   \textcolor{keywordflow}{else} \textcolor{comment}{! This is the buoyancy only mode.}
163     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%buoy, isd, ied, jsd, jed)
164 \textcolor{keywordflow}{  endif}
165 
166 
167   \textcolor{comment}{! MODIFY THE CODE IN THE FOLLOWING LOOPS TO SET THE BUOYANCY FORCING TERMS.}
168 
169   \textcolor{keywordflow}{if} ( cs%use\_temperature ) \textcolor{keywordflow}{then}
170     \textcolor{comment}{! Set whichever fluxes are to be used here.  Any fluxes that}
171     \textcolor{comment}{! are always zero do not need to be changed here.}
172     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
173       \textcolor{comment}{! Fluxes of fresh water through the surface are in units of [R Z T-1 ~> kg m-2 s-1]}
174       \textcolor{comment}{! and are positive downward - i.e. evaporation should be negative.}
175       fluxes%evap(i,j) = -0.0 * g%mask2dT(i,j)
176       fluxes%lprec(i,j) = 0.0 * g%mask2dT(i,j)
177 
178       \textcolor{comment}{! vprec will be set later, if it is needed for salinity restoring.}
179       fluxes%vprec(i,j) = 0.0
180 
181       \textcolor{comment}{!   Heat fluxes are in units of [Q R Z T-1 ~> W m-2] and are positive into the ocean.}
182       fluxes%lw(i,j) = 0.0 * g%mask2dT(i,j)
183       fluxes%latent(i,j) = 0.0 * g%mask2dT(i,j)
184       fluxes%sens(i,j) = 0.0 * g%mask2dT(i,j)
185       fluxes%sw(i,j) = 0.0 * g%mask2dT(i,j)
186 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
187   \textcolor{keywordflow}{else} \textcolor{comment}{! This is the buoyancy only mode.}
188     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
189       \textcolor{comment}{!   fluxes%buoy is the buoyancy flux into the ocean [L2 T-3 ~> m2 s-3].  A positive}
190       \textcolor{comment}{! buoyancy flux is of the same sign as heating the ocean.}
191       fluxes%buoy(i,j) = 0.0 * g%mask2dT(i,j)
192 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
193 \textcolor{keywordflow}{  endif}
194 
195   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
196     \textcolor{keywordflow}{if} (cs%use\_temperature) \textcolor{keywordflow}{then}
197       \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes%heat\_added, isd, ied, jsd, jed)
198       \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}
199       \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}
200       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"User\_buoyancy\_surface\_forcing: "} // &
201         \textcolor{stringliteral}{"Temperature and salinity restoring used without modification."} )
202 
203       rhoxcp = cs%Rho0 * fluxes%C\_p
204       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
205         \textcolor{comment}{!   Set Temp\_restore and Salin\_restore to the temperature (in degC) and}
206         \textcolor{comment}{! salinity (in PSU or ppt) that are being restored toward.}
207         temp\_restore = 0.0
208         salin\_restore = 0.0
209 
210         fluxes%heat\_added(i,j) = (g%mask2dT(i,j) * (rhoxcp * cs%Flux\_const)) * &
211             (temp\_restore - sfc\_state%SST(i,j))
212         fluxes%vprec(i,j) = - (g%mask2dT(i,j) * (cs%Rho0*cs%Flux\_const)) * &
213             ((salin\_restore - sfc\_state%SSS(i,j)) / (0.5 * (salin\_restore + sfc\_state%SSS(i,j))))
214 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
215     \textcolor{keywordflow}{else}
216       \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}
217       \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}
218       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"User\_buoyancy\_surface\_forcing: "} // &
219         \textcolor{stringliteral}{"Buoyancy restoring used without modification."} )
220 
221       \textcolor{comment}{! The -1 is because density has the opposite sign to buoyancy.}
222       buoy\_rest\_const = -1.0 * (cs%G\_Earth * cs%Flux\_const) / cs%Rho0
223       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
224        \textcolor{comment}{!   Set density\_restore to an expression for the surface potential}
225        \textcolor{comment}{! density [kg m-3] that is being restored toward.}
226         density\_restore = 1030.0*us%kg\_m3\_to\_R
227 
228         fluxes%buoy(i,j) = g%mask2dT(i,j) * buoy\_rest\_const * &
229                           (density\_restore - sfc\_state%sfc\_density(i,j))
230 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}
231 \textcolor{keywordflow}{    endif}
232 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}
233 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceuser__surface__forcing_aa2b1be0da515f2b1f2fecc000e85af74}\label{namespaceuser__surface__forcing_aa2b1be0da515f2b1f2fecc000e85af74}} 
\index{user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}!user\+\_\+surface\+\_\+forcing\+\_\+init@{user\+\_\+surface\+\_\+forcing\+\_\+init}}
\index{user\+\_\+surface\+\_\+forcing\+\_\+init@{user\+\_\+surface\+\_\+forcing\+\_\+init}!user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}}
\subsubsection{\texorpdfstring{user\+\_\+surface\+\_\+forcing\+\_\+init()}{user\_surface\_forcing\_init()}}
{\footnotesize\ttfamily subroutine, public user\+\_\+surface\+\_\+forcing\+::user\+\_\+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(in), target}]{diag,  }\item[{type(\hyperlink{structuser__surface__forcing_1_1user__surface__forcing__cs}{user\+\_\+surface\+\_\+forcing\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine initializes the U\+S\+E\+R\+\_\+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}  & {\em diag} & A structure that is used to regulate diagnostic output.\\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module \\
\hline
\end{DoxyParams}


Definition at line 238 of file user\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}
238   \textcolor{keywordtype}{type}(time\_type),               \textcolor{keywordtype}{intent(in)} :: time\textcolor{comment}{ !< The current model time}
239   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(in)} :: g\textcolor{comment}{    !< The ocean's grid structure}
240   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)} :: us\textcolor{comment}{   !< A dimensional unit scaling type}
241   \textcolor{keywordtype}{type}(param\_file\_type),         \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
242   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},       \textcolor{keywordtype}{intent(in)} :: diag\textcolor{comment}{ !< A structure that is used to regulate diagnostic
       output.}
243   \textcolor{keywordtype}{type}(user\_surface\_forcing\_cs), \textcolor{keywordtype}{pointer}    :: cs\textcolor{comment}{   !< A pointer that is set to point to}
244 \textcolor{comment}{                                                    !! the control structure for this module}
245 
246 \textcolor{comment}{! This include declares and sets the variable "version".}
247 \textcolor{preprocessor}{#include "version\_variable.h"}
248 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"user\_surface\_forcing"} \textcolor{comment}{! This module's name.}
249 
250   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}
251     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"USER\_surface\_forcing\_init called with an associated "}// &
252                              \textcolor{stringliteral}{"control structure."})
253     \textcolor{keywordflow}{return}
254 \textcolor{keywordflow}{  endif}
255   \textcolor{keyword}{allocate}(cs)
256   cs%diag => diag
257 
258   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
259   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
260   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, cs%use\_temperature, &
261                  \textcolor{stringliteral}{"If true, Temperature and salinity are used as state "}//&
262                  \textcolor{stringliteral}{"variables."}, default=.true.)
263 
264   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs%G\_Earth, &
265                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, &
266                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80, scale=us%m\_to\_L**2*us%Z\_to\_m*us%T\_to\_s**2)
267   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs%Rho0, &
268                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//&
269                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//&
270                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//&
271                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, &
272                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0, scale=us%kg\_m3\_to\_R)
273   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_CONST"}, cs%gust\_const, &
274                  \textcolor{stringliteral}{"The background gustiness in the winds."}, &
275                  units=\textcolor{stringliteral}{"Pa"}, default=0.0, scale=us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z)
276 
277   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTOREBUOY"}, cs%restorebuoy, &
278                  \textcolor{stringliteral}{"If true, the buoyancy fluxes drive the model back "}//&
279                  \textcolor{stringliteral}{"toward some specified surface state with a rate "}//&
280                  \textcolor{stringliteral}{"given by FLUXCONST."}, default= .false.)
281   \textcolor{keywordflow}{if} (cs%restorebuoy) \textcolor{keywordflow}{then}
282     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST"}, cs%Flux\_const, &
283                  \textcolor{stringliteral}{"The constant that relates the restoring surface fluxes to the relative "}//&
284                  \textcolor{stringliteral}{"surface anomalies (akin to a piston velocity).  Note the non-MKS units."}, &
285                  default=0.0, units=\textcolor{stringliteral}{"m day-1"}, scale=us%m\_to\_Z/(86400.0*us%s\_to\_T))
286 \textcolor{keywordflow}{  endif}
287 
\end{DoxyCode}
\mbox{\Hypertarget{namespaceuser__surface__forcing_ab7000fa60504156e2933a31ae55cc6d8}\label{namespaceuser__surface__forcing_ab7000fa60504156e2933a31ae55cc6d8}} 
\index{user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}!user\+\_\+wind\+\_\+forcing@{user\+\_\+wind\+\_\+forcing}}
\index{user\+\_\+wind\+\_\+forcing@{user\+\_\+wind\+\_\+forcing}!user\+\_\+surface\+\_\+forcing@{user\+\_\+surface\+\_\+forcing}}
\subsubsection{\texorpdfstring{user\+\_\+wind\+\_\+forcing()}{user\_wind\_forcing()}}
{\footnotesize\ttfamily subroutine, public user\+\_\+surface\+\_\+forcing\+::user\+\_\+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{structuser__surface__forcing_1_1user__surface__forcing__cs}{user\+\_\+surface\+\_\+forcing\+\_\+cs}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine sets the surface wind stresses, forcestaux and forcestauy, in \mbox{[}R Z L T-\/2 $\sim$$>$ Pa\mbox{]}. These are the stresses in the direction of the model grid (i.\+e. the same direction as the u-\/ and v-\/ velocities). 


\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} & A pointer to the control structure returned by a previous call to user\+\_\+surface\+\_\+forcing\+\_\+init \\
\hline
\end{DoxyParams}


Definition at line 52 of file user\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}
52   \textcolor{keywordtype}{type}(surface),                 \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
53 \textcolor{comment}{                                                       !! describe the surface state of the ocean.}
54   \textcolor{keywordtype}{type}(mech\_forcing),            \textcolor{keywordtype}{intent(inout)} :: forces\textcolor{comment}{ !< A structure with the driving mechanical forces}
55   \textcolor{keywordtype}{type}(time\_type),               \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}
56   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(inout)} :: g\textcolor{comment}{    !< The ocean's grid structure}
57   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)}    :: us\textcolor{comment}{   !< A dimensional unit scaling type}
58   \textcolor{keywordtype}{type}(user\_surface\_forcing\_cs), \textcolor{keywordtype}{pointer}       :: cs\textcolor{comment}{   !< A pointer to the control structure returned}
59 \textcolor{comment}{                                                       !! by a previous call to user\_surface\_forcing\_init}
60 
61   \textcolor{comment}{! Local variables}
62   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je, isq, ieq, jsq, jeq
63 
64   \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}
65   \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}
66   \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"User\_wind\_surface\_forcing: "} // &
67      \textcolor{stringliteral}{"User forcing routine called without modification."} )
68 
69   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
70   isq = g%IscB ; ieq = g%IecB ; jsq = g%JscB ; jeq = g%JecB
71 
72   \textcolor{comment}{! Allocate the forcing arrays, if necessary.}
73   \textcolor{keyword}{call }allocate\_mech\_forcing(g, forces, stress=.true., ustar=.true.)
74 
75   \textcolor{comment}{!  Set the surface wind stresses, in units of [R L Z T-1 ~> Pa].  A positive taux}
76   \textcolor{comment}{!  accelerates the ocean to the (pseudo-)east.}
77 
78   \textcolor{comment}{!  The i-loop extends to is-1 so that taux can be used later in the}
79   \textcolor{comment}{! calculation of ustar - otherwise the lower bound would be Isq.}
80   \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is-1,ieq
81     \textcolor{comment}{! Change this to the desired expression.}
82     forces%taux(i,j) = g%mask2dCu(i,j) * 0.0*us%kg\_m3\_to\_R*us%m\_s\_to\_L\_T**2*us%L\_to\_Z
83 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
84   \textcolor{keywordflow}{do} j=js-1,jeq ; \textcolor{keywordflow}{do} i=is,ie
85     forces%tauy(i,j) = g%mask2dCv(i,j) * 0.0  \textcolor{comment}{! Change this to the desired expression.}
86 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}
87 
88   \textcolor{comment}{!    Set the surface friction velocity, in units of [Z T-1 ~> m s-1].  ustar}
89   \textcolor{comment}{!  is always positive.}
90   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(forces%ustar)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie
91     \textcolor{comment}{!  This expression can be changed if desired, but need not be.}
92    forces%ustar(i,j) = g%mask2dT(i,j) * sqrt((cs%gust\_const + &
93             sqrt(0.5*(forces%taux(i-1,j)**2 + forces%taux(i,j)**2) + &
94                  0.5*(forces%tauy(i,j-1)**2 + forces%tauy(i,j)**2))) * (us%L\_to\_Z/cs%Rho0))
95 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo} ;\textcolor{keywordflow}{ endif}
96 
\end{DoxyCode}
