- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page