anchor.diff:  logical err
   real(dp), allocatable :: rgp(:,:)
   logical, allocatable :: skip(:)
  +integer OpIndxInSuperCellList, RowInDxGTable
  +
  +open(19,file="debug_get_rotation_perms_lists.out")
   
   ! Number of HNFs (superlattices); Index of the superlattices; Number of d-vectors in d set
   nH = size(HNF,3); n = determinant(HNF(:,:,1)); nD = size(RPList(1)%v,2) 
  
positive.code:    !print *,nop,nd,n;stop
     allocate(rperms%perm(nOp,nD*n),STAT=status)
     if (status/=0) stop "Allocation failed in get_rotation_perm_lists: rperms%perm"
     
     do iOp = 1, nOp ! For each rotation, find the permutation 
        dgp = 0 ! Initialize the (d,g) table
        do iD = 1, nD ! Loop over each row in the (d,g) table
  
negative.code:          gp = nint(rgp) ! Move the rotated group into an integer array
           gp = modulo(gp,spread(diag,2,n)) ! Mod by each entry of the SNF to bring into group
           ! Now that the rotated group is known, find the mapping of the elements between the
           ! original group and the permuted group. This is the permutation.
           skip = .false. ! This is just for efficiency
           do im = 1, n
              do jm = 1, n
                 if (skip(jm)) cycle ! Skip elements whose mapping is already known
                 if (all(gp(:,jm)==g(:,im))) then ! these elements map to each other
                    ! The list of operations that fix the superlattice are a subset of those that fix
                    ! the parent lattice. RotIndx stores the indicies of the parent lattice operations
                    ! in a list with as many entries as supercell fixing operations.
  
                    ! dperms%perm stores a list of d-vector permutations, one permutation (an nD list)
                    ! for each operation in the parent lattice symmetries
                    OpIndxInSuperCellList = RPList(iH)%RotIndx(iOp) 
                    RowInDxGTable = dperms%perm(OpIndxInSuperCellList,iD)
                    dgp(RowInDxGTable,im) = jm+(iD-1)*n
                    skip(jm) = .true.
                    exit
                 endif
  