From c0bdc372266c53a078f32f910abe25c05848a74c Mon Sep 17 00:00:00 2001
From: Piotr Sacharuk <107190444+PiotrSacharuk@users.noreply.github.com>
Date: Fri, 7 Feb 2025 19:56:04 +0100
Subject: [PATCH] nwchem: add master (#48919)

* Add possibility to build nwchem from master branch

* add oneapi@2025: patch for @7.2.3

---------

Co-authored-by: eugeneswalker <eugenesunsetwalker@gmail.com>
---
 .../builtin/packages/nwchem/oneapi2025.patch  | 36 +++++++++++++++++++
 .../repos/builtin/packages/nwchem/package.py  |  6 ++++
 2 files changed, 42 insertions(+)
 create mode 100644 var/spack/repos/builtin/packages/nwchem/oneapi2025.patch

diff --git a/var/spack/repos/builtin/packages/nwchem/oneapi2025.patch b/var/spack/repos/builtin/packages/nwchem/oneapi2025.patch
new file mode 100644
index 00000000000..2b536525630
--- /dev/null
+++ b/var/spack/repos/builtin/packages/nwchem/oneapi2025.patch
@@ -0,0 +1,36 @@
+diff -ruN spack-src/src/config/makefile.h spack-src-patched/src/config/makefile.h
+--- spack-src/src/config/makefile.h	2024-08-28 02:30:22.000000000 +0000
++++ spack-src-patched/src/config/makefile.h	2025-02-07 16:03:07.315882016 +0000
+@@ -2364,15 +2364,14 @@
+ 		    _GOTAVX2 := $(shell cat /proc/cpuinfo | grep fma | tail -n 1 | awk ' /fma/  {print "Y"}')
+ 		    _GOTAVX512F := $(shell cat /proc/cpuinfo | grep avx512f | tail -n 1 | awk ' /avx512f/  {print "Y"}')
+                 endif
+-		_IFCE := $(shell ifort -V  2>&1 |head -1 |awk ' /64/ {print "Y";exit};')
+-		_IFCV7 := $(shell ifort -v  2>&1|grep "Version "|head -n 1|awk ' /7./  {print "Y";exit}')
+-		_IFCV11 := $(shell ifort -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 11) {print "Y";exit}}')
+-		_IFCV12 := $(shell ifort -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 12) {print "Y";exit}}')
+-		_IFCV14 := $(shell ifort -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 14) {print "Y";exit}}')
+-		_IFCV15ORNEWER := $(shell ifort -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 15) {print "Y";exit}}')
+-	       _IFCV17 := $(shell ifort -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 17) {print "Y";exit}}')
+-	       _IFCV18 := $(shell ifort -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 18) {print "Y";exit}}')
+-
++                _IFCE := $(shell $(FC) -V  2>&1 |head -1 |awk ' /64/ {print "Y";exit};')
++		_IFCV7 := $(shell $(FC) -v  2>&1|grep "Version "|head -n 1|awk ' /7./  {print "Y";exit}')
++		_IFCV11 := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 11) {print "Y";exit}}')
++		_IFCV12 := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 12) {print "Y";exit}}')
++		_IFCV14 := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1|sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 14) {print "Y";exit}}')
++		_IFCV15ORNEWER := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 15) {print "Y";exit}}')
++	        _IFCV17 := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 17) {print "Y";exit}}')
++	        _IFCV18 := $(shell $(FC) -logo  2>&1|grep "Version "|head -n 1 | sed 's/.*Version \([0-9][0-9]\).*/\1/' | awk '{if ($$1 >= 18) {print "Y";exit}}')
+ #               Intel EM64T is required
+                 ifneq ($(_IFCE),Y)
+                     defineFCE:
+@@ -2406,7 +2405,7 @@
+ #               CPP=fpp -P
+ #
+                 ifeq ($(_IFCV15ORNEWER), Y)
+-		 IFORTVER := $(shell ifort -v 2>&1|cut -d " " -f 3)
++                 IFORTVER := $(shell $(FC) -v 2>&1|cut -d " " -f 3)
+ #                ifeq ($(IFORTVER),2021.7.0)
+ #                   $(info     )
+ #                   $(info     ifort 2021.7.0 not validated)
diff --git a/var/spack/repos/builtin/packages/nwchem/package.py b/var/spack/repos/builtin/packages/nwchem/package.py
index 222d6e5a740..de05736af60 100644
--- a/var/spack/repos/builtin/packages/nwchem/package.py
+++ b/var/spack/repos/builtin/packages/nwchem/package.py
@@ -13,11 +13,14 @@ class Nwchem(Package):
 
     homepage = "https://nwchemgit.github.io"
     url = "https://github.com/nwchemgit/nwchem/releases/download/v7.2.0-release/nwchem-7.2.0-release.revision-d0d141fd-srconly.2023-03-10.tar.bz2"
+    git = "https://github.com/nwchemgit/nwchem.git"
 
     tags = ["ecp", "ecp-apps"]
 
     maintainers("jeffhammond")
 
+    version("master", branch="master")
+
     version(
         "7.2.3",
         sha256="8cb4ec065215bc0316d8e01f67f1674a572f7d0f565c52e4a327975c04ddb6eb",
@@ -69,6 +72,9 @@ class Nwchem(Package):
         "elpa", default=False, description="Enable optimised diagonalisation routines from ELPA"
     )
 
+    # https://github.com/nwchemgit/nwchem/pull/1034
+    patch("oneapi2025.patch", when="@7.2.3 %oneapi@2025:")
+
     # This patch is for the modification of the build system (e.g. compiler flags) and
     # Fortran syntax to enable the compilation with Fujitsu compilers. The modification
     # will be merged to the next release of NWChem (see https://github.com/nwchemgit/nwchem/issues/347
-- 
GitLab