homebrew-core/Formula/opencoarrays.rb
2019-03-22 10:01:23 +08:00

51 lines
1.7 KiB
Ruby

class Opencoarrays < Formula
desc "Open-source coarray Fortran ABI, API, and compiler wrapper"
homepage "http://opencoarrays.org"
url "https://github.com/sourceryinstitute/OpenCoarrays/releases/download/2.6.1/OpenCoarrays-2.6.1.tar.gz"
sha256 "c0072a82cb2ca38de655bc6b6cd21559d12b27fc1a5635f45ac678e5c57e2f80"
head "https://github.com/sourceryinstitute/opencoarrays.git"
bottle do
cellar :any
sha256 "5a7462278ab992253d628e4db461bd559605cd9a807517acee38e9e1f2e76be3" => :mojave
sha256 "a94a0e4574a162948c1941a952a69a3aa848976fc6a2140bb4128b0d23097231" => :high_sierra
sha256 "0793dc8c6b22ebfed3996c46506f29fdb35f16a972be1ebb54226fb3898ec0a3" => :sierra
end
depends_on "cmake" => :build
depends_on "gcc"
depends_on "open-mpi"
def install
mkdir "build" do
system "cmake", "..", *std_cmake_args
system "make"
system "make", "install"
end
end
test do
(testpath/"tally.f90").write <<~EOS
program main
use iso_c_binding, only : c_int
use iso_fortran_env, only : error_unit
implicit none
integer(c_int) :: tally
tally = this_image() ! this image's contribution
call co_sum(tally)
verify: block
integer(c_int) :: image
if (tally/=sum([(image,image=1,num_images())])) then
write(error_unit,'(a,i5)') "Incorrect tally on image ",this_image()
error stop 2
end if
end block verify
! Wait for all images to pass the test
sync all
if (this_image()==1) write(*,*) "Test passed"
end program
EOS
system "#{bin}/caf", "tally.f90", "-o", "tally"
system "#{bin}/cafrun", "-np", "3", "--oversubscribe", "./tally"
end
end