In addition to the unlimited format item, I've had success using this syntax with a value in the <> brackets before the format type specifier in this snippet example:
numColumn = 8
do row=1,numRow write(*,1)array(row,1:numColumn) end do 1 format(<numColumn>(e16.8))
Another option is to use something like this:
where 100 is guaranteed to be bigger than any m. Note that the format can allow more than you use.
You could consider less restrictions on the format of output.txt. I would suggest you place more information in the file and make it "easier" to "view". Unless you have a very large matrix to transfer, the extra overhead of the approach below should not be a significant issue.
program Console8 implicit none integer(8) :: i,n,m real,allocatable ::bt(:,:) open(unit = 11, file ='output.txt') read*,n,m allocate(bt(n,m)) write (11,*) n, " rows of matrix" do i=1,n write (11,*) i,m bt(i,1:m) = i do j = 1,m write(11,*) bt(i,j) end do end do end program Console8
Greg T. wrote:
In addition to the unlimited format item, I've had success using this syntax with a value in the <> brackets before the format type specifier ..
A caveat: this is an extension, not part of the Fortran standard.
John Campbell's solution is a good one if you wish to avoid formatting.
Here's a tweak of your program using formatting, and Greg T's comment: