source: trunk/MESOSCALE/LMD_MM_MARS/SIMU/notes/makemeso_bak @ 206

Last change on this file since 206 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

  • Property svn:executable set to *
File size: 14.4 KB
Line 
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##############################
14
15#############################
16# Use:   
17#
18# makemeso                   ## basic use (real configuration)
19#
20# makemeso -d                ## no compilation, just check the name of the compile folder
21#
22# makemeso -c real           ## real-case mode [default]
23# makemeso -c convection     ## idealized mode: convective cell
24#
25# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
26# makemeso -r < last         ## basic use + skip questions + only known config
27# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
28#
29# makemeso -j                ## just compile the LMD physics
30#
31# makemeso -g                ## debug mode
32#
33# makemeso -h                ## display options
34#
35#############################
36
37
38# todo: netcdf support
39
40
41##############################################################################################
42##############################################################################################
43##############################################################################################
44##############################################################################################
45
46donotcompile=0
47donotallow=0
48config='real'
49donotcompilephys=0
50justphys=0
51debug=0
52while getopts "drc:njhg" options; do
53  case $options in
54   d ) donotcompile=1;;     ## just to check the compile folder
55   r ) donotallow=1;;       ## allow only known config (useful with 'makemeso < last')
56   c ) config="${OPTARG}";; ## idealized cases
57   n ) donotcompilephys=1;; ## do not recompile physics
58   j ) justphys=1;;         ## just compile LMD physics
59   g ) debug=1;;            ## debug mode
60   h ) echo "
61# Use:   
62#
63# makemeso                   ## basic use (real configuration)
64#
65# makemeso -d                ## no compilation, just check the name of the compile folder
66#
67# makemeso -c real           ## real-case mode [default]
68# makemeso -c convection     ## idealized mode: convective cell
69#
70# makemeso < last            ## basic use + skip questions [! script must have been executed at least once]
71# makemeso -r < last         ## basic use + skip questions + only known config
72# makemeso -nr < last        ## basic use + skip questions + only known config + no LMD phys recompile
73#
74# makemeso -j                ## just compile the LMD physics
75#
76# makemeso -g                ## debug mode
77#
78# makemeso -h                ## display options
79" ; exit ;;
80  esac
81done   
82
83#--------------
84# talk w/ user
85#--------------
86  echo '****************************************'
87  echo 'Welcome.'
88  echo '****************************************'
89  # computer
90  uname -a | grep x86_64 > /dev/null
91  if [[ "$?" == 0 ]]
92  then
93    machine='64'
94  else
95    machine='32'
96  fi
97  # compilator
98  echo '>>>' supported compiler options are 1. pgf90, 2. g95, 3. mpi+pgf90 - your choice ? ; read reply
99  case ${reply} in
100    1) compilo='pgf' ; numproc=1 ;;
101    2) compilo='g95' ; numproc=1 ;;
102    3) compilo='mpi'
103       if [[ "${WHERE_MPI}" = "" ]]
104       then
105         echo Please initialize the variable WHERE_MPI in your environnement
106         exit
107       fi
108       echo '>>>' how many processors ? 1, 2, 4, 6, 8, 12, 16 ; read numproc ;;
109    *) echo not supported by this script ; exit ;;
110  esac
111  # dimensions
112  if [ ${donotcompile} -eq 0 ]
113  then   
114  echo '>>>' grid points in longitude ? ; read lon
115  echo '>>>' grid points in latitude ? ; read lat
116  echo '>>>' number of vertical levels ? ; read level
117  fi
118  echo '>>>' number of domains ? ; read dom
119
120###PB lecture dom si < last
121
122    case ${dom} in
123       1) single='_single' ;;
124       *) single='_nest' ;;
125    esac
126      if [[ "${compilo}" = "mpi" ]]
127      then
128           single=''
129      fi
130      testflag=''
131####
132#testflag='_test'
133####
134    conf_wrf="${compilo}_${machine}${single}${testflag}"
135    \rm what_folder 2> /dev/null
136    echo ${conf_wrf} > what_folder
137         if [ ${donotcompile} -eq 1 ]
138         then
139            #\rm what_folder 2> /dev/null
140            #echo '**********************'
141            #echo '*** Your folder is ...'
142            #echo '**********************'
143            #echo ${conf_wrf} | tee what_folder
144            #cat what_folder
145            #echo ${conf_wrf} > what_folder
146            #echo ${reply} > what_compilo
147            #echo ${numproc} > what_numproc
148            exit
149         fi
150  echo '>>>' number of tracers ? ; read tra
151         if [ ${tra} -eq 0 ]
152         then
153            tra=1       
154         fi
155  # folder
156  mkdir ${conf_wrf} 2> /dev/null
157  if [[ "$?" == 0 ]]
158  then
159    echo new folder ... link sources
160    ./copy_model
161    mv WRFV2 ${conf_wrf}/
162    cd ${conf_wrf}/WRFV2
163    cd Registry ; Registry.bash ; cd ..
164  else
165    cd ${conf_wrf}/WRFV2
166    echo '>>>' did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer
167    case ${answer} in
168      y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;;
169      *) answer='no' ;;
170    esac
171  fi
172  # summary
173  echo '**********************'
174  echo '*** Your folder is ...'
175  echo '**********************'
176  echo ${conf_wrf}
177  echo '**********************'
178  echo '****************************************'
179  echo so ...
180  echo your computer is ${machine} bits
181  echo ${compilo} is your compiler
182       if [[ "${compilo}" = "mpi" ]]
183       then
184         echo MPICH is in ${WHERE_MPI}
185       fi
186  echo you will use ${numproc} processors
187  echo you have ${lon} x points
188  echo '         '${lat} y points
189  echo '         '${level} z points
190  echo '         '${dom} domains
191  echo '         '${tra} tracers
192  echo '****************************************'
193  # save answer
194  \rm last 2> /dev/null
195  touch last
196  echo ${reply} >> last
197     if [[ "${compilo}" = "mpi" ]]
198     then
199     echo ${numproc} >> last
200     fi
201  echo ${lon} >> last
202  echo ${lat} >> last
203  echo ${level} >> last
204  echo ${dom} >> last
205  echo ${tra} >> last
206  echo ${answer} >> last
207
208
209#------------
210# log files
211#------------
212  \rm log_compile 2> /dev/null
213  \rm log_error 2> /dev/null
214
215#-----------------
216# configure WRF
217#-----------------
218  mv configure.wrf configure.wrf.bak 2> /dev/null
219  ########################
220  case ${conf_wrf} in
221                     # PGF90, 32 bits, no nesting
222     pgf_32_single)  echo 1 | configure > log_compile 2> log_error ;;
223                     # PGF90, 32 bits, nesting
224     pgf_32_nest)    echo 2 | configure > log_compile 2> log_error ;;
225                     # PGF90, 64 bits, no nesting
226     pgf_64_single)  echo 1 | configure > log_compile 2> log_error ;;
227                     # PGF90, 64 bits, nesting
228     pgf_64_nest)    cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
229                     echo 4 | configure > log_compile 2> log_error ;;
230                     # G95, 32 bits, no nesting
231     g95_32_single)  echo 13 | configure > log_compile 2> log_error ;;
232                     # MPICH, 64 bits, no nesting / nesting
233     mpi_64)         cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
234                     echo 3 | configure > log_compile 2> log_error
235                     sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
236#| sed s+"fastsse"+"fast"+g > yeah
237                     mv -f yeah configure.wrf ;;
238                     # MPICH, 64 bits, OK with periodic BC but no positive definite
239     mpi_64_test)    cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd ..
240                     echo 2 | configure > log_compile 2> log_error
241                     sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah
242                     mv -f yeah configure.wrf ;;
243                     # ANYTHING ELSE
244     *)              echo NO PRESETS ...
245                     if [ ${donotallow} -eq 0 ] 
246                     then
247                       configure
248                     else
249                       # problem when an input file is used
250                       echo 'please cd to '$PWD' and type ./configure' 
251                       exit     
252                     fi ;;
253  esac
254  ########################
255  sed -f mars.sed configure.wrf > yeah
256  mv -f yeah configure.wrf
257
258  if [ ${debug} -ne 0 ]
259  then
260    echo 'DEBUG DEBUG DEBUG DEBUG'
261    sed s+"#-g"+"-g"+g configure.wrf > yeah
262    mv -f yeah configure.wrf
263  fi
264
265##################################################
266# compile physics
267##################################################
268if [ ${donotcompilephys} -eq 0 ]
269then
270
271  cd mars_lmd/
272
273  # required size
274  #----------------
275  case ${numproc} in
276    1) physx=$(expr ${lon} - 1)
277       physy=$(expr ${lat} - 1)
278       physz=$(expr ${level} - 1) ;;
279    2) physx=$(expr ${lon} - 1)
280       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
281       physz=$(expr ${level} - 1) ;;
282    4) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
283       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2)
284       physz=$(expr ${level} - 1) ;;
285    6) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
286       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 3)
287       physz=$(expr ${level} - 1) ;;
288    8) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2)
289       physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
290       physz=$(expr ${level} - 1) ;;
291    12) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 3)
292        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
293        physz=$(expr ${level} - 1) ;;
294    16) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4)
295        physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4)
296        physz=$(expr ${level} - 1) ;;
297    *) echo not supported ; exit
298  esac
299
300  # change this if you change num_soil_layers in WRF
301  # -- default is 10
302  soilsize=10
303
304  # GCM environment variables
305  #--------------------------
306  export LMDGCM=$PWD
307  export LIBOGCM=$PWD/libo
308
309  # generate the appropriate dimphys
310  #---------------------------------
311  cd libf/phymars
312  \rm dimphys.h 2> /dev/null
313  physize=$(expr ${physx} \* ${physy})
314  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
315  #head -15 dimphys.h
316  cd ../..
317
318  # prepare for nesting
319  #---------------------
320  cd libf
321  duplicate${dom} 2> /dev/null
322  cd ..
323
324  # compile physics
325  #--------------------------
326  \rm libf/grid/dimensions.h 2> /dev/null
327  \rm -rf libo/* 2> /dev/null
328  echo 1. compiling LMD physics ...
329  echo compilation info in:
330  echo $PWD/libo/log_compile_phys
331  if [ ${debug} -ne 0 ]
332  then
333    echo 'DEBUG DEBUG DEBUG DEBUG'
334    nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} meso_testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
335  else
336    nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} meso_testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys
337  fi
338  echo ... done
339        # clean the duplicate routines
340        cd libf
341        duplicate1 2> /dev/null
342        cd ..
343
344  # merge LMD executables in one lib
345  #--------------------------------------
346  cd libo
347  mkdir temp
348  #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp
349  cp -f LINUX*/*.a temp
350  cd temp
351  ar x libbibio.a
352  ar x libphymars.a
353  ar x libaeronomars.a
354  \rm *.a
355  ar r liblmd.a *
356  cp -f liblmd.a ..
357  cd ..
358  \rm -r temp
359  nm liblmd.a > liblmd_content
360  # finish merge
361  cd ..
362
363  # save a copy
364  #--------------
365  cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra}
366  echo '****************************************'
367
368  # ok
369  #----
370  cd ..
371
372  # manage nest includes in module_lmd_driver.F
373  #----
374  cp call_meso_inifis$dom.inc call_meso_inifis.inc
375  cp call_meso_physiq$dom.inc call_meso_physiq.inc
376
377
378fi
379##################################################
380# END compile physics
381##################################################
382
383#------------------
384# compile WRF
385#------------------
386if [ ${justphys} -eq 0 ]
387then
388
389  echo 2. compiling WRF dynamical core ...
390
391  if [[ ! ( -f "call_meso_physiq.inc" ) ]]
392  then
393   echo 'did you compile the physics ? no call_meso_physiq.inc !'
394   exit
395  fi
396
397  # be sure to compile with the most recent physics
398  touch phys/module_lmd_driver.F
399
400  # talk to user
401  echo '>>> YOUR CONFIG IS : '${config}
402  echo '>>> compiling ... this may be long ... <<<'
403  echo check progress in:
404  echo $PWD/log_compile
405  echo check possible errors in:
406  echo $PWD/log_error
407 
408  # compile ...
409  case ${config} in
410    'real')         compile em_real > log_compile 2> log_error
411                    # save executables 
412                    cd main
413                      if [[ -f wrf.exe ]]
414                      then
415                        echo 'Looks good ! wrf.exe is here...'
416                      fi
417                    cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
418                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
419                    cd ..  ;;
420    'convection')   #mkdir 'test/em_quarter_ss' 2> /dev/null
421                    compile em_quarter_ss > log_compile 2> log_error
422                    # save executables 
423                    cd main
424                      if [[ -f wrf.exe ]]
425                      then
426                        echo 'Looks good ! wrf.exe is here...'
427                      fi
428                    cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
429                    cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe
430                    cd ..  ;;
431    *)              echo not supported please use ; echo real convection ; exit ;;
432  esac
433  echo '*******last lines from log_error*********'
434  tail -n 20 log_error
435fi
436
437  # the end
438  echo '****************************************'
439  echo 'done.'
440  echo '****************************************'
441  cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}
442  mv last ../../
443
444  # add here specific messages
445  if [[ "${dom}" != "1" ]]
446  then
447  nest=$(expr ${lon} + 4)
448  echo NB: in namelist.input, please set:
449  echo '
450  max_dom = '$dom'
451  s_we    = 1,1,
452  e_we    = '$lon','$nest',
453  s_sn    = 1,1,
454  e_sn    = '$lat','$nest',
455  s_vert  = 1,1,
456  e_vert  = '$level','$level','
457  fi
458
Note: See TracBrowser for help on using the repository browser.