gpt4 book ai didi

fortran - 在声明类型中分配参数声明类型时,ifort 出现灾难性错误

转载 作者:行者123 更新时间:2023-12-04 21:03:02 25 4
gpt4 key购买 nike

请考虑以下代码

  module t_test
implicit none

type ttt(tsize)
integer, len :: tsize
real x(tsize)
end type ttt



type :: t_rndom_diameter(t_rsize,t_csize)
integer, len :: t_rsize,t_csize
real :: x(t_rsize,t_csize)
type(ttt(tsize=:)), allocatable :: test_type
end type t_rndom_diameter




end module t_test


program p_test
USE t_test
implicit none

type(t_rndom_diameter(t_rsize=3,t_csize=3)) :: gdad

allocate(gdad% ttt(tsize=10) :: gdad % test_type)


end program

它给了我一个灾难性的错误,但没有提及错误是什么:

catastrophic error: **Internal compiler error: segmentation violation signal raised** Please
report this error along with the circumstances in which it occurred in a Software Problem
Report. Note: File and line given may not be explicit cause of this error.

但是,我知道是什么触发了这个错误,即:allocate(gdad% ttt(tsize=10)::gdad% test_type)

这是什么意思?

我也尝试过不使用 gdad,即 allocate(gdad% ttt(tsize=10)::test_type)

最佳答案

像往常一样,“内部编译器错误”与编译器中的错误有关。这是要向编译器供应商报告的事情。

但是,在这种情况下,这将是一个低优先级问题:您尝试编译的代码无效。如前所述,有问题的行是

allocate(gdad% ttt(tsize=10) ::  gdad % test_type)

这是无效的,因为这种形式的 allocate 语句在左侧需要一个类型说明符。 gdad%ttt(10) 不是这样的东西。正确的说法是

allocate(ttt(tsize=10) ::  gdad % test_type)

关于fortran - 在声明类型中分配参数声明类型时,ifort 出现灾难性错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54354783/

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