HΦ  3.2.0
lapack_diag.c File Reference
#include "lapack_diag.h"
#include "matrixlapack.h"
#include "FileIO.h"
+ Include dependency graph for lapack_diag.c:

Go to the source code of this file.

Functions

int lapack_diag (struct BindStruct *X)
 performing full diagonalization using lapack More...
 

Function Documentation

◆ lapack_diag()

int lapack_diag ( struct BindStruct X)

performing full diagonalization using lapack

Parameters
[in,out]X
Author
Takahiro Misawa (The University of Tokyo)
Kazuyoshi Yoshimi (The University of Tokyo)
Returns
Parameters
[in,out]X

Definition at line 35 of file lapack_diag.c.

References cFileNameEigenvalue_Lanczos, BindStruct::Check, childfopenMPI(), D_FileNameMax, BindStruct::Def, Ham, CheckList::idim_max, DefineList::iNGPU, L_vec, myrank, nproc, stdoutMPI, v0, and ZHEEVall().

Referenced by CalcByFullDiag(), and CalcSpectrumByFullDiag().

37  {
38 
39  FILE *fp;
40  char sdt[D_FileNameMax] = "";
41  long int i, j, i_max, xMsize;
42 #ifdef _SCALAPACK
43  int rank, size, nprocs, nprow, npcol, myrow, mycol, ictxt;
44  int i_negone=-1, i_zero=0, iam;
45  long int mb, nb, mp, nq;
46  int dims[2]={0,0};
47 #endif
48 
49  i_max = X->Check.idim_max;
50 
51  for (i = 0; i < i_max; i++) {
52  for (j = 0; j < i_max; j++) {
53  //printf("Ham %f %f ", creal(Ham[i+1][j+1]), cimag(Ham[i+1][j+1]));
54  Ham[i][j] = Ham[i + 1][j + 1];
55  }
56  }
57  xMsize = i_max;
58  /*for(i=0; i<xMsize; i++){
59  for(j=0; j<xMsize; j++){
60  printf("Ham %f %f ", creal(Ham[i][j]), cimag(Ham[i][j]));
61  }
62  }*/
63  if (X->Def.iNGPU == 0) {
64 #ifdef _SCALAPACK
65  if(nproc >1) {
66  fprintf(stdoutMPI, "Using SCALAPACK\n\n");
67  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
68  MPI_Comm_size(MPI_COMM_WORLD, &size);
69  MPI_Dims_create(size,2,dims);
70  nprow=dims[0]; npcol=dims[1];
71 
72  blacs_pinfo_(&iam, &nprocs);
73  blacs_get_(&i_negone, &i_zero, &ictxt);
74  blacs_gridinit_(&ictxt, "R", &nprow, &npcol);
75  blacs_gridinfo_(&ictxt, &nprow, &npcol, &myrow, &mycol);
76 
77  mb = GetBlockSize(xMsize, size);
78 
79  mp = numroc_(&xMsize, &mb, &myrow, &i_zero, &nprow);
80  nq = numroc_(&xMsize, &mb, &mycol, &i_zero, &npcol);
81  Z_vec = malloc(mp*nq*sizeof(complex double));
82  //printf("xMsize %d\n", xMsize);
83  /*if(rank == 0){
84  for(i=0; i<xMsize; i++){
85  for(j=0; j<xMsize; j++){
86  printf("Ham %f %f ", creal(Ham[i][j]), cimag(Ham[i][j]));
87  }
88  }
89  }*/
90  diag_scalapack_cmp(xMsize, Ham, v0, Z_vec, descZ_vec);
91  //printf("Z %f %f\n", creal(Z_vec[0]), cimag(Z_vec[1]));
92  } else {
93  ZHEEVall(xMsize, Ham, v0, L_vec);
94  }
95 #else
96  ZHEEVall(xMsize, Ham, v0, L_vec);
97 #endif
98  } else {
99 #ifdef _MAGMA
100  if(myrank==0){
101  if(diag_magma_cmp(xMsize, Ham, v0, L_vec, X->Def.iNGPU) != 0) {
102  return -1;
103  }
104  }
105 #else
106  fprintf(stdoutMPI, "Warning: MAGMA is not used in this calculation.");
107  ZHEEVall(xMsize, Ham, v0, L_vec);
108 #endif
109  }
110 
111  /*for (i = 0; i < i_max; i++) {
112  for (j = 0; j < i_max; j++) {
113  fprintf(stdoutMPI, "%f %f \n", creal(L_vec[i][j]), cimag(L_vec[i][j]));
114  }
115  }*/
116 
117  strcpy(sdt, cFileNameEigenvalue_Lanczos);
118  if (childfopenMPI(sdt, "w", &fp) != 0) {
119  return -1;
120  }
121  for (i = 0; i < i_max; i++) {
122  fprintf(fp, " %ld %.10lf \n", i, creal(v0[i]));
123  }
124  fclose(fp);
125 
126 
127  return 0;
128 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.h:410
unsigned long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.h:303
#define D_FileNameMax
Definition: global.h:23
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.c:27
int iNGPU
GPU mode ( only for FullDiag )
Definition: struct.h:230
int ZHEEVall(int xNsize, double complex **A, double complex *r, double complex **vec)
obtain eigenvalues and eigenvectors of Hermite matrix A
Definition: matrixlapack.c:374
int nproc
Number of processors, defined in InitializeMPI()
Definition: global.h:162
double complex ** Ham
Definition: global.h:73
double complex ** L_vec
Definition: global.h:74
const char * cFileNameEigenvalue_Lanczos
Definition: global.c:41
int myrank
Process ID, defined in InitializeMPI()
Definition: global.h:163
double complex * v0
Definition: global.h:34
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.h:165
+ Here is the call graph for this function:
+ Here is the caller graph for this function: