|
看到Fortran内置的一个数组操作函数“eoshift”,功能是将数组进行挪位。
就想测试一下它和普通方法的速度差异,代码如下:
[Fortran] 纯文本查看 复制代码 04 | integer , dimension ( : , : , : ) , allocatable :: a |
05 | integer , dimension ( : , : , : ) , allocatable :: temp |
06 | integer :: grid = 1000 , dim 1 = 30 |
07 | real :: time_start , time_end |
09 | allocate ( a ( dim 1 , grid , grid ) ) |
10 | allocate ( temp ( dim 1 , grid , grid ) ) |
15 | call cpu_time ( time_start ) |
16 | a = eoshift ( a , shift = 1 , boundary = 0 , dim = 1 ) |
17 | call cpu_time ( time_end ) |
18 | write ( * , * ) 'function eoshift:' |
19 | write ( * , * ) time_end - time_start , 'seconds elapsed' |
22 | call cpu_time ( time_start ) |
24 | temp ( i , : , : ) = a ( i +1 , : , : ) |
28 | call cpu_time ( time_end ) |
29 | write ( * , * ) 'normal method:' |
30 | write ( * , * ) time_end - time_start , 'seconds elapsed' |
用gfortran编译运行没有问题;
但是用Intel Fortran编译通过,运行时却报错“StackOverflow”;
在Linux下也是同样报错;
既然是栈溢出的问题,于是我将数组大小调整得很小,果然不报错了,但问题是:
1. 调用内置函数eoshift为什么gfortran没有StackOverflow,而ifort却StackOverflow了?
2. 我只知道a是我分配到内存里的,而内置函数eoshift为什么会使用栈?
希望有前辈能够指导一下,感激不尽!
|
|