How can I assign a number or value of variable into a character in Fortran77/90

后端 未结 1 771
礼貌的吻别
礼貌的吻别 2021-01-14 16:47

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.

相关标签:
1条回答
  • 2021-01-14 17:53

    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

    open (unit=10, file="test_x_"//chr_x(2:6)//".dat")
    

    instead.

    0 讨论(0)
提交回复
热议问题