anchor.diff:  !------------------------------------------------------------------------------------------------------
   !> Return eigenvalues, Omega, and eigenvectors
   
  -SUBROUTINE EigenSolve(K, M, N, bCheckSingularity, EigVect, Omega2, ErrStat, ErrMsg )
  +SUBROUTINE EigenSolve(K, M, N, bCheckSingularity, EigVect, Omega, ErrStat, ErrMsg )
      USE NWTC_LAPACK, only: LAPACK_ggev
      USE NWTC_ScaLAPACK, only : ScaLAPACK_LASRT
      INTEGER       ,          INTENT(IN   )    :: N             !< Number of degrees of freedom, size of M and K
  
positive.code:    REAL(FEKi),              INTENT(INOUT)    :: M(N, N)       !< Mass matrix 
     LOGICAL,                 INTENT(IN   )    :: bCheckSingularity                  ! If True, the solver will fail if rigid modes are present 
     REAL(FEKi),              INTENT(INOUT)    :: EigVect(N, N) !< Returned Eigenvectors
     REAL(FEKi),              INTENT(INOUT)    :: Omega2(N)      !< Returned Eigenvalues
     INTEGER(IntKi),          INTENT(  OUT)    :: ErrStat       !< Error status of the operation
     CHARACTER(*),            INTENT(  OUT)    :: ErrMsg        !< Error message if ErrStat /= ErrID_None
     ! LOCALS         
  
negative.code:       EigVect(:,I)=VL(:,KEY(I))  !just reordered as Huimin had a normalization outside of this one
     ENDDO
     !+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++!
  
     ! --- Return Omega (capped by huge(ReKi)) and check for singularity
     Omega(:) = 0.0_FEKi
     do I=1,N 
        ! Capping Om2 to avoid overflow
        if (abs(Omega2(I))>huge(1.0_ReKi)) then
           Om2 = huge(1.0_ReKi) * sign(1.0_FEKI, Omega2(i)) !< NOTE huge(ReKi)
        else
           Om2 = Omega2(i)
        endif
        if (EqualRealNos(real(Om2,ReKi), 0.0_ReKi)) then  ! NOTE: may be necessary for some corner numerics
           Omega(i)=0.0_FEKi
           if (bCheckSingularity) then
              ErrStat2=ErrID_Fatal
              ErrMsg2= 'Zero eigenvalue found, system may be singular (may contain rigid body modes)'
              if(Failed()) return
           endif
        elseif (Om2>0) then 
           Omega(i)=sqrt(Om2)
        else
           ! Negative eigenfrequency
           print*,'>>> Wrong eigenfrequency, Omega^2=',Om2
           Omega(i)= 0.0_FEKi 
           if (bCheckSingularity) then
              ErrStat2=ErrID_Fatal
              ErrMsg2= 'Negative eigenvalue found, system may be singular (may contain rigid body modes)'
              if(Failed()) return
           endif
        endif
     enddo
  
     CALL CleanupEigen()
     RETURN
  
  