How to write without newline in Fortran?

I am writing a piece of code with which I am planning to write a file .txt

that contains a 10x10001 matrix:

do i = 1, 10
    read(1,10) seed !Read a number from file 1
    write(2,20) seed !Write that number in file 2
    do k = 1, 10000 
        seed = mod((a*seed),m)
        R = seed/m
        write(2,20) R !I want all these numbers to be next to the seed, not on new lines
    end do
end do

      

But everything is R

written on new lines.

Is there a way to separate each number with a space instead of a newline, or do I need to implement this same code using C ++ and pipelines?

+3


source to share


1 answer


You can do write

not add a newline at the end of the following code:



write(2, 20, advance="no") R

      

+3


source







All Articles