Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
告知
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

Format anomoly

JohnNichols
高評価コントリビューター III
1,240件の閲覧回数

    !  Known Errors
4373 Write(*,8126)NJL,NM1
    Write(12,8126)

8126 FORMAT("    STOP  as " :: ,2I10)

The double colon does not cause an error, I mistyped, it should be inside the " "

Is this standard Fortran, what does it do?  

This is from the McMaster Uni program, I am down to a few minor errors and this traps two of them. 

0 件の賞賛
6 返答(返信)
Steve_Lionel
名誉コントリビューター III
1,234件の閲覧回数

Yes, it is standard conforming. Colon is a standard control edit descriptor that says to not process more of the format unless there are unused items in the I/O list. You have two of them, and the standard allows there to be no comma between them. I don't think it behaves any different than a single colon.

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

Steve,

Can the FORTMAT have more than one : at different positions in the FORMAT statement? e.g.

    !  Known Errors
4373 Write(*,8126)NJL,NM1 ! two items
    Write(12,8126)NJL ! one item
    Write(1,8126) ! no items

8126 FORMAT("    STOP  as :" : ,I10 :, I10)

Jim Dempsey

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

@jimdempseyatthecove wrote:

Steve,

Can the FORMAT have more than one : at different positions in the FORMAT statement?


Sure, no problem. But your example doesn't show the effect because the I10 would stop processing. The primary use of the colon edit descriptor is when you have non-data transferring descriptors you want to skip if there are no more items. The most common example of this is a comma-list.

 

program test
implicit none
integer :: a(5) = [1,2,3,4,5]
integer :: i

do i=1,5
  write (*,'(*(I2,:,","))') a(1:i)
  end do
end program test
D:\Projects>t.exe
 1
 1, 2
 1, 2, 3
 1, 2, 3, 4
 1, 2, 3, 4, 5

Without the colon, you'd see this:

 1,
 1, 2,
 1, 2, 3,
 1, 2, 3, 4,
 1, 2, 3, 4, 5,

 

 

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

>>The double colon does not cause an error, I mistyped, it should be inside the " "

From your code snip, I think one of the :'s should have been inside the ""'s and the other outside the ""'s.

Jim Dempsey

JohnNichols
高評価コントリビューター III
1,176件の閲覧回数

 

Screenshot 2023-04-08 095111.png

They are both inside the quotations.  I use it as simple device to line up numbers so it is quick to read. 

No idea why I use ::  always have, lost in the mists of time. 

 

This is from the McMaster Program, I have the code running, sorted out the last of the lost goto's, now to make sense of the thesis and the code, both are a little cryptic and the lack of a meaningful output is annoying.  

 

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

Great example!

I've had many occasions to want to do just that.

Jim Dempsey

返信