(j3.2006) Seeming problem with NAMELIST output of charactervariables

Lionel, Steve steve.lionel
Thu Oct 9 09:57:47 EDT 2014


I agree with Malcolm here. The standard is quite clear as to what the behavior is supposed to be, even if some might consider it undesirable. Other users might not want to see quotes around their strings, especially in list-directed output. Making namelist formatting different from list-directed is not to the letter or spirit of the standard. The standard's default behavior (DELIM='NONE') matches that of IBM's implementation of NAMELIST back in the 1970s, after which F90's was clearly modeled (though with slightly different group introducer syntax.)

I'll note that ifort has, for historical reasons, some default behaviors that don't conform to the standard (though not this one) and we offer a command line option to reset these. If gfortran doesn't have something similar, maybe it could be added.

Steve

-----Original Message-----
From: j3-bounces at mailman.j3-fortran.org [mailto:j3-bounces at mailman.j3-fortran.org] On Behalf Of Malcolm Cohen
Sent: Thursday, October 09, 2014 3:13 AM
To: fortran standards email list for J3
Subject: Re: (j3.2006) Seeming problem with NAMELIST output of charactervariables

>I got an interesting test case that exposed what seems to be an 
>unfortunate consequence in the standard.

It is not a "consequence".

>9.5.6.8 says that the default for the DELIM= specifier is ?NONE? in an 
>OPEN statement.

>10.10.4 says that list-directed output of character values when DELIM 
>is  ?NONE? does not include enclosing quotes.

Fortran 95 directly states that this occurs when there is no DELIM= specifier.

>10.11.4.2 says that namelist output editing is the same as for 
>list-directed output.

Fortran 95 directly states the result (it does not refer to list-directed).

> And NOTE 10.39 says that DELIM=?NONE? [which is the default]  will 
> output character values that cannot be read by a namelist read.

That's "might not be acceptable as namelist input" (spelled "may..." in Fortran 95).

>So, in the default case (no DELIM specified in OPEN) we have the 
>situation that namelist output of character data cannot be read by a namelist input statement.
>Which is an unexpected situation for many users.

>Did we really intend that this be the case?

Whether we really intended this, this is Fortran 90.  So approved 23 years ago and unchanged since.  Even though we made other changes to namelist (we added namelist comments).

And obviously we DID intend this, indeed the text states it directly (originally not as a consequence, that is a result in F2008 of text merges and simplifications), and the NOTE is ample evidence we knew what we were doing. 
Some might consider that decision mistaken, but that was the decision nonetheless.

>At least one compiler (gfortran) ignores this combination of rules and 
>includes the ? ? around character values in namelist output, which is 
>what the user wanted/expected.

If there is no OPEN statement for the file, or the user does not want to change the behaviour of list-directed output, he can put DELIM='QUOTE' into his namelist output statement.

(oh, and this is not an "extension", it is giving the wrong answer; extensions are when things are upwards compatible.)

Cheers,
--
................................Malcolm Cohen, Nihon NAG, Tokyo. 

_______________________________________________
J3 mailing list
J3 at mailman.j3-fortran.org
http://mailman.j3-fortran.org/mailman/listinfo/j3
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6616 bytes
Desc: not available
Url : http://mailman.j3-fortran.org/pipermail/j3/attachments/20141009/444fdd05/attachment-0001.bin 



More information about the J3 mailing list