-
Notifications
You must be signed in to change notification settings - Fork 33
/
slrm.sh
executable file
·51 lines (42 loc) · 1.05 KB
/
slrm.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
#!/usr/bin/env bash
# @AUTHOR: Chun-Jie Liu
# @CONTACT: chunjie.sam.liu.at.gmail.com
# @DATE: 2022-02-20 18:22:36
# @DESCRIPTION:
params=$#
script=${1}
function usage {
Description="Notice: The script aimed at running shell command in general parallel."
Usage="Uage: generalParallel shell_script.sh ntasks(default:20) nodes(default:5) ntasks_per_node(default:1)"
ErrorNo="Error: Number of arguments must be 1 or 2"
ErrorScript="Error: suffix of script file must be sh."
if [ "$params" -lt 1 ]; then
echo $ErrorNo
echo $Description
echo $Usage
exit 1
fi
if [ "${script#*.}" != "sh" ]; then
echo $ErrorScript
echo $Description
echo $Usage
exit 1
fi
}
function run {
sbatch << EOF
#!/usr/bin/env bash
#SBATCH --signal=USR2
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=20
#SBATCH --mem=30G
#SBATCH --time=720:00:00
#SBATCH --output=${HOME}/tmp/errout/${name}.%j.out
#SBATCH --error=${HOME}/tmp/errout/${name}.%j.err
#SBATCH --mail-user=chunjie.sam.liu@gmail.com
bash ${script}
EOF
}
usage
name=`basename ${script%%.sh}`
run