How to get a single column output?
The code is like this:
program column_test
implicit none
real ( kind = 8 ) , dimension ( 5 ) :: r
call random_number ( r )
print *, r
end program column_test
How to get a single column output?
The code is like this:
program column_test
implicit none
real ( kind = 8 ) , dimension ( 5 ) :: r
call random_number ( r )
print *, r
end program column_test
Try this one!
program column_test
implicit none
real ( kind = 8 ) , dimension ( 5 ) :: r
integer :: i
character(*), parameter :: newline = new_line("")
call random_number ( r )
print*, (r(i), newline, i=1, 5)
end program column_test
If you’re willing to pick up a couple dependencies,
program column_test
use iso_fortran_env, only: real64
use iso_varying_string, only: char
use strff, only: join, to_string, newline
implicit none
real(real64) :: r(5)
call random_number(r)
print *, char(join(to_string(r), newline))
end program
and you won’t get an extra newline at the end.
How about using a good old format
string?
program column_test
implicit none
real ( kind = 8 ) , dimension ( 5 ) :: r
call random_number ( r )
print "(g0)", r
end program column_test
If you don’t need to handle complex file structures, formatted output is far better than tinkering with strings IMHO (also way better than C/C++)
I think “complex file structures” should be “complicated file structures” in Fortran Discourse because the meaning of “complex” in Fortran may not be what FedericoPerini had in mind.