You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

gfortran二维数组分配报‘Not enough space’错误的解决咨询

问题场景

在64位gfortran 14.2(gcc 12也存在相同问题)环境下运行以下代码:

program test1
   real, allocatable :: a(:), b(:,:)
   ! allocate( a(3870457856_8) )
   allocate( b(8000, 2000000) )
end program test1

执行后报错:

In file 'test4.f90', around line 5: Error allocating 3870457856 bytes: Not enough space

相关测试现象:

  • 注释第二个allocate、取消第一个allocate注释时,程序可正常运行
  • 使用编译选项-mcmodel=large无效果
  • 尝试allocate( b(6000, 2000000) )时无错误,曾怀疑与integer(4)到integer(8)的寻址转换有关
问题结论

代码本身无问题,8000*2000000的real数组(每个real占8字节)需要64GB内存,当前运行环境内存不足导致分配失败。

内容的提问来源于stack exchange,提问作者Pavel Ruzankin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 18:04:58