10
0
mirror of https://github.com/LCPQ/quantum_package synced 2024-09-27 03:51:01 +02:00
quantum_package/scripts/qp_srun
2018-12-21 18:00:47 +01:00

86 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
set -e
NODES=($(srun hostname))
# Test that there is one MPI process per node
NPROC=$(echo ${NODES[@]} | tr ' ' '\n' | sort | wc -l)
NUNIQ=$(echo ${NODES[@]} | tr ' ' '\n' | sort | uniq | wc -l)
if [[ $NPROC != $NUNIQ ]]
then
echo "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error:
There are more than one process per host.
In your SLURM script file, use:
#SBATCH --nodes=$NPROC
#SBATCH --ntasks-per-node=1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
exit -1
fi
PROG=$1
INPUT=$2
# Check if quantum_package.rc is sourced
if [[ -z ${QP_ROOT} ]]
then
echo "Error: quantum_package.rc is not sourced"
exit -1
fi
# Get host names
MASTER_NODE=${NODES[0]}
SLAVE_NODES=$(echo ${NODES[@]:1}| tr ' ' ',')
if [[ $NPROC -gt 1 ]]
then
echo "Master : $MASTER_NODE"
echo "Slaves : $SLAVE_NODES"
fi
# Check if the integrals can be read
source ${QP_ROOT}/external/ezfio/Bash/ezfio.sh
ezfio set_file $INPUT
RW=$(ezfio get integrals_bielec disk_access_mo_integrals)
if [[ $RW != Read ]]
then
echo "
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Warning:
Two-electron integrals were not saved to disk in a previous run.
If the 4-index transformation takes time, you may consider
killing this job and running
qp_run Four_idx_transform $INPUT
as a single-node job before re-submitting the current job.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
fi
rm --force -- "${INPUT}"/work/qp_run_address
set -x
srun -N 1 -n 1 qp_run $PROG $INPUT &
if [[ $NPROC -gt 1 ]]
then
while [[ ! -f $INPUT/work/qp_run_address ]]
do
sleep 1
done
echo "Starting slaves"
srun -n $((${SLURM_NTASKS}-1)) qp_run -slave slave_cipsi $INPUT > $INPUT.slaves.out
fi
wait