Last active
September 2, 2016 20:25
-
-
Save larsvilhuber/654e33edb0d42ec916d7b8b58e9d9eb2 to your computer and use it in GitHub Desktop.
myOpenMPI.qsub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -l | |
# Output (log) and errors will go into the system-defined stdout file | |
#PBS -j oe | |
############################################################################## | |
# Based on http://csc.cnsi.ucsb.edu/docs/running-jobs-torque | |
# IMPORTANT: the next line determines how many nodes to run on | |
# nodes is number of nodes, ppn= processors (cores) per node | |
# | |
#PBS -l nodes=2:ppn=32 | |
# | |
# Make sure that we are in the same subdirectory as where the qsub command | |
# is issued. | |
# | |
cd $PBS_O_WORKDIR | |
source /etc/profile.d/modules.sh | |
# | |
# make a list of allocated nodes(cores) | |
# Note that if multiple jobs run in same directory, use different names | |
# for example, add on jobid nmber. | |
cat $PBS_NODEFILE > hostfile | |
# How many cores total do we have? | |
NO_OF_CORES=`cat hostfile | egrep -v '^#'\|'^$' | wc -l | awk '{print $1}'` | |
NODE_LIST=`cat hostfile | sort | uniq ` | |
# | |
# Just for kicks, see which nodes we got. | |
echo "Nodes: $NODE_LIST" | |
echo "Cores: $NO_OF_CORES" | |
# | |
# Find the binary. This is a frequent cause of grief, see http://stackoverflow.com/questions/22925515/openmpi-simple-2-node-setup | |
MPIRUN=$(which mpirun) | |
# Run the executable. *DO NOT PUT* a '&' at the end!! | |
# | |
$MPIRUN -np $NO_OF_CORES --hostfile ./hostfile ./myprog |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment