source: setup.sh @ 243

Last change on this file since 243 was 233, checked in by htune, 6 years ago

Detail of the detail
Fredho

File size: 7.6 KB
Line 
1#!/bin/bash
2
3set -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
16network=on # on/off
17
18# Old (ExeterUQ) or new (ExeterUQ_MOGP) of Exter UQ programs
19ExeterUQ=ExeterUQ_MOGP
20pip=pip3 # or pip
21python=python3 # or python
22
23if [ $# = 0 ] ; then
24cat <<eod
25Use : setup.sh Model_Name [EXPE_NAME]
26Model_Name name among :
27eod
28ls  models | cat
29exit
30fi
31MODEL=$1
32
33if [ ! -d models/$MODEL ] ; then
34   echo models/$MODEL does not exists
35   exit
36fi
37
38if [ $# = 1 ] ; then
39   EXP=$MODEL
40else
41   EXP=$2
42fi
43
44
45
46########################################################################
47#======================================================================#
48#|           2. CHECKING PACKAGES INSTALLATION                        |#
49#======================================================================#
50########################################################################
51
52############################################
53# Testing availability of various programs
54############################################
55for exe in R Rscript cdo ncks $python $pip ; do
56    if [ "`which $exe`" = "" ] ; then echo You need $exe ; exit 1 ; fi
57done
58
59#####################################################
60# After svn rev 200, python installation is required
61# Except if forcing running an old bench with old=0.
62#####################################################
63rev=`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
72mogp_commit=8dd1b6f76b93c8b96540f240b0dc0d6739892d00
73
74if [ $network = on ] ; then
75if [ $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
102else
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
107fi # if [ $network = on ] ; then
108fi # 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
119exeter_commit=ef50736999f1879f19759ca84655a326e7a6b74d
120
121if [ ! -d $ExeterUQ ] ; then
122   git clone https://github.com/BayesExeter/$ExeterUQ 
123fi 
124cd $ExeterUQ
125if [ $ExeterUQ = ExeterUQ_MOGP ] ; then git checkout $exeter_commit ; fi
126cd ..
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#########################################################
137if [ -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######################################################
142if [ "$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
156else
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
164fi
165
166DIR0=`pwd`
167
168mkdir -p WORK/$EXP
169
170cp src/* WORK/$EXP/
171cp -r models/$MODEL/* WORK/$EXP/
172
173cd WORK/$EXP
174if [ "$MODEL" = "ECRAD" ] ; then
175  ln -s $DIR0/RAD .
176else
177  ln -s $DIR0/LES .
178fi
179ln -s $DIR0/$ExeterUQ/BuildEmulator .
180ln -s $DIR0/$ExeterUQ/HistoryMatching .
181ln -s $DIR0/mogp_emulator .
182
183
184##############################################################
185# Modules. In preparations for computer centers
186##############################################################
187
188hostname=`hostname`
189echo lmdz_env $hostname 0:3 ${hostname:0:3}
190
191if [ ${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
216eod
217) >| env.sh
218
219else
220          ( cat <<eod
221          echo No special environment needed on this computer
222eod
223) >| env.sh
224
225fi
226
227chmod +x env.sh
Note: See TracBrowser for help on using the repository browser.