\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{\tt in,out}  & {\em sfc\+\_\+state} & A structure containing fields that describe the surface state of the ocean.\\
\hline
\mbox{\tt in,out}  & {\em ocean\+\_\+sfc} & A structure containing various publicly\\
\hline
\mbox{\tt in,out}  & {\em g} & The ocean\textquotesingle{}s grid structure\\
\hline
\mbox{\tt in}  & {\em us} & A dimensional unit scaling type\\
\hline
\mbox{\tt in}  & {\em patm} & The pressure at the ocean surface \mbox{[}Pa\mbox{]}.\\
\hline
\mbox{\tt 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}
821   \textcolor{keywordtype}{type}(surface),         \textcolor{keywordtype}{intent(inout)} :: sfc\_state\textcolor{comment}{ !< A structure containing fields that}
822 \textcolor{comment}{                                               !! describe the surface state of the ocean.}
823   \textcolor{keywordtype}{type}(ocean\_public\_type), &
824                  \textcolor{keywordtype}{target}, \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}
825 \textcolor{comment}{                                               !! visible ocean surface fields, whose elements}
826 \textcolor{comment}{                                               !! have their data set here.}
827   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{intent(inout)} :: G\textcolor{comment}{    !< The ocean's grid structure}
828   \textcolor{keywordtype}{type}(unit\_scale\_type), \textcolor{keywordtype}{intent(in)}    :: US\textcolor{comment}{   !< A dimensional unit scaling type}
829   \textcolor{keywordtype}{real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: patm(:,:)\textcolor{comment}{  !< The pressure at the ocean surface [Pa].}
830   \textcolor{keywordtype}{real},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: press\_to\_z\textcolor{comment}{ !< A conversion factor between pressure and}
831 \textcolor{comment}{                                               !! ocean depth in m, usually 1/(rho\_0*g) [m Pa-1].}
832   \textcolor{comment}{! Local variables}
833   \textcolor{keywordtype}{real} :: IgR0
834   \textcolor{keywordtype}{character(len=48)}  :: val\_str
835   \textcolor{keywordtype}{integer} :: isc\_bnd, iec\_bnd, jsc\_bnd, jec\_bnd
836   \textcolor{keywordtype}{integer} :: i, j, i0, j0, is, ie, js, je
837 
838   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
839   \textcolor{keyword}{call }pass\_vector(sfc\_state%u, sfc\_state%v, g%Domain)
840 
841   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc%Domain, isc\_bnd, iec\_bnd, &
842                               jsc\_bnd, jec\_bnd)
843   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(patm)) \textcolor{keywordflow}{then}
844     \textcolor{comment}{! Check that the inidicies in patm are (isc\_bnd:iec\_bnd,jsc\_bnd:jec\_bnd).}
845     \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{present}(press\_to\_z)) \textcolor{keyword}{call }mom\_error(fatal, &
846         \textcolor{stringliteral}{'convert\_state\_to\_ocean\_type: press\_to\_z must be present if patm is.'})
847 \textcolor{keywordflow}{  endif}
848 
849   i0 = is - isc\_bnd ; j0 = js - jsc\_bnd
850   \textcolor{keywordflow}{if} (sfc\_state%T\_is\_conT) \textcolor{keywordflow}{then}
851     \textcolor{comment}{! Convert the surface T from conservative T to potential T.}
852     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
853       ocean\_sfc%t\_surf(i,j) = gsw\_pt\_from\_ct(sfc\_state%SSS(i+i0,j+j0), &
854                                sfc\_state%SST(i+i0,j+j0)) + celsius\_kelvin\_offset
855 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
856   \textcolor{keywordflow}{else}
857     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
858       ocean\_sfc%t\_surf(i,j) = sfc\_state%SST(i+i0,j+j0) + celsius\_kelvin\_offset
859 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
860 \textcolor{keywordflow}{  endif}
861   \textcolor{keywordflow}{if} (sfc\_state%S\_is\_absS) \textcolor{keywordflow}{then}
862     \textcolor{comment}{! Convert the surface S from absolute salinity to practical salinity.}
863     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
864       ocean\_sfc%s\_surf(i,j) = gsw\_sp\_from\_sr(sfc\_state%SSS(i+i0,j+j0))
865 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
866   \textcolor{keywordflow}{else}
867     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
868       ocean\_sfc%s\_surf(i,j) = sfc\_state%SSS(i+i0,j+j0)
869 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
870 \textcolor{keywordflow}{  endif}
871 
872   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(patm)) \textcolor{keywordflow}{then}
873     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
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
875       ocean\_sfc%area(i,j) = us%L\_to\_m**2 * g%areaT(i+i0,j+j0)
876 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
877   \textcolor{keywordflow}{else}
878     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
879       ocean\_sfc%sea\_lev(i,j) = us%Z\_to\_m * sfc\_state%sea\_lev(i+i0,j+j0)
880       ocean\_sfc%area(i,j) = us%L\_to\_m**2 * g%areaT(i+i0,j+j0)
881 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
882 \textcolor{keywordflow}{  endif}
883 
884   \textcolor{keywordflow}{if} (\textcolor{keyword}{allocated}(sfc\_state%frazil)) \textcolor{keywordflow}{then}
885     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
886       ocean\_sfc%frazil(i,j) = us%Q\_to\_J\_kg*us%RZ\_to\_kg\_m2 * sfc\_state%frazil(i+i0,j+j0)
887 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
888 \textcolor{keywordflow}{  endif}
889 
890   \textcolor{keywordflow}{if} (ocean\_sfc%stagger == agrid) \textcolor{keywordflow}{then}
891     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
892       ocean\_sfc%u\_surf(i,j) = g%mask2dT(i+i0,j+j0) * us%L\_T\_to\_m\_s * &
893                 0.5*(sfc\_state%u(i+i0,j+j0)+sfc\_state%u(i-1+i0,j+j0))
894       ocean\_sfc%v\_surf(i,j) = g%mask2dT(i+i0,j+j0) * us%L\_T\_to\_m\_s * &
895                 0.5*(sfc\_state%v(i+i0,j+j0)+sfc\_state%v(i+i0,j-1+j0))
896 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
897   \textcolor{keywordflow}{elseif} (ocean\_sfc%stagger == bgrid\_ne) \textcolor{keywordflow}{then}
898     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
899       ocean\_sfc%u\_surf(i,j) = g%mask2dBu(i+i0,j+j0) * us%L\_T\_to\_m\_s * &
900                 0.5*(sfc\_state%u(i+i0,j+j0)+sfc\_state%u(i+i0,j+j0+1))
901       ocean\_sfc%v\_surf(i,j) = g%mask2dBu(i+i0,j+j0) * us%L\_T\_to\_m\_s * &
902                 0.5*(sfc\_state%v(i+i0,j+j0)+sfc\_state%v(i+i0+1,j+j0))
903 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
904   \textcolor{keywordflow}{elseif} (ocean\_sfc%stagger == cgrid\_ne) \textcolor{keywordflow}{then}
905     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
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)
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)
908 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
909   \textcolor{keywordflow}{else}
910     \textcolor{keyword}{write}(val\_str, \textcolor{stringliteral}{'(I8)'}) ocean\_sfc%stagger
911     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"convert\_state\_to\_ocean\_type: "}//&
912       \textcolor{stringliteral}{"Ocean\_sfc%stagger has the unrecognized value of "}//trim(val\_str))
913 \textcolor{keywordflow}{  endif}
914 
915   \textcolor{keywordflow}{if} (coupler\_type\_initialized(sfc\_state%tr\_fields)) \textcolor{keywordflow}{then}
916     \textcolor{keywordflow}{if} (.not.coupler\_type\_initialized(ocean\_sfc%fields)) \textcolor{keywordflow}{then}
917       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"convert\_state\_to\_ocean\_type: "}//&
918                \textcolor{stringliteral}{"Ocean\_sfc%fields has not been initialized."})
919 \textcolor{keywordflow}{    endif}
920     \textcolor{keyword}{call }coupler\_type\_copy\_data(sfc\_state%tr\_fields, ocean\_sfc%fields)
921 \textcolor{keywordflow}{  endif}
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}
1120   \textcolor{comment}{! Obtain the ocean grid.}
1121   \textcolor{keywordtype}{type}(ocean\_state\_type) :: OS\textcolor{comment}{              !< A structure containing the}
1122 \textcolor{comment}{                                            !! internal ocean state}
1123   \textcolor{keywordtype}{type}(ocean\_grid\_type) , \textcolor{keywordtype}{pointer} :: Gridp\textcolor{comment}{  !< The ocean's grid structure}
1124 
1125   gridp => os%grid
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{\tt in}  & {\em input\+\_\+domain} & The ocean model domain description\\
\hline
\mbox{\tt in,out}  & {\em ocean\+\_\+sfc} & A structure containing various publicly visible ocean surface properties after initialization, whose elements are allocated here.\\
\hline
\mbox{\tt in}  & {\em diag} & A structure that regulates diagnsotic output\\
\hline
\mbox{\tt in}  & {\em maskmap} & A mask indicating which virtual processors\\
\hline
\mbox{\tt 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}
763   \textcolor{keywordtype}{type}(domain2D),          \textcolor{keywordtype}{intent(in)}    :: input\_domain\textcolor{comment}{ !< The ocean model domain description}
764   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}
765 \textcolor{comment}{                                !! visible ocean surface properties after initialization, whose}
766 \textcolor{comment}{                                !! elements are allocated here.}
767   \textcolor{keywordtype}{type}(diag\_ctrl),         \textcolor{keywordtype}{intent(in)}    :: diag\textcolor{comment}{  !< A structure that regulates diagnsotic output}
768   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{dimension(:,:)}, &
769                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: maskmap\textcolor{comment}{ !< A mask indicating which virtual processors}
770 \textcolor{comment}{                                              !! are actually in use.  If missing, all are used.}
771   \textcolor{keywordtype}{type}(coupler\_1d\_bc\_type), &
772                  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: gas\_fields\_ocn\textcolor{comment}{ !< If present, this type describes the}
773 \textcolor{comment}{                                              !! ocean and surface-ice fields that will participate}
774 \textcolor{comment}{                                              !! in the calculation of additional gas or other}
775 \textcolor{comment}{                                              !! tracer fluxes.}
776 
777   \textcolor{keywordtype}{integer} :: xsz, ysz, layout(2)
778   \textcolor{comment}{! ice-ocean-boundary fields are always allocated using absolute indicies}
779   \textcolor{comment}{! and have no halos.}
780   \textcolor{keywordtype}{integer} :: isc, iec, jsc, jec
781 
782   \textcolor{keyword}{call }mpp\_get\_layout(input\_domain,layout)
783   \textcolor{keyword}{call }mpp\_get\_global\_domain(input\_domain, xsize=xsz, ysize=ysz)
784   \textcolor{keywordflow}{if} (\textcolor{keyword}{PRESENT}(maskmap)) \textcolor{keywordflow}{then}
785      \textcolor{keyword}{call }mpp\_define\_domains((/1,xsz,1,ysz/),layout,ocean\_sfc%Domain, maskmap=maskmap)
786   \textcolor{keywordflow}{else}
787      \textcolor{keyword}{call }mpp\_define\_domains((/1,xsz,1,ysz/),layout,ocean\_sfc%Domain)
788 \textcolor{keywordflow}{  endif}
789   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc%Domain, isc, iec, jsc, jec)
790 
791   \textcolor{keyword}{allocate} ( ocean\_sfc%t\_surf (isc:iec,jsc:jec), &
792              ocean\_sfc%s\_surf (isc:iec,jsc:jec), &
793              ocean\_sfc%u\_surf (isc:iec,jsc:jec), &
794              ocean\_sfc%v\_surf (isc:iec,jsc:jec), &
795              ocean\_sfc%sea\_lev(isc:iec,jsc:jec), &
796              ocean\_sfc%area   (isc:iec,jsc:jec), &
797              ocean\_sfc%frazil (isc:iec,jsc:jec))
798 
799   ocean\_sfc%t\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged sst (Kelvin) passed to atmosphere/ice model}
800   ocean\_sfc%s\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged sss (psu) passed to atmosphere/ice models}
801   ocean\_sfc%u\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged u-current (m/sec) passed to atmosphere/ice models}
802   ocean\_sfc%v\_surf(:,:)  = 0.0  \textcolor{comment}{! time averaged v-current (m/sec)  passed to atmosphere/ice models}
803   ocean\_sfc%sea\_lev(:,:) = 0.0  \textcolor{comment}{! time averaged thickness of top model grid cell (m) plus patm/rho0/grav}
804   ocean\_sfc%frazil(:,:)  = 0.0  \textcolor{comment}{! time accumulated frazil (J/m^2) passed to ice model}
805   ocean\_sfc%area(:,:)    = 0.0
806   ocean\_sfc%axes    = diag%axesT1%handles \textcolor{comment}{!diag axes to be used by coupler tracer flux diagnostics}
807 
808   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(gas\_fields\_ocn)) \textcolor{keywordflow}{then}
809     \textcolor{keyword}{call }coupler\_type\_spawn(gas\_fields\_ocn, ocean\_sfc%fields, (/isc,isc,iec,iec/), &
810                               (/jsc,jsc,jec,jec/), suffix = \textcolor{stringliteral}{'\_ocn'}, as\_needed=.true.)
811 \textcolor{keywordflow}{  endif}
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{\tt in}  & {\em ocean} & A structure containing various publicly visible ocean surface fields.\\
\hline
\mbox{\tt in}  & {\em name} & The name of the field to extract\\
\hline
\mbox{\tt 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}
1075   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}
1076 \textcolor{comment}{                                                  !! internal ocean state (intent in).}
1077   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}
1078 \textcolor{comment}{                                                  !! visible ocean surface fields.}
1079   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the field to extract}
1080   \textcolor{keywordtype}{real}                      , \textcolor{keywordtype}{intent(out)}:: \textcolor{keywordtype}{value}\textcolor{comment}{ !< The value of the named field}
1081 
1082   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}
1083   \textcolor{keywordflow}{if} (.not.os%is\_ocean\_pe) \textcolor{keywordflow}{return}
1084 
1085   \textcolor{keywordflow}{select case}(name)
1086   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'c\_p'})
1087     \textcolor{keywordtype}{value} = os%C\_p
1088 \textcolor{keywordflow}{  case default}
1089     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'get\_ocean\_grid\_data1D: unknown argument name='}//name)
1090 \textcolor{keywordflow}{  end select}
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{\tt in}  & {\em ocean} & A structure containing various publicly visible ocean surface fields.\\
\hline
\mbox{\tt in}  & {\em name} & The name of the field to extract\\
\hline
\mbox{\tt out}  & {\em array2d} & The values of the named field, it must cover only the computational domain\\
\hline
\mbox{\tt in}  & {\em isc} & The starting i-\/index of array2D\\
\hline
\mbox{\tt 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}
1013   \textcolor{keywordtype}{use }\mbox{\hyperlink{namespacemom__constants}{mom\_constants}}, \textcolor{keywordtype}{only} : celsius\_kelvin\_offset
1014   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}
1015 \textcolor{comment}{                                                  !! internal ocean state (intent in).}
1016   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}
1017 \textcolor{comment}{                                                  !! visible ocean surface fields.}
1018   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the field to extract}
1019   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(isc:,jsc:)}, \textcolor{keywordtype}{intent(out)}:: array2D\textcolor{comment}{ !< The values of the named field, it must}
1020 \textcolor{comment}{                                                  !! cover only the computational domain}
1021   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: isc\textcolor{comment}{   !< The starting i-index of array2D}
1022   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: jsc\textcolor{comment}{   !< The starting j-index of array2D}
1023 
1024   \textcolor{keywordtype}{integer} :: g\_isc, g\_iec, g\_jsc, g\_jec,g\_isd, g\_ied, g\_jsd, g\_jed, i, j
1025 
1026   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}
1027   \textcolor{keywordflow}{if} (.not.os%is\_ocean\_pe) \textcolor{keywordflow}{return}
1028 
1029 \textcolor{comment}{! The problem is %areaT is on MOM domain but Ice\_Ocean\_Boundary%... is on mpp domain.}
1030 \textcolor{comment}{! We want to return the MOM data on the mpp (compute) domain}
1031 \textcolor{comment}{! Get MOM domain extents}
1032   \textcolor{keyword}{call }mpp\_get\_compute\_domain(os%grid%Domain%mpp\_domain, g\_isc, g\_iec, g\_jsc, g\_jec)
1033   \textcolor{keyword}{call }mpp\_get\_data\_domain   (os%grid%Domain%mpp\_domain, g\_isd, g\_ied, g\_jsd, g\_jed)
1034 
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
1036 
1037 
1038   \textcolor{keywordflow}{select case}(name)
1039   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'area'})
1040      array2d(isc:,jsc:) = os%US%L\_to\_m**2*os%grid%areaT(g\_isc:g\_iec,g\_jsc:g\_jec)
1041   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'mask'})
1042      array2d(isc:,jsc:) = os%grid%mask2dT(g\_isc:g\_iec,g\_jsc:g\_jec)
1043 \textcolor{comment}{!OR same result}
1044 \textcolor{comment}{!     do j=g\_jsc,g\_jec ; do i=g\_isc,g\_iec}
1045 \textcolor{comment}{!        array2D(isc+i-g\_isc,jsc+j-g\_jsc) = OS%grid%mask2dT(i,j)}
1046 \textcolor{comment}{!     enddo ; enddo}
1047   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_surf'})
1048      array2d(isc:,jsc:) = ocean%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset
1049   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_pme'})
1050      array2d(isc:,jsc:) = ocean%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset
1051   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_runoff'})
1052      array2d(isc:,jsc:) = ocean%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset
1053   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'t\_calving'})
1054      array2d(isc:,jsc:) = ocean%t\_surf(isc:,jsc:)-celsius\_kelvin\_offset
1055   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'btfHeat'})
1056      array2d(isc:,jsc:) = 0
1057   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'cos\_rot'})
1058      array2d(isc:,jsc:) = os%grid%cos\_rot(g\_isc:g\_iec,g\_jsc:g\_jec) \textcolor{comment}{! =1}
1059   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'sin\_rot'})
1060      array2d(isc:,jsc:) = os%grid%sin\_rot(g\_isc:g\_iec,g\_jsc:g\_jec) \textcolor{comment}{! =0}
1061   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'s\_surf'})
1062      array2d(isc:,jsc:) = ocean%s\_surf(isc:,jsc:)
1063   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'sea\_lev'})
1064      array2d(isc:,jsc:) = ocean%sea\_lev(isc:,jsc:)
1065   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'frazil'})
1066      array2d(isc:,jsc:) = ocean%frazil(isc:,jsc:)
1067 \textcolor{keywordflow}{  case default}
1068      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'get\_ocean\_grid\_data2D: unknown argument name='}//name)
1069 \textcolor{keywordflow}{  end select}
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{\tt 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{\tt 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}
711   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{   !< An ocean\_public\_type structure that is}
712 \textcolor{comment}{                                                        !! to be deallocated upon termination.}
713   \textcolor{keywordtype}{type}(ocean\_state\_type),  \textcolor{keywordtype}{pointer}       :: Ocean\_state\textcolor{comment}{ !< A pointer to the structure containing}
714 \textcolor{comment}{                                                        !! the internal ocean state to be deallocated}
715 \textcolor{comment}{                                                        !! upon termination.}
716   \textcolor{keywordtype}{type}(time\_type),         \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{        !< The model time, used for writing restarts.}
717 
718   \textcolor{keyword}{call }ocean\_model\_save\_restart(ocean\_state, time)
719   \textcolor{keyword}{call }diag\_mediator\_end(time, ocean\_state%diag)
720   \textcolor{keyword}{call }mom\_end(ocean\_state%MOM\_CSp)
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{\tt 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}
951   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{pointer} :: OS\textcolor{comment}{  !< An optional pointer to the ocean state,}
952 \textcolor{comment}{                                             !! used to figure out if this is an ocean PE that}
953 \textcolor{comment}{                                             !! has already been initialized.}
954   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: verbosity\textcolor{comment}{ !< A 0-9 integer indicating a level of verbosity.}
955 
956   \textcolor{keywordtype}{logical} :: OS\_is\_set
957   \textcolor{keywordtype}{integer} :: verbose
958 
959   os\_is\_set = .false. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(os)) os\_is\_set = \textcolor{keyword}{associated}(os)
960 
961   \textcolor{comment}{! Use this to control the verbosity of output; consider rethinking this logic later.}
962   verbose = 5 ; \textcolor{keywordflow}{if} (os\_is\_set) verbose = 3
963   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(verbosity)) verbose = verbosity
964 
965   \textcolor{keyword}{call }call\_tracer\_flux\_init(verbosity=verbose)
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{\tt in}  & {\em ocean} & A structure containing various publicly visible ocean surface fields.\\
\hline
\mbox{\tt in}  & {\em name} & The name of the current (ua or va) to extract\\
\hline
\mbox{\tt out}  & {\em array2d} & The values of the named field, it must cover only the computational domain\\
\hline
\mbox{\tt in}  & {\em isc} & The starting i-\/index of array2D\\
\hline
\mbox{\tt 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}
1131 
1132   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{    !< A pointer to the structure containing the}
1133 \textcolor{comment}{                                                  !! internal ocean state (intent in).}
1134   \textcolor{keywordtype}{type}(ocean\_public\_type),    \textcolor{keywordtype}{intent(in)} :: Ocean\textcolor{comment}{ !< A structure containing various publicly}
1135 \textcolor{comment}{                                                  !! visible ocean surface fields.}
1136   \textcolor{keywordtype}{character(len=*)}          , \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{  !< The name of the current (ua or va) to extract}
1137   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(isc:,jsc:)}, \textcolor{keywordtype}{intent(out)}:: array2D\textcolor{comment}{ !< The values of the named field, it must}
1138 \textcolor{comment}{                                                  !! cover only the computational domain}
1139   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: isc\textcolor{comment}{   !< The starting i-index of array2D}
1140   \textcolor{keywordtype}{integer}                   , \textcolor{keywordtype}{intent(in)} :: jsc\textcolor{comment}{   !< The starting j-index of array2D}
1141 
1142   \textcolor{keywordtype}{type}(ocean\_grid\_type) , \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{            !< The ocean's grid structure}
1143   \textcolor{keywordtype}{type}(surface),          \textcolor{keywordtype}{pointer} :: sfc\_state\textcolor{comment}{    !< A structure containing fields that}
1144 \textcolor{comment}{                                                  !! describe the surface state of the ocean.}
1145 
1146   \textcolor{keywordtype}{integer} :: isc\_bnd, iec\_bnd, jsc\_bnd, jec\_bnd
1147   \textcolor{keywordtype}{integer} :: i, j, i0, j0
1148   \textcolor{keywordtype}{integer} :: is, ie, js, je
1149 
1150   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}
1151   \textcolor{keywordflow}{if} (.not.os%is\_ocean\_pe) \textcolor{keywordflow}{return}
1152 
1153   g => os%grid
1154   is = g%isc ; ie = g%iec ; js = g%jsc ; je = g%jec
1155 
1156   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean%Domain, isc\_bnd, iec\_bnd, &
1157                               jsc\_bnd, jec\_bnd)
1158 
1159   i0 = is - isc\_bnd ; j0 = js - jsc\_bnd
1160 
1161   sfc\_state => os%sfc\_state
1162 
1163   \textcolor{keywordflow}{select case}(name)
1164   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'ua'})
1165     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
1166       array2d(i,j) = g%mask2dT(i+i0,j+j0) * &
1167                 0.5*(sfc\_state%u(i+i0,j+j0)+sfc\_state%u(i-1+i0,j+j0))
1168 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1169   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'va'})
1170     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
1171       array2d(i,j) = g%mask2dT(i+i0,j+j0) * &
1172                 0.5*(sfc\_state%v(i+i0,j+j0)+sfc\_state%v(i+i0,j-1+j0))
1173 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1174   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'ub'})
1175     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
1176       array2d(i,j) = g%mask2dBu(i+i0,j+j0) * &
1177                 0.5*(sfc\_state%u(i+i0,j+j0)+sfc\_state%u(i+i0,j+j0+1))
1178 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1179   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'vb'})
1180     \textcolor{keywordflow}{do} j=jsc\_bnd,jec\_bnd ; \textcolor{keywordflow}{do} i=isc\_bnd,iec\_bnd
1181       array2d(i,j) = g%mask2dBu(i+i0,j+j0) * &
1182                 0.5*(sfc\_state%v(i+i0,j+j0)+sfc\_state%v(i+i0+1,j+j0))
1183 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}
1184 \textcolor{keywordflow}{  case default}
1185      \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'ocean\_model\_get\_UV\_surf: unknown argument name='}//name)
1186 \textcolor{keywordflow}{  end select}
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{\tt 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{\tt in}  & {\em time\+\_\+init} & The start time for the coupled model\textquotesingle{}s calendar\\
\hline
\mbox{\tt in}  & {\em time\+\_\+in} & The time at which to initialize the ocean model.\\
\hline
\mbox{\tt in}  & {\em wind\+\_\+stagger} & If present, the staggering of the winds that are being provided in calls to update\+\_\+ocean\+\_\+model\\
\hline
\mbox{\tt 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}
228   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{target}, &
229                        \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}
230 \textcolor{comment}{                                !! visible ocean surface properties after initialization,}
231 \textcolor{comment}{                                !! the data in this type is intent out.}
232   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{        !< A structure whose internal}
233 \textcolor{comment}{                                !! contents are private to ocean\_model\_mod that may be used to}
234 \textcolor{comment}{                                !! contain all information about the ocean's interior state.}
235   \textcolor{keywordtype}{type}(time\_type),     \textcolor{keywordtype}{intent(in)}    :: Time\_init\textcolor{comment}{ !< The start time for the coupled model's calendar}
236   \textcolor{keywordtype}{type}(time\_type),     \textcolor{keywordtype}{intent(in)}    :: Time\_in\textcolor{comment}{   !< The time at which to initialize the ocean model.}
237   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},   \textcolor{keywordtype}{intent(in)}    :: wind\_stagger\textcolor{comment}{ !< If present, the staggering of the winds that are}
238 \textcolor{comment}{                                                     !! being provided in calls to update\_ocean\_model}
239   \textcolor{keywordtype}{type}(coupler\_1d\_bc\_type), &
240              \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: gas\_fields\_ocn\textcolor{comment}{ !< If present, this type describes the}
241 \textcolor{comment}{                                              !! ocean and surface-ice fields that will participate}
242 \textcolor{comment}{                                              !! in the calculation of additional gas or other}
243 \textcolor{comment}{                                              !! tracer fluxes, and can be used to spawn related}
244 \textcolor{comment}{                                              !! internal variables in the ice model.}
245   \textcolor{comment}{! Local variables}
246   \textcolor{keywordtype}{real} :: Rho0        \textcolor{comment}{! The Boussinesq ocean density [kg m-3].}
247   \textcolor{keywordtype}{real} :: G\_Earth     \textcolor{comment}{! The gravitational acceleration [m s-2].}
248   \textcolor{keywordtype}{real} :: HFrz\textcolor{comment}{        !< If HFrz > 0 (m), melt potential will be computed.}
249 \textcolor{comment}{                      !! The actual depth over which melt potential is computed will}
250 \textcolor{comment}{                      !! min(HFrz, OBLD), where OBLD is the boundary layer depth.}
251 \textcolor{comment}{                      !! If HFrz <= 0 (default), melt potential will not be computed.}
252   \textcolor{keywordtype}{logical} :: use\_melt\_pot\textcolor{comment}{!< If true, allocate melt\_potential array}
253 
254 \textcolor{comment}{! This include declares and sets the variable "version".}
255 \textcolor{preprocessor}{#include "version\_variable.h"}
256 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"ocean\_model\_init"}  \textcolor{comment}{! This module's name.}
257   \textcolor{keywordtype}{character(len=48)}  :: stagger \textcolor{comment}{! A string indicating the staggering locations for the}
258                                 \textcolor{comment}{! surface velocities returned to the coupler.}
259   \textcolor{keywordtype}{type}(param\_file\_type) :: param\_file\textcolor{comment}{ !< A structure to parse for run-time parameters}
260   \textcolor{keywordtype}{logical} :: use\_temperature \textcolor{comment}{! If true, temperature and salinity are state variables.}
261 
262   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"ocean\_model\_init(), ocean\_model\_MOM.F90"})
263   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{then}
264     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ocean\_model\_init called with an associated "}// &
265                    \textcolor{stringliteral}{"ocean\_state\_type structure. Model is already initialized."})
266     \textcolor{keywordflow}{return}
267 \textcolor{keywordflow}{  endif}
268   \textcolor{keyword}{allocate}(os)
269 
270   os%is\_ocean\_pe = ocean\_sfc%is\_ocean\_pe
271   \textcolor{keywordflow}{if} (.not.os%is\_ocean\_pe) \textcolor{keywordflow}{return}
272 
273   os%Time = time\_in ; os%Time\_dyn = time\_in
274   \textcolor{keyword}{call }initialize\_mom(os%Time, time\_init, param\_file, os%dirs, os%MOM\_CSp, &
275                       os%restart\_CSp, time\_in, offline\_tracer\_mode=os%offline\_tracer\_mode, &
276                       diag\_ptr=os%diag, count\_calls=.true.)
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, &
278                               c\_p\_scaled=os%fluxes%C\_p, use\_temp=use\_temperature)
279 
280   \textcolor{comment}{! Read all relevant parameters and write them to the model log.}
281   \textcolor{keyword}{call }log\_version(param\_file, mdl, version, \textcolor{stringliteral}{""})
282 
283   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"SINGLE\_STEPPING\_CALL"}, os%single\_step\_call, &
284                  \textcolor{stringliteral}{"If true, advance the state of MOM with a single step "}//&
285                  \textcolor{stringliteral}{"including both dynamics and thermodynamics.  If false, "}//&
286                  \textcolor{stringliteral}{"the two phases are advanced with separate calls."}, default=.true.)
287   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT"}, os%dt, &
288                  \textcolor{stringliteral}{"The (baroclinic) dynamics time step.  The time-step that "}//&
289                  \textcolor{stringliteral}{"is actually used will be an integer fraction of the "}//&
290                  \textcolor{stringliteral}{"forcing time-step."}, units=\textcolor{stringliteral}{"s"}, fail\_if\_missing=.true.)
291   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DT\_THERM"}, os%dt\_therm, &
292                  \textcolor{stringliteral}{"The thermodynamic and tracer advection time step. "}//&
293                  \textcolor{stringliteral}{"Ideally DT\_THERM should be an integer multiple of DT "}//&
294                  \textcolor{stringliteral}{"and less than the forcing or coupling time-step, unless "}//&
295                  \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING is true, in which case DT\_THERM "}//&
296                  \textcolor{stringliteral}{"can be an integer multiple of the coupling timestep.  By "}//&
297                  \textcolor{stringliteral}{"default DT\_THERM is set to DT."}, units=\textcolor{stringliteral}{"s"}, default=os%dt)
298   \textcolor{keyword}{call }get\_param(param\_file, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING"}, os%thermo\_spans\_coupling, &
299                  \textcolor{stringliteral}{"If true, the MOM will take thermodynamic and tracer "}//&
300                  \textcolor{stringliteral}{"timesteps that can be longer than the coupling timestep. "}//&
301                  \textcolor{stringliteral}{"The actual thermodynamic timestep that is used in this "}//&
302                  \textcolor{stringliteral}{"case is the largest integer multiple of the coupling "}//&
303                  \textcolor{stringliteral}{"timestep that is less than or equal to DT\_THERM."}, default=.false.)
304   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"DIABATIC\_FIRST"}, os%diabatic\_first, &
305                  \textcolor{stringliteral}{"If true, apply diabatic and thermodynamic processes, "}//&
306                  \textcolor{stringliteral}{"including buoyancy forcing and mass gain or loss, "}//&
307                  \textcolor{stringliteral}{"before stepping the dynamics forward."}, default=.false.)
308 
309   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RESTART\_CONTROL"}, os%Restart\_control, &
310                  \textcolor{stringliteral}{"An integer whose bits encode which restart files are "}//&
311                  \textcolor{stringliteral}{"written. Add 2 (bit 1) for a time-stamped file, and odd "}//&
312                  \textcolor{stringliteral}{"(bit 0) for a non-time-stamped file.  A restart file "}//&
313                  \textcolor{stringliteral}{"will be saved at the end of the run segment for any "}//&
314                  \textcolor{stringliteral}{"non-negative value."}, default=1)
315   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"OCEAN\_SURFACE\_STAGGER"}, stagger, &
316                  \textcolor{stringliteral}{"A case-insensitive character string to indicate the "}//&
317                  \textcolor{stringliteral}{"staggering of the surface velocity field that is "}//&
318                  \textcolor{stringliteral}{"returned to the coupler.  Valid values include "}//&
319                  \textcolor{stringliteral}{"'A', 'B', or 'C'."}, default=\textcolor{stringliteral}{"C"})
320   \textcolor{keywordflow}{if} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'A'}) \textcolor{keywordflow}{then} ; ocean\_sfc%stagger = agrid
321   \textcolor{keywordflow}{elseif} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'B'}) \textcolor{keywordflow}{then} ; ocean\_sfc%stagger = bgrid\_ne
322   \textcolor{keywordflow}{elseif} (uppercase(stagger(1:1)) == \textcolor{stringliteral}{'C'}) \textcolor{keywordflow}{then} ; ocean\_sfc%stagger = cgrid\_ne
323   \textcolor{keywordflow}{else} ; \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"ocean\_model\_init: OCEAN\_SURFACE\_STAGGER = "}// &
324                         trim(stagger)//\textcolor{stringliteral}{" is invalid."}) ;\textcolor{keywordflow}{ endif}
325 
326   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"RHO\_0"}, rho0, &
327                  \textcolor{stringliteral}{"The mean ocean density used with BOUSSINESQ true to "}//&
328                  \textcolor{stringliteral}{"calculate accelerations and the mass for conservation "}//&
329                  \textcolor{stringliteral}{"properties, or with BOUSSINSEQ false to convert some "}//&
330                  \textcolor{stringliteral}{"parameters from vertical units of m to kg m-2."}, &
331                  units=\textcolor{stringliteral}{"kg m-3"}, default=1035.0)
332   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"G\_EARTH"}, g\_earth, &
333                  \textcolor{stringliteral}{"The gravitational acceleration of the Earth."}, &
334                  units=\textcolor{stringliteral}{"m s-2"}, default = 9.80)
335 
336   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICE\_SHELF"},  os%use\_ice\_shelf, &
337                  \textcolor{stringliteral}{"If true, enables the ice shelf model."}, default=.false.)
338 
339   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"ICEBERGS\_APPLY\_RIGID\_BOUNDARY"},  os%icebergs\_alter\_ocean, &
340                  \textcolor{stringliteral}{"If true, allows icebergs to change boundary condition felt by ocean"}, default=.false.)
341 
342   os%press\_to\_z = 1.0/(rho0*g\_earth)
343 
344   \textcolor{comment}{!   Consider using a run-time flag to determine whether to do the diagnostic}
345   \textcolor{comment}{! vertical integrals, since the related 3-d sums are not negligible in cost.}
346   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"HFREEZE"}, hfrz, &
347                  \textcolor{stringliteral}{"If HFREEZE > 0, melt potential will be computed. The actual depth "}//&
348                  \textcolor{stringliteral}{"over which melt potential is computed will be min(HFREEZE, OBLD), "}//&
349                  \textcolor{stringliteral}{"where OBLD is the boundary layer depth. If HFREEZE <= 0 (default), "}//&
350                  \textcolor{stringliteral}{"melt potential will not be computed."}, units=\textcolor{stringliteral}{"m"}, default=-1.0, do\_not\_log=.true.)
351 
352   \textcolor{keywordflow}{if} (hfrz .gt. 0.0) \textcolor{keywordflow}{then}
353     use\_melt\_pot=.true.
354   \textcolor{keywordflow}{else}
355     use\_melt\_pot=.false.
356 \textcolor{keywordflow}{  endif}
357 
358   \textcolor{keyword}{call }allocate\_surface\_state(os%sfc\_state, os%grid, use\_temperature, do\_integrals=.true., &
359                               gas\_fields\_ocn=gas\_fields\_ocn, use\_meltpot=use\_melt\_pot)
360 
361   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(wind\_stagger)) \textcolor{keywordflow}{then}
362     \textcolor{keyword}{call }surface\_forcing\_init(time\_in, os%grid, os%US, param\_file, os%diag, &
363                               os%forcing\_CSp, wind\_stagger)
364   \textcolor{keywordflow}{else}
365     \textcolor{keyword}{call }surface\_forcing\_init(time\_in, os%grid, os%US, param\_file, os%diag, &
366                               os%forcing\_CSp)
367 \textcolor{keywordflow}{  endif}
368 
369   \textcolor{keywordflow}{if} (os%use\_ice\_shelf)  \textcolor{keywordflow}{then}
370     \textcolor{keyword}{call }initialize\_ice\_shelf(param\_file, os%grid, os%Time, os%ice\_shelf\_CSp, &
371                               os%diag, os%forces, os%fluxes)
372 \textcolor{keywordflow}{  endif}
373   \textcolor{keywordflow}{if} (os%icebergs\_alter\_ocean)  \textcolor{keywordflow}{then}
374     \textcolor{keyword}{call }marine\_ice\_init(os%Time, os%grid, param\_file, os%diag, os%marine\_ice\_CSp)
375     \textcolor{keywordflow}{if} (.not. os%use\_ice\_shelf) &
376       \textcolor{keyword}{call }allocate\_forcing\_type(os%grid, os%fluxes, shelf=.true.)
377 \textcolor{keywordflow}{  endif}
378 
379   \textcolor{keyword}{call }get\_param(param\_file, mdl, \textcolor{stringliteral}{"USE\_WAVES"}, os%Use\_Waves, &
380        \textcolor{stringliteral}{"If true, enables surface wave modules."}, default=.false.)
381   \textcolor{keywordflow}{if} (os%use\_waves) \textcolor{keywordflow}{then}
382     \textcolor{keyword}{call }mom\_wave\_interface\_init(os%Time, os%grid, os%GV, os%US, param\_file, os%Waves, os%diag)
383   \textcolor{keywordflow}{else}
384     \textcolor{keyword}{call }mom\_wave\_interface\_init\_lite(param\_file)
385 \textcolor{keywordflow}{  endif}
386 
387   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(os%grid%Domain%maskmap)) \textcolor{keywordflow}{then}
388     \textcolor{keyword}{call }initialize\_ocean\_public\_type(os%grid%Domain%mpp\_domain, ocean\_sfc, &
389                                       os%diag, maskmap=os%grid%Domain%maskmap, &
390                                       gas\_fields\_ocn=gas\_fields\_ocn)
391   \textcolor{keywordflow}{else}
392     \textcolor{keyword}{call }initialize\_ocean\_public\_type(os%grid%Domain%mpp\_domain, ocean\_sfc, &
393                                       os%diag, gas\_fields\_ocn=gas\_fields\_ocn)
394 \textcolor{keywordflow}{  endif}
395 
396   \textcolor{comment}{! This call can only occur here if the coupler\_bc\_type variables have been}
397   \textcolor{comment}{! initialized already using the information from gas\_fields\_ocn.}
398   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(gas\_fields\_ocn)) \textcolor{keywordflow}{then}
399     \textcolor{keyword}{call }coupler\_type\_set\_diags(ocean\_sfc%fields, \textcolor{stringliteral}{"ocean\_sfc"}, &
400                                 ocean\_sfc%axes(1:2), time\_in)
401 
402     \textcolor{keyword}{call }extract\_surface\_state(os%MOM\_CSp, os%sfc\_state)
403 
404     \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os%sfc\_state, ocean\_sfc, os%grid, os%US)
405 
406 \textcolor{keywordflow}{  endif}
407 
408   \textcolor{keyword}{call }close\_param\_file(param\_file)
409   \textcolor{keyword}{call }diag\_mediator\_close\_registration(os%diag)
410 
411   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'==== Completed MOM6 Coupled Initialization ===='}, 2)
412 
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{\tt 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}
930   \textcolor{keywordtype}{type}(ocean\_state\_type),  \textcolor{keywordtype}{pointer}       :: OS\textcolor{comment}{  !< The structure with the complete ocean state}
931   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing various publicly}
932 \textcolor{comment}{                                !! visible ocean surface properties after initialization, whose}
933 \textcolor{comment}{                                !! elements have their data set here.}
934   \textcolor{keywordtype}{integer} :: is, ie, js, je
935 
936   is = os%grid%isc ; ie = os%grid%iec ; js = os%grid%jsc ; je = os%grid%jec
937   \textcolor{keyword}{call }coupler\_type\_spawn(ocean\_sfc%fields, os%sfc\_state%tr\_fields, &
938                           (/is,is,ie,ie/), (/js,js,je,je/), as\_needed=.true.)
939 
940   \textcolor{keyword}{call }extract\_surface\_state(os%MOM\_CSp, os%sfc\_state)
941 
942   \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os%sfc\_state, ocean\_sfc, os%grid, os%US)
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{\tt 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}
673   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{ !< A pointer to the structure containing the}
674 \textcolor{comment}{                                               !! internal ocean state being saved to a restart file}
675   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: timestamp\textcolor{comment}{ !< An optional timestamp string that should be}
676 \textcolor{comment}{                                               !! prepended to the file name. (Currently this is unused.)}
677 
678   \textcolor{keywordflow}{if} (.not.mom\_state\_is\_synchronized(os%MOM\_CSp)) &
679       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"End of MOM\_main reached with inconsistent "}//&
680          \textcolor{stringliteral}{"dynamics and advective times.  Additional restart fields "}//&
681          \textcolor{stringliteral}{"that have not been coded yet would be required for reproducibility."})
682   \textcolor{keywordflow}{if} (.not.os%fluxes%fluxes\_used) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_model\_restart "}//&
683       \textcolor{stringliteral}{"was called with unused buoyancy fluxes.  For conservation, the ocean "}//&
684       \textcolor{stringliteral}{"restart files can only be created after the buoyancy forcing is applied."})
685 
686   \textcolor{keywordflow}{if} (btest(os%Restart\_control,1)) \textcolor{keywordflow}{then}
687     \textcolor{keyword}{call }save\_restart(os%dirs%restart\_output\_dir, os%Time, os%grid, &
688                       os%restart\_CSp, .true., gv=os%GV)
689     \textcolor{keyword}{call }forcing\_save\_restart(os%forcing\_CSp, os%grid, os%Time, &
690                               os%dirs%restart\_output\_dir, .true.)
691     \textcolor{keywordflow}{if} (os%use\_ice\_shelf) \textcolor{keywordflow}{then}
692       \textcolor{keyword}{call }ice\_shelf\_save\_restart(os%Ice\_shelf\_CSp, os%Time, os%dirs%restart\_output\_dir, .true.)
693 \textcolor{keywordflow}{    endif}
694 \textcolor{keywordflow}{  endif}
695   \textcolor{keywordflow}{if} (btest(os%Restart\_control,0)) \textcolor{keywordflow}{then}
696     \textcolor{keyword}{call }save\_restart(os%dirs%restart\_output\_dir, os%Time, os%grid, &
697                       os%restart\_CSp, gv=os%GV)
698     \textcolor{keyword}{call }forcing\_save\_restart(os%forcing\_CSp, os%grid, os%Time, &
699                               os%dirs%restart\_output\_dir)
700     \textcolor{keywordflow}{if} (os%use\_ice\_shelf) \textcolor{keywordflow}{then}
701       \textcolor{keyword}{call }ice\_shelf\_save\_restart(os%Ice\_shelf\_CSp, os%Time, os%dirs%restart\_output\_dir)
702 \textcolor{keywordflow}{    endif}
703 \textcolor{keywordflow}{  endif}
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{\tt in}  & {\em time} & The model time at this call, needed for mpp\+\_\+write calls.\\
\hline
\mbox{\tt in}  & {\em directory} & An optional directory into which to write these restart files.\\
\hline
\mbox{\tt 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}
727   \textcolor{keywordtype}{type}(ocean\_state\_type),     \textcolor{keywordtype}{pointer}    :: OS\textcolor{comment}{  !< A pointer to the structure containing the}
728 \textcolor{comment}{                                                !! internal ocean state (in).}
729   \textcolor{keywordtype}{type}(time\_type),            \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< The model time at this call, needed for mpp\_write
       calls.}
730   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: directory\textcolor{comment}{  !<  An optional directory into which to}
731 \textcolor{comment}{                                                !! write these restart files.}
732   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: filename\_suffix\textcolor{comment}{ !< An optional suffix (e.g., a time-stamp)}
733 \textcolor{comment}{                                                !! to append to the restart file names.}
734 \textcolor{comment}{! Note: This is a new routine - it will need to exist for the new incremental}
735 \textcolor{comment}{!   checkpointing.  It will also be called by ocean\_model\_end, giving the same}
736 \textcolor{comment}{!   restart behavior as now in FMS.}
737   \textcolor{keywordtype}{character(len=200)} :: restart\_dir
738 
739   \textcolor{keywordflow}{if} (.not.mom\_state\_is\_synchronized(os%MOM\_CSp)) &
740     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"ocean\_model\_save\_restart called with inconsistent "}//&
741          \textcolor{stringliteral}{"dynamics and advective times.  Additional restart fields "}//&
742          \textcolor{stringliteral}{"that have not been coded yet would be required for reproducibility."})
743   \textcolor{keywordflow}{if} (.not.os%fluxes%fluxes\_used) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"ocean\_model\_save\_restart "}//&
744        \textcolor{stringliteral}{"was called with unused buoyancy fluxes.  For conservation, the ocean "}//&
745        \textcolor{stringliteral}{"restart files can only be created after the buoyancy forcing is applied."})
746 
747   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(directory)) \textcolor{keywordflow}{then} ; restart\_dir = directory
748   \textcolor{keywordflow}{else} ; restart\_dir = os%dirs%restart\_output\_dir ;\textcolor{keywordflow}{ endif}
749 
750   \textcolor{keyword}{call }save\_restart(restart\_dir, time, os%grid, os%restart\_CSp, gv=os%GV)
751 
752   \textcolor{keyword}{call }forcing\_save\_restart(os%forcing\_CSp, os%grid, time, restart\_dir)
753 
754   \textcolor{keywordflow}{if} (os%use\_ice\_shelf) \textcolor{keywordflow}{then}
755     \textcolor{keyword}{call }ice\_shelf\_save\_restart(os%Ice\_shelf\_CSp, os%Time, os%dirs%restart\_output\_dir)
756 \textcolor{keywordflow}{  endif}
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{\tt in}  & {\em id} & An identifying string for this call\\
\hline
\mbox{\tt in}  & {\em timestep} & The number of elapsed timesteps\\
\hline
\mbox{\tt 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}
1096 
1097   \textcolor{keywordtype}{character(len=*)},        \textcolor{keywordtype}{intent(in)} :: id\textcolor{comment}{  !< An identifying string for this call}
1098   \textcolor{keywordtype}{integer},                 \textcolor{keywordtype}{intent(in)} :: timestep\textcolor{comment}{ !< The number of elapsed timesteps}
1099   \textcolor{keywordtype}{type}(ocean\_public\_type), \textcolor{keywordtype}{intent(in)} :: ocn\textcolor{comment}{ !< A structure containing various publicly}
1100 \textcolor{comment}{                                             !! visible ocean surface fields.}
1101   \textcolor{keywordtype}{integer} :: n, m, outunit
1102 
1103   outunit = stdout()
1104 
1105   \textcolor{keyword}{write}(outunit,*) \textcolor{stringliteral}{"BEGIN CHECKSUM(ocean\_type):: "}, id, timestep
1106   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%t\_surf   '},mpp\_chksum(ocn%t\_surf )
1107   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%s\_surf   '},mpp\_chksum(ocn%s\_surf )
1108   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%u\_surf   '},mpp\_chksum(ocn%u\_surf )
1109   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%v\_surf   '},mpp\_chksum(ocn%v\_surf )
1110   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%sea\_lev  '},mpp\_chksum(ocn%sea\_lev)
1111   \textcolor{keyword}{write}(outunit,100) \textcolor{stringliteral}{'ocean%frazil   '},mpp\_chksum(ocn%frazil )
1112 
1113   \textcolor{keyword}{call }coupler\_type\_write\_chksums(ocn%fields, outunit, \textcolor{stringliteral}{'ocean%'})
1114 100 \textcolor{keyword}{FORMAT}(\textcolor{stringliteral}{"   CHECKSUM::"},a20,\textcolor{stringliteral}{" = "},z20)
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{\tt in}  & {\em index} & The stock index for the quantity of interest.\\
\hline
\mbox{\tt out}  & {\em value} & Sum returned for the conservation quantity of interest.\\
\hline
\mbox{\tt 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}
973   \textcolor{keywordtype}{use }stock\_constants\_mod, \textcolor{keywordtype}{only} : istock\_water, istock\_heat,istock\_salt
974   \textcolor{keywordtype}{type}(ocean\_state\_type), \textcolor{keywordtype}{pointer}     :: OS\textcolor{comment}{         !< A structure containing the internal ocean state.}
975 \textcolor{comment}{                                                    !! The data in OS is intent in.}
976   \textcolor{keywordtype}{integer},                \textcolor{keywordtype}{intent(in)}  :: index\textcolor{comment}{      !< The stock index for the quantity of interest.}
977   \textcolor{keywordtype}{real},                   \textcolor{keywordtype}{intent(out)} :: \textcolor{keywordtype}{value}\textcolor{comment}{      !< Sum returned for the conservation quantity of
       interest.}
978   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: time\_index\textcolor{comment}{ !< An unused optional argument, present only for}
979 \textcolor{comment}{                                                    !! interfacial compatibility with other models.}
980 \textcolor{comment}{! Arguments: OS - A structure containing the internal ocean state.}
981 \textcolor{comment}{!  (in)      index - Index of conservation quantity of interest.}
982 \textcolor{comment}{!  (in)      value -  Sum returned for the conservation quantity of interest.}
983 \textcolor{comment}{!  (in,opt)  time\_index - Index for time level to use if this is necessary.}
984 
985   \textcolor{keywordtype}{real} :: salt
986 
987   \textcolor{keywordtype}{value} = 0.0
988   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{return}
989   \textcolor{keywordflow}{if} (.not.os%is\_ocean\_pe) \textcolor{keywordflow}{return}
990 
991   \textcolor{keywordflow}{select case} (index)
992     \textcolor{keywordflow}{case} (istock\_water)  \textcolor{comment}{! Return the mass of fresh water in the ocean in kg.}
993       \textcolor{keywordflow}{if} (os%GV%Boussinesq) \textcolor{keywordflow}{then}
994         \textcolor{keyword}{call }get\_ocean\_stocks(os%MOM\_CSp, mass=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)
995       \textcolor{keywordflow}{else}  \textcolor{comment}{! In non-Boussinesq mode, the mass of salt needs to be subtracted.}
996         \textcolor{keyword}{call }get\_ocean\_stocks(os%MOM\_CSp, mass=\textcolor{keywordtype}{value}, salt=salt, on\_pe\_only=.true.)
997         \textcolor{keywordtype}{value} = \textcolor{keywordtype}{value} - salt
998 \textcolor{keywordflow}{      endif}
999     \textcolor{keywordflow}{case} (istock\_heat)  \textcolor{comment}{! Return the heat content of the ocean in J.}
1000       \textcolor{keyword}{call }get\_ocean\_stocks(os%MOM\_CSp, heat=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)
1001     \textcolor{keywordflow}{case} (istock\_salt)  \textcolor{comment}{! Return the mass of the salt in the ocean in kg.}
1002        \textcolor{keyword}{call }get\_ocean\_stocks(os%MOM\_CSp, salt=\textcolor{keywordtype}{value}, on\_pe\_only=.true.)
1003 \textcolor{keywordflow}{    case default} ; \textcolor{keywordtype}{value} = 0.0
1004 \textcolor{keywordflow}{  end select}
1005   \textcolor{comment}{! If the FMS coupler is changed so that Ocean\_stock\_PE is only called on}
1006   \textcolor{comment}{! ocean PEs, uncomment the following and eliminate the on\_PE\_only flags above.}
1007   \textcolor{comment}{!  if (.not.is\_root\_pe()) value = 0.0}
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{\tt in}  & {\em ice\+\_\+ocean\+\_\+boundary} & A structure containing the various\\
\hline
 & {\em os} & A pointer to a private structure containing the\\
\hline
\mbox{\tt in,out}  & {\em ocean\+\_\+sfc} & A structure containing all the publicly visible\\
\hline
\mbox{\tt in}  & {\em time\+\_\+start\+\_\+update} & The time at the beginning of the update step.\\
\hline
\mbox{\tt in}  & {\em ocean\+\_\+coupling\+\_\+time\+\_\+step} & The amount of time over which to advance the ocean.\\
\hline
\mbox{\tt in}  & {\em update\+\_\+dyn} & If present and false, do not do updates due to the ocean dynamics.\\
\hline
\mbox{\tt in}  & {\em update\+\_\+thermo} & If present and false, do not do updates due to the ocean thermodynamics or remapping.\\
\hline
\mbox{\tt 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{\tt 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{\tt 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{\tt 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}
424   \textcolor{keywordtype}{type}(ice\_ocean\_boundary\_type), &
425                      \textcolor{keywordtype}{intent(in)}    :: Ice\_ocean\_boundary\textcolor{comment}{ !< A structure containing the various}
426 \textcolor{comment}{                                              !! forcing fields coming from the ice and atmosphere.}
427   \textcolor{keywordtype}{type}(ocean\_state\_type), &
428                      \textcolor{keywordtype}{pointer}       :: OS\textcolor{comment}{      !< A pointer to a private structure containing the}
429 \textcolor{comment}{                                              !! internal ocean state.}
430   \textcolor{keywordtype}{type}(ocean\_public\_type), &
431                      \textcolor{keywordtype}{intent(inout)} :: Ocean\_sfc\textcolor{comment}{ !< A structure containing all the publicly visible}
432 \textcolor{comment}{                                              !! ocean surface fields after a coupling time step.}
433 \textcolor{comment}{                                              !! The data in this type is intent out.}
434   \textcolor{keywordtype}{type}(time\_type),   \textcolor{keywordtype}{intent(in)}    :: time\_start\_update\textcolor{comment}{  !< The time at the beginning of the update step.}
435   \textcolor{keywordtype}{type}(time\_type),   \textcolor{keywordtype}{intent(in)}    :: Ocean\_coupling\_time\_step\textcolor{comment}{ !< The amount of time over which to}
436 \textcolor{comment}{                                              !! advance the ocean.}
437   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: update\_dyn\textcolor{comment}{ !< If present and false, do not do updates}
438 \textcolor{comment}{                                              !! due to the ocean dynamics.}
439   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: update\_thermo\textcolor{comment}{ !< If present and false, do not do updates}
440 \textcolor{comment}{                                              !! due to the ocean thermodynamics or remapping.}
441   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: Ocn\_fluxes\_used\textcolor{comment}{ !< If present, this indicates whether the}
442 \textcolor{comment}{                                              !! cumulative thermodynamic fluxes from the ocean,}
443 \textcolor{comment}{                                              !! like frazil, have been used and should be reset.}
444   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: start\_cycle\textcolor{comment}{ !< This indicates whether this call is to be}
445 \textcolor{comment}{                                              !! treated as the first call to step\_MOM in a}
446 \textcolor{comment}{                                              !! time-stepping cycle; missing is like true.}
447   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: end\_cycle\textcolor{comment}{   !< This indicates whether this call is to be}
448 \textcolor{comment}{                                              !! treated as the last call to step\_MOM in a}
449 \textcolor{comment}{                                              !! time-stepping cycle; missing is like true.}
450   \textcolor{keywordtype}{real},    \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cycle\_length\textcolor{comment}{ !< The duration of a coupled time stepping cycle [s].}
451 
452   \textcolor{comment}{! Local variables}
453   \textcolor{keywordtype}{type}(time\_type) :: Time\_seg\_start \textcolor{comment}{! Stores the dynamic or thermodynamic ocean model time at the}
454                             \textcolor{comment}{! start of this call to allow step\_MOM to temporarily change the time}
455                             \textcolor{comment}{! as seen by internal modules.}
456   \textcolor{keywordtype}{type}(time\_type) :: Time\_thermo\_start \textcolor{comment}{! Stores the ocean model thermodynamics time at the start of}
457                             \textcolor{comment}{! this call to allow step\_MOM to temporarily change the time as seen by}
458                             \textcolor{comment}{! internal modules.}
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.}
460   \textcolor{keywordtype}{integer} :: index\_bnds(4)  \textcolor{comment}{! The computational domain index bounds in the ice-ocean boundary type.}
461   \textcolor{keywordtype}{real} :: weight            \textcolor{comment}{! Flux accumulation weight of the current fluxes.}
462   \textcolor{keywordtype}{real} :: dt\_coupling       \textcolor{comment}{! The coupling time step [s].}
463   \textcolor{keywordtype}{real} :: dt\_therm          \textcolor{comment}{! A limited and quantized version of OS%dt\_therm [s].}
464   \textcolor{keywordtype}{real} :: dt\_dyn            \textcolor{comment}{! The dynamics time step [s].}
465   \textcolor{keywordtype}{real} :: dtdia             \textcolor{comment}{! The diabatic time step [s].}
466   \textcolor{keywordtype}{real} :: t\_elapsed\_seg     \textcolor{comment}{! The elapsed time in this update segment [s].}
467   \textcolor{keywordtype}{integer} :: n              \textcolor{comment}{! The internal iteration counter.}
468   \textcolor{keywordtype}{integer} :: nts            \textcolor{comment}{! The number of baroclinic dynamics time steps in a thermodynamic step.}
469   \textcolor{keywordtype}{integer} :: n\_max          \textcolor{comment}{! The number of calls to step\_MOM dynamics in this call to update\_ocean\_model.}
470   \textcolor{keywordtype}{integer} :: n\_last\_thermo  \textcolor{comment}{! The iteration number the last time thermodynamics were updated.}
471   \textcolor{keywordtype}{logical} :: thermo\_does\_span\_coupling \textcolor{comment}{! If true, thermodynamic forcing spans multiple dynamic timesteps.}
472   \textcolor{keywordtype}{logical} :: do\_dyn         \textcolor{comment}{! If true, step the ocean dynamics and transport.}
473   \textcolor{keywordtype}{logical} :: do\_thermo      \textcolor{comment}{! If true, step the ocean thermodynamics.}
474   \textcolor{keywordtype}{logical} :: step\_thermo    \textcolor{comment}{! If true, take a thermodynamic step.}
475   \textcolor{keywordtype}{integer} :: is, ie, js, je
476 
477   \textcolor{keyword}{call }calltree\_enter(\textcolor{stringliteral}{"update\_ocean\_model(), ocean\_model\_MOM.F90"})
478   dt\_coupling = time\_type\_to\_real(ocean\_coupling\_time\_step)
479 
480   \textcolor{keywordflow}{if} (.not.\textcolor{keyword}{associated}(os)) \textcolor{keywordflow}{then}
481     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"update\_ocean\_model called with an unassociated "}// &
482                     \textcolor{stringliteral}{"ocean\_state\_type structure. ocean\_model\_init must be "}//  &
483                     \textcolor{stringliteral}{"called first to allocate this structure."})
484     \textcolor{keywordflow}{return}
485 \textcolor{keywordflow}{  endif}
486 
487   do\_dyn = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_dyn)) do\_dyn = update\_dyn
488   do\_thermo = .true. ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(update\_thermo)) do\_thermo = update\_thermo
489 
490   \textcolor{keywordflow}{if} (do\_thermo .and. (time\_start\_update /= os%Time)) &
491     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"update\_ocean\_model: internal clock does not "}//&
492                             \textcolor{stringliteral}{"agree with time\_start\_update argument."})
493   \textcolor{keywordflow}{if} (do\_dyn .and. (time\_start\_update /= os%Time\_dyn)) &
494     \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"update\_ocean\_model: internal dynamics clock does not "}//&
495                             \textcolor{stringliteral}{"agree with time\_start\_update argument."})
496 
497   \textcolor{keywordflow}{if} (.not.(do\_dyn .or. do\_thermo)) \textcolor{keyword}{call }mom\_error(fatal, &
498       \textcolor{stringliteral}{"update\_ocean\_model called without updating either dynamics or thermodynamics."})
499   \textcolor{keywordflow}{if} (do\_dyn .and. do\_thermo .and. (os%Time /= os%Time\_dyn)) \textcolor{keyword}{call }mom\_error(fatal, &
500       \textcolor{stringliteral}{"update\_ocean\_model called to update both dynamics and thermodynamics with inconsistent clocks."})
501 
502   \textcolor{comment}{! This is benign but not necessary if ocean\_model\_init\_sfc was called or if}
503   \textcolor{comment}{! OS%sfc\_state%tr\_fields was spawned in ocean\_model\_init.  Consider removing it.}
504   is = os%grid%isc ; ie = os%grid%iec ; js = os%grid%jsc ; je = os%grid%jec
505   \textcolor{keyword}{call }coupler\_type\_spawn(ocean\_sfc%fields, os%sfc\_state%tr\_fields, &
506                           (/is,is,ie,ie/), (/js,js,je,je/), as\_needed=.true.)
507 
508   \textcolor{comment}{! Translate Ice\_ocean\_boundary into fluxes and forces.}
509   \textcolor{keyword}{call }mpp\_get\_compute\_domain(ocean\_sfc%Domain, index\_bnds(1), index\_bnds(2), &
510                               index\_bnds(3), index\_bnds(4))
511 
512   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
513     \textcolor{keyword}{call }convert\_iob\_to\_forces(ice\_ocean\_boundary, os%forces, index\_bnds, os%Time\_dyn, os%grid, os%US, &
514                                os%forcing\_CSp, dt\_forcing=dt\_coupling, reset\_avg=os%fluxes%fluxes\_used)
515     \textcolor{keywordflow}{if} (os%use\_ice\_shelf) &
516       \textcolor{keyword}{call }add\_shelf\_forces(os%grid, os%US, os%Ice\_shelf\_CSp, os%forces)
517     \textcolor{keywordflow}{if} (os%icebergs\_alter\_ocean) &
518       \textcolor{keyword}{call }iceberg\_forces(os%grid, os%forces, os%use\_ice\_shelf, &
519                           os%sfc\_state, dt\_coupling, os%marine\_ice\_CSp)
520 \textcolor{keywordflow}{  endif}
521 
522   \textcolor{keywordflow}{if} (do\_thermo) \textcolor{keywordflow}{then}
523     \textcolor{keywordflow}{if} (os%fluxes%fluxes\_used) \textcolor{keywordflow}{then}
524       \textcolor{keyword}{call }convert\_iob\_to\_fluxes(ice\_ocean\_boundary, os%fluxes, index\_bnds, os%Time, dt\_coupling, &
525                                  os%grid, os%US, os%forcing\_CSp, os%sfc\_state)
526 
527       \textcolor{comment}{! Add ice shelf fluxes}
528       \textcolor{keywordflow}{if} (os%use\_ice\_shelf) &
529         \textcolor{keyword}{call }shelf\_calc\_flux(os%sfc\_state, os%fluxes, os%Time, dt\_coupling, os%Ice\_shelf\_CSp)
530       \textcolor{keywordflow}{if} (os%icebergs\_alter\_ocean) &
531         \textcolor{keyword}{call }iceberg\_fluxes(os%grid, os%US, os%fluxes, os%use\_ice\_shelf, &
532                             os%sfc\_state, dt\_coupling, os%marine\_ice\_CSp)
533 
534 \textcolor{preprocessor}{#ifdef \_USE\_GENERIC\_TRACER}
535 \textcolor{preprocessor}{}      \textcolor{keyword}{call }enable\_averaging(dt\_coupling, os%Time + ocean\_coupling\_time\_step, os%diag) \textcolor{comment}{!Is this needed?}
536       \textcolor{keyword}{call }mom\_generic\_tracer\_fluxes\_accumulate(os%fluxes, 1.0) \textcolor{comment}{! Here weight=1, so just store the current
       fluxes}
537       \textcolor{keyword}{call }disable\_averaging(os%diag)
538 \textcolor{preprocessor}{#endif}
539 \textcolor{preprocessor}{}    \textcolor{keywordflow}{else}
540       \textcolor{comment}{! The previous fluxes have not been used yet, so translate the input fluxes}
541       \textcolor{comment}{! into a temporary type and then accumulate them in about 20 lines.}
542       os%flux\_tmp%C\_p = os%fluxes%C\_p
543       \textcolor{keyword}{call }convert\_iob\_to\_fluxes(ice\_ocean\_boundary, os%flux\_tmp, index\_bnds, os%Time, dt\_coupling, &
544                                  os%grid, os%US, os%forcing\_CSp, os%sfc\_state)
545 
546       \textcolor{keywordflow}{if} (os%use\_ice\_shelf) &
547         \textcolor{keyword}{call }shelf\_calc\_flux(os%sfc\_state, os%flux\_tmp, os%Time, dt\_coupling, os%Ice\_shelf\_CSp)
548       \textcolor{keywordflow}{if} (os%icebergs\_alter\_ocean) &
549         \textcolor{keyword}{call }iceberg\_fluxes(os%grid, os%US, os%flux\_tmp, os%use\_ice\_shelf, &
550                             os%sfc\_state, dt\_coupling, os%marine\_ice\_CSp)
551 
552       \textcolor{keyword}{call }fluxes\_accumulate(os%flux\_tmp, os%fluxes, os%grid, weight)
553 \textcolor{preprocessor}{#ifdef \_USE\_GENERIC\_TRACER}
554 \textcolor{preprocessor}{}       \textcolor{comment}{! Incorporate the current tracer fluxes into the running averages}
555       \textcolor{keyword}{call }mom\_generic\_tracer\_fluxes\_accumulate(os%flux\_tmp, weight)
556 \textcolor{preprocessor}{#endif}
557 \textcolor{preprocessor}{}\textcolor{keywordflow}{    endif}
558 \textcolor{keywordflow}{  endif}
559 
560   \textcolor{comment}{! The net mass forcing is not currently used in the MOM6 dynamics solvers, so this is may be unnecessary.}
561   \textcolor{keywordflow}{if} (do\_dyn .and. \textcolor{keyword}{associated}(os%forces%net\_mass\_src) .and. .not.os%forces%net\_mass\_src\_set) &
562     \textcolor{keyword}{call }get\_net\_mass\_forcing(os%fluxes, os%grid, os%US, os%forces%net\_mass\_src)
563 
564   \textcolor{keywordflow}{if} (os%use\_waves .and. do\_thermo) \textcolor{keywordflow}{then}
565     \textcolor{comment}{! For now, the waves are only updated on the thermodynamics steps, because that is where}
566     \textcolor{comment}{! the wave intensities are actually used to drive mixing.  At some point, the wave updates}
567     \textcolor{comment}{! might also need to become a part of the ocean dynamics, according to B. Reichl.}
568     \textcolor{keyword}{call }update\_surface\_waves(os%grid, os%GV, os%US, os%time, ocean\_coupling\_time\_step, os%waves)
569 \textcolor{keywordflow}{  endif}
570 
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.}
572     \textcolor{keyword}{call }finish\_mom\_initialization(os%Time, os%dirs, os%MOM\_CSp, os%restart\_CSp)
573 \textcolor{keywordflow}{  endif}
574 
575   time\_thermo\_start = os%Time
576   time\_seg\_start = os%Time ; \textcolor{keywordflow}{if} (do\_dyn) time\_seg\_start = os%Time\_dyn
577   time1 = time\_seg\_start
578 
579   \textcolor{keywordflow}{if} (os%offline\_tracer\_mode .and. do\_thermo) \textcolor{keywordflow}{then}
580     \textcolor{keyword}{call }step\_offline(os%forces, os%fluxes, os%sfc\_state, time1, dt\_coupling, os%MOM\_CSp)
581   \textcolor{keywordflow}{elseif} ((.not.do\_thermo) .or. (.not.do\_dyn)) \textcolor{keywordflow}{then}
582     \textcolor{comment}{! The call sequence is being orchestrated from outside of update\_ocean\_model.}
583     \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dt\_coupling, os%MOM\_CSp, &
584                   waves=os%Waves, do\_dynamics=do\_dyn, do\_thermodynamics=do\_thermo, &
585                   start\_cycle=start\_cycle, end\_cycle=end\_cycle, cycle\_length=cycle\_length, &
586                   reset\_therm=ocn\_fluxes\_used)
587   \textcolor{keywordflow}{elseif} (os%single\_step\_call) \textcolor{keywordflow}{then}
588     \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dt\_coupling, os%MOM\_CSp, waves=os%Waves)
589   \textcolor{keywordflow}{else}  \textcolor{comment}{! Step both the dynamics and thermodynamics with separate calls.}
590     n\_max = 1 ; \textcolor{keywordflow}{if} (dt\_coupling > os%dt) n\_max = ceiling(dt\_coupling/os%dt - 0.001)
591     dt\_dyn = dt\_coupling / \textcolor{keywordtype}{real}(n\_max)
592     thermo\_does\_span\_coupling = (os%thermo\_spans\_coupling .and. (os%dt\_therm > 1.5*dt\_coupling))
593 
594     \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}
595       dt\_therm = dt\_coupling * floor(os%dt\_therm / dt\_coupling + 0.001)
596       nts = floor(dt\_therm/dt\_dyn + 0.001)
597     \textcolor{keywordflow}{else}
598       nts = max(1,min(n\_max,floor(os%dt\_therm/dt\_dyn + 0.001)))
599       n\_last\_thermo = 0
600 \textcolor{keywordflow}{    endif}
601 
602     time1 = time\_seg\_start ; t\_elapsed\_seg = 0.0
603     \textcolor{keywordflow}{do} n=1,n\_max
604       \textcolor{keywordflow}{if} (os%diabatic\_first) \textcolor{keywordflow}{then}
605         \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keyword}{call }mom\_error(fatal, &
606             \textcolor{stringliteral}{"MOM is not yet set up to have restarts that work with "}//&
607             \textcolor{stringliteral}{"THERMO\_SPANS\_COUPLING and DIABATIC\_FIRST."})
608         \textcolor{keywordflow}{if} (modulo(n-1,nts)==0) \textcolor{keywordflow}{then}
609           dtdia = dt\_dyn*min(nts,n\_max-(n-1))
610           \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dtdia, os%MOM\_CSp, &
611                         waves=os%Waves, do\_dynamics=.false., do\_thermodynamics=.true., &
612                         start\_cycle=(n==1), end\_cycle=.false., cycle\_length=dt\_coupling)
613 \textcolor{keywordflow}{        endif}
614 
615         \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dt\_dyn, os%MOM\_CSp, &
616                       waves=os%Waves, do\_dynamics=.true., do\_thermodynamics=.false., &
617                       start\_cycle=.false., end\_cycle=(n==n\_max), cycle\_length=dt\_coupling)
618       \textcolor{keywordflow}{else}
619         \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dt\_dyn, os%MOM\_CSp, &
620                       waves=os%Waves, do\_dynamics=.true., do\_thermodynamics=.false., &
621                       start\_cycle=(n==1), end\_cycle=.false., cycle\_length=dt\_coupling)
622 
623         step\_thermo = .false.
624         \textcolor{keywordflow}{if} (thermo\_does\_span\_coupling) \textcolor{keywordflow}{then}
625           dtdia = dt\_therm
626           step\_thermo = mom\_state\_is\_synchronized(os%MOM\_CSp, adv\_dyn=.true.)
627         \textcolor{keywordflow}{elseif} ((modulo(n,nts)==0) .or. (n==n\_max)) \textcolor{keywordflow}{then}
628           dtdia = dt\_dyn*(n - n\_last\_thermo)
629           n\_last\_thermo = n
630           step\_thermo = .true.
631 \textcolor{keywordflow}{        endif}
632 
633         \textcolor{keywordflow}{if} (step\_thermo) \textcolor{keywordflow}{then}
634           \textcolor{comment}{! Back up Time1 to the start of the thermodynamic segment.}
635           time1 = time1 - real\_to\_time(dtdia - dt\_dyn)
636           \textcolor{keyword}{call }step\_mom(os%forces, os%fluxes, os%sfc\_state, time1, dtdia, os%MOM\_CSp, &
637                         waves=os%Waves, do\_dynamics=.false., do\_thermodynamics=.true., &
638                         start\_cycle=.false., end\_cycle=(n==n\_max), cycle\_length=dt\_coupling)
639 \textcolor{keywordflow}{        endif}
640 \textcolor{keywordflow}{      endif}
641 
642       t\_elapsed\_seg = t\_elapsed\_seg + dt\_dyn
643       time1 = time\_seg\_start + real\_to\_time(t\_elapsed\_seg)
644 \textcolor{keywordflow}{    enddo}
645 \textcolor{keywordflow}{  endif}
646 
647   \textcolor{keywordflow}{if} (do\_dyn) os%Time\_dyn = time\_seg\_start + ocean\_coupling\_time\_step
648   \textcolor{keywordflow}{if} (do\_dyn) os%nstep = os%nstep + 1
649   os%Time = time\_thermo\_start  \textcolor{comment}{! Reset the clock to compensate for shared pointers.}
650   \textcolor{keywordflow}{if} (do\_thermo) os%Time = os%Time + ocean\_coupling\_time\_step
651   \textcolor{keywordflow}{if} (do\_thermo) os%nstep\_thermo = os%nstep\_thermo + 1
652 
653   \textcolor{keywordflow}{if} (do\_dyn) \textcolor{keywordflow}{then}
654     \textcolor{keyword}{call }mech\_forcing\_diags(os%forces, dt\_coupling, os%grid, os%Time\_dyn, os%diag, os%forcing\_CSp%handles)
655 \textcolor{keywordflow}{  endif}
656 
657   \textcolor{keywordflow}{if} (os%fluxes%fluxes\_used .and. do\_thermo) \textcolor{keywordflow}{then}
658     \textcolor{keyword}{call }forcing\_diagnostics(os%fluxes, os%sfc\_state, os%grid, os%US, os%Time, os%diag, os%forcing\_CSp
      %handles)
659 \textcolor{keywordflow}{  endif}
660 
661 \textcolor{comment}{! Translate state into Ocean.}
662 \textcolor{comment}{!  call convert\_state\_to\_ocean\_type(OS%sfc\_state, Ocean\_sfc, OS%grid, OS%US, &}
663 \textcolor{comment}{!                                   Ice\_ocean\_boundary%p, OS%press\_to\_z)}
664   \textcolor{keyword}{call }convert\_state\_to\_ocean\_type(os%sfc\_state, ocean\_sfc, os%grid, os%US)
665   time1 = os%Time ; \textcolor{keywordflow}{if} (do\_dyn) time1 = os%Time\_dyn
666   \textcolor{keyword}{call }coupler\_type\_send\_data(ocean\_sfc%fields, time1)
667 
668   \textcolor{keyword}{call }calltree\_leave(\textcolor{stringliteral}{"update\_ocean\_model()"})
\end{DoxyCode}
