Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

list-directed I/O syntax error

elias_arredondo
Beginner
11,725 Views

I am using the following code section to open files in a loop:

do i=1, n

FileName = FileNames(i)
open (49, file=FileName, status='old')

do j=1, NumSim
read (49,*) C(j), P(j)
enddo

close (49)

end do

It will always open the first file but will give me an error when trying to open the second file. The error reads:

forrtl: severe (59): list-directed I/O syntax error, unit 49, file...(file name)

The error indicates a problem with the data in the files but I am confused because I know there is nothing wrong with the files.I havetried switching the names of the first and second files and it will always work with the first one but not the second one.

I am a novice FORTRAN user and I would appreciate any help.

0 Kudos
2 Replies
Steven_L_Intel1
Employee
11,724 Views
You should be able to see which iteration of the loop the error occurs in (use the debugger or have the program print out j in the loop), Then look at that line of the source file. Post the line here (and maybe the two lines around it) as well as the declarations of variables C and P.

Some common causes of this are:

- Reading character strings that have blanks or punctuation in them that aren't enclosed in quotes
- NaN or Inf in the input file for reals
0 Kudos
elias_arredondo
Beginner
11,724 Views
Thank you for your reply. I did have an error in one of my data files and your suggestion helped me find it. As is often the case, this was a programmer error!
0 Kudos
Reply