GFORTRAN编译警告“可以使用非国际化”。对于明显的初始化数组
我的编译器已经开始在开发代码时尚未触摸的一部分的一部分给我警告...分配了Zarray,设置为零,然后将一部分阵列设置为已通过的rarray。
SUBROUTINE advection(rbox0,rfrac,rarray,na)
IMPLICIT NONE
INTEGER, INTENT(IN) :: na
REAL, INTENT(IN) :: rfrac
REAL, INTENT(IN) :: rbox0
REAL, INTENT(INOUT) :: rarray(0:na)
! local arrays
REAL, ALLOCATABLE :: zarray1(:),zarray2(:)
ALLOCATE(zarray1(-4:2*na))
zarray1(:)=0.0
zarray1(0:na)=rarray ! zarray stores the original array
rarray(:)=0.0
rarray(0)=(1.0-rbox0)*zarray1(0)
! etc etc
现在Gfortran在Mac上我得到了此编译警告:
vectri.f90:1101:38:
1101 | rarray(0)=(1.0-rbox0)*zarray1(0)
| ^
Warning: 'MEM <real(kind=4)[0:]> [(real(kind=4)[0:] *)_77][4]' may be used uninitialized [-Wmaybe-uninitialized]
根据我的经验,这样的警告在您的危险中被忽略了,但是我一生无法理解为什么编译器在这里感到不安...我是我使用
GNU fortran(Homebrew GCC 11.3.0_1)11.3.0
编辑:在回复下面的评论时,代码最初是
zarray1=0.0
在
rarray=0.0
警告时,我更改为insert (:)
查看是否是否会有所帮助(没有:-()
My compiler has started giving me a warning on a part of my code I haven't touched while developing code... The zarray is allocated, set to zero, then part of the array is set to rarray that is passed in.
SUBROUTINE advection(rbox0,rfrac,rarray,na)
IMPLICIT NONE
INTEGER, INTENT(IN) :: na
REAL, INTENT(IN) :: rfrac
REAL, INTENT(IN) :: rbox0
REAL, INTENT(INOUT) :: rarray(0:na)
! local arrays
REAL, ALLOCATABLE :: zarray1(:),zarray2(:)
ALLOCATE(zarray1(-4:2*na))
zarray1(:)=0.0
zarray1(0:na)=rarray ! zarray stores the original array
rarray(:)=0.0
rarray(0)=(1.0-rbox0)*zarray1(0)
! etc etc
Now with gfortran on a mac I'm getting this compile warning:
vectri.f90:1101:38:
1101 | rarray(0)=(1.0-rbox0)*zarray1(0)
| ^
Warning: 'MEM <real(kind=4)[0:]> [(real(kind=4)[0:] *)_77][4]' may be used uninitialized [-Wmaybe-uninitialized]
In my experience, warnings such as these are ignored at your peril, but I can't for the life of me understand why the compiler is getting upset here... I'm using
GNU Fortran (Homebrew GCC 11.3.0_1) 11.3.0
EDIT: in reply to the comments below, the code was originally
zarray1=0.0
and
rarray=0.0
when the warning arose, I changed to insert (:)
to see if it would help (it didn't :-( )
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论