-
Notifications
You must be signed in to change notification settings - Fork 7
/
submit.sh
executable file
·127 lines (105 loc) · 2.93 KB
/
submit.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
#!/bin/bash
#################################################################################
# N. Jourdain, IGE-CNRS, Feb. 2017
#
# purpose: used to run an executable in a batch job
#
#################################################################################
date
# Random number :
RAND=$(( ( RANDOM % 10000 ) + 1 ))
rm -f tmptxp_${RAND}.sh
if [ ! -n "$1" ]; then
echo "Usage: `basename $0` file_to_execute [hh] [mem] "
echo " hh is the walltime in hours, with two digits (default is 02) "
echo " mem is the required memory in GB (default is 5GB) "
echo " ex.: ./submit.sh extract_bathy_meter "
echo " ./submit.sh extract_bathy_meter 05 10 "
exit
fi
if [ $# -eq 1 ]; then
walltime="02:00:00"
mem=5
elif [ $# -eq 2 ]; then
walltime="$2:00:00"
mem=5
elif [ $# -eq 3 ]; then
walltime="$2:00:00"
mem=$3
elif [ $# -gt 3 ]; then
echo "Usage: `basename $0` file_to_execute [hh]"
echo " (hh is the walltime in hours, with two digits, default is 02)"
echo " ex.: ./submit.sh extract_bathy_meter 05 "
exit
fi
echo "walltime=$walltime"
echo "mem=${mem}Gb"
#=====
if [ `hostname | cut -d"." -f2` == "occigen" ]; then
echo "host is occigen"
cat > tmptxp_${RAND}.sh << EOF
#!/bin/bash
###SBATCH -C HSW24
#SBATCH -C BDW28
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --ntasks-per-node=1
#SBATCH --threads-per-core=1
#SBATCH -J submit_${1}
#SBATCH -e submit_${1}.e%j
#SBATCH -o submit_${1}.o%j
#SBATCH --mem=${mem}GB
#SBATCH --time=${walltime}
EOF
elif [ `hostname | cut -c 1-3` == "ada" ]; then
echo "host is adapp"
cat > tmptxp_${RAND}.sh << EOF
# @ job_type = serial
# @ requirements = (Feature == "prepost")
# @ wall_clock_limit = ${walltime}
# @ job_name = submit_${1}
# @ output = \$(job_name).\$(jobid)
# @ error = \$(job_name).\$(jobid)
# @ wall_clock_limit = ${walltime}
# @ as_limit = ${mem}.0gb
# @ queue
EOF
elif [ `hostname | cut -c 1-5` == "irene" ]; then
# Walltime in seconds:
walltime_sec=`echo "$2 * 3600" |bc`
# memory: 1.8GB per core:
ncore_mem=`echo "$mem / 1.8" | bc`
cat > tmptxp_${RAND}.sh << EOF
#!/bin/bash
#MSUB -r submit_${1}
#MSUB -o submit_${1}.o%j
#MSUB -e submit_${1}.e%j
#MSUB -n ${ncore_mem}
#MSUB -x
#MSUB -T ${walltime_sec}
#MSUB -A gen6035
#MSUB -q rome
#MSUB -m store,work,workflash,scratch
EOF
else
echo "default host"
echo '#!/bin/bash' > tmptxp_${RAND}.sh
echo " "
echo "WARNING: You may need to add a specific header in submit.sh if `hostname` enables batch jobs"
echo " "
fi
#=====
echo "./$1" >> tmptxp_${RAND}.sh
chmod +x tmptxp_${RAND}.sh
echo "Launching $1 on `hostname`"
if [ `hostname | cut -d"." -f2` == "occigen" ]; then
sbatch ./tmptxp_${RAND}.sh
elif [ `hostname | cut -c 1-3` == "ada" ]; then
llsubmit ./tmptxp_${RAND}.sh
elif [ `hostname | cut -c 1-5` == "irene" ]; then
ccc_msub ./tmptxp_${RAND}.sh
else
./tmptxp_${RAND}.sh
fi
rm -f tmptxp_${RAND}.sh
date