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 2> /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 zeWRFV2 ${conf_wrf}/WRFV2 |
---|
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 the whole place |
---|
260 | clean -a > /dev/null 2> /dev/null |
---|
261 | ### get a possibly modified registry ! |
---|
262 | cp ../../SRC/WRFV2/Registry/Registry.EM Registry/ |
---|
263 | ### ensure the model will be recompiled from scratch with correct registry |
---|
264 | cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. |
---|
265 | # answer='y' ## a voir... pas si sur |
---|
266 | # else |
---|
267 | # if [[ "${phys}" != "nophys_" ]] |
---|
268 | # then |
---|
269 | # echo Did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer |
---|
270 | # case ${answer} in |
---|
271 | # y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;; |
---|
272 | # *) answer='no' ;; |
---|
273 | # esac |
---|
274 | # fi |
---|
275 | fi |
---|
276 | fi |
---|
277 | |
---|
278 | # summary |
---|
279 | echo '**********************' |
---|
280 | echo '*** Your folder is ...' |
---|
281 | echo '**********************' |
---|
282 | echo ${conf_wrf} |
---|
283 | echo '**********************' |
---|
284 | echo '****************************************' |
---|
285 | echo so ... |
---|
286 | echo your computer is ${machine} bits |
---|
287 | echo ${compilo} is your compiler |
---|
288 | if [[ "${compilo}" = "mpi" ]] |
---|
289 | then |
---|
290 | echo MPICH is in ${WHERE_MPI} |
---|
291 | fi |
---|
292 | echo you will use ${numproc} processors |
---|
293 | echo you have ${lon} x points |
---|
294 | echo ' '${lat} y points |
---|
295 | echo ' '${level} z points |
---|
296 | echo ' '${dom} domains |
---|
297 | echo ' '${tra} tracers |
---|
298 | if [[ "${phys}" == "newphys_" ]] |
---|
299 | then |
---|
300 | echo ' '${scat} scatterers |
---|
301 | fi |
---|
302 | echo '****************************************' |
---|
303 | # save answer |
---|
304 | \rm last 2> /dev/null |
---|
305 | touch last |
---|
306 | echo ${reply} >> last |
---|
307 | if [ "${compilo}" = "mpi" -o "${compilo}" = "mpifort" -o "${compilo}" = "mpixlf" ] |
---|
308 | then |
---|
309 | echo ${numproc} >> last |
---|
310 | fi |
---|
311 | echo ${lon} >> last |
---|
312 | echo ${lat} >> last |
---|
313 | echo ${level} >> last |
---|
314 | echo ${dom} >> last |
---|
315 | echo ${tra} >> last |
---|
316 | echo ${scat} >> last |
---|
317 | #echo ${answer} >> last |
---|
318 | |
---|
319 | #------------ |
---|
320 | # log files |
---|
321 | #------------ |
---|
322 | \rm log_compile 2> /dev/null |
---|
323 | \rm log_error 2> /dev/null |
---|
324 | |
---|
325 | #----------------- |
---|
326 | # configure WRF |
---|
327 | #----------------- |
---|
328 | mv configure.wrf configure.wrf.bak 2> /dev/null |
---|
329 | ######################## |
---|
330 | conf_wrf_forall="${compilo}_${machine}${single}${testflag}" |
---|
331 | |
---|
332 | #### in this case options are different because for LES, WRFV3 is used |
---|
333 | if [[ "${config}" == "les" ]] |
---|
334 | then |
---|
335 | conf_wrf_forall="${config}${compilo}_${machine}${single}${testflag}" |
---|
336 | fi |
---|
337 | |
---|
338 | case ${conf_wrf_forall} in |
---|
339 | |
---|
340 | #######LES-specific (WRFV3-based) -- previously in 'makeles' |
---|
341 | ####### |
---|
342 | |
---|
343 | lesmpi_64) ## MPI (dm) 64 bits [PS: remplacer 3 par 4 pour openMP] |
---|
344 | \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 3 >> conf ; echo 1 >> conf |
---|
345 | \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null |
---|
346 | sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
347 | if [[ "$(hostname)" == "ciclad1.ipsl.jussieu.fr" ]] |
---|
348 | then |
---|
349 | echo "SPECIFIC CHANGES FOR CICLAD CLUSTER. EDIT makemeso IF YOU ENCOUNTER PROBLEMS." |
---|
350 | #sed s+"mpif90 -f90=$(SFC)"+"/usr/lib64/openmpi/1.4.2-pgf/bin/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
351 | #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 |
---|
352 | sed s+"mpif90 -f90=\$(SFC)"+"/usr/lib64/openmpi/1.4.3-pgfgcc/bin/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
353 | 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 |
---|
354 | else |
---|
355 | sed s+"mpif90"+"$WHERE_MPI/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
356 | sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
357 | fi |
---|
358 | sed s+"-fastsse"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
359 | ### pas forcement necessaire ici mais OK |
---|
360 | sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
361 | \rm conf > /dev/null ;; |
---|
362 | |
---|
363 | lesmpifort_64) ## MPI (dm) 64 bits IFORT |
---|
364 | \rm conf > /dev/null 2> /dev/null ; touch conf ; echo 7 >> conf ; echo 1 >> conf |
---|
365 | \rm configure.wrf > /dev/null 2> /dev/null ; ./configure < conf > /dev/null 2> /dev/null |
---|
366 | sed s+"-lnetcdf"+"-lnetcdf -L../mars_lmd/libo -llmd"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
367 | sed s+"mpif90"+"$WHERE_MPI/mpif90"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
368 | sed s+"mpicc"+"$WHERE_MPI/mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
369 | sed s+"-fastsse"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
370 | sed s+"-llmd"+"-llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
371 | \rm conf > /dev/null ;; |
---|
372 | |
---|
373 | ####### |
---|
374 | #######LES-specific (WRFV3-based) -- previously in 'makeles' |
---|
375 | |
---|
376 | #######TEST TEST |
---|
377 | # GFORTRAN, 64 bits, no nesting |
---|
378 | gnu_64_single) cd arch ; ln -sf ../configure.defaults.gfortran64 configure.defaults ; cd .. |
---|
379 | echo 15 | configure > log_compile 2> log_error |
---|
380 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
381 | 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 ;; |
---|
382 | #######TEST TEST |
---|
383 | # PGF90, 32 bits, no nesting |
---|
384 | pgf_32_single) echo 1 | configure > log_compile 2> log_error |
---|
385 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
386 | # PGF90, 32 bits, nesting |
---|
387 | pgf_32_nest) echo 2 | configure > log_compile 2> log_error |
---|
388 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
389 | # PGF90, 64 bits, no nesting |
---|
390 | pgf_64_single) echo 1 | configure > log_compile 2> log_error |
---|
391 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
392 | # PGF90, 64 bits, nesting |
---|
393 | pgf_64_nest) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
394 | echo 4 | configure > log_compile 2> log_error |
---|
395 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
396 | # G95, 32 bits, no nesting |
---|
397 | g95_32_single) echo 13 | configure > log_compile 2> log_error |
---|
398 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
399 | # G95, 64 bits, no nesting ### we modify configure.defaults to add x86_64 next to g95 in the header comment |
---|
400 | 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 .. |
---|
401 | echo 14 | configure > log_compile 2> log_error |
---|
402 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf ;; |
---|
403 | #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;; |
---|
404 | # IFORT, 64 bits, no nesting |
---|
405 | ifort_64_single) echo 5 | configure > log_compile 2> log_error |
---|
406 | sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
407 | ## !!! NETCDF must be defined |
---|
408 | sed s+"lio_grib_share"+"lio_grib_share -L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah |
---|
409 | mv -f yeah configure.wrf ;; |
---|
410 | mpifort_64) # MPI+IFORT, 64 bits, no nesting / nesting |
---|
411 | echo 9 | configure > log_compile 2> log_error |
---|
412 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
413 | sed s+"-f90=ifort"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
414 | sed s+"-cc=icc"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
415 | sed s+"-DIFORT_KLUDGE"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
416 | sed s+"O3"+"O2"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
417 | #sed s+"O3"+"O0"+g configure.wrf > yeah ; mv -f yeah configure.wrf ### pour compilation rapide |
---|
418 | #-w -ftz -align all -fno-alias -fp-model precise >>> options indiquees dans WRF3 |
---|
419 | #http://software.intel.com/en-us/articles/performance-tools-for-software-developers-building-wrf-with-the-intel-compilers/ |
---|
420 | #### NB: RSL is replaced by RSL_LITE, better memory capacity, less seg fault |
---|
421 | sed s+"../external/RSL/RSL"+"../external/RSL_LITE"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
422 | sed s+"-DWRF_RSL_IO"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
423 | sed s+"-DRSL"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
424 | sed s+"librsl.a"+"librsl_lite.a"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
425 | sed s+"../external/RSL/gen"+"../external/RSL_LITE/gen"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
426 | sed s+"../external/RSL/module"+"../external/RSL_LITE/module"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
427 | sed s+"-lrsl"+"-lrsl_lite"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
428 | sed s+"linux"+" "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
429 | ### necessary even if mpi-selector is used (no need in makegcm though) |
---|
430 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g > yeah ; mv -f yeah configure.wrf |
---|
431 | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
432 | ## !!! NETCDF must be defined |
---|
433 | sed s+"-L../mars_lmd/libo -llmd"+"-L../mars_lmd/libo -llmd $NETCDF/lib/libnetcdf.a"+g configure.wrf > yeah |
---|
434 | mv -f yeah configure.wrf |
---|
435 | #### POUR LE TRAITEMENT PARTICULIERS des NESTS sur iDATAPLEX [cf. module_lmd_driver] |
---|
436 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DSPECIAL_NEST_SAVE "+g configure.wrf > yeah |
---|
437 | mv -f yeah configure.wrf ;; |
---|
438 | # MPICH, 64 bits, no nesting / nesting |
---|
439 | mpi_64) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
440 | echo 3 | configure > log_compile 2> log_error |
---|
441 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
442 | ### the following line is necessary because readtesassim has a line "use netcdf" in it! |
---|
443 | 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 |
---|
444 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah |
---|
445 | #| sed s+"fastsse"+"fast"+g > yeah |
---|
446 | mv -f yeah configure.wrf ;; |
---|
447 | #sed s+"-fastsse"+"-O2 -Munroll -Mcache_align"+g configure.wrf > yeah |
---|
448 | ##sed s+"-fastsse"+"-O2 -fpic"+g configure.wrf > yeah ## marche pas, ILM problem |
---|
449 | ##sed s+"-fastsse"+"-mcmodel=medium -Mlarge_arrays"+g configure.wrf > yeah ## marche pas, ILM problem |
---|
450 | #mv -f yeah configure.wrf ;; |
---|
451 | # MPICH, 64 bits, OK with periodic BC but no positive definite |
---|
452 | mpi_64_test) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
453 | echo 2 | configure > log_compile 2> log_error |
---|
454 | sed -f mars.sed configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
455 | sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah |
---|
456 | mv -f yeah configure.wrf ;; |
---|
457 | # XLF+MPICH on AIX machine (64 bits) with nesting, NB: the 32bits notice is not to be considered |
---|
458 | mpixlf_32) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. |
---|
459 | echo 3 | configure > log_compile 2> log_error |
---|
460 | sed -f mars.sed configure.wrf > yeah |
---|
461 | mv -f yeah configure.wrf ;; |
---|
462 | # ANYTHING ELSE |
---|
463 | *) echo NO PRESETS ... |
---|
464 | if [ ${donotallow} -eq 0 ] |
---|
465 | then |
---|
466 | configure |
---|
467 | else |
---|
468 | # problem when an input file is used |
---|
469 | echo 'please cd to '$PWD' and type ./configure' |
---|
470 | exit |
---|
471 | fi ;; |
---|
472 | esac |
---|
473 | ######################## |
---|
474 | |
---|
475 | |
---|
476 | ### here a case structure would be great |
---|
477 | |
---|
478 | if [[ "${phys}" == "newphys_" ]] |
---|
479 | then |
---|
480 | if [[ "${config}" == "les" ]] ### LES is different because of WRFV3 |
---|
481 | then |
---|
482 | sed s+"ARCH_LOCAL = "+"ARCH_LOCAL = -DNEWPHYS "+g configure.wrf > yeah |
---|
483 | else |
---|
484 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DNEWPHYS "+g configure.wrf > yeah |
---|
485 | fi |
---|
486 | mv -f yeah configure.wrf |
---|
487 | fi |
---|
488 | |
---|
489 | if [[ ! ("${scenario}" == "") ]] ### not supported with LES for the moment |
---|
490 | then |
---|
491 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -D${scenario} "+g configure.wrf > yeah |
---|
492 | mv -f yeah configure.wrf |
---|
493 | fi |
---|
494 | |
---|
495 | ################ |
---|
496 | if [[ "${phys}" == "nophys_" ]] |
---|
497 | then |
---|
498 | if [[ "${config}" == "les" ]] ### LES is different because of WRFV3 |
---|
499 | then |
---|
500 | sed s+"ARCH_LOCAL = "+"ARCH_LOCAL = -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
501 | sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
502 | else |
---|
503 | ### not tested yet but should be working |
---|
504 | echo CAUTION CAUTION CAUTION NOT FULLY TESTED |
---|
505 | sed s+"ARCHFLAGS = "+"ARCHFLAGS = -DNOPHYS "+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
506 | sed s+"-L../mars_lmd/libo -llmd"+""+g configure.wrf > yeah ; mv -f yeah configure.wrf |
---|
507 | fi |
---|
508 | fi |
---|
509 | ################ |
---|
510 | |
---|
511 | if [ ${debug} -ne 0 ] # not working for xlf! |
---|
512 | then |
---|
513 | echo 'DEBUG DEBUG DEBUG DEBUG' |
---|
514 | sed s+"#-g"+"-g"+g configure.wrf > yeah |
---|
515 | mv -f yeah configure.wrf |
---|
516 | fi |
---|
517 | |
---|
518 | |
---|
519 | ################################################## |
---|
520 | # compile physics |
---|
521 | ################################################## |
---|
522 | if [ ${donotcompilephys} -eq 0 ] |
---|
523 | then |
---|
524 | |
---|
525 | cd mars_lmd/ |
---|
526 | |
---|
527 | # required size |
---|
528 | #---------------- |
---|
529 | case ${numproc} in |
---|
530 | 1) divx=1 ; divy=1 ;; |
---|
531 | 2) divx=1 ; divy=2 ;; |
---|
532 | 4) divx=2 ; divy=2 ;; |
---|
533 | 6) divx=2 ; divy=3 ;; |
---|
534 | 8) divx=2 ; divy=4 ;; |
---|
535 | 12) divx=3 ; divy=4 ;; |
---|
536 | 16) divx=4 ; divy=4 ;; |
---|
537 | 20) divx=4 ; divy=5 ;; |
---|
538 | 24) divx=4 ; divy=6 ;; |
---|
539 | 32) divx=4 ; divy=8 ;; |
---|
540 | 64) divx=8 ; divy=8 ;; |
---|
541 | 128) divx=8 ; divy=16 ;; |
---|
542 | *) echo not yet supported ; exit ;; |
---|
543 | esac |
---|
544 | physx=$(expr ${lon} - 1) |
---|
545 | restex=$(expr ${physx} \% ${divx}) |
---|
546 | physy=$(expr ${lat} - 1) |
---|
547 | restey=$(expr ${physy} \% ${divy}) |
---|
548 | if [[ ${restex} != 0 || ${restey} != 0 ]] |
---|
549 | then |
---|
550 | echo nx-1 shall be divided by ${divx} |
---|
551 | echo ny-1 shall be divided by ${divy} |
---|
552 | exit |
---|
553 | fi |
---|
554 | physx=$(expr ${physx} \/ ${divx}) |
---|
555 | physy=$(expr ${physy} \/ ${divy}) |
---|
556 | physz=$(expr ${level} - 1) |
---|
557 | |
---|
558 | # change this if you change num_soil_layers in WRF |
---|
559 | # -- default is 10 |
---|
560 | if [[ "${phys}" == "newphys_" ]] |
---|
561 | then |
---|
562 | soilsize=18 ## nouvelle physique |
---|
563 | else |
---|
564 | soilsize=10 |
---|
565 | fi |
---|
566 | |
---|
567 | # GCM environment variables |
---|
568 | #-------------------------- |
---|
569 | export LMDGCM=$PWD |
---|
570 | export LIBOGCM=$PWD/libo |
---|
571 | |
---|
572 | # generate the appropriate dimphys |
---|
573 | #--------------------------------- |
---|
574 | cd libf/phymars |
---|
575 | \rm dimphys.h 2> /dev/null |
---|
576 | if [[ "${phys}" == "newphys_" ]] |
---|
577 | then |
---|
578 | ln -sf meso_inc/meso_dimphys.h_ref . |
---|
579 | fi |
---|
580 | physize=$(expr ${physx} \* ${physy}) |
---|
581 | sed s/--xsize--/${physx}/g 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 |
---|
582 | head -15 dimphys.h |
---|
583 | ### TEST new new phys |
---|
584 | if [[ "${phys}" == "newphys_" ]] |
---|
585 | then |
---|
586 | touch gr_fi_dyn.F.lien |
---|
587 | ln -sf ../dyn3d/gr_fi_dyn.F . ## dommage, a corriger |
---|
588 | ############################### |
---|
589 | \rm scatterers.h |
---|
590 | cat << EOF > scatterers.h |
---|
591 | !----------------------------------------------------------------------- |
---|
592 | ! INCLUDE 'scatterers.h' |
---|
593 | ! |
---|
594 | ! Number of kind of tracer radiative properties |
---|
595 | ! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
596 | ! (ex: naerkind=1 if you use one dust mode without ice ...) |
---|
597 | ! (ex: naerkind=2 if you use one dust mode and active ice ...) |
---|
598 | !----------------------------------------------------------------------- |
---|
599 | |
---|
600 | integer, parameter :: naerkind=${scat} |
---|
601 | |
---|
602 | !----------------------------------------------------------------------- |
---|
603 | EOF |
---|
604 | ############################### |
---|
605 | ############################### |
---|
606 | fi |
---|
607 | ### |
---|
608 | ### |
---|
609 | cd ../.. |
---|
610 | |
---|
611 | # prepare for nesting |
---|
612 | #--------------------- |
---|
613 | cd libf |
---|
614 | duplicate${dom} 2> /dev/null |
---|
615 | cd .. |
---|
616 | |
---|
617 | # compile physics |
---|
618 | #-------------------------- |
---|
619 | \rm libf/grid/dimensions.h 2> /dev/null |
---|
620 | \rm -rf libo/* 2> /dev/null |
---|
621 | echo 1. compiling LMD physics ... |
---|
622 | echo compilation info in: |
---|
623 | echo $PWD/libo/log_compile_phys |
---|
624 | |
---|
625 | if [ ${debug} -ne 0 ] |
---|
626 | then |
---|
627 | echo 'DEBUG DEBUG DEBUG DEBUG' |
---|
628 | nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys |
---|
629 | else |
---|
630 | nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys |
---|
631 | fi |
---|
632 | echo ... done |
---|
633 | # clean the duplicate routines |
---|
634 | cd libf |
---|
635 | duplicate1 2> /dev/null |
---|
636 | cd .. |
---|
637 | |
---|
638 | # merge LMD executables in one lib |
---|
639 | #-------------------------------------- |
---|
640 | cd libo |
---|
641 | mkdir temp |
---|
642 | #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp |
---|
643 | cp -f LINUX*/*.a temp |
---|
644 | cd temp |
---|
645 | ar x libbibio.a |
---|
646 | ar x libphymars.a |
---|
647 | ar x libaeronomars.a |
---|
648 | \rm *.a |
---|
649 | ar r liblmd.a * |
---|
650 | cp -f liblmd.a .. |
---|
651 | cd .. |
---|
652 | \rm -r temp |
---|
653 | nm liblmd.a > liblmd_content |
---|
654 | # finish merge |
---|
655 | cd .. |
---|
656 | |
---|
657 | # save a copy |
---|
658 | #-------------- |
---|
659 | cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}_${scat} |
---|
660 | echo '****************************************' |
---|
661 | |
---|
662 | # ok |
---|
663 | #---- |
---|
664 | cd .. |
---|
665 | |
---|
666 | # manage nest includes in module_lmd_driver.F |
---|
667 | #---- |
---|
668 | cp call_meso_inifis$dom.inc call_meso_inifis.inc |
---|
669 | cp call_meso_physiq$dom.inc call_meso_physiq.inc |
---|
670 | |
---|
671 | |
---|
672 | fi |
---|
673 | ################################################## |
---|
674 | # END compile physics |
---|
675 | ################################################## |
---|
676 | |
---|
677 | #------------------ |
---|
678 | # compile WRF |
---|
679 | #------------------ |
---|
680 | if [ ${justphys} -eq 0 ] |
---|
681 | then |
---|
682 | |
---|
683 | echo 2. compiling WRF dynamical core ... |
---|
684 | |
---|
685 | if [[ "${phys}" == "nophys_" ]] |
---|
686 | then |
---|
687 | echo 'NO LMD PHYSICS included' |
---|
688 | else |
---|
689 | if [[ ! ( -f "call_meso_physiq.inc" ) ]] |
---|
690 | then |
---|
691 | echo 'did you compile the physics ? no call_meso_physiq.inc !' |
---|
692 | exit |
---|
693 | fi |
---|
694 | fi |
---|
695 | |
---|
696 | # be sure to compile with the most recent physics |
---|
697 | touch phys/module_lmd_driver.F |
---|
698 | |
---|
699 | # talk to user |
---|
700 | echo '>>> compiling ... this may be long ... <<<' |
---|
701 | echo check progress in: |
---|
702 | echo $PWD/log_compile |
---|
703 | echo check possible errors in: |
---|
704 | echo $PWD/log_error |
---|
705 | |
---|
706 | # compile ... |
---|
707 | case ${config} in |
---|
708 | '') compile em_real > log_compile 2> log_error |
---|
709 | # save executables |
---|
710 | cd main |
---|
711 | if [[ -f real.exe ]] |
---|
712 | then |
---|
713 | echo 'Looks good ! real.exe is here...' |
---|
714 | fi |
---|
715 | if [[ -f wrf.exe ]] |
---|
716 | then |
---|
717 | echo 'Looks good ! wrf.exe is here...' |
---|
718 | fi |
---|
719 | cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
720 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
721 | cd .. ;; |
---|
722 | 'ideal') #mkdir 'test/em_quarter_ss' 2> /dev/null |
---|
723 | echo '>>> YOUR CONFIG IS : '${config} |
---|
724 | compile em_quarter_ss > log_compile 2> log_error |
---|
725 | # save executables |
---|
726 | cd main |
---|
727 | if [[ -f ideal.exe ]] |
---|
728 | then |
---|
729 | echo 'Looks good ! ideal.exe is here...' |
---|
730 | fi |
---|
731 | if [[ -f wrf.exe ]] |
---|
732 | then |
---|
733 | echo 'Looks good ! wrf.exe is here...' |
---|
734 | fi |
---|
735 | cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
736 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
737 | cd .. ;; |
---|
738 | 'les') echo '>>> YOUR CONFIG IS : '${config} |
---|
739 | mkdir 'test/em_les' 2> /dev/null |
---|
740 | compile em_les > log_compile 2> log_error |
---|
741 | # save executables |
---|
742 | cd main |
---|
743 | if [[ -f ideal.exe ]] |
---|
744 | then |
---|
745 | echo 'Looks good ! ideal.exe is here...' |
---|
746 | fi |
---|
747 | if [[ -f wrf.exe ]] |
---|
748 | then |
---|
749 | echo 'Looks good ! wrf.exe is here...' |
---|
750 | fi |
---|
751 | cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
752 | cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat}.exe |
---|
753 | cd .. ;; |
---|
754 | *) echo not supported... please use ; echo ideal les ; exit ;; |
---|
755 | esac |
---|
756 | echo '*******last lines from log_error*********' |
---|
757 | tail -n 20 log_error |
---|
758 | fi |
---|
759 | |
---|
760 | # the end |
---|
761 | echo '****************************************' |
---|
762 | echo 'done.' |
---|
763 | echo '****************************************' |
---|
764 | cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}_s${scat} |
---|
765 | mv last ../../ |
---|
766 | |
---|
767 | # add here specific messages |
---|
768 | if [[ "${dom}" != "1" ]] |
---|
769 | then |
---|
770 | nest=$(expr ${lon} + 4) |
---|
771 | echo NB: in namelist.input, please set: |
---|
772 | echo ' |
---|
773 | max_dom = '$dom' |
---|
774 | s_we = 1,1, |
---|
775 | e_we = '$lon','$nest', |
---|
776 | s_sn = 1,1, |
---|
777 | e_sn = '$lat','$nest', |
---|
778 | s_vert = 1,1, |
---|
779 | e_vert = '$level','$level',' |
---|
780 | fi |
---|
781 | |
---|