Suppose I\'m using a real variable x. I want to assign as a character so that I can use it for printing different filenames depending on the values of x in a do-loop.
Use an explicit format, something like
write(chr_x,'(f8.3)') x
(or even f0.3, but that is IIRC Fortran 95), or if you do not want rounding
f0.3
open (unit=10, file="test_x_"//chr_x(2:6)//".dat")
instead.