Convert integers to strings to create output filenames at run time

前端 未结 9 2119
小鲜肉
小鲜肉 2020-11-22 02:47

I have a program in Fortran that saves the results to a file. At the moment I open the file using

OPEN (1, FILE = \'Output.TXT\')

However,

9条回答
  •  醉梦人生
    2020-11-22 03:29

    To convert an integer to a string:

    integer :: i    
    character* :: s    
    if (i.LE.9) then
         s=char(48+i)    
    else if (i.GE.10) then
         s=char(48+(i/10))// char(48-10*(i/10)+i)    
    endif
    

提交回复
热议问题