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


\subsection{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}\subsection*{Data Types}
\begin{DoxyCompactItemize}
\item 
interface \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 \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 \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 \hyperlink{structmom__io_1_1vardesc}{vardesc}
\begin{DoxyCompactList}\small\item\em Type for describing a variable, typically a tracer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions/\+Subroutines}
\begin{DoxyCompactItemize}
\item 
subroutine, public \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 \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 \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 \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(\hyperlink{structmom__io_1_1vardesc}{vardesc}) function, public \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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 \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}


\subsection{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}}
\subsubsection{\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{\tt 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 683 of file M\+O\+M\+\_\+io.\+F90.


\begin{DoxyCode}
683   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)} :: longname\textcolor{comment}{  !< The CMOR longname being converted}
684   \textcolor{keywordtype}{character(len=len(longname))} :: std\_name\textcolor{comment}{  !< The CMOR standard name generated from longname}
685 
686   \textcolor{keywordtype}{integer} :: k
687 
688   std\_name = lowercase(longname)
689 
690   \textcolor{keywordflow}{do} k=1, len\_trim(std\_name)
691     \textcolor{keywordflow}{if} (std\_name(k:k) == \textcolor{stringliteral}{' '}) std\_name(k:k) = \textcolor{stringliteral}{'\_'}
692 \textcolor{keywordflow}{  enddo}
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}}
\subsubsection{\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(\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{\tt out}  & {\em unit} & unit id of an open file or -\/1 on a nonwriting PE with single file output\\
\hline
\mbox{\tt in}  & {\em filename} & full path to the file to create\\
\hline
\mbox{\tt in}  & {\em vars} & structures describing fields written to filename\\
\hline
\mbox{\tt in}  & {\em novars} & number of fields written to filename\\
\hline
\mbox{\tt in,out}  & {\em fields} & array of fieldtypes for each variable\\
\hline
\mbox{\tt in}  & {\em threading} & S\+I\+N\+G\+L\+E\+\_\+\+F\+I\+LE or M\+U\+L\+T\+I\+P\+LE\\
\hline
\mbox{\tt in}  & {\em timeunit} & length of the units for time \mbox{[}s\mbox{]}. The default value is 86400.\+0, for 1 day.\\
\hline
\mbox{\tt in}  & {\em g} & ocean horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes.\\
\hline
\mbox{\tt in}  & {\em dg} & dynamic horizontal grid structure; G or dG is required if the new file uses any horizontal grid axes.\\
\hline
\mbox{\tt in}  & {\em gv} & ocean vertical grid structure, which is required if the new file uses any vertical grid axes.\\
\hline
\mbox{\tt in}  & {\em checksums} & checksums of vars \\
\hline
\end{DoxyParams}


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


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


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


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


\begin{DoxyCode}
835   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{intent(in)}         :: filename\textcolor{comment}{  !< The name of the file being inquired about}
836   \textcolor{keywordtype}{type}(domain2d), \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: domain\textcolor{comment}{    !< The mpp domain2d that describes the decomposition}
837   \textcolor{keywordtype}{logical},        \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: no\_domain\textcolor{comment}{ !< This file does not use domain decomposition}
838 \textcolor{comment}{! This function uses the fms\_io function file\_exist to determine whether}
839 \textcolor{comment}{! a named file (or its decomposed variant) exists.}
840 
841   \textcolor{keywordtype}{logical} :: fms\_file\_exists
842 
843   fms\_file\_exists = file\_exist(filename, domain, no\_domain)
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}}
\subsubsection{\texorpdfstring{modify\+\_\+vardesc()}{modify\_vardesc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::modify\+\_\+vardesc (\begin{DoxyParamCaption}\item[{type(\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{\tt in,out}  & {\em vd} & vardesc type that is modified\\
\hline
\mbox{\tt in}  & {\em name} & name of variable\\
\hline
\mbox{\tt in}  & {\em units} & units of variable\\
\hline
\mbox{\tt in}  & {\em longname} & long name of variable\\
\hline
\mbox{\tt in}  & {\em hor\+\_\+grid} & horizonal staggering of variable\\
\hline
\mbox{\tt in}  & {\em z\+\_\+grid} & vertical staggering of variable\\
\hline
\mbox{\tt in}  & {\em t\+\_\+grid} & time description\+: s, p, or 1\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+longname} & C\+M\+OR long name\\
\hline
\mbox{\tt in}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive\\
\hline
\mbox{\tt in}  & {\em caller} & calling routine? \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
640   \textcolor{keywordtype}{type}(vardesc),              \textcolor{keywordtype}{intent(inout)} :: vd\textcolor{comment}{              !< vardesc type that is modified}
641   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: name\textcolor{comment}{            !< name of variable}
642   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: units\textcolor{comment}{           !< units of variable}
643   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: longname\textcolor{comment}{        !< long name of variable}
644   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: hor\_grid\textcolor{comment}{        !< horizonal staggering of variable}
645   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: z\_grid\textcolor{comment}{          !< vertical staggering of variable}
646   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: t\_grid\textcolor{comment}{          !< time description: s, p, or 1}
647   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_field\_name\textcolor{comment}{ !< CMOR name}
648   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_units\textcolor{comment}{      !< CMOR physical dimensions of variable}
649   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: cmor\_longname\textcolor{comment}{   !< CMOR long name}
650   \textcolor{keywordtype}{real}            , \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: conversion\textcolor{comment}{      !< for unit conversions, such as needed}
651 \textcolor{comment}{                                                               !! to convert from intensive to extensive}
652   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: caller\textcolor{comment}{          !< calling routine?}
653 
654   \textcolor{keywordtype}{character(len=120)} :: cllr
655   cllr = \textcolor{stringliteral}{"mod\_vardesc"}
656   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(caller)) cllr = trim(caller)
657 
658   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(name))      \textcolor{keyword}{call }safe\_string\_copy(name, vd%name, \textcolor{stringliteral}{"vd%name"}, cllr)
659 
660   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(longname))  \textcolor{keyword}{call }safe\_string\_copy(longname, vd%longname, &
661                                \textcolor{stringliteral}{"vd%longname of "}//trim(vd%name), cllr)
662   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(units))     \textcolor{keyword}{call }safe\_string\_copy(units, vd%units,       &
663                                \textcolor{stringliteral}{"vd%units of "}//trim(vd%name), cllr)
664   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(hor\_grid))  \textcolor{keyword}{call }safe\_string\_copy(hor\_grid, vd%hor\_grid, &
665                                \textcolor{stringliteral}{"vd%hor\_grid of "}//trim(vd%name), cllr)
666   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(z\_grid))    \textcolor{keyword}{call }safe\_string\_copy(z\_grid, vd%z\_grid,     &
667                                \textcolor{stringliteral}{"vd%z\_grid of "}//trim(vd%name), cllr)
668   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(t\_grid))    \textcolor{keyword}{call }safe\_string\_copy(t\_grid, vd%t\_grid,     &
669                                \textcolor{stringliteral}{"vd%t\_grid of "}//trim(vd%name), cllr)
670 
671   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_field\_name)) \textcolor{keyword}{call }safe\_string\_copy(cmor\_field\_name, vd%cmor\_field\_name, &
672                                      \textcolor{stringliteral}{"vd%cmor\_field\_name of "}//trim(vd%name), cllr)
673   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_units))      \textcolor{keyword}{call }safe\_string\_copy(cmor\_units, vd%cmor\_units, &
674                                      \textcolor{stringliteral}{"vd%cmor\_units of "}//trim(vd%name), cllr)
675   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(cmor\_longname))   \textcolor{keyword}{call }safe\_string\_copy(cmor\_longname, vd%cmor\_longname, &
676                                      \textcolor{stringliteral}{"vd%cmor\_longname of "}//trim(vd%name), cllr)
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}}
\subsubsection{\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{\tt in}  & {\em filename} & The name of the file being inquired about\\
\hline
\mbox{\tt in}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
821   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{   !< The name of the file being inquired about}
822   \textcolor{keywordtype}{type}(mom\_domain\_type),  \textcolor{keywordtype}{intent(in)} :: mom\_domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}
823 
824 \textcolor{comment}{! This function uses the fms\_io function file\_exist to determine whether}
825 \textcolor{comment}{! a named file (or its decomposed variant) exists.}
826 
827   \textcolor{keywordtype}{logical} :: mom\_file\_exists
828 
829   mom\_file\_exists = file\_exist(filename, mom\_domain%mpp\_domain)
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}}
\subsubsection{\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{\tt in}  & {\em param\+\_\+file} & structure indicating the open file to parse for model parameter values. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
1043   \textcolor{keywordtype}{type}(param\_file\_type), \textcolor{keywordtype}{intent(in)} :: param\_file\textcolor{comment}{  !< structure indicating the open file to}
1044 \textcolor{comment}{                                                   !! parse for model parameter values.}
1045 
1046 \textcolor{comment}{! This include declares and sets the variable "version".}
1047 \textcolor{preprocessor}{#include "version\_variable.h"}
1048 \textcolor{preprocessor}{}  \textcolor{keywordtype}{character(len=40)}  :: mdl = \textcolor{stringliteral}{"MOM\_io"} \textcolor{comment}{! This module's name.}
1049 
1050   \textcolor{keyword}{call }log\_version(param\_file, mdl, version)
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}}
\subsubsection{\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{\tt in}  & {\em filename} & The name of the file to read\\
\hline
\mbox{\tt in}  & {\em fieldname} & The variable name of the data in the file\\
\hline
\mbox{\tt in,out}  & {\em data} & The 1-\/dimensional array into which the data\\
\hline
\mbox{\tt in}  & {\em timelevel} & The time level in the file to read\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


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


\begin{DoxyCode}
850   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}
851   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}
852   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)},     \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{      !< The 1-dimensional array into which the data}
853   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}
854   \textcolor{keywordtype}{real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}
855 \textcolor{comment}{                                                     !! by before they are returned.}
856 
857   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, timelevel=timelevel, no\_domain=.true.)
858 
859   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}
860     \textcolor{keyword}{data}(:) = scale*\textcolor{keyword}{data}(:)
861 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
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}}
\subsubsection{\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{\tt in}  & {\em filename} & The name of the file to read\\
\hline
\mbox{\tt in}  & {\em fieldname} & The variable name of the data in the file\\
\hline
\mbox{\tt in,out}  & {\em data} & The 2-\/dimensional array into which the data should be read\\
\hline
\mbox{\tt in}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition\\
\hline
\mbox{\tt in}  & {\em timelevel} & The time level in the file to read\\
\hline
\mbox{\tt in}  & {\em position} & A flag indicating where this data is located\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor that the field is multiplied by before they are returned. \\
\hline
\end{DoxyParams}


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


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


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


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


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


\begin{DoxyCode}
926   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: filename\textcolor{comment}{  !< The name of the file to read}
927   \textcolor{keywordtype}{character(len=*)},       \textcolor{keywordtype}{intent(in)}    :: fieldname\textcolor{comment}{ !< The variable name of the data in the file}
928   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:,:,:,:)}, \textcolor{keywordtype}{intent(inout)} :: data\textcolor{comment}{    !< The 4-dimensional array into which the data}
929 \textcolor{comment}{                                                     !! should be read}
930   \textcolor{keywordtype}{type}(mom\_domain\_type),  \textcolor{keywordtype}{intent(in)}    :: mom\_domain\textcolor{comment}{ !< The MOM\_Domain that describes the decomposition}
931   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: timelevel\textcolor{comment}{ !< The time level in the file to read}
932   \textcolor{keywordtype}{integer},      \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: position\textcolor{comment}{  !< A flag indicating where this data is located}
933   \textcolor{keywordtype}{real},         \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}    :: scale\textcolor{comment}{     !< A scaling factor that the field is multiplied}
934 \textcolor{comment}{                                                     !! by before they are returned.}
935 
936   \textcolor{keywordtype}{integer} :: is, ie, js, je
937 
938   \textcolor{keyword}{call }read\_data(filename, fieldname, \textcolor{keyword}{data}, mom\_domain%mpp\_domain, &
939                  timelevel=timelevel, position=position)
940 
941   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(scale)) \textcolor{keywordflow}{then} ; \textcolor{keywordflow}{if} (scale /= 1.0) \textcolor{keywordflow}{then}
942     \textcolor{keyword}{call }get\_simple\_array\_i\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},1), is, ie)
943     \textcolor{keyword}{call }get\_simple\_array\_j\_ind(mom\_domain, \textcolor{keyword}{size}(\textcolor{keyword}{data},2), js, je)
944     \textcolor{keyword}{data}(is:ie,js:je,:,:) = scale*\textcolor{keyword}{data}(is:ie,js:je,:,:)
945 \textcolor{keywordflow}{  endif} ;\textcolor{keywordflow}{ endif}
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}}
\subsubsection{\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{\tt in}  & {\em filename} & The name of the file to read\\
\hline
\mbox{\tt in}  & {\em u\+\_\+fieldname} & The variable name of the u data in the file\\
\hline
\mbox{\tt in}  & {\em v\+\_\+fieldname} & The variable name of the v data in the file\\
\hline
\mbox{\tt in,out}  & {\em u\+\_\+data} & The 2 dimensional array into which the u-\/component of the data should be read\\
\hline
\mbox{\tt in,out}  & {\em v\+\_\+data} & The 2 dimensional array into which the v-\/component of the data should be read\\
\hline
\mbox{\tt in}  & {\em mom\+\_\+domain} & The M\+O\+M\+\_\+\+Domain that describes the decomposition\\
\hline
\mbox{\tt in}  & {\em timelevel} & The time level in the file to read\\
\hline
\mbox{\tt in}  & {\em stagger} & A flag indicating where this vector is discretized\\
\hline
\mbox{\tt in}  & {\em scalar\+\_\+pair} & If true, a pair of scalars are to be read.\+cretized\\
\hline
\mbox{\tt in}  & {\em scale} & A scaling factor that the fields are multiplied by before they are returned. \\
\hline
\end{DoxyParams}


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


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


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


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


\begin{DoxyCode}
478   \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)} :: filename\textcolor{comment}{   !< name of the file to read}
479   \textcolor{keywordtype}{character(len=*)},  \textcolor{keywordtype}{intent(in)} :: varname\textcolor{comment}{    !< variable whose number of time levels}
480 \textcolor{comment}{                                              !! are to be returned}
481   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)} :: min\_dims\textcolor{comment}{   !< The minimum number of dimensions a variable must have}
482 \textcolor{comment}{                                              !! if it has a time dimension.  If the variable has 1 less}
483 \textcolor{comment}{                                              !! dimension than this, then 0 is returned.}
484   \textcolor{keywordtype}{integer} :: n\_time\textcolor{comment}{                           !< number of time levels varname has in filename}
485 
486   \textcolor{keywordtype}{logical} :: found
487   \textcolor{keywordtype}{character(len=200)} :: msg
488   \textcolor{keywordtype}{character(len=nf90\_max\_name)} :: name
489   \textcolor{keywordtype}{integer} :: ncid, nvars, status, varid, ndims, n
490   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{allocatable} :: varids(:)
491   \textcolor{keywordtype}{integer}, \textcolor{keywordtype}{dimension(nf90\_max\_var\_dims)} :: dimids
492 
493   n\_time = -1
494   found = .false.
495 
496   status = nf90\_open(filename, nf90\_nowrite, ncid)
497   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
498     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
499         \textcolor{stringliteral}{" Difficulties opening "}//trim(filename)//\textcolor{stringliteral}{" - "}//&
500         trim(nf90\_strerror(status)))
501     \textcolor{keywordflow}{return}
502 \textcolor{keywordflow}{  endif}
503 
504   status = nf90\_inquire(ncid, nvariables=nvars)
505   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
506     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
507         \textcolor{stringliteral}{" Difficulties getting the number of variables in file "}//&
508         trim(filename)//\textcolor{stringliteral}{" - "}//trim(nf90\_strerror(status)))
509     \textcolor{keywordflow}{return}
510 \textcolor{keywordflow}{  endif}
511 
512   \textcolor{keywordflow}{if} (nvars < 1) \textcolor{keywordflow}{then}
513     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
514         \textcolor{stringliteral}{" There appear not to be any variables in "}//trim(filename))
515     \textcolor{keywordflow}{return}
516 \textcolor{keywordflow}{  endif}
517 
518 
519   \textcolor{keyword}{allocate}(varids(nvars))
520 
521   status = nf90\_inq\_varids(ncid, nvars, varids)
522   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
523     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
524         \textcolor{stringliteral}{" Difficulties getting the variable IDs in file "}//&
525         trim(filename)//\textcolor{stringliteral}{" - "}//trim(nf90\_strerror(status)))
526     \textcolor{keyword}{deallocate}(varids) ; \textcolor{keywordflow}{return}
527 \textcolor{keywordflow}{  endif}
528 
529   \textcolor{keywordflow}{do} n = 1,nvars
530     status = nf90\_inquire\_variable(ncid, varids(n), name=name)
531     \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
532       \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
533           \textcolor{stringliteral}{" Difficulties getting a variable name in file "}//&
534           trim(filename)//\textcolor{stringliteral}{" - "}//trim(nf90\_strerror(status)))
535 \textcolor{keywordflow}{    endif}
536 
537     \textcolor{keywordflow}{if} (trim(lowercase(name)) == trim(lowercase(varname))) \textcolor{keywordflow}{then}
538       \textcolor{keywordflow}{if} (found) \textcolor{keywordflow}{then}
539         \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
540           \textcolor{stringliteral}{" Two variables match the case-insensitive name "}//trim(varname)//&
541           \textcolor{stringliteral}{" in file "}//trim(filename)//\textcolor{stringliteral}{" - "}//trim(nf90\_strerror(status)))
542       \textcolor{keywordflow}{else}
543         varid = varids(n) ; found = .true.
544 \textcolor{keywordflow}{      endif}
545 \textcolor{keywordflow}{    endif}
546 \textcolor{keywordflow}{  enddo}
547 
548   \textcolor{keyword}{deallocate}(varids)
549 
550   \textcolor{keywordflow}{if} (.not.found) \textcolor{keywordflow}{then}
551     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
552         \textcolor{stringliteral}{" variable "}//trim(varname)//\textcolor{stringliteral}{" was not found in file "}//&
553         trim(filename))
554     \textcolor{keywordflow}{return}
555 \textcolor{keywordflow}{  endif}
556 
557   status = nf90\_inquire\_variable(ncid, varid, ndims = ndims)
558   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
559     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
560       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting number of dimensions of "}//&
561       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))
562     \textcolor{keywordflow}{return}
563 \textcolor{keywordflow}{  endif}
564 
565   \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(min\_dims)) \textcolor{keywordflow}{then}
566     \textcolor{keywordflow}{if} (ndims < min\_dims-1) \textcolor{keywordflow}{then}
567       \textcolor{keyword}{write}(msg, \textcolor{stringliteral}{'(I3)'}) min\_dims
568       \textcolor{keyword}{call }mom\_error(warning, \textcolor{stringliteral}{"num\_timelevels: variable "}//trim(varname)//&
569         \textcolor{stringliteral}{" in file "}//trim(filename)//\textcolor{stringliteral}{" has fewer than min\_dims = "}//trim(msg)//&
570         \textcolor{stringliteral}{" dimensions."})
571     \textcolor{keywordflow}{elseif} (ndims == min\_dims - 1) \textcolor{keywordflow}{then}
572       n\_time = 0 ; \textcolor{keywordflow}{return}
573 \textcolor{keywordflow}{    endif}
574 \textcolor{keywordflow}{  endif}
575 
576   status = nf90\_inquire\_variable(ncid, varid, dimids = dimids(1:ndims))
577   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keywordflow}{then}
578     \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
579       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting last dimension ID for "}//&
580       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))
581     \textcolor{keywordflow}{return}
582 \textcolor{keywordflow}{  endif}
583 
584   status = nf90\_inquire\_dimension(ncid, dimids(ndims), len=n\_time)
585   \textcolor{keywordflow}{if} (status /= nf90\_noerr) \textcolor{keyword}{call }mom\_error(warning,\textcolor{stringliteral}{"num\_timelevels: "}//&
586       trim(nf90\_strerror(status))//\textcolor{stringliteral}{" Getting number of time levels of "}//&
587       trim(varname)//\textcolor{stringliteral}{" in "}//trim(filename))
588 
589   \textcolor{keywordflow}{return}
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}}
\subsubsection{\texorpdfstring{query\+\_\+vardesc()}{query\_vardesc()}}
{\footnotesize\ttfamily subroutine, public mom\+\_\+io\+::query\+\_\+vardesc (\begin{DoxyParamCaption}\item[{type(\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{\tt in}  & {\em vd} & vardesc type that is queried\\
\hline
\mbox{\tt out}  & {\em name} & name of variable\\
\hline
\mbox{\tt out}  & {\em units} & units of variable\\
\hline
\mbox{\tt out}  & {\em longname} & long name of variable\\
\hline
\mbox{\tt out}  & {\em hor\+\_\+grid} & horiz staggering of variable\\
\hline
\mbox{\tt out}  & {\em z\+\_\+grid} & vert staggering of variable\\
\hline
\mbox{\tt out}  & {\em t\+\_\+grid} & time description\+: s, p, or 1\\
\hline
\mbox{\tt out}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name\\
\hline
\mbox{\tt out}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable\\
\hline
\mbox{\tt out}  & {\em cmor\+\_\+longname} & C\+M\+OR long name\\
\hline
\mbox{\tt out}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive\\
\hline
\mbox{\tt in}  & {\em caller} & calling routine? \\
\hline
\end{DoxyParams}


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


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


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


\begin{DoxyCode}
438   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)}  :: filename\textcolor{comment}{  !< Name of the file to read}
439   \textcolor{keywordtype}{character(len=*)},   \textcolor{keywordtype}{intent(in)}  :: axis\_name\textcolor{comment}{ !< Name of the axis to read}
440   \textcolor{keywordtype}{real}, \textcolor{keywordtype}{dimension(:)}, \textcolor{keywordtype}{intent(out)} :: var\textcolor{comment}{       !< The axis location data}
441 
442   \textcolor{keywordtype}{integer} :: i,len,unit, ndim, nvar, natt, ntime
443   \textcolor{keywordtype}{logical} :: axis\_found
444   \textcolor{keywordtype}{type}(axistype), \textcolor{keywordtype}{allocatable} :: axes(:)
445   \textcolor{keywordtype}{type}(axistype) :: time\_axis
446   \textcolor{keywordtype}{character(len=32)} :: name, units
447 
448   \textcolor{keyword}{call }open\_file(unit, trim(filename), action=mpp\_rdonly, form=mpp\_netcdf, &
449                  threading=mpp\_multi, fileset=single\_file)
450 
451 \textcolor{comment}{!Find the number of variables (nvar) in this file}
452   \textcolor{keyword}{call }mpp\_get\_info(unit, ndim, nvar, natt, ntime)
453 \textcolor{comment}{! -------------------------------------------------------------------}
454 \textcolor{comment}{! Allocate space for the number of axes in the data file.}
455 \textcolor{comment}{! -------------------------------------------------------------------}
456   \textcolor{keyword}{allocate}(axes(ndim))
457   \textcolor{keyword}{call }mpp\_get\_axes(unit, axes, time\_axis)
458 
459   axis\_found = .false.
460   \textcolor{keywordflow}{do} i = 1, ndim
461     \textcolor{keyword}{call }mpp\_get\_atts(axes(i), name=name,len=len,units=units)
462     \textcolor{keywordflow}{if} (name == axis\_name) \textcolor{keywordflow}{then}
463       axis\_found = .true.
464       \textcolor{keyword}{call }get\_axis\_data(axes(i),var)
465       \textcolor{keywordflow}{exit}
466 \textcolor{keywordflow}{    endif}
467 \textcolor{keywordflow}{  enddo}
468 
469   \textcolor{keywordflow}{if} (.not.axis\_found) \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"MOM\_io read\_axis\_data: "}//&
470     \textcolor{stringliteral}{"Unable to find axis "}//trim(axis\_name)//\textcolor{stringliteral}{" in file "}//trim(filename))
471 
472   \textcolor{keyword}{deallocate}(axes)
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}}
\subsubsection{\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(\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{\tt out}  & {\em unit} & unit id of an open file or -\/1 on a nonwriting PE with single file output\\
\hline
\mbox{\tt in}  & {\em filename} & full path to the file to create\\
\hline
\mbox{\tt in}  & {\em vars} & structures describing fields written to filename\\
\hline
\mbox{\tt in}  & {\em novars} & number of fields written to filename\\
\hline
\mbox{\tt in,out}  & {\em fields} & array of fieldtypes for each variable\\
\hline
\mbox{\tt in}  & {\em threading} & S\+I\+N\+G\+L\+E\+\_\+\+F\+I\+LE or M\+U\+L\+T\+I\+P\+LE\\
\hline
\mbox{\tt in}  & {\em timeunit} & length of the units for time \mbox{[}s\mbox{]}. The default value is 86400.\+0, for 1 day.\\
\hline
\mbox{\tt in}  & {\em g} & ocean horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes.\\
\hline
\mbox{\tt in}  & {\em dg} & dynamic horizontal grid structure; G or dG is required if a new file uses any horizontal grid axes.\\
\hline
\mbox{\tt 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 353 of file M\+O\+M\+\_\+io.\+F90.


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


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


\begin{DoxyCode}
743   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(in)}  :: str1\textcolor{comment}{    !< The string being copied}
744   \textcolor{keywordtype}{character(len=*)},           \textcolor{keywordtype}{intent(out)} :: str2\textcolor{comment}{    !< The string being copied into}
745   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: fieldnm\textcolor{comment}{ !< The name of the field for error messages}
746   \textcolor{keywordtype}{character(len=*)}, \textcolor{keywordtype}{optional}, \textcolor{keywordtype}{intent(in)}  :: caller\textcolor{comment}{  !< The calling routine for error messages}
747 
748   \textcolor{keywordflow}{if} (len(trim(str1)) > len(str2)) \textcolor{keywordflow}{then}
749     \textcolor{keywordflow}{if} (\textcolor{keyword}{present}(fieldnm) .and. \textcolor{keyword}{present}(caller)) \textcolor{keywordflow}{then}
750       \textcolor{keyword}{call }mom\_error(fatal, trim(caller)//\textcolor{stringliteral}{" attempted to copy the overly long"}//&
751         \textcolor{stringliteral}{" string "}//trim(str1)//\textcolor{stringliteral}{" into "}//trim(fieldnm))
752     \textcolor{keywordflow}{else}
753       \textcolor{keyword}{call }mom\_error(fatal, \textcolor{stringliteral}{"safe\_string\_copy: The string "}//trim(str1)//&
754                      \textcolor{stringliteral}{" is longer than its intended target."})
755 \textcolor{keywordflow}{    endif}
756 \textcolor{keywordflow}{  endif}
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}}
\subsubsection{\texorpdfstring{var\+\_\+desc()}{var\_desc()}}
{\footnotesize\ttfamily type(\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{\tt in}  & {\em name} & variable name\\
\hline
\mbox{\tt in}  & {\em units} & variable units\\
\hline
\mbox{\tt in}  & {\em longname} & variable long name\\
\hline
\mbox{\tt in}  & {\em hor\+\_\+grid} & variable horizonal staggering\\
\hline
\mbox{\tt in}  & {\em z\+\_\+grid} & variable vertical staggering\\
\hline
\mbox{\tt in}  & {\em t\+\_\+grid} & time description\+: s, p, or 1\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+field\+\_\+name} & C\+M\+OR name\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+units} & C\+M\+OR physical dimensions of variable\\
\hline
\mbox{\tt in}  & {\em cmor\+\_\+longname} & C\+M\+OR long name\\
\hline
\mbox{\tt in}  & {\em conversion} & for unit conversions, such as needed to convert from intensive to extensive\\
\hline
\mbox{\tt in}  & {\em caller} & calling routine?\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
vardesc type that is created 
\end{DoxyReturn}


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


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