source: trunk/LMDZ.GENERIC/DOC/run.tex @ 1243

Last change on this file since 1243 was 987, checked in by jleconte, 12 years ago

11/06/2013 == JL+EM

  • User manual (+ sources) added in DOC.
File size: 19.1 KB
Line 
1
2\chapter{Running the model: a practice simulation}
3
4\label{loc:contact1}
5
6This chapter is meant for first-time users of the LMD model.
7As the best introduction to the model is surely to run a simulation,
8here we explain how to go about it.
9All you will need are files necessary to build the GCM (all are in
10the {\tt LMDZ.GENERIC} directory) as well as some initial states
11to initiate simulations (see below).\\
12Once you have followed the example given below,
13you can then go on to change the control parameters and the initial states
14as you wish. A more detailed description of the model's organization
15as well as associated inputs and
16outputs are given in sections~\ref{sc:info} and~\ref{sc:io}.
17
18\section{Installing the model from SVN}
19
20The first thing is to download the model from our SVN server. If you cannot use SVN, just find an old school way to get a copy of the basic model directory \verb"LMDZ.GENERIC" (and all the other source files needed for visualization) and download it to your account. Then start directly from the fifth point.
21
22\begin{description}
23\item[$\bullet$] Go to the directory where you want to download the model. Not that only one directory (the root directory) will be added in the current directory.
24
25\item[$\bullet$] If svn is installed on your system, set up the root directory by tipping
26\begin{verbatim}
27svn co "http://svn.lmd.jussieu.fr/Planeto/trunk" -N Name_of_root_directory
28cd Name_of_root_directory
29\end{verbatim}
30
31\item[$\bullet$] You can now download one of the LMDZ models (for Generic, Mars, Venus, Titan, ...) by tipping
32\begin{verbatim}
33svn update LMDZ.MODEL_YOU_WANT
34\end{verbatim}
35For the Generic model, just tipe
36\begin{verbatim}
37svn update LMDZ.GENERIC
38\end{verbatim}
39The contents of the directory that has been created are described in Chapter \ref{loc:contenu}.
40
41\item[$\bullet$] For visualization of the simulations, yo will need some utilities that we might as well download now by doing
42\begin{verbatim}
43svn update UTIL
44\end{verbatim}
45
46\item[$\bullet$] Now we must set up the {\tt makegcm} script that will perform the compilation of the model. Go into the {\tt LMDZ.GENERIC} directory and edit the appropriate \verb"makegcm_mycompiler" (hereafter called \verb"makegcm"), where \verb"mycompiler" is the compiler that you want to use.
47There are two important environment variables concerning source files that are initialized by \verb"makegcm" and that we need to set properly:
48\begin{enumerate}
49\item \verb"LMDGCM", the path to the source files. By default, the line
50\begin{verbatim}
51setenv LMDGCM `readlink -f $scriptdir`
52\end{verbatim}
53allows \verb"makegcm" to assume that it is executed in the root source directory so that this should work without any change. If \verb"makegcm" does not find the source, you can enter manually the path by changing the above line by
54 \begin{verbatim}
55setenv LMDGCM "path/to/source/directory/LMDZ.GENERIC"
56\end{verbatim}
57\item \verb"LIBOGCM", the path to the compilation directory where all object files will be kept. By default, the line
58\begin{verbatim}
59setenv LIBOGCM $LMDGCM/libo
60\end{verbatim}
61specifies that source will be kept in a \verb"libo" directory created in \verb"LMDZ.GENERIC". You can also change that if needed.
62\end{enumerate} 
63
64\item[$\bullet$]Install NetCDF
65%\item {\bf -} \htmladdnormallink{Install NetCDF}
66{http://www.unidata.ucar.edu/packages/netcdf/INSTALL.html}
67and set environment variables  \verb"NCDFINC" and \verb"NCDFLIB":
68
69  \begin{description}
70  \item The latest version of the NetCDF package is available on the web at the following address: {http://www.unidata.ucar.edu/software/netcdf}
71  along with instructions for building (or downloading precompiled
72  binaries of) the library.
73  \item Once the NetCDF library has been compiled (or downloaded),
74  you should have access to the library {\tt libnetcdf.a} itself,
75  the various files ({\tt netcdf.inc}, {\tt netcdf.mod}, ...)
76  to include in programs, and basic NetCDF software ({\it ncdump}
77  and {\it ncgen}).
78
79  \item To ensure that during compilation, the model can find the
80  NetCDF library and include files,
81  you must declare environment variables \verb"NCDFLIB" and \verb"NCDFINC".
82
83  \item \verb"NCDFLIB" must contain the path to the directory containing
84   the object library {\tt libnetcdf.a}
85   and \verb"NCDFINC" must contain the path to the directory containing
86   the include files ({\tt netcdf.inc},...)\\
87As for \verb"LMDGCM" variable, these variables can be declared by changing the right line in \verb"makegcm"
88  \begin{verbatim}
89  setenv NCDFINC /wherever/is/netcdf/include
90  setenv NCDFLIB /wherever/is/netcdf/lib
91  \end{verbatim}
92For example, if working at LMD and with \verb"ifort", the path is 
93   \begin{verbatim}
94  setenv NCDFINC /donnees/emlmd/netcdf64-4.0.1_ifort/include
95  setenv NCDFLIB /donnees/emlmd/netcdf64-4.0.1_ifort/lib
96  \end{verbatim}
97  \end{description}
98 
99\item[$\bullet$] Install software for loading and displaying NetCDF files
100   such as GrAdS (http://grads.iges.org/grads/), Ferret (http://ferret.wrc.noaa.gov/Ferret), or Python. Some visualization scripts, especially for Python, can be found in the
101\verb"UTIL" directory and will be described later.
102
103
104\item[$\bullet$] Finally, make sure that you have access to all the executables
105needed for building and using the model and
106remember to set environment variables to the correct corresponding pathes
107(note that if you do not want to have to redefine these every session,
108you should put the definitions in the corresponding {\tt .cshrc} or
109{\tt .bashrc} files).
110
111  \begin{description}
112  \item {\bf -} UNIX function {\it make}
113  \item {\bf -} a Fortran compiler
114  \item {\bf -} ncdump
115  \item {\bf -} grads (or ferret)
116  \end{description}
117
118\end{description}
119
120
121\section{Installing the model without SVN}
122
123 Create an alias so that the compilation script {\bf makegcm}
124  is available from anywhere (more convinient than having to type the full
125  path to the script, or copying it over where you want to run it).
126  The {\tt makegcm} script is in the LMDZ.GENERIC directory, which
127  is referenced by the {\bf LMDGCM} variable, so:\\
128  If using Csh:
129  \begin{verbatim}
130  alias makegcm $LMDGCM'/makegcm'
131  \end{verbatim}
132  if using Bash:
133  \begin{verbatim}
134  alias makegcm=$LMDGCM/makegcm
135  \end{verbatim}
136
137\section{Compiling the model}
138\label{sc:run1}
139
140Two options exist to compile the model.
141\begin{enumerate}
142\item Create an alias so that the compilation script \verb"makegcm"
143  is available from anywhere.
144  If using Csh:
145  \begin{verbatim}
146  alias makegcm 'path/to/LMDZ.GENERIC/makegcm'
147  \end{verbatim}
148  if using Bash:
149  \begin{verbatim}
150  alias makegcm=path/to/LMDZ.GENERIC/makegcm
151  \end{verbatim}
152Then the compilation is done by tipping
153  \begin{verbatim}
154makegcm -options gcm
155  \end{verbatim}
156This solution can be convenient but is less flexible if you want to compile the model in many different configurations and keep track of it.
157
158\item Create and edit an executable script (that we will call \verb"compile") in the directory where you will want to run the model. Put the line
159  \begin{verbatim}
160/path/to/the/model/I/use/makegcm -options gcm
161  \end{verbatim}
162The advantage of this option is that the \verb"compile" is present in all of the working directories where the model is ran, allowing you to keep track of the options used.
163\end{enumerate}
164
165Just remains to choose the options. The basic options are as follows
166\begin{verbatim}
167makegcm -d LONxLATxALT -p std -t XX -s YY -b IRxVI gcm
168\end{verbatim}
169where \verb"LONxLATxALT" are the number of grid cells in longitude, latitude and altitude, \verb"XX" is the number of tracers, \verb"YY" is the number of scatterers that will be taken into account in the radiative code and \verb"IRxVI" is the number of spectral bands in the thermal emission and stellar part of the radiative code. The option \verb"-debug" is available with most compilers. The code runs much more slowly but can output more user friendly bug report messages.
170
171{\bf -} Example 1: Compiling the generic model at grid resolution 64x48x20
172for example, type (in compliance with the manual for the makegcm function
173given in section~\ref{sc:compil1})
174
175\begin{verbatim}
176makegcm -d 64x48x20 -p std gcm
177\end{verbatim}
178
179\noindent
180You can find executable {\bf gcm.e} (the compiled model) in the directory
181where you ran the makegcm command.
182
183{\bf -} Example 2: Compiling the generic model with 2 tracers
184(e.g. water vapour and ice to simulate the water cycle):
185\begin{verbatim}
186makegcm -d 32x32x20 -t 2 -p std gcm
187\end{verbatim}
188
189{\bf -} Example 3:
190Compiling the the generic model to check for and trace errors (with ifort compiler -
191useful for debugging - warning, the model then runs very slowly!):
192\begin{verbatim}
193makegcm -d 32x32x20 -p std -O "-g -fpe0 -traceback" gcm
194\end{verbatim}
195
196\section{Input files (initial states and def files)}
197{\bf -} In directory \verb+LMDZ.GENERIC/deftank+
198you will find some examples of run
199parameter files ({\tt .def} files) which the model needs at runtime.
200The four files the model requires (they must be in the same directory as the
201executable {\tt gcm.e}) are:
202{\bf run.def} (described in
203section~\ref{loc:entrees}) {\bf callphys.def}
204(see section~\ref{sc:callphys.def}),
205{\bf gases.def}, {\bf z2sig.def} and {\bf traceur.def}.\\
206
207The example {\tt .def} files given in the {\tt deftank} directory
208are for various configurations (e.g. model resolution, planet type), copy (and eventually
209rename these files to match the generic names) to the directory where
210you will run the model.\\
211
212\noindent
213{\bf -} Copy initial condition files
214{\bf start.nc} and {startfi.nc}  (described in section
215\ref{loc:entrees}) to the same directory.\\
216You can extract such files from {\bf start\_archive}
217`banks of initial states' (i.e. files which
218contain collections of initial states from
219stndard scenarios and which can thus be used
220to check if the model is installed correctly) stored on the LMD website at\\
221\verb+http://www.lmd.jussieu.fr/~forget/datagcm/Starts+.
222See section~\ref{sc:newstart} for a description of how to proceed to
223extract {\bf start} files from {\bf start\_archives}.\\
224
225[NOTE: WITH THE GENERIC MODEL WE ALMOST ALWAYS START FROM ``startplanet'' FILES]
226
227\section{Running the model}
228\begin{figure}
229\centerline{\framebox[1.4\textwidth][c]{\includegraphics[width=1.2\textwidth]{Fig/inout.eps}}}
230\caption{Input/output data}
231\label{fig:inout}
232\end{figure}
233
234Once you have the program {\bf gcm.e},
235input files {\bf start.nc} {\bf startfi.nc},
236and parameter files {\bf run.def, callphys.def, gases.def, traceur.def, and z2sig.def}
237in the same directory, simply execute the program to run a simulation:
238\begin{verbatim}
239gcm.e
240\end{verbatim}
241
242You might also want to keep all messages and diagnostics written to standard
243output (i.e. the screen). You should then redirect the standard output
244(and error) to some file, e.g. {\tt gcm.out}:\\
245If using Csh:
246\begin{verbatim}
247gcm.e >! gcm.out
248\end{verbatim}
249If using Bash:
250\begin{verbatim}
251gcm.e > gcm.out 2>&1
252\end{verbatim}
253
254
255\section{Visualizing the output files}
256
257As the model runs it generates output files {\bf diagfi.nc} and
258{\bf stats.nc} files. The former contains instantaneous values of
259various fields and the later statistics (over the whole run) of some
260variables.
261
262\subsection{Using GrAds to visualize outputs}
263If you have never used the graphic software {\bf GrAds}, we strongly
264recommend spending half an hour to familiarize yourself with it by following
265the demonstration provided for that purpose.
266The demo is fast and easy to follow and you will learn the basic commands.
267To do this read file
268\begin{verbatim}
269/distrib/local/grads/sample
270\end{verbatim}
271
272For example, to visualize files {\tt diagfi.nc} and {\tt stats.nc}
273
274NetCDF files {\tt diagfi.nc} and {\tt stats.nc} can be accessed directly
275using GrAdS thanks to utility program gradsnc,
276(the user does not need to intervene).\\
277
278\noindent
279To visualize the temperature in the 5th layer using file
280{\tt diagfi.nc} for example:
281\label{loc:visu}
282
283\begin{description}
284\item {\bf -} GrAdS session:
285
286  \begin{description}
287  \item \verb+grads+ {\it return}
288
289  \item {\it return} (opens a landscape window)
290
291  \item \verb+ga-> sdfopen diagfi.nc+
292
293  \item \verb+ga-> query file+ (displays info about the open file, including the name of the stored variables. Shortcut: {\it q file})
294
295  \item \verb+ga-> set z 5+ (fixes the altitude to the 5th layer)
296
297  \item \verb+ga-> set t 1+ (fixes the time to the first stored value)
298
299  \item \verb+ga-> query dims+ (indicates the fixed values for the 4
300  dimensions. Shortcut: {\it q dims})
301
302  \item \verb+ga-> display temp+ (displays the temperature card for the 5th layer and for the first time value stored. Shortcut: {\it d
303  T})
304
305  \item \verb+ga-> clear+ (clears the display. Shortcut: {\it c})
306
307  \item \verb+ga-> set gxout shaded+ (not a contour plot, but a shaded one)
308
309  \item \verb+ga-> display temp+
310
311  \item \verb+ga-> set gxout contour+ (returns to contour mode to display the levels)
312
313  \item \verb+ga-> display temp+ (superimposes the contours if the clear command is not used)
314
315  \end{description}
316\end{description}
317
318
319
320%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
321
322\section{Resuming a simulation}
323At the end of a simulation, the model generates {\bf restart} files
324(files {\tt restart.nc} and {\tt restartfi.nc})
325which contain the final state of the model.
326As shown in figure~\ref{fig:inout},
327these files (which are of the same format as the start files)
328can later be used as initial
329states for a new simulation.\\
330
331\noindent
332The {\bf restart} files just need to be renamed:
333\begin{verbatim}
334mv restart.nc start.nc
335mv restartfi.nc startfi.nc
336\end{verbatim}
337\noindent
338and running a simulation with these will in fact resume the simulation
339from where the previous run ended.
340
341\section{Chain simulations}
342
343In practice, we recommend running a chain of simulations lasting several
344days or longer (or hundreds of days at low resolution).
345
346To do this, a script named {\tt run0} is available in
347\verb+LMDZ.GENERIC/deftank+ , which should be used as follows:
348\begin{itemize}
349\item Set the length of each simulation in {\tt run.def}
350 (i.e. set the value of {\tt nday})
351\item Set the maximum number of simulations at the beginning of the {\tt run0}
352script (i.e. set the value of {\tt nummax})
353\item Copy start files {\tt start.nc  startfi.nc} over and rename them
354      {\tt start0.nc startfi0.nc}.
355\item Run script {\tt run0}
356\end{itemize}
357
358{\tt run0} runs a series of simulations that generate the indexed output
359files (e.g. {\tt start1, startfi1, diagfi1}, etc.)
360including files {\tt lrun1, lrun2}, etc. containing the redirection of the
361display and the information about the run.
362
363{\it NOTE:} to restart a series of simulations after a first series
364(for example, starting from {\tt start5 and  startfi5}), just write the
365index of the initial files (e.g. 5) in the file named {\tt num\_run}.
366If {\tt num\_run} exists, the model will start from the index written in
367{\tt num\_run}. If not it will start from, {\tt start0 and startfi0}.
368
369
370{\it NOTE}: A script is available for performing annual runs with 12 seasons
371at 30$^o$ solar longitude
372as it is in the database (script {\bf \tt run\_mcd}, also found in directory
373{\tt deftank}).
374This script functions with script run0. Just set the number of simulations to
3751 in run0. Then copy run.def into run.def.ref and set nday to 9999 in this
376file. To start from startN.c, edit the file run\_mcd and comment
377(with a \#) the N months already created and describe N in {\tt num\_run}.
378Then run  {\bf \tt run\_mcd}.
379
380
381\section{Creating and modifying initial states}
382
383\label{sc:newstart}
384
385\subsection{Using program ``newstart''}
386
387When working with the generic model, it is common to start with simple initial conditions (e.g., isothermal, motionless atmosphere). For this we create an initial state using {\bf newstart}. In practice, we usually take an old initial state, and simply modify it.
388
389Like the GCM, the program {\bf newstart} must be compiled (using the {\tt makegcm} script) to the required grid resolution.
390For example:
391\begin{verbatim}
392makegcm -d 32x32x20 -p std newstart
393\end{verbatim}
394
395Then run
396
397\begin{verbatim}
398newstart.e
399\end{verbatim}
400
401The program then gives you two options:
402
403\begin{verbatim}
404 From which kind of files do you want to create newstart and startfi files
405     0 - from a file start_archive
406     1 - from files start and startfi
407\end{verbatim}
408
409\begin{itemize}
410\item{-} Option ``1'' allows you to read and modify the information needed
411to create a new initial state  from the files
412\verb+ start.nc, startfi.nc +
413\item{-} Option ``0'' allows you to read and modify the information needed to
414create a new initial state from file
415\verb+ start_archive.nc + (whatever the \verb+ start_archive.nc +
416grid resolution is).\\
417\end{itemize}
418If you use tracers, make sure that they are taken into account in your
419start files (either start or start\_archive).\\ \\
420Then answer to the various questions in the scroll menu.
421These questions allow you to modify the initial state for the following
422parameters.\\
423
424
425\input{input/questions_inistate.tex}
426
427Program {\bf newstart.e} creates files
428{\tt restart.nc} and {\tt restartfi.nc}
429that you generally need to rename (for instance rename them in start0.nc
430and startfi0.nc if you want to use run0 or run\_mcd, starting with season 0;
431rename them {\tt start.nc} and {\tt startfi.nc} if you just want to perform
432one run with {\tt gcm.e}).
433
434
435\subsection{Creating the initial start\_archive.nc file }
436
437Archive file
438{\tt start\_archive.nc} is created from files
439{\tt start.nc} and {\tt startfi.nc} by program {\bf start2archive}.
440Program {\bf start2archive} compiles to the same grid resolution as the
441{\tt start.nc} and {\tt startfi.nc} grid resolution. For example:
442
443\begin{verbatim}
444makegcm -d 32x32x20 -p std start2archive
445\end{verbatim}
446Then run \verb+ start2archive.e+ \\ \\
447You now have a \verb+ start_archive.nc+ file for one season that you can
448use with newstart.
449If you want to gather other states obtained at other times of year, rerun
450{\tt start2archive.e} with the {\tt start.nc} and {\tt startfi.nc}
451 corresponding to these.
452These additional initial states will automatically be added to the
453{\tt start\_archive.nc} file present in the directory.
454
455\subsection{Changing the horizontal or vertical grid resolution}
456
457To run at a different grid resolution than available initial conditions
458files, one needs to use tools {\bf newstart} and {\bf start2archive}
459
460For example, to create initial states at grid resolution
46132$\times$24$\times$25 from NetCDF files
462\verb+ start + and \verb+ startfi + at grid resolution
463  64$\times$48$\times$32 :
464
465\begin{itemize}
466\item Create file \verb+ start_archive.nc +
467with {\bf start2archive.e} compiled at grid resolution
46864$\times$48$\times$25 using {\bf old file {\tt z2sig.def}
469 used previously}
470
471\item Create files
472{\tt newstart.nc} and {\tt newstartfi.nc}
473 with {\bf newstart.e}
474compiled at grid resolution 32$\times$24$\times$25,
475using {\bf new file {\tt z2sig.def}}
476
477\end{itemize}
478
479[NOT RELEVANT??]
480If you want to create starts files with tracers for 50 layers using a
481{\tt start\_archive.nc} obtained for 32 layers, do not forget to use the
482\verb+ ini_q+ option in newstart in order to correctly initialize tracers
483value for layer 33 to layer 50.
484You just have to answer yes to the question on thermosphere initialization
485if you want to initialize the thermosphere part only (l=33 to l=50),
486and no if you want to initialize tracers for all layers (l=0 to l=50).\\ \\
487
Note: See TracBrowser for help on using the repository browser.