Hello,
I am used to the lahey fortran compiler..... recently I have switched
to the gfortran compiler.... now when I write out data the default
puts several spaces between variables in the outputted text file....
for example if I do: write (11,*) Data(:)
the text file will have several spaces between the Data variables in
the file 11.... In lahey the default was set to 2 I think... how do i
change this to 2 in gfortran?
Regards,
John Hickey
|
|
0
|
|
|
|
Reply
|
JohnHickey
|
2/3/2011 1:26:41 AM |
|
On Feb 2, 8:26=A0pm, JohnHickey <hickeyj...@gmail.com> wrote:
> Hello,
>
> I am used to the lahey fortran compiler..... recently I have switched
> to the gfortran compiler.... now when I write out data the default
> puts several spaces between variables in the outputted text file....
> for example if I do: write (11,*) Data(:)
> the text file will have several spaces between the Data variables in
> the file 11.... In lahey the default was set to 2 I think... how do i
> change this to 2 in gfortran?
>
> Regards,
>
> John Hickey
You change it by using an explicit format, for example
write (11,"(1000(f0.4,1x)") Data(:)
assuming Data(:) is real.
The free g95 compiler uses fewer spaces in list-directed output. You
could try it.
|
|
0
|
|
|
|
Reply
|
Beliavsky
|
2/3/2011 2:02:39 AM
|
|
JohnHickey <hickeyjohn@gmail.com> wrote:
> I am used to the lahey fortran compiler..... recently I have switched
> to the gfortran compiler.... now when I write out data the default
> puts several spaces between variables in the outputted text file....
> for example if I do: write (11,*) Data(:)
> the text file will have several spaces between the Data variables in
> the file 11.... In lahey the default was set to 2 I think... how do i
> change this to 2 in gfortran?
Variants of this count as a frequently asked question here. The specific
question varies, but the general theme is asking how to control
list-directed output formatting.
The answer is invariably to not use list-directed formatting when you
care about the details. Use an explicit format instead.
The whole point of list-directed formatting is to make things simple by
not bothering to specify detaults, but to let the compiler put out the
data in whatever way it wants. (Well, not quite whatever way; there are
some specifications in the standard, but the compiler is still left a
lot of liberty).
If you want to specify the formatting details, that's what explicit
formats are for. Yes, that is often more awkward than list-directed.
No, there do not tend to be ways for you to control the details of
list-directed formatting. I have commented several times that the
user-defined output feature of f2003 could trivially be enhanced to
allow this, but there doesn't seem to be much general interest in such
an enhancement. Heck, there doesn't seem to be much rush to implement
even the feature as it is in the f2003 standard. It is one of the last
f2003 features in terms of implementation progress.
P.S. Well, in theory there are ways to control such things in gfortran.
It being open source, you could change it yourself, but I'm going to go
out on a limb and guess that's not what you had in mind. (I'm feeling
pretty steady on that limb. :-)
--
Richard Maine | Good judgment comes from experience;
email: last name at domain . net | experience comes from bad judgment.
domain: summertriangle | -- Mark Twain
|
|
0
|
|
|
|
Reply
|
nospam
|
2/3/2011 2:27:46 AM
|
|
On Feb 2, 9:27=A0pm, nos...@see.signature (Richard Maine) wrote:
> No, there do not tend to be ways for you to control the details of
> list-directed formatting.
True, but in g95 one can set the G95_LIST_SEPARATOR variable, which is
the
"string Separator to use when writing list output. May contain any
number of spaces and at most one comma. Default is a single space."
http://g95.org/docs.shtml
|
|
0
|
|
|
|
Reply
|
beliavsky (2207)
|
2/3/2011 1:39:54 PM
|
|
On 02/03/2011 02:39 PM, Beliavsky wrote:
> On Feb 2, 9:27 pm, nos...@see.signature (Richard Maine) wrote:
>> No, there do not tend to be ways for you to control the details of
>> list-directed formatting.
>
> True, but in g95 one can set the G95_LIST_SEPARATOR variable, which is
> the "string Separator to use when writing list output. May contain any
> number of spaces and at most one comma. Default is a single space."
Which also does not really toggle between the two design choices:
One group of compilers adds many spaces such that when writing multiple
lines, a nice grid is created and numbers belonging to each other are
underneath each other.
The other group adds just a single space and avoids filling the space
with useless spaces; typically that a good choice if one wants to print
only a single line.
There is an additional design choice: Whether a line break should happen
automatically such that no line is longer than a certain number of
characters or whether one simply writes in one line as long there is
still data left in the IO transfer statement.
I think there are good reasons for those 4 combinations. Usually, I
would like to have a different result at different places in my program
- without tweaking the edit descriptor.
At least "g0" is a convenient edit descriptors which usually gives the
desired result without requiring the user to think too much. :-)
Tobias
PS: There are more choices in list-directed I/O, e.g. how many digits
should be printed, but I think the two mentioned above are the most visible.
|
|
0
|
|
|
|
Reply
|
burnus (564)
|
2/3/2011 2:31:51 PM
|
|
On 02/03/2011 06:31 AM, Tobias Burnus wrote:
> On 02/03/2011 02:39 PM, Beliavsky wrote:
>> On Feb 2, 9:27 pm, nos...@see.signature (Richard Maine) wrote:
>>> No, there do not tend to be ways for you to control the details of
>>> list-directed formatting.
>>
>
> At least "g0" is a convenient edit descriptors which usually gives the
> desired result without requiring the user to think too much. :-)
>
> Tobias
>
> PS: There are more choices in list-directed I/O, e.g. how many digits
> should be printed, but I think the two mentioned above are the most
> visible.
I though only the i, f, b, o, and z edit descriptors could have zero width?
|
|
0
|
|
|
|
Reply
|
baf (63)
|
2/3/2011 4:52:38 PM
|
|
On 2/3/11 10:52 AM, baf wrote:
> On 02/03/2011 06:31 AM, Tobias Burnus wrote:
>> On 02/03/2011 02:39 PM, Beliavsky wrote:
>>> On Feb 2, 9:27 pm, nos...@see.signature (Richard Maine) wrote:
>>>> No, there do not tend to be ways for you to control the details of
>>>> list-directed formatting.
>>>
>>
>> At least "g0" is a convenient edit descriptors which usually gives the
>> desired result without requiring the user to think too much. :-)
>>
>> Tobias
>>
>> PS: There are more choices in list-directed I/O, e.g. how many digits
>> should be printed, but I think the two mentioned above are the most
>> visible.
>
> I though only the i, f, b, o, and z edit descriptors could have zero width?
>
>
True for Fortran 2003, Fortran 2008 also allows zero width for G.
Dick Hendrickson
|
|
0
|
|
|
|
Reply
|
dick.hendrickson (1286)
|
2/3/2011 5:19:29 PM
|
|
On 02/03/2011 05:52 PM, baf wrote:
> I though only the i, f, b, o, and z edit descriptors could have zero width?
It was added with Fortran 2008. I tend to forget that it was a 2008 and
not a 2003 addition as gfortran supports it since GCC 4.4 (i.e. since
more than 2 years). [1]
Thus, if one restricts oneself to gfortran and Cray [2], one can already
use g0. Otherwise, it might be better to restrict oneself to the other
edit descriptors.
Tobias,
who is looking forward to see compilers with full - well-tested -
Fortran 2003 (and possibly also Fortran 2008) support.
[1] http://fortranwiki.org/fortran/show/Fortran+2008+status
|
|
0
|
|
|
|
Reply
|
burnus (564)
|
2/3/2011 5:25:18 PM
|
|
"JohnHickey" <hickeyjohn@gmail.com> wrote in message
news:a934a4ba-b51b-45ce-abce-b43a12dfd654@n11g2000vbm.googlegroups.com...
| Hello,
|
| I am used to the lahey fortran compiler..... recently I have switched
| to the gfortran compiler.... now when I write out data the default
| puts several spaces between variables in the outputted text file....
| for example if I do: write (11,*) Data(:)
| the text file will have several spaces between the Data variables in
| the file 11.... In lahey the default was set to 2 I think... how do i
| change this to 2 in gfortran?
With * as the format, the compiler can use any layout that it likes.
If you want specific layout, best to use an explicit format.
That way you can control the position of spaces and how many of them.
|
|
0
|
|
|
|
Reply
|
robin
|
2/7/2011 12:35:43 AM
|
|
|
8 Replies
192 Views
(page loaded in 2.015 seconds)
Similiar Articles: ftnchek: identifier has embedded space - comp.lang.fortran ...With gfortran, you can also use -std=3Df95 (or -std=3Df2003) to restrict the ... memory size allowed in malloc - comp.lang.c ftnchek: identifier has embedded space ... Simply Fortran IDE for gfortran on Windows - comp.lang.fortran ...The IDE uses gfortran 4.5.0 as the compiler, but this can be changed. Maybe it will ... On second look, it seems it is a problem with blank space in folder name. how to assign a NaN? - comp.lang.fortran| the missing value is represented by an empty string '' ! two quotes | without a space | | I am using gfortran which has the isnan(x) to check for nan. Reading an unformatted file - comp.lang.fortranYes, there *ARE* applications where disk space is important. My applications have ... in principle a simple unformatted sequential I/O should work between g95, gfortran ... Fortran 77/90/95 free compiler - comp.lang.fortranIt's best to avoid installing to a directory with spaces in the path name. ... Seewww.lepsch.com/2009/05/downloads.html >> >> for G77, G95 and Gfortran versions of ... How to write a degree sign - comp.lang.fortranAlso there is a space between the number and the unit abbreviation. All of this ... works in CVF 6.6 in Windows, but gives a question mark in a wee box in > > gfortran on ... namelist input of multidimensional array? - comp.lang.fortran ...... array via a namelist file in Fortran 95 (I'm using a reasonably current "gfortran ... to this write/read symmetry involve character items with embedded spaces or ... Commercial Fortran Compilers - comp.lang.fortran> >If you wished to use gfortran or g95 under Windows, depending on how >sophisticated ... ftnchek: identifier has embedded space - comp.lang.fortran ... If you cannot afford ... problem with mixed c and fortran code - comp.lang.fortran ...C:\gfortran\clf\char_c>type char1.f90 function char1(x) character*(*) char1, x ... If the type has class MEMORY, then the caller provides space for the return value ... Needle problem simulation (Geometric distirbution) - comp.soft-sys ...... en.wikipedia.org/wiki/Knitting_needle or a hypodermic needle: http://en.wikipedia.org/wiki/Hypodermic_needle or the Space Needle: http://en.wikipedia.org/wiki/Space ... GFORTRAN Overview - NIU - Northern Illinois University - Learning ...The GNU GFORTRAN Compiler. We will be using a FORTRAN compiler called gfortran, created ... There is no space between the -I option and the directory name. gfortran - LinuxCommand.org: Learn the Linux command line. Write ...GFORTRAN(1) GNU GFORTRAN(1) NAME gfortran - GNU Fortran 95 ... in typical fixed-form lines in the source file, and through which spaces ... 7/26/2012 6:18:00 AM
|