什么是Fortran 90的最大数组大小双precision? [英] what is the biggest array size for double precision in Fortran 90?

查看:701
本文介绍了什么是Fortran 90的最大数组大小双precision?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果这是不是做这个问题的正确的地方,这是不是programation反而是一个技术问题。
我需要用二维向量的规模巨大阵列双precision aproximately工作的10万元他们。但是,在其他程序中我有记忆问题,在处理这类阵列。我的问题是,如果有某种限制在双precision数组的大小。

Sorry if this is not the correct place to do this question, this is not about programation instead is a technical question. I need to work with enormous size arrays of 2D vectors in double precision, 10 million of them aproximately. But, in other programs I had memory problem in deal with this kind of arrays. My question is if there is some kind of limit for the array size in double precision.

我在Linux下工作,英特尔两大核心,32位。
谢谢

I work in Linux, Intel two core, 32-bits. thanks

推荐答案

好吧,我会为什么字节数是有限的,不仅是元素计数解释。期间数组索引,元件的地址必须被计算。当然,它必须适合到使用intptr_t C变量。此外,数组的字节大小必须适合在为size_t C变量。这些都是32位或对现代机器的32位和64位程序的64位。同样还计划对虚拟内存寻址!并且还通过在OS和CPU存储器寻址,尽管它们可以是64位,即使该方案是32位。

Ok, I will explain by why the number of bytes is limited, not only the element count. During array indexing, the address of the element must be calculated. Of course it must fit to the intptr_t C variable. Also, the size of the array in bytes must fit in a size_t C variable. These are both 32-bit or 64-bit on 32-bit and 64-bit programs on modern machines. The same also holds for the virtual memory addressable by program! And also the memory addressable by the OS and CPU, though they can be 64-bit even if the program is 32-bit.

这是根本原因32位程序和操作系统无法寻址超过4 GB的内存。即使你能以某种方式使用Fortran的变量比选择CPU字长更广泛的计算地址,CPU根本无法访问它。

This is the fundamental reason why 32-bit programs and operating systems cannot address more than 4 GB of memory. Even if you could somehow compute the address using a Fortran variable wider than the chosen CPU word size, the CPU simply cannot access it.

最后,我疯了在英特尔Fortran实验在32位模式与32字节数组的元素:

Finally I mad an experiment in Intel Fortran in 32-bit mode with array with 32 byte elements:

complex(16), allocatable :: a(:)
 do i=1,100
   allocate(a(2**i))
   a(size(a)) = 1
   deallocate(a)
   write(*,*) i
 end do
end

ifort arraysize.f90 -m32 -check -traceback -g

如预期的输出:

       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
    forrtl: severe (179): Cannot allocate array - overflow on array size calculation.

正如预期的那样以字节为单位的数组的大小溢出和程序崩溃长​​索引变量溢出了。这不是一个编译器特定的功能,但存在用于此的一个根本原因。

As expected the size of the array in bytes overflowed and the program crashed long before the indexing variable overflowed. This is not a compiler specific feature, but there is a fundamental reason for this.

这篇关于什么是Fortran 90的最大数组大小双precision?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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