anchor.diff:  integer, pointer, dimension(:,:) :: label, g1, g2, dlabel, qLabel
   integer :: LatDim1, LatDim2, match, nD1, nD2, Nmin, Nmax, k, ioerr
   integer :: strN, sizeN, n, pgOps, diag(3), a, b, c, d, e, f, i, jl, j
  -integer :: iuq, nuq, iP, nP, lc, iStr2, HNFtest(3,3), hdgenfact, labdgen, totdgen
  -integer :: strN2, hnfN2, n2, pgOps2, diag2(3), idx, f1, f2, iLP, nLP, equiN
  -integer, allocatable :: ilabeling1(:), ilabeling2(:), atomType(:), automorphism(:), integerLab(:)
  +integer :: iP, nP, lc, iStr2, HNFtest(3,3), hdgenfact, labdgen, totdgen
  +integer :: strN2, hnfN2, n2, pgOps2, diag2(3), idx, f1, f2, iLP, nLP
  +integer, allocatable :: ilabeling1(:), ilabeling2(:), atomType(:), automorphism(:)
   integer, allocatable :: tempLab(:)
   real(dp) :: eps
   logical full, HNFmatch, foundLab, err, equiatomic
   character(maxLabLength)   :: labeling ! List, 0..k-1, of the atomic type at each site
  -type(RotPermList)         :: dRotList1, dRotList2
  -type(RotPermList),pointer :: LattRotList1(:), LattRotList2(:)
  +type(RotPermList)         :: dRotList1
  +type(RotPermList),pointer :: LattRotList2(:)
   type(opList), pointer     :: fixOp(:)
   integer, pointer          :: crange(:,:), degen_list(:), rotProdLab(:), labPerms(:,:)
   
  
positive.code:       if (lc > 100) stop "Didn't find the 'start' tag in the second file"
     enddo
     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 ",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
        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,&
                                          LattRotList2,sLVlist,degen_list,eps)
           call get_rotation_perms_lists(pLV2,HNFout,L2,SNF,fixOp,LattRotList2,dRotList2,eps)
           call find_equivalent_labelings(ilabeling2,LattRotList2,qLabel,rotProdLab)
           open(17,file="debug_rotation_permutations.out",position="append")
  
           write(17,'("Rots Indx:",/,8(24(i3,1x),/))') LattRotList2(1)%RotIndx(:)
           write(17,'("Permutation group (trans+rot):")')
           nP = size(LattRotList2(1)%perm,1)
           do ip = 1, nP
              write(17,'("Perm #",i3,":",1x,200(i2,1x))') ip,LattRotList2(1)%perm(ip,:)
           enddo
           nuq = size(qLabel,1)
           write(17,'(/,"Number of unique labelings: ",i5)') nuq
           do iuq = 1, nuq
              write(17,'("uq Labeling # :",i3,5x,"labeling:",1x,200(i1,1x))') iuq,qLabel(iuq,:)
           enddo
           close(17)
        else ! The left transform matrices are the same, so the labelings can be compared without conversion
           if(associated(qlabel)) deallocate(qlabel)
           allocate(qlabel(1,n2*nD2))
           qlabel(1,:) = ilabeling2
        endif
  
        write(*,'("Comparing structures (f1 vs f2): ",2(i6,1x))') strN, strN2
        write(13,'("Comparing structures (f1 vs f2): ",2(i6,1x))') strN, strN2
  
negative.code: eps = 1e-4
  write(*,'("Epsilon is currently hardwired at ", g11.4)') eps
  
  !
  ! Read command line arguments for names of files to be compared
  !
  call getarg(1,dummy)
  f1name = trim(dummy)
  call getarg(2,dummy)
  f2name = trim(dummy)
  read(dummy,'(a800)') f2name
  if(iargc()/=2) stop "Need two arguments: source and target struct_enum.out-type files"
  ! This old "read" line was for a previous format of struct_enum.out, presumably.
  !call read_struct_enum_out(title,LatDim1,pLV1,nD1,dset1,k,eq,Nmin,Nmax,eps,full,pLabel,digit,f1name,crange,conc_check)
  !call read_struct_enum_out_oldstyle(title,LatDim1,pLV1,nD1,dset1,k,eq,Nmin,Nmax,eps,full,dLabel,digit,f1name,crange)
  
  call read_struct_enum_out(title,LatDim1,pLV1,nD1,dset1,k,eq,Nmin,Nmax,eps,full,dlabel,digit,cRange,f1name)
  !call read_struct_enum_out(title,LatDim2,pLV2,nD2,dset2,k,eq,Nmin,Nmax,eps,full,pLabel,digit,f2name,crange,conc_check)
  call read_struct_enum_out(title,LatDim2,pLV2,nD2,dset2,k,eq,Nmin,Nmax,eps,full,dLabel,digit,crange,f2name)
  if (LatDim1/=LatDim2) stop "Bulk/surf modes are not the same in the input files"
  print*,"Finished reading header info in both files"
  
  ! Basic checks for possible equivalence
  if (.not. equal(pLV2,pLV1,eps)) stop "Parent lattice vectors are not identical"
  if (nD1/=nD2) stop "Number of d-vectors are not equivalent"
  if (.not. equal(dset1,dset2,eps)) stop "D-vectors are not equivalent"
  allocate(label(1,nD1),digit(nD1))
  label = 1
  digit = 1
  
  !
  ! "Fast forward" to structures in file1
  !
  f1 = 10; open(f1,file=f1name,status="old")
  do ! read f1name file until the structure list begins
     read(f1,*) title
  