-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup
executable file
·164 lines (138 loc) · 4.18 KB
/
setup
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
#!/bin/bash
WD=$PWD
SYSTEM=Anemone
BRANCH=branch_4.2
#COMMIT=b1b3d9e142670c8358f240a8eeb13979600d8039
TAG=4.2.2
NEMODIR=${WD}/nemo
STOP=0
# Handle arguments
usage() { echo "Usage: $0 [-b branch] [-c commit | -t tag] [-d directory] [-s system] [-x stop_after_download]" 1>&2; exit 1; }
while getopts ":b:c:t:d:s:x" o; do
case "${o}" in
b)
BRANCH=${OPTARG}
;;
c)
COMMIT=${OPTARG}
;;
t)
TAG=${OPTARG}
;;
d)
NEMODIR=$(realpath "${OPTARG}")
;;
s)
SYSTEM=${OPTARG}
;;
x)
STOP=1
;;
*)
usage
;;
esac
done
shift $((OPTIND-1))
# Check only one of "-c" or "-t" is specified
if [ -n "${COMMIT}" ] && [ -n "${TAG}" ]; then
echo "Specify only one of "-c" or "-t"."
exit
fi
# Check system is supported and ensure 'correct' case of $SYSTEM
if [[ "$SYSTEM" =~ ^([aA][nN][eE][mM][oO][nN][eE])$ ]]; then
SYSTEM=Anemone
elif [[ "$SYSTEM" =~ ^([aA][rR][cC][hH][eE][rR][2])$ ]]; then
SYSTEM=Archer2
else
echo "System not recognised. Options are: Anemone, Archer2"
exit
fi
# Download NEMO
echo "Downloading NEMO"
# Checking out from NEMO GitLab
git clone https://forge.nemo-ocean.eu/nemo/nemo.git -b "$BRANCH" "$NEMODIR" || exit
if [ -n "${COMMIT}" ]; then
cd "$NEMODIR" || exit
git reset --hard "$COMMIT" || exit
cd "$WD" || exit
fi
if [ -n "${TAG}" ]; then
cd "$NEMODIR" || exit
git reset --hard "$TAG" || exit
cd "$WD" || exit
fi
if [[ "$STOP" == 1 ]]; then
exit
fi
###########################################
# SYSTEM
###########################################
# System specific options
echo "Setting up configuration and scripts for ${SYSTEM}"
echo $PWD
ln -sfT compile_nemo_${SYSTEM} scripts/compile_nemo
ln -sfT compile_tools_${SYSTEM} scripts/compile_tools
ln -sfT mkslurm_NPD_${SYSTEM} scripts/python/mkslurm_NPD
ln -sfT INPUT_eORCA025_${SYSTEM} data/INPUT_eORCA025
ln -sfT INPUT_eORCA12_${SYSTEM} data/INPUT_eORCA12
ln -sfT INPUT_RAPID12_${SYSTEM} data/INPUT_RAPID12
ln -sfT INPUT_RAPID12_${SYSTEM} data/INPUT_RAPID12
ln -sfT INPUT_RAPID36_${SYSTEM} data/INPUT_RAPID36
ln -sfT INPUT_RAPID36_${SYSTEM} data/INPUT_RAPID36
# Copy
echo "Copying customized files into ${NEMODIR}"
cp -r "${WD}"/{arch,cfgs,data,ext,scripts,tools} "$NEMODIR"/. || exit
cp -r "${WD}"/scripts/TIDY "$NEMODIR"/cfgs/GLOBAL_QCO/eORCA025/.
cp -r "${WD}"/scripts/TIDY "$NEMODIR"/cfgs/GLOBAL_QCO/eORCA12/.
cp -r "${WD}"/scripts/TIDY "$NEMODIR"/cfgs/AGRIF_QCO/eORCA025-RAPID12/.
cp -r "${WD}"/scripts/TIDY "$NEMODIR"/cfgs/AGRIF_QCO/eORCA025-RAPID12-RAPID36/.
###########################################
# TOOLS
###########################################
# # Compile tools
# echo "Compiling tools"
# cd "$NEMODIR"/tools || exit
# ../scripts/compile_tools || exit
#
#
# # Submit DOMAINcfg
# echo "Submitting scripts to create domain files"
# for DIR in "${WD}"/tools/DOMAINcfg/*/; do
# DIR=$(basename "$DIR")
# echo "$DIR"
# cd "$NEMODIR"/tools/DOMAINcfg/"$DIR"/ || exit
# if [ "$DIR" == "eORCA025-RAPID12" ] ; then
# DOMAIN_JOBID12=$(sbatch --parsable build_domains.slurm) || exit
# elif [ "$DIR" == "eORCA025-RAPID12-RAPID36" ] ; then
# DOMAIN_JOBID36=$(sbatch --parsable build_domains.slurm) || exit
# else
# sbatch build_domains.slurm || exit
# fi
# done
#
#
# # TO CHECK - note dependency of weights submission on completion of domain building.
#
# # Submit WEIGHTS
# echo "Submitting scripts to create weights"
# for DIR in "${WD}"/tools/WEIGHTS/*/; do
# DIR=$(basename "$DIR")
# echo "$DIR"
# cd "$NEMODIR"/tools/WEIGHTS/"$DIR"/ || exit
# if [ -e build_weights_R36.slurm ] ; then
# sbatch --dependency=afterok:"$DOMAIN_JOBID36" build_weights_R36.slurm || exit
# else
# sbatch --dependency=afterok:"$DOMAIN_JOBID12" build_weights.slurm || exit
# fi
# done
###########################################
# CONFIGURATIONS
###########################################
# Add and compile cfgs
echo "Compiling NEMO"
cd "$NEMODIR" || exit
./scripts/compile_nemo || exit
# Bye-Bye
squeue -u "$USER"
cd "$WD" || exit