From 154870da0ba237b8b94b721d2bc8a4d9f68883dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Edoardo=20Apr=C3=A0?= <edoardo.apra@gmail.com>
Date: Fri, 31 Jul 2020 08:45:27 -0700
Subject: [PATCH] NWChem 7.0.0 (#17779)

* NWChem 7.0.0

* add python2 for 6.8.1. removed 6.8 https://github.com/spack/spack/pull/17779#discussion_r462700413

* nwchem 6.8.1 breaks with gcc 10 and later

* restored extra python bits for version 6.8.1. add env. definition of basis libraries

* changes for flake8

* url fixed

* prevent 6.8.1 being compiled with gcc 10
---
 .../repos/builtin/packages/nwchem/package.py  | 33 ++++++++++++-------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/var/spack/repos/builtin/packages/nwchem/package.py b/var/spack/repos/builtin/packages/nwchem/package.py
index afc1451c0d..5bcc98cb19 100644
--- a/var/spack/repos/builtin/packages/nwchem/package.py
+++ b/var/spack/repos/builtin/packages/nwchem/package.py
@@ -11,22 +11,23 @@
 class Nwchem(Package):
     """High-performance computational chemistry software"""
 
-    homepage = "http://www.nwchem-sw.org"
-    url      = "http://www.nwchem-sw.org/images/Nwchem-6.6.revision27746-src.2015-10-20.tar.gz"
+    homepage = "http://nwchemgit.github.io"
+    url      = "https://github.com/nwchemgit/nwchem/releases/download/v7.0.0-release/nwchem-7.0.0-release.revision-2c9a1c7c-srconly.2020-02-26.tar.bz2"
 
     tags = ['ecp', 'ecp-apps']
 
+    version('7.0.0', sha256='e3c6510627345be596f4079047e5e7b59e6c20599798ecfe122e3527f8ad6eb0',
+            url='https://github.com/nwchemgit/nwchem/releases/download/v7.0.0-release/nwchem-7.0.0-release.revision-2c9a1c7c-srconly.2020-02-26.tar.bz2')
     version('6.8.1', sha256='fd20f9ca1b410270a815e77e052ec23552f828526cd252709f798f589b2a6431',
             url='https://github.com/nwchemgit/nwchem/releases/download/6.8.1-release/nwchem-6.8.1-release.revision-v6.8-133-ge032219-srconly.2018-06-14.tar.bz2')
-    version('6.8', sha256='8401d9f4cce2f653a38639df61260b06be580ff0e1b8d77ed3262da159b372a6',
-            url='https://github.com/nwchemgit/nwchem/archive/v6.8-release.tar.gz')
 
     depends_on('blas')
     depends_on('lapack')
     depends_on('mpi')
     depends_on('scalapack')
-
-    depends_on('python@2.7:2.8', type=('build', 'link', 'run'))
+    depends_on('python@3:', when='@7:', type=('build', 'link', 'run'))
+    depends_on('python@2.7:2.8', when='@:6', type=('build', 'link', 'run'))
+    conflicts('%gcc@10:', when='@:6', msg='NWChem versions prior to 7.0.0 do not build with GCC 10')
 
     # first hash is sha256 of the patch (required for URL patches),
     # second is sha256 for the archive.
@@ -72,18 +73,20 @@ def install(self, spec, prefix):
             'CC=%s' % os.path.basename(spack_cc),
             'FC=%s' % os.path.basename(spack_fc),
             'USE_MPI=y',
-            'MPI_LOC=%s' % spec['mpi'].prefix,
-            'USE_PYTHONCONFIG=y',
             'PYTHONVERSION=%s' % spec['python'].version.up_to(2),
-            'PYTHONHOME=%s' % spec['python'].home,
             'BLASOPT=%s' % ((lapack + blas).ld_flags),
             'BLAS_LIB=%s' % blas.ld_flags,
             'LAPACK_LIB=%s' % lapack.ld_flags,
-            'USE_SCALAPACK=y',
-            'SCALAPACK=%s' % scalapack.ld_flags,
+            'SCALAPACK_LIB=%s' % scalapack.ld_flags,
             'NWCHEM_MODULES=all python',
             'NWCHEM_LONG_PATHS=Y'  # by default NWCHEM_TOP is 64 char max
         ])
+        if spec.version < Version('7.0.0'):
+            args.extend([
+                'PYTHONVERSION=%s' % spec['python'].version.up_to(2),
+                'PYTHONHOME=%s' % spec['python'].home,
+                'USE_PYTHONCONFIG=Y',
+            ])
 
         # TODO: query if blas/lapack/scalapack uses 64bit Ints
         # A flag to distinguish between 32bit and 64bit integers in linear
@@ -155,3 +158,11 @@ def install(self, spec, prefix):
             with open(".nwchemrc", 'w') as f:
                 f.write(nwchemrc)
             install(".nwchemrc", share_path)
+
+    def setup_run_environment(self, env):
+        env.set('NWCHEM_BASIS_LIBRARY', join_path(
+            self.prefix,
+            'share/nwchem/libraries/'))
+        env.set('NWCHEM_NWPW_LIBRARY', join_path(
+            self.prefix,
+            'share/nwchem/libraryps/'))
-- 
GitLab