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!

Fortran 90: Tab characters?

Status
Not open for further replies.

Koarle

Materials
Jun 30, 2006
8
BE
Hello,

I have small Fortran 90 question (compaq visual fortran).

I want to write a matrix in an output file, and separate each element of the matrix by a "tab-character". I have found the control edit descriptors to make a tab character in fortran output (e.g. TR1, TL1 or T1), but when I run my code Fortran always seems to write a space instead! This makes it difficult to directly open my text file in excel.

Is it possible to write Tab characters between elements of a matrix please in Fortran? I have included an example of my code below.

Thanks a lot!

Karel

Example:
write(910, fmt = '(3(es12.6e2,TR1))', advance = 'yes') 1.0d0, 2.0d0, 3.0d0

 
Replies continue below

Recommended for you

The "TL" and "TR" format specifiers just change the position in the current line where the next part of the output will go; they don't result in insertion of tab characters.

Doing what you want is fairly easy. Basically, you want to write a character that has the value of the tab, which is 09. One way is to define a character variable of length one and initialize it to CHAR(9); then just include that variable in the I/O list, with an A format spec to go with it. You could imbed the character in a literal in the format string, but the appearance on screen with your editor may look strange and be hard to work with.
 
If you're going to import into Excel, it would be better to use comma separated.

If you really want tabs, use char(9)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top