-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathcreate_exp.sh
executable file
·80 lines (62 loc) · 1.33 KB
/
create_exp.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
#!/bin/bash
usage()
{
echo "Usage: $0 -n | --name <EXPERIMENT NAME>
[ -p | --path <path to create experiment directory> ]
[ -f | --force ]
"
exit 2
}
error()
{
echo "Error: $1"
exit 1
}
EXP_NAME=''
FORCE=false
WORKPATH='work'
VALID_ARGS=$(getopt -o fp:n: --long name:,path:,force -- "$@")
if [[ $? -ne 0 ]]; then
usage;
fi
eval set -- "$VALID_ARGS"
while [ : ]; do
case "$1" in
-f | --force)
FORCE=true
shift
;;
-n | --name)
EXP_NAME=$2
shift 2
;;
-p | --path)
WORKPATH=$2
shift 2
;;
--) shift;
break
;;
esac
done
[[ -z "$EXP_NAME" ]] && usage
ROOTDIR=$(pwd)
EXPDIR="$WORKPATH/$EXP_NAME"
if [ -f "$EXPDIR" ]; then
error "A file $EXPDIR already exist. Can't create experiment directory with is path!!"
fi
if [ -e "$EXPDIR" ]; then
if [ "$FORCE" != "true" ]; then
error "Path $EXPDIR already exist.!!"
fi
else
mkdir -p $EXPDIR
fi
. $ROOTDIR/.exec_path
for script in $ROOTDIR/scripts/templates/submit_*
do
bscript=$(basename $script)
. $script > $EXPDIR/$bscript || error "Error while creating $bscript"
done
mkdir -p $EXPDIR/INPUT || error "Could not make dir $EXPDIR/INPUT "
mkdir -p $EXPDIR/RESTART || error "Could not make dir $EXPDIR/RESTART "