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


\doxysubsection{Detailed Description}
Sets forcing for the M\+E\+SO configuration. 

Rewritten by Robert Hallberg, June 2009

This file contains the subroutines that a user should modify to to set the surface wind stresses and fluxes of buoyancy or temperature and fresh water. They are called when the run-\/time parameters W\+I\+N\+D\+\_\+\+C\+O\+N\+F\+IG or B\+U\+O\+Y\+\_\+\+C\+O\+N\+F\+IG are set to \char`\"{}\+U\+S\+E\+R\char`\"{}. The standard version has simple examples, along with run-\/time error messages that will cause the model to abort if this code has not been modified. This code is intended for use with relatively simple specifications of the forcing. For more complicated forms, it is probably a good idea to read the forcing from input files using \char`\"{}file\char`\"{} for W\+I\+N\+D\+\_\+\+C\+O\+N\+F\+IG and B\+U\+O\+Y\+\_\+\+C\+O\+N\+F\+IG.

M\+E\+S\+O\+\_\+buoyancy forcing is used to set the surface buoyancy forcing, which may include a number of fresh water flux fields (evap, liq\+\_\+precip, froz\+\_\+precip, liq\+\_\+runoff, froz\+\_\+runoff, and vprec) and the surface heat fluxes (sw, lw, latent and sens) if temperature and salinity are state variables, or it may simply be the buoyancy flux if it is not. This routine also has coded a restoring to surface values of temperature and salinity. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmeso__surface__forcing_1_1meso__surface__forcing__cs}{meso\+\_\+surface\+\_\+forcing\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em This control structure is used to store parameters associated with the M\+E\+SO forcing. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemeso__surface__forcing_a004a1769318285d7d7ab0c51de8b1d77}{meso\+\_\+buoyancy\+\_\+forcing}} (sfc\+\_\+state, fluxes, day, dt, G, US, CS)
\begin{DoxyCompactList}\small\item\em This subroutine sets up the M\+E\+SO buoyancy forcing, which uses control-\/theory style specification restorative buoyancy fluxes at large scales. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemeso__surface__forcing_aff6ab2bfc61d73084c623d1654f85046}{meso\+\_\+surface\+\_\+forcing\+\_\+init}} (Time, G, US, param\+\_\+file, diag, CS)
\begin{DoxyCompactList}\small\item\em Initialize the M\+E\+SO surface forcing module. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Variables}
\begin{DoxyCompactItemize}
\item 
\mbox{\Hypertarget{namespacemeso__surface__forcing_a2fc3c5390054b3d245f409a1ad34cea1}\label{namespacemeso__surface__forcing_a2fc3c5390054b3d245f409a1ad34cea1}} 
logical \mbox{\hyperlink{namespacemeso__surface__forcing_a2fc3c5390054b3d245f409a1ad34cea1}{first\+\_\+call}} = .true.
\begin{DoxyCompactList}\small\item\em True until after the first call to the M\+E\+SO forcing routines. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemeso__surface__forcing_a004a1769318285d7d7ab0c51de8b1d77}\label{namespacemeso__surface__forcing_a004a1769318285d7d7ab0c51de8b1d77}} 
\index{meso\_surface\_forcing@{meso\_surface\_forcing}!meso\_buoyancy\_forcing@{meso\_buoyancy\_forcing}}
\index{meso\_buoyancy\_forcing@{meso\_buoyancy\_forcing}!meso\_surface\_forcing@{meso\_surface\_forcing}}
\doxysubsubsection{\texorpdfstring{meso\_buoyancy\_forcing()}{meso\_buoyancy\_forcing()}}
{\footnotesize\ttfamily subroutine, public meso\+\_\+surface\+\_\+forcing\+::meso\+\_\+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{structmeso__surface__forcing_1_1meso__surface__forcing__cs}{meso\+\_\+surface\+\_\+forcing\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



This subroutine sets up the M\+E\+SO buoyancy forcing, which uses control-\/theory style specification restorative buoyancy fluxes at large scales. 


\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 M\+E\+S\+O\+\_\+surface\+\_\+forcing\+\_\+init \\
\hline
\end{DoxyParams}


Definition at line 59 of file M\+E\+S\+O\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{59   \textcolor{keywordtype}{type}(surface),                 \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{60 \textcolor{comment}{                                                    !! describe the surface state of the ocean.}}
\DoxyCodeLine{61   \textcolor{keywordtype}{type}(forcing),                 \textcolor{keywordtype}{intent(inout)} :: fluxes\textcolor{comment}{ !< A structure containing thermodynamic forcing fields}}
\DoxyCodeLine{62   \textcolor{keywordtype}{type}(time\_type),               \textcolor{keywordtype}{intent(in)}    :: day\textcolor{comment}{  !< The time of the fluxes}}
\DoxyCodeLine{63 \textcolor{keywordtype}{  real},                          \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{   !< The amount of time over which}}
\DoxyCodeLine{64 \textcolor{comment}{                                                       !! the fluxes apply [s]}}
\DoxyCodeLine{65   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{66   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{67   \textcolor{keywordtype}{type}(MESO\_surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer to the control structure returned by}}
\DoxyCodeLine{68 \textcolor{comment}{                                                       !! a previous call to MESO\_surface\_forcing\_init}}
\DoxyCodeLine{69 }
\DoxyCodeLine{70 \textcolor{comment}{!    When temperature is used, there are long list of fluxes that need to be}}
\DoxyCodeLine{71 \textcolor{comment}{!  set -\/ essentially the same as for a full coupled model, but most of these}}
\DoxyCodeLine{72 \textcolor{comment}{!  can be simply set to zero.  The net fresh water flux should probably be}}
\DoxyCodeLine{73 \textcolor{comment}{!  set in fluxes\%evap and fluxes\%lprec, with any salinity restoring}}
\DoxyCodeLine{74 \textcolor{comment}{!  appearing in fluxes\%vprec, and the other water flux components}}
\DoxyCodeLine{75 \textcolor{comment}{!  (fprec, lrunoff and frunoff) left as arrays full of zeros.}}
\DoxyCodeLine{76 \textcolor{comment}{!  Evap is usually negative and precip is usually positive.  All heat fluxes}}
\DoxyCodeLine{77 \textcolor{comment}{!  are in W m-\/2 and positive for heat going into the ocean.  All fresh water}}
\DoxyCodeLine{78 \textcolor{comment}{!  fluxes are in kg m-\/2 s-\/1 and positive for water moving into the ocean.}}
\DoxyCodeLine{79 }
\DoxyCodeLine{80 \textcolor{keywordtype}{  real} :: Temp\_restore   \textcolor{comment}{! The temperature that is being restored toward [degC].}}
\DoxyCodeLine{81 \textcolor{keywordtype}{  real} :: Salin\_restore  \textcolor{comment}{! The salinity that is being restored toward [ppt]}}
\DoxyCodeLine{82 \textcolor{keywordtype}{  real} :: density\_restore  \textcolor{comment}{! The potential density that is being restored toward [R \string~> kg m-\/3].}}
\DoxyCodeLine{83 \textcolor{keywordtype}{  real} :: rhoXcp \textcolor{comment}{! The mean density times the heat capacity [Q R degC-\/1 \string~> J m-\/3 degC-\/1].}}
\DoxyCodeLine{84 \textcolor{keywordtype}{  real} :: buoy\_rest\_const  \textcolor{comment}{! A constant relating density anomalies to the}}
\DoxyCodeLine{85                            \textcolor{comment}{! restoring buoyancy flux [L2 T-\/3 R-\/1 \string~> m5 s-\/3 kg-\/1].}}
\DoxyCodeLine{86 }
\DoxyCodeLine{87   \textcolor{keywordtype}{integer} :: i, j, is, ie, js, je}
\DoxyCodeLine{88   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{89 }
\DoxyCodeLine{90   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{91   isd = g\%isd ; ied = g\%ied ; jsd = g\%jsd ; jed = g\%jed}
\DoxyCodeLine{92 }
\DoxyCodeLine{93   \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}}
\DoxyCodeLine{94   \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}}
\DoxyCodeLine{95 }
\DoxyCodeLine{96   \textcolor{comment}{! Allocate and zero out the forcing arrays, as necessary.  This portion is}}
\DoxyCodeLine{97   \textcolor{comment}{! usually not changed.}}
\DoxyCodeLine{98   \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{99     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%evap, isd, ied, jsd, jed)}
\DoxyCodeLine{100     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%lprec, isd, ied, jsd, jed)}
\DoxyCodeLine{101     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%fprec, isd, ied, jsd, jed)}
\DoxyCodeLine{102     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%lrunoff, isd, ied, jsd, jed)}
\DoxyCodeLine{103     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%frunoff, isd, ied, jsd, jed)}
\DoxyCodeLine{104     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%vprec, isd, ied, jsd, jed)}
\DoxyCodeLine{105 }
\DoxyCodeLine{106     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%sw, isd, ied, jsd, jed)}
\DoxyCodeLine{107     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%lw, isd, ied, jsd, jed)}
\DoxyCodeLine{108     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%latent, isd, ied, jsd, jed)}
\DoxyCodeLine{109     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%sens, isd, ied, jsd, jed)}
\DoxyCodeLine{110     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%heat\_content\_lprec, isd, ied, jsd, jed)}
\DoxyCodeLine{111   \textcolor{keywordflow}{else} \textcolor{comment}{! This is the buoyancy only mode.}}
\DoxyCodeLine{112     \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%buoy, isd, ied, jsd, jed)}
\DoxyCodeLine{113 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{114 }
\DoxyCodeLine{115 }
\DoxyCodeLine{116   \textcolor{comment}{! MODIFY THE CODE IN THE FOLLOWING LOOPS TO SET THE BUOYANCY FORCING TERMS.}}
\DoxyCodeLine{117   \textcolor{keywordflow}{if} (cs\%restorebuoy .and. first\_call) \textcolor{keywordflow}{then} \textcolor{comment}{!\#CTRL\# .or. associated(CS\%ctrl\_forcing\_CSp)) then}}
\DoxyCodeLine{118     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%T\_Restore, isd, ied, jsd, jed)}
\DoxyCodeLine{119     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%S\_Restore, isd, ied, jsd, jed)}
\DoxyCodeLine{120     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%Heat, isd, ied, jsd, jed)}
\DoxyCodeLine{121     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%PmE, isd, ied, jsd, jed)}
\DoxyCodeLine{122     \textcolor{keyword}{call }safe\_alloc\_ptr(cs\%Solar, isd, ied, jsd, jed)}
\DoxyCodeLine{123 }
\DoxyCodeLine{124     \textcolor{keyword}{call }mom\_read\_data(trim(cs\%inputdir)//trim(cs\%SSTrestore\_file), \textcolor{stringliteral}{"SST"}, \&}
\DoxyCodeLine{125              cs\%T\_Restore(:,:), g\%Domain)}
\DoxyCodeLine{126     \textcolor{keyword}{call }mom\_read\_data(trim(cs\%inputdir)//trim(cs\%salinityrestore\_file), \textcolor{stringliteral}{"SAL"}, \&}
\DoxyCodeLine{127              cs\%S\_Restore(:,:), g\%Domain)}
\DoxyCodeLine{128     \textcolor{keyword}{call }mom\_read\_data(trim(cs\%inputdir)//trim(cs\%heating\_file), \textcolor{stringliteral}{"Heat"}, \&}
\DoxyCodeLine{129              cs\%Heat(:,:), g\%Domain, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{130     \textcolor{keyword}{call }mom\_read\_data(trim(cs\%inputdir)//trim(cs\%PmE\_file), \textcolor{stringliteral}{"PmE"}, \&}
\DoxyCodeLine{131              cs\%PmE(:,:), g\%Domain, scale=us\%m\_to\_Z*us\%T\_to\_s)}
\DoxyCodeLine{132     \textcolor{keyword}{call }mom\_read\_data(trim(cs\%inputdir)//trim(cs\%Solar\_file), \textcolor{stringliteral}{"NET\_SOL"}, \&}
\DoxyCodeLine{133              cs\%Solar(:,:), g\%Domain, scale=us\%W\_m2\_to\_QRZ\_T)}
\DoxyCodeLine{134     first\_call = .false.}
\DoxyCodeLine{135 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{136 }
\DoxyCodeLine{137   \textcolor{keywordflow}{if} ( cs\%use\_temperature ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{138     \textcolor{comment}{! Set whichever fluxes are to be used here.  Any fluxes that}}
\DoxyCodeLine{139     \textcolor{comment}{! are always zero do not need to be changed here.}}
\DoxyCodeLine{140     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{141       \textcolor{comment}{! Fluxes of fresh water through the surface are in units of [kg m-\/2 s-\/1]}}
\DoxyCodeLine{142       \textcolor{comment}{! and are positive downward -\/ i.e. evaporation should be negative.}}
\DoxyCodeLine{143       fluxes\%evap(i,j) = -\/0.0 * g\%mask2dT(i,j)}
\DoxyCodeLine{144       fluxes\%lprec(i,j) =  cs\%PmE(i,j) * cs\%Rho0 * g\%mask2dT(i,j)}
\DoxyCodeLine{145 }
\DoxyCodeLine{146       \textcolor{comment}{! vprec will be set later, if it is needed for salinity restoring.}}
\DoxyCodeLine{147       fluxes\%vprec(i,j) = 0.0}
\DoxyCodeLine{148 }
\DoxyCodeLine{149       \textcolor{comment}{!   Heat fluxes are in units of [Q R Z T-\/1 \string~> W m-\/2] and are positive into the ocean.}}
\DoxyCodeLine{150       fluxes\%lw(i,j)     = 0.0 * g\%mask2dT(i,j)}
\DoxyCodeLine{151       fluxes\%latent(i,j) = 0.0 * g\%mask2dT(i,j)}
\DoxyCodeLine{152       fluxes\%sens(i,j)   = cs\%Heat(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{153       fluxes\%sw(i,j)     = cs\%Solar(i,j) * g\%mask2dT(i,j)}
\DoxyCodeLine{154 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{155   \textcolor{keywordflow}{else} \textcolor{comment}{! This is the buoyancy only mode.}}
\DoxyCodeLine{156     \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{157       \textcolor{comment}{!   fluxes\%buoy is the buoyancy flux into the ocean [L2 T-\/3 \string~> m2 s-\/3].  A positive}}
\DoxyCodeLine{158       \textcolor{comment}{! buoyancy flux is of the same sign as heating the ocean.}}
\DoxyCodeLine{159       fluxes\%buoy(i,j) = 0.0 * g\%mask2dT(i,j)}
\DoxyCodeLine{160 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{161 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{162 }
\DoxyCodeLine{163   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{164     \textcolor{keywordflow}{if} (cs\%use\_temperature) \textcolor{keywordflow}{then}}
\DoxyCodeLine{165       \textcolor{keyword}{call }safe\_alloc\_ptr(fluxes\%heat\_added, isd, ied, jsd, jed)}
\DoxyCodeLine{166       \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}}
\DoxyCodeLine{167       \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}}
\DoxyCodeLine{168 \textcolor{comment}{!      call MOM\_error(FATAL, "MESO\_buoyancy\_surface\_forcing: " // \&}}
\DoxyCodeLine{169 \textcolor{comment}{!        "Temperature and salinity restoring used without modification." )}}
\DoxyCodeLine{170 }
\DoxyCodeLine{171       rhoxcp = cs\%Rho0 * fluxes\%C\_p}
\DoxyCodeLine{172       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{173         \textcolor{comment}{!   Set Temp\_restore and Salin\_restore to the temperature (in degC) and}}
\DoxyCodeLine{174         \textcolor{comment}{! salinity (in ppt or PSU) that are being restored toward.}}
\DoxyCodeLine{175         \textcolor{keywordflow}{if} (g\%mask2dT(i,j) > 0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{176           fluxes\%heat\_added(i,j) = g\%mask2dT(i,j) * \&}
\DoxyCodeLine{177               ((cs\%T\_Restore(i,j) -\/ sfc\_state\%SST(i,j)) * rhoxcp * cs\%Flux\_const)}
\DoxyCodeLine{178           fluxes\%vprec(i,j) = -\/ (cs\%Rho0 * cs\%Flux\_const) * \&}
\DoxyCodeLine{179               (cs\%S\_Restore(i,j) -\/ sfc\_state\%SSS(i,j)) / \&}
\DoxyCodeLine{180               (0.5*(sfc\_state\%SSS(i,j) + cs\%S\_Restore(i,j)))}
\DoxyCodeLine{181         \textcolor{keywordflow}{else}}
\DoxyCodeLine{182           fluxes\%heat\_added(i,j) = 0.0}
\DoxyCodeLine{183           fluxes\%vprec(i,j) = 0.0}
\DoxyCodeLine{184 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{185 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{186     \textcolor{keywordflow}{else}}
\DoxyCodeLine{187       \textcolor{comment}{!   When modifying the code, comment out this error message.  It is here}}
\DoxyCodeLine{188       \textcolor{comment}{! so that the original (unmodified) version is not accidentally used.}}
\DoxyCodeLine{189       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MESO\_buoyancy\_surface\_forcing: "} // \&}
\DoxyCodeLine{190         \textcolor{stringliteral}{"Buoyancy restoring used without modification."} )}
\DoxyCodeLine{191 }
\DoxyCodeLine{192       \textcolor{comment}{! The -\/1 is because density has the opposite sign to buoyancy.}}
\DoxyCodeLine{193       buoy\_rest\_const = -\/1.0 * (cs\%G\_Earth * cs\%Flux\_const) / cs\%Rho0}
\DoxyCodeLine{194       \textcolor{keywordflow}{do} j=js,je ; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{195        \textcolor{comment}{!   Set density\_restore to an expression for the surface potential}}
\DoxyCodeLine{196        \textcolor{comment}{! density [R \string~> kg m-\/3] that is being restored toward.}}
\DoxyCodeLine{197         density\_restore = 1030.0 * us\%kg\_m3\_to\_R}
\DoxyCodeLine{198 }
\DoxyCodeLine{199         fluxes\%buoy(i,j) = g\%mask2dT(i,j) * buoy\_rest\_const * \&}
\DoxyCodeLine{200                            (density\_restore -\/ sfc\_state\%sfc\_density(i,j))}
\DoxyCodeLine{201 \textcolor{keywordflow}{      enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{202 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{203 \textcolor{keywordflow}{  endif}                                             \textcolor{comment}{! end RESTOREBUOY}}
\DoxyCodeLine{204 }

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



Initialize the M\+E\+SO surface forcing module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
\mbox{\texttt{ in}}  & {\em g} & The ocean\textquotesingle{}s grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em us} & A dimensional unit scaling type \\
\hline
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters \\
\hline
\mbox{\texttt{ in,out}}  & {\em diag} & structure used to regulate diagnostic output \\
\hline
 & {\em cs} & A pointer that is set to point to the control structure for this module \\
\hline
\end{DoxyParams}


Definition at line 209 of file M\+E\+S\+O\+\_\+surface\+\_\+forcing.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{209 }
\DoxyCodeLine{210   \textcolor{keywordtype}{type}(time\_type),               \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{211   \textcolor{keywordtype}{type}(ocean\_grid\_type),         \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{212   \textcolor{keywordtype}{type}(unit\_scale\_type),         \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{213   \textcolor{keywordtype}{type}(param\_file\_type),         \textcolor{keywordtype}{intent(in)}    :: param\_file\textcolor{comment}{ !< A structure to parse for run-\/time parameters}}
\DoxyCodeLine{214   \textcolor{keywordtype}{type}(diag\_ctrl), \textcolor{keywordtype}{target},       \textcolor{keywordtype}{intent(inout)} :: diag\textcolor{comment}{ !< structure used to regulate diagnostic output}}
\DoxyCodeLine{215   \textcolor{keywordtype}{type}(MESO\_surface\_forcing\_CS), \textcolor{keywordtype}{pointer}       :: CS\textcolor{comment}{   !< A pointer that is set to point to the}}
\DoxyCodeLine{216 \textcolor{comment}{                                                       !! control structure for this module}}
\DoxyCodeLine{217 }
\DoxyCodeLine{218 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{219 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{220 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MESO\_surface\_forcing"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{221 }
\DoxyCodeLine{222   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{223     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MESO\_surface\_forcing\_init called with an associated "}// \&}
\DoxyCodeLine{224                              \textcolor{stringliteral}{"control structure."})}
\DoxyCodeLine{225     \textcolor{keywordflow}{return}}
\DoxyCodeLine{226 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{227   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{228   cs\%diag => diag}
\DoxyCodeLine{229 }
\DoxyCodeLine{230   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{231   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{232   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ENABLE\_THERMODYNAMICS"}, cs\%use\_temperature, \&}
\DoxyCodeLine{233                  \textcolor{stringliteral}{"If true, Temperature and salinity are used as state "}//\&}
\DoxyCodeLine{234                  \textcolor{stringliteral}{"variables."}, default=.true.)}
\DoxyCodeLine{235 }
\DoxyCodeLine{236   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, cs\%G\_Earth, \&}
\DoxyCodeLine{237                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, \&}
\DoxyCodeLine{238                  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{239   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, cs\%Rho0, \&}
\DoxyCodeLine{240                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//\&}
\DoxyCodeLine{241                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//\&}
\DoxyCodeLine{242                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//\&}
\DoxyCodeLine{243                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-\/2."}, \&}
\DoxyCodeLine{244                  units=\textcolor{stringliteral}{"kg m-\/3"}, default=1035.0, scale=us\%kg\_m3\_to\_R)}
\DoxyCodeLine{245   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"GUST\_CONST"}, cs\%gust\_const, \&}
\DoxyCodeLine{246                  \textcolor{stringliteral}{"The background gustiness in the winds."}, units=\textcolor{stringliteral}{"Pa"}, default=0.0)}
\DoxyCodeLine{247 }
\DoxyCodeLine{248   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTOREBUOY"}, cs\%restorebuoy, \&}
\DoxyCodeLine{249                  \textcolor{stringliteral}{"If true, the buoyancy fluxes drive the model back "}//\&}
\DoxyCodeLine{250                  \textcolor{stringliteral}{"toward some specified surface state with a rate "}//\&}
\DoxyCodeLine{251                  \textcolor{stringliteral}{"given by FLUXCONST."}, default= .false.)}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{keywordflow}{if} (cs\%restorebuoy) \textcolor{keywordflow}{then}}
\DoxyCodeLine{254     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"FLUXCONST"}, cs\%Flux\_const, \&}
\DoxyCodeLine{255                  \textcolor{stringliteral}{"The constant that relates the restoring surface fluxes to the relative "}//\&}
\DoxyCodeLine{256                  \textcolor{stringliteral}{"surface anomalies (akin to a piston velocity).  Note the non-\/MKS units."}, \&}
\DoxyCodeLine{257                  default=0.0, units=\textcolor{stringliteral}{"m day-\/1"}, scale=us\%m\_to\_Z/(86400.0*us\%s\_to\_T))}
\DoxyCodeLine{258 }
\DoxyCodeLine{259     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SSTRESTORE\_FILE"}, cs\%SSTrestore\_file, \&}
\DoxyCodeLine{260                  \textcolor{stringliteral}{"The file with the SST toward which to restore in "}//\&}
\DoxyCodeLine{261                  \textcolor{stringliteral}{"variable TEMP."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{262     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SALINITYRESTORE\_FILE"}, cs\%salinityrestore\_file, \&}
\DoxyCodeLine{263                  \textcolor{stringliteral}{"The file with the surface salinity toward which to "}//\&}
\DoxyCodeLine{264                  \textcolor{stringliteral}{"restore in variable SALT."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{265     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SENSIBLEHEAT\_FILE"}, cs\%heating\_file, \&}
\DoxyCodeLine{266                  \textcolor{stringliteral}{"The file with the non-\/shortwave heat flux in "}//\&}
\DoxyCodeLine{267                  \textcolor{stringliteral}{"variable Heat."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{268     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"PRECIP\_FILE"}, cs\%PmE\_file, \&}
\DoxyCodeLine{269                  \textcolor{stringliteral}{"The file with the net precipiation minus evaporation "}//\&}
\DoxyCodeLine{270                  \textcolor{stringliteral}{"in variable PmE."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{271     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SHORTWAVE\_FILE"}, cs\%Solar\_file, \&}
\DoxyCodeLine{272                  \textcolor{stringliteral}{"The file with the shortwave heat flux in "}//\&}
\DoxyCodeLine{273                  \textcolor{stringliteral}{"variable NET\_SOL."}, fail\_if\_missing=.true.)}
\DoxyCodeLine{274     \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"INPUTDIR"}, cs\%inputdir, default=\textcolor{stringliteral}{"."})}
\DoxyCodeLine{275     cs\%inputdir = slasher(cs\%inputdir)}
\DoxyCodeLine{276 }
\DoxyCodeLine{277 \textcolor{keywordflow}{   endif}}
\DoxyCodeLine{278 }

\end{DoxyCode}
