3

私はこのコードを持っていますが、このエラーが発生します。

ステータスを次のように宣言しようとしました

INTEGER :: ステータス

しかし、それはMPI_SENDRECVの後のランクの値を変更します(つまり、すべてのプロセッサでランク= 0)

PROGRAM testsendrecv
  IMPLICIT NONE

  INTEGER :: i, k, nx, nz
  INTEGER :: ierror, comm, p, rank, npr, prev
  INTEGER :: status(MPI_STATUS_SIZE)
  REAL(KIND = 8), ALLOCATABLE :: A(:,:), B(:), C(:)

  include 'mpif.h'

  nx = 5
  nz = 5

  ALLOCATE(A(nx,nz), B(nx))

  CALL MPI_INIT(ierror)
  comm = MPI_COMM_WORLD
  !Get rank
  CALL MPI_COMM_RANK(comm, rank, ierror)
  !Get number of processors
  CALL MPI_COMM_SIZE(comm, p, ierror)

  A(:,:) = rank

  IF(rank==0) THEN
     prev = p-1
  ELSE
     prev = rank-1
  END IF


  CALL MPI_SENDRECV(A(:,1), nx, MPI_DOUBLE_PRECISION, MOD(rank+1,p), 1,  &
       B(:), nx, MPI_DOUBLE_PRECISION, prev, 1, comm, status, ierror)

  WRITE(*,*) rank
  WRITE(*,*) B(1)

  CALL MPI_FINALIZE(ierror)

END PROGRAM testsendrecv

上記のコードは私に次のエラーを与えます

bash-4.1$ mpif90 testsendr.f90
mpif.h:79.35:
    Included at testsendr.f90:9:

       PARAMETER (MPI_STATUS_SIZE=5)
                                   1
Error: VARIABLE attribute of 'mpi_status_size' conflicts with PARAMETER attribute at (1)
mpif.h:80.33:
    Included at testsendr.f90:9:

       INTEGER MPI_STATUS_IGNORE(MPI_STATUS_SIZE)
                                 1
Error: Variable 'mpi_status_size' cannot appear in the expression at (1)
mpif.h:80.49:
    Included at testsendr.f90:9:

       INTEGER MPI_STATUS_IGNORE(MPI_STATUS_SIZE)
                                                 1
Error: The module or main program array 'mpi_status_ignore' at (1) must have constant shape
mpif.h:81.35:
    Included at testsendr.f90:9:

       INTEGER MPI_STATUSES_IGNORE(MPI_STATUS_SIZE,1)
                                   1
Error: Variable 'mpi_status_size' cannot appear in the expression at (1)
mpif.h:81.53:
    Included at testsendr.f90:9:

       INTEGER MPI_STATUSES_IGNORE(MPI_STATUS_SIZE,1)
                                                     1
Error: The module or main program array 'mpi_statuses_ignore' at (1) must have constant shape
testsendr.f90:6.20:

  INTEGER :: status(MPI_STATUS_SIZE)
                    1
Error: Variable 'mpi_status_size' cannot appear in the expression at (1)
testsendr.f90:6.36:

  INTEGER :: status(MPI_STATUS_SIZE)
                                    1
Error: The module or main program array 'status' at (1) must have constant shape

何かご意見は。本当に簡単なプログラムです。

ありがとう

4

1 に答える 1

4

あなたの問題は、プログラム内のステートメントの順序の誤りから生じると思います。行の前に

include mpif.h

そのファイルで定義されている定数の 1 つを使用する変数を次の行で宣言しました。

INTEGER :: status(MPI_STATUS_SIZE)

includeステートメントを の直後に移動するかIMPLICIT NONE、インクルードを完全に削除USE MPIして暗黙のステートメントの前に挿入し、改訂されたコードのリンクを整理します。

于 2013-04-29T07:51:51.800 に答える