1 | #! /bin/bash |
---|
2 | |
---|
3 | |
---|
4 | ################################## |
---|
5 | # makemeso allows you to compile # |
---|
6 | # WRF with modified LMD physics # |
---|
7 | ################################## |
---|
8 | |
---|
9 | ############################## |
---|
10 | # Author: A. Spiga # |
---|
11 | # New version : October 2008 # |
---|
12 | # Last update : January 2009 # |
---|
13 | # November 09 # |
---|
14 | # January 11 # |
---|
15 | ############################## |
---|
16 | |
---|
17 | ############################### |
---|
18 | #### Type makemeso -h for help |
---|
19 | ############################### |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | ############################################################################################## |
---|
24 | ############################################################################################## |
---|
25 | ############################################################################################## |
---|
26 | ############################################################################################## |
---|
27 | |
---|
28 | donotcompile=0 |
---|
29 | donotallow=0 |
---|
30 | config='' |
---|
31 | donotcompilephys=0 |
---|
32 | justphys=0 |
---|
33 | debug=0 |
---|
34 | fresh_start=0 |
---|
35 | phys="" |
---|
36 | scenario="" |
---|
37 | while getopts "drc:njhgpfs:x" options; do |
---|
38 | case $options in |
---|
39 | d ) donotcompile=1;; ## just to check the compile folder |
---|
40 | r ) donotallow=1;; ## allow only known config (useful with 'makemeso < last') |
---|
41 | c ) config="${OPTARG}";; ## idealized cases |
---|
42 | n ) donotcompilephys=1;; ## do not recompile physics |
---|
43 | j ) justphys=1;; ## just compile LMD physics |
---|
44 | g ) debug=1;; ## debug mode |
---|
45 | p ) phys="newphys_";; ## with new physics |
---|
46 | f ) fresh_start=1;; ## a fresh start |
---|
47 | s ) scenario="${OPTARG}";; ## a specific scenario, you need a corresponding "mars_lmd_..." |
---|
48 | x ) donotcompile=1;phys="nophys_";donotcompilephys=1;; ## a case with no LMD physics included |
---|
49 | h ) echo " |
---|
50 | # Use: |
---|
51 | # |
---|
52 | # makemeso ## basic use (real-case configuration) |
---|
53 | # |
---|
54 | # makemeso -d ## no compilation, just check the name of the compile folder |
---|
55 | # |
---|
56 | # makemeso -c ideal ## idealized mode (convective cell, mountain wave, etc...) |
---|
57 | # makemeso -c les ## large-eddy simulations mode based on WRFV3 |
---|
58 | # |
---|
59 | # makemeso -n ## do not recompile LMD physics (must have been compiled before) |
---|
60 | # |
---|
61 | # makemeso < last ## basic use + skip questions [! script must have been executed at least once] |
---|
62 | # makemeso -r < last ## basic use + skip questions + only known config |
---|
63 | # makemeso -nr < last ## basic use + skip questions + only known config + no LMD phys recompile |
---|
64 | # |
---|
65 | # makemeso -j ## just compile the LMD physics |
---|
66 | # |
---|
67 | # makemeso -g ## debug mode |
---|
68 | # |
---|
69 | # makemeso -h ## display options |
---|
70 | # |
---|
71 | # makemeso -p ## with new LMD physics |
---|
72 | # |
---|
73 | # makemeso -f ## fresh start [clean -a] |
---|
74 | # |
---|
75 | # makemeso -s storm ## a specific scenario, you need a corresponding mars_lmd_... (only for newphys) |
---|
76 | # |
---|
77 | # makemeso -x ## a case with no LMD physics included |
---|
78 | " ; exit ;; |
---|
79 | esac |
---|
80 | done |
---|
81 | |
---|
82 | #-------------- |
---|
83 | # talk w/ user |
---|
84 | #-------------- |
---|
85 | echo '****************************************' |
---|
86 | echo ' LMD Mesoscale Model Compiler. Welcome.' |
---|
87 | echo '****************************************' |
---|
88 | if [[ "${phys}" == "newphys_" ]] |
---|
89 | then |
---|
90 | echo '***********with new physics*************' |
---|
91 | echo '****************************************' |
---|
92 | fi |
---|
93 | # computer |
---|
94 | uname -a | grep x86_64 > /dev/null |
---|
95 | if [[ "$?" == 0 ]] |
---|
96 | then |
---|
97 | machine='64' |
---|
98 | else |
---|
99 | machine='32' |
---|
100 | fi |
---|
101 | # compiler |
---|
102 | echo "Supported compiler options are " |
---|
103 | echo " <1> pgf90" |
---|
104 | echo " <2> g95" |
---|
105 | echo " <3> pgf90 + mpi" |
---|
106 | echo " <4> ifort" |
---|
107 | echo " <5> ifort + mpi" |
---|
108 | echo " <7> xlf + mpi (IBM AIX)" |
---|
109 | echo "Your choice ?" ; read reply |
---|
110 | case ${reply} in |
---|
111 | 1) compilo='pgf' ; numproc=1 ;; |
---|
112 | 2) compilo='g95' ; numproc=1 ;; |
---|
113 | 3) compilo='mpi' |
---|
114 | if [[ "${WHERE_MPI}" = "" ]] |
---|
115 | then |
---|
116 | echo Please initialize the variable WHERE_MPI in your environnement |
---|
117 | exit |
---|
118 | fi |
---|
119 | echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;; |
---|
120 | 4) compilo='ifort' ; numproc=1 ;; |
---|
121 | 5) compilo='mpifort' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;; |
---|
122 | 7) compilo='mpixlf' ; echo How many processors ? e.g. 1, 2, 4, 6, 8, 12, 16, 20, 24, 32, 64, 128 ; read numproc ;; |
---|
123 | ### for tests |
---|
124 | 99) compilo='gnu' ; numproc=1 ;; |
---|
125 | *) echo not supported by this script ; exit ;; |
---|
126 | esac |
---|
127 | # dimensions |
---|
128 | if [ ${donotcompile} -eq 0 ] |
---|
129 | then |
---|
130 | echo Grid points in longitude ? ; read lon |
---|
131 | echo Grid points in latitude ? ; read lat |
---|
132 | echo Number of vertical levels ? ; read level |
---|
133 | fi |
---|
134 | echo Number of domains ? ; read dom |
---|
135 | |
---|
136 | ###PB lecture dom si < last |
---|
137 | |
---|
138 | case ${dom} in |
---|
139 | 1) single='_single' ;; |
---|
140 | *) single='_nest' ;; |
---|
141 | esac |
---|
142 | if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ] |
---|
143 | then |
---|
144 | single='' |
---|
145 | fi |
---|
146 | |
---|
147 | testflag='' |
---|
148 | #### |
---|
149 | #testflag='_test' |
---|
150 | #### |
---|
151 | |
---|
152 | conf_wrf="${config}${scenario}${phys}${compilo}_${machine}${single}${testflag}" |
---|
153 | \rm what_folder 2> /dev/null |
---|
154 | echo ${conf_wrf} > what_folder |
---|
155 | if [ ${donotcompile} -eq 1 ] |
---|
156 | then |
---|
157 | #\rm what_folder 2> /dev/null |
---|
158 | #echo '**********************' |
---|
159 | #echo '*** Your folder is ...' |
---|
160 | #echo '**********************' |
---|
161 | #echo ${conf_wrf} | tee what_folder |
---|
162 | #cat what_folder |
---|
163 | #echo ${conf_wrf} > what_folder |
---|
164 | #echo ${reply} > what_compilo |
---|
165 | #echo ${numproc} > what_numproc |
---|
166 | if [[ "${phys}" != "nophys_" ]] |
---|
167 | then |
---|
168 | exit |
---|
169 | fi |
---|
170 | else |
---|
171 | echo Number of tracers ? ; read tra |
---|
172 | if [ ${tra} -eq 0 ] |
---|
173 | then |
---|
174 | tra=1 |
---|
175 | fi |
---|
176 | if [[ "${phys}" == "newphys_" ]] |
---|
177 | then |
---|
178 | echo "How many types of scatterer are you using ? 1 [dust] or 2 [dust + water ice]" ; read scat |
---|
179 | else |
---|
180 | scat=1 ## dummy stuff |
---|
181 | fi |
---|
182 | fi |
---|
183 | # folder |
---|
184 | mkdir ${conf_wrf} 2> /dev/null |
---|
185 | if [[ "$?" == 0 ]] |
---|
186 | then |
---|
187 | echo new folder ... link sources |
---|
188 | if [[ "${phys}" == "newphys_" ]] |
---|
189 | then |
---|
190 | \rm copy_model_tmp > /dev/null |
---|
191 | if [[ "${scenario}" == "" ]] |
---|
192 | then |
---|
193 | sed s+"mars_lmd"+"mars_lmd_new"+g SRC/SCRIPTS/copy_model > copy_model_tmp |
---|
194 | else |
---|
195 | echo SCENARIO ${scenario} DID YOU INCLUDE THE SPECIFIC folder ? ; read dummy |
---|
196 | sed s+"mars_lmd"+"mars_lmd_new_${scenario}"+g SRC/SCRIPTS/copy_model > copy_model_tmp |
---|
197 | if [[ "${config}" == "les" ]] |
---|
198 | then |
---|
199 | echo "NOT SUPPORTED, check options" |
---|
200 | exit |
---|
201 | fi |
---|
202 | fi |
---|
203 | if [[ "${config}" == "les" ]] |
---|
204 | then |
---|
205 | sed s+"PWD/SRC/"+"PWD/SRC/LES/"+g copy_model_tmp > yeah |
---|
206 | mv yeah copy_model_tmp |
---|
207 | fi |
---|
208 | chmod 755 copy_model_tmp |
---|
209 | ./copy_model_tmp |
---|
210 | \rm copy_model_tmp |
---|
211 | mv zeWRFV2 ${conf_wrf}/WRFV2 |
---|
212 | cd ${conf_wrf}/WRFV2 |
---|
213 | if [[ "${scenario}" == "" ]] |
---|
214 | then |
---|
215 | ln -sf mars_lmd_new mars_lmd |
---|
216 | else |
---|
217 | ln -sf mars_lmd_new_${scenario} mars_lmd |
---|
218 | cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/Registry.EM mars_lmd_new_${scenario}/ |
---|
219 | cp ../../SRC/WRFV2/mars_lmd_new_${scenario}/*.inc mars_lmd_new_${scenario}/ |
---|
220 | cd Registry ; ln -sf ../mars_lmd_new_${scenario}/Registry.EM . ; cd .. |
---|
221 | fi |
---|
222 | #ln -sf meso_callkeys_newphys.h meso_callkeys.h |
---|
223 | cd Registry ; Registry.bash ; cd .. |
---|
224 | else |
---|
225 | if [[ "${config}" == "les" ]] |
---|
226 | then |
---|
227 | ### NB: With physics: LES folder // Without physics : LESnophys_ folder |
---|
228 | ### ---- because differences in 'modif' folder ---- |
---|
229 | sed s+"PWD/SRC/"+"PWD/SRC/LES$phys/"+g SRC/SCRIPTS/copy_model > copy_model_tmp |
---|
230 | else |
---|
231 | cp SRC/SCRIPTS/copy_model copy_model_tmp |
---|
232 | fi |
---|
233 | chmod 755 copy_model_tmp |
---|
234 | ./copy_model_tmp |
---|
235 | \rm copy_model_tmp |
---|
236 | mv WRFV2 ${conf_wrf}/ |
---|
237 | cd ${conf_wrf}/WRFV2 |
---|
238 | cd Registry ; Registry.bash ; cd .. |
---|
239 | fi |
---|
240 | #### sparadrap consequent a l'utilisation de copy_model pour les liens |
---|
241 | #### -- car alors il manque fftpack |
---|
242 | if [[ "${config}" == "les" ]] |
---|
243 | then |
---|
244 | if [[ "${phys}" == "nophys_" ]] |
---|
245 | then |
---|
246 | ## voir ci-dessus pour le folder |
---|
247 | cp ../../SRC/LES$phys/correcfft ./ |
---|
248 | else |
---|
249 | cp ../../SRC/LES/correcfft ./ |
---|
250 | fi |
---|
251 | ./correcfft |
---|
252 | \rm correcfft |
---|
253 | fi |
---|
254 | else |
---|
255 | cd ${conf_wrf}/WRFV2 |
---|
256 | if [ ${fresh_start} -eq 1 ] |
---|
257 | then |
---|
258 | echo '*** FRESH START, I clean everything' |
---|
259 | clean -a > /dev/null 2> /dev/null |
---|
260 | cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. |
---|
261 | answer='y' ## a voir... pas si sur |
---|
262 | else |
---|
263 | if [[ "${phys}" != "nophys_" ]] |
---|
264 | then |
---|
265 | echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer |
---|
266 | case ${answer} in |
---|
267 | y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;; |
---|
268 | *) answer='no' ;; |
---|
269 | esac |
---|
270 | fi |
---|
271 | fi |
---|
272 | fi |
---|
273 | |
---|
274 | # summary |
---|
275 | echo '**********************' |
---|
276 | echo '*** Your folder is ...' |
---|
277 | echo '**********************' |
---|
278 | echo ${conf_wrf} |
---|
279 | echo '**********************' |
---|
280 | echo '****************************************' |
---|
281 | echo so ... |
---|
282 | echo your computer is ${machine} bits |
---|
283 | echo ${compilo} is your compiler |
---|
284 | if [[ "${compilo}" = "mpi" ]] |
---|
285 | then |
---|
286 | echo MPICH is in ${WHERE_MPI} |
---|
287 | fi |
---|
288 | echo you will use ${numproc} processors |
---|
289 | echo you have ${lon} x points |
---|
290 | echo ' '${lat} y points |
---|
291 | echo ' '${level} z points |
---|
292 | echo ' '${dom} domains |
---|
293 | echo ' '${tra} tracers |
---|
294 | if [[ "${phys}" == "newphys_" ]] |
---|
295 | then |
---|
296 | echo ' '${scat} scatterers |
---|
297 | fi |
---|
298 | echo '****************************************' |
---|
299 | # save answer |
---|
300 | \rm last 2> /dev/null |
---|
301 | touch last |
---|
302 | echo ${reply} >> last |
---|
303 | if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ] |
---|
304 | then |
---|
305 | echo ${numproc} >> last |
---|
306 | fi |
---|
307 | echo ${lon} >> last |
---|
308 | echo ${lat} >> last |
---|
309 | echo ${level} >> last |
---|
310 | echo ${dom} >> last |
---|
311 | echo ${tra} >> last |
---|
312 | echo ${scat} >> last |
---|
313 | echo ${answer} >> last |
---|
314 | |
---|
315 | #------------ |
---|
316 | # log files |
---|
317 | #------------ |
---|
318 | \rm log_compile 2> /dev/null |
---|
319 | \rm log_error 2> /dev/null |
---|
320 | |
---|
321 | #----------------- |
---|
322 | # configure WRF |
---|
323 | #----------------- |
---|
324 | mv configure.wrf configure.wrf.bak 2> /dev/null |
---|
325 | ######################## |
---|
326 | conf_wrf_forall="${compilo}_${machine}${single}${testflag}" |
---|
327 | |
---|
328 | #### in this case options are different because for LES, WRFV3 is used |
---|
329 | if [[ "${config}" == "les" ]] |
---|
330 | then |
---|
331 | conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}" |
---|
332 | fi |
---|
333 | |
---|
334 | case ${conf_wrf_forall} in |
---|
335 | |
---|
336 | #######LES-specific (WRFV3-based) -- previously in 'makeles' |
---|
337 | ####### |
---|
338 | |
---|
339 | lesmpi_64) ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP] |
---|
340 | \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf |
---|
341 | \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null |
---|
342 | sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
343 | if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]] |
---|
344 | then |
---|
345 | echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS." |
---|
346 | #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
347 | #sed s+"mpicc -cc=$(SCC)"+"/usr/lib64/openmpi/1.4.2-gfortran/bin/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
348 | sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
349 | sed s+"mpicc -cc=\$(SCC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
350 | else |
---|
351 | sed s+"mpif90"+"$WHERE_MPI/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
352 | sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
353 | fi |
---|
354 | sed s+"-fastsse"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
355 | ### pas forcement necessaire ici mais OK |
---|
356 | sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
357 | \rm conf > /dev/null ;; |
---|
358 | |
---|
359 | lesmpifort_64) ## MPI (dm) 64 bits IFORT |
---|
360 | \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf |
---|
361 | \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null |
---|
362 | sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
363 | sed s+"mpif90"+"$WHERE_MPI/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
364 | sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
365 | sed s+"-fastsse"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
366 | sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
367 | \rm conf > /dev/null ;; |
---|
368 | |
---|
369 | ####### |
---|
370 | #######LES-specific (WRFV3-based) -- previously in 'makeles' |
---|
371 | |
---|
372 | #######TEST TEST |
---|
373 | # GFORTRAN, 64 bits, no nesting |
---|
374 | gnu_64_single) cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd .. |
---|
375 | echo 15 | configure > log_compile 2> log_error |
---|
376 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
377 | sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
378 | #######TEST TEST |
---|
379 | # PGF90, 32 bits, no nesting |
---|
380 | pgf_32_single) echo 1 | configure > log_compile 2> log_error |
---|
381 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
382 | # PGF90, 32 bits, nesting |
---|
383 | pgf_32_nest) echo 2 | configure > log_compile 2> log_error |
---|
384 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
385 | # PGF90, 64 bits, no nesting |
---|
386 | pgf_64_single) echo 1 | configure > log_compile 2> log_error |
---|
387 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
388 | # PGF90, 64 bits, nesting |
---|
389 | pgf_64_nest) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
390 | echo 4 | configure > log_compile 2> log_error |
---|
391 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
392 | # G95, 32 bits, no nesting |
---|
393 | g95_32_single) echo 13 | configure > log_compile 2> log_error |
---|
394 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
395 | # G95, 64 bits, no nesting ### we modify configure.defaults to add x86_64 next to g95 in the header comment |
---|
396 | g95_64_single) cd arch ; sed s/"PC Linux i486 i586 i686, g95 compiler"/"PC Linux i486 i586 i686 x86_64, g95 compiler"/g configure.defaults > yeahyeahyeah ; rm configure.defaults ; mv yeahyeahyeah configure.defaults ; cd .. |
---|
397 | echo 14 | configure > log_compile 2> log_error |
---|
398 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
399 | #sed s+"= g95"+"= /home/physastro/aspiga/mysoft/g95/g95-install/bin/x86_64-unknown-linux-gnu-g95"+g configure.wrf > yeah ; mv -f yeah configure.wrf;; |
---|
400 | # IFORT, 64 bits, no nesting |
---|
401 | ifort_64_single) echo 5 | configure > log_compile 2> log_error |
---|
402 | sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
403 | ## !!! NETCDF must be defined |
---|
404 | sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah |
---|
405 | mv -f yeah configure.wrf ;; |
---|
406 | mpifort_64) # MPI+IFORT, 64 bits, no nesting / nesting |
---|
407 | echo 9 | configure > log_compile 2> log_error |
---|
408 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
409 | sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
410 | sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
411 | sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
412 | sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
413 | #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf ### pour compilation rapide |
---|
414 | #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3 |
---|
415 | #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/ |
---|
416 | #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault |
---|
417 | sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
418 | sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
419 | sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
420 | sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
421 | sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
422 | sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
423 | sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
424 | sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
425 | ### necessary even if mpi-selector is used (no need in makegcm though) |
---|
426 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf |
---|
427 | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
428 | ## !!! NETCDF must be defined |
---|
429 | sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah |
---|
430 | mv -f yeah configure.wrf |
---|
431 | #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver] |
---|
432 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah |
---|
433 | mv -f yeah configure.wrf ;; |
---|
434 | # MPICH, 64 bits, no nesting / nesting |
---|
435 | mpi_64) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
436 | echo 3 | configure > log_compile 2> log_error |
---|
437 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
438 | ### the following line is necessary because readtesassim has a line "use netcdf" in it! |
---|
439 | sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
440 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah |
---|
441 | #| sed s+"fastsse"+"fast"+g > yeah |
---|
442 | mv -f yeah configure.wrf ;; |
---|
443 | #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah |
---|
444 | ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem |
---|
445 | ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem |
---|
446 | #mv -f yeah configure.wrf ;; |
---|
447 | # MPICH, 64 bits, OK with periodic BC but no positive definite |
---|
448 | mpi_64_test) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
449 | echo 2 | configure > log_compile 2> log_error |
---|
450 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
451 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah |
---|
452 | mv -f yeah configure.wrf ;; |
---|
453 | # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered |
---|
454 | mpixlf_32) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
455 | echo 3 | configure > log_compile 2> log_error |
---|
456 | sed -f mars.sed configure.wrf > yeah |
---|
457 | mv -f yeah configure.wrf ;; |
---|
458 | # ANYTHING ELSE |
---|
459 | *) echo NO PRESETS ... |
---|
460 | if [ ${donotallow} -eq 0 ] |
---|
461 | then |
---|
462 | configure |
---|
463 | else |
---|
464 | # problem when an input file is used |
---|
465 | echo 'please cd to '$PWD' and type ./configure' |
---|
466 | exit |
---|
467 | fi ;; |
---|
468 | esac |
---|
469 | ######################## |
---|
470 | |
---|
471 | |
---|
472 | ### here a case structure would be great |
---|
473 | |
---|
474 | if [[ "${phys}" == "newphys_" ]] |
---|
475 | then |
---|
476 | if [[ "${config}" == "les" ]] ### LES is different because of WRFV3 |
---|
477 | then |
---|
478 | sed s+"ARCH_LOCAL = "+"ARCH_LOCAL = -DNEWPHYS "+g configure.wrf > yeah |
---|
479 | else |
---|
480 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DNEWPHYS "+g configure.wrf > yeah |
---|
481 | fi |
---|
482 | mv -f yeah configure.wrf |
---|
483 | fi |
---|
484 | |
---|
485 | if [[ ! ("${scenario}" == "") ]] ### not supported with LES for the moment |
---|
486 | then |
---|
487 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -D${scenario} "+g configure.wrf > yeah |
---|
488 | mv -f yeah configure.wrf |
---|
489 | fi |
---|
490 | |
---|
491 | ################ |
---|
492 | if [[ "${phys}" == "nophys_" ]] |
---|
493 | then |
---|
494 | if [[ "${config}" == "les" ]] ### LES is different because of WRFV3 |
---|
495 | then |
---|
496 | sed s+"ARCH_LOCAL = "+"ARCH_LOCAL = -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
497 | sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
498 | else |
---|
499 | ### not tested yet but should be working |
---|
500 | echo CAUTION CAUTION CAUTION NOT FULLY TESTED |
---|
501 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
502 | sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
503 | fi |
---|
504 | fi |
---|
505 | ################ |
---|
506 | |
---|
507 | if [ ${debug} -ne 0 ] # not working for xlf! |
---|
508 | then |
---|
509 | echo 'DEBUG DEBUG DEBUG DEBUG' |
---|
510 | sed s+"#-g"+"-g"+g configure.wrf > yeah |
---|
511 | mv -f yeah configure.wrf |
---|
512 | fi |
---|
513 | |
---|
514 | |
---|
515 | ################################################## |
---|
516 | # compile physics |
---|
517 | ################################################## |
---|
518 | if [ ${donotcompilephys} -eq 0 ] |
---|
519 | then |
---|
520 | |
---|
521 | cd mars_lmd/ |
---|
522 | |
---|
523 | # required size |
---|
524 | #---------------- |
---|
525 | case ${numproc} in |
---|
526 | 1) physx=$(expr ${lon} - 1) |
---|
527 | physy=$(expr ${lat} - 1) |
---|
528 | physz=$(expr ${level} - 1) ;; |
---|
529 | 2) physx=$(expr ${lon} - 1) |
---|
530 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2) |
---|
531 | physz=$(expr ${level} - 1) ;; |
---|
532 | 4) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) |
---|
533 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2) |
---|
534 | physz=$(expr ${level} - 1) ;; |
---|
535 | 6) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) |
---|
536 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 3) |
---|
537 | physz=$(expr ${level} - 1) ;; |
---|
538 | 8) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) |
---|
539 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) |
---|
540 | physz=$(expr ${level} - 1) ;; |
---|
541 | 12) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 3) |
---|
542 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) |
---|
543 | physz=$(expr ${level} - 1) ;; |
---|
544 | 16) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4) |
---|
545 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) |
---|
546 | physz=$(expr ${level} - 1) ;; |
---|
547 | 20) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4) |
---|
548 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 5) |
---|
549 | physz=$(expr ${level} - 1) ;; |
---|
550 | 24) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4) |
---|
551 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 6) |
---|
552 | physz=$(expr ${level} - 1) ;; |
---|
553 | 32) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4) |
---|
554 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8) |
---|
555 | physz=$(expr ${level} - 1) ;; |
---|
556 | 64) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8) |
---|
557 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 8) |
---|
558 | physz=$(expr ${level} - 1) ;; |
---|
559 | 128) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 8) |
---|
560 | physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 16) |
---|
561 | physz=$(expr ${level} - 1) ;; |
---|
562 | *) echo not supported ; exit |
---|
563 | esac |
---|
564 | |
---|
565 | # change this if you change num_soil_layers in WRF |
---|
566 | # -- default is 10 |
---|
567 | if [[ "${phys}" == "newphys_" ]] |
---|
568 | then |
---|
569 | soilsize=18 ## nouvelle physique |
---|
570 | else |
---|
571 | soilsize=10 |
---|
572 | fi |
---|
573 | |
---|
574 | # GCM environment variables |
---|
575 | #-------------------------- |
---|
576 | export LMDGCM=$PWD |
---|
577 | export LIBOGCM=$PWD/libo |
---|
578 | |
---|
579 | # generate the appropriate dimphys |
---|
580 | #--------------------------------- |
---|
581 | cd libf/phymars |
---|
582 | \rm dimphys.h 2> /dev/null |
---|
583 | physize=$(expr ${physx} \* ${physy}) |
---|
584 | sed s/--xsize--/${physx}/g meso_inc/meso_dimphys.h_ref | sed s/--ysize--/${physy}/g | sed s/--physize--/${physize}/g | sed s/--zsize--/${physz}/g | sed s/--soilsize--/${soilsize}/g > dimphys.h |
---|
585 | head -15 dimphys.h |
---|
586 | ### TEST new new phys |
---|
587 | if [[ "${phys}" == "newphys_" ]] |
---|
588 | then |
---|
589 | touch gr_fi_dyn.F.lien |
---|
590 | ln -sf ../dyn3d/gr_fi_dyn.F . ## dommage, a corriger |
---|
591 | ############################### |
---|
592 | \rm scatterers.h |
---|
593 | cat << EOF > scatterers.h |
---|
594 | !----------------------------------------------------------------------- |
---|
595 | ! INCLUDE 'scatterers.h' |
---|
596 | ! |
---|
597 | ! Number of kind of tracer radiative properties |
---|
598 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
599 | ! (ex: naerkind=1 if you use one dust mode without ice ...) |
---|
600 | ! (ex: naerkind=2 if you use one dust mode and active ice ...) |
---|
601 | !----------------------------------------------------------------------- |
---|
602 | |
---|
603 | integer, parameter :: naerkind=${scat} |
---|
604 | |
---|
605 | !----------------------------------------------------------------------- |
---|
606 | EOF |
---|
607 | ############################### |
---|
608 | ############################### |
---|
609 | fi |
---|
610 | ### |
---|
611 | ### |
---|
612 | cd ../.. |
---|
613 | |
---|
614 | # prepare for nesting |
---|
615 | #--------------------- |
---|
616 | cd libf |
---|
617 | duplicate${dom} 2> /dev/null |
---|
618 | cd .. |
---|
619 | |
---|
620 | # compile physics |
---|
621 | #-------------------------- |
---|
622 | \rm libf/grid/dimensions.h 2> /dev/null |
---|
623 | \rm -rf libo/* 2> /dev/null |
---|
624 | echo 1. compiling LMD physics ... |
---|
625 | echo compilation info in: |
---|
626 | echo $PWD/libo/log_compile_phys |
---|
627 | |
---|
628 | if [ ${debug} -ne 0 ] |
---|
629 | then |
---|
630 | echo 'DEBUG DEBUG DEBUG DEBUG' |
---|
631 | nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys |
---|
632 | else |
---|
633 | nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys |
---|
634 | fi |
---|
635 | echo ... done |
---|
636 | # clean the duplicate routines |
---|
637 | cd libf |
---|
638 | duplicate1 2> /dev/null |
---|
639 | cd .. |
---|
640 | |
---|
641 | # merge LMD executables in one lib |
---|
642 | #-------------------------------------- |
---|
643 | cd libo |
---|
644 | mkdir temp |
---|
645 | #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp |
---|
646 | cp -f LINUX*/*.a temp |
---|
647 | cd temp |
---|
648 | ar x libbibio.a |
---|
649 | ar x libphymars.a |
---|
650 | ar x libaeronomars.a |
---|
651 | \rm *.a |
---|
652 | ar r liblmd.a * |
---|
653 | cp -f liblmd.a .. |
---|
654 | cd .. |
---|
655 | \rm -r temp |
---|
656 | nm liblmd.a > liblmd_content |
---|
657 | # finish merge |
---|
658 | cd .. |
---|
659 | |
---|
660 | # save a copy |
---|
661 | #-------------- |
---|
662 | cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}_${scat} |
---|
663 | echo '****************************************' |
---|
664 | |
---|
665 | # ok |
---|
666 | #---- |
---|
667 | cd .. |
---|
668 | |
---|
669 | # manage nest includes in module_lmd_driver.F |
---|
670 | #---- |
---|
671 | cp call_meso_inifis$dom.inc call_meso_inifis.inc |
---|
672 | cp call_meso_physiq$dom.inc call_meso_physiq.inc |
---|
673 | |
---|
674 | |
---|
675 | fi |
---|
676 | ################################################## |
---|
677 | # END compile physics |
---|
678 | ################################################## |
---|
679 | |
---|
680 | #------------------ |
---|
681 | # compile WRF |
---|
682 | #------------------ |
---|
683 | if [ ${justphys} -eq 0 ] |
---|
684 | then |
---|
685 | |
---|
686 | echo 2. compiling WRF dynamical core ... |
---|
687 | |
---|
688 | if [[ "${phys}" == "nophys_" ]] |
---|
689 | then |
---|
690 | echo 'NO LMD PHYSICS included' |
---|
691 | else |
---|
692 | if [[ ! ( -f "call_meso_physiq.inc" ) ]] |
---|
693 | then |
---|
694 | echo 'did you compile the physics ? no call_meso_physiq.inc !' |
---|
695 | exit |
---|
696 | fi |
---|
697 | fi |
---|
698 | |
---|
699 | # be sure to compile with the most recent physics |
---|
700 | touch phys/module_lmd_driver.F |
---|
701 | |
---|
702 | # talk to user |
---|
703 | echo '>>> compiling ... this may be long ... <<<' |
---|
704 | echo check progress in: |
---|
705 | echo $PWD/log_compile |
---|
706 | echo check possible errors in: |
---|
707 | echo $PWD/log_error |
---|
708 | |
---|
709 | # compile ... |
---|
710 | case ${config} in |
---|
711 | '') compile em_real > log_compile 2> log_error |
---|
712 | # save executables |
---|
713 | cd main |
---|
714 | if [[ -f real.exe ]] |
---|
715 | then |
---|
716 | echo 'Looks good ! real.exe is here...' |
---|
717 | fi |
---|
718 | if [[ -f wrf.exe ]] |
---|
719 | then |
---|
720 | echo 'Looks good ! wrf.exe is here...' |
---|
721 | fi |
---|
722 | cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
723 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
724 | cd .. ;; |
---|
725 | 'ideal') #mkdir 'test/em_quarter_ss' 2> /dev/null |
---|
726 | echo '>>> YOUR CONFIG IS : '${config} |
---|
727 | compile em_quarter_ss > log_compile 2> log_error |
---|
728 | # save executables |
---|
729 | cd main |
---|
730 | if [[ -f ideal.exe ]] |
---|
731 | then |
---|
732 | echo 'Looks good ! ideal.exe is here...' |
---|
733 | fi |
---|
734 | if [[ -f wrf.exe ]] |
---|
735 | then |
---|
736 | echo 'Looks good ! wrf.exe is here...' |
---|
737 | fi |
---|
738 | cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
739 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
740 | cd .. ;; |
---|
741 | 'les') echo '>>> YOUR CONFIG IS : '${config} |
---|
742 | mkdir 'test/em_les' 2> /dev/null |
---|
743 | compile em_les > log_compile 2> log_error |
---|
744 | # save executables |
---|
745 | cd main |
---|
746 | if [[ -f ideal.exe ]] |
---|
747 | then |
---|
748 | echo 'Looks good ! ideal.exe is here...' |
---|
749 | fi |
---|
750 | if [[ -f wrf.exe ]] |
---|
751 | then |
---|
752 | echo 'Looks good ! wrf.exe is here...' |
---|
753 | fi |
---|
754 | cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
755 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
756 | cd .. ;; |
---|
757 | *) echo not supported... please use ; echo ideal les ; exit ;; |
---|
758 | esac |
---|
759 | echo '*******last lines from log_error*********' |
---|
760 | tail -n 20 log_error |
---|
761 | fi |
---|
762 | |
---|
763 | # the end |
---|
764 | echo '****************************************' |
---|
765 | echo 'done.' |
---|
766 | echo '****************************************' |
---|
767 | cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat} |
---|
768 | mv last ../../ |
---|
769 | |
---|
770 | # add here specific messages |
---|
771 | if [[ "${dom}" != "1" ]] |
---|
772 | then |
---|
773 | nest=$(expr ${lon} + 4) |
---|
774 | echo NB: in namelist.input, please set: |
---|
775 | echo ' |
---|
776 | max_dom = '$dom' |
---|
777 | s_we = 1,1, |
---|
778 | e_we = '$lon','$nest', |
---|
779 | s_sn = 1,1, |
---|
780 | e_sn = '$lat','$nest', |
---|
781 | s_vert = 1,1, |
---|
782 | e_vert = '$level','$level',' |
---|
783 | fi |
---|
784 | |
---|