73 lines
2.6 KiB
Ruby
73 lines
2.6 KiB
Ruby
class Pnetcdf < Formula
|
|
desc "Parallel netCDF library for scientific data using the OpenMPI library"
|
|
homepage "https://parallel-netcdf.github.io/index.html"
|
|
url "https://parallel-netcdf.github.io/Release/pnetcdf-1.12.1.tar.gz"
|
|
sha256 "56f5afaa0ddc256791c405719b6436a83b92dcd5be37fe860dea103aee8250a2"
|
|
license "NetCDF"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "89fe221a5cfb46dac697259ace423488721524a62cf9753e2f2b0824a5092316" => :catalina
|
|
sha256 "ca2024aecf06507fa3f5018773f59aaa2b6be3291107b73565002f19ed0def02" => :mojave
|
|
sha256 "218b5b009bb564ed50117a0ad5842ee2d20b4b29cc134587fd5e30a3e703412b" => :high_sierra
|
|
end
|
|
|
|
depends_on "gcc"
|
|
depends_on "open-mpi"
|
|
|
|
def install
|
|
system "./configure", "--disable-debug",
|
|
"--disable-dependency-tracking",
|
|
"--disable-silent-rules",
|
|
"--prefix=#{prefix}",
|
|
"--enable-shared",
|
|
# Fix for GCC 10, remove in next version
|
|
# https://github.com/Parallel-NetCDF/PnetCDF/pull/63
|
|
"FFLAGS=-fallow-argument-mismatch",
|
|
"FCFLAGS=-fallow-argument-mismatch"
|
|
system "make", "install"
|
|
end
|
|
|
|
# These tests were converted from the netcdf formula.
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <stdio.h>
|
|
#include "pnetcdf.h"
|
|
int main()
|
|
{
|
|
printf(PNETCDF_VERSION);
|
|
return 0;
|
|
}
|
|
EOS
|
|
system ENV.cc, "test.c", "-L#{lib}", "-I#{include}", "-lpnetcdf",
|
|
"-o", "test"
|
|
assert_equal `./test`, version.to_s
|
|
|
|
(testpath/"test.f90").write <<~EOS
|
|
program test
|
|
use mpi
|
|
use pnetcdf
|
|
integer :: ncid, varid, dimids(2), ierr
|
|
integer :: dat(2,2) = reshape([1, 2, 3, 4], [2, 2])
|
|
call mpi_init(ierr)
|
|
call check( nfmpi_create(MPI_COMM_WORLD, "test.nc", NF_CLOBBER, MPI_INFO_NULL, ncid) )
|
|
call check( nfmpi_def_dim(ncid, "x", 2_MPI_OFFSET_KIND, dimids(2)) )
|
|
call check( nfmpi_def_dim(ncid, "y", 2_MPI_OFFSET_KIND, dimids(1)) )
|
|
call check( nfmpi_def_var(ncid, "data", NF_INT, 2, dimids, varid) )
|
|
call check( nfmpi_enddef(ncid) )
|
|
call check( nfmpi_put_var_int_all(ncid, varid, dat) )
|
|
call check( nfmpi_close(ncid) )
|
|
call mpi_finalize(ierr)
|
|
contains
|
|
subroutine check(status)
|
|
integer, intent(in) :: status
|
|
if (status /= nf_noerr) call abort
|
|
end subroutine check
|
|
end program test
|
|
EOS
|
|
system "mpif90", "test.f90", "-L#{lib}", "-I#{include}", "-lpnetcdf",
|
|
"-o", "testf"
|
|
system "./testf"
|
|
end
|
|
end
|