I do have a main program with a subroutine, which needs to be called many times. The main program looks like:
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
The subroutine does all the work and I do not want to save the values of the arrays. They are mostly used to store intermediate results.
The subroutine looks like:
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
I found that I have problems with two of the 20 arrays. If I double the dimension of these two arrays I can run the program without problems for two times. The program stops with the error message "Program exception Array bound exceeded"
If I take dimension*10, then I can run the program 10 times and get the same error.
But if I take dimension*100, I can run the program only around 30 times and get the error "Program exception - stack overflow"
I do not know where the problem might lie, since I treated all arrays in the same way and only two arrays have this problem. Thank you !