  Subroutine freemv(NFree,vfree)

  use Path_module, only : HUpdate,Hinv
  use Io_module, only : IoOut
  
  IMPLICIT NONE

  INTEGER, PARAMETER :: KINT=KIND(1)
  INTEGER, PARAMETER :: KREAL=KIND(1.0D0)

  INTEGER(KINT), INTENT(IN) :: Nfree
  REAL(KREAL), INTENT(OUT) :: Vfree(Nfree,Nfree)

! ======================================================================
!
! At the end, this should do:
! Construct displacement vectors that are free and which do not contain rigid motions.
! Output : vectors are orthonormal (in the non-mass-weighted metric)
! 
! For now, it just returns an identity matrix (NFree,Nfree)
! v3.94
! We delete displacements that correspond to frozen atoms
!
! ======================================================================
  logical :: debug
  integer(KINT) :: I

  interface
     function valid(string) result (isValid)
       logical                  :: isValid
       character(*), intent(in) :: string
     end function valid
  end interface

  debug=valid('vfree')

  if (debug) WRITE(*,*) "================================= Entering Vfree ==============="
  
  Vfree=0.d0
  DO I=1,Nfree
     Vfree(I,I)=1.d0
  END DO

  if (debug) WRITE(*,*) "================================= Exiting Vfree ==============="

 END Subroutine freemv


