I have written a piece of code today which works fine until I get to the 53rd time in the loop then it crashes. I thought maybe if was the 53 file that was crashing it but I changed the files around and it still crashes the 53rd time in the loop. Am I missing something when I define my variables? Can I not loop over 52 times? I am sure that isn't the case.
PROGRAM read_ecm
IMPLICIT NONE
!
! DECLARATIONS
!
INTEGER,PARAMETER :: NWEEK=1096,NTIME=8,NGRID=525
REAL,dimension(NWEEK,NTIME,NGRID) :: sp,totcc,winda,t2m,dt2m,
& surf,lcld,mcld,hcld,sun,precip,windb
CHARACTER(len = 100) :: junk
CHARACTER(len = 100) :: date_time(1096,8,525)
CHARACTER(len = 100) :: FILENAME
INTEGER :: i,j,k
!
! START PROGRAM
!
! Read in filenames
open(unit=50,file='filenames')
do k=1,60
READ(50,*) FILENAME
WRITE(*,*) FILENAME,k
! open each ecm grid weather data file within the loop
open(unit=51,file=FILENAME)
C
C Read in first line of file
C
read(51,*) junk
C
C Read in data file
C
do i=1,1096
do j=1,8
read(51,*) date_time(i,j,k),sp(i,j,k),
& totcc(i,j,k),winda(i,j,k),windb(i,j,k), surf(i,j,k),lcld(i,j,k),
& mcld(i,j,k),hcld(i,j,k),sun(i,j,k),precip(i,j,k)
enddo
enddo
close(unit=51)
enddo
close(unit=50)
end
If anyone can see my PROBABLY OBVIOUS mistake could you please let me know what it is. It's been driving me crazy all day.
Thanks
PROGRAM read_ecm
IMPLICIT NONE
!
! DECLARATIONS
!
INTEGER,PARAMETER :: NWEEK=1096,NTIME=8,NGRID=525
REAL,dimension(NWEEK,NTIME,NGRID) :: sp,totcc,winda,t2m,dt2m,
& surf,lcld,mcld,hcld,sun,precip,windb
CHARACTER(len = 100) :: junk
CHARACTER(len = 100) :: date_time(1096,8,525)
CHARACTER(len = 100) :: FILENAME
INTEGER :: i,j,k
!
! START PROGRAM
!
! Read in filenames
open(unit=50,file='filenames')
do k=1,60
READ(50,*) FILENAME
WRITE(*,*) FILENAME,k
! open each ecm grid weather data file within the loop
open(unit=51,file=FILENAME)
C
C Read in first line of file
C
read(51,*) junk
C
C Read in data file
C
do i=1,1096
do j=1,8
read(51,*) date_time(i,j,k),sp(i,j,k),
& totcc(i,j,k),winda(i,j,k),windb(i,j,k), surf(i,j,k),lcld(i,j,k),
& mcld(i,j,k),hcld(i,j,k),sun(i,j,k),precip(i,j,k)
enddo
enddo
close(unit=51)
enddo
close(unit=50)
end
If anyone can see my PROBABLY OBVIOUS mistake could you please let me know what it is. It's been driving me crazy all day.
Thanks