Mercurial > hg > cc > cirrus_work
comparison bin/_runme_c.sh @ 99:4c65ae2a4bc3
initialise paths for csing
author | Henry S. Thompson <ht@inf.ed.ac.uk> |
---|---|
date | Fri, 08 Sep 2023 21:40:52 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
98:93d4915ef797 | 99:4c65ae2a4bc3 |
---|---|
1 #!/bin/bash | |
2 # This runs on the compute nodes... | |
3 # Args: [-a i] wd [-d] [-t nthreads] [-b CMDS] [-i input] CMDS | |
4 # See ug4/azure/notes.txt for documentation | |
5 | |
6 N=$SLURM_JOB_NUM_NODES | |
7 n=$SLURM_NTASKS | |
8 c=$SLURM_CPUS_PER_TASK | |
9 nodename=$SLURMD_NODENAME | |
10 local=$SLURM_LOCALID | |
11 node=$SLURM_NODEID | |
12 task=$SLURM_PROCID | |
13 | |
14 if [ "$1" = "-a" ] | |
15 then | |
16 shift | |
17 xarg="$1" | |
18 shift | |
19 else | |
20 xarg= | |
21 fi | |
22 | |
23 cd "$1" | |
24 shift | |
25 | |
26 if [ "$1" = "-d" ] | |
27 then | |
28 shift | |
29 debug=1 | |
30 fi | |
31 | |
32 if [ "$1" = "-t" ] | |
33 then | |
34 shift | |
35 threadsPerTask=$1 | |
36 shift | |
37 else | |
38 threadsPerTask=2 | |
39 fi | |
40 | |
41 pjobs=$((c / $threadsPerTask)) | |
42 | |
43 echo $(date) task $n.$task on $nodename:$N.$node start $pjobs jobs 1>&2 | |
44 | |
45 PATH=$W/$USER/bin:$W/shared/bin:$PATH | |
46 export task PATH n xarg | |
47 | |
48 if [ "$1" = "-b" ] | |
49 then | |
50 shift | |
51 eval "$1" | |
52 shift | |
53 fi | |
54 | |
55 input="seq 1 $pjobs" # default to make sure something runs | |
56 | |
57 if [ "$1" = "-i" ] | |
58 then | |
59 shift | |
60 input="$1" | |
61 shift | |
62 if [ "$debug" ] | |
63 then | |
64 echo $(date) task $n.$task input "|$input|" | |
65 fi | |
66 fi | |
67 | |
68 export cmd="$1" | |
69 shift | |
70 | |
71 doit () { | |
72 arg="$1" | |
73 echo $(date) start $task $PARALLEL_SEQ "|$cmd|$xarg|$arg|" | |
74 eval "$cmd" | |
75 echo $(date) end $task $PARALLEL_SEQ | |
76 } | |
77 | |
78 export -f doit | |
79 | |
80 if [ "$debug" ] | |
81 then | |
82 echo $(date) task $n.$task cmd "|$cmd|" doit $(type doit) | |
83 fi | |
84 | |
85 source $HOME/.csing_init | |
86 | |
87 eval "$input" | \ | |
88 if [ "$debug" ] | |
89 then | |
90 tee >(cat 1>&2) | |
91 else | |
92 cat | |
93 fi | \ | |
94 if [ $pjobs -le 1 ] | |
95 then | |
96 xargs -I ^ -n 1 bash -lc "doit ^" | |
97 else | |
98 parallel --line-buffer -j $pjobs doit '{}' | |
99 fi | |
100 | |
101 echo $(date) task $n.$task on $nodename:$N.$node end 1>&2 | |
102 |