I understood through this post on how to use a variable in format string.
write(*,'(1x,f10.5)')(j(i),i=1,nvar) seems to work but the values in 'j' are displayed row-wise. I want them to be displayed side-by-side (column-wise) on the screen and onto a file too.
I am using, GNU Fortran (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39).
My code:
program test_fmt
implicit none
integer i, nvar
real ::j(2)=(/1.234,5.678/)
nvar=2
write(*,'(f10.5)')(j(i),i=1,nvar)
end
current output:
1.23400
5.67800
required output: 1.23400 5.67800
Might be trivial but I couldn't get my head around it.