anchor.diff:     iStr2 = 0
      ! 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(*,'("Compare loop: file1 strN ",i6)') strN
  +      write(*,'("Compare loop: file1 strN ",i5)') strN
         write(13,'("Compare loop: file1 strN ",i6)') strN
         iStr2 = iStr2 + 1
         !write(*,'("iStr2: ",i4)') iStr2
         read(f2,*,iostat=ioerr) strN2, hnfN2, hdgenfact, labdgen, totdgen, sizeN, n2, pgOps2, diag2, a,b,c,d,e,f, L2(:,:,1), labeling
  -      write(*,'("read from file 2: strN2:",i5)') strN2
  +      write(*,'("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
  +
  +!! July29 Seems like the L1/L2 check should come *after* the HNF check (at least for the sake of efficiency).
         ! Check to see if the two files have different left transform matrices. If they do, they may !  still define equivalent structures so we'll have to do some work.
         if (any(L1/=L2)) then
  +         print*,"Left transforms are different in file1 and file2"
            !make the qlabel list of permutations
            call get_dvector_permutations(pLV2,dset2,nD2,rot,shift,dRotList2,LatDim2,eps)
            call remove_duplicate_lattices(HNFin,LatDim2,pLV2,rot,shift,dset2,dRotList2,HNFout,fixOp,&
  
positive.code:             ! GLWH 2019, see email chain, subject: "Monk?", with Rod Forcade starting May 16 2019
              do jL = 1, size(qlabel,1)
                 ilabeling2 = qLabel(jL,:)
                 write(*,'("plabel: ",14(i1))') plabel(iL,:)
                 write(*,'("qlabel: ",14(i1))') qlabel(jL,:)
                 if(all(ilabeling2==pLabel(iL,:))) then
                    foundLab = .true.
                    print*,"MATCH"
                    if (match/=0) then
                       write(*,'("Additional match found: ",i6," == ",i6)') strN, strN2
                       ! write(*,'("In file 2, structure ",i6)') strN2
                       ! write(*,'("was equivalent to ",i6)') match
                       ! write(*,'("in file 1")')
                       !stop "BUG! Found more than one match in struct_enum.out file"
                    endif
        !            match = iStr2
                    match = strN2
                    exit outer
                 endif
                 !if equiatomic then check for complements. I think it's OK to not check permutations (we've already done that above). We just need to check for different complements of the same labeling...
                 if (equiatomic) then ! check complements as well
                    do iLP = 2, nLP ! Loop over all permutations of the
                                    ! labels (stored in 'labPerms'). Start at 2 since
                                    ! we want to skip the identity.
                       do jp = 1, size(ilabeling2) ! For each digit in the labeling,
                                                   ! permute the label (label exchange)
                          write(*,'(20i2)') labPerms(iL,:)
  !                        ilabeling2(jp) = labPerms(a(jp)+1,iLP)
                       enddo
                       if(all(ilabeling2==pLabel(iL,:))) then
                          foundLab = .true.
                          print*,"MATCH (equiatomic)"
                          if (match/=0) then
  
negative.code: ! 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
  
  