Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.fortran

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 07-10-2012, 10:54 AM
saman
Guest
 
Posts: n/a
Default Multiple matrix output

hi ,
I have three matrix called
Real, Dimension(::A,B,C
A=5,B=5,C=5
I want to print them to an external file where first column is A, 2nd column is B and the last is C. For example I want to have the following format in output:

15 20 1
12 21 4
18 12 2
15 12 3
60 78 4

I write this code but it is not what I want:

OPEN(35, file = 'phenotype',status="REPLACE")
DO cc=1,n
DO bb=1,n
DO aa=1,n
WRITE(35, '(F10.3,2x,F10.3,2x,F10.3)') phenotype(aa),genvalue(bb),E(cc)
END DO
END DO
END DO
CLOSE(35)

Can anybody help me?
best,
Sami
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 07-10-2012, 12:50 PM
glen herrmannsfeldt
Guest
 
Posts: n/a
Default Re: Multiple matrix output

saman <kaviani.saman@gmail.com> wrote:

> I have three matrix called
> Real, Dimension(::A,B,C
> A=5,B=5,C=5
> I want to print them to an external file where first column is A,
> 2nd column is B and the last is C.
> For example I want to have the following format in output:


(snip)

> Can anybody help me?


Someone probably can help you, but also might believe that you
should learn a little more before asking.

Your questions show that you are missing some very basic
programming ideas. Not just Fortran problems, but programming
pretty much in general.

One is that statements are, for the most part executed sequentially.
If you want something to happen before something else, the
statement should be earlier.

The second involves nesting. That all the statements inside
a loop are executed appropriately before the next iteration
of a loop. That is basic to the looping process.

You should get and read a book, try some of the examples
and see that the resutls are as expected. As you learn some
of the basic ideas, you will be ready for more advanced ideas.

-- glen
Reply With Quote
  #3 (permalink)  
Old 07-10-2012, 01:54 PM
Les Neilson
Guest
 
Posts: n/a
Default Re: Multiple matrix output


"saman" <kaviani.saman@gmail.com> wrote in message
news:224cc9c3-023c-4467-bbc7-e0f20b669609@googlegroups.com...
> hi ,
> I have three matrix called
> Real, Dimension(::A,B,C
> A=5,B=5,C=5
> I want to print them to an external file where first column is A, 2nd
> column is B and the last is C. For example I want to have the following
> format in output:
>
> 15 20 1
> 12 21 4
> 18 12 2
> 15 12 3
> 60 78 4
>
> I write this code but it is not what I want:
>
> OPEN(35, file = 'phenotype',status="REPLACE")


delete the next two lines
> DO cc=1,n
> DO bb=1,n


> DO aa=1,n


In the next line replace bb with aa and replace cc with aa
> WRITE(35, '(F10.3,2x,F10.3,2x,F10.3)')
> phenotype(aa),genvalue(bb),E(cc)


delete the next two lines
> END DO
> END DO


> END DO
> CLOSE(35)
>
> Can anybody help me?
> best,
> Sami



For Fortran books try :
Fortran 95/2003 for Scientists & Engineers by Stephen J Chapman
Fortran 95/2003 Explained by Michael Metcalf, John Reid and Malcolm Cohen
Modern Fortran Explained (Numerical Mathematics and Scientific Computation)
by Michael Metcalf, John Reid and Malcolm Cohen

there are others (Google Fortran books or see the Wikipedia Fortran page for
references to Textbooks)

Les

Reply With Quote
  #4 (permalink)  
Old 07-10-2012, 02:55 PM
saman
Guest
 
Posts: n/a
Default Re: Multiple matrix output

On Tuesday, July 10, 2012 12:54:54 PM UTC+2, saman wrote:
> hi ,
> I have three matrix called
> Real, Dimension(::A,B,C
> A=5,B=5,C=5
> I want to print them to an external file where first column is A, 2nd column is B and the last is C. For example I want to have the following format in output:
>
> 15 20 1
> 12 21 4
> 18 12 2
> 15 12 3
> 60 78 4
>
> I write this code but it is not what I want:
>
> OPEN(35, file = 'phenotype',status=&quot;REPLACE&quot
> DO cc=1,n
> DO bb=1,n
> DO aa=1,n
> WRITE(35, '(F10.3,2x,F10.3,2x,F10.3)') phenotype(aa),genvalue(bb),E(cc)
> END DO
> END DO
> END DO
> CLOSE(35)
>
> Can anybody help me?
> best,
> Sami



Dear Les
Thank you very much.
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 09:22 AM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.