Newer
Older
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
#!/bin/bash
#set -x
set -e
# Repertoire où Mesonh MNH-V5-5-0 officiel est installe
#REFDIR=$HOME
# Repertoire où MNH-V5-5-0_PHYEX.tar.gz modifie pour accueillir PHYEX se trouve
#TARGZDIR=$HOME
MNHPACK=${MNHPACK:=$HOME/MesoNH/PHYEX}
PHYEXTOOLSDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
function usage {
echo "Usage: $0 [-h] [-c] [-r] [-C] commit reference"
echo "commit commit hash"
echo "reference commit hash or nothing for ref"
echo "-s suppress compilation pack"
echo "-c performs compilation"
echo "-r runs the tests, if option appears twice, run is also executed on only 2 procs (instead of 4 procs)"
echo "-C checks the result against the reference"
echo ""
echo "If nothing is asked (compilation, running, check) everything is done"
}
compilation=0
run=0
check=0
commit=""
reference=""
suppress=0
while [ -n "$1" ]; do
case "$1" in
'-h') usage;;
'-s') suppress=1;;
'-c') compilation=1;;
'-r') run=$(($run+1));;
'-C') check=1;;
#-b) param="$2"; shift ;;
#--) shift; break ;;
*) if [ -z "${commit-}" ]; then
commit=$1
else
if [ -z "${reference-}" ]; then
reference=$1
else
echo "Only two commit hash allowed on command line"
exit 1
fi
fi;;
esac
shift
done
if [ $compilation -eq 0 -a \
$run -eq 0 -a \
$check -eq 0 ]; then
compilation=1
run=1
check=1
fi
if [ -z "${commit-}" ]; then
echo "At least one commit hash must be provided on command line"
exit 2
fi
#if [ $check -eq 1 -a -z "${reference-}" ]; then
# echo "To perform a comparison two commit hashes are mandatory on the command line"
# exit 3
#fi
fromdir=$commit
if echo $commit | grep '/' > /dev/null; then
name=MNH-V5-5-0-$(echo $commit | sed 's/\//_/g')
[ $suppress -eq 1 -a -d $MNHPACK/$name ] && rm -rf $MNHPACK/$name
else
name=MNH-V5-5-0-$commit
[ $suppress -eq 1 -a -d $MNHPACK/$name ] && rm -rf $MNHPACK/$name
fi
if [ $compilation -eq 1 ]; then
echo "### Compilation of commit $commit"
if [ -d $MNHPACK/$name ]; then
echo "Pack already exists ($MNHPACK/$name), suppress it to be able to compile it again (or use the -s option to automatically suppress it)"
exit 5
fi
# Prepare the pack
cd $MNHPACK
cp $TARGZDIR/MNH-V5-5-0_PHYEX.tar.gz .
tar xvfz MNH-V5-5-0_PHYEX.tar.gz
rm MNH-V5-5-0_PHYEX.tar.gz
mv MNH-V5-5-0 $name
cd $name/src
cd $MNHPACK
echo "Clone repository, and checkout commit $commit"
git clone https://github.com/QuentinRodier/PHYEX.git
cd PHYEX
git checkout $commit
cd src/common/turb
# Rename all *.F90 to *.f90
for rep in turb micro aux; do
cd ../$rep
for f in *.F90; do
mv -- "$f" "${f%.F90}.f90"
done
done
cd ../../../
for rep in turb micro conv ext aux; do
[ ! -d ../$rep ] && mkdir ../$rep
[ -d src/common/$rep ] && mv -f src/common/$rep/* ../$rep/
[ -d src/mesonh/$rep ] && mv -f src/mesonh/$rep/* ../$rep/
touch ../$rep/*
done
cd ..
# Move PHYEX files inside MNH/src/PHYEX
for rep in turb micro conv aux; do
mv $rep/* $name/src/PHYEX/$rep/.
rmdir $rep
done
# Move manually ext/ files in src/MNH
mv -f ext/* $name/src/MNH/.
# Clean folder
rmdir ext
rm -Rf PHYEX
cd $name/src/PHYEX/turb
# Delete files of MNH-V5-5-0/src/MNH and MNH/src/LIB/SURCOUCHE/src with same name
for rep in turb micro conv aux ; do
cd ../$rep
for f in *.f90; do
echo $f
rm -f ../../MNH/$f
rm -f ../../LIB/SURCOUCHE/src/$f
done
done
cd ..
# Delete old files of MNH-V5-5-0/src/MNH that is now called by mode_... NO /aux NEEDED!
find turb micro conv -name 'mode_*' > remove_non_mode.sh
sed -i 's/turb\/mode_/rm -f MNH\//g' remove_non_mode.sh
sed -i 's/micro\/mode_/rm -f MNH\//g' remove_non_mode.sh
sed -i 's/conv\/mode_/rm -f MNH\//g' remove_non_mode.sh
chmod +x remove_non_mode.sh
mv remove_non_mode.sh ../.
cd ../
./remove_non_mode.sh
# nettoyage, routine non appellee :
rm -f MNH/mf_turb_greyzone.f90
rm -f MNH/compute_frac_ice.f90
#Configure and compilation
./configure
set +e #file ends with a test that can return false
. ../conf/profile_mesonh-LXgfortran-R8I4-MNH-V5-5-0-MPIAUTO-DEBUG
set -e
make -j 8
make installmaster
fi
if [ $run -ge 1 ]; then
echo "### Running of commit $commit"
echo $commit
if [ ! -f $MNHPACK/$name/exe/MESONH* ]; then
echo "Pack does not exist ($MNHPACK/$name) or compilation has failed, please check"
exit 6
fi
cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/
[ ! -d 008_run2_$commit ] && cp -R 008_run2 008_run2_$commit
cd $REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$commit
set +e #file ends with a test that can return false
[ $compilation -eq 0 ] && . $MNHPACK/$name/conf/profile_mesonh-LXgfortran-R8I4-MNH-V5-5-0-MPIAUTO-DEBUG
set -e
./clean_mesonh_xyz
./run_mesonh_xyz
fi
if [ $check -eq 1 ]; then
echo "### Check commit $commit against commit $reference"
echo "Compare with python..."
# Compare variable of both Synchronous and Diachronic files with printing difference
if [ "$reference" == "" ]; then
python3 $PHYEXTOOLSDIR/compare.py $commit ref
else
python3 $PHYEXTOOLSDIR/compare.py $commit $reference
fi
#Check bit-repro after date of creation of Synchronous file from ncdump of all values (pb with direct .nc file checks)
file1=$REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$commit/16JAN.1.12B18.001.nc
if [ "$reference" == "" ]; then
file2="$REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2/16JAN.1.12B18.001.nc"
else
file2=$REFDIR/MNH-V5-5-0/MY_RUN/KTEST/007_16janvier/008_run2_$reference/16JAN.1.12B18.001.nc
fi
echo "Compare with ncdump..."
ncdump $file1 > dump_$commit
ncdump $file2 > dump_$reference
cmp -n 62000 dump_$commit dump_$reference
rm -f dump_$commit dump_$reference
echo "...comparison done"
fi