| 1 | #!/bin/bash |
|---|
| 2 | |
|---|
| 3 | set -e |
|---|
| 4 | #set -vx |
|---|
| 5 | |
|---|
| 6 | ######################################################################## |
|---|
| 7 | #======================================================================# |
|---|
| 8 | #----------------------------------------------------------------------# |
|---|
| 9 | #| 1. OPTIONS |# |
|---|
| 10 | #======================================================================# |
|---|
| 11 | ######################################################################## |
|---|
| 12 | |
|---|
| 13 | # Special tricks to deactivate the git clone and so when the network |
|---|
| 14 | # is not available. Can be used only after the setup.sh has been run succesfully |
|---|
| 15 | # once |
|---|
| 16 | network=on # on/off |
|---|
| 17 | |
|---|
| 18 | # Old (ExeterUQ) or new (ExeterUQ_MOGP) of Exter UQ programs |
|---|
| 19 | ExeterUQ=ExeterUQ_MOGP |
|---|
| 20 | pip=pip3 # or pip |
|---|
| 21 | python=python3 # or python |
|---|
| 22 | |
|---|
| 23 | if [ $# = 0 ] ; then |
|---|
| 24 | cat <<eod |
|---|
| 25 | Use : setup.sh Model_Name [EXPE_NAME] |
|---|
| 26 | Model_Name name among : |
|---|
| 27 | eod |
|---|
| 28 | ls models | cat |
|---|
| 29 | exit |
|---|
| 30 | fi |
|---|
| 31 | MODEL=$1 |
|---|
| 32 | |
|---|
| 33 | if [ ! -d models/$MODEL ] ; then |
|---|
| 34 | echo models/$MODEL does not exists |
|---|
| 35 | exit |
|---|
| 36 | fi |
|---|
| 37 | |
|---|
| 38 | if [ $# = 1 ] ; then |
|---|
| 39 | EXP=$MODEL |
|---|
| 40 | else |
|---|
| 41 | EXP=$2 |
|---|
| 42 | fi |
|---|
| 43 | |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | ######################################################################## |
|---|
| 47 | #======================================================================# |
|---|
| 48 | #| 2. CHECKING PACKAGES INSTALLATION |# |
|---|
| 49 | #======================================================================# |
|---|
| 50 | ######################################################################## |
|---|
| 51 | |
|---|
| 52 | ############################################ |
|---|
| 53 | # Testing availability of various programs |
|---|
| 54 | ############################################ |
|---|
| 55 | for exe in R Rscript cdo ncks $python $pip ; do |
|---|
| 56 | if [ "`which $exe`" = "" ] ; then echo You need $exe ; exit 1 ; fi |
|---|
| 57 | done |
|---|
| 58 | |
|---|
| 59 | ##################################################### |
|---|
| 60 | # After svn rev 200, python installation is required |
|---|
| 61 | # Except if forcing running an old bench with old=0. |
|---|
| 62 | ##################################################### |
|---|
| 63 | rev=`svn info --show-item revision` |
|---|
| 64 | |
|---|
| 65 | ##################################################### |
|---|
| 66 | # Insure the same version of mogp tools will be used |
|---|
| 67 | # with this version of the HighTune project |
|---|
| 68 | ##################################################### |
|---|
| 69 | # This commit corresponds to the last one on devel |
|---|
| 70 | # Author: Eric Daub <45598892+edaub@users.noreply.github.com> |
|---|
| 71 | # Date: Wed Jun 3 18:18:33 2020 +0100 |
|---|
| 72 | mogp_commit=8dd1b6f76b93c8b96540f240b0dc0d6739892d00 |
|---|
| 73 | |
|---|
| 74 | if [ $network = on ] ; then |
|---|
| 75 | if [ $ExeterUQ = ExeterUQ_MOGP ] ; then |
|---|
| 76 | if [ ! -d mogp_emulator ] ; then |
|---|
| 77 | git clone https://github.com/alan-turing-institute/mogp_emulator |
|---|
| 78 | fi |
|---|
| 79 | cd mogp_emulator |
|---|
| 80 | $pip install --user -r requirements.txt |
|---|
| 81 | $pip install patsy --user |
|---|
| 82 | git checkout $mogp_commit |
|---|
| 83 | $python setup.py install --user |
|---|
| 84 | cd .. |
|---|
| 85 | |
|---|
| 86 | ############################################################ |
|---|
| 87 | # Needed R packages |
|---|
| 88 | # Following R documentations, using ~/.Renviron to specify |
|---|
| 89 | # where the R packages should be installed by a non root user |
|---|
| 90 | ############################################################ |
|---|
| 91 | if [ ! -f ~/.Renviron ] ; then |
|---|
| 92 | rversion=`R --version | head -1 | awk ' { print $3 } '` |
|---|
| 93 | R_LIBS_USER=~/.local/lib/r-HighTune/$rversion |
|---|
| 94 | echo 'R_LIBS_USER='$R_LIBS_USER >> ~/.Renviron |
|---|
| 95 | mkdir -p $R_LIBS_USER |
|---|
| 96 | else |
|---|
| 97 | if [ "`grep R_LIBS_USER ~/.Renviron`" = "" ] ; then |
|---|
| 98 | echo ~/.Renviron exists without R_LIBS_USER, please check ; exit 1 ; fi |
|---|
| 99 | fi |
|---|
| 100 | eval src/CheckInstallPackages.sh reticulate invgamma GenSA far fields lhs maps mco ncdf4 shape tensor withr loo MASS pracma |
|---|
| 101 | if [ "$?" != "0" ] ; then echo Problem encountered when installing R packages ; exit 1 ; fi |
|---|
| 102 | else |
|---|
| 103 | # When using the original version of ExeterUQ, should install rstan |
|---|
| 104 | # Touchy ... |
|---|
| 105 | eval src/CheckInstallPackages.sh reticulate invgamma GenSA far fields lhs maps mco ncdf4 shape tensor withr loo MASS rstan |
|---|
| 106 | if [ "$?" != "0" ] ; then echo Problem encountered when installing R packages ; exit 1 ; fi |
|---|
| 107 | fi # if [ $network = on ] ; then |
|---|
| 108 | fi # if [ $ExeterUQ = ExeterUQ_MOGP ] ; then |
|---|
| 109 | |
|---|
| 110 | ##################################################### |
|---|
| 111 | # Insure the same version of ExeterUQ tools will be used |
|---|
| 112 | # with this version of the HighTune project |
|---|
| 113 | ##################################################### |
|---|
| 114 | # This commit corresponds to the last one on master |
|---|
| 115 | # Merge: 089036e e284f7e |
|---|
| 116 | # Author: vicvolodina93 <52710405+vicvolodina93@users.noreply.github.com> |
|---|
| 117 | # Date: Thu Jun 4 07:59:41 2020 +0100 |
|---|
| 118 | # exeter_commit=9e45cde952d75c10515646f412226f6072606b81 |
|---|
| 119 | exeter_commit=ef50736999f1879f19759ca84655a326e7a6b74d |
|---|
| 120 | |
|---|
| 121 | if [ ! -d $ExeterUQ ] ; then |
|---|
| 122 | git clone https://github.com/BayesExeter/$ExeterUQ |
|---|
| 123 | fi |
|---|
| 124 | cd $ExeterUQ |
|---|
| 125 | if [ $ExeterUQ = ExeterUQ_MOGP ] ; then git checkout $exeter_commit ; fi |
|---|
| 126 | cd .. |
|---|
| 127 | |
|---|
| 128 | ######################################################################## |
|---|
| 129 | #======================================================================# |
|---|
| 130 | # 3. CONFIGURING THE SPECIFIC EXPERIMENT # |
|---|
| 131 | #======================================================================# |
|---|
| 132 | ######################################################################## |
|---|
| 133 | |
|---|
| 134 | ######################################################### |
|---|
| 135 | # Possibility to have a setup_* specific of a given model |
|---|
| 136 | ######################################################### |
|---|
| 137 | if [ -f models/$MODEL/setup_$MODEL.sh ] ; then models/$MODEL/setup_$MODEL.sh ; fi |
|---|
| 138 | |
|---|
| 139 | ###################################################### |
|---|
| 140 | # Download the data relevant to the current experiment |
|---|
| 141 | ###################################################### |
|---|
| 142 | if [ "$MODEL" = "ECRAD" ] ; then |
|---|
| 143 | |
|---|
| 144 | if [ ! -d LES1D_ecRad ] ; then |
|---|
| 145 | wget http://simu:visu2018@www.umr-cnrm.fr/visu-high-tune/data_tuningtool/LES1D_ecRad.tar |
|---|
| 146 | tar xvf LES1D_ecRad.tar |
|---|
| 147 | \rm -rf LES1D_ecRad.tar |
|---|
| 148 | fi |
|---|
| 149 | |
|---|
| 150 | if [ ! -d RAD ] ; then |
|---|
| 151 | wget http://simu:visu2018@www.umr-cnrm.fr/visu-high-tune/data_tuningtool/RAD.tar |
|---|
| 152 | tar xvf RAD.tar |
|---|
| 153 | \rm -rf RAD.tar |
|---|
| 154 | fi |
|---|
| 155 | |
|---|
| 156 | else |
|---|
| 157 | |
|---|
| 158 | if [ ! -d LES ] ; then |
|---|
| 159 | wget http://simu:visu2018@www.umr-cnrm.fr/visu-high-tune/data_tuningtool/les.tar |
|---|
| 160 | tar xvf les.tar |
|---|
| 161 | \rm -rf les.tar |
|---|
| 162 | fi |
|---|
| 163 | |
|---|
| 164 | fi |
|---|
| 165 | |
|---|
| 166 | DIR0=`pwd` |
|---|
| 167 | |
|---|
| 168 | mkdir -p WORK/$EXP |
|---|
| 169 | |
|---|
| 170 | cp src/* WORK/$EXP/ |
|---|
| 171 | cp -r models/$MODEL/* WORK/$EXP/ |
|---|
| 172 | |
|---|
| 173 | cd WORK/$EXP |
|---|
| 174 | if [ "$MODEL" = "ECRAD" ] ; then |
|---|
| 175 | ln -s $DIR0/RAD . |
|---|
| 176 | else |
|---|
| 177 | ln -s $DIR0/LES . |
|---|
| 178 | fi |
|---|
| 179 | ln -s $DIR0/$ExeterUQ/BuildEmulator . |
|---|
| 180 | ln -s $DIR0/$ExeterUQ/HistoryMatching . |
|---|
| 181 | ln -s $DIR0/mogp_emulator . |
|---|
| 182 | |
|---|
| 183 | |
|---|
| 184 | ############################################################## |
|---|
| 185 | # Modules. In preparations for computer centers |
|---|
| 186 | ############################################################## |
|---|
| 187 | |
|---|
| 188 | hostname=`hostname` |
|---|
| 189 | echo lmdz_env $hostname 0:3 ${hostname:0:3} |
|---|
| 190 | |
|---|
| 191 | if [ ${hostname:0:5} = jean- ] ; then |
|---|
| 192 | ( cat <<eod |
|---|
| 193 | module purge |
|---|
| 194 | compilo=19.0.4 # available 2013.0, 2017.2 |
|---|
| 195 | module load intel-compilers/\$compilo |
|---|
| 196 | module load intel-mpi/\$compilo |
|---|
| 197 | module load hdf5/1.10.5/intel-\$compilo-mpi |
|---|
| 198 | module load netcdf/4.7.0/intel-\$compilo-mpi |
|---|
| 199 | module load netcdf-fortran/4.4.5/intel-\$compilo-mpi |
|---|
| 200 | module load subversion/1.9.7/gcc-4.8.5 |
|---|
| 201 | module load intel-mkl/\$compilo |
|---|
| 202 | module load nco |
|---|
| 203 | module load cdo |
|---|
| 204 | module load ferret |
|---|
| 205 | module load r |
|---|
| 206 | module load python/2.7.16 |
|---|
| 207 | login=`whoami` ; groupe=`echo \$login | cut -c2-4` |
|---|
| 208 | # Inputation de la consommation sur le groupe \$groupe |
|---|
| 209 | # Peut se changer a la main : |
|---|
| 210 | # groupe=gzi |
|---|
| 211 | submit="sbatch -A \${groupe}@cpu " |
|---|
| 212 | run="srun --label -n " |
|---|
| 213 | SCRATCHD=\$SCRATCH |
|---|
| 214 | STORED=\$STORE |
|---|
| 215 | LMDZD=\$WORK |
|---|
| 216 | eod |
|---|
| 217 | ) >| env.sh |
|---|
| 218 | |
|---|
| 219 | else |
|---|
| 220 | ( cat <<eod |
|---|
| 221 | echo No special environment needed on this computer |
|---|
| 222 | eod |
|---|
| 223 | ) >| env.sh |
|---|
| 224 | |
|---|
| 225 | fi |
|---|
| 226 | |
|---|
| 227 | chmod +x env.sh |
|---|