integer :: n
real, allocatable :: x(:)
n=5
allocate(x(n))
x=100.0
write(6,'( <n>(g15.7,1x) )') x
end
The output is
100.0000 100.0000 100.0000 100.0000 100.0000
Note that <n> in the format is support in Intel Fortran, which is very convenient in my opinion. So the format can be easily controlled by the the variable n.
I wonder does gfortran support such a thing or have something similar?
This is an Intel extension inherited from VMS. The easy way to remove the constructs is to write them to a string and then to embed the string in the format. There was a post describing this in comp.lang.fortran a long time ago which I haven’t managed to find. If you have a lot of them, fpt will make this change automatically - please see http://simconglobal.com/fpt_ref_remove_embedded_expressions_from_formats.html
John.