\hypertarget{namespaceocean__model__mod}{}\section{ocean\+\_\+model\+\_\+mod Module Reference}
\label{namespaceocean__model__mod}\index{ocean\_model\_mod@{ocean\_model\_mod}}


\subsection{Detailed Description}
Top-\/level module for the M\+O\+M6 ocean model in coupled mode. \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfaceocean__model__mod_1_1ocean__model__data__get}{ocean\+\_\+model\+\_\+data\+\_\+get}}
\begin{DoxyCompactList}\small\item\em This interface extracts a named scalar field or array from the ocean surface or public type. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}
\begin{DoxyCompactList}\small\item\em This type is used for communication with other components via the F\+MS coupler. The element names and types can be changed only with great deliberation, hence the persistnce of things like the cutsy element name \char`\"{}avg\+\_\+kount\char`\"{}. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}
\begin{DoxyCompactList}\small\item\em The \mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}} contains all information about the state of the ocean, with a format that is private so it can be readily changed without disrupting other coupled components. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a51ac9bb5e227e4a3f8be94a09a77eba8}{ocean\+\_\+model\+\_\+init}} (Ocean\+\_\+sfc, OS, Time\+\_\+init, Time\+\_\+in, wind\+\_\+stagger, gas\+\_\+fields\+\_\+ocn)
\begin{DoxyCompactList}\small\item\em ocean\+\_\+model\+\_\+init initializes the ocean model, including registering fields for restarts and reading restart files if appropriate. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a497d254b44f58fb797b9d75bc006eb60}{update\+\_\+ocean\+\_\+model}} (Ice\+\_\+ocean\+\_\+boundary, OS, Ocean\+\_\+sfc, time\+\_\+start\+\_\+update, Ocean\+\_\+coupling\+\_\+time\+\_\+step, update\+\_\+dyn, update\+\_\+thermo, Ocn\+\_\+fluxes\+\_\+used, start\+\_\+cycle, end\+\_\+cycle, cycle\+\_\+length)
\begin{DoxyCompactList}\small\item\em update\+\_\+ocean\+\_\+model uses the forcing in Ice\+\_\+ocean\+\_\+boundary to advance the ocean model\textquotesingle{}s state from the input value of Ocean\+\_\+state (which must be for time time\+\_\+start\+\_\+update) for a time interval of Ocean\+\_\+coupling\+\_\+time\+\_\+step, returning the publicly visible ocean surface properties in Ocean\+\_\+sfc and storing the new ocean properties in Ocean\+\_\+state. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a908a47d286b0257e91a253272926dc3d}{ocean\+\_\+model\+\_\+restart}} (OS, timestamp)
\begin{DoxyCompactList}\small\item\em This subroutine writes out the ocean model restart file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a276959acb69502491d4b3a5a83e596b8}{ocean\+\_\+model\+\_\+end}} (Ocean\+\_\+sfc, Ocean\+\_\+state, Time)
\begin{DoxyCompactList}\small\item\em ocean\+\_\+model\+\_\+end terminates the model run, saving the ocean state in a restart and deallocating any data associated with the ocean. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_ad969c968b1133584b9dcf48d78f51c01}{ocean\+\_\+model\+\_\+save\+\_\+restart}} (OS, Time, directory, filename\+\_\+suffix)
\begin{DoxyCompactList}\small\item\em ocean\+\_\+model\+\_\+save\+\_\+restart causes restart files associated with the ocean to be written out. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespaceocean__model__mod_a5b1bdaa3feed3ce185af828b84b9c55b}{initialize\+\_\+ocean\+\_\+public\+\_\+type}} (input\+\_\+domain, Ocean\+\_\+sfc, diag, maskmap, gas\+\_\+fields\+\_\+ocn)
\begin{DoxyCompactList}\small\item\em Initialize the public ocean type. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespaceocean__model__mod_acb78c6bf5eefda002e5e2dbd641e5a53}{convert\+\_\+state\+\_\+to\+\_\+ocean\+\_\+type}} (sfc\+\_\+state, Ocean\+\_\+sfc, G, US, patm, press\+\_\+to\+\_\+z)
\begin{DoxyCompactList}\small\item\em This subroutine translates the coupler\textquotesingle{}s ocean\+\_\+data\+\_\+type into M\+OM\textquotesingle{}s surface state variable. This may eventually be folded into the M\+OM code that calculates the surface state in the first place. Note the offset in the arrays because the ocean\+\_\+data\+\_\+type has no halo points in its arrays and always uses absolute indicies. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a2fca652469ca65c63305060534a14c0e}{ocean\+\_\+model\+\_\+init\+\_\+sfc}} (OS, Ocean\+\_\+sfc)
\begin{DoxyCompactList}\small\item\em This subroutine extracts the surface properties from the ocean\textquotesingle{}s internal state and stores them in the ocean type returned to the calling ice model. It has to be separate from the ocean\+\_\+initialization call because the coupler module allocates the space for some of these variables. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_ac5275bd24a712d97ec3ee094db73e885}{ocean\+\_\+model\+\_\+flux\+\_\+init}} (OS, verbosity)
\begin{DoxyCompactList}\small\item\em ocean\+\_\+model\+\_\+flux\+\_\+init is used to initialize properties of the air-\/sea fluxes as determined by various run-\/time parameters. It can be called from non-\/ocean P\+Es, or P\+Es that have not yet been initialzed, and it can safely be called multiple times. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a7ecaaa406a1cba3e9bcd84d375247ec5}{ocean\+\_\+stock\+\_\+pe}} (OS, index, value, time\+\_\+index)
\begin{DoxyCompactList}\small\item\em Ocean\+\_\+stock\+\_\+pe -\/ returns the integrated stocks of heat, water, etc. for conservation checks. Because of the way F\+MS is coded, only the root PE has the integrated amount, while all other P\+Es get 0. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespaceocean__model__mod_ab95b9373525518bee1776b7b9040b769}{ocean\+\_\+model\+\_\+data2d\+\_\+get}} (OS, Ocean, name, array2D, isc, jsc)
\begin{DoxyCompactList}\small\item\em This subroutine extracts a named 2-\/D field from the ocean surface or public type. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespaceocean__model__mod_a1ce15d13f4617f5f660164a7eb210f32}{ocean\+\_\+model\+\_\+data1d\+\_\+get}} (OS, Ocean, name, value)
\begin{DoxyCompactList}\small\item\em This subroutine extracts a named scalar field from the ocean surface or public type. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a3f7b5b40926d545a117274993924c9ee}{ocean\+\_\+public\+\_\+type\+\_\+chksum}} (id, timestep, ocn)
\begin{DoxyCompactList}\small\item\em Write out F\+M\+S-\/format checsums on fields from the ocean surface state. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a4279c231d36022ce0862a7316d4ef1d4}{get\+\_\+ocean\+\_\+grid}} (OS, Gridp)
\begin{DoxyCompactList}\small\item\em This subroutine gives a handle to the grid from ocean state. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespaceocean__model__mod_a87b816a55d210aafbf9d04b38fc49bfd}{ocean\+\_\+model\+\_\+get\+\_\+uv\+\_\+surf}} (OS, Ocean, name, array2D, isc, jsc)
\begin{DoxyCompactList}\small\item\em This subroutine extracts a named (u-\/ or v-\/) 2-\/D surface current from ocean internal state. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespaceocean__model__mod_acb78c6bf5eefda002e5e2dbd641e5a53}\label{namespaceocean__model__mod_acb78c6bf5eefda002e5e2dbd641e5a53}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!convert\_state\_to\_ocean\_type@{convert\_state\_to\_ocean\_type}}
\index{convert\_state\_to\_ocean\_type@{convert\_state\_to\_ocean\_type}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{convert\_state\_to\_ocean\_type()}{convert\_state\_to\_ocean\_type()}}
{\footnotesize\ttfamily subroutine ocean\+\_\+model\+\_\+mod\+::convert\+\_\+state\+\_\+to\+\_\+ocean\+\_\+type (\begin{DoxyParamCaption}\item[{type(surface), intent(inout)}]{sfc\+\_\+state,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout), target}]{Ocean\+\_\+sfc,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(inout)}]{G,  }\item[{type(unit\+\_\+scale\+\_\+type), intent(in)}]{US,  }\item[{real, dimension(\+:,\+:), intent(in), optional}]{patm,  }\item[{real, intent(in), optional}]{press\+\_\+to\+\_\+z }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This subroutine translates the coupler\textquotesingle{}s ocean\+\_\+data\+\_\+type into M\+OM\textquotesingle{}s surface state variable. This may eventually be folded into the M\+OM code that calculates the surface state in the first place. Note the offset in the arrays because the ocean\+\_\+data\+\_\+type has no halo points in its arrays and always uses absolute indicies. 


\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 ocean\+\_\+sfc} & A structure containing various publicly \\
\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
\mbox{\texttt{ in}}  & {\em patm} & The pressure at the ocean surface \mbox{[}Pa\mbox{]}. \\
\hline
\mbox{\texttt{ in}}  & {\em press\+\_\+to\+\_\+z} & A conversion factor between pressure and ocean depth in m, usually 1/(rho\+\_\+0$\ast$g) \mbox{[}m Pa-\/1\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 821 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{821   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}}
\DoxyCodeLine{822 \textcolor{comment}{                                               !! describe the surface state of the ocean.}}
\DoxyCodeLine{823   \textcolor{keywordtype}{type}(ocean\_public\_type), \&}
\DoxyCodeLine{824                  \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{825 \textcolor{comment}{                                               !! visible ocean surface fields, whose elements}}
\DoxyCodeLine{826 \textcolor{comment}{                                               !! have their data set here.}}
\DoxyCodeLine{827   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}}
\DoxyCodeLine{828   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}}
\DoxyCodeLine{829 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: patm(:,:)\textcolor{comment}{  !< The pressure at the ocean surface [Pa].}}
\DoxyCodeLine{830 \textcolor{keywordtype}{  real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: press\_to\_z\textcolor{comment}{ !< A conversion factor between pressure and}}
\DoxyCodeLine{831 \textcolor{comment}{                                               !! ocean depth in m, usually 1/(rho\_0*g) [m Pa-1].}}
\DoxyCodeLine{832   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{833 \textcolor{keywordtype}{  real} :: IgR0}
\DoxyCodeLine{834   \textcolor{keywordtype}{character(len=48)}  :: val\_str}
\DoxyCodeLine{835   \textcolor{keywordtype}{integer} :: isc\_bnd, iec\_bnd, jsc\_bnd, jec\_bnd}
\DoxyCodeLine{836   \textcolor{keywordtype}{integer} :: i, j, i0, j0, is, ie, js, je}
\DoxyCodeLine{837 }
\DoxyCodeLine{838   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{839   \textcolor{keyword}{call }pass\_vector(sfc\_state\%u, sfc\_state\%v, g\%Domain)}
\DoxyCodeLine{840 }
\DoxyCodeLine{841   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc\%Domain, isc\_bnd, iec\_bnd, \&}
\DoxyCodeLine{842                               jsc\_bnd, jec\_bnd)}
\DoxyCodeLine{843   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(patm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{844     \textcolor{comment}{! Check that the inidicies in patm are (isc\_bnd:iec\_bnd,jsc\_bnd:jec\_bnd).}}
\DoxyCodeLine{845     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{present}(press\_to\_z)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{846         \textcolor{stringliteral}{'convert\_state\_to\_ocean\_type: press\_to\_z must be present if patm is.'})}
\DoxyCodeLine{847 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{848 }
\DoxyCodeLine{849   i0 = is - isc\_bnd ; j0 = js - jsc\_bnd}
\DoxyCodeLine{850   \textcolor{keywordflow}{if} (sfc\_state\%T\_is\_conT) \textcolor{keywordflow}{then}}
\DoxyCodeLine{851     \textcolor{comment}{! Convert the surface T from conservative T to potential T.}}
\DoxyCodeLine{852     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{853       ocean\_sfc\%t\_surf(i,j) = gsw\_pt\_from\_ct(sfc\_state\%SSS(i+i0,j+j0), \&}
\DoxyCodeLine{854                                sfc\_state\%SST(i+i0,j+j0)) + celsius\_kelvin\_offset}
\DoxyCodeLine{855 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{856   \textcolor{keywordflow}{else}}
\DoxyCodeLine{857     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{858       ocean\_sfc\%t\_surf(i,j) = sfc\_state\%SST(i+i0,j+j0) + celsius\_kelvin\_offset}
\DoxyCodeLine{859 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{860 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{861   \textcolor{keywordflow}{if} (sfc\_state\%S\_is\_absS) \textcolor{keywordflow}{then}}
\DoxyCodeLine{862     \textcolor{comment}{! Convert the surface S from absolute salinity to practical salinity.}}
\DoxyCodeLine{863     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{864       ocean\_sfc\%s\_surf(i,j) = gsw\_sp\_from\_sr(sfc\_state\%SSS(i+i0,j+j0))}
\DoxyCodeLine{865 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{866   \textcolor{keywordflow}{else}}
\DoxyCodeLine{867     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{868       ocean\_sfc\%s\_surf(i,j) = sfc\_state\%SSS(i+i0,j+j0)}
\DoxyCodeLine{869 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{870 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{871 }
\DoxyCodeLine{872   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(patm)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{873     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{874       ocean\_sfc\%sea\_lev(i,j) = us\%Z\_to\_m * sfc\_state\%sea\_lev(i+i0,j+j0) + patm(i,j) * press\_to\_z}
\DoxyCodeLine{875       ocean\_sfc\%area(i,j) = us\%L\_to\_m**2 * g\%areaT(i+i0,j+j0)}
\DoxyCodeLine{876 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{877   \textcolor{keywordflow}{else}}
\DoxyCodeLine{878     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{879       ocean\_sfc\%sea\_lev(i,j) = us\%Z\_to\_m * sfc\_state\%sea\_lev(i+i0,j+j0)}
\DoxyCodeLine{880       ocean\_sfc\%area(i,j) = us\%L\_to\_m**2 * g\%areaT(i+i0,j+j0)}
\DoxyCodeLine{881 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{882 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{883 }
\DoxyCodeLine{884   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state\%frazil)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{885     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{886       ocean\_sfc\%frazil(i,j) = us\%Q\_to\_J\_kg*us\%RZ\_to\_kg\_m2 * sfc\_state\%frazil(i+i0,j+j0)}
\DoxyCodeLine{887 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{888 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{889 }
\DoxyCodeLine{890   \textcolor{keywordflow}{if} (ocean\_sfc\%stagger == agrid) \textcolor{keywordflow}{then}}
\DoxyCodeLine{891     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{892       ocean\_sfc\%u\_surf(i,j) = g\%mask2dT(i+i0,j+j0) * us\%L\_T\_to\_m\_s * \&}
\DoxyCodeLine{893                 0.5*(sfc\_state\%u(i+i0,j+j0)+sfc\_state\%u(i-1+i0,j+j0))}
\DoxyCodeLine{894       ocean\_sfc\%v\_surf(i,j) = g\%mask2dT(i+i0,j+j0) * us\%L\_T\_to\_m\_s * \&}
\DoxyCodeLine{895                 0.5*(sfc\_state\%v(i+i0,j+j0)+sfc\_state\%v(i+i0,j-1+j0))}
\DoxyCodeLine{896 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{897   \textcolor{keywordflow}{elseif} (ocean\_sfc\%stagger == bgrid\_ne) \textcolor{keywordflow}{then}}
\DoxyCodeLine{898     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{899       ocean\_sfc\%u\_surf(i,j) = g\%mask2dBu(i+i0,j+j0) * us\%L\_T\_to\_m\_s * \&}
\DoxyCodeLine{900                 0.5*(sfc\_state\%u(i+i0,j+j0)+sfc\_state\%u(i+i0,j+j0+1))}
\DoxyCodeLine{901       ocean\_sfc\%v\_surf(i,j) = g\%mask2dBu(i+i0,j+j0) * us\%L\_T\_to\_m\_s * \&}
\DoxyCodeLine{902                 0.5*(sfc\_state\%v(i+i0,j+j0)+sfc\_state\%v(i+i0+1,j+j0))}
\DoxyCodeLine{903 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{904   \textcolor{keywordflow}{elseif} (ocean\_sfc\%stagger == cgrid\_ne) \textcolor{keywordflow}{then}}
\DoxyCodeLine{905     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{906       ocean\_sfc\%u\_surf(i,j) = g\%mask2dCu(i+i0,j+j0)*us\%L\_T\_to\_m\_s * sfc\_state\%u(i+i0,j+j0)}
\DoxyCodeLine{907       ocean\_sfc\%v\_surf(i,j) = g\%mask2dCv(i+i0,j+j0)*us\%L\_T\_to\_m\_s * sfc\_state\%v(i+i0,j+j0)}
\DoxyCodeLine{908 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{909   \textcolor{keywordflow}{else}}
\DoxyCodeLine{910     \textcolor{keyword}{write}(val\_str, \textcolor{stringliteral}{'(I8)'}) ocean\_sfc\%stagger}
\DoxyCodeLine{911     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"convert\_state\_to\_ocean\_type: "}//\&}
\DoxyCodeLine{912       \textcolor{stringliteral}{"Ocean\_sfc\%stagger has the unrecognized value of "}//trim(val\_str))}
\DoxyCodeLine{913 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{914 }
\DoxyCodeLine{915   \textcolor{keywordflow}{if} (coupler\_type\_initialized(sfc\_state\%tr\_fields)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{916     \textcolor{keywordflow}{if} (.not.coupler\_type\_initialized(ocean\_sfc\%fields)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{917       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"convert\_state\_to\_ocean\_type: "}//\&}
\DoxyCodeLine{918                \textcolor{stringliteral}{"Ocean\_sfc\%fields has not been initialized."})}
\DoxyCodeLine{919 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{920     \textcolor{keyword}{call }coupler\_type\_copy\_data(sfc\_state\%tr\_fields, ocean\_sfc\%fields)}
\DoxyCodeLine{921 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{922 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a4279c231d36022ce0862a7316d4ef1d4}\label{namespaceocean__model__mod_a4279c231d36022ce0862a7316d4ef1d4}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!get\_ocean\_grid@{get\_ocean\_grid}}
\index{get\_ocean\_grid@{get\_ocean\_grid}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{get\_ocean\_grid()}{get\_ocean\_grid()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::get\+\_\+ocean\+\_\+grid (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}})}]{OS,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{Gridp }\end{DoxyParamCaption})}



This subroutine gives a handle to the grid from ocean state. 


\begin{DoxyParams}{Parameters}
{\em os} & A structure containing the internal ocean state \\
\hline
{\em gridp} & The ocean\textquotesingle{}s grid structure \\
\hline
\end{DoxyParams}


Definition at line 1120 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1120   \textcolor{comment}{! Obtain the ocean grid.}}
\DoxyCodeLine{1121   \textcolor{keywordtype}{type}(ocean\_state\_type) :: OS\textcolor{comment}{              !< A structure containing the}}
\DoxyCodeLine{1122 \textcolor{comment}{                                            !! internal ocean state}}
\DoxyCodeLine{1123   \textcolor{keywordtype}{type}(ocean\_grid\_type) , \textcolor{keywordtype}{pointer} :: Gridp\textcolor{comment}{  !< The ocean's grid structure}}
\DoxyCodeLine{1124 }
\DoxyCodeLine{1125   gridp => os\%grid}
\DoxyCodeLine{1126   \textcolor{keywordflow}{return}}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a5b1bdaa3feed3ce185af828b84b9c55b}\label{namespaceocean__model__mod_a5b1bdaa3feed3ce185af828b84b9c55b}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!initialize\_ocean\_public\_type@{initialize\_ocean\_public\_type}}
\index{initialize\_ocean\_public\_type@{initialize\_ocean\_public\_type}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{initialize\_ocean\_public\_type()}{initialize\_ocean\_public\_type()}}
{\footnotesize\ttfamily subroutine ocean\+\_\+model\+\_\+mod\+::initialize\+\_\+ocean\+\_\+public\+\_\+type (\begin{DoxyParamCaption}\item[{type(domain2d), intent(in)}]{input\+\_\+domain,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout)}]{Ocean\+\_\+sfc,  }\item[{type(diag\+\_\+ctrl), intent(in)}]{diag,  }\item[{logical, dimension(\+:,\+:), intent(in), optional}]{maskmap,  }\item[{type(coupler\+\_\+1d\+\_\+bc\+\_\+type), intent(in), optional}]{gas\+\_\+fields\+\_\+ocn }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initialize the public ocean type. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em input\+\_\+domain} & The ocean model domain description \\
\hline
\mbox{\texttt{ in,out}}  & {\em ocean\+\_\+sfc} & A structure containing various publicly visible ocean surface properties after initialization, whose elements are allocated here. \\
\hline
\mbox{\texttt{ in}}  & {\em diag} & A structure that regulates diagnsotic output \\
\hline
\mbox{\texttt{ in}}  & {\em maskmap} & A mask indicating which virtual processors \\
\hline
\mbox{\texttt{ in}}  & {\em gas\+\_\+fields\+\_\+ocn} & If present, this type describes the \\
\hline
\end{DoxyParams}


Definition at line 763 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{763   \textcolor{keywordtype}{type}(domain2D),          \textcolor{keywordtype}{intent(in)}    :: input\_domain\textcolor{comment}{ !< The ocean model domain description}}
\DoxyCodeLine{764   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{765 \textcolor{comment}{                                !! visible ocean surface properties after initialization, whose}}
\DoxyCodeLine{766 \textcolor{comment}{                                !! elements are allocated here.}}
\DoxyCodeLine{767   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(in)}    :: diag\textcolor{comment}{  !< A structure that regulates diagnsotic output}}
\DoxyCodeLine{768   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:,:)}, \&}
\DoxyCodeLine{769                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: maskmap\textcolor{comment}{ !< A mask indicating which virtual processors}}
\DoxyCodeLine{770 \textcolor{comment}{                                              !! are actually in use.  If missing, all are used.}}
\DoxyCodeLine{771   \textcolor{keywordtype}{type}(coupler\_1d\_bc\_type), \&}
\DoxyCodeLine{772                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: gas\_fields\_ocn\textcolor{comment}{ !< If present, this type describes the}}
\DoxyCodeLine{773 \textcolor{comment}{                                              !! ocean and surface-ice fields that will participate}}
\DoxyCodeLine{774 \textcolor{comment}{                                              !! in the calculation of additional gas or other}}
\DoxyCodeLine{775 \textcolor{comment}{                                              !! tracer fluxes.}}
\DoxyCodeLine{776 }
\DoxyCodeLine{777   \textcolor{keywordtype}{integer} :: xsz, ysz, layout(2)}
\DoxyCodeLine{778   \textcolor{comment}{! ice-ocean-boundary fields are always allocated using absolute indicies}}
\DoxyCodeLine{779   \textcolor{comment}{! and have no halos.}}
\DoxyCodeLine{780   \textcolor{keywordtype}{integer} :: isc, iec, jsc, jec}
\DoxyCodeLine{781 }
\DoxyCodeLine{782   \textcolor{keyword}{call }mpp\_get\_layout(input\_domain,layout)}
\DoxyCodeLine{783   \textcolor{keyword}{call }mpp\_get\_global\_domain(input\_domain, xsize=xsz, ysize=ysz)}
\DoxyCodeLine{784   \textcolor{keywordflow}{if} (\textcolor{keyword}{PRESENT}(maskmap)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{785      \textcolor{keyword}{call }mpp\_define\_domains((/1,xsz,1,ysz/),layout,ocean\_sfc\%Domain, maskmap=maskmap)}
\DoxyCodeLine{786   \textcolor{keywordflow}{else}}
\DoxyCodeLine{787      \textcolor{keyword}{call }mpp\_define\_domains((/1,xsz,1,ysz/),layout,ocean\_sfc\%Domain)}
\DoxyCodeLine{788 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{789   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc\%Domain, isc, iec, jsc, jec)}
\DoxyCodeLine{790 }
\DoxyCodeLine{791   \textcolor{keyword}{allocate} ( ocean\_sfc\%t\_surf (isc:iec,jsc:jec), \&}
\DoxyCodeLine{792              ocean\_sfc\%s\_surf (isc:iec,jsc:jec), \&}
\DoxyCodeLine{793              ocean\_sfc\%u\_surf (isc:iec,jsc:jec), \&}
\DoxyCodeLine{794              ocean\_sfc\%v\_surf (isc:iec,jsc:jec), \&}
\DoxyCodeLine{795              ocean\_sfc\%sea\_lev(isc:iec,jsc:jec), \&}
\DoxyCodeLine{796              ocean\_sfc\%area   (isc:iec,jsc:jec), \&}
\DoxyCodeLine{797              ocean\_sfc\%frazil (isc:iec,jsc:jec))}
\DoxyCodeLine{798 }
\DoxyCodeLine{799   ocean\_sfc\%t\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged sst (Kelvin) passed to atmosphere/ice model}}
\DoxyCodeLine{800   ocean\_sfc\%s\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged sss (psu) passed to atmosphere/ice models}}
\DoxyCodeLine{801   ocean\_sfc\%u\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged u-current (m/sec) passed to atmosphere/ice models}}
\DoxyCodeLine{802   ocean\_sfc\%v\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged v-current (m/sec)  passed to atmosphere/ice models}}
\DoxyCodeLine{803   ocean\_sfc\%sea\_lev(:,:) = 0.0  \textcolor{comment}{! time averaged thickness of top model grid cell (m) plus patm/rho0/grav}}
\DoxyCodeLine{804   ocean\_sfc\%frazil(:,:)  = 0.0  \textcolor{comment}{! time accumulated frazil (J/m\string^2) passed to ice model}}
\DoxyCodeLine{805   ocean\_sfc\%area(:,:)    = 0.0}
\DoxyCodeLine{806   ocean\_sfc\%axes    = diag\%axesT1\%handles \textcolor{comment}{!diag axes to be used by coupler tracer flux diagnostics}}
\DoxyCodeLine{807 }
\DoxyCodeLine{808   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(gas\_fields\_ocn)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{809     \textcolor{keyword}{call }coupler\_type\_spawn(gas\_fields\_ocn, ocean\_sfc\%fields, (/isc,isc,iec,iec/), \&}
\DoxyCodeLine{810                               (/jsc,jsc,jec,jec/), suffix = \textcolor{stringliteral}{'\_ocn'}, as\_needed=.true.)}
\DoxyCodeLine{811 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{812 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a1ce15d13f4617f5f660164a7eb210f32}\label{namespaceocean__model__mod_a1ce15d13f4617f5f660164a7eb210f32}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_data1d\_get@{ocean\_model\_data1d\_get}}
\index{ocean\_model\_data1d\_get@{ocean\_model\_data1d\_get}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_data1d\_get()}{ocean\_model\_data1d\_get()}}
{\footnotesize\ttfamily subroutine ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+data1d\+\_\+get (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(in)}]{Ocean,  }\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{real, intent(out)}]{value }\end{DoxyParamCaption})}



This subroutine extracts a named scalar field from the ocean surface or public type. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A pointer to the structure containing the internal ocean state (intent in). \\
\hline
\mbox{\texttt{ in}}  & {\em ocean} & A structure containing various publicly visible ocean surface fields. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & The name of the field to extract \\
\hline
\mbox{\texttt{ out}}  & {\em value} & The value of the named field \\
\hline
\end{DoxyParams}


Definition at line 1075 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1075   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}}
\DoxyCodeLine{1076 \textcolor{comment}{                                                  !! internal ocean state (intent in).}}
\DoxyCodeLine{1077   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{1078 \textcolor{comment}{                                                  !! visible ocean surface fields.}}
\DoxyCodeLine{1079   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the field to extract}}
\DoxyCodeLine{1080 \textcolor{keywordtype}{  real}                      , \textcolor{keywordtype}{intent(out)}:: \textcolor{keywordtype}{value}\textcolor{comment}{ !< The value of the named field}}
\DoxyCodeLine{1081 }
\DoxyCodeLine{1082   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1083   \textcolor{keywordflow}{if} (.not.os\%is\_ocean\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1084 }
\DoxyCodeLine{1085   \textcolor{keywordflow}{select case}(name)}
\DoxyCodeLine{1086   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'c\_p'})}
\DoxyCodeLine{1087     \textcolor{keywordtype}{value} = os\%C\_p}
\DoxyCodeLine{1088 \textcolor{keywordflow}{  case default}}
\DoxyCodeLine{1089     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'get\_ocean\_grid\_data1D: unknown argument name='}//name)}
\DoxyCodeLine{1090 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1091 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_ab95b9373525518bee1776b7b9040b769}\label{namespaceocean__model__mod_ab95b9373525518bee1776b7b9040b769}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_data2d\_get@{ocean\_model\_data2d\_get}}
\index{ocean\_model\_data2d\_get@{ocean\_model\_data2d\_get}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_data2d\_get()}{ocean\_model\_data2d\_get()}}
{\footnotesize\ttfamily subroutine ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+data2d\+\_\+get (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(in)}]{Ocean,  }\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{real, dimension(isc\+:,jsc\+:), intent(out)}]{array2D,  }\item[{integer, intent(in)}]{isc,  }\item[{integer, intent(in)}]{jsc }\end{DoxyParamCaption})}



This subroutine extracts a named 2-\/D field from the ocean surface or public type. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A pointer to the structure containing the internal ocean state (intent in). \\
\hline
\mbox{\texttt{ in}}  & {\em ocean} & A structure containing various publicly visible ocean surface fields. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & The name of the field to extract \\
\hline
\mbox{\texttt{ out}}  & {\em array2d} & The values of the named field, it must cover only the computational domain \\
\hline
\mbox{\texttt{ in}}  & {\em isc} & The starting i-\/index of array2D \\
\hline
\mbox{\texttt{ in}}  & {\em jsc} & The starting j-\/index of array2D \\
\hline
\end{DoxyParams}


Definition at line 1013 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1013   \textcolor{keywordtype}{use }\mbox{\hyperlink{namespacemom__constants}{mom\_constants}}, \textcolor{keywordtype}{only} : celsius\_kelvin\_offset}
\DoxyCodeLine{1014   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}}
\DoxyCodeLine{1015 \textcolor{comment}{                                                  !! internal ocean state (intent in).}}
\DoxyCodeLine{1016   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{1017 \textcolor{comment}{                                                  !! visible ocean surface fields.}}
\DoxyCodeLine{1018   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the field to extract}}
\DoxyCodeLine{1019 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(isc:,jsc:)}, \textcolor{keywordtype}{intent(out)}:: array2D\textcolor{comment}{ !< The values of the named field, it must}}
\DoxyCodeLine{1020 \textcolor{comment}{                                                  !! cover only the computational domain}}
\DoxyCodeLine{1021   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: isc\textcolor{comment}{   !< The starting i-index of array2D}}
\DoxyCodeLine{1022   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: jsc\textcolor{comment}{   !< The starting j-index of array2D}}
\DoxyCodeLine{1023 }
\DoxyCodeLine{1024   \textcolor{keywordtype}{integer} :: g\_isc, g\_iec, g\_jsc, g\_jec,g\_isd, g\_ied, g\_jsd, g\_jed, i, j}
\DoxyCodeLine{1025 }
\DoxyCodeLine{1026   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1027   \textcolor{keywordflow}{if} (.not.os\%is\_ocean\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1028 }
\DoxyCodeLine{1029 \textcolor{comment}{! The problem is \%areaT is on MOM domain but Ice\_Ocean\_Boundary\%... is on mpp domain.}}
\DoxyCodeLine{1030 \textcolor{comment}{! We want to return the MOM data on the mpp (compute) domain}}
\DoxyCodeLine{1031 \textcolor{comment}{! Get MOM domain extents}}
\DoxyCodeLine{1032   \textcolor{keyword}{call }mpp\_get\_compute\_domain(os\%grid\%Domain\%mpp\_domain, g\_isc, g\_iec, g\_jsc, g\_jec)}
\DoxyCodeLine{1033   \textcolor{keyword}{call }mpp\_get\_data\_domain   (os\%grid\%Domain\%mpp\_domain, g\_isd, g\_ied, g\_jsd, g\_jed)}
\DoxyCodeLine{1034 }
\DoxyCodeLine{1035   g\_isc = g\_isc-g\_isd+1 ; g\_iec = g\_iec-g\_isd+1 ; g\_jsc = g\_jsc-g\_jsd+1 ; g\_jec = g\_jec-g\_jsd+1}
\DoxyCodeLine{1036 }
\DoxyCodeLine{1037 }
\DoxyCodeLine{1038   \textcolor{keywordflow}{select case}(name)}
\DoxyCodeLine{1039   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'area'})}
\DoxyCodeLine{1040      array2d(isc:,jsc:) = os\%US\%L\_to\_m**2*os\%grid\%areaT(g\_isc:g\_iec,g\_jsc:g\_jec)}
\DoxyCodeLine{1041   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'mask'})}
\DoxyCodeLine{1042      array2d(isc:,jsc:) = os\%grid\%mask2dT(g\_isc:g\_iec,g\_jsc:g\_jec)}
\DoxyCodeLine{1043 \textcolor{comment}{!OR same result}}
\DoxyCodeLine{1044 \textcolor{comment}{!     do j=g\_jsc,g\_jec ; do i=g\_isc,g\_iec}}
\DoxyCodeLine{1045 \textcolor{comment}{!        array2D(isc+i-g\_isc,jsc+j-g\_jsc) = OS\%grid\%mask2dT(i,j)}}
\DoxyCodeLine{1046 \textcolor{comment}{!     enddo ; enddo}}
\DoxyCodeLine{1047   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_surf'})}
\DoxyCodeLine{1048      array2d(isc:,jsc:) = ocean\%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset}
\DoxyCodeLine{1049   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_pme'})}
\DoxyCodeLine{1050      array2d(isc:,jsc:) = ocean\%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset}
\DoxyCodeLine{1051   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_runoff'})}
\DoxyCodeLine{1052      array2d(isc:,jsc:) = ocean\%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset}
\DoxyCodeLine{1053   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_calving'})}
\DoxyCodeLine{1054      array2d(isc:,jsc:) = ocean\%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset}
\DoxyCodeLine{1055   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'btfHeat'})}
\DoxyCodeLine{1056      array2d(isc:,jsc:) = 0}
\DoxyCodeLine{1057   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'cos\_rot'})}
\DoxyCodeLine{1058      array2d(isc:,jsc:) = os\%grid\%cos\_rot(g\_isc:g\_iec,g\_jsc:g\_jec) \textcolor{comment}{! =1}}
\DoxyCodeLine{1059   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'sin\_rot'})}
\DoxyCodeLine{1060      array2d(isc:,jsc:) = os\%grid\%sin\_rot(g\_isc:g\_iec,g\_jsc:g\_jec) \textcolor{comment}{! =0}}
\DoxyCodeLine{1061   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'s\_surf'})}
\DoxyCodeLine{1062      array2d(isc:,jsc:) = ocean\%s\_surf(isc:,jsc:)}
\DoxyCodeLine{1063   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'sea\_lev'})}
\DoxyCodeLine{1064      array2d(isc:,jsc:) = ocean\%sea\_lev(isc:,jsc:)}
\DoxyCodeLine{1065   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'frazil'})}
\DoxyCodeLine{1066      array2d(isc:,jsc:) = ocean\%frazil(isc:,jsc:)}
\DoxyCodeLine{1067 \textcolor{keywordflow}{  case default}}
\DoxyCodeLine{1068      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'get\_ocean\_grid\_data2D: unknown argument name='}//name)}
\DoxyCodeLine{1069 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1070 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a276959acb69502491d4b3a5a83e596b8}\label{namespaceocean__model__mod_a276959acb69502491d4b3a5a83e596b8}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_end@{ocean\_model\_end}}
\index{ocean\_model\_end@{ocean\_model\_end}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_end()}{ocean\_model\_end()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout)}]{Ocean\+\_\+sfc,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{Ocean\+\_\+state,  }\item[{type(time\+\_\+type), intent(in)}]{Time }\end{DoxyParamCaption})}



ocean\+\_\+model\+\_\+end terminates the model run, saving the ocean state in a restart and deallocating any data associated with the ocean. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em ocean\+\_\+sfc} & An \mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}} structure that is to be deallocated upon termination. \\
\hline
 & {\em ocean\+\_\+state} & A pointer to the structure containing the internal ocean state to be deallocated upon termination. \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The model time, used for writing restarts. \\
\hline
\end{DoxyParams}


Definition at line 711 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{711   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{   !< An ocean\_public\_type structure that is}}
\DoxyCodeLine{712 \textcolor{comment}{                                                        !! to be deallocated upon termination.}}
\DoxyCodeLine{713   \textcolor{keywordtype}{type}(ocean\_state\_type),  \textcolor{keywordtype}{pointer}       :: Ocean\_state\textcolor{comment}{ !< A pointer to the structure containing}}
\DoxyCodeLine{714 \textcolor{comment}{                                                        !! the internal ocean state to be deallocated}}
\DoxyCodeLine{715 \textcolor{comment}{                                                        !! upon termination.}}
\DoxyCodeLine{716   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{        !< The model time, used for writing restarts.}}
\DoxyCodeLine{717 }
\DoxyCodeLine{718   \textcolor{keyword}{call }ocean\_model\_save\_restart(ocean\_state, time)}
\DoxyCodeLine{719   \textcolor{keyword}{call }diag\_mediator\_end(time, ocean\_state\%diag)}
\DoxyCodeLine{720   \textcolor{keyword}{call }mom\_end(ocean\_state\%MOM\_CSp)}
\DoxyCodeLine{721   \textcolor{keywordflow}{if} (ocean\_state\%use\_ice\_shelf) \textcolor{keyword}{call }ice\_shelf\_end(ocean\_state\%Ice\_shelf\_CSp)}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_ac5275bd24a712d97ec3ee094db73e885}\label{namespaceocean__model__mod_ac5275bd24a712d97ec3ee094db73e885}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_flux\_init@{ocean\_model\_flux\_init}}
\index{ocean\_model\_flux\_init@{ocean\_model\_flux\_init}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_flux\_init()}{ocean\_model\_flux\_init()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+flux\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), optional, pointer}]{OS,  }\item[{integer, intent(in), optional}]{verbosity }\end{DoxyParamCaption})}



ocean\+\_\+model\+\_\+flux\+\_\+init is used to initialize properties of the air-\/sea fluxes as determined by various run-\/time parameters. It can be called from non-\/ocean P\+Es, or P\+Es that have not yet been initialzed, and it can safely be called multiple times. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & An optional pointer to the ocean state, used to figure out if this is an ocean PE that has already been initialized. \\
\hline
\mbox{\texttt{ in}}  & {\em verbosity} & A 0-\/9 integer indicating a level of verbosity. \\
\hline
\end{DoxyParams}


Definition at line 951 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{951   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer} :: OS\textcolor{comment}{  !< An optional pointer to the ocean state,}}
\DoxyCodeLine{952 \textcolor{comment}{                                             !! used to figure out if this is an ocean PE that}}
\DoxyCodeLine{953 \textcolor{comment}{                                             !! has already been initialized.}}
\DoxyCodeLine{954   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbosity\textcolor{comment}{ !< A 0-9 integer indicating a level of verbosity.}}
\DoxyCodeLine{955 }
\DoxyCodeLine{956   \textcolor{keywordtype}{logical} :: OS\_is\_set}
\DoxyCodeLine{957   \textcolor{keywordtype}{integer} :: verbose}
\DoxyCodeLine{958 }
\DoxyCodeLine{959   os\_is\_set = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(os)) os\_is\_set = \textcolor{keyword}{associated}(os)}
\DoxyCodeLine{960 }
\DoxyCodeLine{961   \textcolor{comment}{! Use this to control the verbosity of output; consider rethinking this logic later.}}
\DoxyCodeLine{962   verbose = 5 ; \textcolor{keywordflow}{if} (os\_is\_set) verbose = 3}
\DoxyCodeLine{963   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(verbosity)) verbose = verbosity}
\DoxyCodeLine{964 }
\DoxyCodeLine{965   \textcolor{keyword}{call }call\_tracer\_flux\_init(verbosity=verbose)}
\DoxyCodeLine{966 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a87b816a55d210aafbf9d04b38fc49bfd}\label{namespaceocean__model__mod_a87b816a55d210aafbf9d04b38fc49bfd}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_get\_uv\_surf@{ocean\_model\_get\_uv\_surf}}
\index{ocean\_model\_get\_uv\_surf@{ocean\_model\_get\_uv\_surf}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_get\_uv\_surf()}{ocean\_model\_get\_uv\_surf()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+get\+\_\+uv\+\_\+surf (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(in)}]{Ocean,  }\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{real, dimension(isc\+:,jsc\+:), intent(out)}]{array2D,  }\item[{integer, intent(in)}]{isc,  }\item[{integer, intent(in)}]{jsc }\end{DoxyParamCaption})}



This subroutine extracts a named (u-\/ or v-\/) 2-\/D surface current from ocean internal state. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A pointer to the structure containing the internal ocean state (intent in). \\
\hline
\mbox{\texttt{ in}}  & {\em ocean} & A structure containing various publicly visible ocean surface fields. \\
\hline
\mbox{\texttt{ in}}  & {\em name} & The name of the current (ua or va) to extract \\
\hline
\mbox{\texttt{ out}}  & {\em array2d} & The values of the named field, it must cover only the computational domain \\
\hline
\mbox{\texttt{ in}}  & {\em isc} & The starting i-\/index of array2D \\
\hline
\mbox{\texttt{ in}}  & {\em jsc} & The starting j-\/index of array2D \\
\hline
\end{DoxyParams}


Definition at line 1131 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1131 }
\DoxyCodeLine{1132   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}}
\DoxyCodeLine{1133 \textcolor{comment}{                                                  !! internal ocean state (intent in).}}
\DoxyCodeLine{1134   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{1135 \textcolor{comment}{                                                  !! visible ocean surface fields.}}
\DoxyCodeLine{1136   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the current (ua or va) to extract}}
\DoxyCodeLine{1137 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(isc:,jsc:)}, \textcolor{keywordtype}{intent(out)}:: array2D\textcolor{comment}{ !< The values of the named field, it must}}
\DoxyCodeLine{1138 \textcolor{comment}{                                                  !! cover only the computational domain}}
\DoxyCodeLine{1139   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: isc\textcolor{comment}{   !< The starting i-index of array2D}}
\DoxyCodeLine{1140   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: jsc\textcolor{comment}{   !< The starting j-index of array2D}}
\DoxyCodeLine{1141 }
\DoxyCodeLine{1142   \textcolor{keywordtype}{type}(ocean\_grid\_type) , \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{            !< The ocean's grid structure}}
\DoxyCodeLine{1143   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{pointer} :: sfc\_state\textcolor{comment}{    !< A structure containing fields that}}
\DoxyCodeLine{1144 \textcolor{comment}{                                                  !! describe the surface state of the ocean.}}
\DoxyCodeLine{1145 }
\DoxyCodeLine{1146   \textcolor{keywordtype}{integer} :: isc\_bnd, iec\_bnd, jsc\_bnd, jec\_bnd}
\DoxyCodeLine{1147   \textcolor{keywordtype}{integer} :: i, j, i0, j0}
\DoxyCodeLine{1148   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{1149 }
\DoxyCodeLine{1150   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1151   \textcolor{keywordflow}{if} (.not.os\%is\_ocean\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{1152 }
\DoxyCodeLine{1153   g => os\%grid}
\DoxyCodeLine{1154   is = g\%isc ; ie = g\%iec ; js = g\%jsc ; je = g\%jec}
\DoxyCodeLine{1155 }
\DoxyCodeLine{1156   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\%Domain, isc\_bnd, iec\_bnd, \&}
\DoxyCodeLine{1157                               jsc\_bnd, jec\_bnd)}
\DoxyCodeLine{1158 }
\DoxyCodeLine{1159   i0 = is - isc\_bnd ; j0 = js - jsc\_bnd}
\DoxyCodeLine{1160 }
\DoxyCodeLine{1161   sfc\_state => os\%sfc\_state}
\DoxyCodeLine{1162 }
\DoxyCodeLine{1163   \textcolor{keywordflow}{select case}(name)}
\DoxyCodeLine{1164   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'ua'})}
\DoxyCodeLine{1165     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{1166       array2d(i,j) = g\%mask2dT(i+i0,j+j0) * \&}
\DoxyCodeLine{1167                 0.5*(sfc\_state\%u(i+i0,j+j0)+sfc\_state\%u(i-1+i0,j+j0))}
\DoxyCodeLine{1168 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1169   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'va'})}
\DoxyCodeLine{1170     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{1171       array2d(i,j) = g\%mask2dT(i+i0,j+j0) * \&}
\DoxyCodeLine{1172                 0.5*(sfc\_state\%v(i+i0,j+j0)+sfc\_state\%v(i+i0,j-1+j0))}
\DoxyCodeLine{1173 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1174   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'ub'})}
\DoxyCodeLine{1175     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{1176       array2d(i,j) = g\%mask2dBu(i+i0,j+j0) * \&}
\DoxyCodeLine{1177                 0.5*(sfc\_state\%u(i+i0,j+j0)+sfc\_state\%u(i+i0,j+j0+1))}
\DoxyCodeLine{1178 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1179   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'vb'})}
\DoxyCodeLine{1180     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd}
\DoxyCodeLine{1181       array2d(i,j) = g\%mask2dBu(i+i0,j+j0) * \&}
\DoxyCodeLine{1182                 0.5*(sfc\_state\%v(i+i0,j+j0)+sfc\_state\%v(i+i0+1,j+j0))}
\DoxyCodeLine{1183 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{1184 \textcolor{keywordflow}{  case default}}
\DoxyCodeLine{1185      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'ocean\_model\_get\_UV\_surf: unknown argument name='}//name)}
\DoxyCodeLine{1186 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1187 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a51ac9bb5e227e4a3f8be94a09a77eba8}\label{namespaceocean__model__mod_a51ac9bb5e227e4a3f8be94a09a77eba8}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_init@{ocean\_model\_init}}
\index{ocean\_model\_init@{ocean\_model\_init}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_init()}{ocean\_model\_init()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+init (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout), target}]{Ocean\+\_\+sfc,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+init,  }\item[{type(time\+\_\+type), intent(in)}]{Time\+\_\+in,  }\item[{integer, intent(in), optional}]{wind\+\_\+stagger,  }\item[{type(coupler\+\_\+1d\+\_\+bc\+\_\+type), intent(in), optional}]{gas\+\_\+fields\+\_\+ocn }\end{DoxyParamCaption})}



ocean\+\_\+model\+\_\+init initializes the ocean model, including registering fields for restarts and reading restart files if appropriate. 

This subroutine initializes both the ocean state and the ocean surface type. Because of the way that indicies and domains are handled, Ocean\+\_\+sfc must have been used in a previous call to initialize\+\_\+ocean\+\_\+type. 
\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em ocean\+\_\+sfc} & A structure containing various publicly \\
\hline
 & {\em os} & A structure whose internal contents are private to \mbox{\hyperlink{namespaceocean__model__mod}{ocean\+\_\+model\+\_\+mod}} that may be used to contain all information about the ocean\textquotesingle{}s interior state. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+init} & The start time for the coupled model\textquotesingle{}s calendar \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+in} & The time at which to initialize the ocean model. \\
\hline
\mbox{\texttt{ in}}  & {\em wind\+\_\+stagger} & If present, the staggering of the winds that are being provided in calls to update\+\_\+ocean\+\_\+model \\
\hline
\mbox{\texttt{ in}}  & {\em gas\+\_\+fields\+\_\+ocn} & If present, this type describes the \\
\hline
\end{DoxyParams}


Definition at line 228 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{228   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{target}, \&}
\DoxyCodeLine{229                        \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{230 \textcolor{comment}{                                !! visible ocean surface properties after initialization,}}
\DoxyCodeLine{231 \textcolor{comment}{                                !! the data in this type is intent out.}}
\DoxyCodeLine{232   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{        !< A structure whose internal}}
\DoxyCodeLine{233 \textcolor{comment}{                                !! contents are private to ocean\_model\_mod that may be used to}}
\DoxyCodeLine{234 \textcolor{comment}{                                !! contain all information about the ocean's interior state.}}
\DoxyCodeLine{235   \textcolor{keywordtype}{type}(time\_type),     \textcolor{keywordtype}{intent(in)}    :: Time\_init\textcolor{comment}{ !< The start time for the coupled model's calendar}}
\DoxyCodeLine{236   \textcolor{keywordtype}{type}(time\_type),     \textcolor{keywordtype}{intent(in)}    :: Time\_in\textcolor{comment}{   !< The time at which to initialize the ocean model.}}
\DoxyCodeLine{237   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},   \textcolor{keywordtype}{intent(in)}    :: wind\_stagger\textcolor{comment}{ !< If present, the staggering of the winds that are}}
\DoxyCodeLine{238 \textcolor{comment}{                                                     !! being provided in calls to update\_ocean\_model}}
\DoxyCodeLine{239   \textcolor{keywordtype}{type}(coupler\_1d\_bc\_type), \&}
\DoxyCodeLine{240              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: gas\_fields\_ocn\textcolor{comment}{ !< If present, this type describes the}}
\DoxyCodeLine{241 \textcolor{comment}{                                              !! ocean and surface-ice fields that will participate}}
\DoxyCodeLine{242 \textcolor{comment}{                                              !! in the calculation of additional gas or other}}
\DoxyCodeLine{243 \textcolor{comment}{                                              !! tracer fluxes, and can be used to spawn related}}
\DoxyCodeLine{244 \textcolor{comment}{                                              !! internal variables in the ice model.}}
\DoxyCodeLine{245   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{246 \textcolor{keywordtype}{  real} :: Rho0        \textcolor{comment}{! The Boussinesq ocean density [kg m-3].}}
\DoxyCodeLine{247 \textcolor{keywordtype}{  real} :: G\_Earth     \textcolor{comment}{! The gravitational acceleration [m s-2].}}
\DoxyCodeLine{248 \textcolor{keywordtype}{  real} :: HFrz\textcolor{comment}{        !< If HFrz > 0 (m), melt potential will be computed.}}
\DoxyCodeLine{249 \textcolor{comment}{                      !! The actual depth over which melt potential is computed will}}
\DoxyCodeLine{250 \textcolor{comment}{                      !! min(HFrz, OBLD), where OBLD is the boundary layer depth.}}
\DoxyCodeLine{251 \textcolor{comment}{                      !! If HFrz <= 0 (default), melt potential will not be computed.}}
\DoxyCodeLine{252   \textcolor{keywordtype}{logical} :: use\_melt\_pot\textcolor{comment}{!< If true, allocate melt\_potential array}}
\DoxyCodeLine{253 }
\DoxyCodeLine{254 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{255 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{256 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"ocean\_model\_init"}  \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{257   \textcolor{keywordtype}{character(len=48)}  :: stagger \textcolor{comment}{! A string indicating the staggering locations for the}}
\DoxyCodeLine{258                                 \textcolor{comment}{! surface velocities returned to the coupler.}}
\DoxyCodeLine{259   \textcolor{keywordtype}{type}(param\_file\_type) :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}}
\DoxyCodeLine{260   \textcolor{keywordtype}{logical} :: use\_temperature \textcolor{comment}{! If true, temperature and salinity are state variables.}}
\DoxyCodeLine{261 }
\DoxyCodeLine{262   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ocean\_model\_init(), ocean\_model\_MOM.F90"})}
\DoxyCodeLine{263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{264     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ocean\_model\_init called with an associated "}// \&}
\DoxyCodeLine{265                    \textcolor{stringliteral}{"ocean\_state\_type structure. Model is already initialized."})}
\DoxyCodeLine{266     \textcolor{keywordflow}{return}}
\DoxyCodeLine{267 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{268   \textcolor{keyword}{allocate}(os)}
\DoxyCodeLine{269 }
\DoxyCodeLine{270   os\%is\_ocean\_pe = ocean\_sfc\%is\_ocean\_pe}
\DoxyCodeLine{271   \textcolor{keywordflow}{if} (.not.os\%is\_ocean\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{272 }
\DoxyCodeLine{273   os\%Time = time\_in ; os\%Time\_dyn = time\_in}
\DoxyCodeLine{274   \textcolor{keyword}{call }initialize\_mom(os\%Time, time\_init, param\_file, os\%dirs, os\%MOM\_CSp, \&}
\DoxyCodeLine{275                       os\%restart\_CSp, time\_in, offline\_tracer\_mode=os\%offline\_tracer\_mode, \&}
\DoxyCodeLine{276                       diag\_ptr=os\%diag, count\_calls=.true.)}
\DoxyCodeLine{277   \textcolor{keyword}{call }get\_mom\_state\_elements(os\%MOM\_CSp, g=os\%grid, gv=os\%GV, us=os\%US, c\_p=os\%C\_p, \&}
\DoxyCodeLine{278                               c\_p\_scaled=os\%fluxes\%C\_p, use\_temp=use\_temperature)}
\DoxyCodeLine{279 }
\DoxyCodeLine{280   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}}
\DoxyCodeLine{281   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})}
\DoxyCodeLine{282 }
\DoxyCodeLine{283   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SINGLE\_STEPPING\_CALL"}, os\%single\_step\_call, \&}
\DoxyCodeLine{284                  \textcolor{stringliteral}{"If true, advance the state of MOM with a single step "}//\&}
\DoxyCodeLine{285                  \textcolor{stringliteral}{"including both dynamics and thermodynamics.  If false, "}//\&}
\DoxyCodeLine{286                  \textcolor{stringliteral}{"the two phases are advanced with separate calls."}, default=.true.)}
\DoxyCodeLine{287   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT"}, os\%dt, \&}
\DoxyCodeLine{288                  \textcolor{stringliteral}{"The (baroclinic) dynamics time step.  The time-step that "}//\&}
\DoxyCodeLine{289                  \textcolor{stringliteral}{"is actually used will be an integer fraction of the "}//\&}
\DoxyCodeLine{290                  \textcolor{stringliteral}{"forcing time-step."}, units=\textcolor{stringliteral}{"s"}, fail\_if\_missing=.true.)}
\DoxyCodeLine{291   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT\_THERM"}, os\%dt\_therm, \&}
\DoxyCodeLine{292                  \textcolor{stringliteral}{"The thermodynamic and tracer advection time step. "}//\&}
\DoxyCodeLine{293                  \textcolor{stringliteral}{"Ideally DT\_THERM should be an integer multiple of DT "}//\&}
\DoxyCodeLine{294                  \textcolor{stringliteral}{"and less than the forcing or coupling time-step, unless "}//\&}
\DoxyCodeLine{295                  \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING is true, in which case DT\_THERM "}//\&}
\DoxyCodeLine{296                  \textcolor{stringliteral}{"can be an integer multiple of the coupling timestep.  By "}//\&}
\DoxyCodeLine{297                  \textcolor{stringliteral}{"default DT\_THERM is set to DT."}, units=\textcolor{stringliteral}{"s"}, default=os\%dt)}
\DoxyCodeLine{298   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING"}, os\%thermo\_spans\_coupling, \&}
\DoxyCodeLine{299                  \textcolor{stringliteral}{"If true, the MOM will take thermodynamic and tracer "}//\&}
\DoxyCodeLine{300                  \textcolor{stringliteral}{"timesteps that can be longer than the coupling timestep. "}//\&}
\DoxyCodeLine{301                  \textcolor{stringliteral}{"The actual thermodynamic timestep that is used in this "}//\&}
\DoxyCodeLine{302                  \textcolor{stringliteral}{"case is the largest integer multiple of the coupling "}//\&}
\DoxyCodeLine{303                  \textcolor{stringliteral}{"timestep that is less than or equal to DT\_THERM."}, default=.false.)}
\DoxyCodeLine{304   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIABATIC\_FIRST"}, os\%diabatic\_first, \&}
\DoxyCodeLine{305                  \textcolor{stringliteral}{"If true, apply diabatic and thermodynamic processes, "}//\&}
\DoxyCodeLine{306                  \textcolor{stringliteral}{"including buoyancy forcing and mass gain or loss, "}//\&}
\DoxyCodeLine{307                  \textcolor{stringliteral}{"before stepping the dynamics forward."}, default=.false.)}
\DoxyCodeLine{308 }
\DoxyCodeLine{309   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTART\_CONTROL"}, os\%Restart\_control, \&}
\DoxyCodeLine{310                  \textcolor{stringliteral}{"An integer whose bits encode which restart files are "}//\&}
\DoxyCodeLine{311                  \textcolor{stringliteral}{"written. Add 2 (bit 1) for a time-stamped file, and odd "}//\&}
\DoxyCodeLine{312                  \textcolor{stringliteral}{"(bit 0) for a non-time-stamped file.  A restart file "}//\&}
\DoxyCodeLine{313                  \textcolor{stringliteral}{"will be saved at the end of the run segment for any "}//\&}
\DoxyCodeLine{314                  \textcolor{stringliteral}{"non-negative value."}, default=1)}
\DoxyCodeLine{315   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OCEAN\_SURFACE\_STAGGER"}, stagger, \&}
\DoxyCodeLine{316                  \textcolor{stringliteral}{"A case-insensitive character string to indicate the "}//\&}
\DoxyCodeLine{317                  \textcolor{stringliteral}{"staggering of the surface velocity field that is "}//\&}
\DoxyCodeLine{318                  \textcolor{stringliteral}{"returned to the coupler.  Valid values include "}//\&}
\DoxyCodeLine{319                  \textcolor{stringliteral}{"'A', 'B', or 'C'."}, default=\textcolor{stringliteral}{"C"})}
\DoxyCodeLine{320   \textcolor{keywordflow}{if} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'A'}) \textcolor{keywordflow}{then} ; ocean\_sfc\%stagger = agrid}
\DoxyCodeLine{321   \textcolor{keywordflow}{elseif} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'B'}) \textcolor{keywordflow}{then} ; ocean\_sfc\%stagger = bgrid\_ne}
\DoxyCodeLine{322   \textcolor{keywordflow}{elseif} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'C'}) \textcolor{keywordflow}{then} ; ocean\_sfc\%stagger = cgrid\_ne}
\DoxyCodeLine{323   \textcolor{keywordflow}{else} ; \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"ocean\_model\_init: OCEAN\_SURFACE\_STAGGER = "}// \&}
\DoxyCodeLine{324                         trim(stagger)//\textcolor{stringliteral}{" is invalid."}) ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{325 }
\DoxyCodeLine{326   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, rho0, \&}
\DoxyCodeLine{327                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//\&}
\DoxyCodeLine{328                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//\&}
\DoxyCodeLine{329                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//\&}
\DoxyCodeLine{330                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, \&}
\DoxyCodeLine{331                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0)}
\DoxyCodeLine{332   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, g\_earth, \&}
\DoxyCodeLine{333                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, \&}
\DoxyCodeLine{334                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80)}
\DoxyCodeLine{335 }
\DoxyCodeLine{336   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF"},  os\%use\_ice\_shelf, \&}
\DoxyCodeLine{337                  \textcolor{stringliteral}{"If true, enables the ice shelf model."}, default=.false.)}
\DoxyCodeLine{338 }
\DoxyCodeLine{339   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICEBERGS\_APPLY\_RIGID\_BOUNDARY"},  os\%icebergs\_alter\_ocean, \&}
\DoxyCodeLine{340                  \textcolor{stringliteral}{"If true, allows icebergs to change boundary condition felt by ocean"}, default=.false.)}
\DoxyCodeLine{341 }
\DoxyCodeLine{342   os\%press\_to\_z = 1.0/(rho0*g\_earth)}
\DoxyCodeLine{343 }
\DoxyCodeLine{344   \textcolor{comment}{!   Consider using a run-time flag to determine whether to do the diagnostic}}
\DoxyCodeLine{345   \textcolor{comment}{! vertical integrals, since the related 3-d sums are not negligible in cost.}}
\DoxyCodeLine{346   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"HFREEZE"}, hfrz, \&}
\DoxyCodeLine{347                  \textcolor{stringliteral}{"If HFREEZE > 0, melt potential will be computed. The actual depth "}//\&}
\DoxyCodeLine{348                  \textcolor{stringliteral}{"over which melt potential is computed will be min(HFREEZE, OBLD), "}//\&}
\DoxyCodeLine{349                  \textcolor{stringliteral}{"where OBLD is the boundary layer depth. If HFREEZE <= 0 (default), "}//\&}
\DoxyCodeLine{350                  \textcolor{stringliteral}{"melt potential will not be computed."}, units=\textcolor{stringliteral}{"m"}, default=-1.0, do\_not\_log=.true.)}
\DoxyCodeLine{351 }
\DoxyCodeLine{352   \textcolor{keywordflow}{if} (hfrz .gt. 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{353     use\_melt\_pot=.true.}
\DoxyCodeLine{354   \textcolor{keywordflow}{else}}
\DoxyCodeLine{355     use\_melt\_pot=.false.}
\DoxyCodeLine{356 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{357 }
\DoxyCodeLine{358   \textcolor{keyword}{call }allocate\_surface\_state(os\%sfc\_state, os\%grid, use\_temperature, do\_integrals=.true., \&}
\DoxyCodeLine{359                               gas\_fields\_ocn=gas\_fields\_ocn, use\_meltpot=use\_melt\_pot)}
\DoxyCodeLine{360 }
\DoxyCodeLine{361   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(wind\_stagger)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{362     \textcolor{keyword}{call }surface\_forcing\_init(time\_in, os\%grid, os\%US, param\_file, os\%diag, \&}
\DoxyCodeLine{363                               os\%forcing\_CSp, wind\_stagger)}
\DoxyCodeLine{364   \textcolor{keywordflow}{else}}
\DoxyCodeLine{365     \textcolor{keyword}{call }surface\_forcing\_init(time\_in, os\%grid, os\%US, param\_file, os\%diag, \&}
\DoxyCodeLine{366                               os\%forcing\_CSp)}
\DoxyCodeLine{367 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{368 }
\DoxyCodeLine{369   \textcolor{keywordflow}{if} (os\%use\_ice\_shelf)  \textcolor{keywordflow}{then}}
\DoxyCodeLine{370     \textcolor{keyword}{call }initialize\_ice\_shelf(param\_file, os\%grid, os\%Time, os\%ice\_shelf\_CSp, \&}
\DoxyCodeLine{371                               os\%diag, os\%forces, os\%fluxes)}
\DoxyCodeLine{372 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{373   \textcolor{keywordflow}{if} (os\%icebergs\_alter\_ocean)  \textcolor{keywordflow}{then}}
\DoxyCodeLine{374     \textcolor{keyword}{call }marine\_ice\_init(os\%Time, os\%grid, param\_file, os\%diag, os\%marine\_ice\_CSp)}
\DoxyCodeLine{375     \textcolor{keywordflow}{if} (.not. os\%use\_ice\_shelf) \&}
\DoxyCodeLine{376       \textcolor{keyword}{call }allocate\_forcing\_type(os\%grid, os\%fluxes, shelf=.true.)}
\DoxyCodeLine{377 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{378 }
\DoxyCodeLine{379   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_WAVES"}, os\%Use\_Waves, \&}
\DoxyCodeLine{380        \textcolor{stringliteral}{"If true, enables surface wave modules."}, default=.false.)}
\DoxyCodeLine{381   \textcolor{keywordflow}{if} (os\%use\_waves) \textcolor{keywordflow}{then}}
\DoxyCodeLine{382     \textcolor{keyword}{call }mom\_wave\_interface\_init(os\%Time, os\%grid, os\%GV, os\%US, param\_file, os\%Waves, os\%diag)}
\DoxyCodeLine{383   \textcolor{keywordflow}{else}}
\DoxyCodeLine{384     \textcolor{keyword}{call }mom\_wave\_interface\_init\_lite(param\_file)}
\DoxyCodeLine{385 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{386 }
\DoxyCodeLine{387   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(os\%grid\%Domain\%maskmap)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{388     \textcolor{keyword}{call }initialize\_ocean\_public\_type(os\%grid\%Domain\%mpp\_domain, ocean\_sfc, \&}
\DoxyCodeLine{389                                       os\%diag, maskmap=os\%grid\%Domain\%maskmap, \&}
\DoxyCodeLine{390                                       gas\_fields\_ocn=gas\_fields\_ocn)}
\DoxyCodeLine{391   \textcolor{keywordflow}{else}}
\DoxyCodeLine{392     \textcolor{keyword}{call }initialize\_ocean\_public\_type(os\%grid\%Domain\%mpp\_domain, ocean\_sfc, \&}
\DoxyCodeLine{393                                       os\%diag, gas\_fields\_ocn=gas\_fields\_ocn)}
\DoxyCodeLine{394 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{395 }
\DoxyCodeLine{396   \textcolor{comment}{! This call can only occur here if the coupler\_bc\_type variables have been}}
\DoxyCodeLine{397   \textcolor{comment}{! initialized already using the information from gas\_fields\_ocn.}}
\DoxyCodeLine{398   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(gas\_fields\_ocn)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{399     \textcolor{keyword}{call }coupler\_type\_set\_diags(ocean\_sfc\%fields, \textcolor{stringliteral}{"ocean\_sfc"}, \&}
\DoxyCodeLine{400                                 ocean\_sfc\%axes(1:2), time\_in)}
\DoxyCodeLine{401 }
\DoxyCodeLine{402     \textcolor{keyword}{call }extract\_surface\_state(os\%MOM\_CSp, os\%sfc\_state)}
\DoxyCodeLine{403 }
\DoxyCodeLine{404     \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os\%sfc\_state, ocean\_sfc, os\%grid, os\%US)}
\DoxyCodeLine{405 }
\DoxyCodeLine{406 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{407 }
\DoxyCodeLine{408   \textcolor{keyword}{call }close\_param\_file(param\_file)}
\DoxyCodeLine{409   \textcolor{keyword}{call }diag\_mediator\_close\_registration(os\%diag)}
\DoxyCodeLine{410 }
\DoxyCodeLine{411   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'==== Completed MOM6 Coupled Initialization ===='}, 2)}
\DoxyCodeLine{412 }
\DoxyCodeLine{413   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"ocean\_model\_init("})}

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a2fca652469ca65c63305060534a14c0e}\label{namespaceocean__model__mod_a2fca652469ca65c63305060534a14c0e}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_init\_sfc@{ocean\_model\_init\_sfc}}
\index{ocean\_model\_init\_sfc@{ocean\_model\_init\_sfc}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_init\_sfc()}{ocean\_model\_init\_sfc()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+init\+\_\+sfc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout)}]{Ocean\+\_\+sfc }\end{DoxyParamCaption})}



This subroutine extracts the surface properties from the ocean\textquotesingle{}s internal state and stores them in the ocean type returned to the calling ice model. It has to be separate from the ocean\+\_\+initialization call because the coupler module allocates the space for some of these variables. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & The structure with the complete ocean state \\
\hline
\mbox{\texttt{ in,out}}  & {\em ocean\+\_\+sfc} & A structure containing various publicly visible ocean surface properties after initialization, whose elements have their data set here. \\
\hline
\end{DoxyParams}


Definition at line 930 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{930   \textcolor{keywordtype}{type}(ocean\_state\_type),  \textcolor{keywordtype}{pointer}       :: OS\textcolor{comment}{  !< The structure with the complete ocean state}}
\DoxyCodeLine{931   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{932 \textcolor{comment}{                                !! visible ocean surface properties after initialization, whose}}
\DoxyCodeLine{933 \textcolor{comment}{                                !! elements have their data set here.}}
\DoxyCodeLine{934   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{935 }
\DoxyCodeLine{936   is = os\%grid\%isc ; ie = os\%grid\%iec ; js = os\%grid\%jsc ; je = os\%grid\%jec}
\DoxyCodeLine{937   \textcolor{keyword}{call }coupler\_type\_spawn(ocean\_sfc\%fields, os\%sfc\_state\%tr\_fields, \&}
\DoxyCodeLine{938                           (/is,is,ie,ie/), (/js,js,je,je/), as\_needed=.true.)}
\DoxyCodeLine{939 }
\DoxyCodeLine{940   \textcolor{keyword}{call }extract\_surface\_state(os\%MOM\_CSp, os\%sfc\_state)}
\DoxyCodeLine{941 }
\DoxyCodeLine{942   \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os\%sfc\_state, ocean\_sfc, os\%grid, os\%US)}
\DoxyCodeLine{943 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a908a47d286b0257e91a253272926dc3d}\label{namespaceocean__model__mod_a908a47d286b0257e91a253272926dc3d}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_restart@{ocean\_model\_restart}}
\index{ocean\_model\_restart@{ocean\_model\_restart}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_restart()}{ocean\_model\_restart()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+restart (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{character(len=$\ast$), intent(in), optional}]{timestamp }\end{DoxyParamCaption})}



This subroutine writes out the ocean model restart file. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A pointer to the structure containing the internal ocean state being saved to a restart file \\
\hline
\mbox{\texttt{ in}}  & {\em timestamp} & An optional timestamp string that should be prepended to the file name. (Currently this is unused.) \\
\hline
\end{DoxyParams}


Definition at line 673 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{673   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{ !< A pointer to the structure containing the}}
\DoxyCodeLine{674 \textcolor{comment}{                                               !! internal ocean state being saved to a restart file}}
\DoxyCodeLine{675   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: timestamp\textcolor{comment}{ !< An optional timestamp string that should be}}
\DoxyCodeLine{676 \textcolor{comment}{                                               !! prepended to the file name. (Currently this is unused.)}}
\DoxyCodeLine{677 }
\DoxyCodeLine{678   \textcolor{keywordflow}{if} (.not.mom\_state\_is\_synchronized(os\%MOM\_CSp)) \&}
\DoxyCodeLine{679       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"End of MOM\_main reached with inconsistent "}//\&}
\DoxyCodeLine{680          \textcolor{stringliteral}{"dynamics and advective times.  Additional restart fields "}//\&}
\DoxyCodeLine{681          \textcolor{stringliteral}{"that have not been coded yet would be required for reproducibility."})}
\DoxyCodeLine{682   \textcolor{keywordflow}{if} (.not.os\%fluxes\%fluxes\_used) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_model\_restart "}//\&}
\DoxyCodeLine{683       \textcolor{stringliteral}{"was called with unused buoyancy fluxes.  For conservation, the ocean "}//\&}
\DoxyCodeLine{684       \textcolor{stringliteral}{"restart files can only be created after the buoyancy forcing is applied."})}
\DoxyCodeLine{685 }
\DoxyCodeLine{686   \textcolor{keywordflow}{if} (btest(os\%Restart\_control,1)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{687     \textcolor{keyword}{call }save\_restart(os\%dirs\%restart\_output\_dir, os\%Time, os\%grid, \&}
\DoxyCodeLine{688                       os\%restart\_CSp, .true., gv=os\%GV)}
\DoxyCodeLine{689     \textcolor{keyword}{call }forcing\_save\_restart(os\%forcing\_CSp, os\%grid, os\%Time, \&}
\DoxyCodeLine{690                               os\%dirs\%restart\_output\_dir, .true.)}
\DoxyCodeLine{691     \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{692       \textcolor{keyword}{call }ice\_shelf\_save\_restart(os\%Ice\_shelf\_CSp, os\%Time, os\%dirs\%restart\_output\_dir, .true.)}
\DoxyCodeLine{693 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{694 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{695   \textcolor{keywordflow}{if} (btest(os\%Restart\_control,0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{696     \textcolor{keyword}{call }save\_restart(os\%dirs\%restart\_output\_dir, os\%Time, os\%grid, \&}
\DoxyCodeLine{697                       os\%restart\_CSp, gv=os\%GV)}
\DoxyCodeLine{698     \textcolor{keyword}{call }forcing\_save\_restart(os\%forcing\_CSp, os\%grid, os\%Time, \&}
\DoxyCodeLine{699                               os\%dirs\%restart\_output\_dir)}
\DoxyCodeLine{700     \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{701       \textcolor{keyword}{call }ice\_shelf\_save\_restart(os\%Ice\_shelf\_CSp, os\%Time, os\%dirs\%restart\_output\_dir)}
\DoxyCodeLine{702 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{703 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{704 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_ad969c968b1133584b9dcf48d78f51c01}\label{namespaceocean__model__mod_ad969c968b1133584b9dcf48d78f51c01}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_model\_save\_restart@{ocean\_model\_save\_restart}}
\index{ocean\_model\_save\_restart@{ocean\_model\_save\_restart}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_model\_save\_restart()}{ocean\_model\_save\_restart()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+model\+\_\+save\+\_\+restart (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{character(len=$\ast$), intent(in), optional}]{directory,  }\item[{character(len=$\ast$), intent(in), optional}]{filename\+\_\+suffix }\end{DoxyParamCaption})}



ocean\+\_\+model\+\_\+save\+\_\+restart causes restart files associated with the ocean to be written out. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A pointer to the structure containing the internal ocean state (in). \\
\hline
\mbox{\texttt{ in}}  & {\em time} & The model time at this call, needed for mpp\+\_\+write calls. \\
\hline
\mbox{\texttt{ in}}  & {\em directory} & An optional directory into which to write these restart files. \\
\hline
\mbox{\texttt{ in}}  & {\em filename\+\_\+suffix} & An optional suffix (e.\+g., a time-\/stamp) to append to the restart file names. \\
\hline
\end{DoxyParams}


Definition at line 727 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{727   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{  !< A pointer to the structure containing the}}
\DoxyCodeLine{728 \textcolor{comment}{                                                !! internal ocean state (in).}}
\DoxyCodeLine{729   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< The model time at this call, needed for mpp\_write calls.}}
\DoxyCodeLine{730   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{  !<  An optional directory into which to}}
\DoxyCodeLine{731 \textcolor{comment}{                                                !! write these restart files.}}
\DoxyCodeLine{732   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: filename\_suffix\textcolor{comment}{ !< An optional suffix (e.g., a time-stamp)}}
\DoxyCodeLine{733 \textcolor{comment}{                                                !! to append to the restart file names.}}
\DoxyCodeLine{734 \textcolor{comment}{! Note: This is a new routine - it will need to exist for the new incremental}}
\DoxyCodeLine{735 \textcolor{comment}{!   checkpointing.  It will also be called by ocean\_model\_end, giving the same}}
\DoxyCodeLine{736 \textcolor{comment}{!   restart behavior as now in FMS.}}
\DoxyCodeLine{737   \textcolor{keywordtype}{character(len=200)} :: restart\_dir}
\DoxyCodeLine{738 }
\DoxyCodeLine{739   \textcolor{keywordflow}{if} (.not.mom\_state\_is\_synchronized(os\%MOM\_CSp)) \&}
\DoxyCodeLine{740     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ocean\_model\_save\_restart called with inconsistent "}//\&}
\DoxyCodeLine{741          \textcolor{stringliteral}{"dynamics and advective times.  Additional restart fields "}//\&}
\DoxyCodeLine{742          \textcolor{stringliteral}{"that have not been coded yet would be required for reproducibility."})}
\DoxyCodeLine{743   \textcolor{keywordflow}{if} (.not.os\%fluxes\%fluxes\_used) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_model\_save\_restart "}//\&}
\DoxyCodeLine{744        \textcolor{stringliteral}{"was called with unused buoyancy fluxes.  For conservation, the ocean "}//\&}
\DoxyCodeLine{745        \textcolor{stringliteral}{"restart files can only be created after the buoyancy forcing is applied."})}
\DoxyCodeLine{746 }
\DoxyCodeLine{747   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(directory)) \textcolor{keywordflow}{then} ; restart\_dir = directory}
\DoxyCodeLine{748   \textcolor{keywordflow}{else} ; restart\_dir = os\%dirs\%restart\_output\_dir ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{749 }
\DoxyCodeLine{750   \textcolor{keyword}{call }save\_restart(restart\_dir, time, os\%grid, os\%restart\_CSp, gv=os\%GV)}
\DoxyCodeLine{751 }
\DoxyCodeLine{752   \textcolor{keyword}{call }forcing\_save\_restart(os\%forcing\_CSp, os\%grid, time, restart\_dir)}
\DoxyCodeLine{753 }
\DoxyCodeLine{754   \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \textcolor{keywordflow}{then}}
\DoxyCodeLine{755     \textcolor{keyword}{call }ice\_shelf\_save\_restart(os\%Ice\_shelf\_CSp, os\%Time, os\%dirs\%restart\_output\_dir)}
\DoxyCodeLine{756 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{757 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a3f7b5b40926d545a117274993924c9ee}\label{namespaceocean__model__mod_a3f7b5b40926d545a117274993924c9ee}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_public\_type\_chksum@{ocean\_public\_type\_chksum}}
\index{ocean\_public\_type\_chksum@{ocean\_public\_type\_chksum}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_public\_type\_chksum()}{ocean\_public\_type\_chksum()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+public\+\_\+type\+\_\+chksum (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{id,  }\item[{integer, intent(in)}]{timestep,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(in)}]{ocn }\end{DoxyParamCaption})}



Write out F\+M\+S-\/format checsums on fields from the ocean surface state. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em id} & An identifying string for this call \\
\hline
\mbox{\texttt{ in}}  & {\em timestep} & The number of elapsed timesteps \\
\hline
\mbox{\texttt{ in}}  & {\em ocn} & A structure containing various publicly visible ocean surface fields. \\
\hline
\end{DoxyParams}


Definition at line 1096 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1096 }
\DoxyCodeLine{1097   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: id\textcolor{comment}{  !< An identifying string for this call}}
\DoxyCodeLine{1098   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)} :: timestep\textcolor{comment}{ !< The number of elapsed timesteps}}
\DoxyCodeLine{1099   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(in)} :: ocn\textcolor{comment}{ !< A structure containing various publicly}}
\DoxyCodeLine{1100 \textcolor{comment}{                                             !! visible ocean surface fields.}}
\DoxyCodeLine{1101   \textcolor{keywordtype}{integer} :: n, m, outunit}
\DoxyCodeLine{1102 }
\DoxyCodeLine{1103   outunit = stdout()}
\DoxyCodeLine{1104 }
\DoxyCodeLine{1105   \textcolor{keyword}{write}(outunit,*) \textcolor{stringliteral}{"BEGIN CHECKSUM(ocean\_type):: "}, id, timestep}
\DoxyCodeLine{1106   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%t\_surf   '},mpp\_chksum(ocn\%t\_surf )}
\DoxyCodeLine{1107   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%s\_surf   '},mpp\_chksum(ocn\%s\_surf )}
\DoxyCodeLine{1108   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%u\_surf   '},mpp\_chksum(ocn\%u\_surf )}
\DoxyCodeLine{1109   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%v\_surf   '},mpp\_chksum(ocn\%v\_surf )}
\DoxyCodeLine{1110   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%sea\_lev  '},mpp\_chksum(ocn\%sea\_lev)}
\DoxyCodeLine{1111   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean\%frazil   '},mpp\_chksum(ocn\%frazil )}
\DoxyCodeLine{1112 }
\DoxyCodeLine{1113   \textcolor{keyword}{call }coupler\_type\_write\_chksums(ocn\%fields, outunit, \textcolor{stringliteral}{'ocean\%'})}
\DoxyCodeLine{1114 100 \textcolor{keyword}{FORMAT}(\textcolor{stringliteral}{"   CHECKSUM::"},a20,\textcolor{stringliteral}{" = "},z20)}
\DoxyCodeLine{1115 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a7ecaaa406a1cba3e9bcd84d375247ec5}\label{namespaceocean__model__mod_a7ecaaa406a1cba3e9bcd84d375247ec5}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!ocean\_stock\_pe@{ocean\_stock\_pe}}
\index{ocean\_stock\_pe@{ocean\_stock\_pe}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{ocean\_stock\_pe()}{ocean\_stock\_pe()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::ocean\+\_\+stock\+\_\+pe (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{integer, intent(in)}]{index,  }\item[{real, intent(out)}]{value,  }\item[{integer, intent(in), optional}]{time\+\_\+index }\end{DoxyParamCaption})}



Ocean\+\_\+stock\+\_\+pe -\/ returns the integrated stocks of heat, water, etc. for conservation checks. Because of the way F\+MS is coded, only the root PE has the integrated amount, while all other P\+Es get 0. 


\begin{DoxyParams}[1]{Parameters}
 & {\em os} & A structure containing the internal ocean state. The data in OS is intent in. \\
\hline
\mbox{\texttt{ in}}  & {\em index} & The stock index for the quantity of interest. \\
\hline
\mbox{\texttt{ out}}  & {\em value} & Sum returned for the conservation quantity of interest. \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+index} & An unused optional argument, present only for interfacial compatibility with other models. \\
\hline
\end{DoxyParams}


Definition at line 973 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{973   \textcolor{keywordtype}{use }stock\_constants\_mod, \textcolor{keywordtype}{only} : istock\_water, istock\_heat,istock\_salt}
\DoxyCodeLine{974   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{pointer}     :: OS\textcolor{comment}{         !< A structure containing the internal ocean state.}}
\DoxyCodeLine{975 \textcolor{comment}{                                                    !! The data in OS is intent in.}}
\DoxyCodeLine{976   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}  :: index\textcolor{comment}{      !< The stock index for the quantity of interest.}}
\DoxyCodeLine{977 \textcolor{keywordtype}{  real},                   \textcolor{keywordtype}{intent(out)} :: \textcolor{keywordtype}{value}\textcolor{comment}{      !< Sum returned for the conservation quantity of interest.}}
\DoxyCodeLine{978   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: time\_index\textcolor{comment}{ !< An unused optional argument, present only for}}
\DoxyCodeLine{979 \textcolor{comment}{                                                    !! interfacial compatibility with other models.}}
\DoxyCodeLine{980 \textcolor{comment}{! Arguments: OS - A structure containing the internal ocean state.}}
\DoxyCodeLine{981 \textcolor{comment}{!  (in)      index - Index of conservation quantity of interest.}}
\DoxyCodeLine{982 \textcolor{comment}{!  (in)      value -  Sum returned for the conservation quantity of interest.}}
\DoxyCodeLine{983 \textcolor{comment}{!  (in,opt)  time\_index - Index for time level to use if this is necessary.}}
\DoxyCodeLine{984 }
\DoxyCodeLine{985 \textcolor{keywordtype}{  real} :: salt}
\DoxyCodeLine{986 }
\DoxyCodeLine{987   \textcolor{keywordtype}{value} = 0.0}
\DoxyCodeLine{988   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}}
\DoxyCodeLine{989   \textcolor{keywordflow}{if} (.not.os\%is\_ocean\_pe) \textcolor{keywordflow}{return}}
\DoxyCodeLine{990 }
\DoxyCodeLine{991   \textcolor{keywordflow}{select case} (index)}
\DoxyCodeLine{992     \textcolor{keywordflow}{case} (istock\_water)  \textcolor{comment}{! Return the mass of fresh water in the ocean in kg.}}
\DoxyCodeLine{993       \textcolor{keywordflow}{if} (os\%GV\%Boussinesq) \textcolor{keywordflow}{then}}
\DoxyCodeLine{994         \textcolor{keyword}{call }get\_ocean\_stocks(os\%MOM\_CSp, mass=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)}
\DoxyCodeLine{995       \textcolor{keywordflow}{else}  \textcolor{comment}{! In non-Boussinesq mode, the mass of salt needs to be subtracted.}}
\DoxyCodeLine{996         \textcolor{keyword}{call }get\_ocean\_stocks(os\%MOM\_CSp, mass=\textcolor{keywordtype}{value}, salt=salt, on\_pe\_only=.true.)}
\DoxyCodeLine{997         \textcolor{keywordtype}{value} = \textcolor{keywordtype}{value} - salt}
\DoxyCodeLine{998 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{999     \textcolor{keywordflow}{case} (istock\_heat)  \textcolor{comment}{! Return the heat content of the ocean in J.}}
\DoxyCodeLine{1000       \textcolor{keyword}{call }get\_ocean\_stocks(os\%MOM\_CSp, heat=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)}
\DoxyCodeLine{1001     \textcolor{keywordflow}{case} (istock\_salt)  \textcolor{comment}{! Return the mass of the salt in the ocean in kg.}}
\DoxyCodeLine{1002        \textcolor{keyword}{call }get\_ocean\_stocks(os\%MOM\_CSp, salt=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)}
\DoxyCodeLine{1003 \textcolor{keywordflow}{    case default} ; \textcolor{keywordtype}{value} = 0.0}
\DoxyCodeLine{1004 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{1005   \textcolor{comment}{! If the FMS coupler is changed so that Ocean\_stock\_PE is only called on}}
\DoxyCodeLine{1006   \textcolor{comment}{! ocean PEs, uncomment the following and eliminate the on\_PE\_only flags above.}}
\DoxyCodeLine{1007   \textcolor{comment}{!  if (.not.is\_root\_pe()) value = 0.0}}
\DoxyCodeLine{1008 }

\end{DoxyCode}
\mbox{\Hypertarget{namespaceocean__model__mod_a497d254b44f58fb797b9d75bc006eb60}\label{namespaceocean__model__mod_a497d254b44f58fb797b9d75bc006eb60}} 
\index{ocean\_model\_mod@{ocean\_model\_mod}!update\_ocean\_model@{update\_ocean\_model}}
\index{update\_ocean\_model@{update\_ocean\_model}!ocean\_model\_mod@{ocean\_model\_mod}}
\subsubsection{\texorpdfstring{update\_ocean\_model()}{update\_ocean\_model()}}
{\footnotesize\ttfamily subroutine, public ocean\+\_\+model\+\_\+mod\+::update\+\_\+ocean\+\_\+model (\begin{DoxyParamCaption}\item[{type(ice\+\_\+ocean\+\_\+boundary\+\_\+type), intent(in)}]{Ice\+\_\+ocean\+\_\+boundary,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__state__type}{ocean\+\_\+state\+\_\+type}}), pointer}]{OS,  }\item[{type(\mbox{\hyperlink{structocean__model__mod_1_1ocean__public__type}{ocean\+\_\+public\+\_\+type}}), intent(inout)}]{Ocean\+\_\+sfc,  }\item[{type(time\+\_\+type), intent(in)}]{time\+\_\+start\+\_\+update,  }\item[{type(time\+\_\+type), intent(in)}]{Ocean\+\_\+coupling\+\_\+time\+\_\+step,  }\item[{logical, intent(in), optional}]{update\+\_\+dyn,  }\item[{logical, intent(in), optional}]{update\+\_\+thermo,  }\item[{logical, intent(in), optional}]{Ocn\+\_\+fluxes\+\_\+used,  }\item[{logical, intent(in), optional}]{start\+\_\+cycle,  }\item[{logical, intent(in), optional}]{end\+\_\+cycle,  }\item[{real, intent(in), optional}]{cycle\+\_\+length }\end{DoxyParamCaption})}



update\+\_\+ocean\+\_\+model uses the forcing in Ice\+\_\+ocean\+\_\+boundary to advance the ocean model\textquotesingle{}s state from the input value of Ocean\+\_\+state (which must be for time time\+\_\+start\+\_\+update) for a time interval of Ocean\+\_\+coupling\+\_\+time\+\_\+step, returning the publicly visible ocean surface properties in Ocean\+\_\+sfc and storing the new ocean properties in Ocean\+\_\+state. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ice\+\_\+ocean\+\_\+boundary} & A structure containing the various \\
\hline
 & {\em os} & A pointer to a private structure containing the \\
\hline
\mbox{\texttt{ in,out}}  & {\em ocean\+\_\+sfc} & A structure containing all the publicly visible \\
\hline
\mbox{\texttt{ in}}  & {\em time\+\_\+start\+\_\+update} & The time at the beginning of the update step. \\
\hline
\mbox{\texttt{ in}}  & {\em ocean\+\_\+coupling\+\_\+time\+\_\+step} & The amount of time over which to advance the ocean. \\
\hline
\mbox{\texttt{ in}}  & {\em update\+\_\+dyn} & If present and false, do not do updates due to the ocean dynamics. \\
\hline
\mbox{\texttt{ in}}  & {\em update\+\_\+thermo} & If present and false, do not do updates due to the ocean thermodynamics or remapping. \\
\hline
\mbox{\texttt{ in}}  & {\em ocn\+\_\+fluxes\+\_\+used} & If present, this indicates whether the cumulative thermodynamic fluxes from the ocean, like frazil, have been used and should be reset. \\
\hline
\mbox{\texttt{ in}}  & {\em start\+\_\+cycle} & This indicates whether this call is to be treated as the first call to step\+\_\+\+M\+OM in a time-\/stepping cycle; missing is like true. \\
\hline
\mbox{\texttt{ in}}  & {\em end\+\_\+cycle} & This indicates whether this call is to be treated as the last call to step\+\_\+\+M\+OM in a time-\/stepping cycle; missing is like true. \\
\hline
\mbox{\texttt{ in}}  & {\em cycle\+\_\+length} & The duration of a coupled time stepping cycle \mbox{[}s\mbox{]}. \\
\hline
\end{DoxyParams}


Definition at line 424 of file ocean\+\_\+model\+\_\+\+M\+O\+M.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{424   \textcolor{keywordtype}{type}(ice\_ocean\_boundary\_type), \&}
\DoxyCodeLine{425                      \textcolor{keywordtype}{intent(in)}    :: Ice\_ocean\_boundary\textcolor{comment}{ !< A structure containing the various}}
\DoxyCodeLine{426 \textcolor{comment}{                                              !! forcing fields coming from the ice and atmosphere.}}
\DoxyCodeLine{427   \textcolor{keywordtype}{type}(ocean\_state\_type), \&}
\DoxyCodeLine{428                      \textcolor{keywordtype}{pointer}       :: OS\textcolor{comment}{      !< A pointer to a private structure containing the}}
\DoxyCodeLine{429 \textcolor{comment}{                                              !! internal ocean state.}}
\DoxyCodeLine{430   \textcolor{keywordtype}{type}(ocean\_public\_type), \&}
\DoxyCodeLine{431                      \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing all the publicly visible}}
\DoxyCodeLine{432 \textcolor{comment}{                                              !! ocean surface fields after a coupling time step.}}
\DoxyCodeLine{433 \textcolor{comment}{                                              !! The data in this type is intent out.}}
\DoxyCodeLine{434   \textcolor{keywordtype}{type}(time\_type),   \textcolor{keywordtype}{intent(in)}    :: time\_start\_update\textcolor{comment}{  !< The time at the beginning of the update step.}}
\DoxyCodeLine{435   \textcolor{keywordtype}{type}(time\_type),   \textcolor{keywordtype}{intent(in)}    :: Ocean\_coupling\_time\_step\textcolor{comment}{ !< The amount of time over which to}}
\DoxyCodeLine{436 \textcolor{comment}{                                              !! advance the ocean.}}
\DoxyCodeLine{437   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: update\_dyn\textcolor{comment}{ !< If present and false, do not do updates}}
\DoxyCodeLine{438 \textcolor{comment}{                                              !! due to the ocean dynamics.}}
\DoxyCodeLine{439   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: update\_thermo\textcolor{comment}{ !< If present and false, do not do updates}}
\DoxyCodeLine{440 \textcolor{comment}{                                              !! due to the ocean thermodynamics or remapping.}}
\DoxyCodeLine{441   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: Ocn\_fluxes\_used\textcolor{comment}{ !< If present, this indicates whether the}}
\DoxyCodeLine{442 \textcolor{comment}{                                              !! cumulative thermodynamic fluxes from the ocean,}}
\DoxyCodeLine{443 \textcolor{comment}{                                              !! like frazil, have been used and should be reset.}}
\DoxyCodeLine{444   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: start\_cycle\textcolor{comment}{ !< This indicates whether this call is to be}}
\DoxyCodeLine{445 \textcolor{comment}{                                              !! treated as the first call to step\_MOM in a}}
\DoxyCodeLine{446 \textcolor{comment}{                                              !! time-stepping cycle; missing is like true.}}
\DoxyCodeLine{447   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: end\_cycle\textcolor{comment}{   !< This indicates whether this call is to be}}
\DoxyCodeLine{448 \textcolor{comment}{                                              !! treated as the last call to step\_MOM in a}}
\DoxyCodeLine{449 \textcolor{comment}{                                              !! time-stepping cycle; missing is like true.}}
\DoxyCodeLine{450 \textcolor{keywordtype}{  real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cycle\_length\textcolor{comment}{ !< The duration of a coupled time stepping cycle [s].}}
\DoxyCodeLine{451 }
\DoxyCodeLine{452   \textcolor{comment}{! Local variables}}
\DoxyCodeLine{453   \textcolor{keywordtype}{type}(time\_type) :: Time\_seg\_start \textcolor{comment}{! Stores the dynamic or thermodynamic ocean model time at the}}
\DoxyCodeLine{454                             \textcolor{comment}{! start of this call to allow step\_MOM to temporarily change the time}}
\DoxyCodeLine{455                             \textcolor{comment}{! as seen by internal modules.}}
\DoxyCodeLine{456   \textcolor{keywordtype}{type}(time\_type) :: Time\_thermo\_start \textcolor{comment}{! Stores the ocean model thermodynamics time at the start of}}
\DoxyCodeLine{457                             \textcolor{comment}{! this call to allow step\_MOM to temporarily change the time as seen by}}
\DoxyCodeLine{458                             \textcolor{comment}{! internal modules.}}
\DoxyCodeLine{459   \textcolor{keywordtype}{type}(time\_type) :: Time1  \textcolor{comment}{! The value of the ocean model's time at the start of a call to step\_MOM.}}
\DoxyCodeLine{460   \textcolor{keywordtype}{integer} :: index\_bnds(4)  \textcolor{comment}{! The computational domain index bounds in the ice-ocean boundary type.}}
\DoxyCodeLine{461 \textcolor{keywordtype}{  real} :: weight            \textcolor{comment}{! Flux accumulation weight of the current fluxes.}}
\DoxyCodeLine{462 \textcolor{keywordtype}{  real} :: dt\_coupling       \textcolor{comment}{! The coupling time step [s].}}
\DoxyCodeLine{463 \textcolor{keywordtype}{  real} :: dt\_therm          \textcolor{comment}{! A limited and quantized version of OS\%dt\_therm [s].}}
\DoxyCodeLine{464 \textcolor{keywordtype}{  real} :: dt\_dyn            \textcolor{comment}{! The dynamics time step [s].}}
\DoxyCodeLine{465 \textcolor{keywordtype}{  real} :: dtdia             \textcolor{comment}{! The diabatic time step [s].}}
\DoxyCodeLine{466 \textcolor{keywordtype}{  real} :: t\_elapsed\_seg     \textcolor{comment}{! The elapsed time in this update segment [s].}}
\DoxyCodeLine{467   \textcolor{keywordtype}{integer} :: n              \textcolor{comment}{! The internal iteration counter.}}
\DoxyCodeLine{468   \textcolor{keywordtype}{integer} :: nts            \textcolor{comment}{! The number of baroclinic dynamics time steps in a thermodynamic step.}}
\DoxyCodeLine{469   \textcolor{keywordtype}{integer} :: n\_max          \textcolor{comment}{! The number of calls to step\_MOM dynamics in this call to update\_ocean\_model.}}
\DoxyCodeLine{470   \textcolor{keywordtype}{integer} :: n\_last\_thermo  \textcolor{comment}{! The iteration number the last time thermodynamics were updated.}}
\DoxyCodeLine{471   \textcolor{keywordtype}{logical} :: thermo\_does\_span\_coupling \textcolor{comment}{! If true, thermodynamic forcing spans multiple dynamic timesteps.}}
\DoxyCodeLine{472   \textcolor{keywordtype}{logical} :: do\_dyn         \textcolor{comment}{! If true, step the ocean dynamics and transport.}}
\DoxyCodeLine{473   \textcolor{keywordtype}{logical} :: do\_thermo      \textcolor{comment}{! If true, step the ocean thermodynamics.}}
\DoxyCodeLine{474   \textcolor{keywordtype}{logical} :: step\_thermo    \textcolor{comment}{! If true, take a thermodynamic step.}}
\DoxyCodeLine{475   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{476 }
\DoxyCodeLine{477   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"update\_ocean\_model(), ocean\_model\_MOM.F90"})}
\DoxyCodeLine{478   dt\_coupling = time\_type\_to\_real(ocean\_coupling\_time\_step)}
\DoxyCodeLine{479 }
\DoxyCodeLine{480   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{481     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"update\_ocean\_model called with an unassociated "}// \&}
\DoxyCodeLine{482                     \textcolor{stringliteral}{"ocean\_state\_type structure. ocean\_model\_init must be "}//  \&}
\DoxyCodeLine{483                     \textcolor{stringliteral}{"called first to allocate this structure."})}
\DoxyCodeLine{484     \textcolor{keywordflow}{return}}
\DoxyCodeLine{485 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{486 }
\DoxyCodeLine{487   do\_dyn = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_dyn)) do\_dyn = update\_dyn}
\DoxyCodeLine{488   do\_thermo = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_thermo)) do\_thermo = update\_thermo}
\DoxyCodeLine{489 }
\DoxyCodeLine{490   \textcolor{keywordflow}{if} (do\_thermo .and. (time\_start\_update /= os\%Time)) \&}
\DoxyCodeLine{491     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"update\_ocean\_model: internal clock does not "}//\&}
\DoxyCodeLine{492                             \textcolor{stringliteral}{"agree with time\_start\_update argument."})}
\DoxyCodeLine{493   \textcolor{keywordflow}{if} (do\_dyn .and. (time\_start\_update /= os\%Time\_dyn)) \&}
\DoxyCodeLine{494     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"update\_ocean\_model: internal dynamics clock does not "}//\&}
\DoxyCodeLine{495                             \textcolor{stringliteral}{"agree with time\_start\_update argument."})}
\DoxyCodeLine{496 }
\DoxyCodeLine{497   \textcolor{keywordflow}{if} (.not.(do\_dyn .or. do\_thermo)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{498       \textcolor{stringliteral}{"update\_ocean\_model called without updating either dynamics or thermodynamics."})}
\DoxyCodeLine{499   \textcolor{keywordflow}{if} (do\_dyn .and. do\_thermo .and. (os\%Time /= os\%Time\_dyn)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{500       \textcolor{stringliteral}{"update\_ocean\_model called to update both dynamics and thermodynamics with inconsistent clocks."})}
\DoxyCodeLine{501 }
\DoxyCodeLine{502   \textcolor{comment}{! This is benign but not necessary if ocean\_model\_init\_sfc was called or if}}
\DoxyCodeLine{503   \textcolor{comment}{! OS\%sfc\_state\%tr\_fields was spawned in ocean\_model\_init.  Consider removing it.}}
\DoxyCodeLine{504   is = os\%grid\%isc ; ie = os\%grid\%iec ; js = os\%grid\%jsc ; je = os\%grid\%jec}
\DoxyCodeLine{505   \textcolor{keyword}{call }coupler\_type\_spawn(ocean\_sfc\%fields, os\%sfc\_state\%tr\_fields, \&}
\DoxyCodeLine{506                           (/is,is,ie,ie/), (/js,js,je,je/), as\_needed=.true.)}
\DoxyCodeLine{507 }
\DoxyCodeLine{508   \textcolor{comment}{! Translate Ice\_ocean\_boundary into fluxes and forces.}}
\DoxyCodeLine{509   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc\%Domain, index\_bnds(1), index\_bnds(2), \&}
\DoxyCodeLine{510                               index\_bnds(3), index\_bnds(4))}
\DoxyCodeLine{511 }
\DoxyCodeLine{512   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}}
\DoxyCodeLine{513     \textcolor{keyword}{call }convert\_iob\_to\_forces(ice\_ocean\_boundary, os\%forces, index\_bnds, os\%Time\_dyn, os\%grid, os\%US, \&}
\DoxyCodeLine{514                                os\%forcing\_CSp, dt\_forcing=dt\_coupling, reset\_avg=os\%fluxes\%fluxes\_used)}
\DoxyCodeLine{515     \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \&}
\DoxyCodeLine{516       \textcolor{keyword}{call }add\_shelf\_forces(os\%grid, os\%US, os\%Ice\_shelf\_CSp, os\%forces)}
\DoxyCodeLine{517     \textcolor{keywordflow}{if} (os\%icebergs\_alter\_ocean) \&}
\DoxyCodeLine{518       \textcolor{keyword}{call }iceberg\_forces(os\%grid, os\%forces, os\%use\_ice\_shelf, \&}
\DoxyCodeLine{519                           os\%sfc\_state, dt\_coupling, os\%marine\_ice\_CSp)}
\DoxyCodeLine{520 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{521 }
\DoxyCodeLine{522   \textcolor{keywordflow}{if} (do\_thermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{523     \textcolor{keywordflow}{if} (os\%fluxes\%fluxes\_used) \textcolor{keywordflow}{then}}
\DoxyCodeLine{524       \textcolor{keyword}{call }convert\_iob\_to\_fluxes(ice\_ocean\_boundary, os\%fluxes, index\_bnds, os\%Time, dt\_coupling, \&}
\DoxyCodeLine{525                                  os\%grid, os\%US, os\%forcing\_CSp, os\%sfc\_state)}
\DoxyCodeLine{526 }
\DoxyCodeLine{527       \textcolor{comment}{! Add ice shelf fluxes}}
\DoxyCodeLine{528       \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \&}
\DoxyCodeLine{529         \textcolor{keyword}{call }shelf\_calc\_flux(os\%sfc\_state, os\%fluxes, os\%Time, dt\_coupling, os\%Ice\_shelf\_CSp)}
\DoxyCodeLine{530       \textcolor{keywordflow}{if} (os\%icebergs\_alter\_ocean) \&}
\DoxyCodeLine{531         \textcolor{keyword}{call }iceberg\_fluxes(os\%grid, os\%US, os\%fluxes, os\%use\_ice\_shelf, \&}
\DoxyCodeLine{532                             os\%sfc\_state, dt\_coupling, os\%marine\_ice\_CSp)}
\DoxyCodeLine{533 }
\DoxyCodeLine{534 \textcolor{preprocessor}{\#ifdef \_USE\_GENERIC\_TRACER}}
\DoxyCodeLine{535 \textcolor{preprocessor}{}      \textcolor{keyword}{call }enable\_averaging(dt\_coupling, os\%Time + ocean\_coupling\_time\_step, os\%diag) \textcolor{comment}{!Is this needed?}}
\DoxyCodeLine{536       \textcolor{keyword}{call }mom\_generic\_tracer\_fluxes\_accumulate(os\%fluxes, 1.0) \textcolor{comment}{! Here weight=1, so just store the current fluxes}}
\DoxyCodeLine{537       \textcolor{keyword}{call }disable\_averaging(os\%diag)}
\DoxyCodeLine{538 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{539 \textcolor{preprocessor}{}    \textcolor{keywordflow}{else}}
\DoxyCodeLine{540       \textcolor{comment}{! The previous fluxes have not been used yet, so translate the input fluxes}}
\DoxyCodeLine{541       \textcolor{comment}{! into a temporary type and then accumulate them in about 20 lines.}}
\DoxyCodeLine{542       os\%flux\_tmp\%C\_p = os\%fluxes\%C\_p}
\DoxyCodeLine{543       \textcolor{keyword}{call }convert\_iob\_to\_fluxes(ice\_ocean\_boundary, os\%flux\_tmp, index\_bnds, os\%Time, dt\_coupling, \&}
\DoxyCodeLine{544                                  os\%grid, os\%US, os\%forcing\_CSp, os\%sfc\_state)}
\DoxyCodeLine{545 }
\DoxyCodeLine{546       \textcolor{keywordflow}{if} (os\%use\_ice\_shelf) \&}
\DoxyCodeLine{547         \textcolor{keyword}{call }shelf\_calc\_flux(os\%sfc\_state, os\%flux\_tmp, os\%Time, dt\_coupling, os\%Ice\_shelf\_CSp)}
\DoxyCodeLine{548       \textcolor{keywordflow}{if} (os\%icebergs\_alter\_ocean) \&}
\DoxyCodeLine{549         \textcolor{keyword}{call }iceberg\_fluxes(os\%grid, os\%US, os\%flux\_tmp, os\%use\_ice\_shelf, \&}
\DoxyCodeLine{550                             os\%sfc\_state, dt\_coupling, os\%marine\_ice\_CSp)}
\DoxyCodeLine{551 }
\DoxyCodeLine{552       \textcolor{keyword}{call }fluxes\_accumulate(os\%flux\_tmp, os\%fluxes, os\%grid, weight)}
\DoxyCodeLine{553 \textcolor{preprocessor}{\#ifdef \_USE\_GENERIC\_TRACER}}
\DoxyCodeLine{554 \textcolor{preprocessor}{}       \textcolor{comment}{! Incorporate the current tracer fluxes into the running averages}}
\DoxyCodeLine{555       \textcolor{keyword}{call }mom\_generic\_tracer\_fluxes\_accumulate(os\%flux\_tmp, weight)}
\DoxyCodeLine{556 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{557 \textcolor{preprocessor}{}\textcolor{keywordflow}{    endif}}
\DoxyCodeLine{558 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{559 }
\DoxyCodeLine{560   \textcolor{comment}{! The net mass forcing is not currently used in the MOM6 dynamics solvers, so this is may be unnecessary.}}
\DoxyCodeLine{561   \textcolor{keywordflow}{if} (do\_dyn .and. \textcolor{keyword}{associated}(os\%forces\%net\_mass\_src) .and. .not.os\%forces\%net\_mass\_src\_set) \&}
\DoxyCodeLine{562     \textcolor{keyword}{call }get\_net\_mass\_forcing(os\%fluxes, os\%grid, os\%US, os\%forces\%net\_mass\_src)}
\DoxyCodeLine{563 }
\DoxyCodeLine{564   \textcolor{keywordflow}{if} (os\%use\_waves .and. do\_thermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{565     \textcolor{comment}{! For now, the waves are only updated on the thermodynamics steps, because that is where}}
\DoxyCodeLine{566     \textcolor{comment}{! the wave intensities are actually used to drive mixing.  At some point, the wave updates}}
\DoxyCodeLine{567     \textcolor{comment}{! might also need to become a part of the ocean dynamics, according to B. Reichl.}}
\DoxyCodeLine{568     \textcolor{keyword}{call }update\_surface\_waves(os\%grid, os\%GV, os\%US, os\%time, ocean\_coupling\_time\_step, os\%waves)}
\DoxyCodeLine{569 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{570 }
\DoxyCodeLine{571   \textcolor{keywordflow}{if} ((os\%nstep==0) .and. (os\%nstep\_thermo==0)) \textcolor{keywordflow}{then} \textcolor{comment}{! This is the first call to update\_ocean\_model.}}
\DoxyCodeLine{572     \textcolor{keyword}{call }finish\_mom\_initialization(os\%Time, os\%dirs, os\%MOM\_CSp, os\%restart\_CSp)}
\DoxyCodeLine{573 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{574 }
\DoxyCodeLine{575   time\_thermo\_start = os\%Time}
\DoxyCodeLine{576   time\_seg\_start = os\%Time ; \textcolor{keywordflow}{if} (do\_dyn) time\_seg\_start = os\%Time\_dyn}
\DoxyCodeLine{577   time1 = time\_seg\_start}
\DoxyCodeLine{578 }
\DoxyCodeLine{579   \textcolor{keywordflow}{if} (os\%offline\_tracer\_mode .and. do\_thermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{580     \textcolor{keyword}{call }step\_offline(os\%forces, os\%fluxes, os\%sfc\_state, time1, dt\_coupling, os\%MOM\_CSp)}
\DoxyCodeLine{581   \textcolor{keywordflow}{elseif} ((.not.do\_thermo) .or. (.not.do\_dyn)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{582     \textcolor{comment}{! The call sequence is being orchestrated from outside of update\_ocean\_model.}}
\DoxyCodeLine{583     \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dt\_coupling, os\%MOM\_CSp, \&}
\DoxyCodeLine{584                   waves=os\%Waves, do\_dynamics=do\_dyn, do\_thermodynamics=do\_thermo, \&}
\DoxyCodeLine{585                   start\_cycle=start\_cycle, end\_cycle=end\_cycle, cycle\_length=cycle\_length, \&}
\DoxyCodeLine{586                   reset\_therm=ocn\_fluxes\_used)}
\DoxyCodeLine{587   \textcolor{keywordflow}{elseif} (os\%single\_step\_call) \textcolor{keywordflow}{then}}
\DoxyCodeLine{588     \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dt\_coupling, os\%MOM\_CSp, waves=os\%Waves)}
\DoxyCodeLine{589   \textcolor{keywordflow}{else}  \textcolor{comment}{! Step both the dynamics and thermodynamics with separate calls.}}
\DoxyCodeLine{590     n\_max = 1 ; \textcolor{keywordflow}{if} (dt\_coupling > os\%dt) n\_max = ceiling(dt\_coupling/os\%dt - 0.001)}
\DoxyCodeLine{591     dt\_dyn = dt\_coupling / real(n\_max)}
\DoxyCodeLine{592     thermo\_does\_span\_coupling = (os\%thermo\_spans\_coupling .and. (os\%dt\_therm > 1.5*dt\_coupling))}
\DoxyCodeLine{593 }
\DoxyCodeLine{594     \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}}
\DoxyCodeLine{595       dt\_therm = dt\_coupling * floor(os\%dt\_therm / dt\_coupling + 0.001)}
\DoxyCodeLine{596       nts = floor(dt\_therm/dt\_dyn + 0.001)}
\DoxyCodeLine{597     \textcolor{keywordflow}{else}}
\DoxyCodeLine{598       nts = max(1,min(n\_max,floor(os\%dt\_therm/dt\_dyn + 0.001)))}
\DoxyCodeLine{599       n\_last\_thermo = 0}
\DoxyCodeLine{600 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{601 }
\DoxyCodeLine{602     time1 = time\_seg\_start ; t\_elapsed\_seg = 0.0}
\DoxyCodeLine{603     \textcolor{keywordflow}{do} n=1,n\_max}
\DoxyCodeLine{604       \textcolor{keywordflow}{if} (os\%diabatic\_first) \textcolor{keywordflow}{then}}
\DoxyCodeLine{605         \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{606             \textcolor{stringliteral}{"MOM is not yet set up to have restarts that work with "}//\&}
\DoxyCodeLine{607             \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING and DIABATIC\_FIRST."})}
\DoxyCodeLine{608         \textcolor{keywordflow}{if} (modulo(n-1,nts)==0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{609           dtdia = dt\_dyn*min(nts,n\_max-(n-1))}
\DoxyCodeLine{610           \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dtdia, os\%MOM\_CSp, \&}
\DoxyCodeLine{611                         waves=os\%Waves, do\_dynamics=.false., do\_thermodynamics=.true., \&}
\DoxyCodeLine{612                         start\_cycle=(n==1), end\_cycle=.false., cycle\_length=dt\_coupling)}
\DoxyCodeLine{613 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{614 }
\DoxyCodeLine{615         \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dt\_dyn, os\%MOM\_CSp, \&}
\DoxyCodeLine{616                       waves=os\%Waves, do\_dynamics=.true., do\_thermodynamics=.false., \&}
\DoxyCodeLine{617                       start\_cycle=.false., end\_cycle=(n==n\_max), cycle\_length=dt\_coupling)}
\DoxyCodeLine{618       \textcolor{keywordflow}{else}}
\DoxyCodeLine{619         \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dt\_dyn, os\%MOM\_CSp, \&}
\DoxyCodeLine{620                       waves=os\%Waves, do\_dynamics=.true., do\_thermodynamics=.false., \&}
\DoxyCodeLine{621                       start\_cycle=(n==1), end\_cycle=.false., cycle\_length=dt\_coupling)}
\DoxyCodeLine{622 }
\DoxyCodeLine{623         step\_thermo = .false.}
\DoxyCodeLine{624         \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}}
\DoxyCodeLine{625           dtdia = dt\_therm}
\DoxyCodeLine{626           step\_thermo = mom\_state\_is\_synchronized(os\%MOM\_CSp, adv\_dyn=.true.)}
\DoxyCodeLine{627         \textcolor{keywordflow}{elseif} ((modulo(n,nts)==0) .or. (n==n\_max)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{628           dtdia = dt\_dyn*(n - n\_last\_thermo)}
\DoxyCodeLine{629           n\_last\_thermo = n}
\DoxyCodeLine{630           step\_thermo = .true.}
\DoxyCodeLine{631 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{632 }
\DoxyCodeLine{633         \textcolor{keywordflow}{if} (step\_thermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{634           \textcolor{comment}{! Back up Time1 to the start of the thermodynamic segment.}}
\DoxyCodeLine{635           time1 = time1 - real\_to\_time(dtdia - dt\_dyn)}
\DoxyCodeLine{636           \textcolor{keyword}{call }step\_mom(os\%forces, os\%fluxes, os\%sfc\_state, time1, dtdia, os\%MOM\_CSp, \&}
\DoxyCodeLine{637                         waves=os\%Waves, do\_dynamics=.false., do\_thermodynamics=.true., \&}
\DoxyCodeLine{638                         start\_cycle=.false., end\_cycle=(n==n\_max), cycle\_length=dt\_coupling)}
\DoxyCodeLine{639 \textcolor{keywordflow}{        endif}}
\DoxyCodeLine{640 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{641 }
\DoxyCodeLine{642       t\_elapsed\_seg = t\_elapsed\_seg + dt\_dyn}
\DoxyCodeLine{643       time1 = time\_seg\_start + real\_to\_time(t\_elapsed\_seg)}
\DoxyCodeLine{644 \textcolor{keywordflow}{    enddo}}
\DoxyCodeLine{645 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{646 }
\DoxyCodeLine{647   \textcolor{keywordflow}{if} (do\_dyn) os\%Time\_dyn = time\_seg\_start + ocean\_coupling\_time\_step}
\DoxyCodeLine{648   \textcolor{keywordflow}{if} (do\_dyn) os\%nstep = os\%nstep + 1}
\DoxyCodeLine{649   os\%Time = time\_thermo\_start  \textcolor{comment}{! Reset the clock to compensate for shared pointers.}}
\DoxyCodeLine{650   \textcolor{keywordflow}{if} (do\_thermo) os\%Time = os\%Time + ocean\_coupling\_time\_step}
\DoxyCodeLine{651   \textcolor{keywordflow}{if} (do\_thermo) os\%nstep\_thermo = os\%nstep\_thermo + 1}
\DoxyCodeLine{652 }
\DoxyCodeLine{653   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}}
\DoxyCodeLine{654     \textcolor{keyword}{call }mech\_forcing\_diags(os\%forces, dt\_coupling, os\%grid, os\%Time\_dyn, os\%diag, os\%forcing\_CSp\%handles)}
\DoxyCodeLine{655 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{656 }
\DoxyCodeLine{657   \textcolor{keywordflow}{if} (os\%fluxes\%fluxes\_used .and. do\_thermo) \textcolor{keywordflow}{then}}
\DoxyCodeLine{658     \textcolor{keyword}{call }forcing\_diagnostics(os\%fluxes, os\%sfc\_state, os\%grid, os\%US, os\%Time, os\%diag, os\%forcing\_CSp\%handles)}
\DoxyCodeLine{659 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{660 }
\DoxyCodeLine{661 \textcolor{comment}{! Translate state into Ocean.}}
\DoxyCodeLine{662 \textcolor{comment}{!  call convert\_state\_to\_ocean\_type(OS\%sfc\_state, Ocean\_sfc, OS\%grid, OS\%US, \&}}
\DoxyCodeLine{663 \textcolor{comment}{!                                   Ice\_ocean\_boundary\%p, OS\%press\_to\_z)}}
\DoxyCodeLine{664   \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os\%sfc\_state, ocean\_sfc, os\%grid, os\%US)}
\DoxyCodeLine{665   time1 = os\%Time ; \textcolor{keywordflow}{if} (do\_dyn) time1 = os\%Time\_dyn}
\DoxyCodeLine{666   \textcolor{keyword}{call }coupler\_type\_send\_data(ocean\_sfc\%fields, time1)}
\DoxyCodeLine{667 }
\DoxyCodeLine{668   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"update\_ocean\_model()"})}

\end{DoxyCode}
