      subroutine lirijcl(icas,ijkl,a,ifilb,ind1,nijcllu1)
      implicit real*8 (a-h,o-x,z),logical*1(y)
      integer ijkl(4)
      integer(2) idx4(4096,4)
      dimension aaint(4096)
      save aaint,idx4,ind,nijcllu
      yw=.false.
      if(yw)print*,'entree lirijcl'
      if(icas==0) then
         ! initialize file
         read(ifilb) idx4,aaint
         ind=0
         nijcllu=1
         if(yw)print*,'icas',icas,'   nijcllu',nijcllu
         ijkl=idx4(1,:)
         a=aaint(1)
      else if (icas==1) then
         ! read next integral
            ind=ind+1
            if(ind>4096) then
               call flush(6)
               read(ifilb) idx4,aaint
               nijcllu=nijcllu+1
               if(yw)print*,'icas',icas,'   nijcllu',nijcllu
               call flush(6)
               ind=1
            endif
            ijkl=idx4(ind,:)
            a=aaint(ind)
      endif
      return
      end
       subroutine lirpqrs(icas,ijkl,a,ifilb,ind1,nijcllu1)
      implicit real*8 (a-h,o-x,z),logical*1(y)
      integer ijkl(4)
      integer(2) idx4(4,4096)
      dimension aaint(4096)
      save aaint,idx4,ind,nijcllu
      yw=.false.
      if(yw)print*,'entree lirijcl'
      if(icas==0) then
         ! initialize file
         read(ifilb) idx4,aaint
         ind=0
         nijcllu=1
         if(yw)print*,'icas',icas,'   nijcllu',nijcllu
         ijkl=idx4(:,1)
         a=aaint(1)
      else if (icas==1) then
         ! read next integral
            ind=ind+1
            if(ind>4096) then
               call flush(6)
               read(ifilb) idx4,aaint
               nijcllu=nijcllu+1
               if(yw)print*,'icas',icas,'   nijcllu',nijcllu
               call flush(6)
               ind=1
            endif
            ijkl=idx4(:,ind)
            a=aaint(ind)
!      else if (icas==2) then
!         ! note position
!         ind1=ind
!         nijcllu1=nijcllu
!        if(yw)print*,'note position',ind,nijcllu
!      else if (icas==3) then
!         ! positionate on file
!          if(yw)print*,'positionate on file',ind,nijcllu,ind1,nijcllu1
!          call flush(6)
!            if(nijcllu==nijcllu1) then
!               if(yw)print*,'lirijcl ne fait rien'
!            else if(nijcllu>nijcllu1) then
!               if(nijcllu1==1) then
!                  rewind ifilb
!                  if(yw)print*,'rewind ifilb'
!               else
!                  do l=nijcllu1,nijcllu
!                     backspace ifilb
!                     if(yw)print*,'backspace ifilb'
!                  enddo
!               endif
!               read(ifilb) idx4,aaint
!            else
!               stop 'lirijcl'
!            endif
!            ind=ind1
!         nijcllu=nijcllu1
!         if(yw)print*,'icas',icas,'   nijcllu',nijcllu
!          if(yw)print*,
!     *    'fin positionate on file',ind,nijcllu,ind1,nijcllu1
      endif
      return
      end
