1 | \chapter{Compiling the model and running a test case}\label{compile} |
---|
2 | |
---|
3 | \vk |
---|
4 | This chapter is also meant for first time users of the LMD Martian Mesoscale Model. We describe how to compile the program and run a test case. We start with important basics about how the model works and how it is organized. |
---|
5 | |
---|
6 | \mk |
---|
7 | \section{Basics} |
---|
8 | |
---|
9 | \sk |
---|
10 | \subsection{Necessary steps to run a simulation}\label{steps} |
---|
11 | |
---|
12 | \sk |
---|
13 | Any simulation that will be carried out with the LMD Martian Mesoscale Model comprises the five following steps. More details are given on the various steps in the following chapters, but it is important at this stage to have this structure in mind. |
---|
14 | |
---|
15 | \sk |
---|
16 | \begin{itemize} |
---|
17 | \item \textbf{Step 0} Compiling the model |
---|
18 | \item \textbf{Step 1} Running the LMD Global Circulation Model (GCM) to provide initial and boundary conditions for the mesoscale model |
---|
19 | \item \textbf{Step 2} Choosing the mesoscale limited-area domain of simulation. Running preprocessing programs to horizontally interpolate GCM meteorological fields and static data (topography, soil properties) to the chosen simulation domain. |
---|
20 | \item \textbf{Step 3} Running preprocessing programs to vertically interpolate GCM meteorological fields and generate the initial and boundary conditions directly used by the mesoscale model |
---|
21 | \item \textbf{Step 4} Running the LMD Martian Mesoscale Model |
---|
22 | \end{itemize} |
---|
23 | |
---|
24 | \sk |
---|
25 | In this chapter, the general method to perform steps 0 and 4 is reviewed. Other steps are reviewed in chapter~\ref{zepreproc}. Here the model will be compiled and run in a test case with precomputed sample files for preprocessing steps 1, 2, 3. |
---|
26 | |
---|
27 | \sk |
---|
28 | \subsection{Structure of the \ttt{LMD\_MM\_MARS} directory} |
---|
29 | |
---|
30 | \sk |
---|
31 | Please take the time to check the contents of the \ttt{LMD\_MM\_MARS} directories\footnote{If you used method~$2$, you will probably notice that other directories than~\ttt{LMD\_MM\_MARS} are present in \ttt{\$MESO}, but those are not important at this stage.} and sub-directories through the following command lines: |
---|
32 | \begin{verbatim} |
---|
33 | ls $MMM ; ls $MMM/* |
---|
34 | \end{verbatim} |
---|
35 | |
---|
36 | \sk |
---|
37 | Contents of~\ttt{LMD\_MM\_MARS} directory: |
---|
38 | \begin{citemize} |
---|
39 | \item \ttt{makemeso}: this is the \ttt{bash} script to compile the model. |
---|
40 | \item \ttt{SRC}: this is a directory containing the model sources. |
---|
41 | \item \ttt{SIMU}: this is a directory containing scripts and files for an advanced use. |
---|
42 | \item \ttt{WPS\_GEOG}: this is a directory containing static data used in step~2. |
---|
43 | \end{citemize} |
---|
44 | |
---|
45 | \sk |
---|
46 | Contents of~\ttt{LMD\_MM\_MARS/SRC} subdirectory: |
---|
47 | \begin{citemize} |
---|
48 | \item \ttt{SCRIPTS}: this is a directory containing useful \ttt{bash} scripts for installation. |
---|
49 | \item \ttt{WRFV2}: this is a directory containing main model sources (modified WRF dynamics + LMD physics in \ttt{mars\_lmd*}). |
---|
50 | \item \ttt{PREP\_MARS}: this is a directory containing sources for the last part of step~1. |
---|
51 | \item \ttt{WPS}: this is a directory containing sources for step~2. |
---|
52 | \item \ttt{POSTPROC}: this is a directory containing postprocessing sources. |
---|
53 | \item \ttt{LES} and \ttt{LESnophys\_}: these are directories containing sources for Large-Eddy Simulations. |
---|
54 | \end{citemize} |
---|
55 | |
---|
56 | \sk |
---|
57 | Contents of~\ttt{LMD\_MM\_MARS/SIMU} subdirectory: |
---|
58 | \begin{citemize} |
---|
59 | \item \ttt{dustopacity.def}, \ttt{namelist.input\_full}, \ttt{namelist.input\_minim}, \ttt{namelist.input\_nests}, \ttt{namelist.input\_les}, \ttt{run.def}, \ttt{namelist.wps}, \ttt{namelist.wps\_les}: these are useful template files to guide you through setting up your own parameters for the LMD Martian Mesoscale Model simulations. |
---|
60 | \item \ttt{calendar}: this is a text file containing time management information in the model. |
---|
61 | \item \ttt{runmeso}: this is a \ttt{bash} script that can be used once the model and preprocessing systems are installed; it prepares and runs a mesoscale simulation by going from step~1 to~4. |
---|
62 | \item \ttt{RUN}: this is a directory containing various files and scripts useful for advanced simulations. |
---|
63 | \item \ttt{DEF}: this is a directory containing many examples of parameter files for simulations. |
---|
64 | \end{citemize} |
---|
65 | |
---|
66 | \sk |
---|
67 | \begin{finger} |
---|
68 | \item In pre-2011 versions of the model, the contents of the various directories listed here might differ. This has probably no impact on your use of the model if you ensure the following files and directories are present in \ttt{LMD\_MM\_MARS}: |
---|
69 | \begin{citemize} |
---|
70 | \item \ttt{makemeso}, \ttt{prepare}, \ttt{prepare\_ini}, \ttt{copy\_model} |
---|
71 | \item \ttt{SRC/WRFV2}, \ttt{SRC/PREP\_MARS}, \ttt{SRC/WPS} |
---|
72 | \item \ttt{SIMU/runmeso}, \ttt{SIMU/calendar} |
---|
73 | \item \ttt{WPS\_GEOG} |
---|
74 | \end{citemize} |
---|
75 | \end{finger} |
---|
76 | |
---|
77 | \mk |
---|
78 | \section{Main compilation step} |
---|
79 | \label{sc:makemeso} |
---|
80 | |
---|
81 | \sk |
---|
82 | \subsection{Description of the \ttt{makemeso} script} |
---|
83 | |
---|
84 | \sk |
---|
85 | The \ttt{bash} script which allows you to compile the LMD Martian Mesoscale Model is \ttt{makemeso}. It is an automated script which performs the following serie of tasks: |
---|
86 | \begin{citemize} |
---|
87 | \item ask the user about compilation settings; |
---|
88 | \item retrieve some additional information about the system; |
---|
89 | \item create a directory \ttt{\$MESO/LMD\_MM\_MARS/your\_compdir} which name depends\footnote{For example, a \ttt{your\_compdir} directory named \ttt{g95\_32\_single} is created if the user requested a \ttt{g95} compilation of the code for single-domain simulations on a 32bits machine.} on the kind of compiler you are using, on whether your system is 32 or 64 bits, on whether sequential or parallel computations are planned and on the kind of simulations (idealized or real-case); |
---|
90 | \item generate with \ttt{copy\_model} a directory \ttt{your\_compdir/WRFV2} containing links to \ttt{SRC/WRFV2} sources\footnote{A note to developers: this method ensures that any change to the model sources would be propagated to all the different \ttt{your\_compdir} installation folders.}; |
---|
91 | \item execute the WRF \ttt{configure} script with the correct option; |
---|
92 | \item tweak the resulting \ttt{configure.wrf} file to include a link towards the Martian physics and various patches and specific compilation options; |
---|
93 | \item calculate the total number of horizontal grid points handled by the LMD physics; |
---|
94 | \item duplicate LMD physical sources if nesting is activated; |
---|
95 | \pagebreak |
---|
96 | \item compile the LMD physical packages with the appropriate \ttt{makegcm} command |
---|
97 | and collect the compiled objects in the library \ttt{liblmd.a}; |
---|
98 | \begin{finger} |
---|
99 | \item This step could be a bit long, especially if you are defining more than one domain. The \ttt{makemeso} script provides you with the full path towards the text file \ttt{log\_compile\_phys} in which you can check for compilation progress and possible errors. In the end of the process, you might find at the end of~\ttt{log\_compile\_phys} an error message associated to the generation of the final executable. Please do not pay attention to this, as the compilation of the LMD sources is meant to generate a library of compiled objects called \ttt{liblmd.a} instead of an executable. |
---|
100 | \end{finger} |
---|
101 | \item compile the modified Martian ARW-WRF solver and include the \ttt{liblmd.a} library; |
---|
102 | \begin{finger} |
---|
103 | \item When it is the first time the model is compiled, this step could be quite long. The \ttt{makemeso} script provides you with a \ttt{log\_compile} text file where the progress of the compilation can be checked and a \ttt{log\_error} text file listing errors and warnings during compilation. A list of warnings related to \ttt{grib} utilities (not used in the Martian model) may appear and have no impact on the final executables. |
---|
104 | \end{finger} |
---|
105 | \item change the name of the executables in agreement with the |
---|
106 | settings provided by the user. |
---|
107 | \end{citemize} |
---|
108 | |
---|
109 | \sk |
---|
110 | \subsection{Use of the \ttt{makemeso} script} |
---|
111 | |
---|
112 | \sk |
---|
113 | To compile the model, change to \ttt{\$MMM} and execute the \ttt{makemeso} command: |
---|
114 | |
---|
115 | \begin{verbatim} |
---|
116 | cd $MMM |
---|
117 | ./makemeso |
---|
118 | \end{verbatim} |
---|
119 | |
---|
120 | \sk |
---|
121 | You are asked a few questions by the \ttt{makemeso} script (see the list below) then it compiles the model for you. The script outputs a text file named \ttt{last} in which your answers to the questions are stored, which allows you to re-run the script without the ``questions to the user" step using the \ttt{makemeso < last} command line. In what follows, the answers given in brackets are the ones you want to use here so that you will be able to run the test case proposed in the next section. |
---|
122 | |
---|
123 | \mk |
---|
124 | \begin{asparaenum}[1.]%[\itshape Q1\upshape)] |
---|
125 | \item \textbf{choice of compiler}\footnote{We advise you to compile the model on the same kind of system (computer + operating system + librairies) as the one you plan to use to run the model.} |
---|
126 | \item[1.bis] (mpi-based compilation) number of processors to be used |
---|
127 | \item \textbf{number of grid points in longitude}\footnote{When you use parallel computations, please bear in mind that with $2$ (respectively $4$, $6$, $8$, $12$, $16$, $20$, $24$, $32$, $64$, $128$) processors the whole domain would be separated into $1$ (resp. $2$, $2$, $2$, $3$, $4$, $4$, $4$, $4$, $8$, $8$) tile over the longitude direction and $2$ (resp. $2$, $3$, $4$, $4$, $4$, $5$, $6$, $8$, $8$, $16$) tiles over the latitude direction. Thus make sure that the number of grid points minus $1$ in each direction could be divided by the aforementioned number of tiles over the considered direction. For instance a~$82 \times 109$ horizontal grid is compliant with the use of~$12$ processors.} [61] |
---|
128 | \item \textbf{number of grid points in latitude} [61] |
---|
129 | \item \textbf{number of vertical levels} [61] |
---|
130 | \item \textbf{number of tracers} [1] |
---|
131 | \item \textbf{number of domains} [1] |
---|
132 | \item[6.bis] (not the first time you use \ttt{makemeso}) a question for advanced users [press any key] |
---|
133 | \item[6.ter] (new LMD physics) number of different scatterers to be used |
---|
134 | \end{asparaenum} |
---|
135 | |
---|
136 | \mk |
---|
137 | An important question that often arises when using the LMD Martian Mesoscale Model is: when does the user have to recompile the model? The set of questions asked by~\ttt{makemeso} give some hints about this. Suppose you compiled a version of the model for a given set of parameters $1$ to $6$ to run a specific compilation. If you would like to run another simulation with at least one of parameters $1$ to $6$ subject to change, the model needs to be recompiled\footnote{This necessary recompilation each time the number of grid points, tracers and domains is modified is imposed by the LMD physics code. The WRF dynamical core alone is much more flexible.} with \ttt{makemeso}. |
---|
138 | |
---|
139 | \mk |
---|
140 | Note that the \ttt{makemeso -h} command lists the various options that can be used in the \ttt{makemeso} script. Most options should be used only by advanced users and some of them will be described in the following chapters. At this stage, the only option of \ttt{makemeso} which can be useful to you is \ttt{-f} which forces the model to be recompiled from scratch. If you already compiled the model succesfully, but the model fails to compile a few days later for reasons unrelated to your operations on your system or on the model file, we recommend you to use the \ttt{-f} option in \ttt{makemeso} to try top recompile the model\footnote{A more extreme solution if \ttt{makemeso -f} does not solve your problem is to remove the corresponding \ttt{your\_compdir} directory.}. |
---|
141 | |
---|
142 | \scriptsize |
---|
143 | \codesource{makemesohelp} |
---|
144 | \normalsize |
---|
145 | |
---|
146 | \mk |
---|
147 | \section{Running a simple test case} |
---|
148 | \label{sc:arsia} |
---|
149 | |
---|
150 | \sk |
---|
151 | We assume here that you had successfully compiled the model with \ttt{makemeso} at the end of the previous section and you had based your answers to the \ttt{makemeso} script on the indications in brackets. You should then find in the \ttt{your\_compdir} directory one \ttt{real\_x61\_y61\_z61\_d1\_t1\_p1.exe} executable and one \ttt{wrf\_x61\_y61\_z61\_d1\_t1\_p1.exe} executable. |
---|
152 | |
---|
153 | \sk |
---|
154 | In order to test the compiled executables, a ready-to-use test case (with pre-generated initial and boundary conditions) is proposed in the \ttt{LMD\_MM\_MARS\_TESTCASE.tar.gz} archive that you can download in the following FTP site \url{ftp://ftp.lmd.jussieu.fr/pub/aslmd/LMD_MM_MARS_TESTCASE.tar.gz}. This test case simulates the hydrostatic atmospheric flow around Arsia Mons (Figure~\ref{arsia}) during half a sol in springtime with constant thermal inertia, albedo and dust opacity\footnote{Though the simulation reproduces some reasonable features of the mesoscale circulation around Arsia Mons (e.g. slope winds), it should not be used for scientific purpose, for the number of grid points is unsufficient for single-domain simulation and the integration time is below the necessary spin-up time.}. |
---|
155 | |
---|
156 | \sk |
---|
157 | To launch the test simulation, please type the following commands, replacing the \ttt{g95\_32\_single} directory with its corresponding value on your system. In the end, the model should run and output the computed meteorological fields in netCDF files named \ttt{wrfout*}. Feel free to browse those files with \ttt{ncview} or your favorite graphical tool to check if the simulated fields looks reasonable. |
---|
158 | % |
---|
159 | \begin{verbatim} |
---|
160 | cp LMD_MM_MARS_TESTCASE.tar.gz $MESO/LMD_MM_MARS/ |
---|
161 | tar xzvf LMD_MM_MARS_TESTCASE.tar.gz |
---|
162 | cd TESTCASE |
---|
163 | ln -sf ../g95_32_single/wrf_x61_y61_z61_d1_t1_p1.exe wrf.exe |
---|
164 | nohup wrf.exe > log_wrf & |
---|
165 | \end{verbatim} |
---|
166 | |
---|
167 | \sk |
---|
168 | The files contained in \ttt{TESTCASE} prior to launching the simulations with the \ttt{wrf.exe} command illustrate which files are needed to perform step 4, i.e. running a LMD Martian Mesoscale Model simulation\footnote{For the test case presented here, a file named \ttt{dustopacity.def} is needed because for the sake of simplicity of this test case, we set idealized uniform dust opacity. The file \ttt{namelist.wps} is included in the \ttt{TESTCASE} folder for further reference but not needed at this stage.}. |
---|
169 | \begin{itemize} |
---|
170 | \item \ttt{namelist.input}: text file containing parameters for the dynamical core |
---|
171 | \item \ttt{callphys.def}: text file containing parameters for the physics parameterizations |
---|
172 | \item \ttt{wrf.exe}: the model executable (or a link to it) as compiled by \ttt{makemeso} |
---|
173 | \item \ttt{wrfinput\_d01} and \ttt{wrfbdy\_d01}: data files containing initial and boundary conditions |
---|
174 | \end{itemize} |
---|
175 | |
---|
176 | \begin{center} |
---|
177 | \begin{figure}[h!] |
---|
178 | \includegraphics[width=0.5\textwidth]{arsiadomain.png} |
---|
179 | \includegraphics[width=0.5\textwidth]{LMD_MMM_d1_20km_HGT_UV_10m-ALS_Ls8_LT1_100.png} |
---|
180 | \caption{\label{arsia} [Left plot] Simulation domain defined in the test case proposed as a demonstrator for running the LMD Martian Mesoscale Model. [Right plot] Nighttime winds predicted by the model~$10$~m above the surface. Both plots have been generated by command-line scripts written in~\ttt{python + numpy + matplotlib} (see chapter~\ref{postproc}).} |
---|
181 | \end{figure} |
---|
182 | \end{center} |
---|
183 | |
---|
184 | \bk |
---|
185 | \scriptsize |
---|
186 | \begin{finger} |
---|
187 | \item If you compiled the model using MPICH2, the command to launch a simulation is slightly different: |
---|
188 | % |
---|
189 | \begin{verbatim} |
---|
190 | [simulation on 4 processors on 1 machine] |
---|
191 | mpd & # first-time only (or after a reboot) |
---|
192 | # NB: may request the creation of a file .mpd.conf |
---|
193 | mpirun -np 4 wrf.exe < /dev/null & # NB: mpirun is only a link to mpiexec |
---|
194 | tail -20 rsl.out.000? # to check the outputs |
---|
195 | \end{verbatim} |
---|
196 | \begin{verbatim} |
---|
197 | [simulation on 16 processors in 4 connected machines] |
---|
198 | echo barry.lmd.jussieu.fr > ~/mpd.hosts |
---|
199 | echo white.lmd.jussieu.fr >> ~/mpd.hosts |
---|
200 | echo loves.lmd.jussieu.fr >> ~/mpd.hosts |
---|
201 | echo tapas.lmd.jussieu.fr >> ~/mpd.hosts |
---|
202 | ssh barry.lmd.jussieu.fr # make sure that ssh to other machines |
---|
203 | # is possible without authentification |
---|
204 | mpdboot -f ~/mpd.hosts -n 4 |
---|
205 | mpdtrace |
---|
206 | mpirun -l -np 16 wrf.exe < /dev/null & # NB: mpirun is only a link to mpiexec |
---|
207 | tail -20 rsl.out.00?? # to check the outputs |
---|
208 | \end{verbatim} |
---|
209 | \end{finger} |
---|
210 | \normalsize |
---|
211 | |
---|
212 | \clearemptydoublepage |
---|