|
|||
|
hi ,
I have three matrix called Real, Dimension( ::A,B,CA=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 |
|
|
||||
|
||||
|
|
|
|||
|
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 |
|
|||
|
"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 |
|
|||
|
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="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 Dear Les Thank you very much. |
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|