From 003e1f27a5c7742e9bbbae66b5573bbeb4c18d73 Mon Sep 17 00:00:00 2001
From: iamashwin99 <ashwin-kumar.karnad@mpsd.mpg.de>
Date: Mon, 20 Mar 2023 17:11:08 +0100
Subject: [PATCH] conf-wrappers: set LIBS_ELPA FCFLAGS_ELPA

---
 octopus/foss2021a-cuda-mpi-config.sh |  3 ++-
 octopus/foss2021a-mpi-config.sh      |  3 ++-
 octopus/foss2021a-serial-config.sh   |  3 ++-
 octopus/foss2022a-cuda-mpi-config.sh |  3 ++-
 octopus/foss2022a-mpi-config.sh      |  3 ++-
 octopus/foss2022a-serial-config.sh   |  3 ++-
 spack_setup.sh                       | 12 ------------
 7 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/octopus/foss2021a-cuda-mpi-config.sh b/octopus/foss2021a-cuda-mpi-config.sh
index 278784e..6c8c4da 100644
--- a/octopus/foss2021a-cuda-mpi-config.sh
+++ b/octopus/foss2021a-cuda-mpi-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/octopus/foss2021a-mpi-config.sh b/octopus/foss2021a-mpi-config.sh
index 9b5935c..6d237a8 100644
--- a/octopus/foss2021a-mpi-config.sh
+++ b/octopus/foss2021a-mpi-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/octopus/foss2021a-serial-config.sh b/octopus/foss2021a-serial-config.sh
index 35fda89..9373879 100644
--- a/octopus/foss2021a-serial-config.sh
+++ b/octopus/foss2021a-serial-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/octopus/foss2022a-cuda-mpi-config.sh b/octopus/foss2022a-cuda-mpi-config.sh
index 278784e..6c8c4da 100644
--- a/octopus/foss2022a-cuda-mpi-config.sh
+++ b/octopus/foss2022a-cuda-mpi-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/octopus/foss2022a-mpi-config.sh b/octopus/foss2022a-mpi-config.sh
index 9b5935c..6d237a8 100644
--- a/octopus/foss2022a-mpi-config.sh
+++ b/octopus/foss2022a-mpi-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/octopus/foss2022a-serial-config.sh b/octopus/foss2022a-serial-config.sh
index dfcfc18..57c5d57 100644
--- a/octopus/foss2022a-serial-config.sh
+++ b/octopus/foss2022a-serial-config.sh
@@ -11,7 +11,8 @@ export LDFLAGS=`echo ${LIBRARY_PATH:+:$LIBRARY_PATH} | sed -e 's/:/ -Wl,-rpath=/
 
 # HG: help configure to find the ELPA F90 modules
 MPSD_ELPA_VERSION=`expr match $MPSD_ELPA_ROOT '.*/elpa-\([0-9.]\+\)'`
-[ -n "$MPSD_ELPA_VERSION" ] && FCFLAGS="$FCFLAGS -I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+[ -n "$MPSD_ELPA_VERSION" ] && export FCFLAGS_ELPA="-I$MPSD_ELPA_ROOT/include/elpa_openmp-$MPSD_ELPA_VERSION/modules"
+export LIBS_ELPA="-L$MPSD_ELPA_ROOT/lib -lelpa_openmp"
 
 # HG: always keep options in the order listed by ``configure --help``
 ../configure \
diff --git a/spack_setup.sh b/spack_setup.sh
index bc65a81..6511bbc 100755
--- a/spack_setup.sh
+++ b/spack_setup.sh
@@ -183,23 +183,11 @@ install_missing_terminfo() {
     done
 }
 
-elpa_openmp_octopus_workaround() {
-    local elpa_specs=$(spack find --no-groups --format '{name}@{version}/{hash}' elpa) || return 0
-    [[ "$elpa_specs" =~ ^[[:alpha:]] ]] || return 0
-    echo "${C_MSG}#####${C_RESET} adding elpa_openmp octopus workaround for '$elpa_specs'"
-    local elpa_spec
-    for elpa_spec in $elpa_specs; do
-        local lib_dir="$(spack location -i $elpa_spec)/lib/"
-        [ -e $lib_dir/libelpa.so ] && continue
-        [ -e $lib_dir/libelpa_openmp.so ] && ln -nsvf $lib_dir/libelpa_openmp.so $lib_dir/libelpa.so
-    done
-}
 
 postprocess_spack_time=0
 postprocess_spack() {
     local func_start_time=$(time_elapsed 0)
     install_missing_terminfo
-    elpa_openmp_octopus_workaround
     update_buildcache
     echo "${C_MSG}#####${C_RESET} (Re-)Creating module files"
     $color_spack module lmod refresh -y
-- 
GitLab