anchor.diff:  implicit none
   character(800)  title, dummy
   character(len=:), allocatable :: f1name, f2name
  -real(dp), dimension(3,3) :: pLV1, pLV2, L2inv, T!, Tinv
  +real(dp), dimension(3,3) :: pLV1, pLV2, L2inv, T!, L1inv!, Tinv
   integer, dimension(3,3,1):: L1, SNF, L2
   real(dp), allocatable :: dset1(:,:), dset2(:,:), rot(:,:,:), shift(:,:)
   real(dp), pointer :: sLVlist(:,:,:)
  
positive.code: ! Check to see if this case is "equiatomic", that is, whether or not the number of labels of each
  ! color is exactly the same. If so, we need some extra logic when two labeling are compared
  ! (see email discussion with Rod Forcade on May 16 2019, subject: "Monk?")
     equiatomic = .false.
     if (mod(n*nD1,k)== 0) then ! necessary but not sufficient condition for equiatomic.
        equiatomic = .true.
        equiN = n*nD1/k
        allocate(integerLab(n*nD1))
        do j = 1, n*nD1
           read(labeling(j:j),'(i1)') integerLab(j)
        enddo
        write(*,'("IntLab",14i1)') integerLab
        print*,count(integerLab==0)
        do i = 0,k-1
        if (count(integerLab==i)/=equiN) then ! can't be equiatomic
           print*,"Not equiatomic"
           equiatomic = .false.
           exit
        endif
        if (equiatomic) print*,"Equiatomic"
        enddo
     endif
  
  ! Why are we doing this? To get the dRotList? We only have one HNF, so there are no duplicates to
  ! remove...
     call remove_duplicate_lattices(HNFin,LatDim1,pLV1,rot,shift,dset1,dRotList1,HNFout,fixOp,&
                                    LattRotList1,sLVlist,degen_list,eps)
     open(17,file="debug_rotation_permutations.out")
  
     ! Get the list of label permutations
     call get_rotation_perms_lists(pLV1,HNFout,L1,SNF,fixOp,LattRotList1,dRotList1,eps)
     write(17,'("Rots Indx:",/,8(24(i3,1x),/))') LattRotList1(1)%RotIndx(:)
     write(17,'("Permutation group (trans+rot):")')
     nP = size(LattRotList1(1)%perm,1)
     do ip = 1, nP
        write(17,'("Perm #",i3,":",1x,200(i2,1x))') ip,LattRotList1(1)%perm(ip,:)
     enddo
  
     ! Use the permutations effected by the rotations that fix the superlattice to generate labelings
     ! that are equivalent. The list of equivalent labelings will be used when we look for a match in the
     ! struct_enum file
     allocate(ilabeling1(n*nD1),ilabeling2(n*nD1),tempLab(n*nD1))!,permutedLab(n*nD1)) 26 July, permutedLab not used
     read(labeling,'(500i1)') ilabeling1
     !write(*,'("ilabeling1:",/,30(i1),/)') ilabeling1
  
negative.code:       if (lc > 100) stop "Didn't find the 'start' tag in the second file"
     enddo
     iStr2 = 0
  
  !! END reading of 'header' from file2
  ! You can get a subtle bug here, hard to chase down, if you have another module opening files with the same unit number. Make sure that the unit numbers for files opened by this program are unique.  GLWH 2019 (that's why f2 is set to 14 above)
  
     compareloop: do
        write(13,'("Compare loop: file1 strN ",i6)') strN
        iStr2 = iStr2 + 1
        read(f2,*,iostat=ioerr) strN2, hnfN2, hdgenfact, labdgen, totdgen, sizeN, n2, pgOps2, diag2, a,b,c,d,e,f, L2(:,:,1), labeling
        write(13,'("read from file 2: strN2: ",i5)') strN2
        if(ioerr/=0) exit
        read(labeling,'(500i1)') ilabeling2
        L2(:,:,1) = transpose(L2(:,:,1)) ! Written out column-wise but read in row-wise. So fix it by transposing
  
        write(*,'("Comparing structures (f1 vs f2): ",2(i6,1x))') strN, strN2
        write(13,'("Comparing structures (f1 vs f2): ",2(i6,1x))') strN, strN2
  