2017-02-09 9 views
0

나는 병렬 코드 작성/실행에 상당히 익숙하다. 현재 저는 프로세스에 대한 느낌을 얻기 위해 병렬 코드를 작성하는 기본 자습서를 실험하고 있습니다. 내 컴퓨터는 Mpich와 함께 우분투를 사용하고 있습니다. 나는 제목의 코드를 실행하려고하고MPI_Send, 유효하지 않은 태그의 치명적 오류

이 페이지의 "벡터를 요약하는 완전한 병렬 프로그램"http://condor.cc.ku.edu/~grobe/docs/intro-MPI.shtml

및/입력 번호를 입력하라는 메시지가 후 실행시 다음과 같은 오류가 발생하고있다 :

sumvecp.f90:41:23: 

    call mpi_send(vector(start_row),num_rows_to_send, mpi_real, an_id, send_data_tag, mpi_comm_world,ierr) 
         1 
Warning: Legacy Extension: REAL array index at (1) 

이 내 코드

된다 컴파일하는 동안
Fatal error in MPI_Send: Invalid tag, error stack: 
MPI_Send(174): MPI_Send(buf=0x7ffeab0f2d3c, count=1, MPI_INT, dest=1, tag=1157242880, MPI_COMM_WORLD) failed 
MPI_Send(101): Invalid tag, value is 1157242880 

나는 또한 경고 메시지

program sumvecp 

include '/usr/include/mpi/mpif.h' 

parameter (max_rows = 10000000) 
parameter (send_data_tag = 2001, return_data_tag = 2002) 

integer my_id, root_proces, ierr, status(mpi_status_size) 
integer num_procs, an_id, num_rows_to_receive 
integer avg_rows_per_process, num_rows,num_rows_to_send 

real vector(max_rows), vector2(max_rows), partial_sum, sum 


root_process = 0 

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 (my_id .eq. root_process) then 
    print *, "please enter the number of numbers to sum: " 
    read *, num_rows 
    if (num_rows .gt. max_rows) stop "Too many numbers." 

    avg_rows_per_process = num_rows/num_procs 

    do ii = 1,num_rows 
     vector(ii) = float(ii) 
    end do 

    do an_id = 1, num_procs -1 
     start_row = (an_id*avg_rows_per_process) +1 
     end_row = start_row + avg_rows_per_process -1 
     if (an_id .eq. (num_procs - 1)) end_row = num_rows 
     num_rows_to_send = end_row - start_row + 1 

     call mpi_send(num_rows_to_send, 1, mpi_int, an_id, send_data_tag, mpi_comm_world,ierr) 

     call mpi_send(vector(start_row),num_rows_to_send, mpi_real, an_id, send_data_tag, mpi_comm_world,ierr) 
    end do 

    summ = 0.0 
    do ii = 1, avg_rows_per_process 
     summ = summ + vector(ii) 
    end do 

    print *,"sum", summ, "calculated by the root process." 

    do an_id =1, num_procs -1 
     call mpi_recv(partial_sum, 1, mpi_real, mpi_any_source, mpi_any_tag, mpi_comm_world, status, ierr) 

     sender = status(mpi_source) 
     print *, "partial sum", partial_sum, "returned from process", sender 
     summ = summ + partial_sum 
    end do 

    print *, "The grand total is: ", sum 

else 
    call mpi_recv(num_rows_to_receive, 1, mpi_int, root_process, mpi_any_tag, mpi_comm_world,status,ierr) 

    call mpi_recv(vector2,num_rows_to_received, mpi_real,root_process,mpi_any_tag,mpi_comm_world,status,ierr) 

    num_rows_received = num_rows_to_receive 

    partial_sum = 0.0 
    do ii=1,num_rows_received 
     partial_sum = partial_sum + vector2(ii) 
    end do 

    call mpi_send(partial_sum,1,mpi_real,root_process,return_data_tag,mpi_comm_world,ierr) 
endif 

call mpi_finalize(ierr) 
stop 
end 

답변

1

IMPLICIT NONE이 누락되어 있으며 선언되지 않은 변수가 많이 있습니다.

send_data_tag = 2001, return_data_tag = 2002 

암시 real 변수가 아닌 integer들 때문에

보고 된 오류입니다. 그러나 당신은 아마 더 많은 문제가 있습니다.

먼저 IMPLICIT NONE을 추가하고 선언 또는 변수를 추가하십시오. 또한 include '/usr/include/mpi/mpif.h' 대신 use mpi을 입력하는 것이 좋습니다. 그러면 더 많은 문제를 찾을 수 있습니다.


이제 코드가 일부 웹 사이트에서 복사 된 것을 볼 수 있습니다. 코드가 분명히 틀리기 때문에 나는이 웹 사이트를 신뢰하지 않을 것입니다.

+1

이번 주에는 동일한 기본 문제로 많은 질문이 있습니다. 'IMPLICIT NONE'은 ** 필수 **입니다 !!! –

+0

IMPLICIT NONE과 선언되지 않은 변수를 선언 한 후에 잘 돌아갔습니다. 파이썬에서 Fortran에 왔습니다. (그게 분명하지 않은 경우) 감사합니다! –