Fortran 90: Tab characters?
Fortran 90: Tab characters?
(OP)
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
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





RE: Fortran 90: 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.
RE: Fortran 90: Tab characters?
If you really want tabs, use char(9)