Line data Source code
1 : !--------------------------------------------------------------------------------------------------!
2 : ! CP2K: A general program to perform molecular dynamics simulations !
3 : ! Copyright 2000-2025 CP2K developers group <https://cp2k.org> !
4 : ! !
5 : ! SPDX-License-Identifier: GPL-2.0-or-later !
6 : !--------------------------------------------------------------------------------------------------!
7 :
8 : ! **************************************************************************************************
9 : !> \brief Provides interfaces to LAPACK routines for factorisation and
10 : !> linear system solving
11 : !> \par History
12 : !> none
13 : !> \author JGH (30-5-2001)
14 : ! **************************************************************************************************
15 : MODULE linear_systems
16 :
17 : USE kinds, ONLY: dp
18 : #include "../base/base_uses.f90"
19 :
20 : IMPLICIT NONE
21 :
22 : PRIVATE
23 :
24 : CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'linear_systems'
25 :
26 : PUBLIC :: solve_system
27 :
28 : CONTAINS
29 :
30 : ! **************************************************************************************************
31 : !> \brief ...
32 : !> \param matrix ...
33 : !> \param mysize ...
34 : !> \param eigenvectors ...
35 : ! **************************************************************************************************
36 659068 : SUBROUTINE solve_system(matrix, mysize, eigenvectors)
37 :
38 : REAL(KIND=dp), INTENT(INOUT) :: matrix(:, :)
39 : INTEGER, INTENT(IN) :: mysize
40 : REAL(KIND=dp), INTENT(INOUT) :: eigenvectors(:, :)
41 :
42 1318136 : INTEGER :: info, lda, ldb, nrhs, ipiv(mysize)
43 :
44 659068 : lda = SIZE(matrix, 1)
45 659068 : ldb = SIZE(eigenvectors, 1)
46 659068 : nrhs = SIZE(eigenvectors, 2)
47 :
48 : CALL dgesv(mysize, nrhs, matrix, lda, ipiv, &
49 659068 : eigenvectors, ldb, info)
50 659068 : IF (info /= 0) THEN
51 0 : CPABORT("Error in inversion")
52 : END IF
53 :
54 659068 : END SUBROUTINE solve_system
55 :
56 : END MODULE linear_systems
57 :
|