将整数转换为文件名不正确地超过一位数

时间:2017-04-28 04:34:03

标签: loops fortran writefile

Program main 
use ifport 

implicit none
integer ii,fileid 
double precision pi
logical result
character*256 path,filename,fileNum
pi = 4.d0*datan(1.d0)
ii = 20
path = './testforlder'

result = makedirqq(path)

Do ii = 1, 11

fileid = 1 + ii
write(fileNum,"(A10,I1,A4)") "/TimeStep-",ii,".txt" 
filename = trim(path)//trim(fileNum)
open(unit = fileid,file=filename,status='unknown')
write(fileid,*) "The result is:", ii,pi,2*pi
close(fileid)

End Do  

pause
End Program   

我的代码如上所述。当循环步长小于10时,它可以工作。然而,当循环步骤> = 10(例如:11)时,它失败。

0 个答案:

没有答案