| 本帖最后由 978142355 于 2016-10-13 15:56 编辑 
 如题,打算把aa.cube文件的前10行放在pot.cub文件的最开头,自己写了程序,如下。由于两个文件都比较大(单个210M,仅仅上传了删改后的数据),发现需要5分钟才能转化完成,还不如手动直接复制粘贴……………………所以开贴求助大家,如何既能实现如题的功能,时间消耗的还比较少。
 [Fortran] syntaxhighlighter_viewsource syntaxhighlighter_copycode     program pot_head
    implicit none
    integer i,j,ierr
    character(len=84) str
    open(11,file='aa.cube') 
    open(12,file='temp1')
    open(13,file='pot.cub')
    open(14,file='temp2')
    i=0
    do
        read(11,"(a84)",iostat=ierr) str
        if(str(9:10)=='E') exit
        if(ierr/=0) exit
        i=i+1
    end do
    rewind(11)
    do j=1,i
        read(11,"(a84)") str
        write(12,"(a84)") str
    end do
    close(11)
    rewind(12)
    do j=1,i
        read(12,"(a84)") str
        write(14,"(a84)") str
    end do
    do
        read(13,"(a84)",iostat=ierr) str
        if (ierr/=0) exit
        write(14,"(a84)") str
    end do
    close(12,status='delete')
    close(13,status='delete')
    rewind(14)
    open(15,file='pot.cub')
    do
        read(14,"(a84)",iostat=ierr) str
        if(ierr/=0) exit
        write(15,"(a84)") str
    end do
    close(14,status='delete')
    close(15)
    read(*,*)
    end program pot_head
 |