elpa_solve_tridi.F90 6 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 45 46 47 48 49 50 51 52 53 54 55 56
!    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.
!
!
! ELPA1 -- Faster replacements for ScaLAPACK symmetric eigenvalue routines
!
! Copyright of the original code rests with the authors inside the ELPA
! consortium. The copyright of any additional modifications shall rest
! with their original authors, but shall adhere to the licensing terms
! distributed along with the original code in the file "COPYING".
!
! Author: A. Marek, MPCDF



57
#include "../../general/sanity.F90"
58 59

      use precision
60 61 62
      use elpa1_auxiliary_impl, only : elpa_solve_tridi_&
      &PRECISION&
      &_impl
63
      use elpa
64
      use elpa_abstract_impl
65 66 67
#ifdef WITH_OPENMP
      use omp_lib
#endif
68
      implicit none
69 70
      integer(kind=ik)            :: na, nev, ldq, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols
      real(kind=REAL_DATATYPE)    :: d(na), e(na)
71
#ifdef USE_ASSUMED_SIZE
72
      real(kind=REAL_DATATYPE)    :: q(ldq,*)
73
#else
74
      real(kind=REAL_DATATYPE)    :: q(ldq,matrixCols)
75
#endif
76

77
      logical, intent(in)         :: wantDebug
78 79
      logical                     :: success ! the return value
      integer                     :: error
80
      class(elpa_t), pointer      :: obj
81 82 83
#ifdef WITH_OPENMP
      integer                     :: nrThreads
#endif
84

85 86 87
      !call timer%start("elpa_solve_tridi_&
      !&PRECISION&
      !&_legacy_interface")
88 89 90

      success = .false.

91
      if (elpa_init(CURRENT_API_VERSION) /= ELPA_OK) then
Pavel Kus's avatar
Pavel Kus committed
92
        print *, "ELPA API version not supported"
93 94 95
        success = .false.
      endif

96 97 98 99 100
      obj => elpa_allocate(error)
      if (error .ne. ELPA_OK) then
        print *,"Problem calling internal elpa_allocate. Aborting ..."
        stop
      endif
101

Andreas Marek's avatar
Andreas Marek committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
      call obj%set("na", na, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call obj%set("nev", nev, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call obj%set("local_nrows", ldq, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call obj%set("local_ncols", matrixCols, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call obj%set("nblk", nblk, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
127

Andreas Marek's avatar
Andreas Marek committed
128 129 130 131 132 133 134 135 136
      call obj%set("mpi_comm_rows", mpi_comm_rows, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
      endif
      call obj%set("mpi_comm_cols", mpi_comm_cols, error)
      if (error .ne. ELPA_OK) then
         print *,"Problem setting option. Aborting..."
         stop
137
      endif
Pavel Kus's avatar
Pavel Kus committed
138 139

      call obj%creating_from_legacy_api()
140

141
      if (obj%setup() .ne. ELPA_OK) then
142
        print *, "Cannot setup ELPA instance"
143 144 145 146
        success = .false.
        return
      endif

147 148 149 150 151 152 153 154
#ifdef WITH_OPENMP
      nrThreads = omp_get_max_threads()
      call obj%set("omp_threads", nrThreads, error)
#else
      call obj%set("omp_threads", 1, error)
#endif


155
      if (wantDebug) then
Andreas Marek's avatar
Andreas Marek committed
156 157 158 159 160
        call obj%set("debug",1, error)
        if (error .ne. ELPA_OK) then
           print *,"Problem setting option. Aborting..."
           stop
        endif
161
      endif
162

163 164 165 166 167 168 169 170
      call obj%solve_tridiagonal(d, e, q(1:ldq,1:matrixCols), error)
      if (error /= ELPA_OK) then
        print *, "Cannot run solve_tridi"
        success = .false.
        return
      else
        success = .true.
      endif
171

172 173 174 175 176 177 178 179 180 181 182
      call elpa_deallocate(obj, error)
      if (error .ne. ELPA_OK) then
        print *," Cannot deallocate the internal ELPA object! This might lead to a memory leak! "
!!        stop
      endif

      call elpa_uninit(error)
      if (error .ne. ELPA_OK) then
        print *," Cannot uninit the internal ELPA object! This might lead to a memory leak!"
!        stop
      endif
183

184 185 186
     !call timer%stop("elpa_solve_tridi_&
     !&PRECISION&
     !&_legacy_interface")
187 188 189 190 191 192

#undef REALCASE
#undef COMPLEXCASE
#undef DOUBLE_PRECISION
#undef SINGLE_PRECISION

193
! vim: syntax=fortran