67 lines
2.3 KiB
Ruby
67 lines
2.3 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"
|
|
|
|
bottle do
|
|
sha256 "04ba040b61d2c7a5418b4af93746f42a52133d18879d9a07c770ffd3f8875b91" => :catalina
|
|
sha256 "29a1ad1b500424446970fab585e2340230b146e004cc1da214cb57af1eaebc0c" => :mojave
|
|
sha256 "882f998426ba7a0a8723043e3924f349ab1601b66a1f5e8e853816c5de8edb11" => :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"
|
|
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
|