- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here is test code. It reads properly the first time when text=".", but fails after writing (which causes removal of quotes) and rereading.
character(len=10)::text
namelist/l/text
open(1,file='test.in',action='read')
read(1,l,err=999)
write(*,l)
close(1)
open(1,file='test.in',action='write')
write(1,l)
close(1)
open(1,file='test.in',action='read')
read(1,l,err=999)
write(*,l)
stop
999 continue
write(*,*)'ERROR in namelist read'
end
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Using "Program Files"\Intel\"Composer XE 2015" ...
With the G95 Fortran compiler there is no problem, because the quotes surrounding a character variable are not removed in a namelist write. This would seem the more logical approach. I wonder why Intel does not do this. And, I wonder if there is some way to force the retention of quotes around a character variable. The work around is something I'd like to avoid--writing my own code to simulate a G95-type namelist write.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
We don't do it because the standard says not to. G95 is defaulting to nonstandard behavior here. You can open the unit with DELIM="QUOTE" if you want the quotes.
NOTE 10.40 Namelist output records produced with a DELIM= specifier with a value of NONE and which contain a character sequence might not be acceptable as namelist input records.
9.5.6.8 DELIM= specifier in the OPEN statement
1 The scalar-default-char-expr shall evaluate to APOSTROPHE, QUOTE, or NONE. The DELIM= specifier is permitted only for a connection for formatted input/output. It specifies the delimiter mode (9.6.2.8) for list-directed (10.10.4) and namelist (10.11.4.2) output for the connection. This mode has no effect on input. It is a changeable mode (9.5.2). If this specifier is omitted in an OPEN statement that initiates a connection, the default value is NONE.

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