我有一個帶有子程序的主程序,需要多次調用它。主程序如下: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左右倍,得到錯誤「程序異常 - 堆棧溢出」
我不知道哪裏出了問題可能在於,因爲我對待所有數組以相同的方式,只有兩個數組有這個問題。 謝謝!
無法給您提供您提供的信息的答案。 –