fortran/mpi汇编错误隐含无语句不能遵循属性声明
我正在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)在哪里,所以我不知道是什么原因导致错误。但是,当我评论隐式无
时,它会恰当地编译并正确运行。关于这里发生的事情有什么想法吗?
代码:
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)
I am in the process of learning MPI in fortran, and so I've been writing a bunch of small functions that do simple tasks in MPI to get a good handle on it. However, halfway through, i began getting this error when trying to compile
$ 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)
which doesn't even show me where (2) is so I don't know whats causing the error. But when I commented out implicit none
, it compiled fine and ran correctly. Any ideas as to what is happening here?
Code:
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
Also this is 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
隐式无
必须出现incomn'mpif.h'
说这是非常错误的,您至少应该使用
(请注意
隐式无
是之后使用mpi
line)理想情况下,您
可能会要求您现代化代码
(例如,数据类型具有自己的类型(例如
类型(MPI_DATATYPE)
而不是Integer
)implicit none
must appear beforeinclude 'mpif.h'
That being said, this is very error prone, and you should at least use
(note the
implicit none
is after theuse mpi
line)Ideally, you would
but that will likely require you to modernize your code
(for example, a datatype has its own type (e.g.
Type(MPI_Datatype)
instead ofINTEGER
)