Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

output an array to a text file

Status
Not open for further replies.

GeorgeEllwood

Mechanical
Aug 22, 2006
134
Hello,
Can someone advise me on how to output an array to a text file? The array itself is ~600 x ~700 x 1. Ideally I'd like to output it to a file whilst the data retains it's position, i.e. ~600 columns not 1 column that I then have to go through and manually put back into the original columns.
I've tried *VWRITE but this seems to have limits of 19 parameters, I've tried using *MWRITE but this hasn't worked at all for me. Either giving out lots of ****** or just giving me one result or putting all the results into one column.
Thanks
George
 
Replies continue below

Recommended for you

Hello George,

Put your *VWRITE in a *do loop. It sould work fine.

Regards,

Orel

 
Hi Orel,
Thanks for the tip. I've tried that but it's writing all the data to the first column. Is there a way to keep the row and column structure of the array?
Thanks
George
 
*do,i,1,X
*vwrite,tab(%i%,1),tab(%i%,2),tab(%i%,3)
(F10.5, ' ', F10.5, ' ', F10.5)​
*enddo

' ' => separation between values (4 spaces here)
F10.5 => fortran format for numbers

I didn't test it so you might have to change it a little bit.

 
Ouch, didn't notice the 600 columns sorry, that won't work

 
Read *mwrite help and use that :

*mwrite,your_file,file_ext,,jik,600
(600F6.0)

Learn how to use fortran format number, here, F6.0 will right floats on 6 chars with 0 decimals ie :

----1. for 1 (- are blanks)

---1.1 for 1.1

If Ansys writes starts, it just tells you that the format is not right, like writing 1234.56 with F3.0

If you don't have exactly 600 colums, ve sure to replace 600 in both lines.

Tested it with random numbers on 50x600 table, works fine.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor