17 #if defined(__LIBPEXSI)
18 USE f_ppexsi_interface,
ONLY: f_ppexsi_dft_driver, &
19 f_ppexsi_load_real_hs_matrix, &
21 f_ppexsi_plan_finalize, &
22 f_ppexsi_plan_initialize, &
23 f_ppexsi_retrieve_real_dft_matrix, &
24 f_ppexsi_set_default_options
26 #if defined(__HAS_IEEE_EXCEPTIONS)
27 USE ieee_exceptions,
ONLY: ieee_get_halting_mode, &
28 ieee_set_halting_mode, &
33 USE iso_c_binding,
ONLY: c_intptr_t
35 #include "./base/base_uses.f90"
41 CHARACTER(len=*),
PARAMETER,
PRIVATE :: moduleN =
'pexsi_interface'
50 #if defined(__LIBPEXSI)
51 TYPE(f_ppexsi_options) :: options
53 INTEGER :: unused = -1
55 END TYPE cp_pexsi_options
83 isInertiaCount, maxPEXSIIter, muMin0, muMax0, mu0, &
84 muInertiaTolerance, muInertiaExpansion, &
85 muPEXSISafeGuard, numElectronPEXSITolerance, &
86 matrixType, isSymbolicFactorize, ordering, rowOrdering, &
87 npSymbFact, verbosity)
89 TYPE(cp_pexsi_options),
INTENT(INOUT) :: pexsi_options
90 REAL(kind=
real_8),
INTENT(IN),
OPTIONAL :: temperature, gap, deltae
91 INTEGER,
INTENT(IN),
OPTIONAL :: numpole, isinertiacount, &
93 REAL(kind=
real_8),
INTENT(IN),
OPTIONAL :: mumin0, mumax0, mu0, &
94 muinertiatolerance, muinertiaexpansion, mupexsisafeguard, &
95 numelectronpexsitolerance
96 INTEGER,
INTENT(IN),
OPTIONAL :: matrixtype, &
97 issymbolicfactorize, &
98 ordering, rowordering, npsymbfact, &
101 #if defined(__LIBPEXSI)
102 IF (
PRESENT(temperature)) pexsi_options%options%temperature = temperature
103 IF (
PRESENT(gap)) pexsi_options%options%gap = gap
104 IF (
PRESENT(deltae)) pexsi_options%options%deltaE = deltae
105 IF (
PRESENT(numpole)) pexsi_options%options%numPole = numpole
106 IF (
PRESENT(isinertiacount)) pexsi_options%options%isInertiaCount = isinertiacount
107 IF (
PRESENT(maxpexsiiter)) pexsi_options%options%maxPEXSIIter = maxpexsiiter
108 IF (
PRESENT(mumin0)) pexsi_options%options%muMin0 = mumin0
109 IF (
PRESENT(mumax0)) pexsi_options%options%muMax0 = mumax0
110 IF (
PRESENT(mu0)) pexsi_options%options%mu0 = mu0
111 IF (
PRESENT(muinertiatolerance)) &
112 pexsi_options%options%muInertiaTolerance = muinertiatolerance
113 IF (
PRESENT(muinertiaexpansion)) &
114 pexsi_options%options%muInertiaExpansion = muinertiaexpansion
115 IF (
PRESENT(mupexsisafeguard)) &
116 pexsi_options%options%muPEXSISafeGuard = mupexsisafeguard
117 IF (
PRESENT(numelectronpexsitolerance)) &
118 pexsi_options%options%numElectronPEXSITolerance = numelectronpexsitolerance
119 IF (
PRESENT(matrixtype)) pexsi_options%options%matrixType = matrixtype
120 IF (
PRESENT(issymbolicfactorize)) &
121 pexsi_options%options%isSymbolicFactorize = issymbolicfactorize
122 IF (
PRESENT(ordering)) pexsi_options%options%ordering = ordering
123 IF (
PRESENT(rowordering)) pexsi_options%options%rowOrdering = rowordering
124 IF (
PRESENT(npsymbfact)) pexsi_options%options%npSymbFact = npsymbfact
125 IF (
PRESENT(verbosity)) pexsi_options%options%verbosity = verbosity
127 mark_used(pexsi_options)
128 mark_used(temperature)
132 mark_used(isinertiacount)
133 mark_used(maxpexsiiter)
137 mark_used(muinertiatolerance)
138 mark_used(muinertiaexpansion)
139 mark_used(mupexsisafeguard)
140 mark_used(numelectronpexsitolerance)
141 mark_used(matrixtype)
142 mark_used(issymbolicfactorize)
144 mark_used(rowordering)
145 mark_used(npsymbfact)
147 cpabort(
"Requires linking to the PEXSI library.")
181 isInertiaCount, maxPEXSIIter, muMin0, muMax0, mu0, &
182 muInertiaTolerance, muInertiaExpansion, &
183 muPEXSISafeGuard, numElectronPEXSITolerance, &
184 matrixType, isSymbolicFactorize, ordering, rowOrdering, &
185 npSymbFact, verbosity)
186 TYPE(cp_pexsi_options),
INTENT(IN) :: pexsi_options
187 REAL(kind=
real_8),
INTENT(OUT),
OPTIONAL :: temperature, gap, deltae
188 INTEGER,
INTENT(OUT),
OPTIONAL :: numpole, isinertiacount, &
190 REAL(kind=
real_8),
INTENT(OUT),
OPTIONAL :: mumin0, mumax0, mu0, &
191 muinertiatolerance, muinertiaexpansion, mupexsisafeguard, &
192 numelectronpexsitolerance
193 INTEGER,
INTENT(OUT),
OPTIONAL :: matrixtype, &
194 issymbolicfactorize, &
195 ordering, rowordering, npsymbfact, &
198 #if defined(__LIBPEXSI)
199 IF (
PRESENT(temperature)) temperature = pexsi_options%options%temperature
200 IF (
PRESENT(gap)) gap = pexsi_options%options%gap
201 IF (
PRESENT(deltae)) deltae = pexsi_options%options%deltaE
202 IF (
PRESENT(numpole)) numpole = pexsi_options%options%numPole
203 IF (
PRESENT(isinertiacount)) isinertiacount = pexsi_options%options%isInertiaCount
204 IF (
PRESENT(maxpexsiiter)) maxpexsiiter = pexsi_options%options%maxPEXSIIter
205 IF (
PRESENT(mumin0)) mumin0 = pexsi_options%options%muMin0
206 IF (
PRESENT(mumax0)) mumax0 = pexsi_options%options%muMax0
207 IF (
PRESENT(mu0)) mu0 = pexsi_options%options%mu0
208 IF (
PRESENT(muinertiatolerance)) &
209 muinertiatolerance = pexsi_options%options%muInertiaTolerance
210 IF (
PRESENT(muinertiaexpansion)) &
211 muinertiaexpansion = pexsi_options%options%muInertiaExpansion
212 IF (
PRESENT(mupexsisafeguard)) &
213 mupexsisafeguard = pexsi_options%options%muPEXSISafeGuard
214 IF (
PRESENT(numelectronpexsitolerance)) &
215 numelectronpexsitolerance = pexsi_options%options%numElectronPEXSITolerance
216 IF (
PRESENT(matrixtype)) matrixtype = pexsi_options%options%matrixType
217 IF (
PRESENT(issymbolicfactorize)) &
218 issymbolicfactorize = pexsi_options%options%isSymbolicFactorize
219 IF (
PRESENT(ordering)) ordering = pexsi_options%options%ordering
220 IF (
PRESENT(rowordering)) rowordering = pexsi_options%options%rowOrdering
221 IF (
PRESENT(npsymbfact)) npsymbfact = pexsi_options%options%npSymbFact
222 IF (
PRESENT(verbosity)) verbosity = pexsi_options%options%verbosity
224 mark_used(pexsi_options)
226 IF (
PRESENT(temperature)) temperature = 0.0_real_8
227 IF (
PRESENT(gap)) gap = 0.0_real_8
228 IF (
PRESENT(deltae)) deltae = 0.0_real_8
229 IF (
PRESENT(numpole)) numpole = -1
230 IF (
PRESENT(isinertiacount)) isinertiacount = -1
231 IF (
PRESENT(maxpexsiiter)) maxpexsiiter = -1
232 IF (
PRESENT(mumin0)) mumin0 = 0.0_real_8
233 IF (
PRESENT(mumax0)) mumax0 = 0.0_real_8
234 IF (
PRESENT(mu0)) mu0 = 0.0_real_8
235 IF (
PRESENT(muinertiatolerance)) muinertiatolerance = 0.0_real_8
236 IF (
PRESENT(muinertiaexpansion)) muinertiaexpansion = 0.0_real_8
237 IF (
PRESENT(mupexsisafeguard)) mupexsisafeguard = 0.0_real_8
238 IF (
PRESENT(numelectronpexsitolerance)) numelectronpexsitolerance = 0.0_real_8
239 IF (
PRESENT(matrixtype)) matrixtype = -1
240 IF (
PRESENT(issymbolicfactorize)) issymbolicfactorize = -1
241 IF (
PRESENT(ordering)) ordering = -1
242 IF (
PRESENT(rowordering)) rowordering = -1
243 IF (
PRESENT(npsymbfact)) npsymbfact = -1
244 IF (
PRESENT(verbosity)) verbosity = -1
245 cpabort(
"Requires linking to the PEXSI library.")
254 TYPE(cp_pexsi_options),
INTENT(OUT) :: pexsi_options
256 #if defined(__LIBPEXSI)
257 CALL f_ppexsi_set_default_options(pexsi_options%options)
259 cpabort(
"Requires linking to the PEXSI library.")
272 TYPE(mp_comm_type),
INTENT(IN) :: comm
273 INTEGER,
INTENT(IN) :: numprocrow, numproccol, &
277 #if defined(__LIBPEXSI)
278 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_pexsi_plan_initialize'
279 INTEGER :: info, handle
281 CALL timeset(routinen, handle)
283 numproccol, outputfileindex, info)
285 cpabort(
"Pexsi returned an error. Consider logPEXSI0 for details.")
286 CALL timestop(handle)
289 mark_used(numprocrow)
290 mark_used(numproccol)
291 mark_used(outputfileindex)
293 cpabort(
"Requires linking to the PEXSI library.")
312 nnzLocal, numColLocal, colptrLocal, &
313 rowindLocal, HnzvalLocal, isSIdentity, &
315 INTEGER(KIND=C_INTPTR_T),
INTENT(IN) :: plan
316 TYPE(cp_pexsi_options),
INTENT(IN) :: pexsi_options
317 INTEGER,
INTENT(IN) :: nrows, nnz, nnzlocal, &
318 numcollocal, colptrlocal(*), &
320 REAL(kind=
real_8),
INTENT(IN) :: hnzvallocal(*)
321 INTEGER,
INTENT(IN) :: issidentity
322 REAL(kind=
real_8),
INTENT(IN) :: snzvallocal(*)
324 #if defined(__LIBPEXSI)
325 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_pexsi_load_real_symmetric_hs_matrix'
326 INTEGER :: handle, info
328 CALL timeset(routinen, handle)
329 CALL f_ppexsi_load_real_hs_matrix(plan, pexsi_options%options, nrows, nnz, nnzlocal, &
330 numcollocal, colptrlocal, rowindlocal, &
331 hnzvallocal, issidentity, snzvallocal, info)
333 cpabort(
"Pexsi returned an error. Consider logPEXSI0 for details.")
334 CALL timestop(handle)
337 mark_used(pexsi_options)
341 mark_used(numcollocal)
342 mark_used(issidentity)
343 cpabort(
"Requires linking to the PEXSI library.")
346 IF (.false.) then;
DO
347 IF (colptrlocal(1) > rowindlocal(1) .OR. hnzvallocal(1) > snzvallocal(1))
EXIT
365 numElectronPEXSI, muMinInertia, muMaxInertia, &
366 numTotalInertiaIter, numTotalPEXSIIter)
367 INTEGER(KIND=C_INTPTR_T),
INTENT(IN) :: plan
368 TYPE(cp_pexsi_options),
INTENT(IN) :: pexsi_options
369 REAL(kind=real_8),
INTENT(IN) :: numelectronexact
370 REAL(kind=real_8),
INTENT(out) :: mupexsi, numelectronpexsi, &
371 mumininertia, mumaxinertia
372 INTEGER,
INTENT(out) :: numtotalinertiaiter, &
375 #if defined(__LIBPEXSI)
376 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_pexsi_dft_driver'
377 INTEGER :: handle, info
378 #if defined(__HAS_IEEE_EXCEPTIONS)
379 LOGICAL,
DIMENSION(5) :: halt
382 CALL timeset(routinen, handle)
386 #if defined(__HAS_IEEE_EXCEPTIONS)
387 CALL ieee_get_halting_mode(ieee_all, halt)
388 CALL ieee_set_halting_mode(ieee_all, .false.)
391 CALL f_ppexsi_dft_driver(plan, pexsi_options%options, numelectronexact, mupexsi, &
392 numelectronpexsi, mumininertia, mumaxinertia, &
393 numtotalinertiaiter, numtotalpexsiiter, info)
395 #if defined(__HAS_IEEE_EXCEPTIONS)
396 CALL ieee_set_halting_mode(ieee_all, halt)
400 cpabort(
"Pexsi returned an error. Consider logPEXSI0 for details.")
401 CALL timestop(handle)
404 mark_used(numelectronexact)
405 mark_used(pexsi_options)
408 numelectronpexsi = 0.0_real_8
409 mumininertia = 0.0_real_8
410 mumaxinertia = 0.0_real_8
411 numtotalinertiaiter = -1
412 numtotalpexsiiter = -1
413 cpabort(
"Requires linking to the PEXSI library.")
428 FDMnzvalLocal, totalEnergyH, &
429 totalEnergyS, totalFreeEnergy)
430 INTEGER(KIND=C_INTPTR_T),
INTENT(IN) :: plan
431 REAL(kind=real_8),
INTENT(out) :: dmnzvallocal(*), edmnzvallocal(*), &
432 fdmnzvallocal(*), totalenergyh, totalenergys, &
435 #if defined(__LIBPEXSI)
436 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_pexsi_retrieve_real_symmetric_dft_matrix'
437 INTEGER :: handle, info
439 CALL timeset(routinen, handle)
440 CALL f_ppexsi_retrieve_real_dft_matrix(plan, dmnzvallocal, edmnzvallocal, &
441 fdmnzvallocal, totalenergyh, &
442 totalenergys, totalfreeenergy, info)
444 cpabort(
"Pexsi returned an error. Consider logPEXSI0 for details.")
445 CALL timestop(handle)
449 dmnzvallocal(1) = 0.0_real_8
450 edmnzvallocal(1) = 0.0_real_8
451 fdmnzvallocal(1) = 0.0_real_8
452 totalenergyh = 0.0_real_8
453 totalenergys = 0.0_real_8
454 totalfreeenergy = 0.0_real_8
456 cpabort(
"Requires linking to the PEXSI library.")
465 INTEGER(KIND=C_INTPTR_T),
INTENT(IN) :: plan
467 #if defined(__LIBPEXSI)
468 CHARACTER(LEN=*),
PARAMETER :: routinen =
'cp_pexsi_plan_finalize'
469 INTEGER :: info, handle
471 CALL timeset(routinen, handle)
472 CALL f_ppexsi_plan_finalize(plan, info)
474 cpabort(
"Pexsi returned an error. Consider logPEXSI0 for details.")
475 CALL timestop(handle)
478 cpabort(
"Requires linking to the PEXSI library.")
Defines the basic variable types.
integer, parameter, public int_8
integer, parameter, public real_8
Interface to the message passing library MPI.
Interface to the PEXSI library, providing wrappers for all PEXSI routines that are called inside CP2K...
integer(kind=c_intptr_t) function, public cp_pexsi_plan_initialize(comm, numProcRow, numProcCol, outputFileIndex)
...
subroutine, public cp_pexsi_plan_finalize(plan)
...
subroutine, public cp_pexsi_get_options(pexsi_options, temperature, gap, deltaE, numPole, isInertiaCount, maxPEXSIIter, muMin0, muMax0, mu0, muInertiaTolerance, muInertiaExpansion, muPEXSISafeGuard, numElectronPEXSITolerance, matrixType, isSymbolicFactorize, ordering, rowOrdering, npSymbFact, verbosity)
Access PEXSI internal options.
subroutine, public cp_pexsi_retrieve_real_dft_matrix(plan, DMnzvalLocal, EDMnzvalLocal, FDMnzvalLocal, totalEnergyH, totalEnergyS, totalFreeEnergy)
...
subroutine, public cp_pexsi_set_default_options(pexsi_options)
...
subroutine, public cp_pexsi_set_options(pexsi_options, temperature, gap, deltaE, numPole, isInertiaCount, maxPEXSIIter, muMin0, muMax0, mu0, muInertiaTolerance, muInertiaExpansion, muPEXSISafeGuard, numElectronPEXSITolerance, matrixType, isSymbolicFactorize, ordering, rowOrdering, npSymbFact, verbosity)
Set PEXSI internal options.
subroutine, public cp_pexsi_dft_driver(plan, pexsi_options, numElectronExact, muPEXSI, numElectronPEXSI, muMinInertia, muMaxInertia, numTotalInertiaIter, numTotalPEXSIIter)
...
subroutine, public cp_pexsi_load_real_hs_matrix(plan, pexsi_options, nrows, nnz, nnzLocal, numColLocal, colptrLocal, rowindLocal, HnzvalLocal, isSIdentity, SnzvalLocal)
...