Troubles on getting started with MPI

Hey! I’ve been trying to start on parallel programming with MPI and when i try to compile using mpifort i get the message “line 376: x86_64-conda_cos6-linux-gnu-gfortran: command not found”. I’m just starting and trying to compile a pretty simple code:

program main
    implicit none

    !call mpi_f08
    include 'mpif.h'
    integer :: ierr, my_rank, nprocs

    call mpi_init(ierr)
    call mpi_comm_rank(mpi_comm_world, my_rank, ierr)
    call mpi_comm_size(mpi_comm_world, nprocs, ierr)

    write(*,*) 'Hello world from processor', my_rank, 'out of', nprocs

    call mpi_finalize(ierr)
end program main

Might be the way i installed it, i just used sudo apt-get install openmpi-bin and did nothing more. I have a ubuntu system if that helps. Thanks!

1 Like

Hi @jorvz , strange output, hopefully someone here can help.

When you manage to compile it, you will see that you have an easy syntax error to fix in your write statement. Also, it is recommended to replace the include mpif.h with use mpi_f08 (before implicit none). Unfortunately I had issues with the mpi_f08 module (Cray MPICH does not seem to support it as far as I know, and I also had issues with it when trying to profile with ARM MAP on a certain machine, in which case it may be good to just to use the mpi module (use mpi). There is also no need for the stop at the end of the program.

Your mpifort is looking for gfortran which I guess is a softlink to x86_64-conda_cos6-linux-gnu-gfortran (conda version of gfortran). Are you using Conda? If you do, I suggest installing everything through conda-forge. Not only will you find gfortran, mpich/openmpi, but also popular tools/libs like fpm, stdlib, fortls, etc. To install gfortran :

conda install -c conda-forge gfortran