anchor.diff:        ErrMsg = 'ReduceKMdofs:invalid matrix sizes.'
         RETURN
      END IF
  +  
  +   CALL AllocAry(idx,  TDOF, 'idx',  ErrStat2, ErrMsg2 )
  +      CALL SetErrStat(ErrStat2, ErrMsg2, ErrStat,ErrMsg,'ReduceKMdofs')
  +      IF (ErrStat >= AbortErrLev) THEN
  +         IF (ALLOCATED(idx)) DEALLOCATE(idx)
  +         RETURN
  +      END IF   
      
      !........
      ! Calculate how many rows/columns need to be eliminated:
      !........
  +   DO I = 1, TDOF       
  +      idx(I) = I
  +   END DO
  +         
      L = 0
  -   DO I = 1, NReactDOFs  !Cycle on reaction DOFs
  +   DO I = 1, NReactDOFs  !Cycle on reaction DOFs      
         IF (Init%BCs(I, 2) == 1) THEN
            L=L+1 !number of DOFs to eliminate
  +         
  +         idx( Init%BCs(I, 1) ) = 0 ! Eliminate this one
         END IF    
      END DO   
      
  
positive.code:    DEALLOCATE(idx)
     
  END SUBROUTINE ReduceKMdofs
  !------------------------------------------------------------------------------------------------------
  !------------------------------------------------------------------------------------------------------
  SUBROUTINE UnReduceVRdofs(VRred,VR,rDOF,rModes, Init,p, ErrStat, ErrMsg )
  !This routine calculates augments VRred to VR for the constrained DOFs, somehow reversing what ReducedKM did for matrices
  
negative.code:    CHARACTER(*),           INTENT(  OUT) :: ErrMsg         ! Error message if ErrStat /= ErrID_None
     
     !locals
     INTEGER                               :: I, J           ! counters into full or reduced matrix
     INTEGER                               :: L              ! number of DOFs to eliminate 
  
     INTEGER, ALLOCATABLE                  :: idx(:)         ! vector to map reduced matrix to full matrix
     INTEGER                               :: NReactDOFs
     INTEGER                               :: DOF_reduced
  