elpa_cholesky_template.F90 5.22 KB
Newer Older
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, error
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 95 96 97 98 99 100 101 102 103 104 105 106
      call e%set("na", na, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call e%set("local_nrows", lda, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call e%set("local_ncols", matrixCols, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call e%set("nblk", nblk, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
107

108 109 110 111 112 113 114 115 116 117
      call e%set("mpi_comm_rows", mpi_comm_rows, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call e%set("mpi_comm_cols", mpi_comm_cols, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
118

119 120 121 122 123 124
      call e%set("legacy_api", 1, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop 1
      endif

125 126 127 128 129 130 131
      !! 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

132
      if (e%setup() .ne. ELPA_OK) then
133
        print *, "Cannot setup ELPA instance"
134 135
        success = .false.
        return
Andreas Marek's avatar
Andreas Marek committed
136 137
      endif

138
      if (wantDebug) then
139 140 141 142 143
        call e%set("debug",1, error)
        if (error .ne. ELPA_OK) then
           print *,"Problem setting option. Aborting..."
           stop
        endif
144
      endif
145
      call e%cholesky(a(1:lda,1:matrixCols), successInternal)
Andreas Marek's avatar
Andreas Marek committed
146

147 148 149 150 151 152
      if (successInternal .ne. ELPA_OK) then
        print *, "Cannot run cholesky"
        success = .false.
        return
      else
        success =.true.
Andreas Marek's avatar
Andreas Marek committed
153
      endif
154
      call elpa_deallocate(e)
Andreas Marek's avatar
Andreas Marek committed
155

156
      call elpa_uninit()
Andreas Marek's avatar
Andreas Marek committed
157

158 159 160 161 162
      !call timer%stop("elpa_cholesky_&
      !&MATH_DATATYPE&
      !&_&
      !&PRECISION&
      !&_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
163 164 165 166 167

#undef REALCASE
#undef COMPLEXCASE
#undef DOUBLE_PRECISION
#undef SINGLE_PRECISION
168 169

! vim: syntax=fortran