- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If memory serves correct, I used to write data using statements like
A = something
B = something
write (6, '(fmt') A, B, A/B
i.e., I want to write the ratio of A/B without explicitly calculating it and assigning to an intermediate variable (just to save the declaration), by including the expression A/B in the I/O list. I thought this used to work consistently (I don't know how long ago or which version, perhaps F77).
When I try this now, I observe that the statement "works" in the sense of writing the correct result. But SOMETIMES it will mess up the value of one or more other variables (depending on where they are stored in memory relative to A or B?), which then results in obscure errors elsewhere in the program. This can be very difficult to track down.
Checking the documentation, I now see that expressions in an I/Olist are not allowed. If this is so, shouldn't the compiler catch an illegal statement such as the above write and at least issue a warning?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There's no problems with expressions in an output (WRITE) list. Obviously it doesn't work for a READ. Can you come up with a real example that fails? Also, please point to the place in the documentation where you think it says this is not allowed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In the documentation, I looked up "WRITE statement" and find many different forms, all of which have an optional [io-list] as the last item. The table then defines [io-list] as "the names of the variables, arrays, array elements, or character substrings from which or to which data will be transferred. Optionally an implied-DO list." Hence my conclusion.
Investigating further, if I click on "I/O list" I am taken to another document area that states
"However, constants and expressions can appear in the I/O lists for output statements because the compiler can use temporary memory locations to hold these values during the execution of the I/O statement."
So I guess it is only the "WRITE" documentation that is wrong, and not the "I/O Lists" documentation.
Can I reproduce the problem and submit it? Probably not, because it is intermittant, and behaves differently on different computers. But I will try. (fyi: the problem surfaces on a 64-bit Win7 computer running IVF12.1, while the same program was OK on a 32-bit WinXP computer running IVF11.10)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thanks. I asked our writers to enhance that text a bit.

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