source: trunk/LMDZ.MARS/doc/run.tex @ 2790

Last change on this file since 2790 was 2569, checked in by emillour, 3 years ago

Mars GCM: update documentation (mostly better handling of http links)
EM

File size: 20.1 KB
Line 
1%\part{Faire tourner le mod\`ele}
2
3
4\chapter{Running the model: a practice simulation}
5
6\label{loc:contact1}
7
8This chapter is meant for first time users of the LMD model.
9As the best introduction to the model is surely to run a simulation,
10here we explain how to go about it.
11All you will need are files and scripts necessary to build the GCM (all are in
12the {\tt LMDZ.COMMON} and {\tt LMDZ.MARS} directories which you will download
13as explained in the next
14sections) as well as some initial states to initiate simulations and,
15if not working on the
16LMD machines, some extra datafiles for external forcings (topography,
17dust scenarios, radiative properties of dust and water ice, etc.).\\
18Once you have followed the example given below,
19you can then go on to change the control parameters and the initial states
20as you wish. A more detailed description of the model's organization
21as well as associated inputs and
22outputs are given in sections~\ref{sc:info} and~\ref{sc:io}.
23
24\section{Obtaining the model}
25The LMD model project is developped using subversion (svn), the free software
26versioning and a revision control system.
27To obtain (download) the latest version of the model,
28simply go to the directory where you want to
29install the model and use the relevant svn command:\\
30{\tt svn checkout http://svn.lmd.jussieu.fr/Planeto/trunk --depth empty}\\
31Then move to the newly generated {\tt trunk directory} and download
32(i.e. {\tt svn update}) the
33{\tt LMDZ.MARS} and {\tt LMDZ.COMMON} directories (the contents of these
34directories are described in chapter \ref{loc:contenu}) with:
35\begin{verbatim}
36svn update LMDZ.MARS LMDZ.COMMON UTIL
37\end{verbatim}
38
39If you are not on the LMD machines, you will also need to download a
40set of files available online at:\\
41\url{http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir}\\
42(preserve the file names and subdirectory structure).
43This directory contains input files (topography, dust scenarios,
44radiative properties of scatteres, etc.) which the GCM needs to run.
45Where you put your local {\tt datadir} directory (or whatever name
46you choose for this directory) is not critical, as that location can
47be specified at runtime (see sections \ref{sc:running_gcm} and
48\ref{sc:callphys.def}).\\
49
50To run the model, you will also need some initial condition files that
51can be downloaded from:\\
52\url{http://www.lmd.jussieu.fr/~lmdz/planets/mars/starts}
53(see section \ref{sc:inputfiles}).
54
55\section{Prerequisites}
56Before downloading and installing the model, a few prerequisites
57must be satisfied:
58\begin{enumerate}
59\item The NetCDF library must be installed
60 on your system, using the same
61 compiler suite (e.g. gfortran and gcc, or ifort and icc) that you will use
62 to compile the model. The latest version of the NetCDF package is available
63 on the web at the following address:\\
64  \url{https://www.unidata.ucar.edu/software/netcdf} \\
65
66  along with instructions for building (or downloading precompiled
67  binaries of) the library.\\
68  Note that we provide in the {\tt UTIL} directory a Bash script
69  {\tt install\_netcdf4.0.1.bash} which may be used to download and install
70  version 4.0.1 of the NetCDF library; run {\tt install\_netcdf4.0.1.bash -h}
71  to list available options.
72\item Some software to load and display NetCDF files such as
73   \begin{itemize}
74   \item Ferret \url{http://ferret.wrc.noaa.gov/Ferret}
75   \item Panoply \url{https://www.giss.nasa.gov/tools/panoply}
76   \item GrAdS \url{http://grads.iges.org/grads}
77   \item ncview \url{http://meteora.ucsd.edu/~pierce/ncview_home_page.html}
78   \end{itemize}
79   among others, should be installed on your system.
80\item The {\tt fcm} utility must be installed on your system.
81  If it is not already so, it may be obtained by the following svn command line:\\
82  {\verb+ svn checkout http://forge.ipsl.jussieu.fr/fcm/svn/PATCHED/FCM_V1.2+}\\
83  And add its {\tt bin} subdirectory to your {\tt PATH} environment variable
84  to make the {\tt fcm} command available from anywhere.
85\item To run at higher resolution (and/or with many tracers) requires some memory, in particular a reasonable stacksize (which is often quite limited by default). It is thus highly recommended that you set this value to {\tt unlimited} via
86the command
87\begin{verbatim}
88ulimit -s unlimited
89\end{verbatim}
90before running the GCM, or more pragmatically by adding this instruction to you
91{\tt .bashrc} or {\tt .profile} so that it is always set.
92\end{enumerate}
93
94\section{Installing the model}
95Scripts for installation/compilation for the model are in the {\tt LMDZ.COMMON} directory
96These scripts can also run the model on parallel computers.
97
98You should first compile the IOIPSL library which is used\footnote{It is in fact for now possible to run the GCM without the IOIPSL library but this requires adding the {\tt -io noioipsl} to the {\tt makelmdz\_fcm} command line, and might no longer be possible in the future.} by the GCM. To do this go to the {\tt LMDZ.COMMON/ioipsl} directory. There are a number of example scripts (depending on machines and compiler suites to use) to run to download and install the ioipsl library. As an illustrative example we detail here using the {\tt install\_ioipsl\_gfortran.bash} script:
99\begin{itemize}
100\item Edit script {\tt install\_ioipsl\_gfortran.bash} to set the path to your NetCDF library in the {\tt setfolder} variable, e.g. \verb+ setfolder="/usr/local/netcdf"+
101\item Run the script: \verb+ ./install_ioipsl_gfortran.bash+
102\item If all went well the script should end with the message \verb+ OK: ioipsl library is in + followed by the full path to the library {\tt libioipsl.a} and companion module files in in subdirectory \verb+modipsl/lib+
103\end{itemize}
104
105\section{Compiling the model}
106\label{sc:compile}
107The Bash script {\tt makelmdz\_fcm} is used to compile the model.
108It needs not be modified or adapted to your settings, as all
109specificities are set in corresponding files located in the {\tt arch}
110subdirectory. For a given machine, e.g. {\tt MyMachine}, one should create
111two files, {\tt arch-MyMachine.fcm} and {\tt arch-MyMachine.path}, using the
112provided example files to set appropriate compiler options and paths
113(for instance {\tt arch-linux-ifort-para.fcm} and
114{\tt arch-linux-ifort-para.path} are adapted to run on local LMD machines).\\
115The {\tt makelmdz\_fcm} script has the mandatory option {\tt -arch MyArch}
116to specify the arch files to use (the {\tt "MyArch"} string should be replaced
117with the name used for your own arch files), and multiple options:
118\begin{itemize}
119\item Example 1: Compiling the Martian model at grid resolution 64x48x49
120\begin{verbatim}
121makelmdz_fcm -arch linux-ifort -d 64x48x49 -p mars gcm
122\end{verbatim}
123\item Example 2: Compiling as above but in "debug" mode
124\begin{verbatim}
125makelmdz_fcm -arch linux-ifort -d 64x48x49 -p mars -debug gcm
126\end{verbatim}
127\item Example 3: Compiling the model to run in parallel (MPI) mode:
128\begin{verbatim}
129makelmdz_fcm -arch linux-ifort -parallel mpi -d 64x48x49 -p mars gcm
130\end{verbatim}
131This option is different from the -j option that determines the number of cores when compilation is run in parallel mode.
132\item For an overview of all available options:
133\begin{verbatim}
134makelmdz_fcm -h
135\end{verbatim}
136\end{itemize}
137Upon succesfull compilation, the GCM executable is generated in the
138{\tt LMDZ.COMMON/bin} directory with the following naming convention:
139\begin{verbatim}
140gcm_XXX_phymars_YY.e
141\end{verbatim}
142where \verb+XXX+ is the model resolution (which was specified with the {\tt -d} argument) and \verb+YY+ is either \verb+seq+ or \verb+para+ depending on if the model was compiled in serial or parallel mode ({\tt -parallel} argument).
143
144\section{Input files (initial states and def files)}
145\label{sc:inputfiles}
146In directory \verb+LMDZ.MARS/deftank+
147you will find some examples of run
148parameter files ({\tt .def} files) which the model needs at runtime.
149The four files the model requires (they must be in the same directory as the
150executable {\tt gcm.e}) are:
151{\bf run.def} (described in
152section~\ref{loc:entrees}) {\bf callphys.def}
153(see section~\ref{sc:callphys.def}),
154{\bf callphys.def}, {\bf z2sig.def} and {\bf traceur.def}.\\
155
156The example {\tt .def} files given in the {\tt deftank} directory
157are for various configurations (e.g. model resolution), copy (and eventually
158rename these files to match the generic names) to the directory where
159you will run the model.\\
160
161Copy initial condition files
162{\bf start.nc} and {startfi.nc}  (described in section
163\ref{loc:entrees}) to the same directory.\\
164You can extract such files from {\bf start\_archive}
165`banks of initial states' (i.e. files which
166contain collections of initial states from
167stndard scenarios and which can thus be used
168to check if the model is installed correctly) stored on the LMD website at
169\url{http://www.lmd.jussieu.fr/~lmdz/planets/mars/starts}.
170See section~\ref{sc:newstart} for a description of how to proceed to
171extract {\bf start} files from {\bf start\_archives}.
172
173\section{Running the model}
174\label{sc:running_gcm}
175\begin{figure}
176\centerline{\framebox[1.4\textwidth][c]{\includegraphics[width=1.2\textwidth]{Fig/inout.pdf}}}
177\caption{Input/output data}
178\label{fig:inout}
179\end{figure}
180
181Once you have the program {\bf gcm.e},
182input files {\bf start.nc} {\bf startfi.nc},
183and parameter files {\bf run.def callphys.def traceur.def z2sig.def}
184in the same directory,
185simply execute the program to run\footnote{
186Note that if you ar not running on the LMD machines, you'll have to
187modify or add, in file {\tt callphys.def}, the line:
188{\tt datadir = /path/to/datafile}\\
189Where {\tt /path/to/datafile} is the full path to the directory which
190contains the set of files downloaded from:\\
191\url{http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir} \\
192To ease downloading, a tar file of this directory can be obtained at: \\
193\url{http://www.lmd.jussieu.fr/~lmdz/planets/mars/datadir.tar.gz}
194}
195a simulation:
196\begin{verbatim}
197gcm.e
198\end{verbatim}
199
200You might also want to keep all messages and diagnotics written to standard
201output (i.e. the screen). You should then redirect the standard output
202(and error) to some file, e.g. {\tt gcm.out}:
203\begin{verbatim}
204gcm.e > gcm.out 2>&1
205\end{verbatim}
206
207If you want to use parallel mode (as MPI for instance), you should specify it as follow:
208\begin{verbatim}
209mpirun gcm.e > gcm.out 2>&1
210\end{verbatim}
211NB: The definition of parallel parameters, such as number of cores, is dependant on the machine used.
212You should find examples of scripts within other simulations or machine user guides.
213
214
215\section{Visualizing the output files}
216
217As the model runs it generates output files {\bf diagfi.nc} and
218{\bf stats.nc} files. The former contains instantaneous values of
219various fields and the later statistics (over the whole run) of some
220variables.
221
222\subsection{Using Ferret to visualize outputs}
223Documentation and tutorials are available on the Ferret official website:
224\begin{verbatim}
225https://ferret.pmel.noaa.gov/Ferret/
226\end{verbatim}
227If you are a new user, we strongly recommend first spending some time browsing the official tutorials and documentation to learn more about Ferret capabilities and usage.\\
228
229Here is asimple illustrative example of how one may visualize temperature for the 5th layer and 9th time step from a {\tt diagfi.nc} file:
230\begin{description}
231\item {\bf -} Ferret session:
232  \begin{description}
233  \item \verb+ferret+ {\it return}
234  \item \verb!yes? use diagfi.nc!
235  \item \verb!yes? show data! (displays information about available variables and their dimensions)
236  \item \verb!yes? fill temp[k=5,l=9]! (plot temperature map of 5th layer and 9th time step)
237  \end{description}
238\end{description}
239
240\subsection{Using GrAds to visualize outputs}
241If you have never used the graphic software {\bf GrAds}, we strongly
242recommend spending half an hour to familiarize yourself with it by following
243the demonstration provided for that purpose.
244The demo is fast and easy to follow and you will learn the basic commands.
245To do this read file
246\begin{verbatim}
247/distrib/local/grads/sample
248\end{verbatim}
249
250For example, to visualize files {\tt diagfi.nc} and {\tt stats.nc}
251
252NetCDF files {\tt diagfi.nc} and {\tt stats.nc} can be accessed directly
253using GrAdS thanks to utility program gradsnc,
254(the user does not need to intervene).\\
255
256\noindent
257To visualize the temperature in the 5th layer using file
258{\tt diagfi.nc} for example:
259\label{loc:visu}
260
261\begin{description}
262\item {\bf -} GrAdS session:
263
264  \begin{description}
265  \item \verb+grads+ {\it return}
266
267  \item {\it return} (opens a landscape window)
268
269  \item \verb+ga-> sdfopen diagfi.nc+
270
271  \item \verb+ga-> query file+ (displays info about the open file, including the name of the stored variables. Shortcut: {\it q file})
272
273  \item \verb+ga-> set z 5+ (fixes the altitude to the 5th layer)
274
275  \item \verb+ga-> set t 1+ (fixes the time to the first stored value)
276
277  \item \verb+ga-> query dims+ (indicates the fixed values for the 4
278  dimensions. Shortcut: {\it q dims})
279
280  \item \verb+ga-> display temp+ (displays the temperature card for the 5th layer and for the first time value stored. Shortcut: {\it d
281  T})
282
283  \item \verb+ga-> clear+ (clears the display. Shortcut: {\it c})
284
285  \item \verb+ga-> set gxout shaded+ (not a contour plot, but a shaded one)
286
287  \item \verb+ga-> display temp+
288
289  \item \verb+ga-> set gxout contour+ (returns to contour mode to display the levels)
290
291  \item \verb+ga-> display temp+ (superimposes the contours if the clear command is not used)
292
293  \end{description}
294\end{description}
295
296
297
298%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
299
300\section{Resuming a simulation}
301At the end of a simulation, the model generates {\bf restart} files
302(files {\tt restart.nc} and {\tt restartfi.nc})
303which contain the final state of the model.
304As shown in figure~\ref{fig:inout},
305these files (which are of the same format as the start files)
306can later be used as initial
307states for a new simulation.\\
308
309\noindent
310The {\bf restart} files just need to be renamed:
311\begin{verbatim} 
312mv restart.nc start.nc
313mv restartfi.nc startfi.nc
314\end{verbatim}
315\noindent
316and running a simulation with these will in fact resume the simulation
317from where the previous run ended.
318
319\section{Chain simulations}
320
321In practice, we recommend running a chain of simulations lasting several
322days or longer (or hundreds of days at low resolution).
323
324To do this, a script named {\tt run0} is available in
325\verb+LMDZ.MARS/deftank+ , which should be used as follows:
326\begin{itemize}
327\item Set the length of each simulation in {\tt run.def}
328 (i.e. set the value of {\tt nday})
329\item Set the maximum number of simulations at the beginning of the {\tt run0}
330script (i.e. set the value of {\tt nummax})
331\item Copy start files {\tt start.nc  startfi.nc} over and rename them
332      {\tt start0.nc startfi0.nc}.
333\item Run script {\tt run0} 
334\end{itemize}
335
336{\tt run0} runs a series of simulations that generate the indexed output
337files (e.g. {\tt start1, startfi1, diagfi1}, etc.)
338including files {\tt lrun1, lrun2}, etc. containing the redirection of the
339display and the information about the run.
340
341To carry on simulations after a first series
342(for example, starting from {\tt start5 and  startfi5}), just write the
343index of the initial files (e.g. 5) in the file {\tt num\_run}.
344If {\tt num\_run} exists, the model will start from the index written in
345{\tt num\_run}. If not it will start from, {\tt start0 and startfi0}.
346
347
348{\it NOTE}: A script is available for performing annual runs with 12 seasons
349at 30$^o$ solar longitude
350as it is in the database (script {\bf \tt run\_mcd}, also found in directory
351{\tt deftank}).
352This script functions with script run0. Just set the number of simulations to
3531 in run0. Then copy {\tt run.def} into {\tt run.def.ref} and set nday to 9999 in this
354file. To start from startN.c, edit the file run\_mcd and comment
355(with a \#) the N months already created and describe N in {\tt num\_run}.
356Then run  {\bf \tt run\_mcd}.
357
358Some scripts similar to {\tt run\_mcd}, but including dedicated handling of job schedulers for the Occigen and Ciclad supercomputers can be found in the {\tt ciclad} and {\tt occigen} subdirectories of {\tt deftank}. Check out the {\tt README} files there.
359
360\section{Creating and modifying initial states}
361
362\label{sc:newstart}
363
364\subsection{Using program ``newstart''}
365
366Several model parameters (for example, the dust optical depth) are stored in
367the initial states (NetCDF files {\tt start.nc}
368and {\tt startfi.nc}).
369To change these parameters, or to generally change the model resolution,
370use program {\bf newstart}.
371
372This program is also used to create an initial state.
373In practice, we usually reuse an old initial state, and modify it using
374{\bf newstart}.
375
376Like the GCM, program {\bf newstart} must be
377compiled (using the {\tt makelmdz\_fcm} script)
378at the required grid resolution.
379For example:
380\begin{verbatim}
381makelmdz_fcm -arch local -d 64x48x25 -p mars newstart
382\end{verbatim}
383The resulting executable will be created in the {\tt LMDZ.COMMON/bin} directory, as \verb+newstart_XXX_phymars_seq.e+, where \verb+XXX+ is the dimension (values given to the {\tt -d} argument) for which newstart was compiled.\\
384
385Then run the newstart program in a directory containing the start
386and def file to be used:
387\begin{verbatim}
388newstart.e
389\end{verbatim}
390
391The program then gives you two options:
392\begin{verbatim}
393 From which kind of files do you want to create newstart and startfi files
394     0 - from a file start_archive
395     1 - from files start and startfi
396\end{verbatim}
397
398\begin{itemize}
399\item{-} Option ``1'' allows you to read and modify the information needed
400to create a new initial state  from the files
401\verb+ start.nc, startfi.nc +
402\item{-} Option ``0'' allows you to read and modify the information needed to
403create a new initial state from file
404\verb+ start_archive.nc + (whatever the \verb+ start_archive.nc +
405grid resolution is).\\
406\end{itemize} 
407If you use tracers, make sure that they are taken into account in your
408start files (either start or start\_archive).\\ \\
409Then answer to the various questions in the scroll menu.
410These questions allow you to modify the initial state for the following
411parameters.
412
413\input{input/questions_inistate.tex} 
414
415Program {\bf newstart.e} creates files
416{\tt restart.nc} and {\tt restartfi.nc}
417that you generally need to rename (for instance rename them in start0.nc
418and startfi0.nc if you want to use run0 or run\_mcd, starting with season 0;
419rename them {\tt start.nc} and {\tt startfi.nc} if you just want to perform
420one run with {\tt gcm.e}).
421
422
423\subsection{Creating the initial start\_archive.nc file } 
424
425Archive file
426{\tt start\_archive.nc} is created from files
427{\tt start.nc} and {\tt startfi.nc} by program {\bf start2archive}.
428Program {\bf start2archive} compiles to the same grid resolution as the
429{\tt start.nc} and {\tt startfi.nc} grid resolution. For example:
430
431\begin{verbatim}
432makelmd_fcm -arch local -d 64x48x25 -p mars start2archive
433\end{verbatim}
434Then run \verb+ start2archive.e+ \\ \\
435You now have a \verb+ start_archive.nc+ file for one season that you can
436use with newstart.
437If you want to gather other states obtained at other times of year, rerun
438{\tt start2archive.e} with the {\tt start.nc} and {\tt startfi.nc}
439 corresponding to these.
440These additional initial states will automatically be added to the
441{\tt start\_archive.nc} file present in the directory. 
442
443\subsection{Changing the horizontal or vertical grid resolution}
444
445To run at a different grid resolution than available initial conditions
446files, one needs to use tools {\bf newstart} and {\bf start2archive}
447
448For example, to create initial states at grid resolution
44932$\times$24$\times$25 from NetCDF files
450\verb+ start + and \verb+ startfi + at grid resolution
451  64$\times$48$\times$32 :
452
453\begin{itemize}
454\item Create file \verb+ start_archive.nc +
455with {\bf start2archive.e} compiled at grid resolution
45664$\times$48$\times$25 using {\bf old file {\tt z2sig.def}
457 used previously}
458
459\item Create files
460{\tt newstart.nc} and {\tt newstartfi.nc}
461 with {\bf newstart.e}
462compiled at grid resolution 32$\times$24$\times$25,
463using {\bf new file {\tt z2sig.def}}
464
465\end{itemize} 
466
467If you want to create starts files with tracers for 49 layers using a
468{\tt start\_archive.nc} obtained for 32 layers, do not forget to use the
469\verb+ ini_q+ option in newstart in order to correctly initialize tracers
470value for layer 33 to layer 49.
471You just have to answer yes to the question on thermosphere initialization
472if you want to initialize the thermosphere part only (l=33 to l=49),
473and no if you want to initialize tracers for all layers (l=0 to l=49).\\ \\
474
Note: See TracBrowser for help on using the repository browser.