Formatting in file using Fortran

Viewed 51
   do i=1,10
    write(21,19) (dai(i,j),j=1,10)
   end do
   19 format(10f12.10)

This is part of my code where I input in file, here 21 is unit of my file. I want to print 10x10 matrix in file such that only 10 digits are there after decimal. The output of this is formatted matrix but with elements having no space between them. Also if I remove format line from code the file output is usual 10x10 matrix(unformatted). What is wrong here?

1 Answers

If you want spaces in the formatted output, you have to include them in the format. Either explicitly using the appropriate descriptors or by increasing the fields for your numbers.

E.g.,

 19 format(10(f12.10,1x))

or

 19 format(10f25.10)
Related