\hypertarget{namespacemom__oda__driver__mod}{}\doxysection{mom\+\_\+oda\+\_\+driver\+\_\+mod Module Reference}
\label{namespacemom__oda__driver__mod}\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}


\doxysubsection{Detailed Description}
Interfaces for M\+O\+M6 ensembles and data assimilation. \doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}
\begin{DoxyCompactList}\small\item\em Control structure that contains a transpose of the ocean state across ensemble members. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__oda__driver__mod_1_1ptr__mpp__domain}{ptr\+\_\+mpp\+\_\+domain}}
\begin{DoxyCompactList}\small\item\em A structure with a pointer to a domain2d, to allow for the creation of arrays of pointers. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_aaaf67b8d0e0db3ba3dfe09e24d2b8b24}{init\+\_\+oda}} (Time, G, GV, CS)
\begin{DoxyCompactList}\small\item\em initialize First\+\_\+guess (prior) and Analysis grid information for all ensemble members \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_a24806346258e5d9143e233999eef0e7f}{set\+\_\+prior\+\_\+tracer}} (Time, G, GV, h, tv, CS)
\begin{DoxyCompactList}\small\item\em Copy ensemble member tracers to ensemble vector. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_aae4e3631b7c02cc28640de25af758b4a}{get\+\_\+posterior\+\_\+tracer}} (Time, CS, h, tv, increment)
\begin{DoxyCompactList}\small\item\em Returns posterior adjustments or full state Note that only those P\+Es associated with an ensemble member receive data. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_ac7821f6ee4d3a59fc8bfe505730b0059}{oda}} (Time, CS)
\begin{DoxyCompactList}\small\item\em Gather observations and sall O\+DA routines. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_a619ba9e78b8b43d33ed6210beacedd37}{oda\+\_\+end}} (CS)
\begin{DoxyCompactList}\small\item\em Finalize DA module. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__oda__driver__mod_a8fd360e7b7af465caf37c4256be70458}{init\+\_\+ocean\+\_\+ensemble}} (CS, Grid, GV, ens\+\_\+size)
\begin{DoxyCompactList}\small\item\em Initialize DA module. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_a6df570bae958c31d3aab1053484e1f5d}{set\+\_\+analysis\+\_\+time}} (Time, CS)
\begin{DoxyCompactList}\small\item\em Set the next analysis time. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_acd36611ea11bbefa2e03a2101abb4810}{save\+\_\+obs\+\_\+diff}} (filename, CS)
\begin{DoxyCompactList}\small\item\em Write observation differences to a file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__oda__driver__mod_a1591229c657f196c97b87b77ca4378a6}{apply\+\_\+oda\+\_\+tracer\+\_\+increments}} (dt, G, tv, h, CS)
\begin{DoxyCompactList}\small\item\em Apply increments to tracers. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_a1591229c657f196c97b87b77ca4378a6}\label{namespacemom__oda__driver__mod_a1591229c657f196c97b87b77ca4378a6}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!apply\_oda\_tracer\_increments@{apply\_oda\_tracer\_increments}}
\index{apply\_oda\_tracer\_increments@{apply\_oda\_tracer\_increments}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{apply\_oda\_tracer\_increments()}{apply\_oda\_tracer\_increments()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::apply\+\_\+oda\+\_\+tracer\+\_\+increments (\begin{DoxyParamCaption}\item[{real, intent(in)}]{dt,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in)}]{G,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(inout)}]{tv,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})}



Apply increments to tracers. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em dt} & The tracer timestep \mbox{[}s\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em h} & layer thickness \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & the data assimilation structure \\
\hline
\end{DoxyParams}


Definition at line 529 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{529 \textcolor{keywordtype}{  real},                     \textcolor{keywordtype}{intent(in)}    :: dt\textcolor{comment}{ !< The tracer timestep [s]}}
\DoxyCodeLine{530   \textcolor{keywordtype}{type}(ocean\_grid\_type),    \textcolor{keywordtype}{intent(in)}    :: G\textcolor{comment}{  !< ocean grid structure}}
\DoxyCodeLine{531   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),    \textcolor{keywordtype}{intent(inout)} :: tv\textcolor{comment}{ !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{532 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))},  \&}
\DoxyCodeLine{533                             \textcolor{keywordtype}{intent(in)}    :: h\textcolor{comment}{  !< layer thickness [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{534   \textcolor{keywordtype}{type}(ODA\_CS),             \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< the data assimilation structure}}
\DoxyCodeLine{535 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_aae4e3631b7c02cc28640de25af758b4a}\label{namespacemom__oda__driver__mod_aae4e3631b7c02cc28640de25af758b4a}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!get\_posterior\_tracer@{get\_posterior\_tracer}}
\index{get\_posterior\_tracer@{get\_posterior\_tracer}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{get\_posterior\_tracer()}{get\_posterior\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::get\+\_\+posterior\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), pointer}]{CS,  }\item[{real, dimension(\+:,\+:,\+:), pointer}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), pointer}]{tv,  }\item[{logical, intent(in), optional}]{increment }\end{DoxyParamCaption})}



Returns posterior adjustments or full state Note that only those P\+Es associated with an ensemble member receive data. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & the current model time \\
\hline
 & {\em cs} & ocean DA control structure \\
\hline
 & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
 & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
\mbox{\texttt{ in}}  & {\em increment} & True if returning increment only \\
\hline
\end{DoxyParams}


Definition at line 365 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{365   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< the current model time}}
\DoxyCodeLine{366   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< ocean DA control structure}}
\DoxyCodeLine{367 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{pointer} :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{368   \textcolor{keywordtype}{type}(thermo\_var\_ptrs), \textcolor{keywordtype}{pointer} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{369   \textcolor{keywordtype}{logical}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: increment\textcolor{comment}{ !< True if returning increment only}}
\DoxyCodeLine{370 }
\DoxyCodeLine{371   \textcolor{keywordtype}{type}(ocean\_control\_struct), \textcolor{keywordtype}{pointer} :: Ocean\_increment=>null()}
\DoxyCodeLine{372   \textcolor{keywordtype}{integer} :: i, j, m}
\DoxyCodeLine{373   \textcolor{keywordtype}{logical} :: used, get\_inc}
\DoxyCodeLine{374 }
\DoxyCodeLine{375   \textcolor{comment}{! return if not analysis time (retain pointers for h and tv)}}
\DoxyCodeLine{376   \textcolor{keywordflow}{if} (time < cs\%Time) \textcolor{keywordflow}{return}}
\DoxyCodeLine{377 }
\DoxyCodeLine{378 }
\DoxyCodeLine{379   \textcolor{comment}{!! switch to global pelist}}
\DoxyCodeLine{380   \textcolor{keyword}{call }set\_current\_pelist(cs\%filter\_pelist)}
\DoxyCodeLine{381   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'Getting posterior'})}
\DoxyCodeLine{382 }
\DoxyCodeLine{383   get\_inc = .true.}
\DoxyCodeLine{384   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(increment)) get\_inc = increment}
\DoxyCodeLine{385 }
\DoxyCodeLine{386   \textcolor{keywordflow}{if} (get\_inc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{387     \textcolor{keyword}{allocate}(ocean\_increment)}
\DoxyCodeLine{388     \textcolor{keyword}{call }init\_ocean\_ensemble(ocean\_increment,cs\%Grid,cs\%GV,cs\%ensemble\_size)}
\DoxyCodeLine{389     ocean\_increment\%T = cs\%Ocean\_posterior\%T -\/ cs\%Ocean\_prior\%T}
\DoxyCodeLine{390     ocean\_increment\%S = cs\%Ocean\_posterior\%S -\/ cs\%Ocean\_prior\%S}
\DoxyCodeLine{391 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{392   \textcolor{keywordflow}{do} m=1,cs\%ensemble\_size}
\DoxyCodeLine{393     \textcolor{keywordflow}{if} (get\_inc) \textcolor{keywordflow}{then}}
\DoxyCodeLine{394       \textcolor{keyword}{call }mpp\_redistribute(cs\%mpp\_domain, ocean\_increment\%T(:,:,:,m), \&}
\DoxyCodeLine{395               cs\%domains(m)\%mpp\_domain, cs\%tv\%T, complete=.true.)}
\DoxyCodeLine{396       \textcolor{keyword}{call }mpp\_redistribute(cs\%mpp\_domain, ocean\_increment\%S(:,:,:,m), \&}
\DoxyCodeLine{397               cs\%domains(m)\%mpp\_domain, cs\%tv\%S, complete=.true.)}
\DoxyCodeLine{398     \textcolor{keywordflow}{else}}
\DoxyCodeLine{399       \textcolor{keyword}{call }mpp\_redistribute(cs\%mpp\_domain, cs\%Ocean\_posterior\%T(:,:,:,m), \&}
\DoxyCodeLine{400               cs\%domains(m)\%mpp\_domain, cs\%tv\%T, complete=.true.)}
\DoxyCodeLine{401       \textcolor{keyword}{call }mpp\_redistribute(cs\%mpp\_domain, cs\%Ocean\_posterior\%S(:,:,:,m), \&}
\DoxyCodeLine{402               cs\%domains(m)\%mpp\_domain, cs\%tv\%S, complete=.true.)}
\DoxyCodeLine{403 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{404 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{405 }
\DoxyCodeLine{406   tv => cs\%tv}
\DoxyCodeLine{407   h => cs\%h}
\DoxyCodeLine{408   \textcolor{comment}{!! switch back to ensemble member pelist}}
\DoxyCodeLine{409   \textcolor{keyword}{call }set\_current\_pelist(cs\%ensemble\_pelist(cs\%ensemble\_id,:))}
\DoxyCodeLine{410 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_a8fd360e7b7af465caf37c4256be70458}\label{namespacemom__oda__driver__mod_a8fd360e7b7af465caf37c4256be70458}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!init\_ocean\_ensemble@{init\_ocean\_ensemble}}
\index{init\_ocean\_ensemble@{init\_ocean\_ensemble}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{init\_ocean\_ensemble()}{init\_ocean\_ensemble()}}
{\footnotesize\ttfamily subroutine mom\+\_\+oda\+\_\+driver\+\_\+mod\+::init\+\_\+ocean\+\_\+ensemble (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structocean__da__types__mod_1_1ocean__control__struct}{ocean\+\_\+control\+\_\+struct}}), pointer}]{CS,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{Grid,  }\item[{type(verticalgrid\+\_\+type), pointer}]{GV,  }\item[{integer, intent(in)}]{ens\+\_\+size }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Initialize DA module. 


\begin{DoxyParams}[1]{Parameters}
 & {\em cs} & Pointer to O\+DA control structure \\
\hline
 & {\em grid} & Pointer to ocean analysis grid \\
\hline
 & {\em gv} & Pointer to DA vertical grid \\
\hline
\mbox{\texttt{ in}}  & {\em ens\+\_\+size} & ensemble size \\
\hline
\end{DoxyParams}


Definition at line 448 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{448   \textcolor{keywordtype}{type}(ocean\_control\_struct), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< Pointer to ODA control structure}}
\DoxyCodeLine{449   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: Grid\textcolor{comment}{ !< Pointer to ocean analysis grid}}
\DoxyCodeLine{450   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{pointer} :: GV\textcolor{comment}{ !< Pointer to DA vertical grid}}
\DoxyCodeLine{451   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{intent(in)} :: ens\_size\textcolor{comment}{ !< ensemble size}}
\DoxyCodeLine{452 }
\DoxyCodeLine{453   \textcolor{keywordtype}{integer} :: n,is,ie,js,je,nk}
\DoxyCodeLine{454 }
\DoxyCodeLine{455   nk=gv\%ke}
\DoxyCodeLine{456   is=grid\%isd;ie=grid\%ied}
\DoxyCodeLine{457   js=grid\%jsd;je=grid\%jed}
\DoxyCodeLine{458   cs\%ensemble\_size=ens\_size}
\DoxyCodeLine{459   \textcolor{keyword}{allocate}(cs\%T(is:ie,js:je,nk,ens\_size))}
\DoxyCodeLine{460   \textcolor{keyword}{allocate}(cs\%S(is:ie,js:je,nk,ens\_size))}
\DoxyCodeLine{461   \textcolor{keyword}{allocate}(cs\%SSH(is:ie,js:je,ens\_size))}
\DoxyCodeLine{462 \textcolor{comment}{!  allocate(CS\%id\_t(ens\_size));CS\%id\_t(:)=-\/1}}
\DoxyCodeLine{463 \textcolor{comment}{!  allocate(CS\%id\_s(ens\_size));CS\%id\_s(:)=-\/1}}
\DoxyCodeLine{464 \textcolor{comment}{!  allocate(CS\%U(is:ie,js:je,nk,ens\_size))}}
\DoxyCodeLine{465 \textcolor{comment}{!  allocate(CS\%V(is:ie,js:je,nk,ens\_size))}}
\DoxyCodeLine{466 \textcolor{comment}{!  allocate(CS\%id\_u(ens\_size));CS\%id\_u(:)=-\/1}}
\DoxyCodeLine{467 \textcolor{comment}{!  allocate(CS\%id\_v(ens\_size));CS\%id\_v(:)=-\/1}}
\DoxyCodeLine{468 \textcolor{comment}{!  allocate(CS\%id\_ssh(ens\_size));CS\%id\_ssh(:)=-\/1}}
\DoxyCodeLine{469 }
\DoxyCodeLine{470   \textcolor{keywordflow}{return}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_aaaf67b8d0e0db3ba3dfe09e24d2b8b24}\label{namespacemom__oda__driver__mod_aaaf67b8d0e0db3ba3dfe09e24d2b8b24}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!init\_oda@{init\_oda}}
\index{init\_oda@{init\_oda}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{init\_oda()}{init\_oda()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::init\+\_\+oda (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(inout), pointer}]{CS }\end{DoxyParamCaption})}



initialize First\+\_\+guess (prior) and Analysis grid information for all ensemble members 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time. \\
\hline
 & {\em g} & domain and grid information for ocean model \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & The DA control structure \\
\hline
\end{DoxyParams}


Definition at line 115 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{115 }
\DoxyCodeLine{116   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< The current model time.}}
\DoxyCodeLine{117   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{ !< domain and grid information for ocean model}}
\DoxyCodeLine{118   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{119   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{  !< The DA control structure}}
\DoxyCodeLine{120 }
\DoxyCodeLine{121 \textcolor{comment}{! Local variables}}
\DoxyCodeLine{122   \textcolor{keywordtype}{type}(thermo\_var\_ptrs) :: tv\_dummy}
\DoxyCodeLine{123   \textcolor{keywordtype}{type}(dyn\_horgrid\_type), \textcolor{keywordtype}{pointer} :: dG=> null()}
\DoxyCodeLine{124   \textcolor{keywordtype}{type}(hor\_index\_type), \textcolor{keywordtype}{pointer} :: HI=> null()}
\DoxyCodeLine{125   \textcolor{keywordtype}{type}(directories) :: dirs}
\DoxyCodeLine{126 }
\DoxyCodeLine{127   \textcolor{keywordtype}{type}(grid\_type), \textcolor{keywordtype}{pointer} :: T\_grid\textcolor{comment}{ !< global tracer grid}}
\DoxyCodeLine{128 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)}, \textcolor{keywordtype}{allocatable} :: global2D, global2D\_old}
\DoxyCodeLine{129 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: lon1D, lat1D, glon1D, glat1D}
\DoxyCodeLine{130   \textcolor{keywordtype}{type}(param\_file\_type) :: PF}
\DoxyCodeLine{131   \textcolor{keywordtype}{integer} :: n, m, k, i, j, nk}
\DoxyCodeLine{132   \textcolor{keywordtype}{integer} :: is,ie,js,je,isd,ied,jsd,jed}
\DoxyCodeLine{133   \textcolor{keywordtype}{integer} :: stdout\_unit}
\DoxyCodeLine{134   \textcolor{keywordtype}{character(len=32)} :: assim\_method}
\DoxyCodeLine{135   \textcolor{keywordtype}{integer} :: npes\_pm, ens\_info(6), ni, nj}
\DoxyCodeLine{136   \textcolor{keywordtype}{character(len=128)} :: mesg}
\DoxyCodeLine{137   \textcolor{keywordtype}{character(len=32)} :: fldnam}
\DoxyCodeLine{138   \textcolor{keywordtype}{character(len=30)} :: coord\_mode}
\DoxyCodeLine{139   \textcolor{keywordtype}{character(len=200)} :: inputdir, basin\_file}
\DoxyCodeLine{140   \textcolor{keywordtype}{logical} :: reentrant\_x, reentrant\_y, tripolar\_N, symmetric}
\DoxyCodeLine{141 }
\DoxyCodeLine{142   \textcolor{keywordflow}{if} (\textcolor{keyword}{associated}(cs)) \textcolor{keyword}{call }mpp\_error(fatal,\textcolor{stringliteral}{'Calling oda\_init with associated control structure'})}
\DoxyCodeLine{143   \textcolor{keyword}{allocate}(cs)}
\DoxyCodeLine{144 \textcolor{comment}{! Use ens1 parameters , this could be changed at a later time}}
\DoxyCodeLine{145 \textcolor{comment}{! if it were desirable to have alternate parameters, e.g. for the grid}}
\DoxyCodeLine{146 \textcolor{comment}{! for the analysis}}
\DoxyCodeLine{147   \textcolor{keyword}{call }get\_mom\_input(pf,dirs,ensemble\_num=0)}
\DoxyCodeLine{148 }
\DoxyCodeLine{149   \textcolor{keyword}{call }unit\_scaling\_init(pf, cs\%US)}
\DoxyCodeLine{150 }
\DoxyCodeLine{151   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ASSIM\_METHOD"}, assim\_method,  \&}
\DoxyCodeLine{152        \textcolor{stringliteral}{"String which determines the data assimilation method "}//\&}
\DoxyCodeLine{153        \textcolor{stringliteral}{"Valid methods are: \(\backslash\)'EAKF\(\backslash\)',\(\backslash\)'OI\(\backslash\)', and \(\backslash\)'NO\_ASSIM\(\backslash\)'"}, default=\textcolor{stringliteral}{'NO\_ASSIM'})}
\DoxyCodeLine{154   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"ASSIM\_FREQUENCY"}, cs\%assim\_frequency,  \&}
\DoxyCodeLine{155        \textcolor{stringliteral}{"data assimilation frequency in hours"})}
\DoxyCodeLine{156   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"USE\_REGRIDDING"}, cs\%use\_ALE\_algorithm , \&}
\DoxyCodeLine{157                 \textcolor{stringliteral}{"If True, use the ALE algorithm (regridding/remapping).\(\backslash\)n"}//\&}
\DoxyCodeLine{158                 \textcolor{stringliteral}{"If False, use the layered isopycnal algorithm."}, default=.false. )}
\DoxyCodeLine{159   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"REENTRANT\_X"}, cs\%reentrant\_x, \&}
\DoxyCodeLine{160        \textcolor{stringliteral}{"If true, the domain is zonally reentrant."}, default=.true.)}
\DoxyCodeLine{161   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"REENTRANT\_Y"}, cs\%reentrant\_y, \&}
\DoxyCodeLine{162        \textcolor{stringliteral}{"If true, the domain is meridionally reentrant."}, \&}
\DoxyCodeLine{163        default=.false.)}
\DoxyCodeLine{164   \textcolor{keyword}{call }get\_param(pf,\textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"TRIPOLAR\_N"}, cs\%tripolar\_N, \&}
\DoxyCodeLine{165        \textcolor{stringliteral}{"Use tripolar connectivity at the northern edge of the "}//\&}
\DoxyCodeLine{166        \textcolor{stringliteral}{"domain.  With TRIPOLAR\_N, NIGLOBAL must be even."}, \&}
\DoxyCodeLine{167        default=.false.)}
\DoxyCodeLine{168   \textcolor{keyword}{call }get\_param(pf,\textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"NIGLOBAL"}, cs\%ni, \&}
\DoxyCodeLine{169        \textcolor{stringliteral}{"The total number of thickness grid points in the "}//\&}
\DoxyCodeLine{170        \textcolor{stringliteral}{"x-\/direction in the physical domain."})}
\DoxyCodeLine{171   \textcolor{keyword}{call }get\_param(pf,\textcolor{stringliteral}{"MOM"}, \textcolor{stringliteral}{"NJGLOBAL"}, cs\%nj, \&}
\DoxyCodeLine{172        \textcolor{stringliteral}{"The total number of thickness grid points in the "}//\&}
\DoxyCodeLine{173        \textcolor{stringliteral}{"y-\/direction in the physical domain."})}
\DoxyCodeLine{174   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{'MOM'}, \textcolor{stringliteral}{"INPUTDIR"}, inputdir)}
\DoxyCodeLine{175   inputdir = slasher(inputdir)}
\DoxyCodeLine{176 }
\DoxyCodeLine{177   \textcolor{keywordflow}{select case}(lowercase(trim(assim\_method)))}
\DoxyCodeLine{178   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'eakf'})}
\DoxyCodeLine{179       cs\%assim\_method = eakf\_assim}
\DoxyCodeLine{180   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'oi'})}
\DoxyCodeLine{181      cs\%assim\_method = oi\_assim}
\DoxyCodeLine{182   \textcolor{keywordflow}{case}(\textcolor{stringliteral}{'no\_assim'})}
\DoxyCodeLine{183       cs\%assim\_method = no\_assim}
\DoxyCodeLine{184 \textcolor{keywordflow}{  case default}}
\DoxyCodeLine{185       \textcolor{keyword}{call }mpp\_error(fatal,\textcolor{stringliteral}{'Invalid assimilation method provided'})}
\DoxyCodeLine{186 \textcolor{keywordflow}{  end select}}
\DoxyCodeLine{187 }
\DoxyCodeLine{188   ens\_info = get\_ensemble\_size()}
\DoxyCodeLine{189   cs\%ensemble\_size = ens\_info(1)}
\DoxyCodeLine{190   npes\_pm=ens\_info(3)}
\DoxyCodeLine{191   cs\%ensemble\_id = get\_ensemble\_id()}
\DoxyCodeLine{192   \textcolor{comment}{!! Switch to global pelist}}
\DoxyCodeLine{193   \textcolor{keyword}{allocate}(cs\%ensemble\_pelist(cs\%ensemble\_size,npes\_pm))}
\DoxyCodeLine{194   \textcolor{keyword}{allocate}(cs\%filter\_pelist(cs\%ensemble\_size*npes\_pm))}
\DoxyCodeLine{195   \textcolor{keyword}{call }get\_ensemble\_pelist(cs\%ensemble\_pelist,\textcolor{stringliteral}{'ocean'})}
\DoxyCodeLine{196   \textcolor{keyword}{call }get\_ensemble\_filter\_pelist(cs\%filter\_pelist,\textcolor{stringliteral}{'ocean'})}
\DoxyCodeLine{197 }
\DoxyCodeLine{198   \textcolor{keyword}{call }set\_current\_pelist(cs\%filter\_pelist)}
\DoxyCodeLine{199 }
\DoxyCodeLine{200   \textcolor{keyword}{allocate}(cs\%domains(cs\%ensemble\_size))}
\DoxyCodeLine{201   cs\%domains(cs\%ensemble\_id)\%mpp\_domain => g\%Domain\%mpp\_domain}
\DoxyCodeLine{202   \textcolor{keywordflow}{do} n=1,cs\%ensemble\_size}
\DoxyCodeLine{203     \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs\%domains(n)\%mpp\_domain)) \textcolor{keyword}{allocate}(cs\%domains(n)\%mpp\_domain)}
\DoxyCodeLine{204     \textcolor{keyword}{call }set\_root\_pe(cs\%ensemble\_pelist(n,1))}
\DoxyCodeLine{205     \textcolor{keyword}{call }mpp\_broadcast\_domain(cs\%domains(n)\%mpp\_domain)}
\DoxyCodeLine{206 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{207   \textcolor{keyword}{call }set\_root\_pe(cs\%filter\_pelist(1))}
\DoxyCodeLine{208   \textcolor{keyword}{allocate}(cs\%Grid)}
\DoxyCodeLine{209   \textcolor{comment}{! params NIHALO\_ODA, NJHALO\_ODA set the DA halo size}}
\DoxyCodeLine{210   \textcolor{keyword}{call }mom\_domains\_init(cs\%Grid\%Domain,pf,param\_suffix=\textcolor{stringliteral}{'\_ODA'})}
\DoxyCodeLine{211   \textcolor{keyword}{allocate}(hi)}
\DoxyCodeLine{212   \textcolor{keyword}{call }hor\_index\_init(cs\%Grid\%Domain, hi, pf, \&}
\DoxyCodeLine{213                       local\_indexing=.false.)  \textcolor{comment}{! Use global indexing for DA}}
\DoxyCodeLine{214   \textcolor{keyword}{call }verticalgridinit( pf, cs\%GV, cs\%US )}
\DoxyCodeLine{215   \textcolor{keyword}{allocate}(dg)}
\DoxyCodeLine{216   \textcolor{keyword}{call }create\_dyn\_horgrid(dg, hi)}
\DoxyCodeLine{217   \textcolor{keyword}{call }clone\_mom\_domain(cs\%Grid\%Domain, dg\%Domain,symmetric=.false.)}
\DoxyCodeLine{218   \textcolor{keyword}{call }set\_grid\_metrics(dg,pf)}
\DoxyCodeLine{219   \textcolor{keyword}{call }mom\_initialize\_topography(dg\%bathyT,dg\%max\_depth,dg,pf)}
\DoxyCodeLine{220   \textcolor{keyword}{call }mom\_initialize\_coord(cs\%GV, cs\%US, pf, .false., \&}
\DoxyCodeLine{221            dirs\%output\_directory, tv\_dummy, dg\%max\_depth)}
\DoxyCodeLine{222   \textcolor{keyword}{call }ale\_init(pf, cs\%GV, cs\%US, dg\%max\_depth, cs\%ALE\_CS)}
\DoxyCodeLine{223   \textcolor{keyword}{call }mom\_grid\_init(cs\%Grid, pf, global\_indexing=.true.)}
\DoxyCodeLine{224   \textcolor{keyword}{call }ale\_updateverticalgridtype(cs\%ALE\_CS, cs\%GV)}
\DoxyCodeLine{225   \textcolor{keyword}{call }copy\_dyngrid\_to\_mom\_grid(dg, cs\%Grid, cs\%US)}
\DoxyCodeLine{226   cs\%mpp\_domain => cs\%Grid\%Domain\%mpp\_domain}
\DoxyCodeLine{227   cs\%Grid\%ke = cs\%GV\%ke}
\DoxyCodeLine{228   cs\%nk = cs\%GV\%ke}
\DoxyCodeLine{229   \textcolor{comment}{! initialize storage for prior and posterior}}
\DoxyCodeLine{230   \textcolor{keyword}{allocate}(cs\%Ocean\_prior)}
\DoxyCodeLine{231   \textcolor{keyword}{call }init\_ocean\_ensemble(cs\%Ocean\_prior,cs\%Grid,cs\%GV,cs\%ensemble\_size)}
\DoxyCodeLine{232   \textcolor{keyword}{allocate}(cs\%Ocean\_posterior)}
\DoxyCodeLine{233   \textcolor{keyword}{call }init\_ocean\_ensemble(cs\%Ocean\_posterior,cs\%Grid,cs\%GV,cs\%ensemble\_size)}
\DoxyCodeLine{234   \textcolor{keyword}{allocate}(cs\%tv)}
\DoxyCodeLine{235 }
\DoxyCodeLine{236   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{'oda\_driver'}, \textcolor{stringliteral}{"REGRIDDING\_COORDINATE\_MODE"}, coord\_mode, \&}
\DoxyCodeLine{237        \textcolor{stringliteral}{"Coordinate mode for vertical regridding."}, \&}
\DoxyCodeLine{238        default=\textcolor{stringliteral}{"ZSTAR"}, fail\_if\_missing=.false.)}
\DoxyCodeLine{239   \textcolor{keyword}{call }initialize\_regridding(cs\%regridCS, cs\%GV, cs\%US, dg\%max\_depth,pf,\textcolor{stringliteral}{'oda\_driver'},coord\_mode,\textcolor{stringliteral}{''},\textcolor{stringliteral}{''})}
\DoxyCodeLine{240   \textcolor{keyword}{call }initialize\_remapping(cs\%remapCS,\textcolor{stringliteral}{'PLM'})}
\DoxyCodeLine{241   \textcolor{keyword}{call }set\_regrid\_params(cs\%regridCS, min\_thickness=0.)}
\DoxyCodeLine{242   \textcolor{keyword}{call }mpp\_get\_data\_domain(g\%Domain\%mpp\_domain,isd,ied,jsd,jed)}
\DoxyCodeLine{243   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs\%h)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{244     \textcolor{keyword}{allocate}(cs\%h(isd:ied,jsd:jed,cs\%GV\%ke)); cs\%h(:,:,:)=0.0}
\DoxyCodeLine{245     \textcolor{comment}{! assign thicknesses}}
\DoxyCodeLine{246     \textcolor{keyword}{call }ale\_initthicknesstocoord(cs\%ALE\_CS,g,cs\%GV,cs\%h)}
\DoxyCodeLine{247 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{248   \textcolor{keyword}{allocate}(cs\%tv\%T(isd:ied,jsd:jed,cs\%GV\%ke)); cs\%tv\%T(:,:,:)=0.0}
\DoxyCodeLine{249   \textcolor{keyword}{allocate}(cs\%tv\%S(isd:ied,jsd:jed,cs\%GV\%ke)); cs\%tv\%S(:,:,:)=0.0}
\DoxyCodeLine{250 }
\DoxyCodeLine{251   \textcolor{keyword}{call }set\_axes\_info(cs\%Grid, cs\%GV, cs\%US, pf, cs\%diag\_cs, set\_vertical=.true.)}
\DoxyCodeLine{252 }
\DoxyCodeLine{253   \textcolor{keyword}{call }mpp\_get\_data\_domain(cs\%mpp\_domain,isd,ied,jsd,jed)}
\DoxyCodeLine{254   \textcolor{keyword}{allocate}(cs\%oda\_grid)}
\DoxyCodeLine{255   cs\%oda\_grid\%x => cs\%Grid\%geolonT}
\DoxyCodeLine{256   cs\%oda\_grid\%y => cs\%Grid\%geolatT}
\DoxyCodeLine{257 }
\DoxyCodeLine{258   \textcolor{keyword}{call }get\_param(pf, \textcolor{stringliteral}{'oda\_driver'}, \textcolor{stringliteral}{"BASIN\_FILE"}, basin\_file, \&}
\DoxyCodeLine{259           \textcolor{stringliteral}{"A file in which to find the basin masks, in variable 'basin'."}, \&}
\DoxyCodeLine{260           default=\textcolor{stringliteral}{"basin.nc"})}
\DoxyCodeLine{261   basin\_file = trim(inputdir) // trim(basin\_file)}
\DoxyCodeLine{262   \textcolor{keyword}{allocate}(cs\%oda\_grid\%basin\_mask(isd:ied,jsd:jed))}
\DoxyCodeLine{263   cs\%oda\_grid\%basin\_mask(:,:) = 0.0}
\DoxyCodeLine{264   \textcolor{keyword}{call }mom\_read\_data(basin\_file,\textcolor{stringliteral}{'basin'},cs\%oda\_grid\%basin\_mask,cs\%Grid\%domain, timelevel=1)}
\DoxyCodeLine{265 }
\DoxyCodeLine{266 \textcolor{comment}{!    get global grid information from ocean\_model}}
\DoxyCodeLine{267   \textcolor{keyword}{allocate}(t\_grid)}
\DoxyCodeLine{268   \textcolor{keyword}{allocate}(t\_grid\%x(cs\%ni,cs\%nj))}
\DoxyCodeLine{269   \textcolor{keyword}{allocate}(t\_grid\%y(cs\%ni,cs\%nj))}
\DoxyCodeLine{270   \textcolor{keyword}{allocate}(t\_grid\%basin\_mask(cs\%ni,cs\%nj))}
\DoxyCodeLine{271   \textcolor{keyword}{call }mpp\_global\_field(cs\%mpp\_domain, cs\%Grid\%geolonT, t\_grid\%x)}
\DoxyCodeLine{272   \textcolor{keyword}{call }mpp\_global\_field(cs\%mpp\_domain, cs\%Grid\%geolatT, t\_grid\%y)}
\DoxyCodeLine{273   \textcolor{keyword}{call }mpp\_global\_field(cs\%mpp\_domain, cs\%oda\_grid\%basin\_mask, t\_grid\%basin\_mask)}
\DoxyCodeLine{274   t\_grid\%ni = cs\%ni}
\DoxyCodeLine{275   t\_grid\%nj = cs\%nj}
\DoxyCodeLine{276   t\_grid\%nk = cs\%nk}
\DoxyCodeLine{277   \textcolor{keyword}{allocate}(t\_grid\%mask(cs\%ni,cs\%nj,cs\%nk))}
\DoxyCodeLine{278   \textcolor{keyword}{allocate}(t\_grid\%z(cs\%ni,cs\%nj,cs\%nk))}
\DoxyCodeLine{279   \textcolor{keyword}{allocate}(global2d(cs\%ni,cs\%nj))}
\DoxyCodeLine{280   \textcolor{keyword}{allocate}(global2d\_old(cs\%ni,cs\%nj))}
\DoxyCodeLine{281   t\_grid\%mask(:,:,:) = 0.0}
\DoxyCodeLine{282   t\_grid\%z(:,:,:) = 0.0}
\DoxyCodeLine{283 }
\DoxyCodeLine{284   \textcolor{keywordflow}{do} k = 1, cs\%nk}
\DoxyCodeLine{285     \textcolor{keyword}{call }mpp\_global\_field(g\%Domain\%mpp\_domain, cs\%h(:,:,k), global2d)}
\DoxyCodeLine{286     \textcolor{keywordflow}{do} i=1, cs\%ni; \textcolor{keywordflow}{do} j=1, cs\%nj}
\DoxyCodeLine{287       \textcolor{keywordflow}{if} ( global2d(i,j) > 1 ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{288         t\_grid\%mask(i,j,k) = 1.0}
\DoxyCodeLine{289 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{290 \textcolor{keywordflow}{    enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{291     \textcolor{keywordflow}{if} (k == 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{292       t\_grid\%z(:,:,k) = global2d/2}
\DoxyCodeLine{293     \textcolor{keywordflow}{else}}
\DoxyCodeLine{294       t\_grid\%z(:,:,k) = t\_grid\%z(:,:,k-\/1) + (global2d + global2d\_old)/2}
\DoxyCodeLine{295 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{296     global2d\_old = global2d}
\DoxyCodeLine{297 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{298 }
\DoxyCodeLine{299   \textcolor{keyword}{call }ocean\_da\_core\_init(cs\%mpp\_domain, t\_grid, cs\%Profiles, time)}
\DoxyCodeLine{300 }
\DoxyCodeLine{301   cs\%Time=time}
\DoxyCodeLine{302   \textcolor{comment}{!! switch back to ensemble member pelist}}
\DoxyCodeLine{303   \textcolor{keyword}{call }set\_current\_pelist(cs\%ensemble\_pelist(cs\%ensemble\_id,:))}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_ac7821f6ee4d3a59fc8bfe505730b0059}\label{namespacemom__oda__driver__mod_ac7821f6ee4d3a59fc8bfe505730b0059}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!oda@{oda}}
\index{oda@{oda}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{oda()}{oda()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::oda (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})}



Gather observations and sall O\+DA routines. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & the current model time \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & the ocean DA control structure \\
\hline
\end{DoxyParams}


Definition at line 415 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{415   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< the current model time}}
\DoxyCodeLine{416   \textcolor{keywordtype}{type}(oda\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< the ocean DA control structure}}
\DoxyCodeLine{417 }
\DoxyCodeLine{418   \textcolor{keywordtype}{integer} :: i, j}
\DoxyCodeLine{419   \textcolor{keywordtype}{integer} :: m}
\DoxyCodeLine{420   \textcolor{keywordtype}{integer} :: yr, mon, day, hr, min, sec}
\DoxyCodeLine{421 }
\DoxyCodeLine{422   \textcolor{keywordflow}{if} ( time >= cs\%Time ) \textcolor{keywordflow}{then}}
\DoxyCodeLine{423 }
\DoxyCodeLine{424     \textcolor{comment}{!! switch to global pelist}}
\DoxyCodeLine{425     \textcolor{keyword}{call }set\_current\_pelist(cs\%filter\_pelist)}
\DoxyCodeLine{426 }
\DoxyCodeLine{427     \textcolor{keyword}{call }get\_profiles(time, cs\%Profiles, cs\%CProfiles)}
\DoxyCodeLine{428 \textcolor{preprocessor}{\#ifdef ENABLE\_ECDA}}
\DoxyCodeLine{429 \textcolor{preprocessor}{}    \textcolor{keyword}{call }ensemble\_filter(cs\%Ocean\_prior, cs\%Ocean\_posterior, cs\%CProfiles, cs\%kdroot, cs\%mpp\_domain, cs\%oda\_grid)}
\DoxyCodeLine{430 \textcolor{preprocessor}{\#endif}}
\DoxyCodeLine{431 \textcolor{preprocessor}{}}
\DoxyCodeLine{432     \textcolor{comment}{!! switch back to ensemble member pelist}}
\DoxyCodeLine{433     \textcolor{keyword}{call }set\_current\_pelist(cs\%ensemble\_pelist(cs\%ensemble\_id,:))}
\DoxyCodeLine{434 }
\DoxyCodeLine{435 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{436 }
\DoxyCodeLine{437   \textcolor{keywordflow}{return}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_a619ba9e78b8b43d33ed6210beacedd37}\label{namespacemom__oda__driver__mod_a619ba9e78b8b43d33ed6210beacedd37}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!oda\_end@{oda\_end}}
\index{oda\_end@{oda\_end}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{oda\_end()}{oda\_end()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::oda\+\_\+end (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(inout)}]{CS }\end{DoxyParamCaption})}



Finalize DA module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em cs} & the ocean DA control structure \\
\hline
\end{DoxyParams}


Definition at line 442 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{442   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< the ocean DA control structure}}
\DoxyCodeLine{443 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_acd36611ea11bbefa2e03a2101abb4810}\label{namespacemom__oda__driver__mod_acd36611ea11bbefa2e03a2101abb4810}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!save\_obs\_diff@{save\_obs\_diff}}
\index{save\_obs\_diff@{save\_obs\_diff}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{save\_obs\_diff()}{save\_obs\_diff()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::save\+\_\+obs\+\_\+diff (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(in), pointer}]{CS }\end{DoxyParamCaption})}



Write observation differences to a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & name of output file \\
\hline
\mbox{\texttt{ in}}  & {\em cs} & pointer to DA control structure \\
\hline
\end{DoxyParams}


Definition at line 502 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{502   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{ !< name of output file}}
\DoxyCodeLine{503   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(in)} :: CS\textcolor{comment}{  !< pointer to DA control structure}}
\DoxyCodeLine{504 }
\DoxyCodeLine{505   \textcolor{keywordtype}{integer} :: fid \textcolor{comment}{! profile file handle}}
\DoxyCodeLine{506   \textcolor{keywordtype}{type}(ocean\_profile\_type), \textcolor{keywordtype}{pointer} :: Prof=>null()}
\DoxyCodeLine{507 }
\DoxyCodeLine{508   fid = open\_profile\_file(trim(filename), nvar=2, thread=mpp\_single, fset=mpp\_single)}
\DoxyCodeLine{509   prof=>cs\%CProfiles}
\DoxyCodeLine{510 }
\DoxyCodeLine{511   \textcolor{comment}{!! switch to global pelist}}
\DoxyCodeLine{512   \textcolor{comment}{!call set\_current\_pelist(CS\%filter\_pelist)}}
\DoxyCodeLine{513 }
\DoxyCodeLine{514   \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (\textcolor{keyword}{associated}(prof))}
\DoxyCodeLine{515     \textcolor{keyword}{call }write\_profile(fid,prof)}
\DoxyCodeLine{516     prof=>prof\%cnext}
\DoxyCodeLine{517 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{518   \textcolor{keyword}{call }close\_profile\_file(fid)}
\DoxyCodeLine{519 }
\DoxyCodeLine{520   \textcolor{comment}{!! switch back to ensemble member pelist}}
\DoxyCodeLine{521   \textcolor{comment}{!call set\_current\_pelist(CS\%ensemble\_pelist(CS\%ensemble\_id,:))}}
\DoxyCodeLine{522 }
\DoxyCodeLine{523   \textcolor{keywordflow}{return}}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_a6df570bae958c31d3aab1053484e1f5d}\label{namespacemom__oda__driver__mod_a6df570bae958c31d3aab1053484e1f5d}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!set\_analysis\_time@{set\_analysis\_time}}
\index{set\_analysis\_time@{set\_analysis\_time}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{set\_analysis\_time()}{set\_analysis\_time()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::set\+\_\+analysis\+\_\+time (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), intent(inout), pointer}]{CS }\end{DoxyParamCaption})}



Set the next analysis time. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & the current model time \\
\hline
\mbox{\texttt{ in,out}}  & {\em cs} & the DA control structure \\
\hline
\end{DoxyParams}


Definition at line 475 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{475   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)} :: Time\textcolor{comment}{ !< the current model time}}
\DoxyCodeLine{476   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{intent(inout)} :: CS\textcolor{comment}{ !< the DA control structure}}
\DoxyCodeLine{477 }
\DoxyCodeLine{478   \textcolor{keywordtype}{character(len=160)} :: mesg  \textcolor{comment}{! The text of an error message}}
\DoxyCodeLine{479   \textcolor{keywordtype}{integer} :: yr, mon, day, hr, min, sec}
\DoxyCodeLine{480 }
\DoxyCodeLine{481   \textcolor{keywordflow}{if} (time >= cs\%Time) \textcolor{keywordflow}{then}}
\DoxyCodeLine{482     cs\%Time=increment\_time(cs\%Time,cs\%assim\_frequency*3600)}
\DoxyCodeLine{483 }
\DoxyCodeLine{484     \textcolor{keyword}{call }get\_date(time, yr, mon, day, hr, min, sec)}
\DoxyCodeLine{485     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Model Time: '}, yr, mon, day, hr, min, sec}
\DoxyCodeLine{486     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"set\_analysis\_time: "}//trim(mesg))}
\DoxyCodeLine{487     \textcolor{keyword}{call }get\_date(cs\%time, yr, mon, day, hr, min, sec)}
\DoxyCodeLine{488     \textcolor{keyword}{write}(mesg,*) \textcolor{stringliteral}{'Assimilation Time: '}, yr, mon, day, hr, min, sec}
\DoxyCodeLine{489     \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{"set\_analysis\_time: "}//trim(mesg))}
\DoxyCodeLine{490 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{491   \textcolor{keywordflow}{if} (cs\%Time < time) \textcolor{keywordflow}{then}}
\DoxyCodeLine{492     \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{" set\_analysis\_time: "} // \&}
\DoxyCodeLine{493          \textcolor{stringliteral}{"assimilation interval appears to be shorter than "} // \&}
\DoxyCodeLine{494          \textcolor{stringliteral}{"the model timestep"})}
\DoxyCodeLine{495 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{496   \textcolor{keywordflow}{return}}
\DoxyCodeLine{497 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__oda__driver__mod_a24806346258e5d9143e233999eef0e7f}\label{namespacemom__oda__driver__mod_a24806346258e5d9143e233999eef0e7f}} 
\index{mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}!set\_prior\_tracer@{set\_prior\_tracer}}
\index{set\_prior\_tracer@{set\_prior\_tracer}!mom\_oda\_driver\_mod@{mom\_oda\_driver\_mod}}
\doxysubsubsection{\texorpdfstring{set\_prior\_tracer()}{set\_prior\_tracer()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+oda\+\_\+driver\+\_\+mod\+::set\+\_\+prior\+\_\+tracer (\begin{DoxyParamCaption}\item[{type(time\+\_\+type), intent(in)}]{Time,  }\item[{type(ocean\+\_\+grid\+\_\+type), pointer}]{G,  }\item[{type(verticalgrid\+\_\+type), intent(in)}]{GV,  }\item[{real, dimension( g \%isd\+: g \%ied, g \%jsd\+: g \%jed, g \%ke), intent(in)}]{h,  }\item[{type(thermo\+\_\+var\+\_\+ptrs), intent(in)}]{tv,  }\item[{type(\mbox{\hyperlink{structmom__oda__driver__mod_1_1oda__cs}{oda\+\_\+cs}}), pointer}]{CS }\end{DoxyParamCaption})}



Copy ensemble member tracers to ensemble vector. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em time} & The current model time \\
\hline
 & {\em g} & domain and grid information for ocean model \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & The ocean\textquotesingle{}s vertical grid structure \\
\hline
\mbox{\texttt{ in}}  & {\em h} & Layer thicknesses \mbox{[}H $\sim$$>$ m or kg m-\/2\mbox{]} \\
\hline
\mbox{\texttt{ in}}  & {\em tv} & A structure pointing to various thermodynamic variables \\
\hline
 & {\em cs} & ocean DA control structure \\
\hline
\end{DoxyParams}


Definition at line 308 of file M\+O\+M\+\_\+oda\+\_\+driver.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{308   \textcolor{keywordtype}{type}(time\_type), \textcolor{keywordtype}{intent(in)}    :: Time\textcolor{comment}{ !< The current model time}}
\DoxyCodeLine{309   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: G\textcolor{comment}{ !< domain and grid information for ocean model}}
\DoxyCodeLine{310   \textcolor{keywordtype}{type}(verticalGrid\_type),               \textcolor{keywordtype}{intent(in)}    :: GV\textcolor{comment}{   !< The ocean's vertical grid structure}}
\DoxyCodeLine{311 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(SZI\_(G),SZJ\_(G),SZK\_(G))}, \textcolor{keywordtype}{intent(in)} :: h\textcolor{comment}{    !< Layer thicknesses [H \string~> m or kg m-\/2]}}
\DoxyCodeLine{312   \textcolor{keywordtype}{type}(thermo\_var\_ptrs),                 \textcolor{keywordtype}{intent(in)} :: tv\textcolor{comment}{   !< A structure pointing to various thermodynamic variables}}
\DoxyCodeLine{313 }
\DoxyCodeLine{314   \textcolor{keywordtype}{type}(ODA\_CS), \textcolor{keywordtype}{pointer} :: CS\textcolor{comment}{ !< ocean DA control structure}}
\DoxyCodeLine{315 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{allocatable} :: T, S}
\DoxyCodeLine{316   \textcolor{keywordtype}{type}(ocean\_grid\_type), \textcolor{keywordtype}{pointer} :: Grid=>null()}
\DoxyCodeLine{317   \textcolor{keywordtype}{integer} :: i,j, m, n, ss}
\DoxyCodeLine{318   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{319   \textcolor{keywordtype}{integer} :: isc, iec, jsc, jec}
\DoxyCodeLine{320   \textcolor{keywordtype}{integer} :: isd, ied, jsd, jed}
\DoxyCodeLine{321   \textcolor{keywordtype}{integer} :: id}
\DoxyCodeLine{322   \textcolor{keywordtype}{logical} :: used}
\DoxyCodeLine{323 }
\DoxyCodeLine{324   \textcolor{comment}{! return if not time for analysis}}
\DoxyCodeLine{325   \textcolor{keywordflow}{if} (time < cs\%Time) \textcolor{keywordflow}{return}}
\DoxyCodeLine{326 }
\DoxyCodeLine{327   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs\%Grid)) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'ODA\_CS ensemble horizontal grid not associated'})}
\DoxyCodeLine{328   \textcolor{keywordflow}{if} (.not. \textcolor{keyword}{associated}(cs\%GV)) \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'ODA\_CS ensemble vertical grid not associated'})}
\DoxyCodeLine{329 }
\DoxyCodeLine{330   \textcolor{comment}{!! switch to global pelist}}
\DoxyCodeLine{331   \textcolor{keyword}{call }set\_current\_pelist(cs\%filter\_pelist)}
\DoxyCodeLine{332   \textcolor{keyword}{call }mom\_mesg(\textcolor{stringliteral}{'Setting prior'})}
\DoxyCodeLine{333 }
\DoxyCodeLine{334   isc=cs\%Grid\%isc;iec=cs\%Grid\%iec;jsc=cs\%Grid\%jsc;jec=cs\%Grid\%jec}
\DoxyCodeLine{335   \textcolor{keyword}{call }mpp\_get\_compute\_domain(cs\%domains(cs\%ensemble\_id)\%mpp\_domain,is,ie,js,je)}
\DoxyCodeLine{336   \textcolor{keyword}{call }mpp\_get\_data\_domain(cs\%domains(cs\%ensemble\_id)\%mpp\_domain,isd,ied,jsd,jed)}
\DoxyCodeLine{337   \textcolor{keyword}{allocate}(t(isd:ied,jsd:jed,cs\%nk))}
\DoxyCodeLine{338   \textcolor{keyword}{allocate}(s(isd:ied,jsd:jed,cs\%nk))}
\DoxyCodeLine{339 }
\DoxyCodeLine{340   \textcolor{keywordflow}{do} j=js,je; \textcolor{keywordflow}{do} i=is,ie}
\DoxyCodeLine{341     \textcolor{keyword}{call }remapping\_core\_h(cs\%remapCS, gv\%ke, h(i,j,:), tv\%T(i,j,:), \&}
\DoxyCodeLine{342          cs\%nk, cs\%h(i,j,:), t(i,j,:))}
\DoxyCodeLine{343     \textcolor{keyword}{call }remapping\_core\_h(cs\%remapCS, gv\%ke, h(i,j,:), tv\%S(i,j,:), \&}
\DoxyCodeLine{344          cs\%nk, cs\%h(i,j,:), s(i,j,:))}
\DoxyCodeLine{345 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{346 }
\DoxyCodeLine{347   \textcolor{keywordflow}{do} m=1,cs\%ensemble\_size}
\DoxyCodeLine{348     \textcolor{keyword}{call }mpp\_redistribute(cs\%domains(m)\%mpp\_domain, t,\&}
\DoxyCodeLine{349          cs\%mpp\_domain, cs\%Ocean\_prior\%T(:,:,:,m), complete=.true.)}
\DoxyCodeLine{350     \textcolor{keyword}{call }mpp\_redistribute(cs\%domains(m)\%mpp\_domain, s,\&}
\DoxyCodeLine{351          cs\%mpp\_domain, cs\%Ocean\_prior\%S(:,:,:,m), complete=.true.)}
\DoxyCodeLine{352 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{353   \textcolor{keyword}{deallocate}(t,s)}
\DoxyCodeLine{354 }
\DoxyCodeLine{355   \textcolor{comment}{!! switch back to ensemble member pelist}}
\DoxyCodeLine{356   \textcolor{keyword}{call }set\_current\_pelist(cs\%ensemble\_pelist(cs\%ensemble\_id,:))}
\DoxyCodeLine{357 }
\DoxyCodeLine{358   \textcolor{keywordflow}{return}}
\DoxyCodeLine{359 }

\end{DoxyCode}
