program main
  implicit none
integer,parameter :: infile=10,outfile=20
         integer:: atom,i
         
         integer,allocatable :: id(:),mol(:),type(:)  
         real,allocatable :: x(:),y(:),z(:)
       
         character(len=79) ::str1,str2

         character(len=79)  :: filename
 
  integer :: status = 0
  logical alive

  write(*,*) "Filename:"
  read (*,"(A79)") filename
  inquire( file=filename, exist=alive)

  if ( alive ) then
    open(unit=infile, file=filename, &
         access="sequential", status="old")

    open(unit=outfile,file='out.txt')
    do while(.true.)
      read(unit=infile, fmt="(A79)", iostat=status ) str1

      
if (str1=="ITEM: NUMBER OF ATOMS") then

read(infile,*)atom
allocate(id(atom))
allocate(mol(atom))
allocate(type(atom))
allocate(x( atom))
allocate(y(atom))
allocate(z(atom))


end if



if (str1=="ITEM: ATOMS id mol type x y z ") then

         do i = 1,atom

           read(infile,*)  id(i),mol(i),type(i),x(i),y(i),z(i)

            write(outfile,"(3I6,3f10.5)") id(i),mol(i),type(i),x(i),y(i),z(i)


         end do
         end if

      if ( status/=0 ) exit  ! 没有数据就跳出循环
     write(*,"(A79)") str1
    end do

  else
    write(*,*) TRIM(filename)," doesn't exist."
  end if
  close(infile)
         close(outfile)
  stop
end
上面程序我想针对
ITEM: BOX BOUNDS                                            
-0.0821485 49.0281                                          
-0.0821485 49.0281                                          
-15 67                                                      
ITEM: ATOMS id type x y z                                   
1586 1 6.48048 3.69877 -10.7853                             
1587 1 5.50828 2.37501 -11.4744                             
4146 1 3.04137 9.13152 -14.8948                             
……
ITEM: ATOMS id type x y z                                   
1596 1 5.48048 3.69877 -10.7853                             
1487 1 5.50828 2.37501 -11.4744                             
4146 1 3.04137 9.13152 -14.8948                             
……
这样的数据提出ITEM: ATOMS id type x y z下面的数据,为什么输出不完全,非常感谢关注的人!!!