anchor.diff:  
   call get_permutations((/(i,i=0,k-1)/),labPerms)
   nLP = size(labPerms,2)
  -write(*,'("labPerms",30i2)') (labPerms(i,:),i=1,size(labPerms,1))
  -
  +write(*,'("label Perms: ",30i2)') (labPerms(i,:),i=1,size(labPerms,1))
  +
  +
  +!
  +! Loop over all structures in file1
  +!
   open(13,file="debug_match_check.out")
  -do ! Read each structure from f1 and see if it is in the list of f2 structures
  +f1loop: do ! Read each structure from f1 and see if it is in the list of f2 structures
      read(f1,*,iostat=ioerr) strN, sizeN, hdgenfact, labdgen, totdgen, idx, n,  pgOps, diag, a,b,c,d,e,f, L1(:,:,1), labeling
      !read(f1,*,iostat=ioerr) strN, sizeN, n,  pgOps, diag, a,b,c,d,e,f, L(:,:,1), labeling
      if(ioerr/=0) exit
  -   write(*,'("file1 str: ",i5)') strN
  +   write(13,'("file1 str: ",i5)') strN
      L1(:,:,1) = transpose(L1(:,:,1)) ! Written out column-wise but read in row-wise. So fix it by transposing
      SNF(1,1,1) = diag(1); SNF(2,2,1) = diag(2); SNF(3,3,1) = diag(3)
   
  
positive.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)
  !!GLWH Seems like the 'plabel' variable was being used for two different purposes. I've renamed this
  !!one 'dlabel'
  !call read_struct_enum_out_oldstyle(title,LatDim1,pLV1,nD1,dset1,k,eq,Nmin,Nmax,eps,full,dLabel,digit,f1name,crange)
  
  print*,"Begin reading structure files"
  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)
  !write(*,'("Read file ",a80)') f1name
  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 equivalent"
  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
  
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
  