Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 324
Karl Yngve Lervåg Avatar asked Mar 19 '09 12:03

Karl Yngve Lervåg


1 Answers

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.

like image 151
Karl Yngve Lervåg Avatar answered Sep 18 '22 17:09

Karl Yngve Lervåg