-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdelete-ece3.sh
executable file
·68 lines (52 loc) · 1.44 KB
/
delete-ece3.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
#! /usr/bin/env bash
#SBATCH --qos=nf
#SBATCH --ntasks=24
#SBATCH --output=log/del.%j.out
#SBATCH --time=06:00:00
set -e
usage() {
cat << EOT >&2
Usage:
sbatch ${0##*/} [-o MODEL1 -o MODEL2 ...] EXP LEG
REMOVE local output of ONE leg of one experiment and for any requested components.
Options are:
-o model : an EC-Earth3 component for which local output should be remove
EOT
}
set -eu
error() { echo "ERROR: $1" >&2; exit 1; }
urror() { echo "ERROR: $1" >&2; usage; exit 1; }
# -- HARDCODED OPTIONS - list of components for which the local output is removed
out_models=ifs
# while getopts "ho:" opt; do
# case "$opt" in
# h) usage; exit 0 ;;
# o) out_models="$OPTARG $out_models" ;;
# ?) echo "UNKNOWN OPTION"; usage; exit 1
# esac
# done
# shift $((OPTIND-1))
# -- ARG
[[ "$#" -ne 2 ]] && urror "Need TWO arguments!"
[[ ! $1 =~ ^[a-Z_0-9]{4}$ ]] && urror "argument EXPERIMENT name (=$1) should be a 4-character string"
[[ ! $2 =~ ^[0-9]+$ ]] && urror "argument LEG_NUMBER (=$2) should be a number"
if [[ -z $out_models && -z $rst_models ]]
then
echo " No model selected!"
exit 0
fi
exp=$1
leg=$((10#$2))
. ./config.cfg
k3d=$(printf %03d ${leg})
for model in ${out_models}
do
outdir=${runs_dir}/$exp/output/$model/$k3d
[[ ! -d $outdir ]] && continue
cd $outdir
for f in *
do
[[ -f $f ]] && rm -f $f
done
done
echo " *II* SUCCESS ${exp} ${leg}"