#!/bin/sh
# autopkgtest check
# (C) 2014 Anton Gladky

set -e

export OMPI_MCA_plm_rsh_agent=/bin/false
# CI runners often expose fewer slots than the -np below asks for, which
# makes OpenMPI 5 (PRRTE) refuse to launch instead of packing the ranks
# onto what is there.
export PRTE_MCA_rmaps_default_mapping_policy=:oversubscribe
# These runs are 2 ranks on one node, so shared memory is all they need.
# Leaving the TCP BTL enabled makes it log "Unable to find reachable
# pairing between local and remote interfaces" in nested CI containers
# and then wedge on shutdown, inside the MPI teardown of LAMMPS's
# destructor (Bug#1145187).
export OMPI_MCA_btl=^tcp

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cp examples/dipole/* $WORKDIR
cd $WORKDIR
mkdir post

timeout --verbose 300 mpirun -np 2 lmp -in in.dipole
lmp -in in.dipole
echo "run: OK"
