I am working on a much bigger program where I struggle with MPI_Gather.
I wrote a minimal example code, see below.
program test
use MPI
integer :: ierr, rank, size
double precision, allocatable, dimension(:) :: send, recv
call MPI_Init(ierr)
call MPI_Comm_size(MPI_COMM_WORLD, size, ierr)
if (ierr /= 0) print *, 'Error in MPI_Comm_size'
call MPI_Comm_rank(MPI_COMM_WORLD, rank, ierr)
if (ierr /= 0) print *, 'Error in MPI_Comm_size'
allocate(send(1), recv(size))
send(1) = rank
call MPI_Gather(send, 1, MPI_DOUBLE_PRECISION, &
recv, 1, MPI_DOUBLE_PRECISION, 0, MPI_COMM_WORLD)
print *, recv
call MPI_Finalize(ierr)
end program test
When (with 2 nodes) I get the following error output.
[jorvik:13887] *** Process received signal ***
[jorvik:13887] Signal: Segmentation fault (11)
[jorvik:13887] Signal code: Address not mapped (1)
[jorvik:13887] Failing at address: (nil)
[jorvik:13888] *** Process received signal ***
[jorvik:13888] Signal: Segmentation fault (11)
[jorvik:13888] Signal code: Address not mapped (1)
[jorvik:13888] Failing at address: (nil)
[jorvik:13887] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x36150) [0x7f6ab77f8150]
[jorvik:13887] [ 1] /usr/lib/libmpi_f77.so.0(PMPI_GATHER+0x12d) [0x7f6ab7ebca9d]
[jorvik:13887] [ 2] ./test() [0x4011a3]
[jorvik:13887] [ 3] ./test(main+0x34) [0x401283]
[jorvik:13887] [ 4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f6ab77e376d]
[jorvik:13887] [ 5] ./test() [0x400d59]
[jorvik:13887] *** End of error message ***
[jorvik:13888] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x36150) [0x7f0ca067d150]
[jorvik:13888] [ 1] /usr/lib/libmpi_f77.so.0(PMPI_GATHER+0x12d) [0x7f0ca0d41a9d]
[jorvik:13888] [ 2] ./test() [0x4011a3]
[jorvik:13888] [ 3] ./test(main+0x34) [0x401283]
[jorvik:13888] [ 4] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7f0ca066876d]
[jorvik:13888] [ 5] ./test() [0x400d59]
[jorvik:13888] *** End of error message ***
What am I doing wrong? MPI is definitely installed and running on the machine I am using.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…