Fortran批量创建及调用文件
直接上Fortran代码
program Console10
implicit none
integer*8 i,j,zj
real*8 t,w
logical::FEXIST
character(len=100)::ti_string
character(len=100)::tj_string
open(unit=10,file='tra_bjming')
open(unit=11,file='test')
!write(*,*) mod(9,2)
do i=1,6300
!read(10,*) t,w
if (mod(i,25)==1)then
zj=mod(i,25)
!if(i==1)then
!open(unit=99,file='vz'//trim(adjustl(ti_string))//'.dat',status='replace')
!endif
write (ti_string,'(i6)') zj
write (tj_string,'(i6)') zj+1
open(unit=99,file='vz'//trim(adjustl(ti_string))//'_'//trim(adjustl(tj_string))//'.dat',position='append')
write(99,*) i
endif
close(99)
enddo
end program Console10
核心语句为
open(unit=99,file='vz'//trim(adjustl(ti_string))//'_'//trim(adjustl(tj_string))//'.dat',position='append')
注意ti_string和tj_string为字符串,由整数型的i和i+1通过write赋值而来