It does not change the issue with parens discussed here, but the article gives short shrift to non-advancing I/O and does not mention the issues that formatted line length limits cause in creating unexpected line breaks albeit that is a less common problem now-adays where line limits are often huge.
r
Using a loop and non-advancing I/O is perhaps verbose, but it is a very flexible alternative.
program testit
implicit none
real :: arr(30)
integer :: i
integer :: items
arr=[(sqrt(real(i)),i=1,size(arr))]
write(*,*)"using advance='no' and a loop"
do i=1,size(arr)
write(*,'(2x,f8.2)',advance='no')arr(i)
enddo
write(*,*)
! Agree star is better now; but big values used to be used. It was not
! clear what the max could be but generally could still get
! multiple lines when current line length was hit. Still true,
! as non-advancing I/O is not true stream I/O.
write(*,*)"using a big count"
write(*,'(2147483647(2x,f8.2))')arr
write(*,*)"sort of like writing format on the fly or VFE"
items=10 ! just for fun, allow changing number of items on line
do i=1,size(arr)
write(*,'(2x,f8.2)',advance=merge('yes','no ',modulo(i,items).eq.0))arr(i)
enddo
!write(*,*)"implied loop not the same"
! subtle, but note this is not the equivalent of the above loop
!write(*,'(2x,f8.2)',advance='no')(arr(i),i=1,size(arr))
! sometimes list-directed is close enough
write(*,*)arr
end program testit
since Fortran lacks a standard way of declaring stdout to be stream I/O it only applies to named output files but that is of course a more robust way to write an unlimited number of values without line breaks and is a bit overkill for most cases but does avoid the issues with formatted line length limits
More along the lines of the original question I use character variables to hold formats very frequently and it bothered me enough that I made a function to add the parentheses but it was not very satisfying so I pretty much have quit using it but it basically just returned ‘(’//string//‘)’. Seemed like a nice idea at first but was really about as much work to use as adding the parenthesis in the first place.