我有一个带有子程序的主程序,需要多次调用它。主程序如下:Fortran子程序中的Stackoverflow
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左右倍,得到错误“程序异常 - 堆栈溢出”
我不知道哪里出了问题可能在于,因为我对待所有数组以相同的方式,只有两个数组有这个问题。 谢谢!
无法给您提供您提供的信息的答案。 –