我正在用fortran学习MPI,所以我一直在编写一些小函数,用MPI完成简单的任务,以便更好地处理它。然而,在进行到一半的时候,我在尝试编译时开始出现这个错误
$ mpif90 example.f90 -o example.out
example.f90:108:17:
108 | implicit none
| 1
Error: IMPLICIT NONE statement at (1) cannot follow attribute declaration statement at (2)
它甚至没有告诉我(2)在哪里,所以我不知道是什么导致了错误。但当我发表评论时
implicit none
,编译良好,运行正常。你知道这里发生了什么吗?
代码:
program send_vec
include 'mpif.h'
implicit none
integer :: process_rank, cluster_size, ierror, message_item
integer :: i
integer, dimension(:), allocatable :: buffer_vector
allocate(buffer_vector(1:10))
call MPI_INIT(ierror)
call MPI_COMM_SIZE(MPI_COMM_WORLD, cluster_size, ierror)
call MPI_COMM_RANK(MPI_COMM_WORLD, process_rank, ierror)
if ( process_rank == 0 ) then
do i = 1, 10
buffer_vector(i) = i
end do
write (*,*) "sent:", buffer_vector
call MPI_SEND(buffer_vector, 10, MPI_INT, 1, 1, MPI_COMM_WORLD, ierror)
else if (process_rank == 1) then
call MPI_RECV(buffer_vector, 10, MPI_INT, 0, 1, MPI_COMM_WORLD, MPI_STATUS_IGNORE, ierror)
write (*,*) "recieved:", buffer_vector
end if
call MPI_FINALIZE(ierror)
end program send_vec
这也是mpif90-v
mpifort for MPICH version 3.4.1
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-7ubuntu2' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-ZPT0kp/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-7ubuntu2)