From 8d90c4506d2bbcb0583766faf6ed2b59eccec702 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sebastian=20L=C3=BChrs?= <s.luehrs@fz-juelich.de>
Date: Tue, 22 Sep 2020 10:17:42 +0200
Subject: [PATCH] add netCDF to npsmpic toolchain

---
 Custom_Toolchains/compiler/nvhpc.py           |  4 +-
 .../netCDF-C++4-4.3.1-npsmpic-2020.eb         | 28 +++++++++++
 .../netCDF-Fortran-4.5.3-npsmpic-2020.eb      | 24 ++++++++++
 .../n/netCDF/netCDF-4.7.4-npsmpic-2020.eb     | 46 +++++++++++++++++++
 ...remove_double_shared_in_link_command.patch | 20 ++++++++
 .../parallel-netcdf-1.12.1-npsmpic-2020.eb    | 34 ++++++++++++++
 6 files changed, 154 insertions(+), 2 deletions(-)
 create mode 100644 Golden_Repo/n/netCDF-C++4/netCDF-C++4-4.3.1-npsmpic-2020.eb
 create mode 100644 Golden_Repo/n/netCDF-Fortran/netCDF-Fortran-4.5.3-npsmpic-2020.eb
 create mode 100644 Golden_Repo/n/netCDF/netCDF-4.7.4-npsmpic-2020.eb
 create mode 100644 Golden_Repo/n/netCDF/remove_double_shared_in_link_command.patch
 create mode 100644 Golden_Repo/p/parallel-netcdf/parallel-netcdf-1.12.1-npsmpic-2020.eb

diff --git a/Custom_Toolchains/compiler/nvhpc.py b/Custom_Toolchains/compiler/nvhpc.py
index 194939816..8aef532d0 100644
--- a/Custom_Toolchains/compiler/nvhpc.py
+++ b/Custom_Toolchains/compiler/nvhpc.py
@@ -88,8 +88,8 @@ class Nvhpc(Compiler):
     # C++ compiler command is version-dependent, see below
     COMPILER_CXX = 'nvc++'
 
-    # COMPILER_F77 = 'pgf77'
-    # COMPILER_F90 = 'pgf90'
+    COMPILER_F77 = 'nvfortran'
+    COMPILER_F90 = 'nvfortran'
     COMPILER_FC = 'nvfortran'
 
     LINKER_TOGGLE_STATIC_DYNAMIC = {
diff --git a/Golden_Repo/n/netCDF-C++4/netCDF-C++4-4.3.1-npsmpic-2020.eb b/Golden_Repo/n/netCDF-C++4/netCDF-C++4-4.3.1-npsmpic-2020.eb
new file mode 100644
index 000000000..9a7ec940e
--- /dev/null
+++ b/Golden_Repo/n/netCDF-C++4/netCDF-C++4-4.3.1-npsmpic-2020.eb
@@ -0,0 +1,28 @@
+easyblock = 'ConfigureMake'
+
+name = 'netCDF-C++4'
+version = '4.3.1'
+
+homepage = 'http://www.unidata.ucar.edu/software/netcdf/'
+description = """NetCDF (network Common Data Form) is a set of software libraries 
+ and machine-independent data formats that support the creation, access, and sharing of array-oriented 
+ scientific data.
+"""
+
+site_contacts = 's.luehrs@fz-juelich.de'
+
+toolchain = {'name': 'npsmpic', 'version': '2020'}
+toolchainopts = {'pic': True}
+
+source_urls = ['https://github.com/Unidata/netcdf-cxx4/archive/']
+sources = ['v%(version)s.tar.gz']
+checksums = ['e3fe3d2ec06c1c2772555bf1208d220aab5fee186d04bd265219b0bc7a978edc']
+
+dependencies = [('netCDF', '4.7.4')]
+
+sanity_check_paths = {
+    'files': ['include/netcdf', 'lib/libnetcdf_c++4.a', 'lib/libnetcdf_c++4.%s' % SHLIB_EXT],
+    'dirs': [],
+}
+
+moduleclass = 'data'
diff --git a/Golden_Repo/n/netCDF-Fortran/netCDF-Fortran-4.5.3-npsmpic-2020.eb b/Golden_Repo/n/netCDF-Fortran/netCDF-Fortran-4.5.3-npsmpic-2020.eb
new file mode 100644
index 000000000..1d4b92943
--- /dev/null
+++ b/Golden_Repo/n/netCDF-Fortran/netCDF-Fortran-4.5.3-npsmpic-2020.eb
@@ -0,0 +1,24 @@
+name = 'netCDF-Fortran'
+version = '4.5.3'
+
+homepage = 'http://www.unidata.ucar.edu/software/netcdf/'
+description = """NetCDF (network Common Data Form) is a set of software libraries 
+ and machine-independent data formats that support the creation, access, and sharing of array-oriented 
+ scientific data.
+"""
+
+site_contacts = 's.luehrs@fz-juelich.de'
+
+toolchain = {'name': 'npsmpic', 'version': '2020'}
+toolchainopts = {'pic': True}
+
+source_urls = [
+    'ftp://ftp.unidata.ucar.edu/pub/netcdf/',
+    'ftp://ftp.unidata.ucar.edu/pub/netcdf/old',
+]
+sources = [SOURCELOWER_TAR_GZ]
+checksums = ['123a5c6184336891e62cf2936b9f2d1c54e8dee299cfd9d2c1a1eb05dd668a74']
+
+dependencies = [('netCDF', '4.7.4')]
+
+moduleclass = 'data'
diff --git a/Golden_Repo/n/netCDF/netCDF-4.7.4-npsmpic-2020.eb b/Golden_Repo/n/netCDF/netCDF-4.7.4-npsmpic-2020.eb
new file mode 100644
index 000000000..d0fbeaeec
--- /dev/null
+++ b/Golden_Repo/n/netCDF/netCDF-4.7.4-npsmpic-2020.eb
@@ -0,0 +1,46 @@
+name = 'netCDF'
+version = '4.7.4'
+
+homepage = 'http://www.unidata.ucar.edu/software/netcdf/'
+description = """NetCDF (network Common Data Form) is a set of software libraries 
+ and machine-independent data formats that support the creation, access, and sharing of array-oriented 
+ scientific data.
+"""
+
+site_contacts = 's.luehrs@fz-juelich.de'
+
+toolchain = {'name': 'npsmpic', 'version': '2020'}
+toolchainopts = {'pic': True, 'usempi': True}
+
+source_urls = ['https://github.com/Unidata/netcdf-c/archive/']
+sources = ['v%s.tar.gz' % (version)]
+checksums = ['99930ad7b3c4c1a8e8831fb061cb02b2170fc8e5ccaeda733bd99c3b9d31666b']
+
+dependencies = [
+    ('HDF5', '1.10.6'),
+    ('cURL', '7.71.1'),
+    ('Szip', '2.1.1'),
+    ('parallel-netcdf', '1.12.1')
+]
+
+builddependencies = [
+    ('CMake', '3.18.0'),
+    ('Doxygen', '1.8.18'),
+]
+
+patches = ['remove_double_shared_in_link_command.patch']
+
+# make sure both static and shared libs are built
+configopts = [
+    "-DCURL_LIBRARY=$EBROOTCURL/lib/libcurl.so -DCURL_INCLUDE_DIR=$EBROOTCURL/include " +
+    "-DENABLE_PNETCDF=ON -DBUILD_SHARED_LIBS=ON",
+    "-DCURL_LIBRARY=$EBROOTCURL/lib/libcurl.so -DCURL_INCLUDE_DIR=$EBROOTCURL/include " +
+    "-DENABLE_PNETCDF=ON -DBUILD_SHARED_LIBS=OFF",
+]
+
+sanity_check_paths = {
+    'files': ["include/netcdf_mem.h", "include/netcdf_par.h"],
+    'dirs': [],
+}
+
+moduleclass = 'data'
diff --git a/Golden_Repo/n/netCDF/remove_double_shared_in_link_command.patch b/Golden_Repo/n/netCDF/remove_double_shared_in_link_command.patch
new file mode 100644
index 000000000..96cb9b297
--- /dev/null
+++ b/Golden_Repo/n/netCDF/remove_double_shared_in_link_command.patch
@@ -0,0 +1,20 @@
+diff -Nru netcdf-c-4.7.4.orig/liblib/CMakeLists.txt netcdf-c-4.7.4/liblib/CMakeLists.txt
+--- netcdf-c-4.7.4.orig/liblib/CMakeLists.txt	2020-09-20 20:17:25.395953767 +0200
++++ netcdf-c-4.7.4/liblib/CMakeLists.txt	2020-09-20 20:17:54.671071349 +0200
+@@ -111,11 +111,11 @@
+     )
+ ENDIF()
+ 
+-IF(NOT MSVC)
+-  IF(BUILD_SHARED_LIBS)
+-    SET_TARGET_PROPERTIES(netcdf PROPERTIES LINK_FLAGS -shared)
+-  ENDIF()
+-ENDIF()
++#IF(NOT MSVC)
++#  IF(BUILD_SHARED_LIBS)
++#    SET_TARGET_PROPERTIES(netcdf PROPERTIES LINK_FLAGS -shared)
++#  ENDIF()
++#ENDIF()
+ 
+ IF(ENABLE_SHARED_LIBRARY_VERSION)
+   SET_TARGET_PROPERTIES(netcdf PROPERTIES
diff --git a/Golden_Repo/p/parallel-netcdf/parallel-netcdf-1.12.1-npsmpic-2020.eb b/Golden_Repo/p/parallel-netcdf/parallel-netcdf-1.12.1-npsmpic-2020.eb
new file mode 100644
index 000000000..0337cfa58
--- /dev/null
+++ b/Golden_Repo/p/parallel-netcdf/parallel-netcdf-1.12.1-npsmpic-2020.eb
@@ -0,0 +1,34 @@
+easyblock = 'ConfigureMake'
+
+name = 'parallel-netcdf'
+version = '1.12.1'
+
+homepage = 'http://trac.mcs.anl.gov/projects/parallel-netcdf'
+description = """PnetCDF is a library providing high-performance parallel I/O while still maintaining file-format
+compatibility with  Unidata's NetCDF, specifically the formats of CDF-1 and CDF-2.
+
+Although NetCDF supports parallel I/O starting from version 4, the files must be in HDF5 format. PnetCDF is currently
+the only choice for carrying out parallel I/O on files that are in classic formats
+"""
+
+site_contacts = 's.luehrs@fz-juelich.de'
+
+toolchain = {'name': 'npsmpic', 'version': '2020'}
+toolchainopts = {'usempi': True, 'pic': True}
+
+source_urls = ['https://parallel-netcdf.github.io/Release/']
+sources = ['pnetcdf-%(version)s.tar.gz']
+checksums = ['56f5afaa0ddc256791c405719b6436a83b92dcd5be37fe860dea103aee8250a2']
+
+configopts = '--enable-shared'
+
+builddependencies = [
+    ('M4', '1.4.18'),
+]
+
+sanity_check_paths = {
+    'files': ['include/pnetcdf.h', 'include/pnetcdf.inc', 'include/pnetcdf.mod', 'lib/libpnetcdf.a'],
+    'dirs': [],
+}
+
+moduleclass = 'data'
-- 
GitLab