- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Look into the unlimited format item option in the language standard e.g., fmt="(*(F8.2,1X))"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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))
Regards, Greg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Another option is to use something like this:
write(1,'(100f8.2)') bt(i,1:m)
where 100 is guaranteed to be bigger than any m. Note that the format can allow more than you use.
Gib
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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:

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page