Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29602 ディスカッション

problem in format statment

dousti_a_
ビギナー
1,678件の閲覧回数

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

 

 
 
0 件の賞賛
5 返答(返信)
Johannes_Rieke
新規コントリビューター III
1,678件の閲覧回数

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

IanH
名誉コントリビューター III
1,678件の閲覧回数

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


 

Johannes_Rieke
新規コントリビューター III
1,678件の閲覧回数

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.

dousti_a_
ビギナー
1,678件の閲覧回数

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

...

Johannes_Rieke
新規コントリビューター III
1,678件の閲覧回数

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

返信