1 |
\section[Customizing MITgcm]{Doing it yourself: customizing the code} |
2 |
|
3 |
When you are ready to run the model in the configuration you want, the |
4 |
easiest thing is to use and adapt the setup of the case studies |
5 |
experiment (described previously) that is the closest to your |
6 |
configuration. Then, the amount of setup will be minimized. In this |
7 |
section, we focus on the setup relative to the ``numerical model'' |
8 |
part of the code (the setup relative to the ``execution environment'' |
9 |
part is covered in the parallel implementation section) and on the |
10 |
variables and parameters that you are likely to change. |
11 |
|
12 |
\subsection{Configuration and setup} |
13 |
|
14 |
The CPP keys relative to the ``numerical model'' part of the code are |
15 |
all defined and set in the file \textit{CPP\_OPTIONS.h }in the |
16 |
directory \textit{ model/inc }or in one of the \textit{code |
17 |
}directories of the case study experiments under |
18 |
\textit{verification.} The model parameters are defined and declared |
19 |
in the file \textit{model/inc/PARAMS.h }and their default values are |
20 |
set in the routine \textit{model/src/set\_defaults.F. }The default |
21 |
values can be modified in the namelist file \textit{data }which needs |
22 |
to be located in the directory where you will run the model. The |
23 |
parameters are initialized in the routine |
24 |
\textit{model/src/ini\_parms.F}. Look at this routine to see in what |
25 |
part of the namelist the parameters are located. |
26 |
|
27 |
In what follows the parameters are grouped into categories related to |
28 |
the computational domain, the equations solved in the model, and the |
29 |
simulation controls. |
30 |
|
31 |
\subsection{Computational domain, geometry and time-discretization} |
32 |
|
33 |
\begin{description} |
34 |
\item[dimensions] \ |
35 |
|
36 |
The number of points in the x, y, and r directions are represented |
37 |
by the variables \textbf{sNx}, \textbf{sNy} and \textbf{Nr} |
38 |
respectively which are declared and set in the file |
39 |
\textit{model/inc/SIZE.h}. (Again, this assumes a mono-processor |
40 |
calculation. For multiprocessor calculations see the section on |
41 |
parallel implementation.) |
42 |
|
43 |
\item[grid] \ |
44 |
|
45 |
Three different grids are available: cartesian, spherical polar, and |
46 |
curvilinear (which includes the cubed sphere). The grid is set |
47 |
through the logical variables \textbf{usingCartesianGrid}, |
48 |
\textbf{usingSphericalPolarGrid}, and \textbf{usingCurvilinearGrid}. |
49 |
In the case of spherical and curvilinear grids, the southern |
50 |
boundary is defined through the variable \textbf{phiMin} which |
51 |
corresponds to the latitude of the southern most cell face (in |
52 |
degrees). The resolution along the x and y directions is controlled |
53 |
by the 1D arrays \textbf{delx} and \textbf{dely} (in meters in the |
54 |
case of a cartesian grid, in degrees otherwise). The vertical grid |
55 |
spacing is set through the 1D array \textbf{delz} for the ocean (in |
56 |
meters) or \textbf{delp} for the atmosphere (in Pa). The variable |
57 |
\textbf{Ro\_SeaLevel} represents the standard position of Sea-Level |
58 |
in ``R'' coordinate. This is typically set to 0m for the ocean |
59 |
(default value) and 10$^{5}$Pa for the atmosphere. For the |
60 |
atmosphere, also set the logical variable \textbf{groundAtK1} to |
61 |
\texttt{'.TRUE.'} which puts the first level (k=1) at the lower |
62 |
boundary (ground). |
63 |
|
64 |
For the cartesian grid case, the Coriolis parameter $f$ is set |
65 |
through the variables \textbf{f0} and \textbf{beta} which correspond |
66 |
to the reference Coriolis parameter (in s$^{-1}$) and |
67 |
$\frac{\partial f}{ \partial y}$(in m$^{-1}$s$^{-1}$) respectively. |
68 |
If \textbf{beta } is set to a nonzero value, \textbf{f0} is the |
69 |
value of $f$ at the southern edge of the domain. |
70 |
|
71 |
\item[topography - full and partial cells] \ |
72 |
|
73 |
The domain bathymetry is read from a file that contains a 2D (x,y) |
74 |
map of depths (in m) for the ocean or pressures (in Pa) for the |
75 |
atmosphere. The file name is represented by the variable |
76 |
\textbf{bathyFile}. The file is assumed to contain binary numbers |
77 |
giving the depth (pressure) of the model at each grid cell, ordered |
78 |
with the x coordinate varying fastest. The points are ordered from |
79 |
low coordinate to high coordinate for both axes. The model code |
80 |
applies without modification to enclosed, periodic, and double |
81 |
periodic domains. Periodicity is assumed by default and is |
82 |
suppressed by setting the depths to 0m for the cells at the limits |
83 |
of the computational domain (note: not sure this is the case for the |
84 |
atmosphere). The precision with which to read the binary data is |
85 |
controlled by the integer variable \textbf{readBinaryPrec} which can |
86 |
take the value \texttt{32} (single precision) or \texttt{64} (double |
87 |
precision). See the matlab program \textit{gendata.m} in the |
88 |
\textit{input} directories under \textit{verification} to see how |
89 |
the bathymetry files are generated for the case study experiments. |
90 |
|
91 |
To use the partial cell capability, the variable \textbf{hFacMin} |
92 |
needs to be set to a value between 0 and 1 (it is set to 1 by |
93 |
default) corresponding to the minimum fractional size of the cell. |
94 |
For example if the bottom cell is 500m thick and \textbf{hFacMin} is |
95 |
set to 0.1, the actual thickness of the cell (i.e. used in the code) |
96 |
can cover a range of discrete values 50m apart from 50m to 500m |
97 |
depending on the value of the bottom depth (in \textbf{bathyFile}) |
98 |
at this point. |
99 |
|
100 |
Note that the bottom depths (or pressures) need not coincide with |
101 |
the models levels as deduced from \textbf{delz} or \textbf{delp}. |
102 |
The model will interpolate the numbers in \textbf{bathyFile} so that |
103 |
they match the levels obtained from \textbf{delz} or \textbf{delp} |
104 |
and \textbf{hFacMin}. |
105 |
|
106 |
(Note: the atmospheric case is a bit more complicated than what is |
107 |
written here I think. To come soon...) |
108 |
|
109 |
\item[time-discretization] \ |
110 |
|
111 |
The time steps are set through the real variables \textbf{deltaTMom} |
112 |
and \textbf{deltaTtracer} (in s) which represent the time step for |
113 |
the momentum and tracer equations, respectively. For synchronous |
114 |
integrations, simply set the two variables to the same value (or you |
115 |
can prescribe one time step only through the variable |
116 |
\textbf{deltaT}). The Adams-Bashforth stabilizing parameter is set |
117 |
through the variable \textbf{abEps} (dimensionless). The stagger |
118 |
baroclinic time stepping can be activated by setting the logical |
119 |
variable \textbf{staggerTimeStep} to \texttt{'.TRUE.'}. |
120 |
|
121 |
\end{description} |
122 |
|
123 |
|
124 |
\subsection{Equation of state} |
125 |
|
126 |
First, because the model equations are written in terms of |
127 |
perturbations, a reference thermodynamic state needs to be specified. |
128 |
This is done through the 1D arrays \textbf{tRef} and \textbf{sRef}. |
129 |
\textbf{tRef} specifies the reference potential temperature profile |
130 |
(in $^{o}$C for the ocean and $^{o}$K for the atmosphere) starting |
131 |
from the level k=1. Similarly, \textbf{sRef} specifies the reference |
132 |
salinity profile (in ppt) for the ocean or the reference specific |
133 |
humidity profile (in g/kg) for the atmosphere. |
134 |
|
135 |
The form of the equation of state is controlled by the character |
136 |
variables \textbf{buoyancyRelation} and \textbf{eosType}. |
137 |
\textbf{buoyancyRelation} is set to \texttt{'OCEANIC'} by default and |
138 |
needs to be set to \texttt{'ATMOSPHERIC'} for atmosphere simulations. |
139 |
In this case, \textbf{eosType} must be set to \texttt{'IDEALGAS'}. |
140 |
For the ocean, two forms of the equation of state are available: |
141 |
linear (set \textbf{eosType} to \texttt{'LINEAR'}) and a polynomial |
142 |
approximation to the full nonlinear equation ( set \textbf{eosType} to |
143 |
\texttt{'POLYNOMIAL'}). In the linear case, you need to specify the |
144 |
thermal and haline expansion coefficients represented by the variables |
145 |
\textbf{tAlpha} (in K$^{-1}$) and \textbf{sBeta} (in ppt$^{-1}$). For |
146 |
the nonlinear case, you need to generate a file of polynomial |
147 |
coefficients called \textit{POLY3.COEFFS}. To do this, use the program |
148 |
\textit{utils/knudsen2/knudsen2.f} under the model tree (a Makefile is |
149 |
available in the same directory and you will need to edit the number |
150 |
and the values of the vertical levels in \textit{knudsen2.f} so that |
151 |
they match those of your configuration). |
152 |
|
153 |
There there are also higher polynomials for the equation of state: |
154 |
\begin{description} |
155 |
\item[\texttt{'UNESCO'}:] The UNESCO equation of state formula of |
156 |
Fofonoff and Millard \cite{fofonoff83}. This equation of state |
157 |
assumes in-situ temperature, which is not a model variable; {\em its |
158 |
use is therefore discouraged, and it is only listed for |
159 |
completeness}. |
160 |
\item[\texttt{'JMD95Z'}:] A modified UNESCO formula by Jackett and |
161 |
McDougall \cite{jackett95}, which uses the model variable potential |
162 |
temperature as input. The \texttt{'Z'} indicates that this equation |
163 |
of state uses a horizontally and temporally constant pressure |
164 |
$p_{0}=-g\rho_{0}z$. |
165 |
\item[\texttt{'JMD95P'}:] A modified UNESCO formula by Jackett and |
166 |
McDougall \cite{jackett95}, which uses the model variable potential |
167 |
temperature as input. The \texttt{'P'} indicates that this equation |
168 |
of state uses the actual hydrostatic pressure of the last time |
169 |
step. Lagging the pressure in this way requires an additional pickup |
170 |
file for restarts. |
171 |
\item[\texttt{'MDJWF'}:] The new, more accurate and less expensive |
172 |
equation of state by McDougall et~al. \cite{mcdougall03}. It also |
173 |
requires lagging the pressure and therefore an additional pickup |
174 |
file for restarts. |
175 |
\end{description} |
176 |
For none of these options an reference profile of temperature or |
177 |
salinity is required. |
178 |
|
179 |
\subsection{Momentum equations} |
180 |
|
181 |
In this section, we only focus for now on the parameters that you are |
182 |
likely to change, i.e. the ones relative to forcing and dissipation |
183 |
for example. The details relevant to the vector-invariant form of the |
184 |
equations and the various advection schemes are not covered for the |
185 |
moment. We assume that you use the standard form of the momentum |
186 |
equations (i.e. the flux-form) with the default advection scheme. |
187 |
Also, there are a few logical variables that allow you to turn on/off |
188 |
various terms in the momentum equation. These variables are called |
189 |
\textbf{momViscosity, momAdvection, momForcing, useCoriolis, |
190 |
momPressureForcing, momStepping} and \textbf{metricTerms }and are |
191 |
assumed to be set to \texttt{'.TRUE.'} here. Look at the file |
192 |
\textit{model/inc/PARAMS.h }for a precise definition of these |
193 |
variables. |
194 |
|
195 |
\begin{description} |
196 |
\item[initialization] \ |
197 |
|
198 |
The velocity components are initialized to 0 unless the simulation |
199 |
is starting from a pickup file (see section on simulation control |
200 |
parameters). |
201 |
|
202 |
\item[forcing] \ |
203 |
|
204 |
This section only applies to the ocean. You need to generate |
205 |
wind-stress data into two files \textbf{zonalWindFile} and |
206 |
\textbf{meridWindFile} corresponding to the zonal and meridional |
207 |
components of the wind stress, respectively (if you want the stress |
208 |
to be along the direction of only one of the model horizontal axes, |
209 |
you only need to generate one file). The format of the files is |
210 |
similar to the bathymetry file. The zonal (meridional) stress data |
211 |
are assumed to be in Pa and located at U-points (V-points). As for |
212 |
the bathymetry, the precision with which to read the binary data is |
213 |
controlled by the variable \textbf{readBinaryPrec}. See the matlab |
214 |
program \textit{gendata.m} in the \textit{input} directories under |
215 |
\textit{verification} to see how simple analytical wind forcing data |
216 |
are generated for the case study experiments. |
217 |
|
218 |
There is also the possibility of prescribing time-dependent periodic |
219 |
forcing. To do this, concatenate the successive time records into a |
220 |
single file (for each stress component) ordered in a (x,y,t) fashion |
221 |
and set the following variables: \textbf{periodicExternalForcing }to |
222 |
\texttt{'.TRUE.'}, \textbf{externForcingPeriod }to the period (in s) |
223 |
of which the forcing varies (typically 1 month), and |
224 |
\textbf{externForcingCycle} to the repeat time (in s) of the forcing |
225 |
(typically 1 year -- note: \textbf{ externForcingCycle} must be a |
226 |
multiple of \textbf{externForcingPeriod}). With these variables set |
227 |
up, the model will interpolate the forcing linearly at each |
228 |
iteration. |
229 |
|
230 |
\item[dissipation] \ |
231 |
|
232 |
The lateral eddy viscosity coefficient is specified through the |
233 |
variable \textbf{viscAh} (in m$^{2}$s$^{-1}$). The vertical eddy |
234 |
viscosity coefficient is specified through the variable |
235 |
\textbf{viscAz} (in m$^{2}$s$^{-1}$) for the ocean and |
236 |
\textbf{viscAp} (in Pa$^{2}$s$^{-1}$) for the atmosphere. The |
237 |
vertical diffusive fluxes can be computed implicitly by setting the |
238 |
logical variable \textbf{implicitViscosity }to \texttt{'.TRUE.'}. |
239 |
In addition, biharmonic mixing can be added as well through the |
240 |
variable \textbf{viscA4} (in m$^{4}$s$^{-1}$). On a spherical polar |
241 |
grid, you might also need to set the variable \textbf{cosPower} |
242 |
which is set to 0 by default and which represents the power of |
243 |
cosine of latitude to multiply viscosity. Slip or no-slip conditions |
244 |
at lateral and bottom boundaries are specified through the logical |
245 |
variables \textbf{no\_slip\_sides} and \textbf{no\_slip\_bottom}. If |
246 |
set to \texttt{'.FALSE.'}, free-slip boundary conditions are |
247 |
applied. If no-slip boundary conditions are applied at the bottom, a |
248 |
bottom drag can be applied as well. Two forms are available: linear |
249 |
(set the variable \textbf{bottomDragLinear} in s$ ^{-1}$) and |
250 |
quadratic (set the variable \textbf{bottomDragQuadratic} in |
251 |
m$^{-1}$). |
252 |
|
253 |
The Fourier and Shapiro filters are described elsewhere. |
254 |
|
255 |
\item[C-D scheme] \ |
256 |
|
257 |
If you run at a sufficiently coarse resolution, you will need the |
258 |
C-D scheme for the computation of the Coriolis terms. The |
259 |
variable\textbf{\ tauCD}, which represents the C-D scheme coupling |
260 |
timescale (in s) needs to be set. |
261 |
|
262 |
\item[calculation of pressure/geopotential] \ |
263 |
|
264 |
First, to run a non-hydrostatic ocean simulation, set the logical |
265 |
variable \textbf{nonHydrostatic} to \texttt{'.TRUE.'}. The pressure |
266 |
field is then inverted through a 3D elliptic equation. (Note: this |
267 |
capability is not available for the atmosphere yet.) By default, a |
268 |
hydrostatic simulation is assumed and a 2D elliptic equation is used |
269 |
to invert the pressure field. The parameters controlling the |
270 |
behaviour of the elliptic solvers are the variables |
271 |
\textbf{cg2dMaxIters} and \textbf{cg2dTargetResidual } for |
272 |
the 2D case and \textbf{cg3dMaxIters} and |
273 |
\textbf{cg3dTargetResidual} for the 3D case. You probably won't need to |
274 |
alter the default values (are we sure of this?). |
275 |
|
276 |
For the calculation of the surface pressure (for the ocean) or |
277 |
surface geopotential (for the atmosphere) you need to set the |
278 |
logical variables \textbf{rigidLid} and \textbf{implicitFreeSurface} |
279 |
(set one to \texttt{'.TRUE.'} and the other to \texttt{'.FALSE.'} |
280 |
depending on how you want to deal with the ocean upper or atmosphere |
281 |
lower boundary). |
282 |
|
283 |
\end{description} |
284 |
|
285 |
\subsection{Tracer equations} |
286 |
|
287 |
This section covers the tracer equations i.e. the potential |
288 |
temperature equation and the salinity (for the ocean) or specific |
289 |
humidity (for the atmosphere) equation. As for the momentum equations, |
290 |
we only describe for now the parameters that you are likely to change. |
291 |
The logical variables \textbf{tempDiffusion} \textbf{tempAdvection} |
292 |
\textbf{tempForcing}, and \textbf{tempStepping} allow you to turn |
293 |
on/off terms in the temperature equation (same thing for salinity or |
294 |
specific humidity with variables \textbf{saltDiffusion}, |
295 |
\textbf{saltAdvection} etc.). These variables are all assumed here to |
296 |
be set to \texttt{'.TRUE.'}. Look at file \textit{model/inc/PARAMS.h} |
297 |
for a precise definition. |
298 |
|
299 |
\begin{description} |
300 |
\item[initialization] \ |
301 |
|
302 |
The initial tracer data can be contained in the binary files |
303 |
\textbf{hydrogThetaFile} and \textbf{hydrogSaltFile}. These files |
304 |
should contain 3D data ordered in an (x,y,r) fashion with k=1 as the |
305 |
first vertical level. If no file names are provided, the tracers |
306 |
are then initialized with the values of \textbf{tRef} and |
307 |
\textbf{sRef} mentioned above (in the equation of state section). In |
308 |
this case, the initial tracer data are uniform in x and y for each |
309 |
depth level. |
310 |
|
311 |
\item[forcing] \ |
312 |
|
313 |
This part is more relevant for the ocean, the procedure for the |
314 |
atmosphere not being completely stabilized at the moment. |
315 |
|
316 |
A combination of fluxes data and relaxation terms can be used for |
317 |
driving the tracer equations. For potential temperature, heat flux |
318 |
data (in W/m$ ^{2}$) can be stored in the 2D binary file |
319 |
\textbf{surfQfile}. Alternatively or in addition, the forcing can |
320 |
be specified through a relaxation term. The SST data to which the |
321 |
model surface temperatures are restored to are supposed to be stored |
322 |
in the 2D binary file \textbf{thetaClimFile}. The corresponding |
323 |
relaxation time scale coefficient is set through the variable |
324 |
\textbf{tauThetaClimRelax} (in s). The same procedure applies for |
325 |
salinity with the variable names \textbf{EmPmRfile}, |
326 |
\textbf{saltClimFile}, and \textbf{tauSaltClimRelax} for freshwater |
327 |
flux (in m/s) and surface salinity (in ppt) data files and |
328 |
relaxation time scale coefficient (in s), respectively. Also for |
329 |
salinity, if the CPP key \textbf{USE\_NATURAL\_BCS} is turned on, |
330 |
natural boundary conditions are applied i.e. when computing the |
331 |
surface salinity tendency, the freshwater flux is multiplied by the |
332 |
model surface salinity instead of a constant salinity value. |
333 |
|
334 |
As for the other input files, the precision with which to read the |
335 |
data is controlled by the variable \textbf{readBinaryPrec}. |
336 |
Time-dependent, periodic forcing can be applied as well following |
337 |
the same procedure used for the wind forcing data (see above). |
338 |
|
339 |
\item[dissipation] \ |
340 |
|
341 |
Lateral eddy diffusivities for temperature and salinity/specific |
342 |
humidity are specified through the variables \textbf{diffKhT} and |
343 |
\textbf{diffKhS} (in m$^{2}$/s). Vertical eddy diffusivities are |
344 |
specified through the variables \textbf{diffKzT} and |
345 |
\textbf{diffKzS} (in m$^{2}$/s) for the ocean and \textbf{diffKpT |
346 |
}and \textbf{diffKpS} (in Pa$^{2}$/s) for the atmosphere. The |
347 |
vertical diffusive fluxes can be computed implicitly by setting the |
348 |
logical variable \textbf{implicitDiffusion} to \texttt{'.TRUE.'}. |
349 |
In addition, biharmonic diffusivities can be specified as well |
350 |
through the coefficients \textbf{diffK4T} and \textbf{diffK4S} (in |
351 |
m$^{4}$/s). Note that the cosine power scaling (specified through |
352 |
\textbf{cosPower}---see the momentum equations section) is applied to |
353 |
the tracer diffusivities (Laplacian and biharmonic) as well. The |
354 |
Gent and McWilliams parameterization for oceanic tracers is |
355 |
described in the package section. Finally, note that tracers can be |
356 |
also subject to Fourier and Shapiro filtering (see the corresponding |
357 |
section on these filters). |
358 |
|
359 |
\item[ocean convection] \ |
360 |
|
361 |
Two options are available to parameterize ocean convection: one is |
362 |
to use the convective adjustment scheme. In this case, you need to |
363 |
set the variable \textbf{cadjFreq}, which represents the frequency |
364 |
(in s) with which the adjustment algorithm is called, to a non-zero |
365 |
value (if set to a negative value by the user, the model will set it |
366 |
to the tracer time step). The other option is to parameterize |
367 |
convection with implicit vertical diffusion. To do this, set the |
368 |
logical variable \textbf{implicitDiffusion} to \texttt{'.TRUE.'} |
369 |
and the real variable \textbf{ivdc\_kappa} to a value (in m$^{2}$/s) |
370 |
you wish the tracer vertical diffusivities to have when mixing |
371 |
tracers vertically due to static instabilities. Note that |
372 |
\textbf{cadjFreq} and \textbf{ivdc\_kappa}can not both have non-zero |
373 |
value. |
374 |
|
375 |
\end{description} |
376 |
|
377 |
\subsection{Simulation controls} |
378 |
|
379 |
The model ''clock'' is defined by the variable \textbf{deltaTClock} |
380 |
(in s) which determines the IO frequencies and is used in tagging |
381 |
output. Typically, you will set it to the tracer time step for |
382 |
accelerated runs (otherwise it is simply set to the default time step |
383 |
\textbf{deltaT}). Frequency of checkpointing and dumping of the model |
384 |
state are referenced to this clock (see below). |
385 |
|
386 |
\begin{description} |
387 |
\item[run duration] \ |
388 |
|
389 |
The beginning of a simulation is set by specifying a start time (in |
390 |
s) through the real variable \textbf{startTime} or by specifying an |
391 |
initial iteration number through the integer variable |
392 |
\textbf{nIter0}. If these variables are set to nonzero values, the |
393 |
model will look for a ''pickup'' file \textit{pickup.0000nIter0} to |
394 |
restart the integration. The end of a simulation is set through the |
395 |
real variable \textbf{endTime} (in s). Alternatively, you can |
396 |
specify instead the number of time steps to execute through the |
397 |
integer variable \textbf{nTimeSteps}. |
398 |
|
399 |
\item[frequency of output] \ |
400 |
|
401 |
Real variables defining frequencies (in s) with which output files |
402 |
are written on disk need to be set up. \textbf{dumpFreq} controls |
403 |
the frequency with which the instantaneous state of the model is |
404 |
saved. \textbf{chkPtFreq} and \textbf{pchkPtFreq} control the output |
405 |
frequency of rolling and permanent checkpoint files, respectively. |
406 |
See section 1.5.1 Output files for the definition of model state and |
407 |
checkpoint files. In addition, time-averaged fields can be written |
408 |
out by setting the variable \textbf{taveFreq} (in s). The precision |
409 |
with which to write the binary data is controlled by the integer |
410 |
variable w\textbf{riteBinaryPrec} (set it to \texttt{32} or |
411 |
\texttt{64}). |
412 |
|
413 |
\end{description} |
414 |
|
415 |
|
416 |
%%% Local Variables: |
417 |
%%% mode: latex |
418 |
%%% TeX-master: t |
419 |
%%% End: |