program main
character elname1*4, elname2*8, folder_name*15,filename*20
integer istat,istat2
real a
write(elname1, '(i4)') 200
write(elname2, '(i8)') 3336
folder_name=trim(adjustl(elname1))//trim(adjustl(elname2))
inquire(file=trim(folder_name), exist=istat)
write(*,*)istat
if (istat) then
print*, 'the file exist'
else
print*, 'the file no exist and will be created'
istat2=system( "Md "//trim(folder_name))
end if
istat2=CHDIR(trim(folder_name)) !改变当前目录到到文件夹
filename='data.txt' !打开写入数据的txt文件
open(308,file=filename,status='replace',form='formatted')
write(308,*) 500
close(308)
end program main
第一次运行结果.JPG (31.67 KB, 下载次数: 305)
第一次运行结果
第二次及多次运行结果.JPG (38.69 KB, 下载次数: 291)
第二次几多次运行结果
program test
integer i, k
character(80) msg
open(10,file='2003336\data.txt',iostat=i,iomsg=msg)
if(i/=0) then
call execute_command_line('md 2003336')
open(10,file='2003336\data.txt',iostat=i,iomsg=msg)
end if
if(i/=0) then
write(*,"(a)") trim(msg)
end if
pause
end
欢迎光临 Fortran Coder (http://bbs.fcode.cn/) | Powered by Discuz! X3.2 |