Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

simple question about writting
Hi all,
I would like to know how can I write in Fortran77 to the std. out
without putting a new line character at the end of the writting.
Furthermore I would like to know how to write a new line character.

What I want to do is to print a m x n matrix using a double loop, so I
will only put new lines after the last item in each row.

Thanks for your help. I am a newbie and my teacher didn't talk this in
class.


Report this thread to moderator Post Follow-up to this message
Old Post
beatdown
05-11-05 01:58 AM


Re: simple question about writting
beatdown wrote:


> I would like to know how can I write in Fortran77 to the std. out
> without putting a new line character at the end of the writting.
> Furthermore I would like to know how to write a new line character.

That is hard.

> What I want to do is to print a m x n matrix using a double loop, so I
> will only put new lines after the last item in each row.

That is easy.  Write each row with one WRITE statement and the
appropriate format inside a DO loop.

DO 1 I=1,M
1     WRITE(6,2) (A(J,I),J=1,N)
2     FORMAT(1X,100G20.10)

(I am not sure between your m and n which is rows and which columns.
It is preferred in Fortran to very the leftmost subscript fastest in
nested loops.)

In Fortran 77 each WRITE always starts a new line.  The FORMAT above
will print up to 100 numbers on a line, up to 2000 characters long.
It is legal to write less than the FORMAT statement describes.

-- glen



Report this thread to moderator Post Follow-up to this message
Old Post
glen herrmannsfeldt
05-11-05 01:58 AM


Re: simple question about writting
"beatdown" <ruben.santacruz@gmail.com> wrote:

>Hi all,
>I would like to know how can I write in Fortran77 to the std. out
>without putting a new line character at the end of the writting.

Check your users' manual for an extension that will allow this.
It is most likely to be a format descriptor like "$" or "\"

>Furthermore I would like to know how to write a new line character.

write(*,*)

>What I want to do is to print a m x n matrix using a double loop, so I
>will only put new lines after the last item in each row.

Look up "implied do list" in your manual for a better way than
using a double loop.

>Thanks for your help. I am a newbie and my teacher didn't talk this in
>class.


--
Mike Prager, NOAA, Beaufort, NC
Address spam-trapped; remove color to reply.
* Opinions expressed are personal and not represented otherwise.
* Any use of tradenames does not constitute a NOAA endorsement.

Report this thread to moderator Post Follow-up to this message
Old Post
Michael Prager
05-11-05 01:58 AM


Re: simple question about writting
In article <UeqdneEdDY8rnBzfRVn-tQ@comcast.com>,
glen herrmannsfeldt  <gah@ugcs.caltech.edu> wrote:
>beatdown wrote:
>
> 
>
>That is hard.

ADVANCE='NO' has been part of Fortran for about 15 years. Why stay with
f77? There are two free f95 compilers available. A valid f77 program is
(with very minor exceptions) a valid f95 program.

John Harper, School of Mathematics, Statistics and Computer Science,
Victoria University, PO Box 600, Wellington, New Zealand
e-mail john.harper@vuw.ac.nz phone (+64)(4)463 5341 fax (+64)(4)463 5045

Report this thread to moderator Post Follow-up to this message
Old Post
John Harper
05-11-05 01:58 AM


Re: simple question about writting
beatdown wrote:
>
> What I want to do is to print a m x n matrix using a double loop, so I
> will only put new lines after the last item in each row.

Try,
write(*,fmt(n)) ((a(i,j), j=1,n), i=1,m)

where "fmt" is a tiny char fcn which you should try and write - from
then on, parts or all of your matrix print can be manipulated by simply
twiddling with m & n.


Report this thread to moderator Post Follow-up to this message
Old Post
bv
05-11-05 09:00 AM


Re: simple question about writting
Thanks you all.
I have solved the problem using something similar to glen's solution. I
use fortran77 because my teacher wants me to do this. I will ask him
why not moving to f95.
Bye.


Report this thread to moderator Post Follow-up to this message
Old Post
beatdown
05-11-05 01:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Fortran archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 09:50 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.