      subroutine lire(b,l,n,ifil)
      parameter (ngru3=2048)
      IMPLICIT REAL*8(A-H,O-Z)
      dimension b(n)
c      write(6,*)'lire l,n,ifil',l,n,ifil
      nn=(n-1)/ngru3
      ll=(l-1)*(nn+1)
      do k=1,n,ngru3
         ll=ll+1
c          read(ifil,rec=l) b
         long=min0(ngru3,n-k+1)
         call lirec(b(k),ll,long,ifil)
      enddo
      return
      end
       subroutine lirec(b,ll,long,ifil)
      IMPLICIT REAL*8(A-H,O-Z)
      dimension b(long)
      !print*,'lirec ll,ifil,long',ll,ifil,long
      irec=ll
      if(ifil==22.or.ifil==21) then
         inquire(ifil,RECL=long2)
         !print*,'lire.f',ifil,ll,long2,long
        !print*,'irec1',irec
         call filesplit('READ',ifil,long2,ichange,irec)
        !print*,'irec2',irec
!         if(ichange==1)
!     *   print*,'****CLOSE/OPEN en lecture  sur file',ifil
         call flush(6)
      endif
!      if(ifil==22)print*,'LECTURE 22',ll
        !if(irec/=ll) print*,'ll,irec',ll,irec
        !if(irec/=ll) stop
      read(ifil,rec=irec) b
      return
      end
