HPhi++  3.1.0
input.cpp File Reference
#include "input.hpp"
#include "FileIO.hpp"
#include "wrapperMPI.hpp"

Go to the source code of this file.

Functions

int inputHam (struct BindStruct *X)
 

Function Documentation

◆ inputHam()

int inputHam ( struct BindStruct X)

Definition at line 20 of file input.cpp.

References DefineList::CDataFileHead, BindStruct::Check, childfopenMPI(), BindStruct::Def, fgetsMPI(), I(), CheckList::idim_max, stdoutMPI, and v0.

Referenced by CalcByFullDiag().

20  {
21  //Input Ham
22  long int i=0;
23  long int ham_i=0;
24  long int ham_j=0;
25  long int imax = X->Check.idim_max;
26  long int ihermite=0;
27  long int itmp;
28  double dHam_re, dHam_im;
29  char ctmp[256], ctmp2[256];
30 
31  FILE *fp;
32  char sdt[D_FileNameMax];
33 
34  sprintf(sdt,"%s_Ham.dat", X->Def.CDataFileHead);
35  if(childfopenMPI(sdt,"r",&fp)!=0){
36  return -1;
37  }
38 
39  //skip: header
40  fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp);
41  //skip: read imax, imax, ihermite
42  fgetsMPI(ctmp, sizeof(ctmp) / sizeof(char), fp);
43  sscanf(ctmp, "%ld %ld %ld\n", &itmp, &itmp, &ihermite);
44  if(itmp != imax){
45  fprintf(stdoutMPI, "Error: The dimension of input Hamiltonian is wrong: input=%ld, idim=%ld.\n", itmp, imax);
46  return -1;
47  }
48  for(i=1; i<= ihermite; i++){
49  fgetsMPI(ctmp2, sizeof(ctmp2) / sizeof(char), fp);
50  sscanf(ctmp2, "%ld %ld %lf %lf\n",
51  &ham_i, &ham_j, &dHam_re, &dHam_im);
52  v0[ham_i][ham_j]=dHam_re+I*dHam_im;
53  v0[ham_j][ham_i]=conj(v0[ham_i][ham_j]);
54  }
55  fclose(fp);
56  return 0;
57 }
struct DefineList Def
Definision of system (Hamiltonian) etc.
Definition: struct.hpp:395
FILE * stdoutMPI
File pointer to the standard output defined in InitializeMPI()
Definition: global.cpp:75
std::complex< double > ** v0
Definition: global.cpp:20
std::complex< double > I(0.0, 1.0)
char * fgetsMPI(char *InputString, int maxcount, FILE *fp)
MPI file I/O (get a line, fgets) wrapper. Only the root node (myrank = 0) reads and broadcast string...
Definition: wrapperMPI.cpp:122
struct CheckList Check
Size of the Hilbert space.
Definition: struct.hpp:396
char * CDataFileHead
Read from Calcmod in readdef.h. Header of output file such as Green&#39;s function.
Definition: struct.hpp:42
long int idim_max
The dimension of the Hilbert space of this process.
Definition: struct.hpp:305
int childfopenMPI(const char *_cPathChild, const char *_cmode, FILE **_fp)
Only the root process open file in output/ directory.
Definition: FileIO.cpp:27