gpt4 book ai didi

fortran - ifort 2015 中可能存在的错误

转载 作者:行者123 更新时间:2023-12-02 16:29:51 24 4
gpt4 key购买 nike

我认为我在 ifort 2015 中观察到一个错误。

$> ifort test.f90 -O1 -g  && ./a.out
6 0 0 0 0 0 0
1 0
$> ifort test.f90 -O0 -g && ./a.out
6 0 0 0 0 0 0
6 0 0 0 0 0 0

第二个结果是好的,我看不出有什么不同。

文件test.f90:

module useless_module
! this module is useless
! remove it and the bug disappear
implicit none
! those variables are useless
! they will never be touched
! remove one of them and the bug disappear
! rename one of them and the bug disappear
integer,allocatable,dimension(:) :: num_dr , &
num_cf , &
num_cfi, &
num_num, &
num_typ
end module useless_module

program test_program
implicit none
! those variables are useless
! they will never be touched
! remove one of them and the bug disappear
integer,allocatable,dimension(:) :: a1, b1, c1, d1, &
e1, g1, f1, h1, &
i1, j1, k1

call routine_1(a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1)
contains

subroutine routine_1(a3,b3,c3,d3,e3,f3,num_cf,num_dr, &
num_typ,num_num,num_cfi)
implicit none
! those arguments are useless
! they will never be touched
! remove one of them and the bug disappear
integer,allocatable,dimension(:) :: a3,b3,c3,d3,e3,f3
! those arguments are useless
! they will never be touched
! remove one of them and the bug disappear
! rename one of them and the bug disappear
integer,allocatable,dimension(:) :: num_dr , &
num_cf , &
num_cfi, &
num_num, &
num_typ
! this variable is useless
! it will never be touched
! remove it and the bug disappear
integer,allocatable,dimension(:) :: g3
! those variables are actualy used !
integer,allocatable,dimension(:,:,:) :: h3,i3,j3

allocate(h3(1,1,1),i3(1,1,1),j3(1,1,1))

call routine_2(g3,i3,j3)

! here, normaly, size(i3)=6 and i3= 0 0 0 0 0 0
! But that is not what is printed : BUG ?
! printing size(i3) AND i3 is mandatory to make the bug happen
write(*,'(7i2)') size(i3),i3
deallocate(h3,i3,j3)
end subroutine routine_1

subroutine routine_2(a2,b2,c2)
use useless_module
implicit none
integer,allocatable,dimension(:) :: a2,d2,e2,f2,g2
integer,allocatable,dimension(:,:,:) :: b2, c2
integer :: j2

! j2 have to be be a variable
j2=1
! allocate and deallocate some array
! not doing that will make the bug desappear
allocate (d2(j2),e2(1),f2(1),g2(1))
deallocate(d2 ,e2 ,f2 ,g2)

call reallocate( c2,3,2,1)
call reallocate( b2,3,2,1) ; b2=0

! here, we have size(b2)=6 and b2= 0 0 0 0 0 0
! printing size(b2) AND b2 is mandatory to make the bug happen
write(*,'(7i2)') size(b2),b2
end subroutine routine_2

subroutine reallocate(a4,b4,c4,d4)
implicit none
integer,allocatable,dimension(:,:,:) :: a4
integer :: b4,c4,d4

deallocate(a4) ; allocate(a4(b4,c4,d4))

end subroutine reallocate

end program test_program

正如你所看到的,我没有做任何花哨的事情。我尝试尽可能减少代码我在三台计算机上尝试了三个版本的ifort(15.0.0 20140723、15.0.2 20150121和14.0.0 20130728)我总是看到同样的事情。

我在 gfortran(4.8.2 或 5.1.0)中没有看到它

它看起来很大,而且我确信我犯了一个错误,但我没有看到它。

任何帮助将不胜感激

编辑:我在linux下(ubuntu和archlinux)

最佳答案

你是对的 - 这是 ifort 中的一个错误。我已将其发送给开发人员。

关于fortran - ifort 2015 中可能存在的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30051232/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com