From 924d6d05a6c4cc88d0967d984453f130bf6e61c2 Mon Sep 17 00:00:00 2001
From: Romain Boman <romain.boman@gmail.com>
Date: Mon, 11 Jun 2018 16:25:31 +0200
Subject: [PATCH] ld_library_path + gnome

---
 cfg/blueberry/intelCommunity.bashrc  | 18 ++----------------
 cfg/blueberry/intelCommunity.profile | 21 ++++++---------------
 cfg/clifton/intelCommunity.bashrc    | 17 ++---------------
 cfg/clifton/intelCommunity.profile   | 19 +++++--------------
 cfg/garfield/compilers.bashrc        | 19 ++++++++++++-------
 cfg/garfield/compilers.profile       | 18 +++++++++++++-----
 cfg/garfield/mumps.profile           |  2 +-
 cfg/gaston/intelCommunity.bashrc     | 13 +------------
 cfg/gaston/intelCommunity.profile    | 19 +++++--------------
 cfg/spring/compilers.bashrc          | 17 ++++-------------
 cfg/spring/compilers.profile         | 19 +++++--------------
 cfg/thorgal/intelCommunity.bashrc    | 13 +------------
 cfg/thorgal/intelCommunity.profile   | 19 +++++--------------
 13 files changed, 62 insertions(+), 152 deletions(-)

diff --git a/cfg/blueberry/intelCommunity.bashrc b/cfg/blueberry/intelCommunity.bashrc
index 09fe18c..2d14ff9 100644
--- a/cfg/blueberry/intelCommunity.bashrc
+++ b/cfg/blueberry/intelCommunity.bashrc
@@ -1,22 +1,8 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
-if [ -z "$MKLROOT" ]; then
+if [ -d /opt/intel ] ; then
     . /opt/intel/mkl/bin/mklvars.sh intel64
-fi
-if [ -z "$TBBROOT" ]; then
     . /opt/intel/tbb/bin/tbbvars.sh intel64
 fi
-
diff --git a/cfg/blueberry/intelCommunity.profile b/cfg/blueberry/intelCommunity.profile
index 3fa6997..b7ff651 100644
--- a/cfg/blueberry/intelCommunity.profile
+++ b/cfg/blueberry/intelCommunity.profile
@@ -1,19 +1,10 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -n "$BASH_VERSION" ]; then
-    . /opt/intel/mkl/bin/mklvars.sh intel64
-    . /opt/intel/tbb/bin/tbbvars.sh intel64
-fi
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/mkl/bin/mklvars.sh intel64
+        . /opt/intel/tbb/bin/tbbvars.sh intel64
+    fi
+fi
\ No newline at end of file
diff --git a/cfg/clifton/intelCommunity.bashrc b/cfg/clifton/intelCommunity.bashrc
index 7b93b13..a24f3b4 100644
--- a/cfg/clifton/intelCommunity.bashrc
+++ b/cfg/clifton/intelCommunity.bashrc
@@ -1,21 +1,8 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
-if [ -z "$MKLROOT" ]; then
+if [ -d /opt/intelCommunity2017 ] ; then
     . /opt/intelCommunity2017/mkl/bin/mklvars.sh intel64
-fi
-if [ -z "$TBBROOT" ]; then
     . /opt/intelCommunity2017/tbb/bin/tbbvars.sh intel64
 fi
diff --git a/cfg/clifton/intelCommunity.profile b/cfg/clifton/intelCommunity.profile
index c74dbb2..597c39a 100644
--- a/cfg/clifton/intelCommunity.profile
+++ b/cfg/clifton/intelCommunity.profile
@@ -1,19 +1,10 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -n "$BASH_VERSION" ]; then
-    . /opt/intelCommunity2017/mkl/bin/mklvars.sh intel64
-    . /opt/intelCommunity2017/tbb/bin/tbbvars.sh intel64
+    if [ -d /opt/intelCommunity2017 ] ; then
+        . /opt/intelCommunity2017/mkl/bin/mklvars.sh intel64
+        . /opt/intelCommunity2017/tbb/bin/tbbvars.sh intel64
+    fi
 fi
diff --git a/cfg/garfield/compilers.bashrc b/cfg/garfield/compilers.bashrc
index 3f73074..9655075 100644
--- a/cfg/garfield/compilers.bashrc
+++ b/cfg/garfield/compilers.bashrc
@@ -1,20 +1,25 @@
 # Intel compiler and/or TBB/MKL 
 #
 # EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
+# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) sets PATH, LD_LIBRARY_PATH.
+# If we want these variables to be set system-wide, it should be run in .profile
+#  
+# BUT
+#  1. the gnome display manager unset LD_LIBRARY_PATH
 #
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
+#  2. if the login shell is "dash", the script cannot be called 
+#     (we cannot add an extra argument to a sourced script with dash). 
+# THEN
 # => we call the scripts in both places (.bashrc & .profile)
 # => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
 #
 # SPECIAL CASE: "at" job
 # => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
 # => the .profile is then rerun manually in our scripts (with bash)
+#    should we run also .bashrc as LD_LIBRARY_PATH should be set here on systems with gnome? 
 # => duplicates are finally removed by loop.sh
 
-if [ -z "$MKLROOT" ]; then
-      . /opt/intel/mkl/bin/mklvars.sh intel64
-      . /opt/intel/tbb/bin/tbbvars.sh intel64
+if [ -d /opt/intel ] ; then
+    . /opt/intel/mkl/bin/mklvars.sh intel64
+    . /opt/intel/tbb/bin/tbbvars.sh intel64
 fi
-
diff --git a/cfg/garfield/compilers.profile b/cfg/garfield/compilers.profile
index 3fa6997..47e3980 100644
--- a/cfg/garfield/compilers.profile
+++ b/cfg/garfield/compilers.profile
@@ -1,19 +1,27 @@
 # Intel compiler and/or TBB/MKL 
 #
 # EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
+# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) sets PATH, LD_LIBRARY_PATH.
+# If we want these variables to be set system-wide, it should be run in .profile
+#  
+# BUT
+#  1. the gnome display manager unset LD_LIBRARY_PATH
 #
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
+#  2. if the login shell is "dash", the script cannot be called 
+#     (we cannot add an extra argument to a sourced script with dash). 
+# THEN
 # => we call the scripts in both places (.bashrc & .profile)
 # => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
 #
 # SPECIAL CASE: "at" job
 # => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
 # => the .profile is then rerun manually in our scripts (with bash)
+#    should we run also .bashrc as LD_LIBRARY_PATH should be set here on systems with gnome? 
 # => duplicates are finally removed by loop.sh
 
 if [ -n "$BASH_VERSION" ]; then
-    . /opt/intel/mkl/bin/mklvars.sh intel64
-    . /opt/intel/tbb/bin/tbbvars.sh intel64
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/mkl/bin/mklvars.sh intel64
+        . /opt/intel/tbb/bin/tbbvars.sh intel64
+    fi
 fi
diff --git a/cfg/garfield/mumps.profile b/cfg/garfield/mumps.profile
index 57e0ada..ad17390 100644
--- a/cfg/garfield/mumps.profile
+++ b/cfg/garfield/mumps.profile
@@ -1,3 +1,3 @@
-add2env LD_LIBRARY_PATH "/opt/mumps/lib"
+#add2env LD_LIBRARY_PATH "/opt/mumps/lib"
 add2env LIB "/opt/mumps/lib"
 add2env INCLUDE "/opt/mumps/include"
diff --git a/cfg/gaston/intelCommunity.bashrc b/cfg/gaston/intelCommunity.bashrc
index 7fb2eff..43482b6 100644
--- a/cfg/gaston/intelCommunity.bashrc
+++ b/cfg/gaston/intelCommunity.bashrc
@@ -1,17 +1,6 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -z "$MKLROOT" ]; then
     . /opt/intel/mkl/bin/mklvars.sh intel64
diff --git a/cfg/gaston/intelCommunity.profile b/cfg/gaston/intelCommunity.profile
index 2501156..e5d1ff5 100644
--- a/cfg/gaston/intelCommunity.profile
+++ b/cfg/gaston/intelCommunity.profile
@@ -1,19 +1,10 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -n "$BASH_VERSION" ]; then
-      . /opt/intel/mkl/bin/mklvars.sh intel64
-      . /opt/intel/tbb/bin/tbbvars.sh intel64
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/mkl/bin/mklvars.sh intel64
+        . /opt/intel/tbb/bin/tbbvars.sh intel64
+    fi
 fi
diff --git a/cfg/spring/compilers.bashrc b/cfg/spring/compilers.bashrc
index 09e595a..b7f235d 100644
--- a/cfg/spring/compilers.bashrc
+++ b/cfg/spring/compilers.bashrc
@@ -1,18 +1,9 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -z "$MKLROOT" ]; then
-      . /opt/intel/bin/compilervars.sh intel64
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/bin/compilervars.sh intel64
+    fi
 fi
diff --git a/cfg/spring/compilers.profile b/cfg/spring/compilers.profile
index f8c5c50..04874c0 100644
--- a/cfg/spring/compilers.profile
+++ b/cfg/spring/compilers.profile
@@ -1,18 +1,9 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -n "$BASH_VERSION" ]; then
-      . /opt/intel/bin/compilervars.sh intel64 # mets intel mpi par defaut!
-fi
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/bin/compilervars.sh intel64 # mets intel mpi par defaut!
+    fi
+fi
\ No newline at end of file
diff --git a/cfg/thorgal/intelCommunity.bashrc b/cfg/thorgal/intelCommunity.bashrc
index 09fe18c..a81955c 100644
--- a/cfg/thorgal/intelCommunity.bashrc
+++ b/cfg/thorgal/intelCommunity.bashrc
@@ -1,17 +1,6 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -z "$MKLROOT" ]; then
     . /opt/intel/mkl/bin/mklvars.sh intel64
diff --git a/cfg/thorgal/intelCommunity.profile b/cfg/thorgal/intelCommunity.profile
index 2501156..e5d1ff5 100644
--- a/cfg/thorgal/intelCommunity.profile
+++ b/cfg/thorgal/intelCommunity.profile
@@ -1,19 +1,10 @@
 # Intel compiler and/or TBB/MKL 
 #
-# EXPLANATIONS [RB]:
-# In practise, the call to "compilervars.sh" or ("mklvars.sh", etc) should be done in .profile 
-#  (it sets PATH, LD_LIBRARY_PATH, etc.)
-#
-# BUT, if the login shell is dash, it does not work (we cannot add an extra argument to a sourced script with dash). 
-# => we call the scripts in both places (.bashrc & .profile)
-# => the env is cleaned in "loop.sh", removing duplicates if the .profile was actually read by bash
-#
-# SPECIAL CASE: "at" job
-# => the environment is OK and kept, but "LD_LIBRARY_PATH" is set to nothing by "at"
-# => the .profile is then rerun manually in our scripts (with bash)
-# => duplicates are finally removed by loop.sh
+# EXPLANATIONS [RB]: (see "cfg/garfield/compilers.*")
 
 if [ -n "$BASH_VERSION" ]; then
-      . /opt/intel/mkl/bin/mklvars.sh intel64
-      . /opt/intel/tbb/bin/tbbvars.sh intel64
+    if [ -d /opt/intel ] ; then
+        . /opt/intel/mkl/bin/mklvars.sh intel64
+        . /opt/intel/tbb/bin/tbbvars.sh intel64
+    fi
 fi
-- 
GitLab