105 lines
3.4 KiB
Ruby
105 lines
3.4 KiB
Ruby
class OpenMpi < Formula
|
|
desc "High performance message passing library"
|
|
homepage "https://www.open-mpi.org/"
|
|
url "https://www.open-mpi.org/software/ompi/v1.10/downloads/openmpi-1.10.2.tar.bz2"
|
|
sha256 "8846e7e69a203db8f50af90fa037f0ba47e3f32e4c9ccdae2db22898fd4d1f59"
|
|
revision 1
|
|
|
|
bottle do
|
|
sha256 "9b815d259c57b232084c2c340bf94d249b2c8cd04ea44e49daa220c83519563d" => :el_capitan
|
|
sha256 "30a575dbb5d9e0984dd3d830acd21ef27f21a3287a8379fb42fb7917d70e9a00" => :yosemite
|
|
sha256 "47e51682109dedc1ea793174385a12489a3ca4aeec94fb86c71d6b9ecb75c891" => :mavericks
|
|
end
|
|
|
|
head do
|
|
url "https://github.com/open-mpi/ompi.git"
|
|
depends_on "automake" => :build
|
|
depends_on "autoconf" => :build
|
|
depends_on "libtool" => :build
|
|
end
|
|
|
|
deprecated_option "disable-fortran" => "without-fortran"
|
|
deprecated_option "enable-mpi-thread-multiple" => "with-mpi-thread-multiple"
|
|
|
|
option "with-mpi-thread-multiple", "Enable MPI_THREAD_MULTIPLE"
|
|
option :cxx11
|
|
|
|
conflicts_with "mpich", :because => "both install mpi__ compiler wrappers"
|
|
conflicts_with "lcdf-typetools", :because => "both install same set of binaries."
|
|
|
|
depends_on :fortran => :recommended
|
|
depends_on "libevent"
|
|
depends_on :java => :optional
|
|
|
|
def install
|
|
ENV.cxx11 if build.cxx11?
|
|
|
|
args = %W[
|
|
--prefix=#{prefix}
|
|
--disable-dependency-tracking
|
|
--disable-silent-rules
|
|
--enable-ipv6
|
|
--with-libevent=#{Formula["libevent"].opt_prefix}
|
|
--with-sge
|
|
]
|
|
args << "--with-platform-optimized" if build.head?
|
|
args << "--disable-mpi-fortran" if build.without? "fortran"
|
|
args << "--enable-mpi-thread-multiple" if build.with? "mpi-thread-multiple"
|
|
args << "--enable-mpi-java" if build.with? "java"
|
|
|
|
system "./autogen.pl" if build.head?
|
|
system "./configure", *args
|
|
system "make", "all"
|
|
system "make", "check"
|
|
system "make", "install"
|
|
|
|
# If Fortran bindings were built, there will be stray `.mod` files
|
|
# (Fortran header) in `lib` that need to be moved to `include`.
|
|
if build.with? "fortran"
|
|
include.install Dir["#{lib}/*.mod"]
|
|
end
|
|
|
|
if build.stable?
|
|
# Move vtsetup.jar from bin to libexec.
|
|
libexec.install bin/"vtsetup.jar"
|
|
inreplace bin/"vtsetup", "$bindir/vtsetup.jar", "$prefix/libexec/vtsetup.jar"
|
|
end
|
|
end
|
|
|
|
test do
|
|
(testpath/"hello.c").write <<-EOS.undent
|
|
#include <mpi.h>
|
|
#include <stdio.h>
|
|
|
|
int main()
|
|
{
|
|
int size, rank, nameLen;
|
|
char name[MPI_MAX_PROCESSOR_NAME];
|
|
MPI_Init(NULL, NULL);
|
|
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
|
|
MPI_Get_processor_name(name, &nameLen);
|
|
printf("[%d/%d] Hello, world! My name is %s.\\n", rank, size, name);
|
|
MPI_Finalize();
|
|
return 0;
|
|
}
|
|
EOS
|
|
system "#{bin}/mpicc", "hello.c", "-o", "hello"
|
|
system "./hello"
|
|
system "#{bin}/mpirun", "-np", "4", "./hello"
|
|
(testpath/"hellof.f90").write <<-EOS.undent
|
|
program hello
|
|
include 'mpif.h'
|
|
integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)
|
|
call MPI_INIT(ierror)
|
|
call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
|
|
call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)
|
|
print*, 'node', rank, ': Hello Fortran world'
|
|
call MPI_FINALIZE(ierror)
|
|
end
|
|
EOS
|
|
system "#{bin}/mpif90", "hellof.f90", "-o", "hellof"
|
|
system "./hellof"
|
|
system "#{bin}/mpirun", "-np", "4", "./hellof"
|
|
end
|
|
end
|