- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Greetings,
I am getting crazy with a trivial routine that systematically hungs my computer. It is a really trivial mnimal set of I/O instructions that I had written for a small computation program and I have then extracted in a stand-alone "project" (of just a few lines). Here is the code
OPEN (UNIT=5,FILE='INPUT.IN',STATUS='OLD',FORM='UNFORMATTED')
OPEN (UNIT=6,FILE='OUTPUT.OUT',STATUS='REPLACE')
WRITE(6,*) 1111
READ(5) A0
WRITE(6,*) 2222
WRITE(6,*) A0
CLOSE(6)
CLOSE(5)
END
Nothing could be simpler than this! Well, build is OK, but when I run this stupid program, it writes the "1111" in the output file and than it hangs. I have to terminate the dos-like window, but actually the .exe remains active - I can see it in the task manager and there is no way to terminate it. At the same time, it saturates my pagefile and I have to reboot.
With CVF I never had such a problem, with IVF this hyper-trivial task seems to be un-doable! I wonder what the hell I'm doing wrong?
Many thanks in advance.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN (UNIT=5,FILE='INPUT.IN',MODE='READ')
OPEN (UNIT=6,FILE='OUTPUT.OUT',MODE='WRITE')
WRITE(6,*) 1111
READ(5,*) A0
WRITE(6,*) 2222
WRITE(6,*) A0
CLOSE(6)
CLOSE(5)
END
In this way it normally works with CVF, but IVF gives error 59 at the READ instruction. I read the help and somewhat guessed that the input way has changed. I looked for "unformatted" and found the above solution. I thought that unformatted meant what the "*" is in Fortran77 but your answer suggests it is not the case. OK, so I have misunderstood how it works. But then, why the above old-style code no longer works?
Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It could be that there's an error in the input that's not detected by CVF, or there's a bug in IVF. Can you create a ZIP of the input file and attach it to a reply here? Don't attach the file itself as that might change some bits. Also, please show the declaration of variable A0.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
OPEN (UNIT=5,FILE='INPUT.IN',MODE='READ')
OPEN (UNIT=6,FILE='OUTPUT.OUT',MODE='WRITE')
WRITE(6,*) 1111
READ(5) A0
WRITE(6,*) 2222
WRITE(6,*) A0
CLOSE(6)
CLOSE(5)
END
The input file contains only a number, 5.3312. No declaration for the variable A0, it start with "A" so it should be implicitely interpeted as floating-point, shouldn't it? Anyway, I also tried adding a declaration: REAL A0, then REAL*4 A0, then REAL*8 A0, no change, I always get the following error message
forrtl: severe(256): unformatted I/O to unit open for formatted transfers, unit 5, file %directory%INPUT.IN
I attach the zipped input file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The input file begins with three non-ASCII characters, hex EF BB BF. What wrote this file?
If you want to read it, use this:
READ (5,'(3X,G6.0)') A0
That will skip over the three "garbage" characters and read just the number. You can't use list-directed input for this.
CVF would behave identically for this input file.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, sorry, I forgot to add the "*"!
READ(5,*)
Now I get the 59 error
forrtl: severe(59): list-directed I/O syntax error, unit 5, file etc.
The file has been written with a normal text editor (Window's notepad). I cannot give a formatted input because the file will be edited by hand by different users: some can put a blank before, others may not... I want to stress that this is a trivial operation I did thousand of times: open, read(5,*) a file containing a list of numbers, close, process data.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The file has been saved with UTF-8encoding.
I just used notepad to create a file test.txt and entered "5.312"
When Iedit the file and look at the hex data I see the following :
efbb bf35 2e33 3132 0d0a ...5.312..
Les
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

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