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
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.