This program unsuccessfully attempts to print an array on one line using an implicit loop in the format specification. It succeeds in doing the job with an explicit loop.
program cycle
implicit none
integer, dimension(5) :: a=(/1,2,3,4,5/), b=(/11,12,13,14,15/)
integer :: n, i
Print *, "Implicit loop"
print "(i0, 1x)", (a(i)*b(i), i=1,n)
Print *, "Explicit loop"
do i=1,n-1
write(*, '(i0, 1x)', advance = "no") a(i)*b(i)
end do
write(*, '(i0)') a(n)*b(n)
end program cycle
Here is the result:
Implicit loop
11
24
39
Explicit loop
11 24 39
How do I make the implicit loop print everything on a single line? Is it even possible? My attempts at inserting advance="no", surrounded by various commas and parentheses, have not worked.
nis never given a value.ais never modified, why not useinteger, parameter :: a(*)= [1, 2, 3, 4, 5].nis important, but the change you made left the code uncompilable. Although you didn't have comment privelege at that time, such things are best done (as with High Performance Mark's comment) by requesting clarification from the author.