×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

output an array to a text file

output an array to a text file

output an array to a text file

(OP)
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

RE: output an array to a text file

Hello George,

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

Regards,

Orel

RE: output an array to a text file

(OP)
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

RE: output an array to a text file

*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.

RE: output an array to a text file

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

RE: output an array to a text file

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources