Line data Source code
1 : !--------------------------------------------------------------------------------
2 : ! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
3 : ! This file is part of FLEUR and available as free software under the conditions
4 : ! of the MIT license as expressed in the LICENSE file in more detail.
5 : !--------------------------------------------------------------------------------
6 :
7 : MODULE m_available_solvers
8 : IMPLICIT NONE
9 : ! list of constants indicating the different solvers
10 : ! the parameters are set to negative values to indicate that a particular solver is not compiled
11 : ! -solvers with numbers below 100 expect a non-distributed matrix
12 : ! -solvers with numbers 100-199 can handle both distributed and non-distributed matrices
13 : ! -solvers with numbers higher than 200 expect a distributed (scalapack-type) matrix
14 :
15 : !The default is choosen as: the minimum number >0 for non-distributed matrices
16 : ! the maximum number >100 for distributed matrices
17 : !1. solver
18 : #ifdef CPP_CHASE
19 : INTEGER,PARAMETER:: diag_chase=207
20 : #else
21 : INTEGER,PARAMETER:: diag_chase=-207
22 : #endif
23 : !2. solver
24 : #ifdef CPP_ELEMENTAL
25 : INTEGER,PARAMETER:: diag_elemental=212
26 : #else
27 : INTEGER,PARAMETER:: diag_elemental=-212
28 : #endif
29 : !3. solver
30 : #ifdef CPP_SCALAPACK
31 : INTEGER,PARAMETER:: diag_scalapack=213
32 : #else
33 : INTEGER,PARAMETER:: diag_scalapack=-213
34 : #endif
35 : !4. solver
36 : #ifdef CPP_ELPA
37 : INTEGER,PARAMETER:: diag_elpa=214
38 : #else
39 : INTEGER,PARAMETER:: diag_elpa=-214
40 : #endif
41 : !5.6. solver
42 : #ifdef CPP_ELSI
43 : INTEGER,PARAMETER:: diag_elsielpa=216
44 : INTEGER,PARAMETER:: diag_elsichase=215
45 : #else
46 : INTEGER,PARAMETER:: diag_elsielpa=-216
47 : INTEGER,PARAMETER:: diag_elsichase=-215
48 : #endif
49 : !7. solver
50 : #ifdef CPP_MAGMA
51 : INTEGER,PARAMETER:: diag_magma=8
52 : #else
53 : INTEGER,PARAMETER:: diag_magma=-8
54 : #endif
55 : !8. solver
56 : INTEGER,PARAMETER :: diag_stop=101 ! dummy solver that simply stops FLEUR
57 : !9. solver
58 : #ifdef CPP_CUSOLVER
59 : INTEGER,PARAMETER:: diag_cusolver=7
60 : #else
61 : INTEGER,PARAMETER:: diag_cusolver=-7
62 : #endif
63 : !10.11. solver
64 : INTEGER,PARAMETER:: diag_lapack=10
65 : INTEGER,PARAMETER:: diag_lapack_singlePrec=11
66 : !12. solver
67 : #ifdef CPP_ELPA_ONENODE
68 : INTEGER,PARAMETER:: diag_elpa_1node=4
69 : #else
70 : INTEGER,PARAMETER:: diag_elpa_1node=-4
71 : #endif
72 : !13. solver
73 : #ifdef CPP_SCALAPACK
74 : INTEGER,PARAMETER:: diag_debugout=120
75 : #else
76 : INTEGER,PARAMETER:: diag_debugout=20
77 : #endif
78 : !14.solver
79 : INTEGER,PARAMETER:: diag_dummy=21
80 :
81 :
82 : INTEGER,PARAMETER::diag_all_solver(14)=(/diag_chase,diag_elemental,diag_scalapack,diag_elpa,diag_elsielpa,&
83 : diag_elsichase,diag_magma,diag_stop,diag_cusolver,diag_lapack,diag_lapack_singlePrec,&
84 : diag_elpa_1node,diag_debugout,diag_dummy/)
85 :
86 : CONTAINS
87 :
88 92 : LOGICAL FUNCTION parallel_solver_available()
89 92 : parallel_solver_available=ANY(diag_all_solver>100)
90 92 : END FUNCTION parallel_solver_available
91 :
92 7422 : FUNCTION select_solver(suggested_solver,parallel) RESULT(diag_solver)
93 : USE m_juDFT
94 : LOGICAL,INTENT(IN):: parallel
95 : INTEGER,INTENT(in):: suggested_solver
96 : INTEGER :: diag_solver
97 7422 : diag_solver=-99
98 :
99 7422 : diag_solver=suggested_solver
100 :
101 7422 : IF (suggested_solver==0) THEN
102 : !Determine the default solver
103 234 : IF (parallel) THEN
104 : diag_solver=MAXVAL(diag_all_solver,mask=diag_all_solver>100)
105 : ELSE
106 68 : diag_solver=MINVAL(diag_all_solver,mask=diag_all_solver<200.and.diag_all_solver>0)
107 : ENDIF
108 :
109 : !check if a special solver was requested
110 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="elpa") diag_solver=diag_elpa
111 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="elpa_1node") diag_solver=diag_elpa_1node
112 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="scalapack") diag_solver=diag_scalapack
113 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="elemental") diag_solver=diag_elemental
114 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="lapack") diag_solver=diag_lapack
115 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="lapack_singlePrec") diag_solver=diag_lapack_singlePrec
116 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="magma") diag_solver=diag_magma
117 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="chase") diag_solver=diag_chase
118 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="cusolver") diag_solver=diag_cusolver
119 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="debugout") diag_solver=diag_debugout
120 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="elsielpa") diag_solver=diag_elsielpa
121 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="elsichase") diag_solver=diag_elsichase
122 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="dummy") diag_solver=diag_dummy
123 234 : IF (TRIM(juDFT_string_for_argument("-diag"))=="stop") diag_solver=diag_stop
124 :
125 : !Check if solver is possible
126 234 : IF (diag_solver<0) CALL juDFT_error(&
127 : "You selected a solver for the eigenvalue problem that is not available",&
128 0 : hint="You most probably did not provide the appropriate libraries for compilation/linking")
129 234 : IF (diag_solver<100.AND.parallel) CALL judft_error(&
130 : "You selected an eigensolver that does not support distributed memory parallism",&
131 0 : hint="Try scalapack,elpa or another supported solver for parallel matrices")
132 234 : IF (diag_solver>200.AND..NOT.parallel) CALL judft_error(&
133 : "You selected an eigensolver for matrices that are memory distributed",&
134 0 : hint="Try lapack, cusolver or another supported solver for non-distributed matrices")
135 : END IF
136 :
137 7422 : END FUNCTION select_solver
138 :
139 80 : subroutine print_solver(parallel)
140 : LOGICAL,INTENT(IN):: parallel
141 0 : select case(select_solver(0,parallel))
142 : case(diag_chase)
143 0 : write(*,*) "Selected Eigensolver : chase"
144 : case(diag_elemental)
145 0 : write(*,*) "Selected Eigensolver : elemental"
146 : case(diag_scalapack)
147 80 : write(*,*) "Selected Eigensolver : scalapack"
148 : case(diag_elpa)
149 0 : write(*,*) "Selected Eigensolver : elpa"
150 : case(diag_elsielpa)
151 0 : write(*,*) "Selected Eigensolver : elsielpa"
152 : case(diag_elsichase)
153 0 : write(*,*) "Selected Eigensolver : elsichase"
154 : case(diag_magma)
155 0 : write(*,*) "Selected Eigensolver : magma"
156 : case(diag_stop)
157 0 : write(*,*) "Selected Eigensolver : stop"
158 : case(diag_cusolver)
159 0 : write(*,*) "Selected Eigensolver : cusolver"
160 : case(diag_lapack)
161 0 : write(*,*) "Selected Eigensolver : lapack"
162 : case(diag_lapack_singleprec)
163 0 : write(*,*) "Selected Eigensolver : lapack_singlePrec"
164 : case(diag_elpa_1node)
165 0 : write(*,*) "Selected Eigensolver : elpa_1node"
166 : case(diag_debugout)
167 0 : write(*,*) "Selected Eigensolver : debugout"
168 : case(diag_dummy)
169 80 : write(*,*) "Selected Eigensolver : dummy"
170 : end select
171 80 : end subroutine
172 :
173 : END MODULE m_available_solvers
|