Silverfrost Forums

Welcome to our forums

input, reading from files problem.

25 Jan 2013 4:36 #11488

I'd appreciate some help with what I'm doing wrong:

  PROGRAM SNAP
  INTEGER :: SVA(500000,1),J
  WRITE(*,*) 'BEGIN'
  OPEN (UNIT=7,ACCESS='DIRECT',STATUS='OLD',RECL=500000, &
  FILE='N:CASE1.TXT',ACTION='READ')
  DO 5 J=1,500000,1
  READ(*,UNIT =7) SVA(J,1)

5 CONTINUE CLOSE(UNIT=7,STATUS='KEEP') WRITE (,) 'DONE ENTERING VALUES' WRITE(,) SVA(500000,1)
END PROGRAM SNAP

Compiling and linking file: FreeFormat1.f95 C:\Users\mike\Documents\FreeFormat1.F95(7) : error 265 - Duplicate UNIT keyword in READ control list Compilation failed.

thanks in advance. mike

25 Jan 2013 5:18 #11489

Line 7 must be:

READ(UNIT=7,*) SVA(J,1)

Detlef

25 Feb 2013 9:07 #11614

thanks

26 Feb 2013 5:26 #11617

Your read statement is not compatible with your file being declared as DIRECT and RECL = 500000 (4_byte words) Where did you get the file 'N:CASE1.TXT' from ? If it wasn't created by FTN95 you might have more problems to deal with it as a direct access file. (Check what record length the file should be.)

A likely change could be: from: DO 5 J=1,500000,1 READ(*,UNIT =7) SVA(J,1) 5 CONTINUE

to: READ (unit=7, rec=1) SVA(:,1)

Also, why is SVA declared as rank 2 ? Do you want to write out 500,000 values or only the last one ?

John

Please login to reply.