subroutine freeLMat()
#ifndef USE_TCHINT_
character(*), parameter :: t_r = "freeLMat"
#endif
if (t_use_tchint_lib) then
#ifdef USE_TCHINT_
call tchint_finalize()
#else
call stop_all(t_r, "Did not compile with TCHINT support")
#endif
else
if (tLMatCalc .or. t_rs_factors) then
call freeLMatFactors()
else
call LMat%safe_dealloc()
end if
endif
end subroutine freeLMat