Good points. Personally, I think I always have at least an SP between the data descriptors.
I think the only time I do not is when I intend to read the values back in from the output file,
My favorite way of printing complex values is to make little functions
(typically in a module) that convert them to a string; as in the
following:
program main
implicit none
interface px; procedure px_s, px_d; end interface
complex :: c
integer :: i
c=(3.0,4.0)
! converting complex values to s string lets you create simpler formats
write(*,'(*(g0:,", "))')( px(i*c), i=1,3) ! list of values
write(*,'(*(g0:,", "))')[ px(c),px(c),px(c)] ! array
contains
function px_d(value) result(string)
! function to write complex value into a string using a format
complex(kind=kind(0.0d0)),intent(in) :: value
character(len=80) :: line
character(len=:),allocatable :: string
write(line,'("(",g0,SP,g0,"i)")')value
string=trim(line)
end function px_d
function px_s(value) result(string)
! function to write complex value into a string using a format
complex(kind=kind(0.0)),intent(in) :: value
character(len=80) :: line
character(len=:),allocatable :: string
write(line,'("(",g0,SP,g0,"i)")')value
string=trim(line)
end function px_s
end program main
(3.00000000+4.00000000i), (6.00000000+8.00000000i), (9.00000000+12.0000000i)
(3.00000000+4.00000000i), (3.00000000+4.00000000i), (3.00000000+4.00000000i)
I know the first time I formatted complex values I was a little surprised by how it works and was looking for descriptors specific to complex types, partly because list-directed and NAMELIST output wrote them looking like “(x,y)” and I was looking for a descriptor to match. So I think the edit is warranted on BOZ usage myself, but actually do wish there was a descriptor like “C” that would print it all like list-directed basically does with the parenthesis and comma. That would make it a lot easier to read in as well if there were a standard format defined by the descriptor.