output from fortran to excel

output from fortran to excel

hi everybody,

at firts i apologise my english after that,

i am using visual fortran for my acedemic thesis. i dont know fortran very well.

in my programme, i took a output excel file but when i took my output every data, all my data wrote first box in excel. for example i wanna took data for  first iteration a1, a2, a3 and second b1, b2, b3 but every data write one by one in a1 and b1.


how can i correct my false, would you help me



2 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You need to write your data to the file with delimiters. Excel can recognize a comma or a tab as a delimiter. If there are no recognized delimiters, then all the values will be assigned to the first cell.

As an example of how you might do this, if we assume that your data is in an array named R, one could use:

WRITE (2,'(*(G0.3,:,","))') R

What this does is, for each element in R, writes the value using the G0.3 format (it will use the minimum width needed and three decimal places - you can change this as desired). Then if there are additional elements to write, it puts in a comma and repeats for the next value, for as many values as there are.

Then when you open the file in Excel, either name the file with a .csv type or tell Excel that it is comma-delimited.

I will note that in some "locales", some delimiter other than comma can be used. Tab is a safer choice but is a bit harder to do easily in a format. You could do it something like this:

WRITE (2,'(*(G0.3,A))') (R(I),CHAR(10),I=LBOUND(R),UBOUND(R))

Retired 12/31/2016

Leave a Comment

Please sign in to add a comment. Not a member? Join today