Skip to content

Latest commit

 

History

History
102 lines (82 loc) · 5.02 KB

GETTING_STARTED.md

File metadata and controls

102 lines (82 loc) · 5.02 KB

Getting Started

Download as PDF

Download this file as a PDF document here.

The caf compiler wrapper

The preferred method for compiling a CAF program is by invoking the caf bash script that the OpenCoarrays CMake scripts install in the bin subdirectory of the installation path. This is an experimental script with limited but useful capabilities that will grow over time. Please submit bug reports and feature requests via our Issues page.

The caf script liberates the source code and workflow from explicit dependence on the underlying compiler and communication library by passing the unmodified source code to the compiler with the necessary arguments for building a parallel Fortran 2018 program, embedding the paths to OpenCoarrays libraries (e.g., libcaf_mpi.a) installed in the lib subdirectory of the OpenCoarrays installation path.

A sample basic workflow

The following program listing, compilation, and execution workflow exemplify the use of OpenCoarrays with GCC in a Linux bash shell with the bin directory of the chosen installation path in the user's PATH environment variable:

$ cat tally.f90
      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
          end if
        end block verify
        ! Wait for all images to pass the test
        sync all
        if (this_image()==1) print *,"Test passed"
      end program
$ caf tally.f90 -o tally
$ cafrun -np 4 ./tally
        Test passed

where "4" is the number of images to be launched at program start-up.

An advanced workflow

If you prefer to invoke the compiler directly, first run caf and cafrun with the --show flag to see the proper linking and file includes. For example, on a macOS system where OpenCoarrays was installed via the homebrew package manager, the following results:

$ caf --show
/usr/local/bin/gfortran -I/usr/local/Cellar/opencoarrays/2.2.0/include/OpenCoarrays-2.2.0_GNU-8.2.0 -fcoarray=lib -Wl,-flat_namespace -Wl,-commons,use_dylibs -L/usr/local/Cellar/libevent/2.1.8/lib -L/usr/local/Cellar/open-mpi/3.1.1/lib ${@} /usr/local/Cellar/opencoarrays/2.2.0/lib/libcaf_mpi.a /usr/local/lib/libmpi_usempif08.dylib /usr/local/lib/libmpi_usempi_ignore_tkr.dylib /usr/local/lib/libmpi_mpifh.dylib /usr/local/lib/libmpi.dylib
$ cafrun --show
/usr/local/bin/mpiexec -n <number_of_images> /path/to/coarray_Fortran_program [arg4 [arg5 [...]]]

GitHub forks GitHub stars GitHub watchers Twitter URL