나는 아이 MPI_Comm_spawn를 사용하여 만든 부모 프로세스 사이에 통신을 MPI_Send()와 MPI_Recv()를 사용하려고 만들어 부모와 자식 프로세스 사이 MPI_Recv 아래에서 볼 수 있듯이 :사용 MPI_Send 및 MPI_Comm_spawn
는 Parent.f90
program master
use mpi
implicit none
integer :: ierr, num_procs, my_id, intercomm, i, array(10), tag
CALL MPI_INIT(ierr)
CALL MPI_COMM_RANK(MPI_COMM_WORLD, my_id, ierr)
CALL MPI_COMM_SIZE(MPI_COMM_WORLD, num_procs, ierr)
if (.not. (ierr .eq. 0)) then
print*, "S.Unable to initilaize!"
stop
endif
if (my_id .eq. 0) then
call MPI_Comm_spawn("./child.out", MPI_ARGV_NULL, 1, MPI_INFO_NULL, my_id, &
& MPI_COMM_WORLD, intercomm, MPI_ERRCODES_IGNORE, ierr)
call MPI_Send(array, 255, MPI_INTEGER, my_id, tag, intercomm, ierr)
endif
call MPI_Finalize(ierr)
end program master
Child.f90 위의 프로그램이 실행
program name
use mpi
implicit none
! type declaration statements
integer :: ierr, parent, my_id, n_procs, i, array(10), tag, intercomm
logical :: flag, high
! executable statements
call MPI_Init(ierr)
call MPI_Initialized(flag, ierr)
call MPI_Comm_get_parent(parent, ierr)
call MPI_Comm_rank(MPI_COMM_WORLD, my_id, ierr)
call MPI_Comm_size(MPI_COMM_WORLD, n_procs, ierr)
print *, "Initilaized? ", flag
print *, "My mommy is: ", parent
print *, "My rank is:", my_id
tag = 1
call MPI_Recv(array, 255, MPI_INTEGER, MPI_ANY_SOURCE, tag, parent, MPI_STATUS_IGNORE, ierr)
print *, "Client received array."
call MPI_Finalize(ierr)
end program name
, 부모 잘 통해 실행하는 것,하지만 아이는 결코 프린터 용 소비하지 ts : "클라이언트가 배열을 받았다."나는 send/recv로 무언가를 엉망으로 만들었다는 것을 알게 해주었습니다.
내가 달성하고자하는 것이 명확하지 않은 경우 부모에게 자식을 생성하고 그 자식에게 배열을 보내려면 자식을 배열을 처리하고 자식이 배열을 부모에게 다시 보내도록합니다.. , 순간
(이탤릭체가 아직 내가 처음 작업이 기본 통신을 얻으려면, 기록 될 것입니다) 나는 실행하면 mpiexec -np 1 parent.out
, 아이 인쇄 :
Initilaized? T
My mommy is: 3
My rank is: 0
하지만 "클라이언트받은 배열을. "