【发布时间】:2011-10-20 19:45:16
【问题描述】:
我确实有一个带有子程序的主程序,需要多次调用。主程序如下:
program main
open output file
do i = 1, 20000
read parameters par_1, par_2, ..., par_8
call subroutine (par_1, .... , par_8)
enddo
end program
子例程完成所有工作,我不想保存数组的值。它们主要用于存储中间结果。
子程序如下:
subroutine calcr
real, dimension(5000) :: array_1, array_2, .... array_20
read temperature into array_1
read pH into array_2
...
store intermediate results into array_10
sotre intermediate results into array_20
...
make final calculations
write the results to the output file
close files from which the data was read (temperature, pH...)
end subroutine
我发现 20 个数组中有两个有问题。如果我将这两个数组的维度加倍,我可以毫无问题地运行程序两次。 程序停止并显示错误消息“超出程序异常数组绑定”
如果我取维度*10,那么我可以运行程序10次,得到同样的错误。
但是如果我取维度*100,我只能运行程序大约 30 次,并得到错误“程序异常 - 堆栈溢出”
我不知道问题出在哪里,因为我以相同的方式处理所有数组,只有两个数组有这个问题。 谢谢 !
【问题讨论】:
-
您提供的信息无法给您答案。
标签: arrays fortran stack-overflow