I'm running Visual Fortran Composer 2013 inside Visual Studio 10, Windows 7 64 bit, 128 GB RAM.
I wrote a program that computes elements in matrices. The program works fine for pretty large input files.
Now I want to increase the size of the input file and all works well (more than enough memory is available) until the
program terminates with:
forrtl: severe <408>: fort: <10>: Subscript #1 of the array ZGPf has value 2147443984 which is greater than the upper bound of 48372.
Reading about such errors on the net, I see that the common problem is that people use variables without initializing them first. The number that I've encountered (2147443984) looks like a junk number but the fact is that the variable that is giving me the problem is a loop variable and thus cannot have a junk number since it is given a definite value at the start of each loop. Here is the problematic part of the code:
integer :: nbf, it, nf, ibf, nt
complex (8), dimension (size(L%Inzt)+1) :: ZGPt ! checking this dimension size gives 250 which is correct.
complex (8), dimension (size(L%Inzf)+1) :: ZGPf ! checking this dimesnion size gives 48,372 which is correct.
nf = size(L%Inzf) ! this equals 48,371
nbf = size(L%I) ! this equals 60,000
nt = size(L%Inzt) ! this equals 249.
do ibf = 1, nbf
do it = 1, nt
ZGPt(it) = calcElectric (......) ! this calls "calcElectric" which does some calculations. The output from this function is correct.
end do ! this loop works fine always no matter the size of my input file.
do it = 1, nf
ZGPf(it) = calcElectric (......) ! this calls "calcElectric" which does some calculations. The output from this function is correct.
end do ! This loop gives me the error "severe <408>..." for the last value of 'it' which should be 48,371. Up to and including 48,370 all is fine.
end subroutine CreateImpMat
What I'm understading from this code along with the error message is that the problem is with 'it'. But as you can see 'it' has a definite value which is why I don't understand the 'junk' number 2147443984. For smaller input files the program works great. Also, I cannot think of a problem happeing in the function "calcElectric" because 'it' is a local variable and would not change values while another function is running. Another thing I tried was printing the value of 'it' while doing the inner problematic loop and it does have a correct value. I also tried defining another complex variable and giving it the output of the "calcElectric" function and only then putting this value in ZGPf(it). Still the same error message.
Can anyone explain what's happening here? Could this be a visual fortran bug?