      module mod_lirint
      double precision,allocatable,save,dimension(:) :: f
      double precision,allocatable,dimension(:) :: hmonol
      double precision,allocatable,dimension(:,:) ::
     *ajk,aiikl,aijil,aijjj,hmono
      integer,save :: indice40=4096
      integer,save :: indice30=4096
      contains
       subroutine lirin4(i,j,k,l,aa,ifil)
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      dimension aa(3)
      integer(2),dimension(4096),save :: iint,jnt,knt,lnt
      double precision,save,dimension(3,4096) :: aaloc
      character(80) file
      !
! lecture d'une integrale a 4 indices differents
! les indices sont dans l'ordre physicien
      indice40=indice40+1
      if(indice40>4096) then
         indice40=1
         read(ifil,end=1) iint,jnt,knt,lnt,aaloc
         goto 2
 1       continue
         inquire(ifil,name=file)
         call incr_name2(file,ifil)
         read(ifil) iint,jnt,knt,lnt,aaloc
      endif
 2    continue
      i=iint(indice40)
      j=jnt(indice40)
      k=knt(indice40)
      l=lnt(indice40)
      aa=aaloc(:,indice40)
      return
      end subroutine
       subroutine ecrin4(i,j,k,l,aa,icas)
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      dimension aa(3)
      integer(2),dimension(4096),save :: iint,jnt,knt,lnt
      integer,save :: indice17=0
      double precision,save,dimension(3,4096) :: aaloc
      !
      if(icas==0) then
         open(17,file='IJCLLOC4',status='unknown',form='unformatted')
         return
      endif
      if(icas==2) then
         indice17=indice17+1
         if(indice17>4096) then
            indice17=1
            write(17) iint,jnt,knt,lnt,aaloc
         endif
         iint(indice17)=0
         write(17) iint,jnt,knt,lnt,aaloc
         return
      endif
      indice17=indice17+1
      if(indice17>4096) then
         indice17=1
         write(17) iint,jnt,knt,lnt,aaloc
      endif
      iint(indice17)=i
      jnt(indice17)=j
      knt(indice17)=k
      lnt(indice17)=l
      aaloc(:,indice17)=aa
      return
      end subroutine
       subroutine lirin3(i,j,k,aa,ifil)
      IMPLICIT REAL(8)(A-H,O-X,Z),logical(1)(y)
      dimension aa(2)
      integer(2),dimension(4096),save :: iint,jnt,knt
      double precision,save,dimension(2,4096) :: aaloc
      character(80) file
      !
      indice30=indice30+1
      if(indice30>4096) then
         indice30=1
         read(ifil,end=1) iint,jnt,knt,aaloc
         goto 2
 1       continue
         inquire(ifil,name=file)
         call incr_name2(file,ifil)
         read(ifil) iint,jnt,knt,aaloc
      endif
 2       continue
      i=iint(indice30)
      j=jnt(indice30)
      k=knt(indice30)
      aa=aaloc(:,indice30)
      return
      end subroutine
      end module mod_lirint
      
      
