\hypertarget{namespacemom__get__input}{}\section{mom\+\_\+get\+\_\+input Module Reference}
\label{namespacemom__get__input}\index{mom\+\_\+get\+\_\+input@{mom\+\_\+get\+\_\+input}}


\subsection{Detailed Description}
Reads the only Fortran name list needed to boot-\/strap the model. 

The name list parameters indicate which directories to use for certain types of input and output, and which files to look in for the full parsable input parameter file(s). \subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
type \mbox{\hyperlink{structmom__get__input_1_1directories}{directories}}
\begin{DoxyCompactList}\small\item\em Container for paths and parameter file names. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__get__input_a46e89b56d1317f17ccb44b3fa7694731}{get\+\_\+mom\+\_\+input}} (param\+\_\+file, dirs, check\+\_\+params, default\+\_\+input\+\_\+filename, ensemble\+\_\+num)
\begin{DoxyCompactList}\small\item\em Get the names of the I/O directories and initialization file. Also calls the subroutine that opens run-\/time parameter files. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__get__input_a46e89b56d1317f17ccb44b3fa7694731}\label{namespacemom__get__input_a46e89b56d1317f17ccb44b3fa7694731}} 
\index{mom\+\_\+get\+\_\+input@{mom\+\_\+get\+\_\+input}!get\+\_\+mom\+\_\+input@{get\+\_\+mom\+\_\+input}}
\index{get\+\_\+mom\+\_\+input@{get\+\_\+mom\+\_\+input}!mom\+\_\+get\+\_\+input@{mom\+\_\+get\+\_\+input}}
\subsubsection{\texorpdfstring{get\+\_\+mom\+\_\+input()}{get\_mom\_input()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+get\+\_\+input\+::get\+\_\+mom\+\_\+input (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(out), optional}]{param\+\_\+file,  }\item[{type(\mbox{\hyperlink{structmom__get__input_1_1directories}{directories}}), intent(out), optional}]{dirs,  }\item[{logical, intent(in), optional}]{check\+\_\+params,  }\item[{character(len=$\ast$), intent(in), optional}]{default\+\_\+input\+\_\+filename,  }\item[{integer, intent(in), optional}]{ensemble\+\_\+num }\end{DoxyParamCaption})}



Get the names of the I/O directories and initialization file. Also calls the subroutine that opens run-\/time parameter files. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\tt out}  & {\em param\+\_\+file} & A structure to parse for run-\/time parameters.\\
\hline
\mbox{\tt out}  & {\em dirs} & Container for paths and parameter file names.\\
\hline
\mbox{\tt in}  & {\em check\+\_\+params} & If present and False will stop error checking for run-\/time parameters.\\
\hline
\mbox{\tt in}  & {\em default\+\_\+input\+\_\+filename} & If present, is the value assumed for input\+\_\+filename if input\+\_\+filename is not listed in the namelist M\+O\+M\+\_\+input\+\_\+nml.\\
\hline
\mbox{\tt in}  & {\em ensemble\+\_\+num} & The ensemble id of the current member \\
\hline
\end{DoxyParams}


Definition at line 35 of file M\+O\+M\+\_\+get\+\_\+input.\+F90.


\begin{DoxyCode}
35   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: param\_file\textcolor{comment}{   !< A structure to parse for run-time
       parameters.}
36   \textcolor{keywordtype}{type}(directories),     \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: dirs\textcolor{comment}{         !< Container for paths and parameter file
       names.}
37   \textcolor{keywordtype}{logical},               \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: check\_params\textcolor{comment}{ !< If present and False will stop error
       checking for}
38 \textcolor{comment}{                                                               !! run-time parameters.}
39   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: default\_input\_filename\textcolor{comment}{ !< If present, is the value
       assumed for}
40 \textcolor{comment}{                                                               !! input\_filename if input\_filename is not
       listed}
41 \textcolor{comment}{                                                               !! in the namelist MOM\_input\_nml.}
42   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: ensemble\_num\textcolor{comment}{ !< The ensemble id of the current member}
43   \textcolor{comment}{! Local variables}
44   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{parameter} :: npf = 5 \textcolor{comment}{! Maximum number of parameter files}
45 
46   \textcolor{keywordtype}{character(len=240)} :: &
47     parameter\_filename(npf), & \textcolor{comment}{! List of files containing parameters.}
48     output\_directory,        & \textcolor{comment}{! Directory to use to write the model output.}
49     restart\_input\_dir,       & \textcolor{comment}{! Directory for reading restart and input files.}
50     restart\_output\_dir         \textcolor{comment}{! Directory into which to write restart files.}
51   \textcolor{keywordtype}{character(len=2048)} :: &
52     input\_filename             \textcolor{comment}{! A string that indicates the input files or how}
53                                \textcolor{comment}{! the run segment should be started.}
54   \textcolor{keywordtype}{character(len=240)} :: output\_dir
55   \textcolor{keywordtype}{integer} :: unit, io, ierr, valid\_param\_files
56 
57   namelist /mom\_input\_nml/ output\_directory, input\_filename, parameter\_filename, &
58                            restart\_input\_dir, restart\_output\_dir
59 
60   \textcolor{comment}{! Default values in case parameter is not set in file input.nml}
61   parameter\_filename(:) = \textcolor{stringliteral}{' '}
62   output\_directory = \textcolor{stringliteral}{' '}
63   restart\_input\_dir = \textcolor{stringliteral}{' '}
64   restart\_output\_dir = \textcolor{stringliteral}{' '}
65   input\_filename  = \textcolor{stringliteral}{' '}
66   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(default\_input\_filename)) input\_filename = trim(default\_input\_filename)
67 
68   \textcolor{comment}{! Open namelist}
69   \textcolor{keywordflow}{if} (file\_exists(\textcolor{stringliteral}{'input.nml'})) \textcolor{keywordflow}{then}
70     unit = open\_namelist\_file(file=\textcolor{stringliteral}{'input.nml'})
71   \textcolor{keywordflow}{else}
72     \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{'Required namelist file input.nml does not exist.'})
73 \textcolor{keywordflow}{  endif}
74 
75   \textcolor{comment}{! Read namelist parameters}
76   ierr=1 ; \textcolor{keywordflow}{do} \textcolor{keywordflow}{while} (ierr /= 0)
77     \textcolor{keyword}{read}(unit, nml=mom\_input\_nml, iostat=io, end=10)
78     ierr = check\_nml\_error(io, \textcolor{stringliteral}{'MOM\_input\_nml'})
79 \textcolor{keywordflow}{  enddo}
80 10 \textcolor{keyword}{call }close\_file(unit)
81 
82   \textcolor{comment}{! Store parameters in container}
83   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(dirs)) \textcolor{keywordflow}{then}
84     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ensemble\_num)) \textcolor{keywordflow}{then}
85       dirs%output\_directory = slasher(ensembler(output\_directory,ensemble\_num))
86       dirs%restart\_output\_dir = slasher(ensembler(restart\_output\_dir,ensemble\_num))
87       dirs%restart\_input\_dir = slasher(ensembler(restart\_input\_dir,ensemble\_num))
88       dirs%input\_filename = ensembler(input\_filename,ensemble\_num)
89     \textcolor{keywordflow}{else}
90       dirs%output\_directory = slasher(ensembler(output\_directory))
91       dirs%restart\_output\_dir = slasher(ensembler(restart\_output\_dir))
92       dirs%restart\_input\_dir = slasher(ensembler(restart\_input\_dir))
93       dirs%input\_filename = ensembler(input\_filename)
94 \textcolor{keywordflow}{    endif}
95 \textcolor{keywordflow}{  endif}
96 
97   \textcolor{comment}{! Open run-time parameter file(s)}
98   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(param\_file)) \textcolor{keywordflow}{then}
99     output\_dir = slasher(ensembler(output\_directory))
100     valid\_param\_files = 0
101     \textcolor{keywordflow}{do} io = 1, npf
102       \textcolor{keywordflow}{if} (len\_trim(trim(parameter\_filename(io))) > 0) \textcolor{keywordflow}{then}
103         \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ensemble\_num)) \textcolor{keywordflow}{then}
104           \textcolor{keyword}{call }open\_param\_file(ensembler(parameter\_filename(io),ensemble\_num), param\_file, &
105                check\_params, doc\_file\_dir=output\_dir)
106         \textcolor{keywordflow}{else}
107           \textcolor{keyword}{call }open\_param\_file(ensembler(parameter\_filename(io)), param\_file, &
108                check\_params, doc\_file\_dir=output\_dir)
109 \textcolor{keywordflow}{        endif}
110         valid\_param\_files = valid\_param\_files + 1
111 \textcolor{keywordflow}{      endif}
112 \textcolor{keywordflow}{    enddo}
113     \textcolor{keywordflow}{if} (valid\_param\_files == 0) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"There must be at "}//&
114          \textcolor{stringliteral}{"least 1 valid entry in input\_filename in MOM\_input\_nml in input.nml."})
115 \textcolor{keywordflow}{  endif}
116 
\end{DoxyCode}
