(git:ccc2433)
linear_systems.F
Go to the documentation of this file.
1 !--------------------------------------------------------------------------------------------------!
2 ! CP2K: A general program to perform molecular dynamics simulations !
3 ! Copyright 2000-2024 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 !> \note
12 !> We are using LAPACK interfaces, so please make sure in IBM/AIX you have
13 !> the lapack library before essl: "xlf90 ... -llapack -lessl" !!!
14 !> \par History
15 !> none
16 !> \author JGH (30-5-2001)
17 ! **************************************************************************************************
19 
20  USE kinds, ONLY: dp
21  USE lapack, ONLY: lapack_sgesv
22 #include "../base/base_uses.f90"
23 
24  IMPLICIT NONE
25 
26  PRIVATE
27 
28  CHARACTER(len=*), PARAMETER, PRIVATE :: moduleN = 'linear_systems'
29 
30  PUBLIC :: solve_system
31 
32 CONTAINS
33 
34 ! **************************************************************************************************
35 !> \brief ...
36 !> \param matrix ...
37 !> \param mysize ...
38 !> \param eigenvectors ...
39 ! **************************************************************************************************
40  SUBROUTINE solve_system(matrix, mysize, eigenvectors)
41 
42  REAL(kind=dp), INTENT(INOUT) :: matrix(:, :)
43  INTEGER, INTENT(IN) :: mysize
44  REAL(kind=dp), INTENT(INOUT) :: eigenvectors(:, :)
45 
46  INTEGER :: info, lda, ldb, nrhs, ipiv(mysize)
47 
48  lda = SIZE(matrix, 1)
49  ldb = SIZE(eigenvectors, 1)
50  nrhs = SIZE(eigenvectors, 2)
51 
52  CALL lapack_sgesv(mysize, nrhs, matrix, lda, ipiv, &
53  eigenvectors, ldb, info)
54  IF (info /= 0) THEN
55  cpabort("Error in inversion")
56  END IF
57 
58  END SUBROUTINE solve_system
59 
60 END MODULE linear_systems
61 
Defines the basic variable types.
Definition: kinds.F:23
integer, parameter, public dp
Definition: kinds.F:34
Interface to the LAPACK F77 library.
Definition: lapack.F:17
Provides interfaces to LAPACK routines for factorisation and linear system solving.
subroutine, public solve_system(matrix, mysize, eigenvectors)
...