(1) 处的数组规范在 mpif-sizeof.h 中具有超过 7 个维度

Array specification at (1) has more than 7 dimensions in mpif-sizeof.h

我有以下 makelist 文件:

BIN_SUFFIX = cpu
OMP_FLAGS = -p
OPT_FLAGS = -ofast
compiler = mpifort
compiler = mpif90


#used in gfortran
MISC_FLAGS = -ffree-line-length-300 #

CFLAGS += $(OPT_FLAGS)
CFLAGS += $(OMP_FLAGS)
CFLAGS += $(MISC_FLAGS)

LFLAGS = $(CFLAGS)

COMPILE = ${compiler} -c
LINK = ${compiler}

objects = Main_multiphase.o Main_singlephase.o Module.o Init_multiphase.o Init_singlephase.o Misc.o IO_multiphase.o IO_singlephase.o Kernel_multiphase.o Kernel_singlephase.o Mpi_misc.o Mpi_pdf.o Mpi_pdf_acc.o Boundary_singlephase.o Boundary_singlephase_special_case.o Boundary_multiphase_inlet.o Boundary_multiphase_outlet.o Boundary_multiphase_other.o Boundary_multiphase_special_case.o Monitor.o Phase_gradient.o Monitor_special_case.o
LBM : $(objects)    
    ${LINK} $(LFLAGS) -o MF_LBM.$(BIN_SUFFIX) $(objects) 

Module.o : Module.F90
    ${COMPILE} $(CFLAGS) Module.F90
Main_multiphase.o : Main_multiphase.F90 Module.o
    ${COMPILE} $(CFLAGS) Main_multiphase.F90
Main_singlephase.o : Main_singlephase.F90 Module.o
    ${COMPILE} $(CFLAGS) Main_singlephase.F90
Misc.o : Misc.F90 Module.o  
    ${COMPILE} $(CFLAGS) Misc.F90
Monitor.o : Monitor.F90 Module.o    
    ${COMPILE} $(CFLAGS) Monitor.F90
Monitor_special_case.o : Monitor_special_case.F90 Module.o  
    ${COMPILE} $(CFLAGS) Monitor_special_case.F90
Boundary_multiphase_inlet.o : Boundary_multiphase_inlet.F90 Module.o    
    ${COMPILE} $(CFLAGS) Boundary_multiphase_inlet.F90
Boundary_multiphase_outlet.o : Boundary_multiphase_outlet.F90 Module.o  
    ${COMPILE} $(CFLAGS) Boundary_multiphase_outlet.F90
Boundary_multiphase_other.o : Boundary_multiphase_other.F90 Module.o    
    ${COMPILE} $(CFLAGS) Boundary_multiphase_other.F90
Boundary_multiphase_special_case.o : Boundary_multiphase_special_case.F90 Module.o  
    ${COMPILE} $(CFLAGS) Boundary_multiphase_special_case.F90
Boundary_singlephase.o : Boundary_singlephase.F90 Module.o  
    ${COMPILE} $(CFLAGS) Boundary_singlephase.F90
Boundary_singlephase_special_case.o : Boundary_singlephase_special_case.F90 Module.o    
    ${COMPILE} $(CFLAGS) Boundary_singlephase_special_case.F90
Kernel_multiphase.o : Kernel_multiphase.F90 Module.o    
    ${COMPILE} $(CFLAGS) Kernel_multiphase.F90
Kernel_singlephase.o : Kernel_singlephase.F90 Module.o  
    ${COMPILE} $(CFLAGS) Kernel_singlephase.F90
Init_multiphase.o : Init_multiphase.F90 Module.o
    ${COMPILE} $(CFLAGS) Init_multiphase.F90
Init_singlephase.o : Init_singlephase.F90 Module.o
    ${COMPILE} $(CFLAGS) Init_singlephase.F90
IO_multiphase.o : IO_multiphase.F90 Module.o
    ${COMPILE} $(CFLAGS) IO_multiphase.F90
IO_singlephase.o : IO_singlephase.F90 Module.o
    ${COMPILE} $(CFLAGS) IO_singlephase.F90
Phase_gradient.o : Phase_gradient.F90 Module.o
    ${COMPILE} $(CFLAGS) Phase_gradient.F90
Mpi_misc.o : Mpi_misc.F90 Module.o
    ${COMPILE} $(CFLAGS) Mpi_misc.F90
Mpi_pdf.o : Mpi_pdf.F90 Module.o
    ${COMPILE} $(CFLAGS) Mpi_pdf.F90
Mpi_pdf_acc.o : Mpi_pdf_acc.F90 Module.o
    ${COMPILE} $(CFLAGS) Mpi_pdf_acc.F90

clean:
    rm -f *.o *.mod
    rm MF_LBM.$(BIN_SUFFIX)

当我运行以下命令时:make,我得到以下错误:

$ make
mpif90  -c   -ofast -p -ffree-line-length-300   Main_multiphase.F90
Main_multiphase.F90:485:0:

 #endif

Warning: null character(s) ignored
mpif-sizeof.h:66:41:

Error: Array specification at (1) has more than 7 dimensions
mpif-sizeof.h:72:41:

Error: Array specification at (1) has more than 7 dimensions
mpif-sizeof.h:78:41:

Error: Array specification at (1) has more than 7 dimensions
mpif-sizeof.h:84:41:

Error: Array specification at (1) has more than 7 dimensions
mpif-sizeof.h:90:41:

.
.
.

Error: Ambiguous interfaces in generic interface 'mpi_sizeof' for ‘mpi_sizeof_real64_r14’ at (1) and ‘mpi_sizeof_real64_r15’ at (2)
mpif-sizeof.h:2631:39:

mpif-sizeof.h:2638:39:

Error: Ambiguous interfaces in generic interface 'pmpi_sizeof' for ‘pmpi_sizeof_real64_r14’ at (1) and ‘pmpi_sizeof_real64_r15’ at (2)
mpif-sizeof.h:1315:38:

mpif-sizeof.h:1322:38:

Error: Ambiguous interfaces in generic interface 'mpi_sizeof' for ‘mpi_sizeof_real64_r14’ at (1) and ‘mpi_sizeof_real64_r15’ at (2)
mpif-sizeof.h:2631:39:

mpif-sizeof.h:2638:39:

Error: Ambiguous interfaces in generic interface 'pmpi_sizeof' for ‘pmpi_sizeof_real64_r14’ at (1) and ‘pmpi_sizeof_real64_r15’ at (2)
make: *** [makefile:43: Main_multiphase.o] Error 1

我安装了以下版本的 Fortran:

$ mpif90 --version
GNU Fortran (GCC) 7.4.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

是编译器不兼容导致的问题吗?我的系统是 运行ning Windows 10 64 位版本,我使用的是 Cygwin。

Cygwin 中的 Openmpi 安装

TL;DR 您必须使用用于构建 Open MPI 的 same Fortran 编译器(供应商 and 版本)。

您的应用 include 'mpif.h',并且在内部 include 'mpif-sizeof.h'。 这里发生的是 Open MPI 是使用支持超过 7 维数组的 Fortran 编译器构建的,但是您用来构建应用程序的 Fortran 编译器不支持,因此会出现错误。

话虽这么说,正确的解决方法是使您的应用程序现代化,并将“遗留”include 'mpif.h' 替换为现代 use mpi,甚至更好,use mpi_f08

正如我们在评论中解决的那样,您需要使用与您正在使用的 OpenMPI 兼容的编译器,或者以其他方式使用与您的 OpenMPI 兼容的编译器。不仅 MPI 的 header mpif.h headers 包含 gfortran 7 等级过多的数组声明,而且一旦您使用更现代的 Fortran 功能,您也会遇到不兼容的问题数组描述符,因此模块文件不兼容。

当您尝试使用更现代的功能(如 use mpiuse mpi_f08 而不是 include "mpif.h" 时,这种不兼容性会变得更加明显。来自 MPI 库的模块文件如果来自不兼容的版本,将立即被编译器拒绝。 MPI 库必须针对确切的主编译器版本进行编译。这也意味着现代化您的应用程序不会解决您当前的问题。

您的项目中还有一个模块文件 .mod.,它使用模块版本 14,由 gfortran 5 制作。该文件将与任何其他 gfortran 版本不兼容。您将需要重新编译它。如果您有源代码,只需删除项目中的所有 .mod 个文件。如果您没有源文件,您需要获取它。