write in array format in fortran

后端 未结 1 1890
庸人自扰
庸人自扰 2020-12-21 23:30

I try to write an output file.dat with an nxn matrix format .

I write the code but the output is a column of value f.

Now the problem is: how can i

相关标签:
1条回答
  • 2020-12-22 00:23

    This statement

    write(20,*) f(i,j)
    

    will write the value of f(i,j) then move to the next line, so the file you're getting is exactly what your code is specifying. If you want the file to contain n rows each with n values try

    write(20,*) f(i,:)
    

    which ought to make a good stab at writing the whole of row i of the array to a single line in the output file. Of course, this makes your loop over j redundant so you can remove it.

    0 讨论(0)
提交回复
热议问题