source: trunk/LMDZ.MARS/doc/io.tex @ 3468

Last change on this file since 3468 was 1954, checked in by emillour, 6 years ago

Mars GCM:

  • Make a "doc" subdirectory to store the documentation source files with the code.

EM

File size: 18.5 KB
Line 
1\chapter{Input/Output}
2\label{sc:io}
3
4\section{NetCDF format}
5
6%%%%%%%%%%%%%%%%%%%%%%%%%%
7GCM input/output data are written in {\bf NetCDF} format
8(Network Common Data Form). NetCDF is an interface used to store and access
9geophysical data, and a library that provides an implementation of this
10interface. The NetCDF library also defines a machine-independent format for
11representing scientific data.
12Together, the interface, library and format support the creation, access and
13sharing of scientific data. NetCDF was developed at the Unidata Program Center
14in Boulder, Colorado. The freely available source can be obtained from
15the Unidata website:
16\begin{verbatim}
17http://www.unidata.ucar.edu/software/netcdf
18\end{verbatim}
19
20
21%%%%%%%%%%%%%%%%%%%%%%%%%%
22
23A data set in NetCDF format is a single file, as it is self-descriptive.
24
25\subsection{NetCDF text representation: ncdump}
26
27This utility is included in the NetCDF library.
28It generates the CDL representation (text format of the file content) to the standard output
29from the NetCDF file specified as input.
30
31\paragraph{Main options for the ncdump command}
32
33\begin{center}
34{\it ncdump diagfi.nc}
35\end{center}
36
37\noindent
38dump contents of NetCDF file {\tt diagfi.nc} to standard output
39(i.e. the screen).
40
41\begin{center}
42{\it ncdump -c diagfi.nc}
43\end{center}
44
45\noindent
46Displays the {\bf coordinate} variable values (variables which are also
47dimensions), as well as the declarations, variables and attribute values.
48The values of the non-coordinate variable data are not displayed at
49the output.
50
51\begin{center}
52{\it ncdump -h diagfi.nc}
53\end{center}
54
55\noindent
56Shows only the informative header of the file, which is the declaration
57of the dimensions, variables and attributes, but not the values of these
58variables. The output is identical to that in option {\bf -c} except for
59the fact that the coordinated variable values are not included.
60
61\begin{center}
62{\it ncdump -v var1,...,varn diagfi.nc}
63\end{center}
64
65\noindent
66The output includes the specific variable values,
67as well as all the dimensions, variables and attributes.
68More that one variable can be specified in the list following this option.
69The list must be a simple argument for the command, and must not contain any
70spaces. If no variable is specified, the command displays all the values of
71the variables in the file by default. 
72
73
74\subsection{Graphic visualization of NetCDF files using GrAds}
75
76GrAdS (The Grid Analysis and Display System) is a graphic software developed
77by Brian Doty at the "Center for Ocean-Land-Atmosphere (COLA)".
78
79One of its functions is to enable data stored in NetCDF format to be
80visualized directly. In figure~\ref{fg:grads} for example, we can see the
81GrADS visualization of the temperature data at a given moment.
82%
83\begin{figure}
84\centering
85\includegraphics[width=0.5\textwidth,angle=270]{Fig/grads.pdf}
86\caption{Example of temperature data at a given time using
87GrADS visualization\label{fg:grads}}
88\end{figure}
89%
90However, unlike NetCDF, GrADS only recognizes files where all the variables are stored on the same horizontal grid.
91These variables can be in 1, 2, 3 or 4 dimensions (X,Y,Z and t).\\
92
93GrADS can also be obtained from:
94\begin{verbatim}
95http://grads.iges.org/grads/
96\end{verbatim}
97
98\subsection{Graphic visualization of NetCDF files using Ferret}
99
100Ferret may also be used to visualize the contents of NetCDF files. Download intruction and documentation are available from the official website:
101\begin{verbatim}
102https://ferret.pmel.noaa.gov/Ferret/
103\end{verbatim} 
104
105\section{Input and parameter files}
106
107%{\bf \it Examples of initialization files can be found in directory
108%\begin{verbatim}$PATH1/LMDZ.MARS/deftank \end{verbatim}}
109\label{loc:entrees}
110
111The (3D version of the) GCM requires
112the input of two initialization files (in NetCDF format):\\
113-{\bf start.nc}
114contains the initial states of the dynamical variables.\\
115-{\bf startfi.nc}
116contains the initial states of the physical variables.\\
117Note that collections of initial states can be retreived at:\\
118\verb+http://www.lmd.jussieu.fr/~lmdz/planets/mars/starts+ \\
119Extracting {\tt start.nc} and {\tt startfi.nc} from these archived
120requires using program {\tt newstart}, as described in
121section~\ref{sc:newstart}.\\
122
123\noindent
124To run, the GCM also requires the  four following
125parameter files (ascii text files):\\
126-{\bf run.def} the parameters of the dynamical part of the program,
127and the temporal integration of the model.\\
128-{\bf callphys.def} the parameters for calling the physical part.\\
129-{\bf traceur.def} the names of the tracer to use.\\
130-{\bf z2sig.def}
131 the vertical distribution of the atmospheric layers.\\
132Examples of these parameter files can be found in the
133\verb+LMDZ.MARS/deftank+ directory.
134
135\subsection{run.def}
136\label{vb:run.def}
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% run.def: les param sont lus dans dyn3d/defrun.F
139%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
140
141A typical {\tt run.def} file is given as an example below.
142The choice of variables to be set is simple (e.g.
143 {\tt nday} number of modeled days to run),
144while the others do not need to be changed for normal use.\\
145The format of the {\tt run.def} file is quite straightforward
146(and flexible): values given to parameters must be given as:
147\begin{verbatim}
148  parameter = value
149\end{verbatim}
150Any blank line or line beginning with symbol {\bf \#} is
151a comment, and instruction lines may be written in any order.
152Moreover, not specifying a parameter/value set (e.g. deleting it
153or commenting it out) means you want the GCM to use a default built-in value.
154Additionally, one may use a specific keyword {\bf INCLUDEDEF} to specify
155another (text) file in which to also read values of parameters; e.g.:
156\begin{verbatim}
157INCLUDEDEF=callphys.def
158\end{verbatim}
159
160
161\noindent Here are some details about some of the parameters which may be
162set in {\tt run.def}:
163\begin{itemize}
164\item {\bf day\_step}, the number of dynamical steps per day to use for
165the time integration. This needs to be large enough for the model
166to remain stable (this is related to the CFL stability criterion
167which essentially depends on the horizontal resolution of the model).
168On Mars, in theory, the GCM can run with
169{\tt day\_step}=480 using the 64$\times$48 grid, but model stability
170improves when this number is higher: {\tt day\_step}=960 is recommended
171 when using the 64$\times$48 grid. According to the CFL criterion,
172{\tt day\_step} should vary in proportion with the resolution: for example
173{\tt day\_step}=480 using the 32$\times$24 horizontal resolution.
174Note that {\tt day\_step} must also be divisible by {\tt iperiod}.
175
176\item {\bf tetagdiv, tetagrot, tetatemp} control the dissipation intensity.
177It is better to limit the dissipation intensity
178(tetagdiv, tetagrot, tetatemp should not be too low).
179However the model diverges if tetagdiv, tetagrot, tetatemp are too high,
180especially if there is a lot of dust in the atmosphere. \\
181Example used with nitergdiv=1 and  nitergrot=niterh=2 : \\
182- using the 32$\times$24 grid tetagdiv=6000~s ; tetagrot=tetatemp=30000~s \\
183- using the 64$\times$48 grid: tetagdiv=2500~s ; tetagrot=tetatemp=5000~s
184
185\item {\bf idissip} is the time step used for the dissipation:
186dissipation is computed and added every {\tt idissip} dynamical
187time step. If {\tt idissip} is
188too short, the model waste time in these calculations. But if idissip is too
189long, the  dissipation will not be parametrized correctly and the  model will
190be more likely to diverge.
191A check must be made, so that:
192{\tt idissip}~$<$~{\tt tetagdiv}$\times${\tt daystep}/88775
193(same rule for {\tt tetagrot} and {\tt tetatemp}).
194This is tested automatically during the run.
195
196\item {\bf iphysiq} is the time step used for the physics:
197physical tendencies are computed every {\tt iphysiq} dynamical time step.
198In practice, we
199usually set the physical time step to be of the order of half an hour.
200We thus generally set {\tt iphysiq}= {\tt day\_step}/48
201
202\end{itemize}
203
204\noindent
205{\it Example of run.def file: }
206{\footnotesize
207\input{input/run.tex}
208}
209%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
210
211
212\subsection{callphys.def}
213\label{sc:callphys.def}
214%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
215% callphys.def: les param sont lus dans phymars/inifis.F
216%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217The {\tt callphys.def} file (along the same format
218as the {\tt run.def} file) contains parameter/value sets
219for the physics.\\
220
221 
222\noindent
223{\it Example of callphys.def file: }
224{\footnotesize
225\input{input/callphys.tex}
226}
227%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
228
229\subsection{traceur.def}
230\label{sc:traceur.def}
231Tracers in input ({\tt start.nc} and {\tt startfi.nc}) and output
232files ({\tt restart.nc} and {\tt restartfi.nc}) are stored using
233individual tracer names (e.g. {\tt co2} for CO2 gas, {\tt h2o\_vap}
234for water vapour, {\tt h2o\_ice} for water ice, ...).\\
235The first line of the {\tt traceur.def} file (an ASCII file) must
236contain the number of tracers to load and use (this number should
237be the same as given to the {\tt -t} option of the {\tt makegcm}
238script when the GCM was compiled), followed by the tracer names
239(one per line). Note that if the corresponding tracers are not
240found in input files {\tt start.nc} and {\tt startfi.nc}, then the
241tracer is initialized to zero.\\
242
243
244\noindent {\it Example of a traceur.def file}:
245with CO2, dust distribution moments, (water ice) cloud condensation nuclei moments, water vapour and water ice tracers
246{\footnotesize
247\begin{verbatim}
2487
249co2
250dust_number
251dust_mass
252ccn_number
253ccn_mass
254h2o_ice
255h2o_vap
256\end{verbatim}
257}
258
259\subsection{z2sig.def}
260The {\tt Z2sig.def} file contains the pseudo-altitudes
261(in km) at which the user wants to set the vertical levels.\\
262Note that levels should be unevenly spread, with a higher resolution
263near the surface in order to capture the rapid variations of variables
264there. It is recommended to use the altitude levels as set in the
265{\tt z2sig.def} file provided in the {\tt deftank} directory.\\
266
267
268\noindent
269{\it Example of  z2sig.def file
270(this version for 49 layers between  0 and 300~km):}
271{\footnotesize
272\input{input/z2sig.tex}
273}
274
275\subsection{Initialization files: start and startfi}
276
277%
278\begin{figure}[h]
279\centering
280\framebox[0.8\textwidth][c]{\includegraphics[width=0.7\textwidth]{Fig/netcdf.pdf}}
281\caption{Organization of NetCDF files \label{fg:netcdf}}
282\end{figure}
283%
284Files {\tt start.nc} and {\tt startfi.nc}, like all the NetCDF files of
285the GCM,
286are constructed on the same model (see NetCDF file composition,
287figure~\ref{fg:netcdf}). They contain:\\
288- a header with a ``control'' variable followed by a series of variables
289defining the (physical and dynamical) grids \\
290- a series of non temporal variables that give information about surface
291conditions on the planet.\\
292- a ``time'' variable giving the values of the different instants at which
293the temporal variables are stored
294(a single time value (t=0) for start,
295as it describes the dynamical initial states,
296and no time values for startfi, as it describes only a physical state).\\
297
298To dump (in text format) the contents of a {\tt start.nc} file using the
299{\tt ncdump} command:\\
300
301\noindent
302{\it ncdump -h start.nc}\\
303%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
304% List START
305%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
306\input{input/dyn_list.tex}
307%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
308
309\noindent
310List of contents of a {\tt startfi.nc} file:\\
311
312\noindent
313{\it ncdump -h startfi.nc}\\
314%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
315% List startfi
316%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
317\input{input/fi_list.tex}
318%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
319
320
321
322%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
323%    Description des start et startfi
324%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
325
326\paragraph{Physical and dynamical headers}
327
328There are two types of headers: one for the physical headers,
329and one for the dynamical headers.
330The headers always begin with a ``control' variable
331(described below), that is allocated differently in the physical and
332dynamical parts.
333The other variables in the header concern the (physical and dynamical) grids.
334They are the following:\\
335
336\noindent
337the horizontal coordinates\\
338- {\bf rlonu}, {\bf rlatu}, {\bf rlonv}, {\bf rlatv} for the dynamical part,\\
339- {\bf lati}, {\bf long} for the physical part,\\
340
341\noindent
342the coefficients for passing from the physical grid to the dynamical grid\\
343- {\bf cu},{\bf cv} only in the dynamical header\\
344
345\noindent
346and finally, the grid box areas\\
347- {\bf aire} for the dynamical part,\\
348- {\bf area} for the physical part.\\
349
350\paragraph{Surface conditions}
351
352The surface conditions are mostly given in the physical NetCDF files by
353variables:\\
354- {\bf phisfi} for the initial state of surface geopotential,\\
355- {\bf albedodat} for the bare ground albedo,\\
356- {\bf inertiedat} for the surface thermal inertia,\\
357- {\bf zmea}, {\bf zstd}, {\bf zsig}, {\bf zgam} and {\bf zthe} for
358  the subgrid scale topography.\\
359
360\noindent
361For the dynamics:\\
362- {\bf physinit} for the initial state of surface geopotential\\
363
364\noindent
365Remark: variables {\bf phisfi} and {\bf physinit} contain the same information
366(surface geopotential), but {\bf phisfi} gives the geopotential values on the
367physical grid, while {\bf physinit} give the values on the dynamical grid.\\
368
369\paragraph{Physical and dynamical state variables}
370To save disk space, the initialization files store the variables used by
371the model, rather than the ``natural'' variables.\\
372
373\noindent
374For the dynamics:
375\begin{description}
376\item - {\bf ucov} and {\bf vcov} the covariant winds\\
377These variables are linked to the ``natural'' winds by\\
378\verb+ucov = cu * u+ and \verb+vcov = cv * v+
379\item - {\bf teta} the potential temperature,\\
380  or more precisely, the potential enthalpy linked to temperature {\bf T} by
381  $\theta = T\dep{\frac{P}{Pref}}^{-K}$
382\item - the tracers,
383\item - {\bf ps} surface pressure.
384\item - {\bf masse} the atmosphere mass in each grid box.
385\end{description}
386
387\noindent
388``Vectorial'' variables {\bf ucov} and {\bf vcov} are stored on
389``staggered'' grids u and v respectively (in the dynamics)
390(see section \ref{fg:grid}).\\
391Scalar variables {\bf h}, {\bf q} (tracers), {\bf ps}, {\bf masse} are stored
392on the ``scalar'' grid of the dynamical part.\\
393
394\noindent
395For the physics:
396\begin{description}
397\item - {\bf co2ice} surface dry ice,
398\item - {\bf tsurf} surface temperature,
399\item - {\bf tsoil} temperatures at different layers under the surface,
400\item - {\bf emis} surface emissivity,
401\item - {\bf q2} wind variance,\\
402or more precisely, the square root of the turbulent kinetic energy.
403\item - the surface ``tracer'' budget
404 (kg.m$^{-2}$),\\
405\end{description}
406
407\noindent
408All these variables are stored on the ``physical'' grid
409(see section \ref{fg:grid}).\\
410%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
411
412\paragraph{The ``control'' array}
413
414\indent
415Both physical and dynamical headers of the GCM NetCDF files start with
416a {\bf controle} variable. This variable is an array of 100 reals (the vector
417called {\tt tab\_cntrl} in the program), which contains the program control
418parameters.
419Parameters differ between the physical and dynamical sections, and examples
420of both are listed below. The contents of table {\tt tab\_cntrl} can also
421be checked with the command {\tt ncdump -ff -v controle}.\\
422
423\noindent
424{\bf The "control" array in the header of a dynamical NetCDF file:
425start}
426%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
427% tab_cntrl (dynamique) dans dyn3d/inimomo.F
428%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
429\input{input/dyn_cntl.tex}
430%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
431
432\noindent
433{\bf The "controle" array in the header of a physical NetCDF file:
434startfi.nc}
435%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
436% tab_cntrl (physique) dans phymars/iniwritefi.F
437%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
438\input{input/fi_cntl.tex}
439%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
440 
441\newpage
442\section{Output files}
443
444\subsection{NetCDF restart files - restart.nc and restartfi.nc}
445These files are of the exact same format as {\tt start.nc} and
446{\tt startfi.nc}
447%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
448% Description des fichiers de Sortie
449%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
450
451\subsection{ NetCDF file - diagfi.nc}
452NetCDF file {\tt diagfi.nc} stores the instantaneous physical variables
453throughout the simulation at regular intervals
454(set by the value of parameter {\tt ecritphy} in
455parameter file {\tt run.def}; note that {\tt ecritphy} should be a
456multiple of {\tt iphysiq} as well as a divisor of {\tt day\_step}).
457
458\noindent
459{\bf Any variable from any sub-routine of the physics can be stored
460by calling subroutine} {\tt writediagfi}.
461Moreover, one may add a {\tt diagfi.def} file containing only the names
462of variables to output (one per line) in the directory where the GCM is
463run, in order to have only thoses listed outputed in the {\tt diagfi.nc}
464file.\\
465
466\noindent
467Illustrative example of the contents of a {\tt diagfi.nc}
468file (using ncdump):\\
469\noindent
470{\it ncdump -h diagfi.nc}\\
471%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
472% List DIAGFI
473%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
474% temporaire!!!
475\input{input/diag_list.tex}
476%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
477
478\noindent
479The structure of the file is thus as follows:
480\begin{description}
481\item- the dimensions
482\item- variable ``time'' containing the time of the timestep stored in the
483 file (in Martian days since the beginning of the run)
484\item- variable ``control'' containing many parameters, as described above.
485\item- from `` rhonu'' to 'phisinit'': a list of data describing the
486 geometrical coordinates of the data file, plus the surface topography
487\item- finally, all the 2D or 3D data stored in the run.
488\end{description}
489
490
491\subsection{Stats files}
492
493As an option ({\tt stats} must be set to {\tt .true.} in {\tt callphys.def}),
494the model can accumulate any
495variable from any subroutine of the physics by calling
496subroutine \verb+ wstat+
497\\ \\ 
498\noindent
499This save is performed at regular intervals 12 times a day.
500An average of the daily evolutions over the whole run is calculated
501(for example, for a 10 day run, the averages of the variable values at
5020hTU, 2hTU, 4hTU,...24hTU are calculated), along with RMS standard
503deviations of the variables. This ouput is given in
504file {\tt stats.nc}.\\
505
506
507\noindent
508Illustrative example of the contents of a {\tt stats.nc} file (using ncdump):\\
509\noindent
510{\it ncdump -h stats.nc}\\
511\input{input/stats_list.tex}
512
513\noindent
514The structure of the file is simillar to the {\tt diagfi.nc} file,
515except that, as stated before, the average of variables are given for
51612 times of the day and that RMS standard deviation are also provided.
517
Note: See TracBrowser for help on using the repository browser.