Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

ANSYS: Writing large string/values arrays into a txt file using VWRITE

Status
Not open for further replies.

jgrzmmm

Mechanical
Nov 12, 2011
3
Hello,

Here’s the short summary. I have two arrays:

- String array:

*DIM,header_names,STRING,128,50

header_names (1,1)='name_longer_than_8_digits’
header_names (1,2)='another_name’
header_names (1,3)= 'yet_another_name’

header_names (1,50)=’last_name’

- Values array:

*DIM,values, ,50,100

*DO,x,1,50
*DO,y,1,100

values(x,y)=x+y

*ENDDO
*ENDDO

The main point here is that my macro is supposed to work on more than 19 parameters (which is a limtation for VWRITE) and the number of parameters is varying depends on user input. Using of manually created series of “%G,%G,%G …” or “%C,%C,%C …” corresponding to the number of elements in array is what I would like to avoid.

Having the following for writing into txt file:

- String array:

*CFOPEN,results,txt
*VWRITE,header_names(1,1)
%C,
*CFCLOS

results in writing the headers as a column instead of row.

- Values array

*CFOPEN,results,txt,,append
*VWRITE, values(1,1)
(2x,f18.6,$,',')
*VWRITE,
(1x)
*CFCLOS

Values are written properly, only one line, but horizontally, so that’s what I want to achieve. How can this be done for headers, should I define the string array differently, or use different Fortran/C operators ?

Thank you,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor