For Programmers: Free Programming Magazines  


Home > Archive > Fortran > August 2007 > format printing [Was: Why Fortran?]









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author format printing [Was: Why Fortran?]
fred

2007-08-26, 4:27 am

David Thompson <dave.thompson2@verizon.net> a écrit :
[color=darkred]
>

Well, you re-up this thread, so...

I re-ask my question.

The C line above prints each variable separared by a blank
char.

My question is twofold:

1) How can I do this in fortran ?
The "%g" means that it prints "12" if x=12 and not "12.0000"

2) How can I avoid the broken line beyond (72 ?) characters printed ?
I would like to have all the characters on the same line (say I want to
print 10x10 matrix).

TIA.

Cheers,

--
http://scipy.org/FredericPetit
Dr Ivan D. Reid

2007-08-26, 7:14 pm

On Sun, 26 Aug 2007 10:50:13 +0200, fred <fredantispam@free.fr>
wrote in <87k5rik7cq.fsf_-_@free.fr>:
> David Thompson <dave.thompson2@verizon.net> a écrit :


[color=darkred]
[color=darkred]
> Well, you re-up this thread, so...


> I re-ask my question.


> The C line above prints each variable separared by a blank
> char.


So will Fortran list format (*) or an explicit format should you
so desire.

> My question is twofold:


> 1) How can I do this in fortran ?
> The "%g" means that it prints "12" if x=12 and not "12.0000"


C is, IMHO, severely broken in this respect -- you can't tell by
inspection of the output whether x is an integer or a real. OK, it's
possible to get the same effect in Fortran, but you have to _try_.

> 2) How can I avoid the broken line beyond (72 ?) characters printed ?
> I would like to have all the characters on the same line (say I want to
> print 10x10 matrix).


Specify a different record length in your OPEN statement. (You
will need to use an explicit OPEN if you are writing to standard output,
to over-ride the default).

--
Ivan Reid, School of Engineering & Design, _____________ CMS Collaboration,
Brunel University. Ivan.Reid@[brunel.ac.uk|cern.ch] Room 40-1-B12, CERN
KotPT -- "for stupidity above and beyond the call of duty".
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com