elpa_cholesky_template.F90 4.21 KB
Newer Older
Andreas Marek's avatar
Andreas Marek committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
!    This file is part of ELPA.
!
!    The ELPA library was originally created by the ELPA consortium,
!    consisting of the following organizations:
!
!    - Max Planck Computing and Data Facility (MPCDF), formerly known as
!      Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
!    - Bergische Universität Wuppertal, Lehrstuhl für angewandte
!      Informatik,
!    - Technische Universität München, Lehrstuhl für Informatik mit
!      Schwerpunkt Wissenschaftliches Rechnen ,
!    - Fritz-Haber-Institut, Berlin, Abt. Theorie,
!    - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
!      Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
!      and
!    - IBM Deutschland GmbH
!
!    This particular source code file contains additions, changes and
!    enhancements authored by Intel Corporation which is not part of
!    the ELPA consortium.
!
!    More information can be found here:
!    http://elpa.mpcdf.mpg.de/
!
!    ELPA is free software: you can redistribute it and/or modify
!    it under the terms of the version 3 of the license of the
!    GNU Lesser General Public License as published by the Free
!    Software Foundation.
!
!    ELPA is distributed in the hope that it will be useful,
!    but WITHOUT ANY WARRANTY; without even the implied warranty of
!    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
!    GNU Lesser General Public License for more details.
!
!    You should have received a copy of the GNU Lesser General Public License
!    along with ELPA.  If not, see <http://www.gnu.org/licenses/>
!
!    ELPA reflects a substantial effort on the part of the original
!    ELPA consortium, and we ask you to respect the spirit of the
!    license that we chose: i.e., please contribute any changes you
!    may have back to the original ELPA library distribution, and keep
!    any derivatives of ELPA under the same license that we chose for
!    the original distribution, the GNU Lesser General Public License.

45
#include "../../general/sanity.F90"
46
47
48
      use elpa
      use precision
      implicit none
Andreas Marek's avatar
Andreas Marek committed
49

50
      integer(kind=ik)                 :: na, lda, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols
Andreas Marek's avatar
Andreas Marek committed
51
#if REALCASE == 1
52
#ifdef USE_ASSUMED_SIZE
53
      real(kind=REAL_DATATYPE)         :: a(lda,*)
54
#else
55
      real(kind=REAL_DATATYPE)         :: a(lda,matrixCols)
56
#endif
Andreas Marek's avatar
Andreas Marek committed
57
58
#endif
#if COMPLEXCASE == 1
59
60
61
#ifdef USE_ASSUMED_SIZE
      complex(kind=COMPLEX_DATATYPE)   :: a(lda,*)
#else
Andreas Marek's avatar
Andreas Marek committed
62
      complex(kind=COMPLEX_DATATYPE)   :: a(lda,matrixCols)
63
#endif
64
#endif
65
66
      logical, intent(in)              :: wantDebug
      logical                          :: success
67
      integer(kind=ik)                 :: successInternal
68

69
      class(elpa_t), pointer           :: e
Andreas Marek's avatar
Andreas Marek committed
70

71
72
73
74
75
      !call timer%start("elpa_cholesky_&
      !&MATH_DATATYPE&
      !&_&
      !&PRECISION&
      !&_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
76
77
78

      success = .true.

79
      if (elpa_init(CURRENT_API_VERSION) /= ELPA_OK) then
Pavel Kus's avatar
Pavel Kus committed
80
        print *, "ELPA API version not supported"
81
        success = .false.
Pavel Kus's avatar
Pavel Kus committed
82
        return
Andreas Marek's avatar
Andreas Marek committed
83
84
      endif

85
      e => elpa_allocate()
86
87
88
89
90
91
92
93
94

      call e%set("na", na)
      call e%set("local_nrows", lda)
      call e%set("local_ncols", matrixCols)
      call e%set("nblk", nblk)

      call e%set("mpi_comm_rows", mpi_comm_rows)
      call e%set("mpi_comm_cols", mpi_comm_cols)

Andreas Marek's avatar
Andreas Marek committed
95
96
97
98
99
100
101
      !! the elpa object needs nev to be set (in case the EVP-solver is
      !! called later. Thus it is set by user, do nothing, otherwise,
      !! set it to na as default
      !if (e%is_set("nev")) .ne. 1) then
      !  call e%set("nev", na)
      !endif

102
      if (e%setup() .ne. ELPA_OK) then
103
        print *, "Cannot setup ELPA instance"
104
105
        success = .false.
        return
Andreas Marek's avatar
Andreas Marek committed
106
107
      endif

108
109
110
      if (wantDebug) then
        call e%set("debug",1)
      endif
111
      call e%cholesky(a(1:lda,1:matrixCols), successInternal)
Andreas Marek's avatar
Andreas Marek committed
112

113
114
115
116
117
118
      if (successInternal .ne. ELPA_OK) then
        print *, "Cannot run cholesky"
        success = .false.
        return
      else
        success =.true.
Andreas Marek's avatar
Andreas Marek committed
119
      endif
120
      call elpa_deallocate(e)
Andreas Marek's avatar
Andreas Marek committed
121

122
      call elpa_uninit()
Andreas Marek's avatar
Andreas Marek committed
123

124
125
126
127
128
      !call timer%stop("elpa_cholesky_&
      !&MATH_DATATYPE&
      !&_&
      !&PRECISION&
      !&_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
129
130
131
132
133

#undef REALCASE
#undef COMPLEXCASE
#undef DOUBLE_PRECISION
#undef SINGLE_PRECISION
134
135

! vim: syntax=fortran