program testit
integer :: lun
integer,allocatable :: ivals(:)
   if(allocated(ivals))deallocate(ivals)
   allocate(ivals(0))
   open(file='sample.txt',newunit=lun)
   do
      read(lun,'(i256)',advance='no',iostat=ios)i
      if(is_iostat_eor(ios).or.ios.eq.0)then
         ivals=[ivals,i]
      else
         exit
      endif
   enddo
   write(*,*)'size=',size(ivals),'ivals=',ivals
end program testit
