在PGI Fortran中分配大型数组 [英] Allocate large array in PGI Fortran

查看:141
本文介绍了在PGI Fortran中分配大型数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Fortran中分配一个真实的数组finn_var(459,299,27,24,nspec)。 nspec = 24可以正常工作,而nspec = 25不可以。分配过程没有错误消息,但打印命令打印空白而不是零值。如果您使用该阵列,则会出现分段错误错误消息。测试程序是

 程序测试

隐含无

整数: :nx,ny,nez,nt,nspec
integer :: allocation_status
real,allocatable :: finn_var(:,::,:,

nx = 459
ny = 299
nez = 27
nt = 24
nspec = 24

分配(finn_var(nx,ny,nez,nt,nspec) ,stat = allocation_status)
if(allocation_status> 0)then
print *,finn_var的分配错误
stop
end if

print *,finn_var

end

不应该是内存问题。我没有问题地分配双精度finn_var(459,299,27,24,24)。这是什么原因?



我在linux服务器上使用pgf90。 cat / proc / meminfo命令:

  MemTotal:396191724 kB 
MemFree:66065188 kB
缓冲区: 402388 kB
缓存:274584600 kB
SwapCached:0 kB
Active:131679328 kB
Inactive:191625200 kB
HighTotal:0 kB
HighFree:0 kB
LowTotal:396191724 kB
LowFree:66065188 kB
SwapTotal:20971484 kB
SwapFree:20971180 kB
脏:605508 kB
编写:0 kB
AnonPages:48317148 kB
Mapped:123328 kB
Slab:6612824 kB
PageTables:132920 kB
NFS_Unstable:0 kB
跳动:0 kB
SubmitLimit:219067344 kB
Committed_AS:53206972 kB
VmallocTotal:34359738367 kB
VmallocUsed:275624 kB
VmallocChunk:34359462559 kB
HugePages_Total:0
HugePages_Free:0
HugePages_Rsvd:0
Hugepagesize:2048 kB

unlimit -a命令:

 核心文件大小(块,-c)0 
数据段大小(千字节,-d)无限制
调度优先级(-e)0
文件大小(块,-f)无限制
挂起信号(-i)3153920
最大锁定内存(千字节,-l)32
最大内存大小(千字节,-m)无限制
打开文件(-n)1024
管道大小(512字节,-p)8
POSIX消息队列(字节,-q)819200
实时优先级(-r)0
堆栈大小(千字节,-s)10240
cpu时间(秒,-t)无限
最大用户进程(-u)3153920
虚拟内存(千字节,-v)无限制
文件锁定(-x)不限制

我是由pgf90编译的。但如果我用gfortran编译,没有问题。

解决方案

它不一定是内存不足。数组的大小是 2 223 304 200 。这可疑地接近最大32位整数 2 147 483 648



看起来元素数量编译器使用内部溢出。对 malloc 的内部调用请求的内存不足,然后尝试读取最后的某些元素失败。



这是编译器默认设置的限制。可以使用 -Mlarge_arrays 选项来设置使用64位寻址。 http://www.pgroup.com/products/freepgi/freepgi_ref/ch05.html#ArryIndex =nofollow> http://www.pgroup.com/products/freepgi/freepgi_ref/ch05.html#ArryIndex


I am trying to allocate an real array finn_var(459,299,27,24,nspec) in Fortran. nspec = 24 works ok, while nspec = 25 not. No error message for allocation process, but print command print empty rather than zero values. If you use the array, there will be "segmentation fault" error message. The test program is

  program test

  implicit none

  integer                    :: nx, ny, nez, nt, nspec
  integer                    :: allocation_status
  real , allocatable         :: finn_var(:,:,:,:,:)

  nx    = 459
  ny    = 299
  nez   = 27
  nt    = 24
  nspec = 24

  allocate( finn_var(nx, ny, nez, nt, nspec), stat = allocation_status )
  if (allocation_status > 0) then
    print*, "Allocation error for finn_var"
    stop
  end if

  print*, finn_var

  end

Should not be the memory issue. I allocated double precision finn_var(459,299,27,24,24) without problem. What is the reason then?

I use pgf90 on linux server. the cat /proc/meminfo command:

MemTotal:     396191724 kB
MemFree:      66065188 kB
Buffers:        402388 kB
Cached:       274584600 kB
SwapCached:          0 kB
Active:       131679328 kB
Inactive:     191625200 kB
HighTotal:           0 kB
HighFree:            0 kB
LowTotal:     396191724 kB
LowFree:      66065188 kB
SwapTotal:    20971484 kB
SwapFree:     20971180 kB
Dirty:          605508 kB
Writeback:           0 kB
AnonPages:    48317148 kB
Mapped:         123328 kB
Slab:          6612824 kB
PageTables:     132920 kB
NFS_Unstable:        0 kB
Bounce:              0 kB
CommitLimit:  219067344 kB
Committed_AS: 53206972 kB
VmallocTotal: 34359738367 kB
VmallocUsed:    275624 kB
VmallocChunk: 34359462559 kB
HugePages_Total:     0
HugePages_Free:      0
HugePages_Rsvd:      0
Hugepagesize:     2048 kB

the unlimit -a command:

core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 3153920
max locked memory       (kbytes, -l) 32
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 3153920
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

I compiled by pgf90. But if I compiled by gfortran, there is no problem.

解决方案

It doesn't have to be insufficient memory. The size of the array is 2 223 304 200. That is suspiciously close to the maximum 32bit integer 2 147 483 648.

It looks like that the element count that the compiler uses internally overflows. The internal call to malloc requests not enough memory and then any attempt to read some of the elements at the end fails.

It is a limitation of the compiler in its default settings. It can be set-up to use 64bit addressing by using the option ‑Mlarge_arrays.

See http://www.pgroup.com/products/freepgi/freepgi_ref/ch05.html#ArryIndex

这篇关于在PGI Fortran中分配大型数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆