Topic: Using OpenMPI

Hi all,

Is it possible to use Openmpi on Windows and within Simple Fortran:

Please see the code below. It is from "Modern Fortran" by Milan Curcic (Listing 1.2).

Or should this be implemented with OpenMP and how?

program array_copy_mpi

  use mpi
  implicit none

  integer :: ierr, nproc, procsize, request
  integer :: stat(mpi_status_size)

  integer :: array(5) = 0
  integer, parameter :: sender = 0, receiver = 1

  call mpi_init(ierr)
  call mpi_comm_rank(mpi_comm_world, nproc, ierr)
  call mpi_comm_size(mpi_comm_world, procsize, ierr)

  if (procsize /= 2) then
    call mpi_finalize(ierr)
    stop 'Error: This program must be run on 2 parallel processes'
  end if

  if (nproc == sender) array = [1, 2, 3, 4, 5]

  print '(a,i1,a,5(4x,i2))', 'array on proc ', nproc, &
    ' before copy:', array

  call mpi_barrier(mpi_comm_world, ierr)

  if (nproc == sender) then
    call mpi_isend(array, size(array), mpi_int, receiver, 1, &
                   mpi_comm_world, request, ierr)
  else if (nproc == receiver) then
    call mpi_irecv(array, size(array), mpi_int, sender, 1, &
                   mpi_comm_world, request, ierr)
    call mpi_wait(request, stat, ierr)
  end if

  print '(a,i1,a,5(4x,i2))', 'array on proc ', nproc, &
    ' after copy: ', array

  call mpi_finalize(ierr)

end program array_copy_mpi

Re: Using OpenMPI

It is possible to use Microsoft MPI with Simply Fortran, but we don't include it with Simply Fortran's installer due to licensing issues.  Additionally, Microsoft MPI is somewhat lagging in terms of the standard. 

So yes, that program should work, but you would need MS MPI set up first to work with Simply Fortran.  OpenMP or using Fortran Coarrays directly on Windows is definitely preferable.

Jeff Armstrong
Approximatrix, LLC

Re: Using OpenMPI

Thank you for the feedback, Jeff.

If I had a Linux version of Simple Fortran would I then be able to use OpenMPI?

Re: Using OpenMPI

If your Linux distribution supports Open MPI, then yes, you could use it from Simply Fortran.  The Linux version of Simply Fortran will use the system's Fortran compiler and libraries, so it would depend on the distribution.

Jeff Armstrong
Approximatrix, LLC