#!/bin/bash
# -*-sh-*-

# shellcheck disable=SC1091
#
export MAKEFLAGS=""
status=0

source ./common/TEST_ENV || exit 1
source ./common/functions || exit 1

cd libs/scalapack || exit 1
export BATS_JUNIT_CLASS=scalapack

# bootstrap the local autotools project if necessary

./bootstrap || exit 1

for COMPILER in ${COMPILER_FAMILIES}; do

	# gnu families only
	[[ ! "${COMPILER}" =~ gnu ]] && continue

	for MPI in ${MPI_FAMILIES}; do

		echo " "
		echo " "
		echo "-------------------------------------------------------"
		echo "Libraries: scalapack tests: ${COMPILER}-${MPI}"
		echo "-------------------------------------------------------"

		module purge || exit 1
		module load prun || exit 1
		module load "${COMPILER}" || exit 1
		module load "${MPI}" || exit 1
		module load scalapack || exit 1

		./configure || exit 1
		make clean || exit 1
		make -k check || status=1

		save_logs_mpi_family tests "${COMPILER}" "${MPI}"

		make distclean
	done
done

exit "${status}"
