elpa_c_interface.F90 100 KB
Newer Older
Andreas Marek's avatar
Andreas Marek committed
1
2
3
4
5
!    This file is part of ELPA.
!
!    The ELPA library was originally created by the ELPA consortium,
!    consisting of the following organizations:
!
6
7
!    - Max Planck Computing and Data Facility (MPCDF), formerly known as
!      Rechenzentrum Garching der Max-Planck-Gesellschaft (RZG),
Andreas Marek's avatar
Andreas Marek committed
8
9
10
11
12
!    - 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,
13
!    - Max-Plack-Institut für Mathematik in den Naturwissenschaften,
Andreas Marek's avatar
Andreas Marek committed
14
15
16
17
18
19
!      Leipzig, Abt. Komplexe Strukutren in Biologie und Kognition,
!      and
!    - IBM Deutschland GmbH
!
!
!    More information can be found here:
20
!    http://elpa.mpcdf.mpg.de/
Andreas Marek's avatar
Andreas Marek committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
!
!    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.
!
42
! Author: Andreas Marek, MCPDF
Andreas Marek's avatar
Andreas Marek committed
43
#include "config-f90.h"
Andreas Marek's avatar
Andreas Marek committed
44
  !c> #include <complex.h>
Andreas Marek's avatar
Andreas Marek committed
45

46
  !c> /*! \brief C old, deprecated interface, will be deleted. Use "elpa_get_communicators"
47
48
49
50
51
52
53
  !c> *
  !c> * \param mpi_comm_word    MPI global communicator (in)
  !c> * \param my_prow          Row coordinate of the calling process in the process grid (in)
  !c> * \param my_pcol          Column coordinate of the calling process in the process grid (in)
  !c> * \param mpi_comm_rows    Communicator for communicating within rows of processes (out)
  !c> * \result int             integer error value of mpi_comm_split function
  !c> */
54
  !c> int get_elpa_row_col_comms(int mpi_comm_world, int my_prow, int my_pcol, int *mpi_comm_rows, int *mpi_comm_cols);
55
  function get_elpa_row_col_comms_wrapper_c_name1(mpi_comm_world, my_prow, my_pcol, &
Andreas Marek's avatar
Andreas Marek committed
56
                                          mpi_comm_rows, mpi_comm_cols)     &
57
                                          result(mpierr) bind(C,name="get_elpa_row_col_comms")
Andreas Marek's avatar
Andreas Marek committed
58
59
60
    use, intrinsic :: iso_c_binding
    use elpa1, only : get_elpa_row_col_comms

Andreas Marek's avatar
Andreas Marek committed
61
    implicit none
Andreas Marek's avatar
Andreas Marek committed
62
63
64
65
66
67
68
69
    integer(kind=c_int)         :: mpierr
    integer(kind=c_int), value  :: mpi_comm_world, my_prow, my_pcol
    integer(kind=c_int)         :: mpi_comm_rows, mpi_comm_cols

    mpierr = get_elpa_row_col_comms(mpi_comm_world, my_prow, my_pcol, &
                                    mpi_comm_rows, mpi_comm_cols)

  end function
70
71
  !c> #include <complex.h>

72
  !c> /*! \brief C old, deprecated interface, will be deleted. Use "elpa_get_communicators"
73
74
75
76
77
78
79
80
81
82
83
84
  !c> *
  !c> * \param mpi_comm_word    MPI global communicator (in)
  !c> * \param my_prow          Row coordinate of the calling process in the process grid (in)
  !c> * \param my_pcol          Column coordinate of the calling process in the process grid (in)
  !c> * \param mpi_comm_rows    Communicator for communicating within rows of processes (out)
  !c> * \result int             integer error value of mpi_comm_split function
  !c> */
  !c> int get_elpa_communicators(int mpi_comm_world, int my_prow, int my_pcol, int *mpi_comm_rows, int *mpi_comm_cols);
  function get_elpa_row_col_comms_wrapper_c_name2(mpi_comm_world, my_prow, my_pcol, &
                                          mpi_comm_rows, mpi_comm_cols)     &
                                          result(mpierr) bind(C,name="get_elpa_communicators")
    use, intrinsic :: iso_c_binding
85
    use elpa1, only : get_elpa_communicators
86
87
88
89
90
91

    implicit none
    integer(kind=c_int)         :: mpierr
    integer(kind=c_int), value  :: mpi_comm_world, my_prow, my_pcol
    integer(kind=c_int)         :: mpi_comm_rows, mpi_comm_cols

92
    mpierr = get_elpa_communicators(mpi_comm_world, my_prow, my_pcol, &
93
94
95
96
                                    mpi_comm_rows, mpi_comm_cols)

  end function

97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
  !c> #include <complex.h>

  !c> /*! \brief C interface to create ELPA communicators
  !c> *
  !c> * \param mpi_comm_word    MPI global communicator (in)
  !c> * \param my_prow          Row coordinate of the calling process in the process grid (in)
  !c> * \param my_pcol          Column coordinate of the calling process in the process grid (in)
  !c> * \param mpi_comm_rows    Communicator for communicating within rows of processes (out)
  !c> * \result int             integer error value of mpi_comm_split function
  !c> */
  !c> int elpa_get_communicators(int mpi_comm_world, int my_prow, int my_pcol, int *mpi_comm_rows, int *mpi_comm_cols);
  function elpa_get_communicators_wrapper_c(mpi_comm_world, my_prow, my_pcol, &
                                          mpi_comm_rows, mpi_comm_cols)     &
                                          result(mpierr) bind(C,name="elpa_get_communicators")
    use, intrinsic :: iso_c_binding
    use elpa1, only : elpa_get_communicators

    implicit none
    integer(kind=c_int)         :: mpierr
    integer(kind=c_int), value  :: mpi_comm_world, my_prow, my_pcol
    integer(kind=c_int)         :: mpi_comm_rows, mpi_comm_cols

    mpierr = elpa_get_communicators(mpi_comm_world, my_prow, my_pcol, &
                                    mpi_comm_rows, mpi_comm_cols)

  end function
123
124


125
  !c>  /*! \brief C interface to solve the double-precision real eigenvalue problem with 1-stage solver
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  !c>  *
  !c> *  \param  na                   Order of matrix a
  !c> *  \param  nev                  Number of eigenvalues needed.
  !c> *                               The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                    Distributed matrix for which eigenvalues are to be computed.
  !c> *                               Distribution is like in Scalapack.
  !c> *                               The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                   Leading dimension of a
  !c> *  \param ev(na)                On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                     On output: Eigenvectors of a
  !c> *                               Distribution is like in Scalapack.
  !c> *                               Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                               even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                   Leading dimension of q
  !c> *  \param nblk                  blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols           distributed number of matrix columns
  !c> *  \param mpi_comm_rows        MPI-Communicator for rows
  !c> *  \param mpi_comm_cols        MPI-Communicator for columns
144
  !c> *  \param useGPU               use GPU (1=yes, 0=No)
145
146
147
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c>*/
148
#define DOUBLE_PRECISION_REAL 1
149
#ifdef DOUBLE_PRECISION_REAL
150
  !c> int elpa_solve_evp_real_1stage_double_precision(int na, int nev, double *a, int lda, double *ev, double *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
151
#else
152
  !c> int elpa_solve_evp_real_1stage_single_precision(int na, int nev, float *a, int lda, float *ev, float *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
153
#endif
154

155
#ifdef DOUBLE_PRECISION_REAL
156
  function solve_elpa1_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk, &
157
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
158
                                  useGPU)      &
159
160
                                  result(success) bind(C,name="elpa_solve_evp_real_1stage_double_precision")
#else
161
  function solve_elpa1_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk, &
162
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
163
                                  useGPU)      &
164
165
                                  result(success) bind(C,name="elpa_solve_evp_real_1stage_single_precision")
#endif
166

Andreas Marek's avatar
Andreas Marek committed
167
    use, intrinsic :: iso_c_binding
168
    use elpa1
Andreas Marek's avatar
Andreas Marek committed
169

Andreas Marek's avatar
Andreas Marek committed
170
    implicit none
Andreas Marek's avatar
Andreas Marek committed
171
    integer(kind=c_int)                    :: success
172
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, mpi_comm_all
173
    integer(kind=c_int), value, intent(in) :: useGPU
174
#ifdef DOUBLE_PRECISION_REAL
175
    real(kind=c_double)                    :: ev(1:na)
176
#ifdef USE_ASSUMED_SIZE
177
178
179
    real(kind=c_double)                    :: a(lda,*), q(ldq,*)
#else
    real(kind=c_double)                    :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
180
181
182
183
184
#endif

#else /* SINGLE_PRECISION */
    real(kind=c_float)                     :: ev(1:na)

185
#ifdef USE_ASSUMED_SIZE
186
    real(kind=c_float)                     :: a(lda,*), q(ldq,*)
187
188
#else
    real(kind=c_float)                     :: a(1:lda,1:matrixCols), ev(1:na), q(1:ldq,1:matrixCols)
189
190
#endif

191
#endif
Andreas Marek's avatar
Andreas Marek committed
192
193
    logical                                :: successFortran

194
#ifdef DOUBLE_PRECISION_REAL
195
196
    successFortran = elpa_solve_evp_real_1stage_double(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
197
                                  useGPU == 1)
198
#else
199
200
    successFortran = elpa_solve_evp_real_1stage_single(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
201
                                  useGPU == 1)
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#endif
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function

#ifdef WANT_SINGLE_PRECISION_REAL
#undef DOUBLE_PRECISION_REAL
  !c>  /*! \brief C interface to solve the single-precision real eigenvalue problem with 1-stage solver
  !c>  *
  !c> *  \param  na                   Order of matrix a
  !c> *  \param  nev                  Number of eigenvalues needed.
  !c> *                               The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                    Distributed matrix for which eigenvalues are to be computed.
  !c> *                               Distribution is like in Scalapack.
  !c> *                               The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                   Leading dimension of a
  !c> *  \param ev(na)                On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                     On output: Eigenvectors of a
  !c> *                               Distribution is like in Scalapack.
  !c> *                               Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                               even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                   Leading dimension of q
  !c> *  \param nblk                  blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols           distributed number of matrix columns
  !c> *  \param mpi_comm_rows        MPI-Communicator for rows
  !c> *  \param mpi_comm_cols        MPI-Communicator for columns
232
  !c> *  \param useGPU               use GPU (1=yes, 0=No)
233
234
235
236
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c>*/
#ifdef DOUBLE_PRECISION_REAL
237
  !c> int elpa_solve_evp_real_1stage_double_precision(int na, int nev, double *a, int lda, double *ev, double *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
238
#else
239
  !c> int elpa_solve_evp_real_1stage_single_precision(int na, int nev, float *a, int lda, float *ev, float *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
240
241
242
243
#endif

#ifdef DOUBLE_PRECISION_REAL
  function solve_elpa1_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk, &
244
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
245
                                  ueGPU)      &
246
247
248
                                  result(success) bind(C,name="elpa_solve_evp_real_1stage_double_precision")
#else
  function solve_elpa1_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk, &
249
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
250
                                  useGPU)      &
251
252
253
254
                                  result(success) bind(C,name="elpa_solve_evp_real_1stage_single_precision")
#endif
    use, intrinsic :: iso_c_binding
    use elpa1
255

256
257
    implicit none
    integer(kind=c_int)                    :: success
258
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, mpi_comm_all
259
    integer(kind=c_int), value, intent(in) :: useGPU
260
261
262
263
264
265
#ifdef DOUBLE_PRECISION_REAL
    real(kind=c_double)                    :: a(1:lda,1:matrixCols), ev(1:na), q(1:ldq,1:matrixCols)
#else
    real(kind=c_float)                     :: a(1:lda,1:matrixCols), ev(1:na), q(1:ldq,1:matrixCols)
#endif
    logical                                :: successFortran
266

267
#ifdef DOUBLE_PRECISION_REAL
268
269
    successFortran = elpa_solve_evp_real_1stage_double(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
270
                                  useGPU == 1)
271
#else
272
273
    successFortran = elpa_solve_evp_real_1stage_single(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
274
                                  useGPU == 1)
275
#endif
Andreas Marek's avatar
Andreas Marek committed
276
277
278
279
280
281
282
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function
283

284
285
#endif /* WANT_SINGLE_PRECISION_REAL */

286

287
288

  !c> /*! \brief C interface to solve the double-precision complex eigenvalue problem with 1-stage solver
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
  !c> *
  !c> *  \param  na                   Order of matrix a
  !c> *  \param  nev                  Number of eigenvalues needed.
  !c> *                               The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                    Distributed matrix for which eigenvalues are to be computed.
  !c> *                               Distribution is like in Scalapack.
  !c> *                               The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                   Leading dimension of a
  !c> *  \param ev(na)                On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                     On output: Eigenvectors of a
  !c> *                               Distribution is like in Scalapack.
  !c> *                               Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                               even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                   Leading dimension of q
  !c> *  \param nblk                  blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols           distributed number of matrix columns
  !c> *  \param mpi_comm_rows        MPI-Communicator for rows
  !c> *  \param mpi_comm_cols        MPI-Communicator for columns
307
  !c> *  \param useGPU               use GPU (1=yes, 0=No)
308
309
310
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
311
#define DOUBLE_PRECISION_COMPLEX 1
312
#ifdef DOUBLE_PRECISION_COMPLEX
313
  !c> int elpa_solve_evp_complex_1stage_double_precision(int na, int nev, double complex *a, int lda, double *ev, double complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
314
#else
315
  !c> int elpa_solve_evp_complex_1stage_single_precision(int na, int nev,  complex *a, int lda, float *ev, complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
316
317
318
#endif

#ifdef DOUBLE_PRECISION_COMPLEX
319
  function solve_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk, &
320
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
321
                                  useGPU)      &
322
323
                                  result(success) bind(C,name="elpa_solve_evp_complex_1stage_double_precision")
#else
324
  function solve_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk, &
325
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
326
                                  useGPU)      &
327
328
                                  result(success) bind(C,name="elpa_solve_evp_complex_1stage_single_precision")
#endif
Andreas Marek's avatar
Andreas Marek committed
329
    use, intrinsic :: iso_c_binding
330
    use elpa1
Andreas Marek's avatar
Andreas Marek committed
331

Andreas Marek's avatar
Andreas Marek committed
332
    implicit none
Andreas Marek's avatar
Andreas Marek committed
333
    integer(kind=c_int)                    :: success
334
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, mpi_comm_all
335
    integer(kind=c_int), value, intent(in) :: useGPU
336
#ifdef DOUBLE_PRECISION_COMPLEX
Andreas Marek's avatar
Andreas Marek committed
337
    real(kind=c_double)                    :: ev(1:na)
338
#ifdef USE_ASSUMED_SIZE
339
    complex(kind=c_double_complex)         :: a(lda,*), q(ldq,*)
340
#else
341
    complex(kind=c_double_complex)         :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
342
#endif
343
344

#else /* SINGLE_PRECISION */
345
    real(kind=c_float)                     :: ev(1:na)
346
#ifdef USE_ASSUMED_SIZE
347
348
349
350
351
    complex(kind=c_float_complex)          :: a(lda,*), q(ldq,*)
#else
    complex(kind=c_float_complex)          :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif

352
#endif
Andreas Marek's avatar
Andreas Marek committed
353
354
355

    logical                                :: successFortran

356
#ifdef DOUBLE_PRECISION_COMPLEX
357
358
    successFortran = elpa_solve_evp_complex_1stage_double(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
359
                                  useGPU == 1)
360
#else
361
362
    successFortran = elpa_solve_evp_complex_1stage_single(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
363
                                  useGPU == 1)
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
#endif
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function

#ifdef WANT_SINGLE_PRECISION_COMPLEX

  !c> /*! \brief C interface to solve the single-precision complex eigenvalue problem with 1-stage solver
  !c> *
  !c> *  \param  na                   Order of matrix a
  !c> *  \param  nev                  Number of eigenvalues needed.
  !c> *                               The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                    Distributed matrix for which eigenvalues are to be computed.
  !c> *                               Distribution is like in Scalapack.
  !c> *                               The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                   Leading dimension of a
  !c> *  \param ev(na)                On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                     On output: Eigenvectors of a
  !c> *                               Distribution is like in Scalapack.
  !c> *                               Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                               even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                   Leading dimension of q
  !c> *  \param nblk                  blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols           distributed number of matrix columns
  !c> *  \param mpi_comm_rows        MPI-Communicator for rows
  !c> *  \param mpi_comm_cols        MPI-Communicator for columns
394
  !c> *  \param useGPU               use GPU (1=yes, 0=No)
395
396
397
398
399
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
#undef DOUBLE_PRECISION_COMPLEX
#ifdef DOUBLE_PRECISION_COMPLEX
400
  !c> int elpa_solve_evp_complex_1stage_double_precision(int na, int nev, double complex *a, int lda, double *ev, double complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
401
#else
402
  !c> int elpa_solve_evp_complex_1stage_single_precision(int na, int nev,  complex *a, int lda, float *ev, complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int useGPU);
403
404
405
406
#endif

#ifdef DOUBLE_PRECISION_COMPLEX
  function solve_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk, &
407
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
408
                                  useGPU)      &
409
410
411
                                  result(success) bind(C,name="elpa_solve_evp_complex_1stage_double_precision")
#else
  function solve_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk, &
412
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
413
                                  useGPU)      &
414
415
416
417
418
419
420
                                  result(success) bind(C,name="elpa_solve_evp_complex_1stage_single_precision")
#endif
    use, intrinsic :: iso_c_binding
    use elpa1

    implicit none
    integer(kind=c_int)                    :: success
421
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, mpi_comm_all
422
    integer(kind=c_int), value, intent(in) :: useGPU
423
424
425
426
427
428
429
430
431
#ifdef DOUBLE_PRECISION_COMPLEX
    complex(kind=c_double_complex)         :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
    real(kind=c_double)                    :: ev(1:na)
#else
    complex(kind=c_float_complex)          :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
    real(kind=c_float)                     :: ev(1:na)
#endif

    logical                                :: successFortran
Andreas Marek's avatar
Andreas Marek committed
432

433
#ifdef DOUBLE_PRECISION_COMPLEX
434
435
    successFortran = elpa_solve_evp_complex_1stage_double(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
436
                                  useGPU == 1)
437
#else
438
439
    successFortran = elpa_solve_evp_complex_1stage_single(na, nev, a, lda, ev, q, ldq, nblk, &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,  &
440
                                  useGPU == 1)
441
#endif
Andreas Marek's avatar
Andreas Marek committed
442
443
444
445
446
447
448
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function
449
450
451
452
453

#endif /* WANT_SINGLE_PRECISION_COMPLEX */


  !c> /*! \brief C interface to solve the double-precision real eigenvalue problem with 2-stage solver
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
  !c> *  \param THIS_REAL_ELPA_KERNEL_API  specify used ELPA2 kernel via API
474
475
  !c> *  \param useQR                      use QR decomposition 1 = yes, 0 = no
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
476
477
478
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
479
#define DOUBLE_PRECISION_REAL 1
480
#ifdef DOUBLE_PRECISION_REAL
481
  !c> int elpa_solve_evp_real_2stage_double_precision(int na, int nev, double *a, int lda, double *ev, double *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU);
482
#else
483
  !c> int elpa_solve_evp_real_2stage_single_precision(int na, int nev, float *a, int lda, float *ev, float *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU);
484
485
#endif

486
#ifdef DOUBLE_PRECISION_REAL
487
  function solve_elpa2_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,         &
488
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
489
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU)    &
490
491
                                  result(success) bind(C,name="elpa_solve_evp_real_2stage_double_precision")
#else
492
  function solve_elpa2_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk,         &
493
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
494
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU)    &
495
496
                                  result(success) bind(C,name="elpa_solve_evp_real_2stage_double_precision")

497
498
                                  result(success) bind(C,name="elpa_solve_evp_real_2stage_single_precision")
#endif
Andreas Marek's avatar
Andreas Marek committed
499
    use, intrinsic :: iso_c_binding
500
    use elpa2
Andreas Marek's avatar
Andreas Marek committed
501

Andreas Marek's avatar
Andreas Marek committed
502
    implicit none
Andreas Marek's avatar
Andreas Marek committed
503
    integer(kind=c_int)                    :: success
504
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
Andreas Marek's avatar
Andreas Marek committed
505
                                              mpi_comm_all
506
    integer(kind=c_int), value, intent(in) :: THIS_REAL_ELPA_KERNEL_API, useQR, useGPU
507
#ifdef DOUBLE_PRECISION_REAL
508
    real(kind=c_double)                    :: ev(1:na)
509
510
#ifdef USE_ASSUMED_SIZE
    real(kind=c_double)                    :: a(lda,*), q(ldq,*)
511
#else
512
513
    real(kind=c_double)                    :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif
514
515
516
517

#else /* SINGLE_PRECISION */

    real(kind=c_float)                     :: ev(1:na)
518
#ifdef USE_ASSUMED_SIZE
519
520
521
522
523
    real(kind=c_float)                     :: a(1:lda,*), q(1:ldq,*)
#else
    real(kind=c_float)                     :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif

524
#endif
Andreas Marek's avatar
Andreas Marek committed
525
526
527
528
529
530
531
532
533

    logical                                :: successFortran, useQRFortran

    if (useQR .eq. 0) then
      useQRFortran =.false.
    else
      useQRFortran = .true.
    endif

534
#ifdef DOUBLE_PRECISION_REAL
535
536
537
      successFortran = elpa_solve_evp_real_2stage_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                                         mpi_comm_cols, mpi_comm_all,                                  &
                                                         THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
538
#else
539
540
541
      successFortran = elpa_solve_evp_real_2stage_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                                         mpi_comm_cols, mpi_comm_all,                                  &
                                                         THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
542
#endif
543

544
545
546
547
548
    if (successFortran) then
      success = 1
    else
      success = 0
    endif
Andreas Marek's avatar
Andreas Marek committed
549

550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
  end function

#ifdef WANT_SINGLE_PRECISION_REAL

  !c> /*! \brief C interface to solve the single-precision real eigenvalue problem with 2-stage solver
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
  !c> *  \param THIS_REAL_ELPA_KERNEL_API  specify used ELPA2 kernel via API
575
576
  !c> *  \param useQR                      use QR decomposition 1 = yes, 0 = no
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
577
578
579
580
581
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
#undef DOUBLE_PRECISION_REAL
#ifdef DOUBLE_PRECISION_REAL
582
  !c> int elpa_solve_evp_real_2stage_double_precision(int na, int nev, double *a, int lda, double *ev, double *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU);
583
#else
584
  !c> int elpa_solve_evp_real_2stage_single_precision(int na, int nev, float *a, int lda, float *ev, float *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU);
585
586
587
#endif

#ifdef DOUBLE_PRECISION_REAL
588
  function solve_elpa2_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,         &
589
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
590
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU)    &
591
592
                                  result(success) bind(C,name="elpa_solve_evp_real_2stage_double_precision")
#else
593
  function solve_elpa2_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk,         &
594
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
595
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU)    &
596
597
598
599
600
601
602
603
604
                                  result(success) bind(C,name="elpa_solve_evp_real_2stage_single_precision")
#endif
    use, intrinsic :: iso_c_binding
    use elpa2

    implicit none
    integer(kind=c_int)                    :: success
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
                                              mpi_comm_all
605
    integer(kind=c_int), value, intent(in) :: THIS_REAL_ELPA_KERNEL_API, useQR, useGPU
606
#ifdef DOUBLE_PRECISION_REAL
607
    real(kind=c_double)                    ::  ev(1:na)
608
#ifdef USE_ASSUMED_SIZE
609
    real(kind=c_double)                    :: a(1:lda,*), q(1:ldq,*)
610
#else
611
612
    real(kind=c_double)                    :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif
Andreas Marek's avatar
Andreas Marek committed
613

614
615
616
#else /* SINGLE_PRECISION */

    real(kind=c_float)                     :: ev(1:na)
617
#ifdef USE_ASSUMED_SIZE
618
619
620
    real(kind=c_float)                     :: a(1:lda,*), q(1:ldq,*)
#else
    real(kind=c_float)                     :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
621
622
#endif

623
#endif
624
625
626
627
628
629
630
631
632
    logical                                :: successFortran, useQRFortran

    if (useQR .eq. 0) then
      useQRFortran =.false.
    else
      useQRFortran = .true.
    endif

#ifdef DOUBLE_PRECISION_REAL
633
634
635
      successFortran = elpa_solve_evp_real_2stage_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                                         mpi_comm_cols, mpi_comm_all,                                  &
                                                         THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
636
#else
637
638
639
      successFortran = elpa_solve_evp_real_2stage_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                                         mpi_comm_cols, mpi_comm_all,                                  &
                                                         THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
640
#endif
Andreas Marek's avatar
Andreas Marek committed
641
642
643
644
645
646
647
648
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function

649
#endif /* WANT_SINGLE_PRECISION_REAL */
650

651
  !c> /*! \brief C interface to solve the double-precision complex eigenvalue problem with 2-stage solver
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
671
  !c> *  \param THIS_COMPLEX_ELPA_KERNEL_API  specify used ELPA2 kernel via API
672
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
673
674
675
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
676
677
#define DOUBLE_PRECISION_COMPLEX 1

678
#ifdef DOUBLE_PRECISION_COMPLEX
679
  !c> int elpa_solve_evp_complex_2stage_double_precision(int na, int nev, double complex *a, int lda, double *ev, double complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_COMPLEX_ELPA_KERNEL_API, int useGPU);
680
#else
681
  !c> int elpa_solve_evp_complex_2stage_single_precision(int na, int nev, complex *a, int lda, float *ev, complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_COMPLEX_ELPA_KERNEL_API, int useGPU);
682
#endif
683
684

#ifdef DOUBLE_PRECISION_COMPLEX
685
  function solve_elpa2_evp_complex_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,         &
686
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,    &
687
                                  THIS_COMPLEX_ELPA_KERNEL_API, useGPU)           &
688
689
                                  result(success) bind(C,name="elpa_solve_evp_complex_2stage_double_precision")
#else
690
  function solve_elpa2_evp_complex_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk,         &
691
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,    &
692
                                  THIS_COMPLEX_ELPA_KERNEL_API, useGPU)           &
693
694
                                  result(success) bind(C,name="elpa_solve_evp_complex_2stage_single_precision")
#endif
Andreas Marek's avatar
Andreas Marek committed
695
696

    use, intrinsic :: iso_c_binding
697
    use elpa2
Andreas Marek's avatar
Andreas Marek committed
698

Andreas Marek's avatar
Andreas Marek committed
699
    implicit none
Andreas Marek's avatar
Andreas Marek committed
700
    integer(kind=c_int)                    :: success
701
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
Andreas Marek's avatar
Andreas Marek committed
702
                                              mpi_comm_all
703
    integer(kind=c_int), value, intent(in) :: THIS_COMPLEX_ELPA_KERNEL_API, useGPU
704
#ifdef DOUBLE_PRECISION_COMPLEX
Andreas Marek's avatar
Andreas Marek committed
705
    real(kind=c_double)                    :: ev(1:na)
706
#ifdef USE_ASSUMED_SIZE
707
    complex(kind=c_double_complex)         :: a(lda,*), q(ldq,*)
708
#else
709
    complex(kind=c_double_complex)         :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
710
#endif
711
712

#else /* SINGLE_PRECISION */
713
    real(kind=c_float)                     :: ev(1:na)
714
#ifdef USE_ASSUMED_SIZE
715
716
717
718
719
    complex(kind=c_float_complex)          ::  a(lda,*), q(ldq,*)
#else
    complex(kind=c_float_complex)          :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif

720
#endif
Andreas Marek's avatar
Andreas Marek committed
721
722
    logical                                :: successFortran

723
724
725

      ! matrix is not banded

726
#ifdef DOUBLE_PRECISION_COMPLEX
727
728
729
      successFortran = elpa_solve_evp_complex_2stage_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, &
                                                            mpi_comm_rows, mpi_comm_cols, &
                                                            mpi_comm_all, THIS_COMPLEX_ELPA_KERNEL_API, useGPU == 1)
730
#else
731
732
733
      successFortran = elpa_solve_evp_complex_2stage_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, &
                                                            mpi_comm_rows, mpi_comm_cols, &
                                                            mpi_comm_all, THIS_COMPLEX_ELPA_KERNEL_API, useGPU == 1)
734
#endif
735

736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function

#ifdef WANT_SINGLE_PRECISION_COMPLEX

  !c> /*! \brief C interface to solve the single-precision complex eigenvalue problem with 2-stage solver
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
  !c> *  \param THIS_REAL_ELPA_KERNEL_API  specify used ELPA2 kernel via API
767
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
768
769
770
771
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
#undef DOUBLE_PRECISION_COMPLEX
Andreas Marek's avatar
Andreas Marek committed
772

773
#ifdef DOUBLE_PRECISION_COMPLEX
774
  !c> int elpa_solve_evp_complex_2stage_double_precision(int na, int nev, double complex *a, int lda, double *ev, double complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_COMPLEX_ELPA_KERNEL_API, int useGPU);
775
#else
776
  !c> int elpa_solve_evp_complex_2stage_single_precision(int na, int nev, complex *a, int lda, float *ev, complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_COMPLEX_ELPA_KERNEL_API, int useGPU);
777
778
779
#endif

#ifdef DOUBLE_PRECISION_COMPLEX
780
  function solve_elpa2_evp_complex_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,         &
781
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,    &
782
                                  THIS_COMPLEX_ELPA_KERNEL_API, useGPU)           &
783
784
                                  result(success) bind(C,name="elpa_solve_evp_complex_2stage_double_precision")
#else
785
  function solve_elpa2_evp_complex_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk,         &
786
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,    &
787
                                  THIS_COMPLEX_ELPA_KERNEL_API, useGPU)           &
788
789
790
791
792
793
794
795
796
797
                                  result(success) bind(C,name="elpa_solve_evp_complex_2stage_single_precision")
#endif

    use, intrinsic :: iso_c_binding
    use elpa2

    implicit none
    integer(kind=c_int)                    :: success
    integer(kind=c_int), value, intent(in) :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
                                              mpi_comm_all
798
    integer(kind=c_int), value, intent(in) :: THIS_COMPLEX_ELPA_KERNEL_API, useGPU
799
800
801
802
803
804
805
806
807
#ifdef DOUBLE_PRECISION_COMPLEX
    complex(kind=c_double_complex)         :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
    real(kind=c_double)                    :: ev(1:na)
#else
    complex(kind=c_float_complex)          :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
    real(kind=c_float)                     :: ev(1:na)
#endif
    logical                                :: successFortran

808

809
#ifdef DOUBLE_PRECISION_COMPLEX
810
811
812
      successFortran = elpa_solve_evp_complex_2stage_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, &
                                                            mpi_comm_rows, mpi_comm_cols, &
                                                            mpi_comm_all, THIS_COMPLEX_ELPA_KERNEL_API, useGPU == 1)
813
#else
814
815
816
817
818
      successFortran = elpa_solve_evp_complex_2stage_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, &
                                                            mpi_comm_rows, mpi_comm_cols, &
                                                            mpi_comm_all, THIS_COMPLEX_ELPA_KERNEL_API, useGPU == 1)
#endif

Andreas Marek's avatar
Andreas Marek committed
819
820
821
822
823
824
825
    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
#endif /* WANT_SINGLE_PRECISION_COMPLEX */

  !c> /*! \brief C interface to driver function "elpa_solve_evp_real_double"
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
  !c> *  \param THIS_REAL_ELPA_KERNEL_API  specify used ELPA2 kernel via API
849
850
851
852
  !c> *  \param useQR                      use QR decomposition 1 = yes, 0 = no
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
  !c> *  \param method                     choose whether to use ELPA 1stage or 2stage solver
  !c> *                                    possible values: "1stage" => use ELPA 1stage solver
853
854
855
856
857
  !c> *                                                      "2stage" => use ELPA 2stage solver
  !c> *                                                       "auto"   => (at the moment) use ELPA 2stage solver
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
858
  !c> int elpa_solve_evp_real_double(int na, int nev, double *a, int lda, double *ev, double *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU, char *method);
859
860
  function elpa_solve_evp_real_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,    &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
861
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU, method)           &
862
863
864
865
866
867
868
869
870
                                  result(success) bind(C,name="elpa_solve_evp_real_double")

    use, intrinsic :: iso_c_binding
    use elpa, only : elpa_solve_evp_real_double

    implicit none
    integer(kind=c_int)                      :: success
    integer(kind=c_int), value, intent(in)   :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
                                                mpi_comm_all
871
    integer(kind=c_int), value, intent(in)   :: THIS_REAL_ELPA_KERNEL_API, useQR, useGPU
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
    real(kind=c_double)                      :: ev(1:na)
#ifdef USE_ASSUMED_SIZE
    real(kind=c_double)                      :: a(lda,*), q(ldq,*)
#else
    real(kind=c_double)                      :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif
    logical                                  :: successFortran, useQRFortran
    character(kind=c_char,len=1), intent(in) :: method(*)
    character(len=6)                         :: methodFortran
    integer(kind=c_int)                      :: charCount

    if (useQR .eq. 0) then
      useQRFortran =.false.
    else
      useQRFortran = .true.
    endif

    charCount = 1
    do
      if (method(charCount) == c_null_char) exit
      charCount = charCount + 1
    enddo
    charCount = charCount - 1

    if (charCount .ge. 1)  then
      methodFortran(1:charCount) = transfer(method(1:charCount), methodFortran)

      successFortran = elpa_solve_evp_real_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                           mpi_comm_cols, mpi_comm_all,                                  &
901
                                           THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1, methodFortran)
902
903
904
    else
      successFortran = elpa_solve_evp_real_double(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                           mpi_comm_cols, mpi_comm_all,                                  &
905
                                           THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
906
907
908
909
910
911
912
913
914
    endif

    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function
Andreas Marek's avatar
Andreas Marek committed
915

916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
#ifdef WANT_SINGLE_PRECISION_REAL
  !c> /*! \brief C interface to driver function "elpa_solve_evp_real_single"
  !c> *
  !c> *  \param  na                        Order of matrix a
  !c> *  \param  nev                       Number of eigenvalues needed.
  !c> *                                    The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                         Distributed matrix for which eigenvalues are to be computed.
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                        Leading dimension of a
  !c> *  \param ev(na)                     On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                          On output: Eigenvectors of a
  !c> *                                    Distribution is like in Scalapack.
  !c> *                                    Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                    even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                        Leading dimension of q
  !c> *  \param nblk                       blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                 distributed number of matrix columns
  !c> *  \param mpi_comm_rows              MPI-Communicator for rows
  !c> *  \param mpi_comm_cols              MPI-Communicator for columns
  !c> *  \param mpi_coll_all               MPI communicator for the total processor set
  !c> *  \param THIS_REAL_ELPA_KERNEL_API  specify used ELPA2 kernel via API
938
939
940
941
  !c> *  \param useQR                      use QR decomposition 1 = yes, 0 = no
  !c> *  \param useGPU                     use GPU (1=yes, 0=No)
  !c> *  \param method                     choose whether to use ELPA 1stage or 2stage solver
  !c> *                                    possible values: "1stage" => use ELPA 1stage solver
942
943
944
945
946
  !c> *                                                      "2stage" => use ELPA 2stage solver
  !c> *                                                       "auto"   => (at the moment) use ELPA 2stage solver
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
947
  !c> int elpa_solve_evp_real_single(int na, int nev, float *a, int lda, float *ev, float *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_REAL_ELPA_KERNEL_API, int useQR, int useGPU, char *method);
948
949
  function elpa_solve_evp_real_wrapper_single(na, nev, a, lda, ev, q, ldq, nblk,    &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all, &
950
                                  THIS_REAL_ELPA_KERNEL_API, useQR, useGPU, method)           &
951
952
953
954
955
956
957
958
959
                                  result(success) bind(C,name="elpa_solve_evp_real_single")

    use, intrinsic :: iso_c_binding
    use elpa, only : elpa_solve_evp_real_single

    implicit none
    integer(kind=c_int)                      :: success
    integer(kind=c_int), value, intent(in)   :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
                                                mpi_comm_all
960
    integer(kind=c_int), value, intent(in)   :: THIS_REAL_ELPA_KERNEL_API, useQR, useGPU
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
    real(kind=c_float)                       :: ev(1:na)
#ifdef USE_ASSUMED_SIZE
    real(kind=c_float)                       :: a(lda,*), q(ldq,*)
#else
    real(kind=c_float)                       :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif
    logical                                  :: successFortran, useQRFortran
    character(kind=c_char,len=1), intent(in) :: method(*)
    character(len=6)                         :: methodFortran
    integer(kind=c_int)                      :: charCount

    if (useQR .eq. 0) then
      useQRFortran =.false.
    else
      useQRFortran = .true.
    endif

    charCount = 1
    do
      if (method(charCount) == c_null_char) exit
      charCount = charCount + 1
    enddo
    charCount = charCount - 1

    if (charCount .ge. 1)  then
      methodFortran(1:charCount) = transfer(method(1:charCount), methodFortran)

      successFortran = elpa_solve_evp_real_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                           mpi_comm_cols, mpi_comm_all,                                  &
990
                                           THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1, methodFortran)
991
992
993
    else
      successFortran = elpa_solve_evp_real_single(na, nev, a, lda, ev, q, ldq, nblk, matrixCols, mpi_comm_rows, &
                                           mpi_comm_cols, mpi_comm_all,                                  &
994
                                           THIS_REAL_ELPA_KERNEL_API, useQRFortran, useGPU == 1)
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
    endif

    if (successFortran) then
      success = 1
    else
      success = 0
    endif

  end function
#endif /* WANT_SINGLE_PRECISION_REAL */

  !c> /*! \brief C interface to driver function "elpa_solve_evp_complex_double"
  !c> *
  !c> *  \param  na                           Order of matrix a
  !c> *  \param  nev                          Number of eigenvalues needed.
  !c> *                                       The smallest nev eigenvalues/eigenvectors are calculated.
  !c> *  \param  a                            Distributed matrix for which eigenvalues are to be computed.
  !c> *                                       Distribution is like in Scalapack.
  !c> *                                       The full matrix must be set (not only one half like in scalapack).
  !c> *  \param lda                           Leading dimension of a
  !c> *  \param ev(na)                        On output: eigenvalues of a, every processor gets the complete set
  !c> *  \param q                             On output: Eigenvectors of a
  !c> *                                       Distribution is like in Scalapack.
  !c> *                                       Must be always dimensioned to the full size (corresponding to (na,na))
  !c> *                                       even if only a part of the eigenvalues is needed.
  !c> *  \param ldq                           Leading dimension of q
  !c> *  \param nblk                          blocksize of cyclic distribution, must be the same in both directions!
  !c> *  \param matrixCols                    distributed number of matrix columns
  !c> *  \param mpi_comm_rows                 MPI-Communicator for rows
  !c> *  \param mpi_comm_cols                 MPI-Communicator for columns
  !c> *  \param mpi_coll_all                  MPI communicator for the total processor set
  !c> *  \param THIS_COMPLEX_ELPA_KERNEL_API  specify used ELPA2 kernel via API
1027
  !c> *  \param useGPU                        use GPU (1=yes, 0=No)
1028
1029
1030
1031
1032
1033
1034
  !c> *  \param method                        choose whether to use ELPA 1stage or 2stage solver
  !c> *                                       possible values: "1stage" => use ELPA 1stage solver
  !c> *                                                        "2stage" => use ELPA 2stage solver
  !c> *                                                         "auto"   => (at the moment) use ELPA 2stage solver
  !c> *
  !c> *  \result                     int: 1 if error occured, otherwise 0
  !c> */
1035
  !c> int elpa_solve_evp_complex_double(int na, int nev, double complex *a, int lda, double *ev, double complex *q, int ldq, int nblk, int matrixCols, int mpi_comm_rows, int mpi_comm_cols, int mpi_comm_all, int THIS_COMPLEX_ELPA_KERNEL_API, int useGPU, char *method);
1036
1037
  function elpa_solve_evp_complex_wrapper_double(na, nev, a, lda, ev, q, ldq, nblk,    &
                                  matrixCols, mpi_comm_rows, mpi_comm_cols, mpi_comm_all,    &
1038
                                  THIS_COMPLEX_ELPA_KERNEL_API, useGPU, method)                  &
1039
1040
1041
1042
1043
1044
1045
1046
1047
                                  result(success) bind(C,name="elpa_solve_evp_complex_double")

    use, intrinsic :: iso_c_binding
    use elpa, only : elpa_solve_evp_complex_double

    implicit none
    integer(kind=c_int)                      :: success
    integer(kind=c_int), value, intent(in)   :: na, nev, lda, ldq, nblk, matrixCols, mpi_comm_cols, mpi_comm_rows, &
                                                mpi_comm_all
1048
    integer(kind=c_int), value, intent(in)   :: THIS_COMPLEX_ELPA_KERNEL_API, useGPU
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
#ifdef USE_ASSUMED_SIZE
    complex(kind=c_double_complex)           :: a(lda,*), q(ldq,*)
#else
    complex(kind=c_double_complex)           :: a(1:lda,1:matrixCols), q(1:ldq,1:matrixCols)
#endif
    real(kind=c_double)                      :: ev(1:na)
    character(kind=c_char,len=1), intent(in) :: method(*)
    character(len=6)                         :: methodFortran
    integer(kind=c_int)                      :: charCount

    logical                                  :: successFortran


    charCount = 1
    do
      if (method(charCount) == c_null_char) exit
      charCount = charCount + 1
    enddo
    charCount = charCount - 1

    if (charCount .ge. 1)  then
      methodFortran(1:charCount) = transfer(method(1:charCount), methodFortran)
      successFortran = elpa_solve_evp_complex_double(na, nev, a, lda, ev, q, ldq, nblk,