Karl Yngve Lervåg
Karl Yngve Lervåg

Reputation: 1725

Suppressing line breaks in Fortran 95 write statements

I would like to write to the standard output in fortran without adding a line break. That is, I want to do something like this:

a='some string and '
b='some other string'
write(*,101) a
...
write(*,102) b
...
101 format(a,...)
102 format(a)

Is it possible to use some kind of format statement to supress the line break in 101, such that the code outputs "some string and some other string" on the same output line?

Note that it is important that the two write statements are separated, as the code in between is actually used to generate the second string.

Upvotes: 10

Views: 15576

Answers (1)

Karl Yngve Lervåg
Karl Yngve Lervåg

Reputation: 1725

You can used the advance='no' option:

a='some string and '
b='some other string'
write(*,101,advance='no') a
...
write(*,102) b
...
101 format(a)
102 format(a)

This will suppress the linebreak.

Upvotes: 17

Related Questions