How can I assign a number or value of variable into a character in Fortran77/90
问题 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. My present code is: program test_print real*8:: x character*40:: chr_x x=1.d0 do i=1,6 write(chr_x,*) x open (unit=10, file="test_x_"//trim(adjustl(chr_x))//".dat") write(10,*)i,x x=x+0.2d0 ! Update x close(10) end do stop end program test_print Now this generates files with filenames: test_x_1.0000000000000000.dat test_x_1