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

Last change on this file since 2236 was 2206, checked in by adelavois, 5 years ago

Mars GCM:
Correction of Mars GCM utility:

Variables declaration changed in order to be compiled with ifort (modification of r2204)

Manual User Update:

Old stuff removed from part4: Running the model

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