Fortran MPI状态错​​误

时间:2016-02-16 15:32:47

标签: fortran mpi

编译以下代码时出现以下错误

代码:

      IMPLICIT REAL*8(A-H,O-Z)
      include 'common_files.inc'
      CHARACTER*100 MNO, MESSAGE
      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)

        call MPI_INIT(ierror)
        call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
        call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)      
        starttime = MPI_WTIME()
        /* ........rest of code.................

编译输出:

main.f:23.46:

      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)          
                                              1
Error: Variable 'mpi_status_size' cannot appear in the expression at (1)
main.f:23.62:

      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)          
                                                              1
Error: The module or main program array 'status' at (1) must have constant shape

' common_files.inc'文件包含头文件,例如' include' mpif.h''。不幸的是,我不允许发布剩余的代码。

我正在使用以下命令

编译上述内容
mpif90 -g main.f

错误的可能原因是什么?

1 个答案:

答案 0 :(得分:1)

您明显对include 'mpif.h'声明有疑问:

参见例如:

      IMPLICIT REAL*8(A-H,O-Z)
c      include 'mpif.h'
      integer rank, size, ierror, status(MPI_STATUS_SIZE)

        call MPI_INIT(ierror)
        call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierror)
        call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierror)      
        print *, size, "  ", rank
        call MPI_Finalize(ierr)
      end

给了我:

$ mpif90 foo.f
foo.f:4.46:

      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)          
                                              1
Error: Variable 'mpi_status_size' cannot appear in the expression at (1)
foo.f:4.62:

      integer rank, size, ierror, tag, status(MPI_STATUS_SIZE)          
                                                              1
Error: The module or main program array 'status' at (1) must have constant shape

然而,如果我取消注释include 'mpif.h'行,它只会编译并运行。

您应该仔细检查common_files.inc文件。