AiProgramDo
Programmer
I am new to Fortran 90, but have programmed in other languages. I am working on reading data into an array, and have a nested do loop that is acting strangely:
INTEGER (KIND = 4) :: i,j ! Loop counters
INTEGER (KIND = 4) :: k ! Number of pixels
INTEGER (KIND = 2) :: b ! Number of bands
INTEGER (KIND = 2), ALLOCATABLE :: BVVarray , !k,b
!Get input file name, k and b code goes here, and works fine
! k = 1048576, b = 6
ALLOCATE (BVVarray (k,b))
BVVarray = 0
open (unit = 2, file = InputFileName, &
form = "binary", status = "old", action = "read")
ReadBands: do j = 1,b
ReadBVs: do i = 1,k
read (unit = 2) BVVarray (i,j)
ENDDO ReadBVs
ENDDO ReadBands
When I execute this code, j gets assigned -872415231. I don't get it! Any suggestions?
I have been able to make this code work with i as the outside loop, however, it does not read the file in the order I need it to. I need to read b sets of k, not k sets of b.
Thanks!
INTEGER (KIND = 4) :: i,j ! Loop counters
INTEGER (KIND = 4) :: k ! Number of pixels
INTEGER (KIND = 2) :: b ! Number of bands
INTEGER (KIND = 2), ALLOCATABLE :: BVVarray , !k,b
!Get input file name, k and b code goes here, and works fine
! k = 1048576, b = 6
ALLOCATE (BVVarray (k,b))
BVVarray = 0
open (unit = 2, file = InputFileName, &
form = "binary", status = "old", action = "read")
ReadBands: do j = 1,b
ReadBVs: do i = 1,k
read (unit = 2) BVVarray (i,j)
ENDDO ReadBVs
ENDDO ReadBands
When I execute this code, j gets assigned -872415231. I don't get it! Any suggestions?
I have been able to make this code work with i as the outside loop, however, it does not read the file in the order I need it to. I need to read b sets of k, not k sets of b.
Thanks!