GFORTRAN编译警告“可以使用非国际化”。对于明显的初始化数组

发布于 2025-02-09 16:22:32 字数 1095 浏览 0 评论 0原文

我的编译器已经开始在开发代码时尚未触摸的一部分的一部分给我警告...分配了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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文