\hypertarget{namespacemom__io}{}\doxysection{mom\+\_\+io Module Reference}
\label{namespacemom__io}\index{mom\_io@{mom\_io}}


\doxysubsection{Detailed Description}
This module contains I/O framework code. 

This file contains a number of subroutines that manipulate Net\+C\+DF files and handle input and output of fields. These subroutines, along with their purpose, are\+:


\begin{DoxyItemize}
\item create\+\_\+file\+: create a new file and set up structures that are needed for subsequent output and write out the coordinates.
\item reopen\+\_\+file\+: reopen an existing file for writing and set up structures that are needed for subsequent output.
\item open\+\_\+input\+\_\+file\+: open the indicated file for reading only.
\item close\+\_\+file\+: close an open file.
\item synch\+\_\+file\+: flush the buffers, completing all pending output.
\item write\+\_\+field\+: write a field to an open file.
\item write\+\_\+time\+: write a value of the time axis to an open file.
\item read\+\_\+data\+: read a variable from an open file.
\item read\+\_\+time\+: read a time from an open file.
\item name\+\_\+output\+\_\+file\+: provide a name for an output file based on a name root and the time of the output.
\item find\+\_\+input\+\_\+file\+: find a file that has been previously written by M\+OM and named by name\+\_\+output\+\_\+file and open it for reading.
\item handle\+\_\+error\+: write an error code and quit. 
\end{DoxyItemize}\doxysubsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \mbox{\hyperlink{interfacemom__io_1_1file__exists}{file\+\_\+exists}}
\begin{DoxyCompactList}\small\item\em Indicate whether a file exists, perhaps with domain decomposition. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__io_1_1mom__read__data}{mom\+\_\+read\+\_\+data}}
\begin{DoxyCompactList}\small\item\em Read a data field from a file. \end{DoxyCompactList}\item 
interface \mbox{\hyperlink{interfacemom__io_1_1mom__read__vector}{mom\+\_\+read\+\_\+vector}}
\begin{DoxyCompactList}\small\item\em Read a pair of data fields representing the two components of a vector from a file. \end{DoxyCompactList}\item 
type \mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}
\begin{DoxyCompactList}\small\item\em Type for describing a variable, typically a tracer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_a9371806dfa593ba805e8914d4b6c3421}{create\+\_\+file}} (unit, filename, vars, novars, fields, threading, timeunit, G, dG, GV, checksums)
\begin{DoxyCompactList}\small\item\em Routine creates a new Net\+C\+DF file. It also sets up structures that describe this file and variables that will later be written to this file. Type for describing a variable, typically a tracer. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_ac15e7cf282a5b17192ffb7561537cb8c}{reopen\+\_\+file}} (unit, filename, vars, novars, fields, threading, timeunit, G, dG, GV)
\begin{DoxyCompactList}\small\item\em This routine opens an existing Net\+C\+DF file for output. If it does not find the file, a new file is created. It also sets up structures that describe this file and the variables that will later be written to this file. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_a9cbd4826c272e6b7a35ad95894a977c3}{read\+\_\+axis\+\_\+data}} (filename, axis\+\_\+name, var)
\begin{DoxyCompactList}\small\item\em Read the data associated with a named axis in a file. \end{DoxyCompactList}\item 
integer function, public \mbox{\hyperlink{namespacemom__io_a79952045e028c6882f5b04ea5a1a83f7}{num\+\_\+timelevels}} (filename, varname, min\+\_\+dims)
\begin{DoxyCompactList}\small\item\em This function determines how many time levels a variable has. \end{DoxyCompactList}\item 
type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}) function, public \mbox{\hyperlink{namespacemom__io_a09be50ad112d6bc134d06d82fcbe1fdc}{var\+\_\+desc}} (name, units, longname, hor\+\_\+grid, z\+\_\+grid, t\+\_\+grid, cmor\+\_\+field\+\_\+name, cmor\+\_\+units, cmor\+\_\+longname, conversion, caller)
\begin{DoxyCompactList}\small\item\em Returns a vardesc type whose elements have been filled with the provided fields. The argument name is required, while the others are optional and have default values that are empty strings or are appropriate for a 3-\/d tracer field at the tracer cell centers. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_a0dff28e4952f43175f84cd9cdcda9837}{modify\+\_\+vardesc}} (vd, name, units, longname, hor\+\_\+grid, z\+\_\+grid, t\+\_\+grid, cmor\+\_\+field\+\_\+name, cmor\+\_\+units, cmor\+\_\+longname, conversion, caller)
\begin{DoxyCompactList}\small\item\em This routine modifies the named elements of a vardesc type. All arguments are optional, except the vardesc type to be modified. \end{DoxyCompactList}\item 
character(len=len(longname)) function, public \mbox{\hyperlink{namespacemom__io_ab4558f715ee39149cfe675832b7fa99d}{cmor\+\_\+long\+\_\+std}} (longname)
\begin{DoxyCompactList}\small\item\em This function returns the C\+M\+OR standard name given a C\+M\+OR longname, based on the standard pattern of character conversions. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_aa583d22dfaf16e3157b2741d838f5240}{query\+\_\+vardesc}} (vd, name, units, longname, hor\+\_\+grid, z\+\_\+grid, t\+\_\+grid, cmor\+\_\+field\+\_\+name, cmor\+\_\+units, cmor\+\_\+longname, conversion, caller)
\begin{DoxyCompactList}\small\item\em This routine queries vardesc. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_ac4bc408e8b38dbd669842753f26ebf88}{safe\+\_\+string\+\_\+copy}} (str1, str2, fieldnm, caller)
\begin{DoxyCompactList}\small\item\em Copies a string. \end{DoxyCompactList}\item 
character(len=len(name)) function, public \mbox{\hyperlink{namespacemom__io_a0fe77ff735a4a6177da5395fb4bc2949}{ensembler}} (name, ens\+\_\+no\+\_\+in)
\begin{DoxyCompactList}\small\item\em Returns a name with \char`\"{}\%\#\+E\char`\"{} or \char`\"{}\%\+E\char`\"{} replaced with the ensemble member number. \end{DoxyCompactList}\item 
logical function \mbox{\hyperlink{namespacemom__io_a0288cf8b0b8226fbefc6ac23989dee54}{mom\+\_\+file\+\_\+exists}} (filename, M\+O\+M\+\_\+\+Domain)
\begin{DoxyCompactList}\small\item\em Returns true if the named file or its domain-\/decomposed variant exists. \end{DoxyCompactList}\item 
logical function \mbox{\hyperlink{namespacemom__io_a1351b06e9a7ece9adf5b7ef5cfb9e801}{fms\+\_\+file\+\_\+exists}} (filename, domain, no\+\_\+domain)
\begin{DoxyCompactList}\small\item\em Returns true if the named file or its domain-\/decomposed variant exists. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_a59696f6954e8d111983ef8d86bbbe109}{mom\+\_\+read\+\_\+data\+\_\+1d}} (filename, fieldname, data, timelevel, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read 1-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_a4a26da14aed075eb784a5b82f2c6d978}{mom\+\_\+read\+\_\+data\+\_\+2d}} (filename, fieldname, data, M\+O\+M\+\_\+\+Domain, timelevel, position, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 2-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_ae4d85b211226c10f44328e1c544a6087}{mom\+\_\+read\+\_\+data\+\_\+3d}} (filename, fieldname, data, M\+O\+M\+\_\+\+Domain, timelevel, position, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 3-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_ae52771cd57953bb7e5f9d38ee9142fca}{mom\+\_\+read\+\_\+data\+\_\+4d}} (filename, fieldname, data, M\+O\+M\+\_\+\+Domain, timelevel, position, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 4-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_a5164130471f3bf80cc8657e17b5c08eb}{mom\+\_\+read\+\_\+vector\+\_\+2d}} (filename, u\+\_\+fieldname, v\+\_\+fieldname, u\+\_\+data, v\+\_\+data, M\+O\+M\+\_\+\+Domain, timelevel, stagger, scalar\+\_\+pair, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read a pair of distributed 2-\/D data fields with names given by \char`\"{}\mbox{[}uv\mbox{]}\+\_\+fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}stagger\char`\"{} include C\+G\+R\+I\+D\+\_\+\+NE, B\+G\+R\+I\+D\+\_\+\+NE, and A\+G\+R\+ID. \end{DoxyCompactList}\item 
subroutine \mbox{\hyperlink{namespacemom__io_ac5eac11ba2b78f5d1146f4541d50abd5}{mom\+\_\+read\+\_\+vector\+\_\+3d}} (filename, u\+\_\+fieldname, v\+\_\+fieldname, u\+\_\+data, v\+\_\+data, M\+O\+M\+\_\+\+Domain, timelevel, stagger, scalar\+\_\+pair, scale)
\begin{DoxyCompactList}\small\item\em This function uses the fms\+\_\+io function read\+\_\+data to read a pair of distributed 3-\/D data fields with names given by \char`\"{}\mbox{[}uv\mbox{]}\+\_\+fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}stagger\char`\"{} include C\+G\+R\+I\+D\+\_\+\+NE, B\+G\+R\+I\+D\+\_\+\+NE, and A\+G\+R\+ID. \end{DoxyCompactList}\item 
subroutine, public \mbox{\hyperlink{namespacemom__io_a80a3125a7c246310b5580f4b90ced8a0}{mom\+\_\+io\+\_\+init}} (param\+\_\+file)
\begin{DoxyCompactList}\small\item\em Initialize the M\+O\+M\+\_\+io module. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Function/\+Subroutine Documentation}
\mbox{\Hypertarget{namespacemom__io_ab4558f715ee39149cfe675832b7fa99d}\label{namespacemom__io_ab4558f715ee39149cfe675832b7fa99d}} 
\index{mom\_io@{mom\_io}!cmor\_long\_std@{cmor\_long\_std}}
\index{cmor\_long\_std@{cmor\_long\_std}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{cmor\_long\_std()}{cmor\_long\_std()}}
{\footnotesize\ttfamily character(len=len(longname)) function, public mom\+\_\+io\+::cmor\+\_\+long\+\_\+std (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{longname }\end{DoxyParamCaption})}



This function returns the C\+M\+OR standard name given a C\+M\+OR longname, based on the standard pattern of character conversions. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em longname} & The C\+M\+OR longname being converted \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The C\+M\+OR standard name generated from longname 
\end{DoxyReturn}


Definition at line 682 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{683   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: longname\textcolor{comment}{  !< The CMOR longname being converted}}
\DoxyCodeLine{684   \textcolor{keywordtype}{character(len=len(longname))} :: std\_name\textcolor{comment}{  !< The CMOR standard name generated from longname}}
\DoxyCodeLine{685 }
\DoxyCodeLine{686   \textcolor{keywordtype}{integer} :: k}
\DoxyCodeLine{687 }
\DoxyCodeLine{688   std\_name = lowercase(longname)}
\DoxyCodeLine{689 }
\DoxyCodeLine{690   \textcolor{keywordflow}{do} k=1, len\_trim(std\_name)}
\DoxyCodeLine{691     \textcolor{keywordflow}{if} (std\_name(k:k) == \textcolor{stringliteral}{' '}) std\_name(k:k) = \textcolor{stringliteral}{'\_'}}
\DoxyCodeLine{692 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{693 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a9371806dfa593ba805e8914d4b6c3421}\label{namespacemom__io_a9371806dfa593ba805e8914d4b6c3421}} 
\index{mom\_io@{mom\_io}!create\_file@{create\_file}}
\index{create\_file@{create\_file}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{create\_file()}{create\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::create\+\_\+file (\begin{DoxyParamCaption}\item[{integer, intent(out)}]{unit,  }\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}), dimension(\+:), intent(in)}]{vars,  }\item[{integer, intent(in)}]{novars,  }\item[{type(fieldtype), dimension(\+:), intent(inout)}]{fields,  }\item[{integer, intent(in), optional}]{threading,  }\item[{real, intent(in), optional}]{timeunit,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), optional}]{G,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in), optional}]{dG,  }\item[{type(verticalgrid\+\_\+type), intent(in), optional}]{GV,  }\item[{integer(kind=8), dimension(\+:,\+:), intent(in), optional}]{checksums }\end{DoxyParamCaption})}



Routine creates a new Net\+C\+DF file. It also sets up structures that describe this file and variables that will later be written to this file. Type for describing a variable, typically a tracer. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em unit} & unit id of an open file or -\/1 on a nonwriting PE with single file output \\
\hline
\mbox{\texttt{ in}}  & {\em filename} & full path to the file to create \\
\hline
\mbox{\texttt{ in}}  & {\em vars} & structures describing fields written to filename \\
\hline
\mbox{\texttt{ in}}  & {\em novars} & number of fields written to filename \\
\hline
\mbox{\texttt{ in,out}}  & {\em fields} & array of fieldtypes for each variable \\
\hline
\mbox{\texttt{ in}}  & {\em threading} & S\+I\+N\+G\+L\+E\+\_\+\+F\+I\+LE or M\+U\+L\+T\+I\+P\+LE \\
\hline
\mbox{\texttt{ in}}  & {\em timeunit} & length of the units for time \mbox{[}s\mbox{]}. The default value is 86400.\+0, for 1 day. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes. \\
\hline
\mbox{\texttt{ in}}  & {\em dg} & dynamic horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure, which is required if the new file uses any vertical grid axes. \\
\hline
\mbox{\texttt{ in}}  & {\em checksums} & checksums of vars \\
\hline
\end{DoxyParams}


Definition at line 92 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{93   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(out)}   :: unit\textcolor{comment}{       !< unit id of an open file or -\/1 on a}}
\DoxyCodeLine{94 \textcolor{comment}{                                                     !! nonwriting PE with single file output}}
\DoxyCodeLine{95   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{   !< full path to the file to create}}
\DoxyCodeLine{96   \textcolor{keywordtype}{type}(vardesc),         \textcolor{keywordtype}{intent(in)}    :: vars(:)\textcolor{comment}{    !< structures describing fields written to filename}}
\DoxyCodeLine{97   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: novars\textcolor{comment}{     !< number of fields written to filename}}
\DoxyCodeLine{98   \textcolor{keywordtype}{type}(fieldtype),       \textcolor{keywordtype}{intent(inout)} :: fields(:)\textcolor{comment}{  !< array of fieldtypes for each variable}}
\DoxyCodeLine{99   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)}    :: threading\textcolor{comment}{  !< SINGLE\_FILE or MULTIPLE}}
\DoxyCodeLine{100 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional},        \textcolor{keywordtype}{intent(in)}    :: timeunit\textcolor{comment}{   !< length of the units for time [s]. The}}
\DoxyCodeLine{101 \textcolor{comment}{                                                     !! default value is 86400.0, for 1 day.}}
\DoxyCodeLine{102   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< ocean horizontal grid structure; G or dG}}
\DoxyCodeLine{103 \textcolor{comment}{                                                     !! is required if the new file uses any}}
\DoxyCodeLine{104 \textcolor{comment}{                                                     !! horizontal grid axes.}}
\DoxyCodeLine{105   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dG\textcolor{comment}{ !< dynamic horizontal grid structure; G or dG}}
\DoxyCodeLine{106 \textcolor{comment}{                                                     !! is required if the new file uses any}}
\DoxyCodeLine{107 \textcolor{comment}{                                                     !! horizontal grid axes.}}
\DoxyCodeLine{108   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< ocean vertical grid structure, which is}}
\DoxyCodeLine{109 \textcolor{comment}{                                                     !! required if the new file uses any}}
\DoxyCodeLine{110 \textcolor{comment}{                                                     !! vertical grid axes.}}
\DoxyCodeLine{111   \textcolor{keywordtype}{integer(kind=8)}, \textcolor{keywordtype}{optional},      \textcolor{keywordtype}{intent(in)}    :: checksums(:,:)\textcolor{comment}{  !< checksums of vars}}
\DoxyCodeLine{112 }
\DoxyCodeLine{113   \textcolor{keywordtype}{logical}        :: use\_lath, use\_lonh, use\_latq, use\_lonq, use\_time}
\DoxyCodeLine{114   \textcolor{keywordtype}{logical}        :: use\_layer, use\_int, use\_periodic}
\DoxyCodeLine{115   \textcolor{keywordtype}{logical}        :: one\_file, domain\_set}
\DoxyCodeLine{116   \textcolor{keywordtype}{type}(axistype) :: axis\_lath, axis\_latq, axis\_lonh, axis\_lonq}
\DoxyCodeLine{117   \textcolor{keywordtype}{type}(axistype) :: axis\_layer, axis\_int, axis\_time, axis\_periodic}
\DoxyCodeLine{118   \textcolor{keywordtype}{type}(axistype) :: axes(4)}
\DoxyCodeLine{119   \textcolor{keywordtype}{type}(MOM\_domain\_type), \textcolor{keywordtype}{pointer} :: Domain => null()}
\DoxyCodeLine{120   \textcolor{keywordtype}{type}(domain1d) :: x\_domain, y\_domain}
\DoxyCodeLine{121   \textcolor{keywordtype}{integer}        :: numaxes, pack, thread, k}
\DoxyCodeLine{122   \textcolor{keywordtype}{integer}        :: isg, ieg, jsg, jeg, IsgB, IegB, JsgB, JegB}
\DoxyCodeLine{123   \textcolor{keywordtype}{integer}        :: var\_periods, num\_periods=0}
\DoxyCodeLine{124 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{allocatable} :: period\_val}
\DoxyCodeLine{125 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{pointer}, \textcolor{keywordtype}{dimension(:)} :: \&}
\DoxyCodeLine{126     gridLatT => null(), \& \textcolor{comment}{! The latitude or longitude of T or B points for}}
\DoxyCodeLine{127     gridlatb => null(), \& \textcolor{comment}{! the purpose of labeling the output axes.}}
\DoxyCodeLine{128     gridlont => null(), gridlonb => null()}
\DoxyCodeLine{129   \textcolor{keywordtype}{character(len=40)} :: time\_units, x\_axis\_units, y\_axis\_units}
\DoxyCodeLine{130   \textcolor{keywordtype}{character(len=8)}  :: t\_grid, t\_grid\_read}
\DoxyCodeLine{131 }
\DoxyCodeLine{132   use\_lath  = .false. ; use\_lonh     = .false.}
\DoxyCodeLine{133   use\_latq  = .false. ; use\_lonq     = .false.}
\DoxyCodeLine{134   use\_time  = .false. ; use\_periodic = .false.}
\DoxyCodeLine{135   use\_layer = .false. ; use\_int      = .false.}
\DoxyCodeLine{136 }
\DoxyCodeLine{137   thread = single\_file}
\DoxyCodeLine{138   \textcolor{keywordflow}{if} (\textcolor{keyword}{PRESENT}(threading)) thread = threading}
\DoxyCodeLine{139 }
\DoxyCodeLine{140   domain\_set = .false.}
\DoxyCodeLine{141   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(g)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{142     domain\_set = .true. ; domain => g\%Domain}
\DoxyCodeLine{143     gridlatt => g\%gridLatT ; gridlatb => g\%gridLatB}
\DoxyCodeLine{144     gridlont => g\%gridLonT ; gridlonb => g\%gridLonB}
\DoxyCodeLine{145     x\_axis\_units = g\%x\_axis\_units ; y\_axis\_units = g\%y\_axis\_units}
\DoxyCodeLine{146     isg = g\%isg ; ieg = g\%ieg ; jsg = g\%jsg ; jeg = g\%jeg}
\DoxyCodeLine{147     isgb = g\%IsgB ; iegb = g\%IegB ; jsgb = g\%JsgB ; jegb = g\%JegB}
\DoxyCodeLine{148   \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(dg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{149     domain\_set = .true. ; domain => dg\%Domain}
\DoxyCodeLine{150     gridlatt => dg\%gridLatT ; gridlatb => dg\%gridLatB}
\DoxyCodeLine{151     gridlont => dg\%gridLonT ; gridlonb => dg\%gridLonB}
\DoxyCodeLine{152     x\_axis\_units = dg\%x\_axis\_units ; y\_axis\_units = dg\%y\_axis\_units}
\DoxyCodeLine{153     isg = dg\%isg ; ieg = dg\%ieg ; jsg = dg\%jsg ; jeg = dg\%jeg}
\DoxyCodeLine{154     isgb = dg\%IsgB ; iegb = dg\%IegB ; jsgb = dg\%JsgB ; jegb = dg\%JegB}
\DoxyCodeLine{155 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{156 }
\DoxyCodeLine{157   one\_file = .true.}
\DoxyCodeLine{158   \textcolor{keywordflow}{if} (domain\_set) one\_file = (thread == single\_file)}
\DoxyCodeLine{159 }
\DoxyCodeLine{160   \textcolor{keywordflow}{if} (one\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{161     \textcolor{keyword}{call }open\_file(unit, filename, mpp\_overwr, mpp\_netcdf, threading=thread)}
\DoxyCodeLine{162   \textcolor{keywordflow}{else}}
\DoxyCodeLine{163     \textcolor{keyword}{call }open\_file(unit, filename, mpp\_overwr, mpp\_netcdf, domain=domain\%mpp\_domain)}
\DoxyCodeLine{164 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{165 }
\DoxyCodeLine{166 \textcolor{comment}{! Define the coordinates.}}
\DoxyCodeLine{167   \textcolor{keywordflow}{do} k=1,novars}
\DoxyCodeLine{168     \textcolor{keywordflow}{select case} (vars(k)\%hor\_grid)}
\DoxyCodeLine{169       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'h'}) ; use\_lath = .true. ; use\_lonh = .true.}
\DoxyCodeLine{170       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'q'}) ; use\_latq = .true. ; use\_lonq = .true.}
\DoxyCodeLine{171       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'u'}) ; use\_lath = .true. ; use\_lonq = .true.}
\DoxyCodeLine{172       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'v'}) ; use\_latq = .true. ; use\_lonh = .true.}
\DoxyCodeLine{173       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'T'})  ; use\_lath = .true. ; use\_lonh = .true.}
\DoxyCodeLine{174       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Bu'}) ; use\_latq = .true. ; use\_lonq = .true.}
\DoxyCodeLine{175       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Cu'}) ; use\_lath = .true. ; use\_lonq = .true.}
\DoxyCodeLine{176       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Cv'}) ; use\_latq = .true. ; use\_lonh = .true.}
\DoxyCodeLine{177       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{178 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{179         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{180                         \textcolor{stringliteral}{" has unrecognized hor\_grid "}//trim(vars(k)\%hor\_grid))}
\DoxyCodeLine{181 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{182     \textcolor{keywordflow}{select case} (vars(k)\%z\_grid)}
\DoxyCodeLine{183       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'L'}) ; use\_layer = .true.}
\DoxyCodeLine{184       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'i'}) ; use\_int = .true.}
\DoxyCodeLine{185       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{186 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{187         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{188                         \textcolor{stringliteral}{" has unrecognized z\_grid "}//trim(vars(k)\%z\_grid))}
\DoxyCodeLine{189 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{190     t\_grid = adjustl(vars(k)\%t\_grid)}
\DoxyCodeLine{191     \textcolor{keywordflow}{select case} (t\_grid(1:1))}
\DoxyCodeLine{192       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'s'}, \textcolor{stringliteral}{'a'}, \textcolor{stringliteral}{'m'}) ; use\_time = .true.}
\DoxyCodeLine{193       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'p'}) ; use\_periodic = .true.}
\DoxyCodeLine{194         \textcolor{keywordflow}{if} (len\_trim(t\_grid(2:8)) <= 0) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{195           \textcolor{stringliteral}{"MOM\_io create\_file: No periodic axis length was specified in "}//\&}
\DoxyCodeLine{196           trim(vars(k)\%t\_grid) // \textcolor{stringliteral}{" in the periodic axes of variable "}//\&}
\DoxyCodeLine{197           trim(vars(k)\%name)//\textcolor{stringliteral}{" in file "}//trim(filename))}
\DoxyCodeLine{198         var\_periods = -\/9999999}
\DoxyCodeLine{199         t\_grid\_read = adjustl(t\_grid(2:8))}
\DoxyCodeLine{200         \textcolor{keyword}{read}(t\_grid\_read,*) var\_periods}
\DoxyCodeLine{201         \textcolor{keywordflow}{if} (var\_periods == -\/9999999) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{202           \textcolor{stringliteral}{"MOM\_io create\_file: Failed to read the number of periods from "}//\&}
\DoxyCodeLine{203           trim(vars(k)\%t\_grid) // \textcolor{stringliteral}{" in the periodic axes of variable "}//\&}
\DoxyCodeLine{204           trim(vars(k)\%name)//\textcolor{stringliteral}{" in file "}//trim(filename))}
\DoxyCodeLine{205         \textcolor{keywordflow}{if} (var\_periods < 1) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io create\_file: "}//\&}
\DoxyCodeLine{206            \textcolor{stringliteral}{"variable "}//trim(vars(k)\%name)//\textcolor{stringliteral}{" in file "}//trim(filename)//\&}
\DoxyCodeLine{207            \textcolor{stringliteral}{" uses a periodic time axis, and must have a positive "}//\&}
\DoxyCodeLine{208            \textcolor{stringliteral}{"value for the number of periods in "}//vars(k)\%t\_grid )}
\DoxyCodeLine{209         \textcolor{keywordflow}{if} ((num\_periods > 0) .and. (var\_periods /= num\_periods)) \&}
\DoxyCodeLine{210           \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io create\_file: "}//\&}
\DoxyCodeLine{211             \textcolor{stringliteral}{"Only one value of the number of periods can be used in the "}//\&}
\DoxyCodeLine{212             \textcolor{stringliteral}{"create\_file call for file "}//trim(filename)//\textcolor{stringliteral}{".  The second is "}//\&}
\DoxyCodeLine{213             \textcolor{stringliteral}{"variable "}//trim(vars(k)\%name)//\textcolor{stringliteral}{" with t\_grid "}//vars(k)\%t\_grid )}
\DoxyCodeLine{214 }
\DoxyCodeLine{215         num\_periods = var\_periods}
\DoxyCodeLine{216       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{217 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{218         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{219                         \textcolor{stringliteral}{" has unrecognized t\_grid "}//trim(vars(k)\%t\_grid))}
\DoxyCodeLine{220 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{221 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{222 }
\DoxyCodeLine{223   \textcolor{keywordflow}{if} ((use\_lath .or. use\_lonh .or. use\_latq .or. use\_lonq)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{224     \textcolor{keywordflow}{if} (.not.domain\_set) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"create\_file: "}//\&}
\DoxyCodeLine{225       \textcolor{stringliteral}{"An ocean\_grid\_type or dyn\_horgrid\_type is required to create a file with a horizontal coordinate."})}
\DoxyCodeLine{226 }
\DoxyCodeLine{227     \textcolor{keyword}{call }mpp\_get\_domain\_components(domain\%mpp\_domain, x\_domain, y\_domain)}
\DoxyCodeLine{228 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{229   \textcolor{keywordflow}{if} ((use\_layer .or. use\_int) .and. .not.\textcolor{keyword}{present}(gv)) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{230     \textcolor{stringliteral}{"create\_file: A vertical grid type is required to create a file with a vertical coordinate."})}
\DoxyCodeLine{231 }
\DoxyCodeLine{232 \textcolor{comment}{! Specify all optional arguments to mpp\_write\_meta: name, units, longname, cartesian, calendar, sense,}}
\DoxyCodeLine{233 \textcolor{comment}{! domain, data, min). Otherwise if optional arguments are added to mpp\_write\_meta the compiler may}}
\DoxyCodeLine{234 \textcolor{comment}{! (and in case of GNU does) get confused and crash.}}
\DoxyCodeLine{235   \textcolor{keywordflow}{if} (use\_lath) \&}
\DoxyCodeLine{236     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_lath, name=\textcolor{stringliteral}{"lath"}, units=y\_axis\_units, longname=\textcolor{stringliteral}{"Latitude"}, \&}
\DoxyCodeLine{237                    cartesian=\textcolor{stringliteral}{'Y'}, domain = y\_domain, data=gridlatt(jsg:jeg))}
\DoxyCodeLine{238 }
\DoxyCodeLine{239   \textcolor{keywordflow}{if} (use\_lonh) \&}
\DoxyCodeLine{240     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_lonh, name=\textcolor{stringliteral}{"lonh"}, units=x\_axis\_units, longname=\textcolor{stringliteral}{"Longitude"}, \&}
\DoxyCodeLine{241                    cartesian=\textcolor{stringliteral}{'X'}, domain = x\_domain, data=gridlont(isg:ieg))}
\DoxyCodeLine{242 }
\DoxyCodeLine{243   \textcolor{keywordflow}{if} (use\_latq) \&}
\DoxyCodeLine{244     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_latq, name=\textcolor{stringliteral}{"latq"}, units=y\_axis\_units, longname=\textcolor{stringliteral}{"Latitude"}, \&}
\DoxyCodeLine{245                    cartesian=\textcolor{stringliteral}{'Y'}, domain = y\_domain, data=gridlatb(jsgb:jegb))}
\DoxyCodeLine{246 }
\DoxyCodeLine{247   \textcolor{keywordflow}{if} (use\_lonq) \&}
\DoxyCodeLine{248     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_lonq, name=\textcolor{stringliteral}{"lonq"}, units=x\_axis\_units, longname=\textcolor{stringliteral}{"Longitude"}, \&}
\DoxyCodeLine{249                    cartesian=\textcolor{stringliteral}{'X'}, domain = x\_domain, data=gridlonb(isgb:iegb))}
\DoxyCodeLine{250 }
\DoxyCodeLine{251   \textcolor{keywordflow}{if} (use\_layer) \&}
\DoxyCodeLine{252     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_layer, name=\textcolor{stringliteral}{"Layer"}, units=trim(gv\%zAxisUnits), \&}
\DoxyCodeLine{253           longname=\textcolor{stringliteral}{"Layer "}//trim(gv\%zAxisLongName), cartesian=\textcolor{stringliteral}{'Z'}, \&}
\DoxyCodeLine{254           sense=1, data=gv\%sLayer(1:gv\%ke))}
\DoxyCodeLine{255 }
\DoxyCodeLine{256   \textcolor{keywordflow}{if} (use\_int) \&}
\DoxyCodeLine{257     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_int, name=\textcolor{stringliteral}{"Interface"}, units=trim(gv\%zAxisUnits), \&}
\DoxyCodeLine{258           longname=\textcolor{stringliteral}{"Interface "}//trim(gv\%zAxisLongName), cartesian=\textcolor{stringliteral}{'Z'}, \&}
\DoxyCodeLine{259           sense=1, data=gv\%sInterface(1:gv\%ke+1))}
\DoxyCodeLine{260 }
\DoxyCodeLine{261   \textcolor{keywordflow}{if} (use\_time) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(timeunit)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{262     \textcolor{comment}{! Set appropriate units, depending on the value.}}
\DoxyCodeLine{263     \textcolor{keywordflow}{if} (timeunit < 0.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{264       time\_units = \textcolor{stringliteral}{"days"} \textcolor{comment}{! The default value.}}
\DoxyCodeLine{265     \textcolor{keywordflow}{elseif} ((timeunit >= 0.99) .and. (timeunit < 1.01)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{266       time\_units = \textcolor{stringliteral}{"seconds"}}
\DoxyCodeLine{267     \textcolor{keywordflow}{elseif} ((timeunit >= 3599.0) .and. (timeunit < 3601.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{268       time\_units = \textcolor{stringliteral}{"hours"}}
\DoxyCodeLine{269     \textcolor{keywordflow}{elseif} ((timeunit >= 86399.0) .and. (timeunit < 86401.0)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{270       time\_units = \textcolor{stringliteral}{"days"}}
\DoxyCodeLine{271     \textcolor{keywordflow}{elseif} ((timeunit >= 3.0e7) .and. (timeunit < 3.2e7)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{272       time\_units = \textcolor{stringliteral}{"years"}}
\DoxyCodeLine{273     \textcolor{keywordflow}{else}}
\DoxyCodeLine{274       \textcolor{keyword}{write}(time\_units,\textcolor{stringliteral}{'(es8.2," s")'}) timeunit}
\DoxyCodeLine{275 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{276 }
\DoxyCodeLine{277     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_time, name=\textcolor{stringliteral}{"Time"}, units=time\_units, longname=\textcolor{stringliteral}{"Time"}, cartesian=\textcolor{stringliteral}{'T'})}
\DoxyCodeLine{278   \textcolor{keywordflow}{else}}
\DoxyCodeLine{279     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_time, name=\textcolor{stringliteral}{"Time"}, units=\textcolor{stringliteral}{"days"}, longname=\textcolor{stringliteral}{"Time"},cartesian= \textcolor{stringliteral}{'T'})}
\DoxyCodeLine{280 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{281 }
\DoxyCodeLine{282   \textcolor{keywordflow}{if} (use\_periodic) \textcolor{keywordflow}{then}}
\DoxyCodeLine{283     \textcolor{keywordflow}{if} (num\_periods <= 1) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io create\_file: "}//\&}
\DoxyCodeLine{284       \textcolor{stringliteral}{"num\_periods for file "}//trim(filename)//\textcolor{stringliteral}{" must be at least 1."})}
\DoxyCodeLine{285     \textcolor{comment}{! Define a periodic axis with unit labels.}}
\DoxyCodeLine{286     \textcolor{keyword}{allocate}(period\_val(num\_periods))}
\DoxyCodeLine{287     \textcolor{keywordflow}{do} k=1,num\_periods ; period\_val(k) = real(k) ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{288     \textcolor{keyword}{call }mpp\_write\_meta(unit, axis\_periodic, name=\textcolor{stringliteral}{"Period"}, units=\textcolor{stringliteral}{"nondimensional"}, \&}
\DoxyCodeLine{289           longname=\textcolor{stringliteral}{"Periods for cyclical varaiables"}, cartesian= \textcolor{stringliteral}{'t'}, data=period\_val)}
\DoxyCodeLine{290     \textcolor{keyword}{deallocate}(period\_val)}
\DoxyCodeLine{291 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{292 }
\DoxyCodeLine{293   \textcolor{keywordflow}{do} k=1,novars}
\DoxyCodeLine{294     numaxes = 0}
\DoxyCodeLine{295     \textcolor{keywordflow}{select case} (vars(k)\%hor\_grid)}
\DoxyCodeLine{296       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'h'})  ; numaxes = 2 ; axes(1) = axis\_lonh ; axes(2) = axis\_lath}
\DoxyCodeLine{297       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'q'})  ; numaxes = 2 ; axes(1) = axis\_lonq ; axes(2) = axis\_latq}
\DoxyCodeLine{298       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'u'})  ; numaxes = 2 ; axes(1) = axis\_lonq ; axes(2) = axis\_lath}
\DoxyCodeLine{299       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'v'})  ; numaxes = 2 ; axes(1) = axis\_lonh ; axes(2) = axis\_latq}
\DoxyCodeLine{300       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'T'})  ; numaxes = 2 ; axes(1) = axis\_lonh ; axes(2) = axis\_lath}
\DoxyCodeLine{301       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Bu'}) ; numaxes = 2 ; axes(1) = axis\_lonq ; axes(2) = axis\_latq}
\DoxyCodeLine{302       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Cu'}) ; numaxes = 2 ; axes(1) = axis\_lonq ; axes(2) = axis\_lath}
\DoxyCodeLine{303       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'Cv'}) ; numaxes = 2 ; axes(1) = axis\_lonh ; axes(2) = axis\_latq}
\DoxyCodeLine{304       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{305 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{306         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{307                         \textcolor{stringliteral}{" has unrecognized hor\_grid "}//trim(vars(k)\%hor\_grid))}
\DoxyCodeLine{308 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{309     \textcolor{keywordflow}{select case} (vars(k)\%z\_grid)}
\DoxyCodeLine{310       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'L'}) ; numaxes = numaxes+1 ; axes(numaxes) = axis\_layer}
\DoxyCodeLine{311       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'i'}) ; numaxes = numaxes+1 ; axes(numaxes) = axis\_int}
\DoxyCodeLine{312       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{313 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{314         \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{315                         \textcolor{stringliteral}{" has unrecognized z\_grid "}//trim(vars(k)\%z\_grid))}
\DoxyCodeLine{316 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{317     t\_grid = adjustl(vars(k)\%t\_grid)}
\DoxyCodeLine{318     \textcolor{keywordflow}{select case} (t\_grid(1:1))}
\DoxyCodeLine{319       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'s'}, \textcolor{stringliteral}{'a'}, \textcolor{stringliteral}{'m'}) ; numaxes = numaxes+1 ; axes(numaxes) = axis\_time}
\DoxyCodeLine{320       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'p'})           ; numaxes = numaxes+1 ; axes(numaxes) = axis\_periodic}
\DoxyCodeLine{321       \textcolor{keywordflow}{case} (\textcolor{stringliteral}{'1'}) \textcolor{comment}{! Do nothing.}}
\DoxyCodeLine{322 \textcolor{keywordflow}{      case default}}
\DoxyCodeLine{323         \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"MOM\_io create\_file: "}//trim(vars(k)\%name)//\&}
\DoxyCodeLine{324                         \textcolor{stringliteral}{" has unrecognized t\_grid "}//trim(vars(k)\%t\_grid))}
\DoxyCodeLine{325 \textcolor{keywordflow}{    end select}}
\DoxyCodeLine{326     pack = 1}
\DoxyCodeLine{327 }
\DoxyCodeLine{328     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(checksums)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{329        \textcolor{keyword}{call }mpp\_write\_meta(unit, fields(k), axes(1:numaxes), vars(k)\%name, vars(k)\%units, \&}
\DoxyCodeLine{330            vars(k)\%longname, pack = pack, checksum=checksums(k,:))}
\DoxyCodeLine{331     \textcolor{keywordflow}{else}}
\DoxyCodeLine{332        \textcolor{keyword}{call }mpp\_write\_meta(unit, fields(k), axes(1:numaxes), vars(k)\%name, vars(k)\%units, \&}
\DoxyCodeLine{333            vars(k)\%longname, pack = pack)}
\DoxyCodeLine{334 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{335 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{336 }
\DoxyCodeLine{337   \textcolor{keywordflow}{if} (use\_lath) \textcolor{keyword}{call }write\_field(unit, axis\_lath)}
\DoxyCodeLine{338   \textcolor{keywordflow}{if} (use\_latq) \textcolor{keyword}{call }write\_field(unit, axis\_latq)}
\DoxyCodeLine{339   \textcolor{keywordflow}{if} (use\_lonh) \textcolor{keyword}{call }write\_field(unit, axis\_lonh)}
\DoxyCodeLine{340   \textcolor{keywordflow}{if} (use\_lonq) \textcolor{keyword}{call }write\_field(unit, axis\_lonq)}
\DoxyCodeLine{341   \textcolor{keywordflow}{if} (use\_layer) \textcolor{keyword}{call }write\_field(unit, axis\_layer)}
\DoxyCodeLine{342   \textcolor{keywordflow}{if} (use\_int) \textcolor{keyword}{call }write\_field(unit, axis\_int)}
\DoxyCodeLine{343   \textcolor{keywordflow}{if} (use\_periodic) \textcolor{keyword}{call }write\_field(unit, axis\_periodic)}
\DoxyCodeLine{344 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a0fe77ff735a4a6177da5395fb4bc2949}\label{namespacemom__io_a0fe77ff735a4a6177da5395fb4bc2949}} 
\index{mom\_io@{mom\_io}!ensembler@{ensembler}}
\index{ensembler@{ensembler}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{ensembler()}{ensembler()}}
{\footnotesize\ttfamily character(len=len(name)) function, public mom\+\_\+io\+::ensembler (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{integer, intent(in), optional}]{ens\+\_\+no\+\_\+in }\end{DoxyParamCaption})}



Returns a name with \char`\"{}\%\#\+E\char`\"{} or \char`\"{}\%\+E\char`\"{} replaced with the ensemble member number. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em name} & The name to be modified \\
\hline
\mbox{\texttt{ in}}  & {\em ens\+\_\+no\+\_\+in} & The number of the current ensemble member \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The name encoded with the ensemble number 
\end{DoxyReturn}


Definition at line 762 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{763   \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{       !< The name to be modified}}
\DoxyCodeLine{764   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: ens\_no\_in\textcolor{comment}{  !< The number of the current ensemble member}}
\DoxyCodeLine{765   \textcolor{keywordtype}{character(len=len(name))} :: en\_nm\textcolor{comment}{  !< The name encoded with the ensemble number}}
\DoxyCodeLine{766 }
\DoxyCodeLine{767   \textcolor{comment}{! This function replaces "\%\#E" or "\%E" with the ensemble number anywhere it}}
\DoxyCodeLine{768   \textcolor{comment}{! occurs in name, with \%E using 4 or 6 digits (depending on the ensemble size)}}
\DoxyCodeLine{769   \textcolor{comment}{! and \%\#E using \# digits, where \# is a number from 1 to 9.}}
\DoxyCodeLine{770 }
\DoxyCodeLine{771   \textcolor{keywordtype}{character(len=len(name))} :: tmp}
\DoxyCodeLine{772   \textcolor{keywordtype}{character(10)} :: ens\_num\_char}
\DoxyCodeLine{773   \textcolor{keywordtype}{character(3)}  :: code\_str}
\DoxyCodeLine{774   \textcolor{keywordtype}{integer} :: ens\_no}
\DoxyCodeLine{775   \textcolor{keywordtype}{integer} :: n, is, ie}
\DoxyCodeLine{776 }
\DoxyCodeLine{777   en\_nm = trim(name)}
\DoxyCodeLine{778   \textcolor{keywordflow}{if} (index(name,\textcolor{stringliteral}{"\%"}) == 0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{779 }
\DoxyCodeLine{780   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(ens\_no\_in)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{781     ens\_no = ens\_no\_in}
\DoxyCodeLine{782   \textcolor{keywordflow}{else}}
\DoxyCodeLine{783     ens\_no = get\_ensemble\_id()}
\DoxyCodeLine{784 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{785 }
\DoxyCodeLine{786   \textcolor{keyword}{write}(ens\_num\_char, \textcolor{stringliteral}{'(I10)'}) ens\_no ; ens\_num\_char = adjustl(ens\_num\_char)}
\DoxyCodeLine{787   \textcolor{keywordflow}{do}}
\DoxyCodeLine{788     is = index(en\_nm,\textcolor{stringliteral}{"\%E"})}
\DoxyCodeLine{789     \textcolor{keywordflow}{if} (is == 0) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{790     \textcolor{keywordflow}{if} (len(en\_nm) < len(trim(en\_nm)) + len(trim(ens\_num\_char)) -\/ 2) \&}
\DoxyCodeLine{791       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io ensembler: name "}//trim(name)// \&}
\DoxyCodeLine{792       \textcolor{stringliteral}{" is not long enough for \%E expansion for ens\_no "}//trim(ens\_num\_char))}
\DoxyCodeLine{793     tmp = en\_nm(1:is-\/1)//trim(ens\_num\_char)//trim(en\_nm(is+2:))}
\DoxyCodeLine{794     en\_nm = tmp}
\DoxyCodeLine{795 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{796 }
\DoxyCodeLine{797   \textcolor{keywordflow}{if} (index(name,\textcolor{stringliteral}{"\%"}) == 0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{798 }
\DoxyCodeLine{799   \textcolor{keyword}{write}(ens\_num\_char, \textcolor{stringliteral}{'(I10.10)'}) ens\_no}
\DoxyCodeLine{800   \textcolor{keywordflow}{do} n=1,9 ; \textcolor{keywordflow}{do}}
\DoxyCodeLine{801     \textcolor{keyword}{write}(code\_str, \textcolor{stringliteral}{'("\%",I1,"E")'}) n}
\DoxyCodeLine{802 }
\DoxyCodeLine{803     is = index(en\_nm,code\_str)}
\DoxyCodeLine{804     \textcolor{keywordflow}{if} (is == 0) \textcolor{keywordflow}{exit}}
\DoxyCodeLine{805     \textcolor{keywordflow}{if} (ens\_no < 10**n) \textcolor{keywordflow}{then}}
\DoxyCodeLine{806       \textcolor{keywordflow}{if} (len(en\_nm) < len(trim(en\_nm)) + n-\/3) \textcolor{keyword}{call }mom\_error(fatal, \&}
\DoxyCodeLine{807         \textcolor{stringliteral}{"MOM\_io ensembler: name "}//trim(name)//\textcolor{stringliteral}{" is not long enough for \%E expansion."})}
\DoxyCodeLine{808       tmp = en\_nm(1:is-\/1)//trim(ens\_num\_char(11-\/n:10))//trim(en\_nm(is+3:))}
\DoxyCodeLine{809     \textcolor{keywordflow}{else}}
\DoxyCodeLine{810       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io ensembler: Ensemble number is too large "}//\&}
\DoxyCodeLine{811           \textcolor{stringliteral}{"to be encoded with "}//code\_str//\textcolor{stringliteral}{" in "}//trim(name))}
\DoxyCodeLine{812 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{813     en\_nm = tmp}
\DoxyCodeLine{814 \textcolor{keywordflow}{  enddo} ;\textcolor{keywordflow}{ enddo}}
\DoxyCodeLine{815 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a1351b06e9a7ece9adf5b7ef5cfb9e801}\label{namespacemom__io_a1351b06e9a7ece9adf5b7ef5cfb9e801}} 
\index{mom\_io@{mom\_io}!fms\_file\_exists@{fms\_file\_exists}}
\index{fms\_file\_exists@{fms\_file\_exists}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{fms\_file\_exists()}{fms\_file\_exists()}}
{\footnotesize\ttfamily logical function mom\+\_\+io\+::fms\+\_\+file\+\_\+exists (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{type(domain2d), intent(in), optional}]{domain,  }\item[{logical, intent(in), optional}]{no\+\_\+domain }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns true if the named file or its domain-\/decomposed variant exists. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file being inquired about \\
\hline
\mbox{\texttt{ in}}  & {\em domain} & The mpp domain2d that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em no\+\_\+domain} & This file does not use domain decomposition \\
\hline
\end{DoxyParams}


Definition at line 834 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{835   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}         :: filename\textcolor{comment}{  !< The name of the file being inquired about}}
\DoxyCodeLine{836   \textcolor{keywordtype}{type}(domain2d), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: domain\textcolor{comment}{    !< The mpp domain2d that describes the decomposition}}
\DoxyCodeLine{837   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: no\_domain\textcolor{comment}{ !< This file does not use domain decomposition}}
\DoxyCodeLine{838 \textcolor{comment}{! This function uses the fms\_io function file\_exist to determine whether}}
\DoxyCodeLine{839 \textcolor{comment}{! a named file (or its decomposed variant) exists.}}
\DoxyCodeLine{840 }
\DoxyCodeLine{841   \textcolor{keywordtype}{logical} :: FMS\_file\_exists}
\DoxyCodeLine{842 }
\DoxyCodeLine{843   fms\_file\_exists = file\_exist(filename, domain, no\_domain)}
\DoxyCodeLine{844 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a0dff28e4952f43175f84cd9cdcda9837}\label{namespacemom__io_a0dff28e4952f43175f84cd9cdcda9837}} 
\index{mom\_io@{mom\_io}!modify\_vardesc@{modify\_vardesc}}
\index{modify\_vardesc@{modify\_vardesc}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{modify\_vardesc()}{modify\_vardesc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::modify\+\_\+vardesc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}), intent(inout)}]{vd,  }\item[{character(len=$\ast$), intent(in), optional}]{name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{character(len=$\ast$), intent(in), optional}]{longname,  }\item[{character(len=$\ast$), intent(in), optional}]{hor\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{z\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{t\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+longname,  }\item[{real, intent(in), optional}]{conversion,  }\item[{character(len=$\ast$), intent(in), optional}]{caller }\end{DoxyParamCaption})}



This routine modifies the named elements of a vardesc type. All arguments are optional, except the vardesc type to be modified. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in,out}}  & {\em vd} & vardesc type that is modified \\
\hline
\mbox{\texttt{ in}}  & {\em name} & name of variable \\
\hline
\mbox{\texttt{ in}}  & {\em units} & units of variable \\
\hline
\mbox{\texttt{ in}}  & {\em longname} & long name of variable \\
\hline
\mbox{\texttt{ in}}  & {\em hor\+\_\+grid} & horizonal staggering of variable \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+grid} & vertical staggering of variable \\
\hline
\mbox{\texttt{ in}}  & {\em t\+\_\+grid} & time description\+: s, p, or 1 \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+longname} & C\+M\+OR long name \\
\hline
\mbox{\texttt{ in}}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive \\
\hline
\mbox{\texttt{ in}}  & {\em caller} & calling routine? \\
\hline
\end{DoxyParams}


Definition at line 638 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{640   \textcolor{keywordtype}{type}(vardesc),              \textcolor{keywordtype}{intent(inout)} :: vd\textcolor{comment}{              !< vardesc type that is modified}}
\DoxyCodeLine{641   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: name\textcolor{comment}{            !< name of variable}}
\DoxyCodeLine{642   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: units\textcolor{comment}{           !< units of variable}}
\DoxyCodeLine{643   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: longname\textcolor{comment}{        !< long name of variable}}
\DoxyCodeLine{644   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: hor\_grid\textcolor{comment}{        !< horizonal staggering of variable}}
\DoxyCodeLine{645   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: z\_grid\textcolor{comment}{          !< vertical staggering of variable}}
\DoxyCodeLine{646   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: t\_grid\textcolor{comment}{          !< time description: s, p, or 1}}
\DoxyCodeLine{647   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_field\_name\textcolor{comment}{ !< CMOR name}}
\DoxyCodeLine{648   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_units\textcolor{comment}{      !< CMOR physical dimensions of variable}}
\DoxyCodeLine{649   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_longname\textcolor{comment}{   !< CMOR long name}}
\DoxyCodeLine{650 \textcolor{keywordtype}{  real}            , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: conversion\textcolor{comment}{      !< for unit conversions, such as needed}}
\DoxyCodeLine{651 \textcolor{comment}{                                                               !! to convert from intensive to extensive}}
\DoxyCodeLine{652   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: caller\textcolor{comment}{          !< calling routine?}}
\DoxyCodeLine{653 }
\DoxyCodeLine{654   \textcolor{keywordtype}{character(len=120)} :: cllr}
\DoxyCodeLine{655   cllr = \textcolor{stringliteral}{"mod\_vardesc"}}
\DoxyCodeLine{656   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(caller)) cllr = trim(caller)}
\DoxyCodeLine{657 }
\DoxyCodeLine{658   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(name))      \textcolor{keyword}{call }safe\_string\_copy(name, vd\%name, \textcolor{stringliteral}{"vd\%name"}, cllr)}
\DoxyCodeLine{659 }
\DoxyCodeLine{660   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(longname))  \textcolor{keyword}{call }safe\_string\_copy(longname, vd\%longname, \&}
\DoxyCodeLine{661                                \textcolor{stringliteral}{"vd\%longname of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{662   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units))     \textcolor{keyword}{call }safe\_string\_copy(units, vd\%units,       \&}
\DoxyCodeLine{663                                \textcolor{stringliteral}{"vd\%units of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{664   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(hor\_grid))  \textcolor{keyword}{call }safe\_string\_copy(hor\_grid, vd\%hor\_grid, \&}
\DoxyCodeLine{665                                \textcolor{stringliteral}{"vd\%hor\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{666   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(z\_grid))    \textcolor{keyword}{call }safe\_string\_copy(z\_grid, vd\%z\_grid,     \&}
\DoxyCodeLine{667                                \textcolor{stringliteral}{"vd\%z\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{668   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(t\_grid))    \textcolor{keyword}{call }safe\_string\_copy(t\_grid, vd\%t\_grid,     \&}
\DoxyCodeLine{669                                \textcolor{stringliteral}{"vd\%t\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{670 }
\DoxyCodeLine{671   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keyword}{call }safe\_string\_copy(cmor\_field\_name, vd\%cmor\_field\_name, \&}
\DoxyCodeLine{672                                      \textcolor{stringliteral}{"vd\%cmor\_field\_name of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{673   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units))      \textcolor{keyword}{call }safe\_string\_copy(cmor\_units, vd\%cmor\_units, \&}
\DoxyCodeLine{674                                      \textcolor{stringliteral}{"vd\%cmor\_units of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{675   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_longname))   \textcolor{keyword}{call }safe\_string\_copy(cmor\_longname, vd\%cmor\_longname, \&}
\DoxyCodeLine{676                                      \textcolor{stringliteral}{"vd\%cmor\_longname of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{677 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a0288cf8b0b8226fbefc6ac23989dee54}\label{namespacemom__io_a0288cf8b0b8226fbefc6ac23989dee54}} 
\index{mom\_io@{mom\_io}!mom\_file\_exists@{mom\_file\_exists}}
\index{mom\_file\_exists@{mom\_file\_exists}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_file\_exists()}{mom\_file\_exists()}}
{\footnotesize\ttfamily logical function mom\+\_\+io\+::mom\+\_\+file\+\_\+exists (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Returns true if the named file or its domain-\/decomposed variant exists. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file being inquired about \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\end{DoxyParams}


Definition at line 820 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{821   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{   !< The name of the file being inquired about}}
\DoxyCodeLine{822   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)} :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{823 }
\DoxyCodeLine{824 \textcolor{comment}{! This function uses the fms\_io function file\_exist to determine whether}}
\DoxyCodeLine{825 \textcolor{comment}{! a named file (or its decomposed variant) exists.}}
\DoxyCodeLine{826 }
\DoxyCodeLine{827   \textcolor{keywordtype}{logical} :: MOM\_file\_exists}
\DoxyCodeLine{828 }
\DoxyCodeLine{829   mom\_file\_exists = file\_exist(filename, mom\_domain\%mpp\_domain)}
\DoxyCodeLine{830 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a80a3125a7c246310b5580f4b90ced8a0}\label{namespacemom__io_a80a3125a7c246310b5580f4b90ced8a0}} 
\index{mom\_io@{mom\_io}!mom\_io\_init@{mom\_io\_init}}
\index{mom\_io\_init@{mom\_io\_init}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_io\_init()}{mom\_io\_init()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::mom\+\_\+io\+\_\+init (\begin{DoxyParamCaption}\item[{type(param\+\_\+file\+\_\+type), intent(in)}]{param\+\_\+file }\end{DoxyParamCaption})}



Initialize the M\+O\+M\+\_\+io module. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em param\+\_\+file} & structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


Definition at line 1042 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1043   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{  !< structure indicating the open file to}}
\DoxyCodeLine{1044 \textcolor{comment}{                                                   !! parse for model parameter values.}}
\DoxyCodeLine{1045 }
\DoxyCodeLine{1046 \textcolor{comment}{! This include declares and sets the variable "version".}}
\DoxyCodeLine{1047 \textcolor{preprocessor}{\#include "version\_variable.h"}}
\DoxyCodeLine{1048 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_io"} \textcolor{comment}{! This module's name.}}
\DoxyCodeLine{1049 }
\DoxyCodeLine{1050   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)}
\DoxyCodeLine{1051 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a59696f6954e8d111983ef8d86bbbe109}\label{namespacemom__io_a59696f6954e8d111983ef8d86bbbe109}} 
\index{mom\_io@{mom\_io}!mom\_read\_data\_1d@{mom\_read\_data\_1d}}
\index{mom\_read\_data\_1d@{mom\_read\_data\_1d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_data\_1d()}{mom\_read\_data\_1d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+data\+\_\+1d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{fieldname,  }\item[{real, dimension(\+:), intent(inout)}]{data,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read 1-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname} & The variable name of the data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em data} & The 1-\/dimensional array into which the data \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 849 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{850   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{851   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}}
\DoxyCodeLine{852 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{      !< The 1-\/dimensional array into which the data}}
\DoxyCodeLine{853   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{854 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}}
\DoxyCodeLine{855 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{856 }
\DoxyCodeLine{857   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, timelevel=timelevel, no\_domain=.true.)}
\DoxyCodeLine{858 }
\DoxyCodeLine{859   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{860     \textcolor{keyword}{data}(:) = scale*\textcolor{keyword}{data}(:)}
\DoxyCodeLine{861 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{862 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a4a26da14aed075eb784a5b82f2c6d978}\label{namespacemom__io_a4a26da14aed075eb784a5b82f2c6d978}} 
\index{mom\_io@{mom\_io}!mom\_read\_data\_2d@{mom\_read\_data\_2d}}
\index{mom\_read\_data\_2d@{mom\_read\_data\_2d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_data\_2d()}{mom\_read\_data\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+data\+\_\+2d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{fieldname,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{data,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{integer, intent(in), optional}]{position,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 2-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname} & The variable name of the data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em data} & The 2-\/dimensional array into which the data should be read \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em position} & A flag indicating where this data is located \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 868 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{870   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{871   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}}
\DoxyCodeLine{872 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{      !< The 2-\/dimensional array into which the data}}
\DoxyCodeLine{873 \textcolor{comment}{                                                     !! should be read}}
\DoxyCodeLine{874   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{875   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{876   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: position\textcolor{comment}{  !< A flag indicating where this data is located}}
\DoxyCodeLine{877 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}}
\DoxyCodeLine{878 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{879 }
\DoxyCodeLine{880   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{881 }
\DoxyCodeLine{882   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{883                  timelevel=timelevel, position=position)}
\DoxyCodeLine{884 }
\DoxyCodeLine{885   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{886     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},1), is, ie)}
\DoxyCodeLine{887     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},2), js, je)}
\DoxyCodeLine{888     \textcolor{keyword}{data}(is:ie,js:je) = scale*\textcolor{keyword}{data}(is:ie,js:je)}
\DoxyCodeLine{889 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{890 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_ae4d85b211226c10f44328e1c544a6087}\label{namespacemom__io_ae4d85b211226c10f44328e1c544a6087}} 
\index{mom\_io@{mom\_io}!mom\_read\_data\_3d@{mom\_read\_data\_3d}}
\index{mom\_read\_data\_3d@{mom\_read\_data\_3d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_data\_3d()}{mom\_read\_data\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+data\+\_\+3d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{fieldname,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{data,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{integer, intent(in), optional}]{position,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 3-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname} & The variable name of the data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em data} & The 3-\/dimensional array into which the data should be read \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em position} & A flag indicating where this data is located \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 896 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{898   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{899   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}}
\DoxyCodeLine{900 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{      !< The 3-\/dimensional array into which the data}}
\DoxyCodeLine{901 \textcolor{comment}{                                                     !! should be read}}
\DoxyCodeLine{902   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{903   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{904   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: position\textcolor{comment}{  !< A flag indicating where this data is located}}
\DoxyCodeLine{905 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}}
\DoxyCodeLine{906 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{907 }
\DoxyCodeLine{908   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{909 }
\DoxyCodeLine{910   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{911                  timelevel=timelevel, position=position)}
\DoxyCodeLine{912 }
\DoxyCodeLine{913   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{914     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},1), is, ie)}
\DoxyCodeLine{915     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},2), js, je)}
\DoxyCodeLine{916     \textcolor{keyword}{data}(is:ie,js:je,:) = scale*\textcolor{keyword}{data}(is:ie,js:je,:)}
\DoxyCodeLine{917 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{918 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_ae52771cd57953bb7e5f9d38ee9142fca}\label{namespacemom__io_ae52771cd57953bb7e5f9d38ee9142fca}} 
\index{mom\_io@{mom\_io}!mom\_read\_data\_4d@{mom\_read\_data\_4d}}
\index{mom\_read\_data\_4d@{mom\_read\_data\_4d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_data\_4d()}{mom\_read\_data\_4d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+data\+\_\+4d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{fieldname,  }\item[{real, dimension(\+:,\+:,\+:,\+:), intent(inout)}]{data,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{integer, intent(in), optional}]{position,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read a distributed 4-\/D data field named \char`\"{}fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}position\char`\"{} include C\+O\+R\+N\+ER, C\+E\+N\+T\+ER, E\+A\+S\+T\+\_\+\+F\+A\+CE and N\+O\+R\+T\+H\+\_\+\+F\+A\+CE. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em fieldname} & The variable name of the data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em data} & The 4-\/dimensional array into which the data should be read \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em position} & A flag indicating where this data is located \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 924 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{926   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{927   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}}
\DoxyCodeLine{928 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{    !< The 4-\/dimensional array into which the data}}
\DoxyCodeLine{929 \textcolor{comment}{                                                     !! should be read}}
\DoxyCodeLine{930   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{931   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{932   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: position\textcolor{comment}{  !< A flag indicating where this data is located}}
\DoxyCodeLine{933 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}}
\DoxyCodeLine{934 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{935 }
\DoxyCodeLine{936   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{937 }
\DoxyCodeLine{938   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{939                  timelevel=timelevel, position=position)}
\DoxyCodeLine{940 }
\DoxyCodeLine{941   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{942     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},1), is, ie)}
\DoxyCodeLine{943     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},2), js, je)}
\DoxyCodeLine{944     \textcolor{keyword}{data}(is:ie,js:je,:,:) = scale*\textcolor{keyword}{data}(is:ie,js:je,:,:)}
\DoxyCodeLine{945 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{946 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a5164130471f3bf80cc8657e17b5c08eb}\label{namespacemom__io_a5164130471f3bf80cc8657e17b5c08eb}} 
\index{mom\_io@{mom\_io}!mom\_read\_vector\_2d@{mom\_read\_vector\_2d}}
\index{mom\_read\_vector\_2d@{mom\_read\_vector\_2d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_vector\_2d()}{mom\_read\_vector\_2d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+vector\+\_\+2d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{u\+\_\+fieldname,  }\item[{character(len=$\ast$), intent(in)}]{v\+\_\+fieldname,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{u\+\_\+data,  }\item[{real, dimension(\+:,\+:), intent(inout)}]{v\+\_\+data,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{integer, intent(in), optional}]{stagger,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read a pair of distributed 2-\/D data fields with names given by \char`\"{}\mbox{[}uv\mbox{]}\+\_\+fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}stagger\char`\"{} include C\+G\+R\+I\+D\+\_\+\+NE, B\+G\+R\+I\+D\+\_\+\+NE, and A\+G\+R\+ID. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+fieldname} & The variable name of the u data in the file \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+fieldname} & The variable name of the v data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+data} & The 2 dimensional array into which the u-\/component of the data should be read \\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+data} & The 2 dimensional array into which the v-\/component of the data should be read \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em stagger} & A flag indicating where this vector is discretized \\
\hline
\mbox{\texttt{ in}}  & {\em scalar\+\_\+pair} & If true, a pair of scalars are to be read.\+cretized \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the fields are multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 953 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{955   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{956   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: u\_fieldname\textcolor{comment}{ !< The variable name of the u data in the file}}
\DoxyCodeLine{957   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: v\_fieldname\textcolor{comment}{ !< The variable name of the v data in the file}}
\DoxyCodeLine{958 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{intent(inout)} :: u\_data\textcolor{comment}{    !< The 2 dimensional array into which the}}
\DoxyCodeLine{959 \textcolor{comment}{                                                     !! u-\/component of the data should be read}}
\DoxyCodeLine{960 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:)},   \textcolor{keywordtype}{intent(inout)} :: v\_data\textcolor{comment}{    !< The 2 dimensional array into which the}}
\DoxyCodeLine{961 \textcolor{comment}{                                                     !! v-\/component of the data should be read}}
\DoxyCodeLine{962   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{963   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{964   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: stagger\textcolor{comment}{   !< A flag indicating where this vector is discretized}}
\DoxyCodeLine{965   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scalar\_pair\textcolor{comment}{ !< If true, a pair of scalars are to be read.cretized}}
\DoxyCodeLine{966 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the fields are multiplied}}
\DoxyCodeLine{967 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{968   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{969   \textcolor{keywordtype}{integer} :: u\_pos, v\_pos}
\DoxyCodeLine{970 }
\DoxyCodeLine{971   u\_pos = east\_face ; v\_pos = north\_face}
\DoxyCodeLine{972   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stagger)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{973     \textcolor{keywordflow}{if} (stagger == cgrid\_ne) \textcolor{keywordflow}{then} ; u\_pos = east\_face ; v\_pos = north\_face}
\DoxyCodeLine{974     \textcolor{keywordflow}{elseif} (stagger == bgrid\_ne) \textcolor{keywordflow}{then} ; u\_pos = corner ; v\_pos = corner}
\DoxyCodeLine{975     \textcolor{keywordflow}{elseif} (stagger == agrid) \textcolor{keywordflow}{then} ; u\_pos = center ; v\_pos = center ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{976 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{977 }
\DoxyCodeLine{978   \textcolor{keyword}{call }read\_data(filename, u\_fieldname, u\_data, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{979                  timelevel=timelevel, position=u\_pos)}
\DoxyCodeLine{980   \textcolor{keyword}{call }read\_data(filename, v\_fieldname, v\_data, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{981                  timelevel=timelevel, position=v\_pos)}
\DoxyCodeLine{982 }
\DoxyCodeLine{983   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{984     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(u\_data,1), is, ie)}
\DoxyCodeLine{985     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(u\_data,2), js, je)}
\DoxyCodeLine{986     u\_data(is:ie,js:je) = scale*u\_data(is:ie,js:je)}
\DoxyCodeLine{987     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(v\_data,1), is, ie)}
\DoxyCodeLine{988     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(v\_data,2), js, je)}
\DoxyCodeLine{989     v\_data(is:ie,js:je) = scale*v\_data(is:ie,js:je)}
\DoxyCodeLine{990 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{991 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_ac5eac11ba2b78f5d1146f4541d50abd5}\label{namespacemom__io_ac5eac11ba2b78f5d1146f4541d50abd5}} 
\index{mom\_io@{mom\_io}!mom\_read\_vector\_3d@{mom\_read\_vector\_3d}}
\index{mom\_read\_vector\_3d@{mom\_read\_vector\_3d}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{mom\_read\_vector\_3d()}{mom\_read\_vector\_3d()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::mom\+\_\+read\+\_\+vector\+\_\+3d (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{u\+\_\+fieldname,  }\item[{character(len=$\ast$), intent(in)}]{v\+\_\+fieldname,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{u\+\_\+data,  }\item[{real, dimension(\+:,\+:,\+:), intent(inout)}]{v\+\_\+data,  }\item[{type(mom\+\_\+domain\+\_\+type), intent(in)}]{M\+O\+M\+\_\+\+Domain,  }\item[{integer, intent(in), optional}]{timelevel,  }\item[{integer, intent(in), optional}]{stagger,  }\item[{logical, intent(in), optional}]{scalar\+\_\+pair,  }\item[{real, intent(in), optional}]{scale }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



This function uses the fms\+\_\+io function read\+\_\+data to read a pair of distributed 3-\/D data fields with names given by \char`\"{}\mbox{[}uv\mbox{]}\+\_\+fieldname\char`\"{} from file \char`\"{}filename\char`\"{}. Valid values for \char`\"{}stagger\char`\"{} include C\+G\+R\+I\+D\+\_\+\+NE, B\+G\+R\+I\+D\+\_\+\+NE, and A\+G\+R\+ID. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & The name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em u\+\_\+fieldname} & The variable name of the u data in the file \\
\hline
\mbox{\texttt{ in}}  & {\em v\+\_\+fieldname} & The variable name of the v data in the file \\
\hline
\mbox{\texttt{ in,out}}  & {\em u\+\_\+data} & The 3 dimensional array into which the u-\/component of the data should be read \\
\hline
\mbox{\texttt{ in,out}}  & {\em v\+\_\+data} & The 3 dimensional array into which the v-\/component of the data should be read \\
\hline
\mbox{\texttt{ in}}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\mbox{\texttt{ in}}  & {\em timelevel} & The time level in the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em stagger} & A flag indicating where this vector is discretized \\
\hline
\mbox{\texttt{ in}}  & {\em scalar\+\_\+pair} & If true, a pair of scalars are to be read.\+cretized \\
\hline
\mbox{\texttt{ in}}  & {\em scale} & A scaling factor that the fields are multiplied by before they are returned. \\
\hline
\end{DoxyParams}


Definition at line 998 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{1000   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}}
\DoxyCodeLine{1001   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: u\_fieldname\textcolor{comment}{ !< The variable name of the u data in the file}}
\DoxyCodeLine{1002   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: v\_fieldname\textcolor{comment}{ !< The variable name of the v data in the file}}
\DoxyCodeLine{1003 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: u\_data\textcolor{comment}{    !< The 3 dimensional array into which the}}
\DoxyCodeLine{1004 \textcolor{comment}{                                                     !! u-\/component of the data should be read}}
\DoxyCodeLine{1005 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: v\_data\textcolor{comment}{    !< The 3 dimensional array into which the}}
\DoxyCodeLine{1006 \textcolor{comment}{                                                     !! v-\/component of the data should be read}}
\DoxyCodeLine{1007   \textcolor{keywordtype}{type}(MOM\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: MOM\_Domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}}
\DoxyCodeLine{1008   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}}
\DoxyCodeLine{1009   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: stagger\textcolor{comment}{   !< A flag indicating where this vector is discretized}}
\DoxyCodeLine{1010   \textcolor{keywordtype}{logical},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scalar\_pair\textcolor{comment}{ !< If true, a pair of scalars are to be read.cretized}}
\DoxyCodeLine{1011 \textcolor{keywordtype}{  real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the fields are multiplied}}
\DoxyCodeLine{1012 \textcolor{comment}{                                                     !! by before they are returned.}}
\DoxyCodeLine{1013 }
\DoxyCodeLine{1014   \textcolor{keywordtype}{integer} :: is, ie, js, je}
\DoxyCodeLine{1015   \textcolor{keywordtype}{integer} :: u\_pos, v\_pos}
\DoxyCodeLine{1016 }
\DoxyCodeLine{1017   u\_pos = east\_face ; v\_pos = north\_face}
\DoxyCodeLine{1018   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(stagger)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1019     \textcolor{keywordflow}{if} (stagger == cgrid\_ne) \textcolor{keywordflow}{then} ; u\_pos = east\_face ; v\_pos = north\_face}
\DoxyCodeLine{1020     \textcolor{keywordflow}{elseif} (stagger == bgrid\_ne) \textcolor{keywordflow}{then} ; u\_pos = corner ; v\_pos = corner}
\DoxyCodeLine{1021     \textcolor{keywordflow}{elseif} (stagger == agrid) \textcolor{keywordflow}{then} ; u\_pos = center ; v\_pos = center ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1022 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{1023 }
\DoxyCodeLine{1024   \textcolor{keyword}{call }read\_data(filename, u\_fieldname, u\_data, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{1025                  timelevel=timelevel, position=u\_pos)}
\DoxyCodeLine{1026   \textcolor{keyword}{call }read\_data(filename, v\_fieldname, v\_data, mom\_domain\%mpp\_domain, \&}
\DoxyCodeLine{1027                  timelevel=timelevel, position=v\_pos)}
\DoxyCodeLine{1028 }
\DoxyCodeLine{1029   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}}
\DoxyCodeLine{1030     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(u\_data,1), is, ie)}
\DoxyCodeLine{1031     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(u\_data,2), js, je)}
\DoxyCodeLine{1032     u\_data(is:ie,js:je,:) = scale*u\_data(is:ie,js:je,:)}
\DoxyCodeLine{1033     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(v\_data,1), is, ie)}
\DoxyCodeLine{1034     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(v\_data,2), js, je)}
\DoxyCodeLine{1035     v\_data(is:ie,js:je,:) = scale*v\_data(is:ie,js:je,:)}
\DoxyCodeLine{1036 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}}
\DoxyCodeLine{1037 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a79952045e028c6882f5b04ea5a1a83f7}\label{namespacemom__io_a79952045e028c6882f5b04ea5a1a83f7}} 
\index{mom\_io@{mom\_io}!num\_timelevels@{num\_timelevels}}
\index{num\_timelevels@{num\_timelevels}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{num\_timelevels()}{num\_timelevels()}}
{\footnotesize\ttfamily integer function, public mom\+\_\+io\+::num\+\_\+timelevels (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{varname,  }\item[{integer, intent(in), optional}]{min\+\_\+dims }\end{DoxyParamCaption})}



This function determines how many time levels a variable has. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em varname} & variable whose number of time levels are to be returned \\
\hline
\mbox{\texttt{ in}}  & {\em min\+\_\+dims} & The minimum number of dimensions a variable must have if it has a time dimension. If the variable has 1 less dimension than this, then 0 is returned. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
number of time levels varname has in filename 
\end{DoxyReturn}


Definition at line 477 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{478   \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{   !< name of the file to read}}
\DoxyCodeLine{479   \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)} :: varname\textcolor{comment}{    !< variable whose number of time levels}}
\DoxyCodeLine{480 \textcolor{comment}{                                              !! are to be returned}}
\DoxyCodeLine{481   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: min\_dims\textcolor{comment}{   !< The minimum number of dimensions a variable must have}}
\DoxyCodeLine{482 \textcolor{comment}{                                              !! if it has a time dimension.  If the variable has 1 less}}
\DoxyCodeLine{483 \textcolor{comment}{                                              !! dimension than this, then 0 is returned.}}
\DoxyCodeLine{484   \textcolor{keywordtype}{integer} :: n\_time\textcolor{comment}{                           !< number of time levels varname has in filename}}
\DoxyCodeLine{485 }
\DoxyCodeLine{486   \textcolor{keywordtype}{logical} :: found}
\DoxyCodeLine{487   \textcolor{keywordtype}{character(len=200)} :: msg}
\DoxyCodeLine{488   \textcolor{keywordtype}{character(len=nf90\_max\_name)} :: name}
\DoxyCodeLine{489   \textcolor{keywordtype}{integer} :: ncid, nvars, status, varid, ndims, n}
\DoxyCodeLine{490   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable} :: varids(:)}
\DoxyCodeLine{491   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(nf90\_max\_var\_dims)} :: dimids}
\DoxyCodeLine{492 }
\DoxyCodeLine{493   n\_time = -\/1}
\DoxyCodeLine{494   found = .false.}
\DoxyCodeLine{495 }
\DoxyCodeLine{496   status = nf90\_open(filename, nf90\_nowrite, ncid)}
\DoxyCodeLine{497   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{498     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{499         \textcolor{stringliteral}{" Difficulties opening "}//trim(filename)//\textcolor{stringliteral}{" -\/ "}//\&}
\DoxyCodeLine{500         trim(nf90\_strerror(status)))}
\DoxyCodeLine{501     \textcolor{keywordflow}{return}}
\DoxyCodeLine{502 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{503 }
\DoxyCodeLine{504   status = nf90\_inquire(ncid, nvariables=nvars)}
\DoxyCodeLine{505   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{506     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{507         \textcolor{stringliteral}{" Difficulties getting the number of variables in file "}//\&}
\DoxyCodeLine{508         trim(filename)//\textcolor{stringliteral}{" -\/ "}//trim(nf90\_strerror(status)))}
\DoxyCodeLine{509     \textcolor{keywordflow}{return}}
\DoxyCodeLine{510 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{511 }
\DoxyCodeLine{512   \textcolor{keywordflow}{if} (nvars < 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{513     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{514         \textcolor{stringliteral}{" There appear not to be any variables in "}//trim(filename))}
\DoxyCodeLine{515     \textcolor{keywordflow}{return}}
\DoxyCodeLine{516 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{517 }
\DoxyCodeLine{518 }
\DoxyCodeLine{519   \textcolor{keyword}{allocate}(varids(nvars))}
\DoxyCodeLine{520 }
\DoxyCodeLine{521   status = nf90\_inq\_varids(ncid, nvars, varids)}
\DoxyCodeLine{522   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{523     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{524         \textcolor{stringliteral}{" Difficulties getting the variable IDs in file "}//\&}
\DoxyCodeLine{525         trim(filename)//\textcolor{stringliteral}{" -\/ "}//trim(nf90\_strerror(status)))}
\DoxyCodeLine{526     \textcolor{keyword}{deallocate}(varids) ; \textcolor{keywordflow}{return}}
\DoxyCodeLine{527 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{528 }
\DoxyCodeLine{529   \textcolor{keywordflow}{do} n = 1,nvars}
\DoxyCodeLine{530     status = nf90\_inquire\_variable(ncid, varids(n), name=name)}
\DoxyCodeLine{531     \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{532       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{533           \textcolor{stringliteral}{" Difficulties getting a variable name in file "}//\&}
\DoxyCodeLine{534           trim(filename)//\textcolor{stringliteral}{" -\/ "}//trim(nf90\_strerror(status)))}
\DoxyCodeLine{535 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{536 }
\DoxyCodeLine{537     \textcolor{keywordflow}{if} (trim(lowercase(name)) == trim(lowercase(varname))) \textcolor{keywordflow}{then}}
\DoxyCodeLine{538       \textcolor{keywordflow}{if} (found) \textcolor{keywordflow}{then}}
\DoxyCodeLine{539         \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{540           \textcolor{stringliteral}{" Two variables match the case-\/insensitive name "}//trim(varname)//\&}
\DoxyCodeLine{541           \textcolor{stringliteral}{" in file "}//trim(filename)//\textcolor{stringliteral}{" -\/ "}//trim(nf90\_strerror(status)))}
\DoxyCodeLine{542       \textcolor{keywordflow}{else}}
\DoxyCodeLine{543         varid = varids(n) ; found = .true.}
\DoxyCodeLine{544 \textcolor{keywordflow}{      endif}}
\DoxyCodeLine{545 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{546 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{547 }
\DoxyCodeLine{548   \textcolor{keyword}{deallocate}(varids)}
\DoxyCodeLine{549 }
\DoxyCodeLine{550   \textcolor{keywordflow}{if} (.not.found) \textcolor{keywordflow}{then}}
\DoxyCodeLine{551     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{552         \textcolor{stringliteral}{" variable "}//trim(varname)//\textcolor{stringliteral}{" was not found in file "}//\&}
\DoxyCodeLine{553         trim(filename))}
\DoxyCodeLine{554     \textcolor{keywordflow}{return}}
\DoxyCodeLine{555 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{556 }
\DoxyCodeLine{557   status = nf90\_inquire\_variable(ncid, varid, ndims = ndims)}
\DoxyCodeLine{558   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{559     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{560       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting number of dimensions of "}//\&}
\DoxyCodeLine{561       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))}
\DoxyCodeLine{562     \textcolor{keywordflow}{return}}
\DoxyCodeLine{563 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{564 }
\DoxyCodeLine{565   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(min\_dims)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{566     \textcolor{keywordflow}{if} (ndims < min\_dims-\/1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{567       \textcolor{keyword}{write}(msg, \textcolor{stringliteral}{'(I3)'}) min\_dims}
\DoxyCodeLine{568       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"num\_timelevels: variable "}//trim(varname)//\&}
\DoxyCodeLine{569         \textcolor{stringliteral}{" in file "}//trim(filename)//\textcolor{stringliteral}{" has fewer than min\_dims = "}//trim(msg)//\&}
\DoxyCodeLine{570         \textcolor{stringliteral}{" dimensions."})}
\DoxyCodeLine{571     \textcolor{keywordflow}{elseif} (ndims == min\_dims -\/ 1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{572       n\_time = 0 ; \textcolor{keywordflow}{return}}
\DoxyCodeLine{573 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{574 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{575 }
\DoxyCodeLine{576   status = nf90\_inquire\_variable(ncid, varid, dimids = dimids(1:ndims))}
\DoxyCodeLine{577   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}}
\DoxyCodeLine{578     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{579       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting last dimension ID for "}//\&}
\DoxyCodeLine{580       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))}
\DoxyCodeLine{581     \textcolor{keywordflow}{return}}
\DoxyCodeLine{582 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{583 }
\DoxyCodeLine{584   status = nf90\_inquire\_dimension(ncid, dimids(ndims), len=n\_time)}
\DoxyCodeLine{585   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//\&}
\DoxyCodeLine{586       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting number of time levels of "}//\&}
\DoxyCodeLine{587       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))}
\DoxyCodeLine{588 }
\DoxyCodeLine{589   \textcolor{keywordflow}{return}}
\DoxyCodeLine{590 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_aa583d22dfaf16e3157b2741d838f5240}\label{namespacemom__io_aa583d22dfaf16e3157b2741d838f5240}} 
\index{mom\_io@{mom\_io}!query\_vardesc@{query\_vardesc}}
\index{query\_vardesc@{query\_vardesc}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{query\_vardesc()}{query\_vardesc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::query\+\_\+vardesc (\begin{DoxyParamCaption}\item[{type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}), intent(in)}]{vd,  }\item[{character(len=$\ast$), intent(out), optional}]{name,  }\item[{character(len=$\ast$), intent(out), optional}]{units,  }\item[{character(len=$\ast$), intent(out), optional}]{longname,  }\item[{character(len=$\ast$), intent(out), optional}]{hor\+\_\+grid,  }\item[{character(len=$\ast$), intent(out), optional}]{z\+\_\+grid,  }\item[{character(len=$\ast$), intent(out), optional}]{t\+\_\+grid,  }\item[{character(len=$\ast$), intent(out), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(out), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(out), optional}]{cmor\+\_\+longname,  }\item[{real, intent(out), optional}]{conversion,  }\item[{character(len=$\ast$), intent(in), optional}]{caller }\end{DoxyParamCaption})}



This routine queries vardesc. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em vd} & vardesc type that is queried \\
\hline
\mbox{\texttt{ out}}  & {\em name} & name of variable \\
\hline
\mbox{\texttt{ out}}  & {\em units} & units of variable \\
\hline
\mbox{\texttt{ out}}  & {\em longname} & long name of variable \\
\hline
\mbox{\texttt{ out}}  & {\em hor\+\_\+grid} & horiz staggering of variable \\
\hline
\mbox{\texttt{ out}}  & {\em z\+\_\+grid} & vert staggering of variable \\
\hline
\mbox{\texttt{ out}}  & {\em t\+\_\+grid} & time description\+: s, p, or 1 \\
\hline
\mbox{\texttt{ out}}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name \\
\hline
\mbox{\texttt{ out}}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable \\
\hline
\mbox{\texttt{ out}}  & {\em cmor\+\_\+longname} & C\+M\+OR long name \\
\hline
\mbox{\texttt{ out}}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive \\
\hline
\mbox{\texttt{ in}}  & {\em caller} & calling routine? \\
\hline
\end{DoxyParams}


Definition at line 697 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{699   \textcolor{keywordtype}{type}(vardesc),              \textcolor{keywordtype}{intent(in)}  :: vd\textcolor{comment}{                 !< vardesc type that is queried}}
\DoxyCodeLine{700   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: name\textcolor{comment}{               !< name of variable}}
\DoxyCodeLine{701   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: units\textcolor{comment}{              !< units of variable}}
\DoxyCodeLine{702   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: longname\textcolor{comment}{           !< long name of variable}}
\DoxyCodeLine{703   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: hor\_grid\textcolor{comment}{           !< horiz staggering of variable}}
\DoxyCodeLine{704   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: z\_grid\textcolor{comment}{             !< vert staggering of variable}}
\DoxyCodeLine{705   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: t\_grid\textcolor{comment}{             !< time description: s, p, or 1}}
\DoxyCodeLine{706   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: cmor\_field\_name\textcolor{comment}{    !< CMOR name}}
\DoxyCodeLine{707   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: cmor\_units\textcolor{comment}{         !< CMOR physical dimensions of variable}}
\DoxyCodeLine{708   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: cmor\_longname\textcolor{comment}{      !< CMOR long name}}
\DoxyCodeLine{709 \textcolor{keywordtype}{  real}            , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(out)} :: conversion\textcolor{comment}{         !< for unit conversions, such as needed to}}
\DoxyCodeLine{710 \textcolor{comment}{                                                                !! convert from intensive to extensive}}
\DoxyCodeLine{711   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: caller\textcolor{comment}{             !< calling routine?}}
\DoxyCodeLine{712 }
\DoxyCodeLine{713 }
\DoxyCodeLine{714   \textcolor{keywordtype}{character(len=120)} :: cllr}
\DoxyCodeLine{715   cllr = \textcolor{stringliteral}{"mod\_vardesc"}}
\DoxyCodeLine{716   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(caller)) cllr = trim(caller)}
\DoxyCodeLine{717 }
\DoxyCodeLine{718   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(name))      \textcolor{keyword}{call }safe\_string\_copy(vd\%name, name,         \&}
\DoxyCodeLine{719                                \textcolor{stringliteral}{"vd\%name of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{720   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(longname))  \textcolor{keyword}{call }safe\_string\_copy(vd\%longname, longname, \&}
\DoxyCodeLine{721                                \textcolor{stringliteral}{"vd\%longname of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{722   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units))     \textcolor{keyword}{call }safe\_string\_copy(vd\%units, units,       \&}
\DoxyCodeLine{723                                \textcolor{stringliteral}{"vd\%units of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{724   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(hor\_grid))  \textcolor{keyword}{call }safe\_string\_copy(vd\%hor\_grid, hor\_grid, \&}
\DoxyCodeLine{725                                \textcolor{stringliteral}{"vd\%hor\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{726   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(z\_grid))    \textcolor{keyword}{call }safe\_string\_copy(vd\%z\_grid, z\_grid,     \&}
\DoxyCodeLine{727                                \textcolor{stringliteral}{"vd\%z\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{728   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(t\_grid))    \textcolor{keyword}{call }safe\_string\_copy(vd\%t\_grid, t\_grid,     \&}
\DoxyCodeLine{729                                \textcolor{stringliteral}{"vd\%t\_grid of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{730 }
\DoxyCodeLine{731   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keyword}{call }safe\_string\_copy(vd\%cmor\_field\_name, cmor\_field\_name, \&}
\DoxyCodeLine{732                                      \textcolor{stringliteral}{"vd\%cmor\_field\_name of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{733   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units))      \textcolor{keyword}{call }safe\_string\_copy(vd\%cmor\_units, cmor\_units,          \&}
\DoxyCodeLine{734                                      \textcolor{stringliteral}{"vd\%cmor\_units of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{735   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_longname))   \textcolor{keyword}{call }safe\_string\_copy(vd\%cmor\_longname, cmor\_longname, \&}
\DoxyCodeLine{736                                      \textcolor{stringliteral}{"vd\%cmor\_longname of "}//trim(vd\%name), cllr)}
\DoxyCodeLine{737 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a9cbd4826c272e6b7a35ad95894a977c3}\label{namespacemom__io_a9cbd4826c272e6b7a35ad95894a977c3}} 
\index{mom\_io@{mom\_io}!read\_axis\_data@{read\_axis\_data}}
\index{read\_axis\_data@{read\_axis\_data}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{read\_axis\_data()}{read\_axis\_data()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::read\+\_\+axis\+\_\+data (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{character(len=$\ast$), intent(in)}]{axis\+\_\+name,  }\item[{real, dimension(\+:), intent(out)}]{var }\end{DoxyParamCaption})}



Read the data associated with a named axis in a file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em filename} & Name of the file to read \\
\hline
\mbox{\texttt{ in}}  & {\em axis\+\_\+name} & Name of the axis to read \\
\hline
\mbox{\texttt{ out}}  & {\em var} & The axis location data \\
\hline
\end{DoxyParams}


Definition at line 437 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{438   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)}  :: filename\textcolor{comment}{  !< Name of the file to read}}
\DoxyCodeLine{439   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)}  :: axis\_name\textcolor{comment}{ !< Name of the axis to read}}
\DoxyCodeLine{440 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)} :: var\textcolor{comment}{       !< The axis location data}}
\DoxyCodeLine{441 }
\DoxyCodeLine{442   \textcolor{keywordtype}{integer} :: i,len,unit, ndim, nvar, natt, ntime}
\DoxyCodeLine{443   \textcolor{keywordtype}{logical} :: axis\_found}
\DoxyCodeLine{444   \textcolor{keywordtype}{type}(axistype), \textcolor{keywordtype}{allocatable} :: axes(:)}
\DoxyCodeLine{445   \textcolor{keywordtype}{type}(axistype) :: time\_axis}
\DoxyCodeLine{446   \textcolor{keywordtype}{character(len=32)} :: name, units}
\DoxyCodeLine{447 }
\DoxyCodeLine{448   \textcolor{keyword}{call }open\_file(unit, trim(filename), action=mpp\_rdonly, form=mpp\_netcdf, \&}
\DoxyCodeLine{449                  threading=mpp\_multi, fileset=single\_file)}
\DoxyCodeLine{450 }
\DoxyCodeLine{451 \textcolor{comment}{!Find the number of variables (nvar) in this file}}
\DoxyCodeLine{452   \textcolor{keyword}{call }mpp\_get\_info(unit, ndim, nvar, natt, ntime)}
\DoxyCodeLine{453 \textcolor{comment}{! -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{454 \textcolor{comment}{! Allocate space for the number of axes in the data file.}}
\DoxyCodeLine{455 \textcolor{comment}{! -\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/-\/}}
\DoxyCodeLine{456   \textcolor{keyword}{allocate}(axes(ndim))}
\DoxyCodeLine{457   \textcolor{keyword}{call }mpp\_get\_axes(unit, axes, time\_axis)}
\DoxyCodeLine{458 }
\DoxyCodeLine{459   axis\_found = .false.}
\DoxyCodeLine{460   \textcolor{keywordflow}{do} i = 1, ndim}
\DoxyCodeLine{461     \textcolor{keyword}{call }mpp\_get\_atts(axes(i), name=name,len=len,units=units)}
\DoxyCodeLine{462     \textcolor{keywordflow}{if} (name == axis\_name) \textcolor{keywordflow}{then}}
\DoxyCodeLine{463       axis\_found = .true.}
\DoxyCodeLine{464       \textcolor{keyword}{call }get\_axis\_data(axes(i),var)}
\DoxyCodeLine{465       \textcolor{keywordflow}{exit}}
\DoxyCodeLine{466 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{467 \textcolor{keywordflow}{  enddo}}
\DoxyCodeLine{468 }
\DoxyCodeLine{469   \textcolor{keywordflow}{if} (.not.axis\_found) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io read\_axis\_data: "}//\&}
\DoxyCodeLine{470     \textcolor{stringliteral}{"Unable to find axis "}//trim(axis\_name)//\textcolor{stringliteral}{" in file "}//trim(filename))}
\DoxyCodeLine{471 }
\DoxyCodeLine{472   \textcolor{keyword}{deallocate}(axes)}
\DoxyCodeLine{473 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_ac15e7cf282a5b17192ffb7561537cb8c}\label{namespacemom__io_ac15e7cf282a5b17192ffb7561537cb8c}} 
\index{mom\_io@{mom\_io}!reopen\_file@{reopen\_file}}
\index{reopen\_file@{reopen\_file}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{reopen\_file()}{reopen\_file()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::reopen\+\_\+file (\begin{DoxyParamCaption}\item[{integer, intent(out)}]{unit,  }\item[{character(len=$\ast$), intent(in)}]{filename,  }\item[{type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}), dimension(\+:), intent(in)}]{vars,  }\item[{integer, intent(in)}]{novars,  }\item[{type(fieldtype), dimension(\+:), intent(inout)}]{fields,  }\item[{integer, intent(in), optional}]{threading,  }\item[{real, intent(in), optional}]{timeunit,  }\item[{type(ocean\+\_\+grid\+\_\+type), intent(in), optional}]{G,  }\item[{type(dyn\+\_\+horgrid\+\_\+type), intent(in), optional}]{dG,  }\item[{type(verticalgrid\+\_\+type), intent(in), optional}]{GV }\end{DoxyParamCaption})}



This routine opens an existing Net\+C\+DF file for output. If it does not find the file, a new file is created. It also sets up structures that describe this file and the variables that will later be written to this file. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ out}}  & {\em unit} & unit id of an open file or -\/1 on a nonwriting PE with single file output \\
\hline
\mbox{\texttt{ in}}  & {\em filename} & full path to the file to create \\
\hline
\mbox{\texttt{ in}}  & {\em vars} & structures describing fields written to filename \\
\hline
\mbox{\texttt{ in}}  & {\em novars} & number of fields written to filename \\
\hline
\mbox{\texttt{ in,out}}  & {\em fields} & array of fieldtypes for each variable \\
\hline
\mbox{\texttt{ in}}  & {\em threading} & S\+I\+N\+G\+L\+E\+\_\+\+F\+I\+LE or M\+U\+L\+T\+I\+P\+LE \\
\hline
\mbox{\texttt{ in}}  & {\em timeunit} & length of the units for time \mbox{[}s\mbox{]}. The default value is 86400.\+0, for 1 day. \\
\hline
\mbox{\texttt{ in}}  & {\em g} & ocean horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes. \\
\hline
\mbox{\texttt{ in}}  & {\em dg} & dynamic horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes. \\
\hline
\mbox{\texttt{ in}}  & {\em gv} & ocean vertical grid structure, which is required if a new file uses any vertical grid axes. \\
\hline
\end{DoxyParams}


Definition at line 352 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{353   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(out)}   :: unit\textcolor{comment}{       !< unit id of an open file or -\/1 on a}}
\DoxyCodeLine{354 \textcolor{comment}{                                                     !! nonwriting PE with single file output}}
\DoxyCodeLine{355   \textcolor{keywordtype}{character(len=*)},      \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{   !< full path to the file to create}}
\DoxyCodeLine{356   \textcolor{keywordtype}{type}(vardesc),         \textcolor{keywordtype}{intent(in)}    :: vars(:)\textcolor{comment}{    !< structures describing fields written to filename}}
\DoxyCodeLine{357   \textcolor{keywordtype}{integer},               \textcolor{keywordtype}{intent(in)}    :: novars\textcolor{comment}{     !< number of fields written to filename}}
\DoxyCodeLine{358   \textcolor{keywordtype}{type}(fieldtype),       \textcolor{keywordtype}{intent(inout)} :: fields(:)\textcolor{comment}{  !< array of fieldtypes for each variable}}
\DoxyCodeLine{359   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional},     \textcolor{keywordtype}{intent(in)}    :: threading\textcolor{comment}{  !< SINGLE\_FILE or MULTIPLE}}
\DoxyCodeLine{360 \textcolor{keywordtype}{  real}, \textcolor{keywordtype}{optional},        \textcolor{keywordtype}{intent(in)}    :: timeunit\textcolor{comment}{   !< length of the units for time [s]. The}}
\DoxyCodeLine{361 \textcolor{comment}{                                                     !! default value is 86400.0, for 1 day.}}
\DoxyCodeLine{362   \textcolor{keywordtype}{type}(ocean\_grid\_type),   \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: G\textcolor{comment}{ !< ocean horizontal grid structure; G or dG}}
\DoxyCodeLine{363 \textcolor{comment}{                                                     !! is required if a new file uses any}}
\DoxyCodeLine{364 \textcolor{comment}{                                                     !! horizontal grid axes.}}
\DoxyCodeLine{365   \textcolor{keywordtype}{type}(dyn\_horgrid\_type),  \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: dG\textcolor{comment}{ !< dynamic horizontal grid structure; G or dG}}
\DoxyCodeLine{366 \textcolor{comment}{                                                     !! is required if a new file uses any}}
\DoxyCodeLine{367 \textcolor{comment}{                                                     !! horizontal grid axes.}}
\DoxyCodeLine{368   \textcolor{keywordtype}{type}(verticalGrid\_type), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: GV\textcolor{comment}{ !< ocean vertical grid structure, which is}}
\DoxyCodeLine{369 \textcolor{comment}{                                                     !! required if a new file uses any}}
\DoxyCodeLine{370 \textcolor{comment}{                                                     !! vertical grid axes.}}
\DoxyCodeLine{371 }
\DoxyCodeLine{372   \textcolor{keywordtype}{type}(MOM\_domain\_type), \textcolor{keywordtype}{pointer} :: Domain => null()}
\DoxyCodeLine{373   \textcolor{keywordtype}{character(len=200)} :: check\_name, mesg}
\DoxyCodeLine{374   \textcolor{keywordtype}{integer} :: length, ndim, nvar, natt, ntime, thread}
\DoxyCodeLine{375   \textcolor{keywordtype}{logical} :: exists, one\_file, domain\_set}
\DoxyCodeLine{376 }
\DoxyCodeLine{377   thread = single\_file}
\DoxyCodeLine{378   \textcolor{keywordflow}{if} (\textcolor{keyword}{PRESENT}(threading)) thread = threading}
\DoxyCodeLine{379 }
\DoxyCodeLine{380   check\_name = filename}
\DoxyCodeLine{381   length = len(trim(check\_name))}
\DoxyCodeLine{382   \textcolor{keywordflow}{if} (check\_name(length-\/2:length) /= \textcolor{stringliteral}{".nc"}) check\_name = trim(check\_name)//\textcolor{stringliteral}{".nc"}}
\DoxyCodeLine{383   \textcolor{keywordflow}{if} (thread /= single\_file) check\_name = trim(check\_name)//\textcolor{stringliteral}{".0000"}}
\DoxyCodeLine{384 }
\DoxyCodeLine{385   \textcolor{keyword}{inquire}(file=check\_name,exist=exists)}
\DoxyCodeLine{386 }
\DoxyCodeLine{387   \textcolor{keywordflow}{if} (.not.exists) \textcolor{keywordflow}{then}}
\DoxyCodeLine{388     \textcolor{keyword}{call }create\_file(unit, filename, vars, novars, fields, threading, timeunit, \&}
\DoxyCodeLine{389                      g=g, dg=dg, gv=gv)}
\DoxyCodeLine{390   \textcolor{keywordflow}{else}}
\DoxyCodeLine{391 }
\DoxyCodeLine{392     domain\_set = .false.}
\DoxyCodeLine{393     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(g)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{394       domain\_set = .true. ; domain => g\%Domain}
\DoxyCodeLine{395     \textcolor{keywordflow}{elseif} (\textcolor{keyword}{present}(dg)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{396       domain\_set = .true. ; domain => dg\%Domain}
\DoxyCodeLine{397 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{398 }
\DoxyCodeLine{399     one\_file = .true.}
\DoxyCodeLine{400     \textcolor{keywordflow}{if} (domain\_set) one\_file = (thread == single\_file)}
\DoxyCodeLine{401 }
\DoxyCodeLine{402     \textcolor{keywordflow}{if} (one\_file) \textcolor{keywordflow}{then}}
\DoxyCodeLine{403       \textcolor{keyword}{call }open\_file(unit, filename, mpp\_append, mpp\_netcdf, threading=thread)}
\DoxyCodeLine{404     \textcolor{keywordflow}{else}}
\DoxyCodeLine{405       \textcolor{keyword}{call }open\_file(unit, filename, mpp\_append, mpp\_netcdf, domain=domain\%mpp\_domain)}
\DoxyCodeLine{406 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{407     \textcolor{keywordflow}{if} (unit < 0) \textcolor{keywordflow}{return}}
\DoxyCodeLine{408 }
\DoxyCodeLine{409     \textcolor{keyword}{call }mpp\_get\_info(unit, ndim, nvar, natt, ntime)}
\DoxyCodeLine{410 }
\DoxyCodeLine{411     \textcolor{keywordflow}{if} (nvar == -\/1) \textcolor{keywordflow}{then}}
\DoxyCodeLine{412       \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Reopening file "},trim(filename),\textcolor{stringliteral}{" apparently had "},nvar,\&}
\DoxyCodeLine{413                      \textcolor{stringliteral}{" variables. Clobbering and creating file with "},novars,\textcolor{stringliteral}{" instead."}}
\DoxyCodeLine{414       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"MOM\_io: "}//mesg)}
\DoxyCodeLine{415       \textcolor{keyword}{call }create\_file(unit, filename, vars, novars, fields, threading, timeunit, g=g, gv=gv)}
\DoxyCodeLine{416     \textcolor{keywordflow}{elseif} (nvar /= novars) \textcolor{keywordflow}{then}}
\DoxyCodeLine{417       \textcolor{keyword}{write} (mesg,*) \textcolor{stringliteral}{"Reopening file "},trim(filename),\textcolor{stringliteral}{" with "},novars,\&}
\DoxyCodeLine{418                      \textcolor{stringliteral}{" variables instead of "},nvar,\textcolor{stringliteral}{"."}}
\DoxyCodeLine{419       \textcolor{keyword}{call }mom\_error(fatal,\textcolor{stringliteral}{"MOM\_io: "}//mesg)}
\DoxyCodeLine{420 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{421 }
\DoxyCodeLine{422     \textcolor{keywordflow}{if} (nvar>0) \textcolor{keyword}{call }mpp\_get\_fields(unit,fields(1:nvar))}
\DoxyCodeLine{423 }
\DoxyCodeLine{424     \textcolor{comment}{! Check the field names...}}
\DoxyCodeLine{425 \textcolor{comment}{!    do i=1,nvar}}
\DoxyCodeLine{426 \textcolor{comment}{!      call mpp\_get\_field\_atts(fields(i),name)}}
\DoxyCodeLine{427 \textcolor{comment}{!      !if (trim(name) /= trim(vars\%name) then}}
\DoxyCodeLine{428 \textcolor{comment}{!      !write (mesg,'("Reopening file ",a," variable ",a," is called ",a,".")',\&}}
\DoxyCodeLine{429 \textcolor{comment}{!      !    filename,vars\%name,name)}}
\DoxyCodeLine{430 \textcolor{comment}{!      !call MOM\_error(NOTE,"MOM\_io: "//mesg)}}
\DoxyCodeLine{431 \textcolor{comment}{!    enddo}}
\DoxyCodeLine{432 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{433 }

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_ac4bc408e8b38dbd669842753f26ebf88}\label{namespacemom__io_ac4bc408e8b38dbd669842753f26ebf88}} 
\index{mom\_io@{mom\_io}!safe\_string\_copy@{safe\_string\_copy}}
\index{safe\_string\_copy@{safe\_string\_copy}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{safe\_string\_copy()}{safe\_string\_copy()}}
{\footnotesize\ttfamily subroutine mom\+\_\+io\+::safe\+\_\+string\+\_\+copy (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{str1,  }\item[{character(len=$\ast$), intent(out)}]{str2,  }\item[{character(len=$\ast$), intent(in), optional}]{fieldnm,  }\item[{character(len=$\ast$), intent(in), optional}]{caller }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [private]}}



Copies a string. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em str1} & The string being copied \\
\hline
\mbox{\texttt{ out}}  & {\em str2} & The string being copied into \\
\hline
\mbox{\texttt{ in}}  & {\em fieldnm} & The name of the field for error messages \\
\hline
\mbox{\texttt{ in}}  & {\em caller} & The calling routine for error messages \\
\hline
\end{DoxyParams}


Definition at line 742 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{743   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(in)}  :: str1\textcolor{comment}{    !< The string being copied}}
\DoxyCodeLine{744   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(out)} :: str2\textcolor{comment}{    !< The string being copied into}}
\DoxyCodeLine{745   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: fieldnm\textcolor{comment}{ !< The name of the field for error messages}}
\DoxyCodeLine{746   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: caller\textcolor{comment}{  !< The calling routine for error messages}}
\DoxyCodeLine{747 }
\DoxyCodeLine{748   \textcolor{keywordflow}{if} (len(trim(str1)) > len(str2)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{749     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fieldnm) .and. \textcolor{keyword}{present}(caller)) \textcolor{keywordflow}{then}}
\DoxyCodeLine{750       \textcolor{keyword}{call }mom\_error(fatal, trim(caller)//\textcolor{stringliteral}{" attempted to copy the overly long"}//\&}
\DoxyCodeLine{751         \textcolor{stringliteral}{" string "}//trim(str1)//\textcolor{stringliteral}{" into "}//trim(fieldnm))}
\DoxyCodeLine{752     \textcolor{keywordflow}{else}}
\DoxyCodeLine{753       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"safe\_string\_copy: The string "}//trim(str1)//\&}
\DoxyCodeLine{754                      \textcolor{stringliteral}{" is longer than its intended target."})}
\DoxyCodeLine{755 \textcolor{keywordflow}{    endif}}
\DoxyCodeLine{756 \textcolor{keywordflow}{  endif}}
\DoxyCodeLine{757   str2 = trim(str1)}

\end{DoxyCode}
\mbox{\Hypertarget{namespacemom__io_a09be50ad112d6bc134d06d82fcbe1fdc}\label{namespacemom__io_a09be50ad112d6bc134d06d82fcbe1fdc}} 
\index{mom\_io@{mom\_io}!var\_desc@{var\_desc}}
\index{var\_desc@{var\_desc}!mom\_io@{mom\_io}}
\doxysubsubsection{\texorpdfstring{var\_desc()}{var\_desc()}}
{\footnotesize\ttfamily type(\mbox{\hyperlink{structmom__io_1_1vardesc}{vardesc}}) function, public mom\+\_\+io\+::var\+\_\+desc (\begin{DoxyParamCaption}\item[{character(len=$\ast$), intent(in)}]{name,  }\item[{character(len=$\ast$), intent(in), optional}]{units,  }\item[{character(len=$\ast$), intent(in), optional}]{longname,  }\item[{character(len=$\ast$), intent(in), optional}]{hor\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{z\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{t\+\_\+grid,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+field\+\_\+name,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+units,  }\item[{character(len=$\ast$), intent(in), optional}]{cmor\+\_\+longname,  }\item[{real, intent(in), optional}]{conversion,  }\item[{character(len=$\ast$), intent(in), optional}]{caller }\end{DoxyParamCaption})}



Returns a vardesc type whose elements have been filled with the provided fields. The argument name is required, while the others are optional and have default values that are empty strings or are appropriate for a 3-\/d tracer field at the tracer cell centers. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em name} & variable name \\
\hline
\mbox{\texttt{ in}}  & {\em units} & variable units \\
\hline
\mbox{\texttt{ in}}  & {\em longname} & variable long name \\
\hline
\mbox{\texttt{ in}}  & {\em hor\+\_\+grid} & variable horizonal staggering \\
\hline
\mbox{\texttt{ in}}  & {\em z\+\_\+grid} & variable vertical staggering \\
\hline
\mbox{\texttt{ in}}  & {\em t\+\_\+grid} & time description\+: s, p, or 1 \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable \\
\hline
\mbox{\texttt{ in}}  & {\em cmor\+\_\+longname} & C\+M\+OR long name \\
\hline
\mbox{\texttt{ in}}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive \\
\hline
\mbox{\texttt{ in}}  & {\em caller} & calling routine? \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
vardesc type that is created 
\end{DoxyReturn}


Definition at line 598 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}{0}
\DoxyCodeLine{600   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(in)} :: name\textcolor{comment}{               !< variable name}}
\DoxyCodeLine{601   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: units\textcolor{comment}{              !< variable units}}
\DoxyCodeLine{602   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: longname\textcolor{comment}{           !< variable long name}}
\DoxyCodeLine{603   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: hor\_grid\textcolor{comment}{           !< variable horizonal staggering}}
\DoxyCodeLine{604   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: z\_grid\textcolor{comment}{             !< variable vertical staggering}}
\DoxyCodeLine{605   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: t\_grid\textcolor{comment}{             !< time description: s, p, or 1}}
\DoxyCodeLine{606   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_field\_name\textcolor{comment}{    !< CMOR name}}
\DoxyCodeLine{607   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_units\textcolor{comment}{         !< CMOR physical dimensions of variable}}
\DoxyCodeLine{608   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: cmor\_longname\textcolor{comment}{      !< CMOR long name}}
\DoxyCodeLine{609 \textcolor{keywordtype}{  real}            , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: conversion\textcolor{comment}{         !< for unit conversions, such as needed to}}
\DoxyCodeLine{610 \textcolor{comment}{                                                               !! convert from intensive to extensive}}
\DoxyCodeLine{611   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: caller\textcolor{comment}{             !< calling routine?}}
\DoxyCodeLine{612   \textcolor{keywordtype}{type}(vardesc)                          :: vd\textcolor{comment}{                 !< vardesc type that is created}}
\DoxyCodeLine{613 }
\DoxyCodeLine{614   \textcolor{keywordtype}{character(len=120)} :: cllr}
\DoxyCodeLine{615   cllr = \textcolor{stringliteral}{"var\_desc"}}
\DoxyCodeLine{616   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(caller)) cllr = trim(caller)}
\DoxyCodeLine{617 }
\DoxyCodeLine{618   \textcolor{keyword}{call }safe\_string\_copy(name, vd\%name, \textcolor{stringliteral}{"vd\%name"}, cllr)}
\DoxyCodeLine{619 }
\DoxyCodeLine{620   vd\%longname = \textcolor{stringliteral}{""} ; vd\%units = \textcolor{stringliteral}{""}}
\DoxyCodeLine{621   vd\%hor\_grid = \textcolor{stringliteral}{'h'} ; vd\%z\_grid = \textcolor{stringliteral}{'L'} ; vd\%t\_grid = \textcolor{stringliteral}{'s'}}
\DoxyCodeLine{622 }
\DoxyCodeLine{623   vd\%cmor\_field\_name  =  \textcolor{stringliteral}{""}}
\DoxyCodeLine{624   vd\%cmor\_units       =  \textcolor{stringliteral}{""}}
\DoxyCodeLine{625   vd\%cmor\_longname    =  \textcolor{stringliteral}{""}}
\DoxyCodeLine{626   vd\%conversion       =  1.0}
\DoxyCodeLine{627 }
\DoxyCodeLine{628   \textcolor{keyword}{call }modify\_vardesc(vd, units=units, longname=longname, hor\_grid=hor\_grid, \&}
\DoxyCodeLine{629                       z\_grid=z\_grid, t\_grid=t\_grid,                          \&}
\DoxyCodeLine{630                       cmor\_field\_name=cmor\_field\_name,cmor\_units=cmor\_units, \&}
\DoxyCodeLine{631                       cmor\_longname=cmor\_longname, conversion=conversion, caller=cllr)}
\DoxyCodeLine{632 }

\end{DoxyCode}
