Sunday, 15 February 2015

shell - Reducing nested bash scripts to single file/mpirun commands -



shell - Reducing nested bash scripts to single file/mpirun commands -

i regularly utilize simplified 2 scripts below distribute embarrassingly parallel work across cluster pbs/mpi. know if commands can merged single file clarity , reduction in clutter. more interested in understanding limitations of bash/mpirun looking alternate approaches solving original problem such pbs arrays.

pbs script:

#pbs -l nodes=2:ppn=2 #pbs -q debug #pbs -v mpirun -n $pbs_np $pbs_o_workdir/worker_script.sh

worker_script.sh

#!/bin/bash ndata=25 data_array=() ((data=${ompi_comm_world_rank};data<${ndata};data=${data}+${pbs_np})) data_array+=(${data}) done echo ${ompi_comm_world_rank} processing ${data_array[@]}

running gives desired output:

0 processing 0 4 8 12 16 20 24 1 processing 1 5 9 13 17 21 3 processing 3 7 11 15 19 23 2 processing 2 6 10 14 18 22 ---------------------------------------------------------------- jobs exit status code 0

is there way of writing contents of worker_script.sh inline mpirun command? there way arounds shell expansion parent other separate file?

anything looks like

#!/bin/bash stuff here

(save scripts here documents) can equivalently expressed on single logical line as

bash -c 'stuff; here'

or more readably

bash -c 'stuff here'

(in case can embed here document.)

if script contains single quotes, have worked around somehow.

having script within single quotes protects wildcard expansion, variable substitution, etc.

just because can doesn't mean should.

bash shell mpi pbs

No comments:

Post a Comment