- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i define a subroutine
but it no work
subroutine printrmat(matrix,row,column)
implicit none
integer row,column,,i,j
real(8) matrix(row,column)
do i=1,row
write(*,10) (matrix(i,j),j=1,column)
10 format(column(f))
end do
end subroutine
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi dousti,
try this (it works with Intel compilers but is not standard Fortran):
subroutine printrmat(matrix,row,column) implicit none integer, intent(in) :: row, column real(8), intent(in) :: matrix(row,column) integer :: i,j do i=1,row write(*,'(<column>ES16.8)') matrix(i,1:column) end do return end subroutine
Regards, Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The standard language offers an unlimited repeat count in format specifications, that can come in handy for these cases.
subroutine printrmat(matrix,row,column) implicit none integer, intent(in) :: row, column real(8), intent(in) :: matrix(row,column) integer :: i do i=1,row write(*,'(*(ES16.8))') matrix(i,:) end do end subroutine
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi IanH,
didn't know of that standard feature 'unlimited format repeat count' before. I've googled it and it was introduced with F08. It is implemented since Composer XE2011 in the Intel compilers.
https://software.intel.com/en-us/forums/intel-fortran-compiler-for-linux-and-mac-os-x/topic/270542
Hopefully other compilers (e.g. gfortran, ...) support it also in the stable releases.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi friends
tanks very much
i found a solution for problem
write(*,10) (matrix(i,j),j=1,column)
10 format(100(f))
or
write(*,10) (matrix(i,j),j=1,column)
10 format(1000(f))
or
...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi dousti,
good that you found a solution. But in my opinion it would be better to use 'unlimited format repeat count', '*', instead of the fixed number. In case you plan to use this print routine in future, you could avoid trouble later on...

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