-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathinstall.sh
executable file
·228 lines (172 loc) · 4.99 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#!/bin/bash
set -e
#####################################################
# User specific defaults
# EMS Version
EMS_VERSION=2.4.5
# Directory where EMS is installed
REP_EMS=$HOME/Tools/EMS/V${EMS_VERSION}
# Directory where MUSC will be run
REP_MUSC=$HOME/MUSC/V${EMS_VERSION}
# Debug mode (0: unactivated, 1: activated)
DEBUG=0
# Testing. So fatr only on CNRM computer
# and for ARPEGE-Climat 6.3.2
TESTS="n"
# Force to remove already installed directories
REMOVE="n"
#####################################################
#####################################################
# Usage
#
bold=$(tput bold)
normal=$(tput sgr0)
unline=$(tput smul)
usage() {
PROGNAME=`basename $0`
cat << USAGE
${bold}NAME${normal}
${PROGNAME} - Installation script for EMS - Environment for MUSC Simulations
${bold}USAGE${normal}
${PROGNAME} [-i <install-directory>] [-r <musc-run-directory>]
[-v <ems-version>] [ -d ] [ -t ] [ -f ] [ -h ]
${bold}DESCRIPTION${normal}
Description of what the EMS install script does
${bold}OPTIONS${normal}
-i ${unline}install-directory${normal}
PATH to where you want to install EMS
REP_EMS [$REP_EMS]
-r ${unline}musc-run-directory${normal}
PATH to where you want to run MUSC
REP_MUSC [$REP_MUSC]
-v ${unline}ems-version${normal}
EMS_VERSION [$EMS_VERSION]
-t Testing! Only on CNRM computer and for ARPEGE-Climat 6.3.2
-d Debug! Add debug information with set -xv
-f Force to remove already installed directories
that is $REP_EMS and $REP_MUSC
-h Help! Print usage information.
USAGE
}
#####################################################
# Some defaults
USAGE=0
#####################################################
while getopts i:r:v:dtfh option
do
case $option in
i)
REP_EMS=$OPTARG
;;
r)
REP_MUSC=$OPTARG
;;
v)
EMS_VERSION=$OPTARG
;;
d)
DEBUG=1
;;
t)
TESTS="y"
;;
f)
REMOVE="y"
;;
h)
USAGE=1
;;
*)
USAGE=1
;;
esac
done
if [ ${USAGE} -eq 1 ]; then
usage
exit 1
fi
if [ ${DEBUG} -eq 1 ]; then
set -vx
fi
DIR0=`pwd`
#####################################################
# Some tests to avoid overwriting
if [ -d "$REP_EMS" ]; then
echo "REP_EMS="$REP_EMS
echo "REP_EMS already exists. Please remove it or modify REP_EMS at the top of install.sh"
echo "You can force removal of REP_EMS using the -f argument"
echo "!!! It may remove REP_MUSC if it exists !!!"
if [ "$REMOVE" == "y" ]; then
/bin/rm -r $REP_EMS
else
exit
fi
fi
if [ -d "$REP_MUSC" ]; then
echo "REP_MUSC="$REP_MUSC
echo "REP_MUSC already exists. Please remove it or modify REP_MUSC at the top of install.sh"
echo "You can force removal of REP_MUSC using the -f argument"
if [ "$REMOVE" == "y" ]; then
/bin/rm -r $REP_MUSC
else
exit
fi
fi
#####################################################
# Download and install EMS in REP_EMS
if [ "${EMS_VERSION}" == 'git' ]; then
git clone https://github.com/romainroehrig/EMS $REP_EMS
else
[ -d $REP_EMS ] || mkdir -p $REP_EMS
cd $REP_EMS
wget https://github.com/romainroehrig/EMS/archive/V${EMS_VERSION}.tar.gz
tar zxvf V${EMS_VERSION}.tar.gz
rm -f V${EMS_VERSION}.tar.gz
mv EMS-${EMS_VERSION}/* .
rm -rf EMS-${EMS_VERSION}
fi
# Some compilation if you want
compile="y"
if [ $compile = "y" ]; then
# lfa python library
cd $REP_EMS/aux/lfa4py
make
fi
#####################################################
# Prepare what is needed to run MUSC simulations in REP_MUSC
[ -d "$REP_MUSC" ] || mkdir -p $REP_MUSC
cd $REP_MUSC
cp -r $REP_EMS/examples/* .
ln -s $REP_EMS/apptools/MUSC.py
for ff in convertLFA2nc.py lfa2nc.py convert2p.py convert2z.py
do
ln -s $REP_EMS/apptools/ems_$ff $REP_MUSC/post/$ff
done
tmp=$(printf '%s' "$REP_EMS" | sed -e 's/[\/&]/\\&/g')
sed -i.bak "s/__REP_EMS__/"$tmp"/" setenv
cd config
for ff in `ls config_*.py`
do
tmp=$(printf '%s' "$REP_MUSC" | sed -e 's/[\/&]/\\&/g')
sed -i.bak "s/__REP_MUSC__/"$tmp"/" $ff
done
cd ..
#####################################################
# Some Testing
testing="$TESTS"
test_arp632="y"
if [ $testing = "y" ]; then
# Testing ARPEGE-Climat 6.3.2
if [ $test_arp632 = "y" ]; then
cd $REP_MUSC
source setenv
MPLBACKEND=Agg ./MUSC.py -config config/config_arp632_CMIP6.py -case ARMCU -subcase REF
[ -f $REP_MUSC/ATM/V632/arp632_CMIP6/ARMCU/REF/initfile_L91 ] || echo "PROBLEM when preparing atmospheric files"
[ -f $REP_MUSC/SURFEX/V632/arp632_CMIP6/ARMCU/REF/PGD.lfi ] || echo "PROBLEM when prepararing PGD"
[ -f $REP_MUSC/SURFEX/V632/arp632_CMIP6/ARMCU/REF/PREP.lfi ] || echo "PROBLEM when preparing PREP"
[ -f $REP_MUSC/simulations/V632/arp632_CMIP6/ARMCU/REF/Output/netcdf/Out_klevel.nc ] || echo "PROBLEM when running MUSC"
fi
fi
#####################################################
# Back in directory where installation was launched
cd $DIR0