0
我不明白爲什麼下面的程序不工作。當我用「mpirun -np 2 a.out」運行它時,我期望它打印出「N:2」,但是它會給我一個seg故障。MPI_REDUCE錯誤
謝謝
main.f
program main
implicit none
include 'mpif.h'
integer me, ngs,ierror
call inimpi(me, ngs)
call calc
call mpi_finalize(ierror)
stop
end
inimpi.f
subroutine inimpi(me, ngs)
include 'mpif.h'
integer me, ngs, ierror
call mpi_init(ierror)
call mpi_comm_rank(mpi_comm_world, me, ierror)
call mpi_comm_size(mpi_comm_world, ngs, ierror)
return
end
calc.f
subroutine calc
include 'mpif.h'
integer p, e, ierror
p = 1
call mpi_reduce(p, e, 1, mpi_integer,
& mpi_sum, mpi_comm_world, ierror)
print *, "N: ", e
return
end
謝謝你指出。 – jhaprade 2013-03-18 01:32:51