Jacobian
Jacobian

Reputation: 10802

Write to file and prevent formating

I write to a file rows of (x,y) coordinates which are of real type. I do it in this way:

open(UNIT=23,FILE="plotdata.txt")
do while(...)
    write(23, *) x," ", y
enddo  
close(23)

But when I open the file I see a lot of extra space around numbers. But what I want is just a number, a space and the second number

Upvotes: 0

Views: 44

Answers (1)

Robert Redl
Robert Redl

Reputation: 126

you can try to use this format:

write(23, fmt="(F0.2, A1, F0.2)") x, " ", y

That will give you the numbers without surrounding spaces. The 2 is the number of digits behind the dot.

Upvotes: 3

Related Questions