Skip to content

Commit

Permalink
hdf5: update to use parallel version of hdf5
Browse files Browse the repository at this point in the history
hdf5 parallel is required for certain applications and should not conflict with serial applications as they are part of the same source code.
  • Loading branch information
abhinavsns committed Apr 2, 2024
1 parent 6d88eee commit e8112c7
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions Formula/h/hdf5.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,33 @@ class Hdf5 < Formula
depends_on "cmake" => :build
depends_on "gcc" # for gfortran
depends_on "libaec"
depends_on "open-mpi" # for parallel support
depends_on "pkg-config"

uses_from_macos "zlib"

conflicts_with "hdf5-mpi", because: "hdf5-mpi is a variant of hdf5, one can only use one or the other"

def install
ENV["libaec_DIR"] = Formula["libaec"].opt_prefix.to_s
# Work around incompatibility with new linker (FB13194355)
# https://github.com/HDFGroup/hdf5/issues/3571
ENV.append "LDFLAGS", "-Wl,-ld_classic" if DevelopmentTools.clang_build_version >= 1500
args = %w[
-DHDF5_USE_GNU_DIRS:BOOL=ON
-DHDF5_INSTALL_CMAKE_DIR=lib/cmake/hdf5
-DHDF5_BUILD_FORTRAN:BOOL=ON
-DHDF5_BUILD_CPP_LIB:BOOL=ON
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON
-DHDF5_ENABLE_PARALLEL:BOOL=ON
-DALLOW_UNSUPPORTED:BOOL=ON
-DCMAKE_C_COMPILER=mpicc
-DCMAKE_CXX_COMPILER=mpic++
-DCMAKE_FC_COMPILER=mpifort
-DCMAKE_F77_COMPILER=mpif77
-DCMAKE_F90_COMPILER=mpif90
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args

# Avoid c shims in settings files
inreplace_c_files = %w[
build/src/H5build_settings.c
build/src/libhdf5.settings
build/CMakeFiles/h5cc
build/CMakeFiles/h5hlcc
]
inreplace inreplace_c_files, Superenv.shims_path/ENV.cc, ENV.cc

# Avoid cpp shims in settings files
inreplace_cxx_files = %w[
build/CMakeFiles/h5c++
build/CMakeFiles/h5hlc++
]
inreplace_cxx_files << "build/src/libhdf5.settings" if OS.linux?
inreplace inreplace_cxx_files, Superenv.shims_path/ENV.cxx, ENV.cxx

system "cmake", "--build", "build"
system "cmake", "--install", "build"
end
Expand All @@ -78,6 +71,8 @@ def install
EOS
system "#{bin}/h5cc", "test.c"
assert_equal version.to_s, shell_output("./a.out").chomp
system "#{bin}/h5pcc", "test.c"
assert_equal version.to_s, shell_output("./a.out").chomp

(testpath/"test.f90").write <<~EOS
use hdf5
Expand Down Expand Up @@ -107,6 +102,7 @@ def install
end
EOS
system bin/"h5fc", "test.f90"
system "#{bin}/h5pfc", "test.f90"
assert_equal version.to_s, shell_output("./a.out").chomp

# Make sure that it was built with SZIP/libaec
Expand Down

0 comments on commit e8112c7

Please sign in to comment.