Beispiel #1
0
public  Status  get_image_file_size(
    STRING         filename,
    int            *x_size,
    int            *y_size,
    int            *nc )
{
    char   command[EXTREMELY_LARGE_STRING_SIZE+1];
    FILE   *file;

    /*---  get the image size */

    (void) sprintf( command, "get_image_size.pl %s", filename );

    if( (file = popen( command, "r")) == NULL )
    {
        print_error( "Error opening file %s or finding command 'get_image_size.pl'\n",
                     filename );
        return( ERROR );
    }

    if( input_int( file, x_size ) != OK ||
        input_int( file, y_size ) != OK ||
        input_int( file, nc ) != OK )
        return( ERROR );

    pclose( file );

    return( OK );
}
void arbitrary_bc_polynomial_file(
    struct All_variables *E,
    struct PolyBc *POLY,
    char *name,
    standard_precision *field,
    unsigned int *bcbitf,
    unsigned int bcmask_on,
    unsigned int bcmask_off,
    const unsigned int surf
)
{
  char read_string[500], pfx;
  void arbitrary_bc_polynomial();
  int i;

  /*RAA: 5/8/01, eventually, there should be more coefficients for order>1,
       for cross-terms (a6*x*y, etc) */

  sprintf(read_string,"%s_bc_poly",name);
  input_int(read_string,&(POLY->numb),"0");
  sprintf(read_string,"%s_bc_poly_ord",name);
  input_int(read_string,&(POLY->order),"0,0,19");
  sprintf(read_string,"%s_bc_poly_norm",name);
  input_char_vector(read_string,POLY->numb,POLY->norm);
  sprintf(read_string,"%s_bc_poly_icpt",name);
  input_std_precision_vector(read_string,POLY->numb,POLY->intercept);
  sprintf(read_string,"%s_bc_poly_aa1",name);
  input_std_precision_vector(read_string,POLY->numb,POLY->aa1);
  sprintf(read_string,"%s_bc_poly_aa2",name);
  input_std_precision_vector(read_string,POLY->numb,POLY->aa2);
  sprintf(read_string,"%s_bc_poly_bb1",name);
  input_std_precision_vector(read_string,POLY->numb,POLY->bb1);
  sprintf(read_string,"%s_bc_poly_bb2",name);
  input_std_precision_vector(read_string,POLY->numb,POLY->bb2);

  /*RAA: 5/7/01, aaa%02d (abb%02d) used to be oaa.. (obb..),
    should be <= below, not just < !!*/
  /* DAS: 6/1/04, make this work for both _oaa and _aaa forms,
     as long as it's consistent for each polynomial */
  sprintf(read_string,"%s_bc_poly_aaa00",name);
  if(input_std_precision_vector(read_string,POLY->numb,POLY->aaa[i]))
      pfx = 'o';
  else
      pfx = 'a';
  for(i=0;i<=POLY->order;i++) {
      sprintf(read_string,"%s_bc_poly_%caa%02d",name,pfx,i);
      input_std_precision_vector(read_string,POLY->numb,POLY->aaa[i]);
      sprintf(read_string,"%s_bc_poly_%cbb%02d",name,pfx,i);
      input_std_precision_vector(read_string,POLY->numb,POLY->abb[i]);
      }

  arbitrary_bc_polynomial(E,POLY,field,bcbitf,bcmask_on,bcmask_off,surf);
 
  return;  
}
void arbitrary_bc_harmonic_file(
  struct All_variables *E,
  struct HarmBc *HARM,
  char *name,
  standard_precision **field,
  unsigned int **bcbitf,
  unsigned int bcmask_on,
  unsigned int bcmask_off,
    const unsigned int surf
)
{
  char read_string[500];
  void arbitrary_bc_harmonic();
  int i;

  sprintf(read_string,"%s_bc_harm",name);
  input_int(read_string,&(HARM->numb),"0");
  sprintf(read_string,"%s_bc_harms",name);
  input_int(read_string,&(HARM->harms),"0,0,19");
  sprintf(read_string,"%s_bc_harm_norm",name);
  input_char_vector(read_string,HARM->numb,HARM->norm);
  sprintf(read_string,"%s_bc_harm_ofst",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->off);
  sprintf(read_string,"%s_bc_harm_icpt",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->intercept);
  sprintf(read_string,"%s_bc_harm_aa1",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->aa1);
  sprintf(read_string,"%s_bc_harm_aa2",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->aa2);
  sprintf(read_string,"%s_bc_harm_bb1",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->bb1);
  sprintf(read_string,"%s_bc_harm_bb2",name);
  input_std_precision_vector(read_string,HARM->numb,HARM->bb2);

  for(i=0;i<HARM->harms;i++) {
      sprintf(read_string,"%s_bc_harm_kaa%02d",name,i);
      input_std_precision_vector(read_string,HARM->numb,HARM->kaa[i]);
      sprintf(read_string,"%s_bc_harm_kbb%02d",name,i);
      input_std_precision_vector(read_string,HARM->numb,HARM->kbb[i]);
      sprintf(read_string,"%s_bc_harm_amp%02d",name,i);
      input_std_precision_vector(read_string,HARM->numb,HARM->amp[i]);
      sprintf(read_string,"%s_bc_harm_phaa%02d",name,i);
      input_std_precision_vector(read_string,HARM->numb,HARM->phaa[i]);
      sprintf(read_string,"%s_bc_harm_phbb%02d",name,i);
      input_std_precision_vector(read_string,HARM->numb,HARM->phbb[i]);
  }
   
  arbitrary_bc_harmonic(E,HARM,field,bcbitf,bcmask_on,bcmask_off,surf);
 
  return;  
}
void arbitrary_bc_circle_file(
    struct All_variables *E,
    struct CircBc *CIRC,
    char *name,
    standard_precision **field,
    unsigned int **bcbitf,
    unsigned int bcmask_on,
    unsigned int bcmask_off,
    const unsigned int surf
)
{
  char read_string[500];
  void arbitrary_bc_circle();

  sprintf(read_string,"%s_bc_circ",name);
  input_int(read_string,&(CIRC->numb),"0");
  sprintf(read_string,"%s_bc_circ_aa",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->aa);
  sprintf(read_string,"%s_bc_circ_bb",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->bb);
  sprintf(read_string,"%s_bc_circ_rad",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->rad);
  sprintf(read_string,"%s_bc_circ_mag",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->mag);
  sprintf(read_string,"%s_circhw",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->halfw);
  sprintf(read_string,"%s_bc_circ_icpt",name);
  input_std_precision_vector(read_string,CIRC->numb,CIRC->intercept);
  sprintf(read_string,"%s_bc_circ_norm",name);
  input_char_vector(read_string,CIRC->numb,CIRC->norm);
 
  arbitrary_bc_circle(E,CIRC,field,bcbitf,bcmask_on,bcmask_off,surf);
 
  return;  
}
void Name_pairs::read_names()
{
	//input number of names;
	std::cout << "please input the number of names (one int(>0) in a line)" << std::endl;
	int n = 0;
	while (true){
		n = input_int();
		if (n > 0){
			break;
		}
		std::cout << "Invalid number. Try again." << std::endl;
	}
	//clear data;
	name.clear();
	age.clear();
	//input names;
	std::cout << "Please input " << n << " names below (one per line)" << std::endl;
	std::string s = "";
	for (int i = 0; i < n; ++i){
		std::getline(std::cin, s);
		if (std::cin.bad()){
			throw std::runtime_error("bad stream");
		}
		if (std::cin.eof()){
			throw std::runtime_error("unexpected end of file");
		}
		name.push_back(s);
	}
}
Beispiel #6
0
void grain_growth_initialize(
     struct All_variables *E
)
{
  int i,j,el,level,rheo,material;
  char default_str[40];

  /* Which formulation is to be used .... growth/nucleation or empirical */

  input_int("Grain_size_model",&(E->tracer.grain_size_model),"1");

  for(material=0;material<=E->tracer.NUM_MATERIALS;material++) {

    if(E->tracer.grain_size_model==1) {
      sprintf(default_str,"Material_%d_grsz_epsT",material);
      input_std_precision(default_str,&(E->tracer.grain[material].grsz_epsT),"0.0");
      sprintf(default_str,"Material_%d_grsz_B",material);
      input_std_precision(default_str,&(E->tracer.grain[material].grsz_B),"1.0");
      sprintf(default_str,"Material_%d_grsz_stsexp",material);
      input_std_precision(default_str,&(E->tracer.grain[material].grsz_stsexp),"1.0");

    }

    else if (E->tracer.grain_size_model==2) {

      sprintf(default_str,"Material_%d_reduction_factor_e",material);
      input_std_precision(default_str,&(E->tracer.grain[material].reduction_factor_equil),"1.0");
      sprintf(default_str,"Material_%d_reduction_factor_m",material);
      input_std_precision(default_str,&(E->tracer.grain[material].reduction_factor_metas),"1.0");
      
      sprintf(default_str,"Material_%d_grain_T_dep",material);
      input_int_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].GRAIN_T_dep,1);
      sprintf(default_str,"Material_%d_grain_gr_a",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_a,0.0);
      sprintf(default_str,"Material_%d_grain_gr_m",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_m,0.0);
      sprintf(default_str,"Material_%d_grain_gr_Q",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_Q,0.0);
      sprintf(default_str,"Material_%d_grain_gr_T",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_T,0.0);
      sprintf(default_str,"Material_%d_grain_gr_T0",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].ggrw_T0,0.0);
      sprintf(default_str,"Material_%d_grain_nu_a",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_a,0.0);
      sprintf(default_str,"Material_%d_grain_nu_m",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_m,0.0);
      sprintf(default_str,"Material_%d_grain_nu_meps",material);
      input_std_precision_vector(default_str,E->tracer.Phases[material],E->tracer.grain[material].gnuc_meps,0.0);
    }
  }
  return;
}
Beispiel #7
0
void interrupt handler(void){
		
        int int_id;
        
         //determine if port is open
		 if(DCB->flag != OPEN) outportb(PIC_CMD, 0x20);
		else{

			 //Read Interrupt ID
			 int_id=inportb(COM1_INT_ID_REG);
			 int_id &= 0x07;	

			 //calling appropiate second-level handler
			 if(int_id == 2) output_int();
			 else if(int_id == 4) input_int();
		  
			 //clear interrupt
			 outportb(PIC_CMD,0x20);
		}
}//end new_handler
void arbitrary_bc_rectangle_file(
				 struct All_variables *E,
				 struct RectBc *RECT,
				 char *name,
				 standard_precision **field,
				 unsigned int **bcbitf,
				 const unsigned int bcmask_on,
				 const unsigned int bcmask_off,
				 const unsigned int surf
				 )
{
  char read_string[500];
  void arbitrary_bc_rectangle();


  sprintf(read_string,"%s_bc_rect",name);
  input_int(read_string,&(RECT->numb),"0");
  sprintf(read_string,"%s_bc_rect_aa1",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->aa1);
  sprintf(read_string,"%s_bc_rect_aa2",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->aa2);
  sprintf(read_string,"%s_bc_rect_bb1",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->bb1);
  sprintf(read_string,"%s_bc_rect_bb2",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->bb2);
  sprintf(read_string,"%s_bc_rect_hw",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->halfw);
  sprintf(read_string,"%s_bc_rect_mag",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->mag);
  sprintf(read_string,"%s_bc_rect_icpt",name);
  input_std_precision_vector(read_string,RECT->numb,RECT->intercept);
  sprintf(read_string,"%s_bc_rect_norm",name);
  input_char_vector(read_string,RECT->numb,RECT->norm);

  arbitrary_bc_rectangle(E,RECT,field,bcbitf,bcmask_on,bcmask_off,surf);  
     
  return;
}
Beispiel #9
0
//# MENU antenna
void antenna_main()
{
	frequency=(int64_t)input_int("Frequency:",(int)(frequency/1000000),50,4000,4)*1000000;

	lcdClear();
	lcdSetCrsr(0,0);
	lcdPrintln("Antenna Frequency");

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(frequency/1000000,4,F_LONG));
	lcdPrintln(" MHz ");

	lcdNl();
	lcdPrintln("Antenna Length");

	float meter = SPEEDOFLIGHT/frequency;

	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 2, 4, F_LONG ));
	lcdPrint(" mm");
	lcdNl();
	lcdPrint(" ");
	lcdPrint(IntToStr(meter * 1000 / 4, 4, F_LONG ));
	lcdPrint(" mm");

	lcdDisplay();

	getInputWaitRepeat();

}
Beispiel #10
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);
}
Beispiel #11
0
void Show_DFT_DATA(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 gx,gy,gz,fx,fy,fz;
  double sum1,sum2;
  double time1,TotalTime;
  char SN[30][YOUSO10];
  char SB[30][YOUSO10];
  char SV[30][YOUSO10];
  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;
  int numprocs,myid;

  char *dir;
  char input_dir[300];
  char *output_file;
  DIR *dp;
  struct dirent *entry;

  MPI_Request request;
  MPI_Status  status;

  /* set up MPI */

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

  sprintf(input_dir,"%s",argv[2]);

  printf("%s\n",input_dir);
  
  /* print the header */

  if (myid==Host_ID){

    /* 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);

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

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

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

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

    sprintf(fname_dat,"%s",fndat[i].fn);

    input_open(fname_dat);
    input_int("Species.Number",&SpeciesNum,0);

    /* read Definition.of.Atomic.Species */

    if (fp=input_find("<Definition.of.Atomic.Species")) {

      for (k=0; k<SpeciesNum; k++){
        fscanf(fp,"%s %s %s",SN[k],SB[k],SV[k]);

        printf("i=%2d k=%2d %s %s\n",i,k,SB[k],SV[k]);

	/*
        SpeciesString2int(i);
	*/
      }

      if (! input_last("Definition.of.Atomic.Species>")) {
	MPI_Finalize();
	exit(0);
      }
    }

    input_close();
  }

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

  MPI_Barrier(mpi_comm_level1);
  MPI_Finalize();
  exit(0);
}
Beispiel #12
0
int main()
{
    char cmd[20];
    int done = 0;
    int ret, trk, a, b;

    if (cd_init() < 0) {
	printf("Error initialising libcda (%s)\n", cd_error);
	return 1;
    }
	
    show_cmds();

    do {  
	printf(">>> ");
	fflush(stdout);
	scanf("%s", cmd);

	switch (cmd[0]) {
	    case '?':
		show_cmds();
		break;

	    case 'p':
		trk = input_int("Track");
		ret = cd_play(trk);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'r':
		a = input_int("First track");
		b = input_int("Last track");
		ret = cd_play_range(a, b);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'f':
		trk = input_int("Start track");
		ret = cd_play_from(trk);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		break;

	    case 'P':
		trk = cd_current_track();
		if (trk)
		    printf("Playing track %d\n", trk);
		else
		    printf("Not playing\n");
		break;

	    case 'w':
		cd_pause();
		break;

	    case 'W':
		cd_resume();
		break;

	    case 'S':
		ret = cd_is_paused();
		if (ret)
		    printf("Paused\n");
		else
		    printf("Not paused\n");
		break;

	    case 's':
		cd_stop();
		break;

	    case 'i':
		ret = cd_get_tracks(&a, &b);
		if (ret != 0)
		    printf("Error occurred (%s)\n", cd_error);
		else
		    printf("First track: %d\nLast track: %d\n", a, b);
		break;

	    case 'a':
		trk = input_int("Track");
		ret = cd_is_audio(trk);
		if (ret < 0)
		    printf("Error occurred (%s)\n", cd_error);
		else
		    printf("Track %d is %s\n", trk, (ret ? "audio" : "data"));
		break;

	    case 'v':
		a = input_int("Left (0-255)");
		b = input_int("Right (0-255)");
		cd_set_volume(a, b);
		break;

	    case 'V':
		cd_get_volume(&a, &b);
		printf("Left volume: %d\nRight volume: %d\n", a, b);
		break;

	    case 'e':
		cd_eject();
		break;

	    case 'c':
		cd_close();
		break;

	    case 'q':
		done = 1;
		break;

	    default:
		printf("Unrecognised command: `%c'\n", cmd[0]);
	}
    } while (!done);

    cd_exit();
    
    return 0;
}
Beispiel #13
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 );
}
Beispiel #14
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;
}
Beispiel #15
0
int
main(void)
{
    int i;
    int n;
    int t;
    int pygen_0_tagF_temp;
    int pygen_1_tagF_temp;
    int pygen_0_compF_temp;
    int pygen_2_tagF_temp;
    int pygen_1_compF_temp;
    int pygen_0_projF_temp;
    int pygen_1_projF_temp;
    int pygen_2_compF_temp;
    int pygen_0_injF_temp;
    int pygen_1_ifexF_temp;
    int pygen_3_tagF_temp;
    int pygen_3_compF_temp;
    int pygen_2_projF_temp;
    int pygen_3_projF_temp;
    int pygen_4_compF_temp;
    int pygen_1_injF_temp;
    int pygen_0_ifexF_temp;
    int pygen_4_projF_temp;
    int pygen_5_projF_temp;
    int pygen_0_callF_temp;
    int pygen_2_injF_temp;
    int pygen_3_ifexF_temp;
    int pygen_4_tagF_temp;
    int pygen_5_compF_temp;
    int pygen_6_projF_temp;
    int pygen_7_projF_temp;
    int pygen_6_compF_temp;
    int pygen_3_injF_temp;
    int pygen_2_ifexF_temp;
    int pygen_8_projF_temp;
    int pygen_9_projF_temp;
    int pygen_7_compF_temp;
    int pygen_4_injF_temp;
    int pygen_2_let_temp;
    int pygen_5_tagF_temp;
    int pygen_8_compF_temp;
    int pygen_10_projF_temp;
    int pygen_9_compF_temp;
    int pygen_5_ifexF_temp;
    int pygen_6_tagF_temp;
    int pygen_10_compF_temp;
    int pygen_11_projF_temp;
    int pygen_11_compF_temp;
    int pygen_4_ifexF_temp;
    int pygen_1_callF_temp;
    int pygen_7_tagF_temp;
    int pygen_12_compF_temp;
    int pygen_12_projF_temp;
    int pygen_13_projF_temp;
    int pygen_0_addF_temp;
    int pygen_5_injF_temp;
    int pygen_7_ifexF_temp;
    int pygen_8_tagF_temp;
    int pygen_13_compF_temp;
    int pygen_14_projF_temp;
    int pygen_15_projF_temp;
    int pygen_1_addF_temp;
    int pygen_6_injF_temp;
    int pygen_6_ifexF_temp;
    int pygen_16_projF_temp;
    int pygen_17_projF_temp;
    int pygen_2_callF_temp;
    int pygen_7_injF_temp;
    int pygen_18_projF_temp;
    int pygen_0_usubF_temp;
    int pygen_8_injF_temp;
    int pygen_0_let_temp;
    int pygen_9_tagF_temp;
    int pygen_14_compF_temp;
    int pygen_19_projF_temp;
    int pygen_20_projF_temp;
    int pygen_2_addF_temp;
    int pygen_9_injF_temp;
    int pygen_9_ifexF_temp;
    int pygen_10_tagF_temp;
    int pygen_15_compF_temp;
    int pygen_21_projF_temp;
    int pygen_22_projF_temp;
    int pygen_3_addF_temp;
    int pygen_10_injF_temp;
    int pygen_8_ifexF_temp;
    int pygen_23_projF_temp;
    int pygen_24_projF_temp;
    int pygen_3_callF_temp;
    int pygen_11_injF_temp;
    int pygen_12_injF_temp;
    int pygen_1_let_temp;
    int pygen_11_tagF_temp;
    int pygen_16_compF_temp;
    int pygen_25_projF_temp;
    int pygen_26_projF_temp;
    int pygen_4_addF_temp;
    int pygen_13_injF_temp;
    int pygen_11_ifexF_temp;
    int pygen_12_tagF_temp;
    int pygen_17_compF_temp;
    int pygen_27_projF_temp;
    int pygen_28_projF_temp;
    int pygen_5_addF_temp;
    int pygen_14_injF_temp;
    int pygen_10_ifexF_temp;
    int pygen_29_projF_temp;
    int pygen_30_projF_temp;
    int pygen_4_callF_temp;
    int pygen_15_injF_temp;
    i = inject_int(0);
    n = input_int();
    t = inject_int(0);
    pygen_0_tagF_temp = tag(i);
    pygen_1_tagF_temp = tag(n);
    pygen_0_compF_temp = (pygen_0_tagF_temp == pygen_1_tagF_temp);
    if (pygen_0_compF_temp) {
        pygen_2_tagF_temp = tag(i);
        pygen_1_compF_temp = (pygen_2_tagF_temp == 0);
        if (pygen_1_compF_temp) {
            pygen_0_projF_temp = project_int(i);
            pygen_1_projF_temp = project_int(n);
            pygen_2_compF_temp = (pygen_0_projF_temp != pygen_1_projF_temp);
            pygen_0_injF_temp = inject_bool(pygen_2_compF_temp);
            pygen_1_ifexF_temp = pygen_0_injF_temp;
        } else {
            pygen_3_tagF_temp = tag(i);
            pygen_3_compF_temp = (pygen_3_tagF_temp == 1);
            if (pygen_3_compF_temp) {
                pygen_2_projF_temp = project_bool(i);
                pygen_3_projF_temp = project_bool(n);
                pygen_4_compF_temp = (pygen_2_projF_temp != pygen_3_projF_temp);
                pygen_1_injF_temp = inject_bool(pygen_4_compF_temp);
                pygen_0_ifexF_temp = pygen_1_injF_temp;
            } else {
                pygen_4_projF_temp = project_big(i);
                pygen_5_projF_temp = project_big(n);
                pygen_0_callF_temp = not_equal(pygen_4_projF_temp, pygen_5_projF_temp);
                pygen_2_injF_temp = inject_bool(pygen_0_callF_temp);
                pygen_0_ifexF_temp = pygen_2_injF_temp;
            }
            pygen_1_ifexF_temp = pygen_0_ifexF_temp;
        }
        pygen_3_ifexF_temp = pygen_1_ifexF_temp;
    } else {
        pygen_4_tagF_temp = tag(i);
        pygen_5_compF_temp = (pygen_4_tagF_temp == 0);
        if (pygen_5_compF_temp) {
            pygen_6_projF_temp = project_int(i);
            pygen_7_projF_temp = project_bool(n);
            pygen_6_compF_temp = (pygen_6_projF_temp != pygen_7_projF_temp);
            pygen_3_injF_temp = inject_bool(pygen_6_compF_temp);
            pygen_2_ifexF_temp = pygen_3_injF_temp;
        } else {
            pygen_8_projF_temp = project_bool(i);
            pygen_9_projF_temp = project_int(n);
            pygen_7_compF_temp = (pygen_8_projF_temp != pygen_9_projF_temp);
            pygen_4_injF_temp = inject_bool(pygen_7_compF_temp);
            pygen_2_ifexF_temp = pygen_4_injF_temp;
        }
        pygen_3_ifexF_temp = pygen_2_ifexF_temp;
    }
    pygen_2_let_temp = pygen_3_ifexF_temp;
    pygen_5_tagF_temp = tag(pygen_2_let_temp);
    pygen_8_compF_temp = (pygen_5_tagF_temp == 0);
    if (pygen_8_compF_temp) {
        pygen_10_projF_temp = project_int(pygen_2_let_temp);
        pygen_9_compF_temp = (0 != pygen_10_projF_temp);
        pygen_5_ifexF_temp = pygen_9_compF_temp;
    } else {
        pygen_6_tagF_temp = tag(pygen_2_let_temp);
        pygen_10_compF_temp = (pygen_6_tagF_temp == 1);
        if (pygen_10_compF_temp) {
            pygen_11_projF_temp = project_bool(pygen_2_let_temp);
            pygen_11_compF_temp = (0 != pygen_11_projF_temp);
            pygen_4_ifexF_temp = pygen_11_compF_temp;
        } else {
            pygen_1_callF_temp = is_true(pygen_2_let_temp);
            pygen_4_ifexF_temp = pygen_1_callF_temp;
        }
        pygen_5_ifexF_temp = pygen_4_ifexF_temp;
    }
    while (pygen_5_ifexF_temp) {
        pygen_7_tagF_temp = tag(t);
        pygen_12_compF_temp = (pygen_7_tagF_temp == 0);
        if (pygen_12_compF_temp) {
            pygen_12_projF_temp = project_int(t);
            pygen_13_projF_temp = project_int(i);
            pygen_0_addF_temp = (pygen_12_projF_temp + pygen_13_projF_temp);
            pygen_5_injF_temp = inject_int(pygen_0_addF_temp);
            pygen_7_ifexF_temp = pygen_5_injF_temp;
        } else {
            pygen_8_tagF_temp = tag(t);
            pygen_13_compF_temp = (pygen_8_tagF_temp == 1);
            if (pygen_13_compF_temp) {
                pygen_14_projF_temp = project_bool(t);
                pygen_15_projF_temp = project_bool(i);
                pygen_1_addF_temp = (pygen_14_projF_temp + pygen_15_projF_temp);
                pygen_6_injF_temp = inject_int(pygen_1_addF_temp);
                pygen_6_ifexF_temp = pygen_6_injF_temp;
            } else {
                pygen_16_projF_temp = project_big(t);
                pygen_17_projF_temp = project_big(i);
                pygen_2_callF_temp = add(pygen_16_projF_temp, pygen_17_projF_temp);
                pygen_7_injF_temp = inject_big(pygen_2_callF_temp);
                pygen_6_ifexF_temp = pygen_7_injF_temp;
            }
            pygen_7_ifexF_temp = pygen_6_ifexF_temp;
        }
        t = pygen_7_ifexF_temp;
        pygen_18_projF_temp = project_int(i);
        pygen_0_usubF_temp = -(pygen_18_projF_temp);
        pygen_8_injF_temp = inject_int(pygen_0_usubF_temp);
        pygen_0_let_temp = pygen_8_injF_temp;
        pygen_9_tagF_temp = tag(pygen_0_let_temp);
        pygen_14_compF_temp = (pygen_9_tagF_temp == 0);
        if (pygen_14_compF_temp) {
            pygen_19_projF_temp = project_int(pygen_0_let_temp);
            pygen_20_projF_temp = project_int(t);
            pygen_2_addF_temp = (pygen_19_projF_temp + pygen_20_projF_temp);
            pygen_9_injF_temp = inject_int(pygen_2_addF_temp);
            pygen_9_ifexF_temp = pygen_9_injF_temp;
        } else {
            pygen_10_tagF_temp = tag(pygen_0_let_temp);
            pygen_15_compF_temp = (pygen_10_tagF_temp == 1);
            if (pygen_15_compF_temp) {
                pygen_21_projF_temp = project_bool(pygen_0_let_temp);
                pygen_22_projF_temp = project_bool(t);
                pygen_3_addF_temp = (pygen_21_projF_temp + pygen_22_projF_temp);
                pygen_10_injF_temp = inject_int(pygen_3_addF_temp);
                pygen_8_ifexF_temp = pygen_10_injF_temp;
            } else {
                pygen_23_projF_temp = project_big(pygen_0_let_temp);
                pygen_24_projF_temp = project_big(t);
                pygen_3_callF_temp = add(pygen_23_projF_temp, pygen_24_projF_temp);
                pygen_11_injF_temp = inject_big(pygen_3_callF_temp);
                pygen_8_ifexF_temp = pygen_11_injF_temp;
            }
            pygen_9_ifexF_temp = pygen_8_ifexF_temp;
        }
        t = pygen_9_ifexF_temp;
        pygen_12_injF_temp = inject_int(1);
        pygen_1_let_temp = pygen_12_injF_temp;
        pygen_11_tagF_temp = tag(i);
        pygen_16_compF_temp = (pygen_11_tagF_temp == 0);
        if (pygen_16_compF_temp) {
            pygen_25_projF_temp = project_int(i);
            pygen_26_projF_temp = project_int(pygen_1_let_temp);
            pygen_4_addF_temp = (pygen_25_projF_temp + pygen_26_projF_temp);
            pygen_13_injF_temp = inject_int(pygen_4_addF_temp);
            pygen_11_ifexF_temp = pygen_13_injF_temp;
        } else {
            pygen_12_tagF_temp = tag(i);
            pygen_17_compF_temp = (pygen_12_tagF_temp == 1);
            if (pygen_17_compF_temp) {
                pygen_27_projF_temp = project_bool(i);
                pygen_28_projF_temp = project_bool(pygen_1_let_temp);
                pygen_5_addF_temp = (pygen_27_projF_temp + pygen_28_projF_temp);
                pygen_14_injF_temp = inject_int(pygen_5_addF_temp);
                pygen_10_ifexF_temp = pygen_14_injF_temp;
            } else {
                pygen_29_projF_temp = project_big(i);
                pygen_30_projF_temp = project_big(pygen_1_let_temp);
                pygen_4_callF_temp = add(pygen_29_projF_temp, pygen_30_projF_temp);
                pygen_15_injF_temp = inject_big(pygen_4_callF_temp);
                pygen_10_ifexF_temp = pygen_15_injF_temp;
            }
            pygen_11_ifexF_temp = pygen_10_ifexF_temp;
        }
        i = pygen_11_ifexF_temp;
        pygen_0_tagF_temp = tag(i);
        pygen_1_tagF_temp = tag(n);
        pygen_0_compF_temp = (pygen_0_tagF_temp == pygen_1_tagF_temp);
        if (pygen_0_compF_temp) {
            pygen_2_tagF_temp = tag(i);
            pygen_1_compF_temp = (pygen_2_tagF_temp == 0);
            if (pygen_1_compF_temp) {
                pygen_0_projF_temp = project_int(i);
                pygen_1_projF_temp = project_int(n);
                pygen_2_compF_temp = (pygen_0_projF_temp != pygen_1_projF_temp);
                pygen_0_injF_temp = inject_bool(pygen_2_compF_temp);
                pygen_1_ifexF_temp = pygen_0_injF_temp;
            } else {
                pygen_3_tagF_temp = tag(i);
                pygen_3_compF_temp = (pygen_3_tagF_temp == 1);
                if (pygen_3_compF_temp) {
                    pygen_2_projF_temp = project_bool(i);
                    pygen_3_projF_temp = project_bool(n);
                    pygen_4_compF_temp = (pygen_2_projF_temp != pygen_3_projF_temp);
                    pygen_1_injF_temp = inject_bool(pygen_4_compF_temp);
                    pygen_0_ifexF_temp = pygen_1_injF_temp;
                } else {
                    pygen_4_projF_temp = project_big(i);
                    pygen_5_projF_temp = project_big(n);
                    pygen_0_callF_temp = not_equal(pygen_4_projF_temp, pygen_5_projF_temp);
                    pygen_2_injF_temp = inject_bool(pygen_0_callF_temp);
                    pygen_0_ifexF_temp = pygen_2_injF_temp;
                }
                pygen_1_ifexF_temp = pygen_0_ifexF_temp;
            }
            pygen_3_ifexF_temp = pygen_1_ifexF_temp;
        } else {
            pygen_4_tagF_temp = tag(i);
            pygen_5_compF_temp = (pygen_4_tagF_temp == 0);
            if (pygen_5_compF_temp) {
                pygen_6_projF_temp = project_int(i);
                pygen_7_projF_temp = project_bool(n);
                pygen_6_compF_temp = (pygen_6_projF_temp != pygen_7_projF_temp);
                pygen_3_injF_temp = inject_bool(pygen_6_compF_temp);
                pygen_2_ifexF_temp = pygen_3_injF_temp;
            } else {
                pygen_8_projF_temp = project_bool(i);
                pygen_9_projF_temp = project_int(n);
                pygen_7_compF_temp = (pygen_8_projF_temp != pygen_9_projF_temp);
                pygen_4_injF_temp = inject_bool(pygen_7_compF_temp);
                pygen_2_ifexF_temp = pygen_4_injF_temp;
            }
            pygen_3_ifexF_temp = pygen_2_ifexF_temp;
        }
        pygen_2_let_temp = pygen_3_ifexF_temp;
        pygen_5_tagF_temp = tag(pygen_2_let_temp);
        pygen_8_compF_temp = (pygen_5_tagF_temp == 0);
        if (pygen_8_compF_temp) {
            pygen_10_projF_temp = project_int(pygen_2_let_temp);
            pygen_9_compF_temp = (0 != pygen_10_projF_temp);
            pygen_5_ifexF_temp = pygen_9_compF_temp;
        } else {
            pygen_6_tagF_temp = tag(pygen_2_let_temp);
            pygen_10_compF_temp = (pygen_6_tagF_temp == 1);
            if (pygen_10_compF_temp) {
                pygen_11_projF_temp = project_bool(pygen_2_let_temp);
                pygen_11_compF_temp = (0 != pygen_11_projF_temp);
                pygen_4_ifexF_temp = pygen_11_compF_temp;
            } else {
                pygen_1_callF_temp = is_true(pygen_2_let_temp);
                pygen_4_ifexF_temp = pygen_1_callF_temp;
            }
            pygen_5_ifexF_temp = pygen_4_ifexF_temp;
        }
    }
    print_any(t);
}
void composition_input(struct All_variables *E)
{
    int i;
    int m = E->parallel.me;
    input_boolean("CDEPV",&(E->viscosity.CDEPV),"off",m);
    E->composition.icompositional_rheology = E->viscosity.CDEPV;

    input_boolean("chemical_buoyancy",
		  &(E->composition.ichemical_buoyancy),
		  "1,0,nomax",m);

    if (E->control.tracer && 
	(E->composition.ichemical_buoyancy || 
	 E->composition.icompositional_rheology)) {

        /* ibuoy_type=0 (absolute method) */
        /* ibuoy_type=1 (ratio method) */

        input_int("buoy_type",&(E->composition.ibuoy_type),"1,0,nomax",m);
        /* if (E->composition.ibuoy_type!=1) {
            fprintf(stderr,"Terror-Sorry, only ratio method allowed now\n");
            fflush(stderr);
            parallel_process_termination();
        } */

        if (E->composition.ibuoy_type==0)
            E->composition.ncomp = E->trace.nflavors;
        else if (E->composition.ibuoy_type==1)
            E->composition.ncomp = E->trace.nflavors - 1;
	
        E->composition.buoyancy_ratio = (double*) malloc(E->composition.ncomp
                                                         *sizeof(double));

        /* default values .... */
        for (i=0; i<E->composition.ncomp; i++)
            E->composition.buoyancy_ratio[i] = 1.0;

        input_double_vector("buoyancy_ratio", E->composition.ncomp,
                            E->composition.buoyancy_ratio,m);

    }


    /* compositional rheology */
    /* what was this about? there is a CDEPV for compositional rheology 
       
    i moved this to the top so that cdepv = on would activate tracers

    TWB  */

    /* icompositional_rheology=0 (off) */
    /* icompositional_rheology=1 (on) */
    //E->composition.icompositional_rheology = 0;


    /*
    input_int("compositional_rheology",
              &(E->composition.icompositional_rheology),"1,0,nomax",m);

    if (E->composition.icompositional_rheology==1) {
        input_double("compositional_prefactor",
                     &(E->composition.compositional_rheology_prefactor),
                     "1.0",m);
    }
    */

    return;
}
Beispiel #17
0
int main()
{
  pyobj x = input_int();
  print_any(x);
}