1

I have a very basic Fortran program to try to learn MPI. I'm compiling this script using Visual Studio 2019, MPICH2 and the Intel oneAPI Toolkit. The program is the following

program hello
implicit none 
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, "says Hello World!"

call MPI_BARRIER(MPI_COMM_WORLD, ierror)

call MPI_FINALIZE(ierror)

! here

end program hello

This program compiles and runs as expected, producing the output

PS C:\Users\gf715\Documents\VS_testing\test\Debug> mpiexec -n 4 test.exe
 node           1 says Hello World
 node           2 says Hello World
 node           3 says Hello World
 node           0 says Hello World

However, if I add a stop statement before ending the program (where I have written the "here" comment), the code will still compile, but now produces no output when I run it:

PS C:\Users\gf715\Documents\VS_testing\test\Debug> mpiexec -n 4 test.exe
PS C:\Users\gf715\Documents\VS_testing\test\Debug>

I don't remember having this problem before I used the Intel oneAPI toolkit (I used to use the same setup, but with Parallel Studio XE Cluster Edition, I was forced to change when my license expired). Why does the stop prevent any output?

mgmf46
  • 145
  • 1
  • 1
  • 10
  • Some Fortran compilers print immediately to standard output and some are buffered. I suggest flushing the output buffer before the stop command. – Dan Sp. Apr 07 '21 at 15:29
  • How do I flush the output buffer? I'm using the ifort compiler – mgmf46 Apr 07 '21 at 15:33
  • Flushing stdout did not fix the issue – mgmf46 Apr 07 '21 at 15:43
  • Could you show the exact code you are using, please? If you don't everything we say is a guess. I can see that the program above can not be the one you are compiling because you have Implicit None in scope, but you don't declare the variable ierror. Please show both versions of the code. – Ian Bush Apr 07 '21 at 16:21
  • Sorry, this was a typo. It should have ierror in the declaration rather than error. I've corrected this in the question. This is the exact code I'm using – mgmf46 Apr 07 '21 at 16:30

1 Answers1

2

Answering my own question. This is due to having multiple versions of the Intel Compiler on a computer (see here)

I fixed this by uninstalling the old version and updating the new compilers, but there seem to be easier ways.

Nike
  • 1,223
  • 2
  • 19
  • 42
mgmf46
  • 145
  • 1
  • 1
  • 10