elpa_invert_trm.F90 6.25 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
!    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".

53
#include "../../general/sanity.F90"
Andreas Marek's avatar
Andreas Marek committed
54 55

       use precision
56
       use elpa
57 58
!       use elpa1_compute
!       use elpa_utilities
Andreas Marek's avatar
Andreas Marek committed
59 60 61
       use elpa_mpi
       implicit none

62
       integer(kind=ik)                 :: na, lda, nblk, matrixCols, mpi_comm_rows, mpi_comm_cols
Andreas Marek's avatar
Andreas Marek committed
63
#if  REALCASE ==  1
64
#ifdef USE_ASSUMED_SIZE
65
       real(kind=REAL_DATATYPE)         :: a(lda,*)
66
#else
67
       real(kind=REAL_DATATYPE)         :: a(lda,matrixCols)
68
#endif
Andreas Marek's avatar
Andreas Marek committed
69 70 71
#endif

#if COMPLEXCASE == 1
72 73 74
#ifdef USE_ASSUMED_SIZE
       complex(kind=COMPLEX_DATATYPE)   :: a(lda,*)
#else
Andreas Marek's avatar
Andreas Marek committed
75
       complex(kind=COMPLEX_DATATYPE)   :: a(lda,matrixCols)
76
#endif
77 78
#endif

79 80 81
!      integer(kind=ik)                 :: my_prow, my_pcol, np_rows, np_cols, mpierr
!      integer(kind=ik)                 :: l_cols, l_rows, l_col1, l_row1, l_colx, l_rowx
!      integer(kind=ik)                 :: n, nc, i, info, ns, nb
82 83 84 85 86 87
!#if REALCASE ==  1
!       real(kind=REAL_DATATYPE), allocatable   :: tmp1(:), tmp2(:,:), tmat1(:,:), tmat2(:,:)
!#endif
!#if COMPLEXCASE == 1
!       complex(kind=COMPLEX_DATATYPE), allocatable    :: tmp1(:), tmp2(:,:), tmat1(:,:), tmat2(:,:)
!#endif
Andreas Marek's avatar
Andreas Marek committed
88 89 90
       logical, intent(in)          :: wantDebug
       logical                      :: success

91
       integer(kind=iK)            :: error
92
       class(elpa_t), pointer      :: e
Andreas Marek's avatar
Andreas Marek committed
93

94 95 96 97 98
       !call timer%start("elpa_invert_trm_&
       !&MATH_DATATYPE&
       !&_&
       !&PRECISION&
       !&_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
99

100
       success = .true.
Andreas Marek's avatar
Andreas Marek committed
101

102
       if (elpa_init(CURRENT_API_VERSION) /= ELPA_OK) then
Pavel Kus's avatar
Pavel Kus committed
103
         print *, "ELPA API version not supported"
104
         success = .false.
Pavel Kus's avatar
Pavel Kus committed
105
         return
Andreas Marek's avatar
Andreas Marek committed
106 107
       endif

108 109 110 111 112 113
       e => elpa_allocate(error)
       if (error .ne. ELPA_OK) then
         print *,"Problem calling internal elpa_allocate. Aborting ..."
         stop
       endif

114

Andreas Marek's avatar
Andreas Marek committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
       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
135

Andreas Marek's avatar
Andreas Marek committed
136 137 138 139 140 141 142 143 144 145
       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
146

Pavel Kus's avatar
Pavel Kus committed
147
       call e%creating_from_legacy_api()
148

149
       if (e%setup() .ne. ELPA_OK) then
150
         print *, "Cannot setup ELPA instance"
151 152
         success = .false.
         return
Andreas Marek's avatar
Andreas Marek committed
153 154
       endif

Pavel Kus's avatar
Pavel Kus committed
155

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

164
       call e%invert_triangular(a(1:lda,1:matrixCols), error)
Andreas Marek's avatar
Andreas Marek committed
165

166
       if (error .ne. ELPA_OK) then
167
         print *, "Cannot run invert_trm"
168 169 170 171 172
         success = .false.
         return
       else
         success =.true.
       endif
Andreas Marek's avatar
Andreas Marek committed
173

174 175 176 177 178 179 180 181 182 183 184
       call elpa_deallocate(e, 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
Andreas Marek's avatar
Andreas Marek committed
185

186
      !call timer%stop("elpa_invert_trm_&
187 188 189 190
       !&MATH_DATATYPE&
       !&_&
       !&PRECISION&
       !&_legacy_interface")
Andreas Marek's avatar
Andreas Marek committed
191 192 193 194 195

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