Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top