66 |
\end{description} |
\end{description} |
67 |
|
|
68 |
|
|
69 |
|
\subsection{Using MNC} |
70 |
|
|
71 |
|
\subsubsection{``Grid--Types'' and ``Variable--Types''} |
72 |
|
|
73 |
|
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 |
75 |
|
convenience is the use of pre-defined ``grid types'' and ``variable |
76 |
|
types''. These ``types'' are simply look-up tables that store |
77 |
|
dimensions, indicies, attributes, and other information that can all |
78 |
|
be retrieved using a single character string. |
79 |
|
|
80 |
|
The ``grid types'' are a way of mapping variables within MITgcm to |
81 |
|
NetCDF arrays. Within MITgcm, most spatial variables are defined |
82 |
|
using two-- or three--dimensional arrays with ``overlap'' regions (see |
83 |
|
Figures \ref{fig:communication_primitives}, a possible vertical index, |
84 |
|
and \ref{fig:tiling-strategy}) and tile indicies such as the following |
85 |
|
``U'' velocity: |
86 |
|
\begin{verbatim} |
87 |
|
_RL uVel (1-OLx:sNx+OLx,1-OLy:sNy+OLy,Nr,nSx,nSy) |
88 |
|
\end{verbatim} |
89 |
|
as defined in \filelink{model/inc/DYNVARS.h}{model-inc-DYNVARS.h} |
90 |
|
|
91 |
|
The grid type is a character string that encodes the presence and |
92 |
|
types associated with the four possible dimensions. The character |
93 |
|
string follows the format |
94 |
|
\begin{center} |
95 |
|
\texttt{H0\_H1\_H2\_\_V\_\_T} |
96 |
|
\end{center} |
97 |
|
where the terms \textit{H0,H1,H2,V,T} can be almost any combination of |
98 |
|
the following: |
99 |
|
\begin{center} |
100 |
|
\begin{tabular}[h]{|ccc|c|c|}\hline |
101 |
|
\multicolumn{3}{|c|}{Horizontal} & Vertical & \\ |
102 |
|
Location & Direction & Halo & Location & Time \\\hline |
103 |
|
H0 & H1 & H2 & V & T \\\hline |
104 |
|
\texttt{-} & xy & Hn & \texttt{-} & \texttt{-} \\ |
105 |
|
U & x & Hy & i & t \\ |
106 |
|
V & y & & c & \\ |
107 |
|
Cen & & & & \\ |
108 |
|
Cor & & & & \\\hline |
109 |
|
\end{tabular} |
110 |
|
\end{center} |
111 |
|
A example list of all pre-defined combinations is contained in the |
112 |
|
file |
113 |
|
\begin{center} |
114 |
|
\texttt{pkg/mnc/pre-defined\_grids.txt}. |
115 |
|
\end{center} |
116 |
|
|
117 |
|
|
118 |
|
\subsubsection{An Example} |
119 |
|
|
120 |
|
Writing variables to NetCDF files can be accomplished in as few as two |
121 |
|
function calls. The first function call defines a variable type, |
122 |
|
associates it with a name (character string), and provides additional |
123 |
|
information about the indicies for \texttt{bi,bj} dimensions. The |
124 |
|
second function call will write variable at, if necessary, the |
125 |
|
current time level within the model. |
126 |
|
|
127 |
|
Examples of the initialization calls can be found in the file |
128 |
|
\begin{center} |
129 |
|
\filelink{model/src/initialise\_fixed.F}{model-src-initialise_fixed.F} |
130 |
|
\end{center} |
131 |
|
where these four function calls: {\footnotesize |
132 |
|
\begin{verbatim} |
133 |
|
C Create MNC definitions for DYNVARS.h variables |
134 |
|
CALL MNC_CW_ADD_VNAME(myThid, 'iter', '-_-_--__-__t', 0,0) |
135 |
|
CALL MNC_CW_ADD_VATTR_TEXT(myThid,'iter',1, |
136 |
|
& 'long_name','iteration_count') |
137 |
|
CALL MNC_CW_ADD_VNAME(myThid, 'U', 'U_xy_Hn__C__t', 4,5) |
138 |
|
CALL MNC_CW_ADD_VATTR_TEXT(myThid,'U',1,'units','m/s') |
139 |
|
\end{verbatim} } |
140 |
|
{\noindent initialize two \texttt{VNAME}s and add one attribute to each.} |
141 |
|
|
142 |
|
The two variables are subsequently written at specific time steps |
143 |
|
within |
144 |
|
\begin{center} |
145 |
|
\filelink{model/src/write\_state.F}{model-src-write_state.F} |
146 |
|
\end{center} |
147 |
|
using the function calls: {\footnotesize |
148 |
|
\begin{verbatim} |
149 |
|
C Write the DYNVARS.h variables using the MNC package |
150 |
|
mnc_iter = myIter |
151 |
|
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) |
153 |
|
\end{verbatim} } |
154 |
|
|
155 |
|
|
156 |
\subsection{Key subroutines, parameters and files} |
\subsection{Key subroutines, parameters and files} |
157 |
|
|
158 |
All of the variables used to implement the lookup tables are described |
All of the variables used to implement the lookup tables are described |
159 |
in \filelink{pkg/mnc/mnc\_common.h}{pkg/mnc/mnc_common}. |
in \filelink{model/src/write\_state.F}{model-src-write_state.F} |
160 |
|
|
161 |
|
|
162 |
|
|
163 |
\subsection{Package Reference} |
\subsection{Package Reference} |
164 |
|
|