1 |
% $Header$ |
% $Header$ |
2 |
% $Name$ |
% $Name$ |
3 |
|
|
4 |
\section{NetCDF I/O Integration} |
\section{NetCDF I/O Integration: MNC} |
5 |
\label{sec:pkg:mnc} |
\label{sec:pkg:mnc} |
6 |
|
|
7 |
The \texttt{mnc} package is a set of convenience routines written to |
The \texttt{mnc} package is a set of convenience routines written to |
23 |
The \texttt{mnc} package is a two-level convenience library (or |
The \texttt{mnc} package is a two-level convenience library (or |
24 |
``wrapper'') for most of the NetCDF Fortran API. Its purpose is to |
``wrapper'') for most of the NetCDF Fortran API. Its purpose is to |
25 |
streamline the user interface to NetCDF by maintaining internal |
streamline the user interface to NetCDF by maintaining internal |
26 |
relations (``look-up tables'') keyed with strings (or ``names'') and |
relations (look-up tables) keyed with strings (or names) and entities |
27 |
entities such as NetCDF files, variables, and attributes. |
such as NetCDF files, variables, and attributes. |
28 |
|
|
29 |
The two levels of the \texttt{mnc} package are: |
The two levels of the \texttt{mnc} package are: |
30 |
\begin{description} |
\begin{description} |
34 |
The upper level contains information about two kinds of |
The upper level contains information about two kinds of |
35 |
associations: |
associations: |
36 |
\begin{description} |
\begin{description} |
37 |
\item[Grid type] is lookup table indexed with a grid type name. |
\item[grid type] is lookup table indexed with a grid type name. |
38 |
Each grid type name is associated with a number of dimensions, the |
Each grid type name is associated with a number of dimensions, the |
39 |
dimension sizes (one of which may be unlimited), and starting and |
dimension sizes (one of which may be unlimited), and starting and |
40 |
ending index arrays. The intent is to store all the necessary |
ending index arrays. The intent is to store all the necessary |
44 |
shown in Figures \ref{fig:communication_primitives} and |
shown in Figures \ref{fig:communication_primitives} and |
45 |
\ref{fig:tiling-strategy}). |
\ref{fig:tiling-strategy}). |
46 |
|
|
47 |
\item[Variable type] is a lookup table indexed by a variable type |
\item[variable type] is a lookup table indexed by a variable type |
48 |
name. For each name, the table contains a reference to a grid |
name. For each name, the table contains a reference to a grid |
49 |
type for the variable and the names and values of various |
type for the variable and the names and values of various |
50 |
attributes. |
attributes. |
68 |
|
|
69 |
\subsection{Using MNC} |
\subsection{Using MNC} |
70 |
|
|
71 |
\subsubsection{``Grid--Types'' and ``Variable--Types''} |
\subsubsection{Grid--Types and Variable--Types} |
72 |
|
|
73 |
As a convenience for users, the MNC package includes numerous routines |
As a convenience for users, the MNC package includes numerous routines |
74 |
to aid in the writing of data to NetCDF format. Probably the biggest |
to aid in the writing of data to NetCDF format. Probably the biggest |
94 |
\begin{center} |
\begin{center} |
95 |
\texttt{H0\_H1\_H2\_\_V\_\_T} |
\texttt{H0\_H1\_H2\_\_V\_\_T} |
96 |
\end{center} |
\end{center} |
97 |
where the terms \textit{H0,H1,H2,V,T} can be almost any combination of |
where the terms \textit{H0}, \textit{H1}, \textit{H2}, \textit{V}, |
98 |
the following: |
\textit{T} can be almost any combination of the following: |
99 |
\begin{center} |
\begin{center} |
100 |
\begin{tabular}[h]{|ccc|c|c|}\hline |
\begin{tabular}[h]{|ccc|c|c|}\hline |
101 |
\multicolumn{3}{|c|}{Horizontal} & Vertical & \\ |
\multicolumn{3}{|c|}{Horizontal} & Vertical & Time \\ |
102 |
Location & Direction & Halo & Location & Time \\\hline |
\textit{H0}: location & \textit{H1}: dimensions & \textit{H2}: halo |
103 |
H0 & H1 & H2 & V & T \\\hline |
& \textit{V}: location & \textit{T}: level \\\hline |
104 |
\texttt{-} & xy & Hn & \texttt{-} & \texttt{-} \\ |
\texttt{-} & xy & Hn & \texttt{-} & \texttt{-} \\ |
105 |
U & x & Hy & i & t \\ |
U & x & Hy & i & t \\ |
106 |
V & y & & c & \\ |
V & y & & c & \\ |
120 |
Writing variables to NetCDF files can be accomplished in as few as two |
Writing variables to NetCDF files can be accomplished in as few as two |
121 |
function calls. The first function call defines a variable type, |
function calls. The first function call defines a variable type, |
122 |
associates it with a name (character string), and provides additional |
associates it with a name (character string), and provides additional |
123 |
information about the indicies for \texttt{bi,bj} dimensions. The |
information about the indicies for the tile (\texttt{bi},\texttt{bj}) |
124 |
second function call will write variable at, if necessary, the |
dimensions. The second function call will write the data at, if |
125 |
current time level within the model. |
necessary, the current time level within the model. |
126 |
|
|
127 |
Examples of the initialization calls can be found in the file |
Examples of the initialization calls can be found in the file |
128 |
\begin{center} |
\filelink{model/src/initialise\_fixed.F}{model-src-initialise_fixed.F} |
129 |
\filelink{model/src/initialise\_fixed.F}{model-src-initialise_fixed.F} |
where these four function calls: |
130 |
\end{center} |
{\footnotesize |
|
where these four function calls: {\footnotesize |
|
131 |
\begin{verbatim} |
\begin{verbatim} |
132 |
C Create MNC definitions for DYNVARS.h variables |
C Create MNC definitions for DYNVARS.h variables |
133 |
CALL MNC_CW_ADD_VNAME(myThid, 'iter', '-_-_--__-__t', 0,0) |
CALL MNC_CW_ADD_VNAME(myThid, 'iter', '-_-_--__-__t', 0,0) |
135 |
& 'long_name','iteration_count') |
& 'long_name','iteration_count') |
136 |
CALL MNC_CW_ADD_VNAME(myThid, 'U', 'U_xy_Hn__C__t', 4,5) |
CALL MNC_CW_ADD_VNAME(myThid, 'U', 'U_xy_Hn__C__t', 4,5) |
137 |
CALL MNC_CW_ADD_VATTR_TEXT(myThid,'U',1,'units','m/s') |
CALL MNC_CW_ADD_VATTR_TEXT(myThid,'U',1,'units','m/s') |
138 |
\end{verbatim} } |
\end{verbatim} |
139 |
{\noindent initialize two \texttt{VNAME}s and add one attribute to each.} |
} |
140 |
|
{\noindent initialize two \texttt{VNAME}s and add one NetCDF |
141 |
|
attribute to each.} |
142 |
|
|
143 |
The two variables are subsequently written at specific time steps |
The two variables defined above are subsequently written at specific |
144 |
within |
time steps within |
145 |
\begin{center} |
\filelink{model/src/write\_state.F}{model-src-write_state.F} |
146 |
\filelink{model/src/write\_state.F}{model-src-write_state.F} |
using the function calls: |
147 |
\end{center} |
{\footnotesize |
|
using the function calls: {\footnotesize |
|
148 |
\begin{verbatim} |
\begin{verbatim} |
149 |
C Write the DYNVARS.h variables using the MNC package |
C Write the DYNVARS.h variables using the MNC package |
150 |
mnc_iter = myIter |
mnc_iter = myIter |
151 |
CALL MNC_CW_RL_W_R(myThid,'state',0,0,'iter',-1,mnc_iter) |
CALL MNC_CW_RL_W_R(myThid,'state',0,0,'iter',-1,mnc_iter) |
152 |
CALL MNC_CW_RL_W_D(myThid,'state',0,0,'U', 0, uVel) |
CALL MNC_CW_RL_W_D(myThid,'state',0,0,'U', 0, uVel) |
153 |
\end{verbatim} } |
\end{verbatim} |
154 |
|
} |
155 |
|
|
156 |
|
|
157 |
\subsection{Key subroutines, parameters and files} |
\subsection{Key subroutines, parameters and files} |