This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug fortran/45710] WRITE of NAMELIST group to internal file contains newline characters
- From: "burnus at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Sep 2010 07:56:21 -0000
- Subject: [Bug fortran/45710] WRITE of NAMELIST group to internal file contains newline characters
- References: <bug-45710-18131@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from burnus at gcc dot gnu dot org 2010-09-20 07:56 -------
(In reply to comment #0)
> In gfortran a WRITE of a NAMELIST group into an internal file appears to all
> go into the first record.
[...]
> only major complaint with that is that I first guessed that your output
> into an internal file would be formatted just like it was to stdout.
>
> But gfortran output to stdout or to a file writes in a very different format,
> putting one keyword=value per line (which I like, but is also not required by
> any standard requirement I can find).
If you use a scalar string, there is only a single record - thus gfortran has
no choice then using only one record. You could instead use a character array,
e.g.
character(30) :: str(6)
integer :: a, b, c, d
namelist /nml/ a,b,c,d
str = ''
write(str,nml=nml)
write(*,'(a)')str
end
>From the F2008 standard:
"If the file is a scalar character variable, it consists of a single record
whose length is the same as the length of the scalar character variable. If the
file is a character array, it is treated as a sequence of character array
elements. Each array element, if any, is a record of the file."
(In reply to comment #4)
> This issue, line ending for namelist to character arrays, has come up before.
> I don't remember the outcome of that previous discussion. I will research a
> little.
Well, in gfortran character arrays seem to do what urbanjost would like to
have: A new record for each namelist element.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45710