Skip to content

Commit

Permalink
Merge branch 'update.setup.env.tools.mpich' into 'master.dev'
Browse files Browse the repository at this point in the history
Adjusted module scripts for mpich

See merge request piclas/piclas!893
  • Loading branch information
scopplestone committed Jan 8, 2024
2 parents 49f3940 + 77d7208 commit c2c8337
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 39 deletions.
21 changes: 17 additions & 4 deletions tools/Setup_ModuleEnv/InstallHDF5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,31 @@ do
then
LOADMODULES=0
# Set desired versions

# GCC
#USECOMPILERVERSION=13.1.0
USECOMPILERVERSION=13.2.0
USEMPIVERSION=4.1.5

# OpenMPI
#MPINAMES='openmpi'
#USEMPIVERSION=4.1.5

# MPICH
MPINAMES='mpich'
USEMPIVERSION=4.1.2

# Force --rerun via 'set'
echo ""
echo "Running '-m' with GCC $USECOMPILERVERSION and OpenMPI $USEMPIVERSION"
echo "Running '-m' with GCC $USECOMPILERVERSION and $MPINAMES $USEMPIVERSION"
set -- -rerun
break
fi
done

if [[ $LOADMODULES -eq 1 ]]; then
MPINAMES='openmpi mpich'
fi

NBROFCORES=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}')
INSTALLDIR=/opt
SOURCESDIR=/opt/sources
Expand Down Expand Up @@ -105,7 +120,6 @@ TARFILE=${SOURCESDIR}/hdf5-${HDF5VERSION}.tar.gz

# Change to sources directors
cd ${SOURCESDIR}
pwd

echo -e "Download HF5 version ${GREEN}${HDF5VERSION}${NC}."
read -p "Press [Enter] to continue or [Crtl+c] to abort!"
Expand Down Expand Up @@ -239,7 +253,6 @@ for WHICHCOMPILER in ${COMPILERNAMES}; do
# ============================================================================================================================================================================
#--- build hdf5 with mpi
# ============================================================================================================================================================================
MPINAMES='openmpi mpich'
for WHICHMPI in ${MPINAMES}; do
echo "${GREEN} $WHICHMPI ------------------------------------------------------------------------------${NC}"
if [ ! -d "${INSTALLDIR}/modules/modulefiles/libraries/hdf5/${HDF5VERSION}/${WHICHCOMPILER}/${COMPILERVERSION}/${WHICHMPI}" ]; then
Expand Down
42 changes: 30 additions & 12 deletions tools/Setup_ModuleEnv/InstallHOPR.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ load_module () {
# Check command line arguments
RERUNMODE=0
LOADMODULES=1
# default to openmpi
WHICHMPI='openmpi'
for ARG in "$@"
do

Expand Down Expand Up @@ -113,7 +115,22 @@ do
#OPENMPIVERSION=4.0.2
#OPENMPIVERSION=3.1.6
#OPENMPIVERSION=4.1.1
OPENMPIVERSION=4.1.5
#OPENMPIVERSION=4.1.5

MPICHVERSION=4.1.2

# chose which mpi you want to have installed (openmpi or mpich), default is openmpi
if [[ -n ${MPICHVERSION} ]]; then
WHICHMPI='mpich'
MPIVERSION=${MPICHVERSION}
else
if [[ -z ${OPENMPIVERSION} ]]; then
echo "${RED}ERROR: Set either OPENMPIVERSION or MPICHVERSION in InstallPETSc.sh when running with '-m'${NC}. Exit."
exit
else
MPIVERSION=${OPENMPIVERSION}
fi
fi

#HDF5VERSION=1.10.5
#HDF5VERSION=1.10.6
Expand Down Expand Up @@ -160,14 +177,14 @@ if [[ -n $(module purge 2>&1) ]]; then
exit
fi

# take the first gcc compiler installed with first compatible openmpi and hdf5
# take the first gcc compiler installed with first compatible openmpi/mpich and hdf5
echo " "
if [[ $LOADMODULES -eq 1 ]]; then
CMAKEVERSION=$(ls ${MODULESDIR}/utilities/cmake/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
GCCVERSION=$(ls ${MODULESDIR}/compilers/gcc/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
OPENMPIVERSION=$(ls ${MODULESDIR}/MPI/openmpi/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
MPIVERSION=$(ls ${MODULESDIR}/MPI/${WHICHMPI}/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
HDF5VERSION=$(ls ${MODULESDIR}/libraries/hdf5/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
echo -e "Modules found automatically.\n\nCMAKEVERSION=${CMAKEVERSION}\nGCCVERSION=${GCCVERSION}\nOPENMPIVERSION=${OPENMPIVERSION}\nHDF5VERSION=${HDF5VERSION}\n\nWARNING: The combination might not be possible!"
echo -e "Modules found automatically.\n\nCMAKEVERSION=${CMAKEVERSION}\nGCCVERSION=${GCCVERSION}\n${WHICHMPI}-MPIVERSION=${MPIVERSION}\nHDF5VERSION=${HDF5VERSION}\n\nWARNING: The combination might not be possible!"
if [[ ${RERUNMODE} -eq 0 ]]; then
read -p "Press [Enter] to continue or [Crtl+c] to abort!"
fi
Expand All @@ -176,11 +193,11 @@ else
fi

check_module "cmake" "${CMAKEVERSION}"
check_module "gcc " "${GCCVERSION}"
check_module "mpi " "${OPENMPIVERSION}"
check_module "hdf5 " "${HDF5VERSION}"
check_module "gcc" "${GCCVERSION}"
check_module "${WHICHMPI}" "${MPIVERSION}"
check_module "hdf5" "${HDF5VERSION}"

HOPRMODULEFILEDIR=${MODULESDIR}/utilities/hopr/${HOPRVERSION}/gcc/${GCCVERSION}/openmpi/${OPENMPIVERSION}/hdf5
HOPRMODULEFILEDIR=${MODULESDIR}/utilities/hopr/${HOPRVERSION}/gcc/${GCCVERSION}/${WHICHMPI}/${MPIVERSION}/hdf5
MODULEFILE=${HOPRMODULEFILEDIR}/${HDF5VERSION}

# if no HOPR module for this compiler found, install HOPR and create module
Expand All @@ -191,8 +208,8 @@ if [ ! -e "${MODULEFILE}" ]; then
module purge
load_module "cmake/${CMAKEVERSION}"
load_module "gcc/${GCCVERSION}"
load_module "openmpi/${OPENMPIVERSION}/gcc/${GCCVERSION}"
load_module "hdf5/${HDF5VERSION}/gcc/${GCCVERSION}/openmpi/${OPENMPIVERSION}"
load_module "${WHICHMPI}/${MPIVERSION}/gcc/${GCCVERSION}"
load_module "hdf5/${HDF5VERSION}/gcc/${GCCVERSION}/${WHICHMPI}/${MPIVERSION}"
module list
echo " "
echo -e "$GREEN""Important: If the compilation step fails, run the script again and if it still fails \n1) try compiling single, .i.e., remove -j from make -j or \n2) try make -j 2 (not all available threads)$NC"
Expand All @@ -203,7 +220,7 @@ if [ ! -e "${MODULEFILE}" ]; then
fi

# Install destination
HOPRINSTALLDIR=/opt/hopr/${HOPRVERSION}/gcc-${GCCVERSION}/openmpi-${OPENMPIVERSION}/hdf5-${HDF5VERSION}
HOPRINSTALLDIR=/opt/hopr/${HOPRVERSION}/gcc-${GCCVERSION}/${WHICHMPI}-${MPIVERSION}/hdf5-${HDF5VERSION}

# Create and change to install directory
mkdir -p ${HOPRINSTALLDIR}
Expand Down Expand Up @@ -309,9 +326,10 @@ if [ ! -e "${MODULEFILE}" ]; then
sed -i 's/hoprversion/'${HOPRVERSION}'/gI' ${MODULEFILE}
sed -i 's/CMAKEVERSIONFLAG/'${CMAKEVERSION}'/gI' ${MODULEFILE}
sed -i 's/GCCVERSIONFLAG/'${GCCVERSION}'/gI' ${MODULEFILE}
sed -i 's/MPIVERSIONFLAG/'${OPENMPIVERSION}'/gI' ${MODULEFILE}
sed -i 's/MPIVERSIONFLAG/'${MPIVERSION}'/gI' ${MODULEFILE}
sed -i 's/HDF5VERSIONFLAG/'${HDF5VERSION}'/gI' ${MODULEFILE}
sed -i 's\HOPRTOPDIR\'${HOPRBUILDDIR}'\gI' ${MODULEFILE}
sed -i 's\HOPRWHICHMPI\'${WHICHMPI}'\gI' ${MODULEFILE}
else
echo -e "$RED""No module file created for HOPR-${HOPRVERSION} for GCC-${GCCVERSION}$NC"
echo -e "$RED""no installation found in ${HOPRBUILDDIR}/bin$NC"
Expand Down
10 changes: 6 additions & 4 deletions tools/Setup_ModuleEnv/InstallMPIallCOMPILERS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ fi
# --------------------------------------------------------------------------------------------------
NBROFCORES=$(grep ^cpu\\scores /proc/cpuinfo | uniq | awk '{print $4}')
# chose which mpi you want to have installed (openmpi or mpich)
WHICHMPI=openmpi
#WHICHMPI=openmpi
WHICHMPI=mpich
# choose for which compilers mpi is build (gcc or intel)
WHICHCOMPILER=gcc

Expand All @@ -72,7 +73,8 @@ if [ "${WHICHMPI}" == "openmpi" ]; then
MPIVERSION=4.1.5
elif [ "${WHICHMPI}" == "mpich" ]; then
# DOWNLOAD and INSTALL MPICH (example mpich-3.2.0)
MPIVERSION=3.2
#MPIVERSION=3.2
MPIVERSION=4.1.2
else
echo -e "${RED}ERROR: Setting is neither 'openmpi' nor 'mpich'${NC}"
echo -e "${RED}ERROR: no mpi installed will be installed. Exit.${NC}"
Expand Down Expand Up @@ -189,7 +191,7 @@ if [ "${WHICHCOMPILER}" == "gcc" ] || [ "${WHICHCOMPILER}" == "intel" ]; then
# Change to build directory
cd ${BUILDDIR}

# Configure setup
# Configure setup for openmpi or mpich using the same command
if [ "${WHICHCOMPILER}" == "gcc" ]; then
../configure --prefix=${MPIINSTALLDIR}/${WHICHCOMPILER}/${COMPILERVERSION} CC=$(which gcc) CXX=$(which g++) FC=$(which gfortran)
elif [ "${WHICHCOMPILER}" == "intel" ]; then
Expand All @@ -208,7 +210,7 @@ if [ "${WHICHCOMPILER}" == "gcc" ] || [ "${WHICHCOMPILER}" == "intel" ]; then
make install 2>&1 | tee install.out
fi

# Create modulefile if installation seems successful (check if mpicc, mpicxx, mpifort exists in installdir)
# Create module file if installation seems to have been successful (check if mpicc, mpicxx, mpifort exists in installdir)
if [ -e "${MPIINSTALLDIR}/${WHICHCOMPILER}/${COMPILERVERSION}/bin/mpicc" ] && [ -e "${MPIINSTALLDIR}/${WHICHCOMPILER}/${COMPILERVERSION}/bin/mpicxx" ] && [ -e "${MPIINSTALLDIR}/${WHICHCOMPILER}/${COMPILERVERSION}/bin/mpifort" ]; then
if [ ! -d "${MPIMODULEFILEDIR}" ]; then
mkdir -p ${MPIMODULEFILEDIR}
Expand Down
48 changes: 32 additions & 16 deletions tools/Setup_ModuleEnv/InstallPETSc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ load_module () {
# Check command line arguments
RERUNMODE=0
LOADMODULES=1
# default to openmpi
WHICHMPI='openmpi'
for ARG in "$@"
do

Expand All @@ -96,6 +98,7 @@ do
#CMAKEVERSION=3.17.0-d
#CMAKEVERSION=3.20.3
#CMAKEVERSION=3.21.3
#CMAKEVERSION=3.24.2
CMAKEVERSION=3.26.4

#GCCVERSION=9.2.0
Expand All @@ -113,7 +116,22 @@ do
#OPENMPIVERSION=3.1.6
#OPENMPIVERSION=4.1.1
#OPENMPIVERSION=4.1.4
OPENMPIVERSION=4.1.5
#OPENMPIVERSION=4.1.5

MPICHVERSION=4.1.2

# chose which mpi you want to have installed (openmpi or mpich), default is openmpi
if [[ -n ${MPICHVERSION} ]]; then
WHICHMPI='mpich'
MPIVERSION=${MPICHVERSION}
else
if [[ -z ${OPENMPIVERSION} ]]; then
echo "${RED}ERROR: Set either OPENMPIVERSION or MPICHVERSION in InstallPETSc.sh when running with '-m'${NC}. Exit."
exit
else
MPIVERSION=${OPENMPIVERSION}
fi
fi

fi

Expand All @@ -124,9 +142,6 @@ do

done

# chose which mpi you want to have installed (openmpi or mpich), default is openmpi
WHICHMPI=openmpi

# DOWNLOAD and INSTALL PETSc (example PETSc-3.17.0)
#PETSCVERSION=3.17.0
#PETSCVERSION=3.18.4
Expand Down Expand Up @@ -174,13 +189,13 @@ if [[ -n $(module purge 2>&1) ]]; then
exit
fi

# take the first gcc compiler installed with first compatible openmpi
# take the first gcc compiler installed with first compatible openmpi or mpich
echo " "
if [[ $LOADMODULES -eq 1 ]]; then
CMAKEVERSION=$(ls ${MODULESDIR}/utilities/cmake/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
GCCVERSION=$(ls ${MODULESDIR}/compilers/gcc/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
OPENMPIVERSION=$(ls ${MODULESDIR}/MPI/openmpi/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
echo -e "Modules found automatically.\n\nCMAKEVERSION=${CMAKEVERSION}\nGCCVERSION=${GCCVERSION}\nOPENMPIVERSION=${OPENMPIVERSION}\n\nWARNING: The combination might not be possible!"
MPIVERSION=$(ls ${MODULESDIR}/MPI/${WHICHMPI}/ | sed 's/ /\n/g' | grep -i "[0-9]\." | head -n 1 | tail -n 1)
echo -e "Modules found automatically.\n\nCMAKEVERSION=${CMAKEVERSION}\nGCCVERSION=${GCCVERSION}\n${WHICHMPI}-MPIVERSION=${MPIVERSION}\n\nWARNING: The combination might not be possible!"
if [[ ${RERUNMODE} -eq 0 ]]; then
read -p "Press [Enter] to continue or [Crtl+c] to abort!"
fi
Expand All @@ -189,11 +204,11 @@ else
fi

check_module "cmake" "${CMAKEVERSION}"
check_module "gcc " "${GCCVERSION}"
check_module "mpi " "${OPENMPIVERSION}"
check_module "gcc" "${GCCVERSION}"
check_module "${WHICHMPI}" "${MPIVERSION}"

PETSCMODULEFILEDIR=${MODULESDIR}/utilities/petsc/${PETSCVERSION}${DEBUGDIR}/gcc/${GCCVERSION}/openmpi
MODULEFILE=${PETSCMODULEFILEDIR}/${OPENMPIVERSION}
PETSCMODULEFILEDIR=${MODULESDIR}/utilities/petsc/${PETSCVERSION}${DEBUGDIR}/gcc/${GCCVERSION}/${WHICHMPI}
MODULEFILE=${PETSCMODULEFILEDIR}/${MPIVERSION}

# if no PETSc module for this compiler found, install PETSc and create module
if [ ! -e "${MODULEFILE}" ]; then
Expand All @@ -203,7 +218,7 @@ if [ ! -e "${MODULEFILE}" ]; then
module purge
load_module "cmake/${CMAKEVERSION}"
load_module "gcc/${GCCVERSION}"
load_module "openmpi/${OPENMPIVERSION}/gcc/${GCCVERSION}"
load_module "${WHICHMPI}/${MPIVERSION}/gcc/${GCCVERSION}"
module list
echo " "
echo -e "$GREEN""Important: If the compilation step fails, run the script again and if it still fails \n1) try compiling single, .i.e., remove -j from make -j or \n2) try make -j 2 (not all available threads)$NC"
Expand All @@ -214,7 +229,7 @@ if [ ! -e "${MODULEFILE}" ]; then
fi

# Install destination
PETSCINSTALLDIR=/opt/petsc/${PETSCVERSION}${DEBUGDIR}/gcc-${GCCVERSION}/openmpi-${OPENMPIVERSION}
PETSCINSTALLDIR=/opt/petsc/${PETSCVERSION}${DEBUGDIR}/gcc-${GCCVERSION}/${WHICHMPI}-${MPIVERSION}

# Change to sources directors
cd ${SOURCESDIR}
Expand All @@ -226,7 +241,7 @@ if [ ! -e "${MODULEFILE}" ]; then
while true; do
echo " "
echo "${YELLOW}${CLONEDIR} already exists.${NC}"
echo "${YELLOW}Do you want to continue the installation (y/n)?${NC}"
echo "${YELLOW}Do you want to continue the installation with the existing files under ${CLONEDIR} (y/n)?${NC}"
# Inquiry
if [[ ${RERUNMODE} -eq 0 ]]; then
read -p "${YELLOW}Otherwise the directory will be removed and a fresh installation will be performed. [Y/n]${NC}" yn
Expand Down Expand Up @@ -277,7 +292,7 @@ if [ ! -e "${MODULEFILE}" ]; then
fi

# Configure
MPIINSTALLDIR=${INSTALLDIR}/${WHICHMPI}/${OPENMPIVERSION}/gcc/${GCCVERSION}
MPIINSTALLDIR=${INSTALLDIR}/${WHICHMPI}/${MPIVERSION}/gcc/${GCCVERSION}
if [[ ! -d ${MPIINSTALLDIR} ]]; then
echo -e "$RED""Failed: Cannot find MPI directory ${MPIINSTALLDIR}$NC"
exit
Expand Down Expand Up @@ -332,8 +347,9 @@ if [ ! -e "${MODULEFILE}" ]; then
sed -i 's/petscversion/'${PETSCVERSION}'/gI' ${MODULEFILE}
sed -i 's/CMAKEVERSIONFLAG/'${CMAKEVERSION}'/gI' ${MODULEFILE}
sed -i 's/GCCVERSIONFLAG/'${GCCVERSION}'/gI' ${MODULEFILE}
sed -i 's/MPIVERSIONFLAG/'${OPENMPIVERSION}'/gI' ${MODULEFILE}
sed -i 's/MPIVERSIONFLAG/'${MPIVERSION}'/gI' ${MODULEFILE}
sed -i 's\PETSCTOPDIR\'${PETSCINSTALLDIR}'\gI' ${MODULEFILE}
sed -i 's\PETSCWHICHMPI\'${WHICHMPI}'\gI' ${MODULEFILE}
else
echo -e "$RED""No module file created for PETSc-${PETSCVERSION} for GCC-${GCCVERSION}$NC"
echo -e "$RED""no installation found in ${PETSCINSTALLDIR}/include$NC"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ module-whatis "Sets the environment for using hopr-hoprversion"
conflict hopr

prereq gcc/GCCVERSIONFLAG
prereq openmpi/MPIVERSIONFLAG/gcc/GCCVERSIONFLAG
prereq hdf5/HDF5VERSIONFLAG/gcc/GCCVERSIONFLAG/openmpi/MPIVERSIONFLAG
prereq HOPRWHICHMPI/MPIVERSIONFLAG/gcc/GCCVERSIONFLAG
prereq hdf5/HDF5VERSIONFLAG/gcc/GCCVERSIONFLAG/HOPRWHICHMPI/MPIVERSIONFLAG

# for Tcl script use only
set topdir HOPRTOPDIR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module-whatis "Sets the environment for using petsc-petscversion"
conflict petsc

prereq gcc/GCCVERSIONFLAG
prereq openmpi/MPIVERSIONFLAG/gcc/GCCVERSIONFLAG
prereq PETSCWHICHMPI/MPIVERSIONFLAG/gcc/GCCVERSIONFLAG

# for Tcl script use only
set topdir PETSCTOPDIR
Expand Down

0 comments on commit c2c8337

Please sign in to comment.