Пример #1
0
int main() {
    std::vector <double> result;
    double A;
    double B;
    double C;
    initscr();
    noecho();
    clear();
    printw("input A \n");
    refresh();
    do {
        clear();
        refresh();
        printw("input A \n");
        refresh();
        A = input_double();
        printw("input B \n");    
        refresh();
        B = input_double();
        printw("input C \n");    
        refresh();
        C = input_double();
    
        if (A == 0) { //handling A = 0
            printw("A = 0");
            refresh();
            continue;
        }

        result = hard_solve(A, B, C);
        if (result[0] == 0) {
            printw("no solutions");
            refresh();
        }

        if (result[0] == 1) {
            printw("%f", result[1]);
            refresh();
        }

        if (result[0] == 2) {
            printw("%f", result[1]);
            printw(", ");
            printw("%f", result[2]);
            refresh();
        } 

        printw("\n");
        printw("press any key to continue");
        printw("\n");
        printw("press ESC key to quit");
        refresh();
    } while (getchar() != 27);
    endwin();
}
Пример #2
0
void Name_pairs::read_ages()
{
	//check
	if (name.size() <= 0){
		throw std::runtime_error("unable to read ages");
	}
	std::cout << "Below you should input " << name.size() << " ages." << std::endl;
	//clear
	age.clear();
	//read ages
	for (size_t i = 0; i < name.size(); ++i){
		std::cout << "Input age for " << name[i] << " :" << std::endl;
		double tmp = 0;
		while (true){
			tmp = input_double();
			if (tmp > 0){
				break;
			}
			std::cout << "invalid age. Try again." << std::endl;
		}
		age.push_back(tmp);
	}
}
Пример #3
0
void Runtest(char *mode, int argc, char *argv[]) 
{
  FILE *fp,*fp0,*fp1,*fp2,*fp3;
  int Num_DatFiles,i,j,k,fp_OK;
  int Num_Atoms;
  int NGrid1_1,NGrid1_2,NGrid1_3;
  int NGrid2_1,NGrid2_2,NGrid2_3;
  double Utot1,Utot2,dU,dF;
  double Spread1,Spread2;
  double Omega1,Omega2;
  double gx,gy,gz,fx,fy,fz;
  double sum1,sum2;
  double time1,TotalTime;
  char fname[YOUSO10];
  char fname0[YOUSO10];
  char fname1[YOUSO10];
  char fname2[YOUSO10];
  char fname_dat[YOUSO10];
  char fname_dat2[YOUSO10];
  char fname_out1[YOUSO10];
  char fname_out2[YOUSO10];
  char ftmp[YOUSO10];
  fname_type *fndat;
  char operate[800];
  int numprocs,myid;

  char *dir;
  char *input_dir;
  char *output_file;
  DIR *dp;
  struct dirent *entry;

  MPI_Request request;
  MPI_Status  status;

  /* set up MPI */

  MPI_Comm_size(MPI_COMM_WORLD1, &numprocs);
  MPI_Comm_rank(MPI_COMM_WORLD1, &myid);

  if (strcasecmp(mode,"S")==0){  
    input_dir = "input_example";
    output_file = "runtest.result";
  }
  else if (strcasecmp(mode,"L")==0){  
    input_dir = "large_example";
    output_file = "runtestL.result";
  }
  else if (strcasecmp(mode,"L2")==0){  
    input_dir = "large2_example";
    output_file = "runtestL2.result";
  }
  else if (strcasecmp(mode,"G")==0){  
    input_dir = "geoopt_example";
    output_file = "runtestG.result";
  }
  else if (strcasecmp(mode,"WF")==0){  
    input_dir = "wf_example";
    output_file = "runtestWF.result";
  }
  else if (strcasecmp(mode,"NEGF")==0){  
    input_dir = "negf_example";
    output_file = "runtestNEGF.result";
  }

  /* set Runtest_flag */

  Runtest_flag = 1;

  /* initialize TotalTime */

  TotalTime = 0.0;

  /* print the header */

  if (myid==Host_ID){

    printf("\n*******************************************************\n");  fflush(stdout);
    printf("*******************************************************\n");    fflush(stdout);
    printf(" Welcome to OpenMX   Ver. %s                           \n",Version_OpenMX); fflush(stdout);
    printf(" Copyright (C), 2002-2013, T.Ozaki                     \n");    fflush(stdout);
    printf(" OpenMX comes with ABSOLUTELY NO WARRANTY.             \n");    fflush(stdout);
    printf(" This is free software, and you are welcome to         \n");    fflush(stdout);
    printf(" redistribute it under the constitution of the GNU-GPL.\n");    fflush(stdout);
    printf("*******************************************************\n");    fflush(stdout);
    printf("*******************************************************\n\n\n");fflush(stdout);  

    printf("\n");
    printf(" OpenMX is now in the mode to check whether OpenMX runs normally\n"); fflush(stdout);
    printf(" on your machine or not by comparing the stored *.out and\n");        fflush(stdout);
    printf(" generated *.out \n"); fflush(stdout);
    printf("\n");fflush(stdout);

    /* set dir */

    dir = input_dir;

    /* count the number of dat files */

    if(( dp = opendir(dir) ) == NULL ){
      printf("could not find the directry '%s'\n",input_dir);
      MPI_Finalize();
      exit(0);
    }

    Num_DatFiles = 0;
    while((entry = readdir(dp)) != NULL){

      if ( strstr(entry->d_name,".dat")!=NULL ){ 
          
        Num_DatFiles++;
      }
    }
    closedir(dp);

    fndat = (fname_type*)malloc(sizeof(fname_type)*Num_DatFiles);

    /* store the name of dat files */

    if(( dp = opendir(dir) ) == NULL ){
      printf("could not find the directry '%s'\n",input_dir);
      MPI_Finalize();
      exit(0);
    }

    Num_DatFiles = 0;
    while((entry = readdir(dp)) != NULL){
 
      if ( strstr(entry->d_name,".dat")!=NULL ){ 

        sprintf(fndat[Num_DatFiles].fn,"%s/%s",input_dir,entry->d_name);  
        Num_DatFiles++;
      }
    }
    closedir(dp);

    /* sorting fndat */

    qsort(fndat, Num_DatFiles, sizeof(fname_type), stringcomp);  

    /*
    for (i=0; i<Num_DatFiles; i++){
      printf("i=%2d %s\n",i,fndat[i].fn);
    } 
    */

  } /* if (myid==Host_ID) */

  sprintf(fname2,"%s",output_file);

  if (myid==Host_ID){
    fp = fopen(fname2, "r");   
    if (fp!=NULL){
      fclose(fp); 
      sprintf(operate,"%s",fname2);
      remove(operate);
    }
  }

  if (myid==Host_ID){
    printf(" %2d dat files are found in the directory '%s'.\n\n\n",Num_DatFiles,input_dir);
  }

  MPI_Bcast(&Num_DatFiles, 1, MPI_INT, Host_ID, MPI_COMM_WORLD1);

  /***********************************************************
                      start calculations
  ***********************************************************/

  for (i=0; i<Num_DatFiles; i++){

    if (myid==Host_ID){
      sprintf(fname_dat,"%s",fndat[i].fn);
    }  

    MPI_Bcast(&fname_dat, YOUSO10, MPI_CHAR, Host_ID, MPI_COMM_WORLD1);

    /* run openmx */

    argv[1] = fname_dat;
    run_main(argc, argv, numprocs, myid); 

    /***********************************************************
          comparison between two files and save the result               
    ***********************************************************/

    if (myid==Host_ID){

      input_open(fname_dat);
      input_string("System.Name",fname_dat2,"default");
      input_close();

      /* compare two out files */

      sprintf(fname_out1,"%s.out",fname_dat2);
      sprintf(fname_out2,"%s/%s.out",input_dir,fname_dat2);

      /* generated file */

      input_open(fname_out1);
      input_double("Utot.",&Utot1,(double)0.0);

      /* for Wannier functions */

      if (strcasecmp(mode,"WF")==0){  
        input_double("Sum.of.Spreads.",&Spread1,(double)0.0);
        input_double("Total.Omega.=",&Omega1,(double)0.0);
      }

      input_int("Num.Grid1.",&NGrid1_1,(int)0);
      input_int("Num.Grid2.",&NGrid1_2,(int)0);
      input_int("Num.Grid3.",&NGrid1_3,(int)0);

      input_double("Elapsed.Time.",&time1,(double)0.0);

      TotalTime += time1;

      if (fp3=input_find("<coordinates.forces")) {
          
	fscanf(fp3,"%d",&Num_Atoms);

	sum1 = 0.0;
	for (j=1; j<=Num_Atoms; j++){  
	  fscanf(fp3,"%d %s %lf %lf %lf %lf %lf %lf",
		 &k,ftmp,&gx,&gy,&gz,&fx,&fy,&fz);
	  sum1 += fx + fy + fz;
	}

	if ( ! input_last("coordinates.forces>") ) {
	  printf("Format error for coordinates.forces\n");
	}
      }
      else {
	sum1 = 1000.0;
      }

      input_close();

      /* stored file */

      input_open(fname_out2);

      /* Utot */

      input_double("Utot.",&Utot2,(double)0.0);

      /* for Wannier functions */

      if (strcasecmp(mode,"WF")==0){  
        input_double("Sum.of.Spreads.",&Spread2,(double)0.0);
        input_double("Total.Omega.=",&Omega2,(double)0.0);
      }

      /* grids */

      input_int("Num.Grid1.",&NGrid2_1,(int)0);
      input_int("Num.Grid2.",&NGrid2_2,(int)0);
      input_int("Num.Grid3.",&NGrid2_3,(int)0);

      /* coordinates and forces */

      if (fp3=input_find("<coordinates.forces")) {
          
	fscanf(fp3,"%d",&Num_Atoms);

	sum2 = 0.0;
	for (j=1; j<=Num_Atoms; j++){  
	  fscanf(fp3,"%d %s %lf %lf %lf %lf %lf %lf",
		 &k,ftmp,&gx,&gy,&gz,&fx,&fy,&fz);
	  sum2 += fx + fy + fz;
	}

	if ( ! input_last("coordinates.forces>") ) {
	  /* format error */
	  printf("Format error for coordinates.forces\n");
	}
      }
      else {
	sum2 = 100.0;
      }

      input_close();

      dU = fabs(Utot1 - Utot2);
      dF = fabs(sum1 - sum2);

      /* write the result to a file, runtest.result */

      if ( (fp2 = fopen(fname2,"a")) != NULL ){

	if (  (NGrid1_1!=NGrid2_1)
	      || (NGrid1_2!=NGrid2_2)
	      || (NGrid1_3!=NGrid2_3) )
	  {
	    fprintf(fp2,"  Invalid comparison due to the different number of grids.\n");
	    fprintf(fp2,"  You may use a different radix for FFT.\n");
	  }

        if (strcasecmp(mode,"WF")==0){  

	  fprintf(fp2,"%4d  %-32.30s Elapsed time(s)=%8.2f  diff spread=%15.12f  diff Omega=%15.12f\n",
		  i+1,fname_dat,time1,fabs(Spread1-Spread2),fabs(Omega1-Omega2));
	}
        else{

	  fprintf(fp2,"%4d  %-32.30s Elapsed time(s)=%8.2f  diff Utot=%15.12f  diff Force=%15.12f\n",
		i+1,fname_dat,time1,dU,dF);
	}

	if (i==(Num_DatFiles-1)){
	  fprintf(fp2,"\n\nTotal elapsed time (s) %11.2f\n",TotalTime);
	}

	fclose(fp2);
      }
    }

  }

  /* tell us the end of calculation */
  if (myid==Host_ID){
    printf("\n\n\n\n");
    printf("The comparison can be found in a file '%s'.\n\n\n",output_file);
  }

  if (myid==Host_ID){
    free(fndat);
  }


  MPI_Barrier(MPI_COMM_WORLD1);
  MPI_Finalize();
  exit(0);
}
Пример #4
0
void tic_input(struct All_variables *E)
{

  int m = E->parallel.me;
  int noz = E->lmesh.noz;
  int n;
#ifdef USE_GGRD
  int tmp;
#endif

  input_int("tic_method", &(E->convection.tic_method), "0,0,2", m);

#ifdef USE_GGRD			/* for backward capability */
  input_int("ggrd_tinit", &tmp, "0", m);
  if(tmp){
    E->convection.tic_method = 4; /*  */
    E->control.ggrd.use_temp = 1;
  }
#endif  
  /* When tic_method is 0 (default), the temperature is a linear profile +
     perturbation at some layers.

     When tic_method is -1, the temperature is read in from the
     [datafile_old].velo.[rank].[solution_cycles_init] files.

     When tic_method is 1, the temperature is isothermal (== bottom b.c.) +
     uniformly cold plate (thickness specified by 'half_space_age').

     When tic_method is 2, (tic_method==1) + a hot blob. A user can specify
     the location and radius of the blob, and also the amplitude of temperature
     change in the blob relative to the ambient mantle temperautre
     (E->control.mantle_temp).
        - blob_center: A comma-separated list of three float numbers.
        - blob_radius: A dmensionless length, typically a fraction
                       of the Earth's radius.
        - blob_dT    : Dimensionless temperature.

     When tic_method is 3, the temperature is a linear profile + perturbation
     for whole mantle.

     tic_method is 4: read in initial temperature distribution from a set of netcdf grd
                      files. this required the GGRD extension to be compiled in

  */

    /* This part put a temperature anomaly at depth where the global
       node number is equal to load_depth. The horizontal pattern of
       the anomaly is given by spherical harmonic ll & mm. */

    input_int("num_perturbations", &n, "0,0,PERTURB_MAX_LAYERS", m);

    if (n > 0) {
      E->convection.number_of_perturbations = n;

      if (! input_float_vector("perturbmag", n, E->convection.perturb_mag, m) ) {
	fprintf(stderr,"Missing input parameter: 'perturbmag'\n");
	parallel_process_termination();
      }
      if (! input_int_vector("perturbm", n, E->convection.perturb_mm, m) ) {
	fprintf(stderr,"Missing input parameter: 'perturbm'\n");
	parallel_process_termination();
      }
      if (! input_int_vector("perturbl", n, E->convection.perturb_ll, m) ) {
	fprintf(stderr,"Missing input parameter: 'perturbl'\n");
	parallel_process_termination();
      }
      if (! input_int_vector("perturblayer", n, E->convection.load_depth, m) ) {
	fprintf(stderr,"Missing input parameter: 'perturblayer'\n");
	parallel_process_termination();
      }
    }
    else {
      E->convection.number_of_perturbations = 1;
      E->convection.perturb_mag[0] = 1;
      E->convection.perturb_mm[0] = 2;
      E->convection.perturb_ll[0] = 2;
      E->convection.load_depth[0] = (noz+1)/2;
    }

    input_float("half_space_age", &(E->convection.half_space_age), "40.0,1e-3,nomax", m);
    input_float("mantle_temp",&(E->control.mantle_temp),"1.0",m);

    
    switch(E->convection.tic_method){
    case 2:			/* blob */
      if( ! input_float_vector("blob_center", 3, E->convection.blob_center, m)) {
	assert( E->sphere.caps == 12 || E->sphere.caps == 1 );
	if(E->sphere.caps == 12) { /* Full version: just quit here */
	  fprintf(stderr,"Missing input parameter: 'blob_center'.\n");
	  parallel_process_termination();
	}
	else if(E->sphere.caps == 1) { /* Regional version: put the blob at the center */
	  fprintf(stderr,"Missing input parameter: 'blob_center'. The blob will be placed at the center of the domain.\n");
	  E->convection.blob_center[0] = 0.5*(E->control.theta_min+E->control.theta_max);
	  E->convection.blob_center[1] = 0.5*(E->control.fi_min+E->control.fi_max);
	  E->convection.blob_center[2] = 0.5*(E->sphere.ri+E->sphere.ro);
	}
      }
      input_float("blob_radius", &(E->convection.blob_radius), "0.063,0.0,1.0", m);
      input_float("blob_dT", &(E->convection.blob_dT), "0.18,nomin,nomax", m);
      input_boolean("blob_bc_persist",&(E->convection.blob_bc_persist),"off",m);
      break;
    case 4:
      /*
	case 4: initial temp from grd files
      */
#ifdef USE_GGRD
      /* 
	 read in some more parameters 
	 
      */
      /* scale the anomalies with PREM densities */
      input_boolean("ggrd_tinit_scale_with_prem",
		    &(E->control.ggrd.temp.scale_with_prem),"off",E->parallel.me);
      /* limit T to 0...1 */
      input_boolean("ggrd_tinit_limit_trange",
		    &(E->control.ggrd.temp.limit_trange),"on",E->parallel.me);
      /* scaling factor for the grids */
      input_double("ggrd_tinit_scale",
		   &(E->control.ggrd.temp.scale),"1.0",E->parallel.me); /* scale */
      /* temperature offset factor */
      input_double("ggrd_tinit_offset",
		   &(E->control.ggrd.temp.offset),"0.0",E->parallel.me); /* offset */
      /* 
	 do we want a different scaling for the lower mantle?
      */
      input_float("ggrd_lower_depth_km",&(E->control.ggrd_lower_depth_km),"7000",
		  E->parallel.me); /* depth, in km, below which
				      different scaling applies */
      input_float("ggrd_lower_scale",&(E->control.ggrd_lower_scale),"1.0",E->parallel.me);
      input_float("ggrd_lower_offset",&(E->control.ggrd_lower_offset),"1.0",E->parallel.me);

      /* grid name, without the .i.grd suffix */
      input_string("ggrd_tinit_gfile",
		   E->control.ggrd.temp.gfile,"",E->parallel.me); /* grids */
      input_string("ggrd_tinit_dfile",
		   E->control.ggrd.temp.dfile,"",E->parallel.me); /* depth.dat layers of grids*/
      /* override temperature boundary condition? */
      input_boolean("ggrd_tinit_override_tbc",
		    &(E->control.ggrd.temp.override_tbc),"off",E->parallel.me);
      input_string("ggrd_tinit_prem_file",
		   E->control.ggrd.temp.prem.model_filename,"hc/prem/prem.dat", 
		   E->parallel.me); /* PREM model filename */

      /* non-linear scaling, downweighing negative anomalies? */
      input_boolean("ggrd_tinit_nl_scale",&(E->control.ggrd_tinit_nl_scale),"off",E->parallel.me);
    
#else
      fprintf(stderr,"tic_method 4 only works for USE_GGRD compiled code\n");
      parallel_process_termination();
#endif
      break;
    } /* no default needed */
    return;
}
Пример #5
0
void TRAN_Input_std(
  MPI_Comm comm1, 
  int Solver,          /* input */
  int SpinP_switch,  
  char *filepath,
  double kBvalue,
  double TRAN_eV2Hartree,
  double Electronic_Temperature,
                      /* output */
  int *output_hks
)
{
  FILE *fp;
  int i,po;
  int i_vec[20],i_vec2[20];
  double r_vec[20];
  char *s_vec[20];
  char buf[MAXBUF];
  int myid;
  /* S MitsuakiKAWAMURA*/
  int TRAN_Analysis_Dummy;
  /* E MitsuakiKAWAMURA*/

  MPI_Comm_rank(comm1,&myid);

  /****************************************************
               parameters for TRANSPORT
  ****************************************************/

  input_logical("NEGF.Output_HKS",&TRAN_output_hks,0);
  *output_hks = TRAN_output_hks;

  /* printf("NEGF.OutputHKS=%d\n",TRAN_output_hks); */
  input_string("NEGF.filename.HKS",TRAN_hksoutfilename,"NEGF.hks");
  /* printf("TRAN_hksoutfilename=%s\n",TRAN_hksoutfilename); */

  input_logical("NEGF.Output.for.TranMain",&TRAN_output_TranMain,0);

  if ( Solver!=4 ) { return; }

  /**** show transport credit ****/
  TRAN_Credit(comm1);

  input_string("NEGF.filename.hks.l",TRAN_hksfilename[0],"NEGF.hks.l");
  input_string("NEGF.filename.hks.r",TRAN_hksfilename[1],"NEGF.hks.r");

  /* read data of leads */

  TRAN_RestartFile(comm1, "read","left", filepath,TRAN_hksfilename[0]);
  TRAN_RestartFile(comm1, "read","right",filepath,TRAN_hksfilename[1]);

  /* check b-, and c-axes of the unit cell of leads. */

  po = 0;
  for (i=2; i<=3; i++){
    if (1.0e-10<fabs(tv_e[0][i][1]-tv_e[1][i][1])) po = 1;
    if (1.0e-10<fabs(tv_e[0][i][2]-tv_e[1][i][2])) po = 1;
    if (1.0e-10<fabs(tv_e[0][i][3]-tv_e[1][i][3])) po = 1;
  }

  if (po==1){

    if (myid==Host_ID){
      printf("Warning: The b- or c-axis of the unit cell for the left lead is not same as that for the right lead.\n");
    }

    MPI_Finalize();
    exit(1);
  }

  /* show chemical potentials */

  if (myid==Host_ID){
    printf("\n");
    printf("Intrinsic chemical potential (eV) of the leads\n");
    printf("  Left lead:  %15.12f\n",ChemP_e[0]*TRAN_eV2Hartree);
    printf("  Right lead: %15.12f\n",ChemP_e[1]*TRAN_eV2Hartree);
  }

  /* check the conflict of SpinP_switch */

  if ( (SpinP_switch!=SpinP_switch_e[0]) || (SpinP_switch!=SpinP_switch_e[1]) ){

    if (myid==Host_ID){
      printf ("scf.SpinPolarization conflicts between leads or lead and center.\n");
    }

    MPI_Finalize();
    exit(0);
  }

  input_int(   "NEGF.Surfgreen.iterationmax", &tran_surfgreen_iteration_max, 600);
  input_double("NEGF.Surfgreen.convergeeps", &tran_surfgreen_eps, 1.0e-12); 

  /****  k-points parallel to the layer, which are used for the SCF calc. ****/

  i_vec2[0]=1;
  i_vec2[1]=1;
  input_intv("NEGF.scf.Kgrid",2,i_vec,i_vec2);
  TRAN_Kspace_grid2 = i_vec[0];
  TRAN_Kspace_grid3 = i_vec[1];

  if (TRAN_Kspace_grid2<=0){

    if (myid==Host_ID){
      printf("NEGF.scf.Kgrid should be over 1\n");
    }

    MPI_Finalize();
    exit(1);
  } 
  if (TRAN_Kspace_grid3<=0){

    if (myid==Host_ID){
      printf("NEGF.scf.Kgrid should be over 1\n");
    }

    MPI_Finalize();
    exit(1);
  } 

  /* Poisson solver */

  TRAN_Poisson_flag = 1;

  /* beginning added by mari 07.23.2014 */
  s_vec[0]="FD";  s_vec[1]="FFT";  s_vec[2]="FDG";
  i_vec[0]=1   ;  i_vec[1]=2    ;  i_vec[2]=3    ;

  input_string2int("NEGF.Poisson.Solver", &TRAN_Poisson_flag, 3, s_vec,i_vec);
  /* end added by mari 07.23.2014 */

  /* parameter to scale terms with Gpara=0 */

  input_double("NEGF.Poisson_Gparazero.scaling", &TRAN_Poisson_Gpara_Scaling, 1.0); 

  /* the number of buffer cells in FFTE */

  input_int("NEGF.FFTE.Num.Buffer.Cells", &TRAN_FFTE_CpyNum, 1); 

  /* the number of iterations by the Band calculation in the initial SCF iterations */

  input_int("NEGF.SCF.Iter.Band", &TRAN_SCF_Iter_Band, 3); 

  /* integration method */

  TRAN_integration = 0;

  s_vec[0]="CF"; s_vec[1]="OLD"; 
  i_vec[0]=0    ; i_vec[1]=1    ;
  input_string2int("NEGF.Integration", &TRAN_integration, 2, s_vec,i_vec);

  /* check whether analysis is made or not */

  input_logical("NEGF.tran.analysis",&TRAN_analysis,1);

  /* S MitsuakiKAWAMURA*/
  input_logical("NEGF.tran.channel", &TRAN_Analysis_Dummy, 1);
  if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1){
    TRAN_analysis = 1;
    if (myid == Host_ID)
      printf("Since NEGF.tran.channel is on, NEGF.tran.analysis is automatically set to on.\n");
  }
  input_logical("NEGF.tran.CurrentDensity", &TRAN_Analysis_Dummy, 1);
  if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1){
    TRAN_analysis = 1;
    if (myid == Host_ID)
      printf("Since NEGF.tran.CurrentDensity is on, NEGF.tran.analysis is automatically set to on.\n");
  }
  input_logical("NEGF.OffDiagonalCurrent", &TRAN_Analysis_Dummy, 0);
  if (TRAN_Analysis_Dummy == 1 && TRAN_analysis != 1) {
    TRAN_analysis = 1;
    if (myid == Host_ID)
      printf("Since NEGF.OffDiagonalCurrent is on, NEGF.tran.analysis is automatically set to on.\n");
  }
  /* E MitsuakiKAWAMURA*/

  /* check whether the SCF calcultion is skipped or not */

  i = 0;
  s_vec[i] = "OFF";         i_vec[i] = 0;  i++;
  s_vec[i] = "ON";          i_vec[i] = 1;  i++;
  s_vec[i] = "Periodic";  i_vec[i] = 2;  i++;

  input_string2int("NEGF.tran.SCF.skip", &TRAN_SCF_skip, i, s_vec, i_vec);

  /****  k-points parallel to the layer, which are used for the transmission calc. ****/
  
  i_vec2[0]=TRAN_Kspace_grid2;
  i_vec2[1]=TRAN_Kspace_grid3;
  input_intv("NEGF.tran.Kgrid",2,i_vec,i_vec2);
  TRAN_TKspace_grid2 = i_vec[0];
  TRAN_TKspace_grid3 = i_vec[1];

  if (TRAN_TKspace_grid2<=0){

    if (myid==Host_ID){
      printf("NEGF.tran.Kgrid should be over 1\n");
    }

    MPI_Finalize();
    exit(1);
  } 
  if (TRAN_TKspace_grid3<=0){

    if (myid==Host_ID){
      printf("NEGF.tran.Kgrid should be over 1\n");
    }

    MPI_Finalize();
    exit(1);
  } 

  /**** source and drain bias voltage ****/

  input_logical("NEGF.bias.apply",&tran_bias_apply,1); /* default=on */

  if ( tran_bias_apply ) {

    double tmp;

    tran_biasvoltage_e[0] = 0.0;
    input_double("NEGF.bias.voltage", &tmp, 0.0);  /* in eV */
    tran_biasvoltage_e[1] = tmp/TRAN_eV2Hartree; 

  }
  else {
    tran_biasvoltage_e[0]=0.0;
    tran_biasvoltage_e[1]=0.0;
  }

  if (tran_bias_apply) {

    int side;
    side=0;
    TRAN_Apply_Bias2e(comm1,  side, tran_biasvoltage_e[side], TRAN_eV2Hartree,
		      SpinP_switch_e[side], atomnum_e[side],
		      WhatSpecies_e[side], Spe_Total_CNO_e[side], FNAN_e[side], natn_e[side],
		      Ngrid1_e[side], Ngrid2_e[side], Ngrid3_e[side], OLP_e[side][0],
		      &ChemP_e[side],H_e[side], dVHart_Grid_e[side] ); /* output */
    side=1;
    TRAN_Apply_Bias2e(comm1,  side, tran_biasvoltage_e[side], TRAN_eV2Hartree,
		      SpinP_switch_e[side], atomnum_e[side],
		      WhatSpecies_e[side], Spe_Total_CNO_e[side], FNAN_e[side], natn_e[side],
		      Ngrid1_e[side], Ngrid2_e[side], Ngrid3_e[side], OLP_e[side][0],
		      &ChemP_e[side], H_e[side], dVHart_Grid_e[side] ); /* output */
  }

  /**** gate voltage ****/

  /* beginning added by mari 07.30.2014 */
  if(TRAN_Poisson_flag == 3) {
    r_vec[0] = 0.0;
    r_vec[1] = 0.0;
    input_doublev("NEGF.gate.voltage", 2, tran_gate_voltage, r_vec); 
    tran_gate_voltage[0] /= TRAN_eV2Hartree; 
    tran_gate_voltage[1] /= TRAN_eV2Hartree; 
  } else {
    r_vec[0] = 0.0;
    input_doublev("NEGF.gate.voltage", 1, tran_gate_voltage, r_vec); 
    tran_gate_voltage[0] /= TRAN_eV2Hartree; 
  }
  /* end added by mari 07.30.2014 */

  /******************************************************
            parameters for the DOS calculation         
  ******************************************************/
  
  i=0;
  r_vec[i++] = -10.0;
  r_vec[i++] =  10.0;
  r_vec[i++] = 5.0e-3;
  input_doublev("NEGF.Dos.energyrange",i, tran_dos_energyrange, r_vec); /* in eV */
  /* change the unit from eV to Hartree */
  tran_dos_energyrange[0] /= TRAN_eV2Hartree;
  tran_dos_energyrange[1] /= TRAN_eV2Hartree;
  tran_dos_energyrange[2] /= TRAN_eV2Hartree;

  input_int("NEGF.Dos.energy.div",&tran_dos_energydiv,200);
  
  i_vec2[0]=1;
  i_vec2[1]=1;
  input_intv("NEGF.Dos.Kgrid",2,i_vec,i_vec2);
  TRAN_dos_Kspace_grid2 = i_vec[0];
  TRAN_dos_Kspace_grid3 = i_vec[1];

  /********************************************************
    integration on real axis with a small imaginary part
    for the "non-equilibrium" region
  ********************************************************/

  input_double("NEGF.bias.neq.im.energy", &Tran_bias_neq_im_energy, 1.0e-2);  /* in eV */
  if (Tran_bias_neq_im_energy<0.0) {
    if (myid==Host_ID)  printf("NEGF.bias.neq.im.energy should be positive.\n");
    MPI_Finalize();
    exit(1);
  }
  /* change the unit from eV to Hartree */
  Tran_bias_neq_im_energy /= TRAN_eV2Hartree; 

  input_double("NEGF.bias.neq.energy.step", &Tran_bias_neq_energy_step, 0.02);  /* in eV */
  if (Tran_bias_neq_energy_step<0.0) {
    if (myid==Host_ID)  printf("NEGF.bias.neq.energy.step should be positive.\n");
    MPI_Finalize();
    exit(1);
  }
  /* change the unit from eV to Hartree */
  Tran_bias_neq_energy_step /= TRAN_eV2Hartree; 

  input_double("NEGF.bias.neq.cutoff", &Tran_bias_neq_cutoff, 1.0e-8);  /* dimensionless */

  /********************************************************
     contour integration based on a continued 
     fraction representation of the Fermi function 
  ********************************************************/

  input_int("NEGF.Num.Poles", &tran_num_poles,150);

  TRAN_Set_IntegPath( comm1, TRAN_eV2Hartree, kBvalue, Electronic_Temperature );
}