Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My FORTRAN code crashes on the 53 file, why?

Status
Not open for further replies.

Bobgirl

Programmer
May 22, 2013
1
GB
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
 
Nothing really obvious but try
Code:
INTEGER,PARAMETER :: NWEEK=1096,NTIME=8,NGRID=60
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(NWEEK,NTIME,NGRID)
It might possibly be that your arrays are too big.
 
Hhhhmmm...I don't know...the size of the arrays do not seem to add up to too much (less than .7 GB).

Say, what's the description of your variables? what do they mean? what does NWEEK mean? I mean, if this variable has something to do with weeks and there are 52 weeks in a year...maybe you do not really have more than 52 files in that directory? ...just reaching, here.
 
a subtle point to make

you said :- "...works fine until I get to the 53rd time in the LOOP then it crashes."

but, according to your code, there are 2 LOOPS where that could occur :-

Code:
do k=1,60
end do


and


Code:
do i=1,1096
end do


do you know WHICH of these loops is the culprit ?

if it's the first one (do k=1,60), then it might be that you only have 52 file names in your file "filenames" (unit 50).

by the way, is there a reason why you have made the 3rd dimension of your matrices = 525 ? can you make it 60, so it's the same size as the "k" do loop ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top