#! /bin/bash ################################## # makemeso allows you to compile # # WRF with modified LMD physics # ################################## ############################## # Author: A. Spiga # # New version : October 2008 # # Last update : January 2009 # ############################## ############################# # Use: # # makemeso ## basic use (real configuration) # # makemeso -d ## no compilation, just check the name of the compile folder # # makemeso -c real ## real-case mode [default] # makemeso -c convection ## idealized mode: convective cell # # makemeso < last ## basic use + skip questions [! script must have been executed at least once] # makemeso -r < last ## basic use + skip questions + only known config # makemeso -nr < last ## basic use + skip questions + only known config + no LMD phys recompile # # makemeso -j ## just compile the LMD physics # # makemeso -g ## debug mode # # makemeso -h ## display options # ############################# # todo: netcdf support ############################################################################################## ############################################################################################## ############################################################################################## ############################################################################################## donotcompile=0 donotallow=0 config='real' donotcompilephys=0 justphys=0 debug=0 while getopts "drc:njhg" options; do case $options in d ) donotcompile=1;; ## just to check the compile folder r ) donotallow=1;; ## allow only known config (useful with 'makemeso < last') c ) config="${OPTARG}";; ## idealized cases n ) donotcompilephys=1;; ## do not recompile physics j ) justphys=1;; ## just compile LMD physics g ) debug=1;; ## debug mode h ) echo " # Use: # # makemeso ## basic use (real configuration) # # makemeso -d ## no compilation, just check the name of the compile folder # # makemeso -c real ## real-case mode [default] # makemeso -c convection ## idealized mode: convective cell # # makemeso < last ## basic use + skip questions [! script must have been executed at least once] # makemeso -r < last ## basic use + skip questions + only known config # makemeso -nr < last ## basic use + skip questions + only known config + no LMD phys recompile # # makemeso -j ## just compile the LMD physics # # makemeso -g ## debug mode # # makemeso -h ## display options " ; exit ;; esac done #-------------- # talk w/ user #-------------- echo '****************************************' echo 'Welcome.' echo '****************************************' # computer uname -a | grep x86_64 > /dev/null if [[ "$?" == 0 ]] then machine='64' else machine='32' fi # compilator echo '>>>' supported compiler options are 1. pgf90, 2. g95, 3. mpi+pgf90 - your choice ? ; read reply case ${reply} in 1) compilo='pgf' ; numproc=1 ;; 2) compilo='g95' ; numproc=1 ;; 3) compilo='mpi' if [[ "${WHERE_MPI}" = "" ]] then echo Please initialize the variable WHERE_MPI in your environnement exit fi echo '>>>' how many processors ? 1, 2, 4, 6, 8, 12, 16 ; read numproc ;; *) echo not supported by this script ; exit ;; esac # dimensions if [ ${donotcompile} -eq 0 ] then echo '>>>' grid points in longitude ? ; read lon echo '>>>' grid points in latitude ? ; read lat echo '>>>' number of vertical levels ? ; read level fi echo '>>>' number of domains ? ; read dom ###PB lecture dom si < last case ${dom} in 1) single='_single' ;; *) single='_nest' ;; esac if [[ "${compilo}" = "mpi" ]] then single='' fi testflag='' #### #testflag='_test' #### conf_wrf="${compilo}_${machine}${single}${testflag}" \rm what_folder 2> /dev/null echo ${conf_wrf} > what_folder if [ ${donotcompile} -eq 1 ] then #\rm what_folder 2> /dev/null #echo '**********************' #echo '*** Your folder is ...' #echo '**********************' #echo ${conf_wrf} | tee what_folder #cat what_folder #echo ${conf_wrf} > what_folder #echo ${reply} > what_compilo #echo ${numproc} > what_numproc exit fi echo '>>>' number of tracers ? ; read tra if [ ${tra} -eq 0 ] then tra=1 fi # folder mkdir ${conf_wrf} 2> /dev/null if [[ "$?" == 0 ]] then echo new folder ... link sources ./copy_model mv WRFV2 ${conf_wrf}/ cd ${conf_wrf}/WRFV2 cd Registry ; Registry.bash ; cd .. else cd ${conf_wrf}/WRFV2 echo '>>>' did you modify anything in the Registry or clean ? y for yes, any key for no ; read answer case ${answer} in y) cd Registry ; mv Registry Registry.bak ; Registry.bash ; cd .. ;; *) answer='no' ;; esac fi # summary echo '**********************' echo '*** Your folder is ...' echo '**********************' echo ${conf_wrf} echo '**********************' echo '****************************************' echo so ... echo your computer is ${machine} bits echo ${compilo} is your compiler if [[ "${compilo}" = "mpi" ]] then echo MPICH is in ${WHERE_MPI} fi echo you will use ${numproc} processors echo you have ${lon} x points echo ' '${lat} y points echo ' '${level} z points echo ' '${dom} domains echo ' '${tra} tracers echo '****************************************' # save answer \rm last 2> /dev/null touch last echo ${reply} >> last if [[ "${compilo}" = "mpi" ]] then echo ${numproc} >> last fi echo ${lon} >> last echo ${lat} >> last echo ${level} >> last echo ${dom} >> last echo ${tra} >> last echo ${answer} >> last #------------ # log files #------------ \rm log_compile 2> /dev/null \rm log_error 2> /dev/null #----------------- # configure WRF #----------------- mv configure.wrf configure.wrf.bak 2> /dev/null ######################## case ${conf_wrf} in # PGF90, 32 bits, no nesting pgf_32_single) echo 1 | configure > log_compile 2> log_error ;; # PGF90, 32 bits, nesting pgf_32_nest) echo 2 | configure > log_compile 2> log_error ;; # PGF90, 64 bits, no nesting pgf_64_single) echo 1 | configure > log_compile 2> log_error ;; # PGF90, 64 bits, nesting pgf_64_nest) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. echo 4 | configure > log_compile 2> log_error ;; # G95, 32 bits, no nesting g95_32_single) echo 13 | configure > log_compile 2> log_error ;; # MPICH, 64 bits, no nesting / nesting mpi_64) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. echo 3 | configure > log_compile 2> log_error sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah #| sed s+"fastsse"+"fast"+g > yeah mv -f yeah configure.wrf ;; # MPICH, 64 bits, OK with periodic BC but no positive definite mpi_64_test) cd arch ; ln -sf ../configure.defaults.fix64nest configure.defaults ; cd .. echo 2 | configure > log_compile 2> log_error sed s+"mpif90"+"${WHERE_MPI}/mpif90"+g configure.wrf | sed s+"mpicc"+"${WHERE_MPI}/mpicc"+g | sed s+"mpicc"+"mpicc -DMPI2_SUPPORT"+g > yeah mv -f yeah configure.wrf ;; # ANYTHING ELSE *) echo NO PRESETS ... if [ ${donotallow} -eq 0 ] then configure else # problem when an input file is used echo 'please cd to '$PWD' and type ./configure' exit fi ;; esac ######################## sed -f mars.sed configure.wrf > yeah mv -f yeah configure.wrf if [ ${debug} -ne 0 ] then echo 'DEBUG DEBUG DEBUG DEBUG' sed s+"#-g"+"-g"+g configure.wrf > yeah mv -f yeah configure.wrf fi ################################################## # compile physics ################################################## if [ ${donotcompilephys} -eq 0 ] then cd mars_lmd/ # required size #---------------- case ${numproc} in 1) physx=$(expr ${lon} - 1) physy=$(expr ${lat} - 1) physz=$(expr ${level} - 1) ;; 2) physx=$(expr ${lon} - 1) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2) physz=$(expr ${level} - 1) ;; 4) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 2) physz=$(expr ${level} - 1) ;; 6) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 3) physz=$(expr ${level} - 1) ;; 8) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 2) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) physz=$(expr ${level} - 1) ;; 12) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 3) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) physz=$(expr ${level} - 1) ;; 16) physx=$(expr ${lon} - 1) ; physx=$(expr ${physx} \/ 4) physy=$(expr ${lat} - 1) ; physy=$(expr ${physy} \/ 4) physz=$(expr ${level} - 1) ;; *) echo not supported ; exit esac # change this if you change num_soil_layers in WRF # -- default is 10 soilsize=10 # GCM environment variables #-------------------------- export LMDGCM=$PWD export LIBOGCM=$PWD/libo # generate the appropriate dimphys #--------------------------------- cd libf/phymars \rm dimphys.h 2> /dev/null physize=$(expr ${physx} \* ${physy}) 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 #head -15 dimphys.h cd ../.. # prepare for nesting #--------------------- cd libf duplicate${dom} 2> /dev/null cd .. # compile physics #-------------------------- \rm libf/grid/dimensions.h 2> /dev/null \rm -rf libo/* 2> /dev/null echo 1. compiling LMD physics ... echo compilation info in: echo $PWD/libo/log_compile_phys if [ ${debug} -ne 0 ] then echo 'DEBUG DEBUG DEBUG DEBUG' nohup makegcm_${compilo} -debug -t ${tra} -p mars -d ${physz} meso_testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys else nohup makegcm_${compilo} -t ${tra} -p mars -d ${physz} meso_testphys1d | tee libo/log_compile_phys | grep 'warnings' >> libo/log_compile_phys fi echo ... done # clean the duplicate routines cd libf duplicate1 2> /dev/null cd .. # merge LMD executables in one lib #-------------------------------------- cd libo mkdir temp #cp -f LINUXfastI._${physz}_t${tra}_reg/*.a temp cp -f LINUX*/*.a temp cd temp ar x libbibio.a ar x libphymars.a ar x libaeronomars.a \rm *.a ar r liblmd.a * cp -f liblmd.a .. cd .. \rm -r temp nm liblmd.a > liblmd_content # finish merge cd .. # save a copy #-------------- cp -f libo/liblmd.a libo/liblmd.a_${lon}_${lat}_${level}_${dom}_${tra} echo '****************************************' # ok #---- cd .. # manage nest includes in module_lmd_driver.F #---- cp call_meso_inifis$dom.inc call_meso_inifis.inc cp call_meso_physiq$dom.inc call_meso_physiq.inc fi ################################################## # END compile physics ################################################## #------------------ # compile WRF #------------------ if [ ${justphys} -eq 0 ] then echo 2. compiling WRF dynamical core ... if [[ ! ( -f "call_meso_physiq.inc" ) ]] then echo 'did you compile the physics ? no call_meso_physiq.inc !' exit fi # be sure to compile with the most recent physics touch phys/module_lmd_driver.F # talk to user echo '>>> YOUR CONFIG IS : '${config} echo '>>> compiling ... this may be long ... <<<' echo check progress in: echo $PWD/log_compile echo check possible errors in: echo $PWD/log_error # compile ... case ${config} in 'real') compile em_real > log_compile 2> log_error # save executables cd main if [[ -f wrf.exe ]] then echo 'Looks good ! wrf.exe is here...' fi cp -f real.exe ../../real_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe cd .. ;; 'convection') #mkdir 'test/em_quarter_ss' 2> /dev/null compile em_quarter_ss > log_compile 2> log_error # save executables cd main if [[ -f wrf.exe ]] then echo 'Looks good ! wrf.exe is here...' fi cp -f ideal.exe ../../ideal_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe cp -f wrf.exe ../../wrf_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc}.exe cd .. ;; *) echo not supported please use ; echo real convection ; exit ;; esac echo '*******last lines from log_error*********' tail -n 20 log_error fi # the end echo '****************************************' echo 'done.' echo '****************************************' cp last ../makemeso_x${lon}_y${lat}_z${level}_d${dom}_t${tra}_p${numproc} mv last ../../ # add here specific messages if [[ "${dom}" != "1" ]] then nest=$(expr ${lon} + 4) echo NB: in namelist.input, please set: echo ' max_dom = '$dom' s_we = 1,1, e_we = '$lon','$nest', s_sn = 1,1, e_sn = '$lat','$nest', s_vert = 1,1, e_vert = '$level','$level',' fi