\hypertarget{namespaceuser__surface__forcing}{}\doxysection{user\+\_\+surface\+\_\+forcing Module Reference}
\label{namespaceuser__surface__forcing}\index{user\_surface\_forcing@{user\_surface\_forcing}}


\doxysubsection{Detailed Description}
Template for user to code up surface forcing. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\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}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\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 \mbox{\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 \mbox{\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}


\doxysubsection{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}}
\doxysubsubsection{\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(\mbox{\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{\texttt{ in,out}}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean. \\
\hline
\mbox{\texttt{ in,out}}  & {\em fluxes} & A structure containing thermodynamic forcing fields \\
\hline
\mbox{\texttt{ in}}  & {\em day} & The time of the fluxes \\
\hline
\mbox{\texttt{ in}}  & {\em dt} & The amount of time over which the fluxes apply \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
 & {\em cs} & A pointer to the control structure returned by a previous call to user\+\_\+surface\+\_\+forcing\+\_\+init \\
\hline
\end{DoxyParams}


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


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


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


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


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

\end{DoxyCode}
