Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to save a matrix

Status
Not open for further replies.

vibhava

Programmer
Apr 20, 2008
19
US
hi,
i wish to save a 250rows x 2557columns matrix that i am getting at the end of my program to a .csv file.
e.g. I get a file xyz(250,2557) but when i am trying to write it in a .csv file using "write" statement all the columns are being written one below the other (instead of being written in 250 different columns)

can anyone tell me how can i achieve this.

thanks

vibhava
 
Note that in Fortran the 2nd index changes fastest so you might want to redeclare your array as xyz(2557,250). If you don't do that then you'd have to write it as
Code:
integer, parameter:: rowmax=2557, colmax=250

do irow = 1, rowmax
   write (20, 100) (xyz(icol,irow), icol = 1, colmax)
enddo
100 format (1X,250(F5.2,','))
If you swap the rows and columns then it becomes
Code:
write (20, 100) xyz

Note that some output devices will automatically give you a carriage return after a specified number of characters.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top