- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
! 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.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
@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,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
>>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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Great example!
I've had many occasions to want to do just that.
Jim Dempsey
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page