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

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.c.

References DefineList::CDataFileHead, cFileNamePhys_FullDiag_Ham, BindStruct::Check, childfopenMPI(), D_FileNameMax, BindStruct::Def, fgetsMPI(), Ham, CheckList::idim_max, and stdoutMPI.

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 
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  Ham[ham_i][ham_j]=dHam_re+I*dHam_im;
53  Ham[ham_j][ham_i]=conj(Ham[ham_i][ham_j]);
54  }
55  fclose(fp);
56  return 0;
57 }
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
double complex ** Ham
Definition: global.h:73
const char * cFileNamePhys_FullDiag_Ham
Definition: global.c:78
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.c:122
struct CheckList Check
Size of the Hilbert space.
Definition: struct.h:411
char * CDataFileHead
Read from Calcmod in readdef.h. Header of output file such as Green&#39;s function.
Definition: struct.h:42
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: