class OpenMpi < Formula desc "High performance message passing library" homepage "https://www.open-mpi.org/" url "https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-4.0.1.tar.bz2" sha256 "cce7b6d20522849301727f81282201d609553103ac0b09162cf28d102efb9709" revision 2 bottle do rebuild 1 sha256 "a1e1363f461531508564a90ddbf787c4d3e265bc581f1ec9ad4e5ce0034a63f4" => :catalina sha256 "322c39684795f8eaf9e8f342528ecc119aa65566db10963272b975e9c6f31018" => :mojave sha256 "c2a5846928bb13ccf83513f1db65ed79f8499d75cb51da655f8fb4f49ac787bd" => :high_sierra sha256 "ff6a8d0b903ddbd716a33ee4669f80d12bcaa59eb11862614efaf92092c68d41" => :sierra end head do url "https://github.com/open-mpi/ompi.git" depends_on "autoconf" => :build depends_on "automake" => :build depends_on "libtool" => :build end depends_on "gcc" depends_on "hwloc" depends_on "libevent" conflicts_with "mpich", :because => "both install MPI compiler wrappers" def install # otherwise libmpi_usempi_ignore_tkr gets built as a static library ENV["MACOSX_DEPLOYMENT_TARGET"] = MacOS.version ENV.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? # Fixes an issue in 4.0.0, should be fixed in 4.0.1 args << "--enable-mpi1-compatibility" system "./autogen.pl" if build.head? system "./configure", *args system "make", "all" system "make", "check" system "make", "install" # Fortran bindings install stray `.mod` files (Fortran modules) in `lib` # that need to be moved to `include`. include.install Dir["#{lib}/*.mod"] end test do (testpath/"hello.c").write <<~EOS #include #include 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", "./hello" (testpath/"hellof.f90").write <<~EOS 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", "./hellof" end end