elpa_20180525_onenode.F90 2.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
!-------------------------------------------------------------------------------
! Copyright (c) 2016 Peter Grünberg Institut, Forschungszentrum Jülich, Germany
! This file is part of FLEUR and available as free software under the conditions
! of the MIT license as expressed in the LICENSE file in more detail.
!--------------------------------------------------------------------------------

MODULE m_elpa_onenode
CONTAINS
  SUBROUTINE elpa_diag_onenode(hmat,smat,ne,eig,ev)
    !
    !----------------------------------------------------
12 13
    ! Sigensystem solver 
    !  Uses the ELPA (1 node version)
14 15 16 17 18 19 20 21 22 23
    !
    !
    ! hmat ..... Hamiltonian matrix
    ! smat ..... overlap matrix
    ! ne ....... number of ev's searched (and found) on this node
    !            On input, overall number of ev's searched,
    !            On output, local number of ev's found
    ! eig ...... eigenvalues, output
    ! ev ....... eigenvectors, output
    !
24
    ! U.Alekseeva     Nov. 2018
25 26 27 28
    !----------------------------------------------------
    USE m_juDFT
    USE m_types_mat
    USE m_types
29
#ifdef CPP_ELPA_ONENODE
30
    USE elpa
31
#endif
32 33 34 35
    IMPLICIT NONE

    CLASS(t_mat),INTENT(INOUT)    :: hmat,smat
    CLASS(t_mat),ALLOCATABLE,INTENT(OUT)::ev
36
    REAL,INTENT(OUT)              :: eig(:)
37 38
    INTEGER,INTENT(INOUT)         :: ne
    
39
#ifdef CPP_ELPA_ONENODE
40 41 42
    !...  Local variables
    !
    INTEGER           :: err
43 44 45
    REAL,ALLOCATABLE  :: eig2(:)
    TYPE(t_mat)       :: ev_dist
    INTEGER           :: kernel
46 47
    CLASS(elpa_t),pointer :: elpa_obj

48 49
    err = elpa_init(20180525)
    elpa_obj => elpa_allocate()
50
       
51 52
    ALLOCATE ( eig2(hmat%matsize1), stat=err ) ! The eigenvalue array
    IF (err.NE.0) CALL juDFT_error('Failed to allocated "eig2"', calledby ='elpa')
53

54 55
    CALL ev_dist%init(hmat)! Eigenvectors
    IF (err.NE.0) CALL juDFT_error('Failed to allocated "ev_dist"',calledby ='elpa')
56
       
57 58 59 60 61 62 63
    CALL elpa_obj%set("na", hmat%matsize1, err)
    CALL elpa_obj%set("nev", ne, err)
    CALL elpa_obj%set("local_nrows", hmat%matsize1, err)
    CALL elpa_obj%set("local_ncols", hmat%matsize2, err)
    CALL elpa_obj%set("nblk",hmat%matsize1, err)
    CALL elpa_obj%set("blacs_context", -1, err)
    err = elpa_obj%setup()
64

65 66
    CALL hmat%add_transpose(hmat)       
    CALL smat%add_transpose(smat)       
67

68 69 70 71 72
    IF (hmat%l_real) THEN
        CALL elpa_obj%generalized_eigenvectors(hmat%data_r,smat%data_r,eig2, ev_dist%data_r, .FALSE.,err)
    ELSE
        CALL elpa_obj%generalized_eigenvectors(hmat%data_c,smat%data_c,eig2, ev_dist%data_c, .FALSE., err)
    ENDIF
73
       
74 75 76
    CALL elpa_deallocate(elpa_obj)
    CALL elpa_uninit()
    ! END of ELPA stuff
77

78 79 80
    eig(1:ne) = eig2(1:ne)
    DEALLOCATE(eig2)
       
81 82
    ALLOCATE(t_mat::ev)
    CALL ev%alloc(hmat%l_real,hmat%matsize1,ne)
83
    CALL ev%copy(ev_dist,1,1)
84 85

#endif
86 87 88
 
END SUBROUTINE elpa_diag_onenode
END MODULE m_elpa_onenode