The ampersand method

From CAC Documentation wiki
Jump to navigation Jump to search

If when you run a program multiple times they all tend to take about the same length of time to run, you can use multiple cores on a node by using simple job control. Start the program with an ampersand to put it in the background. Then wait until the background tasks are done.

This code sits at

#PBS -l nodes=1,walltime=2:00:00
#PBS -A dal16_0001
#PBS -N trying_ampersands
#PBS -q v4
#PBS -j oe


# copy files


export LD_LIBRARY_PATH=/cac/contrib/gsl-1.11/lib/
./logregFCHMMv2 3 4 train_d0.5_s1000.txt > res_lgFCHMMv2_d0.5_s1000.txt >&tast1.log.stdout &
./logregFCHMMv2 3 4 train_d0.5_s2000.txt > res_lgFCHMMv2_d0.5_s2000.txt &
./logregFCHMMv2 3 4 train_d0.5_s5000.txt > res_lgFCHMMv2_d0.5_s5000.txt &
./logregFCHMMv2 3 4 train_d0.5_s10000.txt > res_lgFCHMMv2_d0.5_s10000.txt &

# copy output back
cp -f $TMPDIR/res* $START_DIR
cp -f $TMPDIR/log* $START_DIR