LCOV - code coverage report
Current view: top level - diagonalization - available_solvers.F90 (source / functions) Hit Total Coverage
Test: combined.info Lines: 23 26 88.5 %
Date: 2019-09-08 04:53:50 Functions: 2 2 100.0 %

          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 expect a distributed (scalapack-type) matrix
      13             : ! -solvers with numbers higher than 200 can handle both
      14             : #ifdef CPP_ELPA
      15             :   INTEGER,PARAMETER:: diag_elpa=101
      16             : #else
      17             :   INTEGER,PARAMETER:: diag_elpa=-101
      18             : #endif
      19             : #ifdef CPP_ELEMENTAL
      20             :   INTEGER,PARAMETER:: diag_elemental=102
      21             : #else
      22             :   INTEGER,PARAMETER:: diag_elemental=-102
      23             : #endif
      24             : #ifdef CPP_SCALAPACK
      25             :   INTEGER,PARAMETER:: diag_scalapack=103
      26             : #else
      27             :   INTEGER,PARAMETER:: diag_scalapack=-103
      28             : #endif
      29             : #ifdef CPP_MAGMA
      30             :   INTEGER,PARAMETER:: diag_magma=6
      31             : #else
      32             :   INTEGER,PARAMETER:: diag_magma=-6
      33             : #endif
      34             : #ifdef CPP_CHASE
      35             :   INTEGER,PARAMETER:: diag_chase=7
      36             : #else
      37             :   INTEGER,PARAMETER:: diag_chase=-7
      38             : #endif
      39             : #ifdef CPP_CUSOLVER
      40             :   INTEGER,PARAMETER:: diag_cusolver=8
      41             : #else
      42             :   INTEGER,PARAMETER:: diag_cusolver=-8
      43             : #endif
      44             :   
      45             :   INTEGER,PARAMETER:: diag_lapack=4
      46             : #ifdef CPP_ELPA_ONENODE
      47             :   INTEGER,PARAMETER:: diag_elpa_1node=14
      48             : #else
      49             :   INTEGER,PARAMETER:: diag_elpa_1node=-14
      50             : #endif 
      51             : #ifdef CPP_SCALAPACK
      52             :   INTEGER,PARAMETER:: diag_debugout=201
      53             : #else
      54             :   INTEGER,PARAMETER:: diag_debugout=20
      55             : #endif  
      56             :   INTEGER,PARAMETER::diag_all_solver(9)=(/diag_elpa,diag_elemental,diag_scalapack,diag_magma,diag_chase,diag_cusolver,diag_lapack,diag_elpa_1node,diag_debugout/)
      57             :   
      58             : CONTAINS
      59             : 
      60          42 :   LOGICAL FUNCTION parallel_solver_available()
      61          42 :     parallel_solver_available=ANY(diag_all_solver>100)
      62          42 :   END FUNCTION parallel_solver_available
      63             : 
      64        1188 :   FUNCTION select_solver(suggested_solver,parallel) RESULT(diag_solver)
      65             :     USE m_juDFT
      66             :     LOGICAL,INTENT(IN):: parallel
      67             :     INTEGER,INTENT(in):: suggested_solver
      68             :     INTEGER           :: diag_solver
      69        1188 :     diag_solver=-99
      70             : 
      71        1188 :     diag_solver=suggested_solver
      72             : 
      73        1188 :     IF (suggested_solver==0) THEN
      74             :        !Determine the default solver
      75          66 :        IF (parallel) THEN
      76         340 :           diag_solver=MINVAL(diag_all_solver,mask=diag_all_solver>100)
      77             :        ELSE
      78         320 :           diag_solver=MINVAL(diag_all_solver,mask=diag_all_solver>0)
      79             :        ENDIF
      80             :        
      81             :        !check if a special solver was requested
      82          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="elpa")       diag_solver=diag_elpa
      83          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="elpa_1node") diag_solver=diag_elpa_1node
      84          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="scalapack")  diag_solver=diag_scalapack
      85          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="elemental")  diag_solver=diag_elemental
      86          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="lapack")     diag_solver=diag_lapack
      87          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="magma")      diag_solver=diag_magma
      88          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="chase")      diag_solver=diag_chase
      89          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="cusolver")   diag_solver=diag_cusolver
      90          66 :        IF (TRIM(juDFT_string_for_argument("-diag"))=="debugout")   diag_solver=diag_debugout
      91             :        !Check if solver is possible
      92          66 :        IF (diag_solver<0)  CALL juDFT_error(&
      93             :             "You selected a solver for the eigenvalue problem that is not available",&
      94           0 :             hint="You most probably did not provide the appropriate libraries for compilation/linking")
      95          66 :        IF (diag_solver<100.AND.parallel) CALL judft_error(&
      96             :             "You selected an eigensolver that does not support distributed memory parallism",&
      97           0 :             hint="Try scalapack,elpa or another supported solver for parallel matrices")
      98          66 :        IF (diag_solver>100.AND.diag_solver<200.AND..NOT.parallel) CALL judft_error(&
      99             :             "You selected an eigensolver for matrices that are memory distributed",&
     100           0 :             hint="Try lapack, cusolver or another supported solver for non-distributed matrices")
     101             :     END IF
     102             : 
     103        1188 :   END FUNCTION select_solver
     104             : 
     105             : END MODULE m_available_solvers

Generated by: LCOV version 1.13