anchor.diff:            exit ! if there isn't a match in just one digit, illegal labeling
          endif
       enddo
  -    
  +
     ENDFUNCTION labeling_is_legal
   
     !!<summary>This routine takes in the permutations effected by both
  
positive.code:     integer(li) :: multiplier(n*nD) ! place values for each
      ! digit. k^(i-1) for the i-th digit for "normal" base-k
      ! numbers. More complicated for mixed radix case.
      integer c(0:k-1) ! running sum (count) of the number of each label type 
      integer id, iq ! Counter for labels that are duplicates, for those unique
      integer, pointer :: labPerms(:,:) ! List of permutations of the k labels
      integer :: nsp ! Number of superperiodic labelings
  
negative.code:   !!<parameter name="digit"></parameter>
    !!<parameter name="multiplier"></parameter>
    SUBROUTINE setup_mixed_radix_multiplier(n,k,parLabel,parDigit,label,digit,multiplier)
      integer, intent(in) :: n,k
      integer, intent(in) :: parLabel(:,:), parDigit(:)
      integer, pointer:: label(:,:), digit(:) ! n*longer than parLab/parDigit (INTENT(OUT))
      integer, pointer:: multiplier(:)
      integer i,j, nD, istat, ic
  
      nD = size(parDigit) ! Size of the d-set n*nD is the total length of a labeling
  
      if (associated(label)) deallocate(label)
      if (associated(digit)) deallocate(digit)
      if (associated(multiplier)) deallocate(multiplier)
      allocate(label(k,n*nD),digit(n*nD),multiplier(n*nD),STAT=istat)
      if (istat/=0) stop "Allocation failed in setup_mixed_radix_multiplier"
  
      digit = (/((parDigit(j),i=1,n),j=1,nD)/) ! Repeat the digit
      ! ordinals across all places in the labeling
      forall(j=1:k);label(j,:) = (/((parLabel(j,i),ic=1,n),i=1,nD)/); endforall ! Ditto for labels
  