      module mod_tijkl
!
!-----------------------------------------------------------------------
! 1. split integral file in files according to the symmetry of the
!    indices (files TEMPPQRSijkl, i,j,k,l=index symmetries
!    1111, 2121, 2211 ...)
!
! 2. outer loop on index symmetrie ijkl
!    read TEMPPQRSijkl
!    scope: split file into smaller files that can fit in memory
!    all pqrs integrals corresponding to a given pq pair must
!    belong to only one file
!
!    compute the number of integrals corresponding to a pq pair
!    compute the number of pq pairs that fit in a file
!    compute the number Nf of required files, open them
!    put in memory a 2x2 matrix:  (p,q) --> Nr of the file
!    Allocate a buffer table B(d,Nf), with d as large as possible
!
! 3. read TEMPPQRSijkl, fill B, write lines to file TEMPPQRSijkl_m
!    m=1,Nf when they are full
!-----------------------------------------------------------------------
!
 
      implicit real*8 (a-h,o-x,z),logical*1(y)
      integer,parameter :: lblock=160
      integer p,q,r,s,ps,qs,rs,ss,nis,njs,nks,nls,msym,msymoa,
     *is,js,ks,ls
      integer nb_typ_int,max_pqrs_mem,max_pqrs_s_mem,nfil2
      integer nfil,mps,n_pspq,n_psrs,n_psij,n_pskl,mps2
      integer isym1,isym2,isym3,isym4,idimfr,nfr
      allocatable num1(:),num2(:),num3(:),ins(:),ilech(:)
     *,insoa(:),insac(:),numadr2(:),numadr3(:),numadr4(:)
      integer(4),allocatable,dimension(:) :: itsymoa,noacs,nononacs
     *,numom1,numom2,numom3,numom4
     *,numnonac
      integer ijkl0(4)
      integer ijkls(4)
      real(8),allocatable,dimension(:,:) :: om1,om2,om3,om4
      real(8),allocatable,dimension(:) :: hhh
      integer(4),allocatable,dimension(:,:) :: numacs,numnonacs
      integer(2),allocatable,dimension(:,:) :: pair_file
      character(4) cs
      allocatable om(:,:,:)
      allocatable temp_vect_pqrs(:,:)
      dimension isymt(8),isymtoa(8)
      real(8) a,a1,t_reor,t_transf
      dimension ind_aos(1000,4) !!!ramener 1000 a la valeur pour nsym=8
      dimension nijkls(1000) !!!ramener 1000 a la valeur pour nsym=8
      dimension npqrs_s(1000) !!!ramener 1000 a la valeur pour nsym=8
      dimension ifil_s(1000) !!!ramener 1000 a la valeur pour nsym=8
      character(13),dimension(1000) :: filename!!!ramener 1000 a la vale
      integer nbfil_pqrs_s(1000) !!!ramener 1000 a la valeur pour nsym=8
 
      integer nfil_pair(1000)!!!ramener 1000 a la valeur pour nsym=8
      integer ind_pair(1000)!!!ramener 1000 a la valeur pour nsym=8

      integer(8) memb  !  test a supprimer!
 
 
      logical yw1
      end module
