コード例 #1
0
int main(int argc, char** argv)  {
	if(argc != 3)  {
		std::cerr << "usage: " << argv[0] << " dist_file data_base" << std::endl;
		return 1;
	}
	int arg_num = 1;
	string input_filename = argv[arg_num++];

	string data_base = argv[arg_num++];
	string data_filename = data_base + "_data.dat";
	string dist_filename = data_base + "_dist.gnu";
	string angle_filename = data_base + "_angle.gnu";

	string dist_eps = data_base + "_dist.eps";
	string angle_eps = data_base + "_angle.eps";

	FILE* data_file = fopen(data_filename.c_str(), "w");
	FILE* dist_file = fopen(dist_filename.c_str(), "w");
	FILE* angle_file = fopen(angle_filename.c_str(), "w");

	FILE* input_file = fopen(input_filename.c_str(), "rb");
	if(input_file == 0)  {
		cerr << "bad dist file! " << input_filename << endl;
		return -1;
	}

	size_t num_read = 0;
	double shape_dist[8];
	num_read = fread(shape_dist, sizeof(double), 8, input_file);
	double angle_dist[8];
	num_read = fread(angle_dist, sizeof(double), 8, input_file);
	fclose(input_file);

	fprintf(data_file, "%.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f %.7f\n", shape_dist[0], shape_dist[1], shape_dist[2], shape_dist[3], shape_dist[4],
																									  angle_dist[0], angle_dist[1], angle_dist[2], angle_dist[3], angle_dist[4]);
	fclose(data_file);

	dump_init(dist_file, "Position", "error (mm)");
	dump_dist_plot(dist_file, data_filename, dist_eps, shape_dist[0], shape_dist[4]);
	dump_init(angle_file, "Normal", "error ({/Symbol \\260})");
	dump_angle_plot(angle_file, data_filename, angle_eps, angle_dist[0], angle_dist[4]);

	fclose(dist_file);
	fclose(angle_file);

	char exec_gnu_dist[300];
	sprintf(exec_gnu_dist, "gnuplot %s", dist_filename.c_str());
	char exec_gnu_angle[300];
	sprintf(exec_gnu_angle, "gnuplot %s", angle_filename.c_str());
	int result = system(exec_gnu_dist);
	result = system(exec_gnu_angle);

	char rm_exec[500];
	sprintf(rm_exec, "rm %s %s %s %s %s", data_filename.c_str(), dist_filename.c_str(), angle_filename.c_str(), dist_eps.c_str(), angle_eps.c_str());
	result = system(rm_exec);
}
コード例 #2
0
ファイル: dump.c プロジェクト: andreaaraldo/mytstat
void dump_ini_start_section(void) {
    if (current_time.tv_sec != 0) {
        dump_flush(FALSE);
    }
    old_dump_engine = dump_engine;
    dump_init();
}
コード例 #3
0
ファイル: verlet.c プロジェクト: zhekan/durkMD
void verlet(const char* filename){
dictionary* ini;
    ini = iniparser_load(filename);

    iniparser_dump(ini, stdout);
    FILE *file;
    file = fopen(LOGFILE, "a");
    iniparser_dump(ini, file);
    fclose(file);
    ReportMessage("\n");

    t_key       key  = key_init(ini);
    t_pSys      pSys = pSys_init (ini);
    t_opts      opts = opts_init (ini);
    t_pair      p    = t_pair_init(ini);
    t_dump      dump = dump_init(ini);
    t_fix       fix  = fix_init(ini);
    t_compute   compute = compute_init(ini, &key);

    init (&key, &pSys, &opts, &p, &compute);
    if(key.dump) dump_run(&key, &pSys, &opts, &dump); // Make initial snapshot.
    while(opts.thisIter < opts.targIters){  // Repeat until iterational limit.
        verlet_iter (&key, &pSys, &opts, &p, &fix, &compute);
        if(key.dump) dump_run(&key, &pSys, &opts, &dump);
        resetStep(&pSys);
    }
}
コード例 #4
0
ファイル: expr_compound_lit.c プロジェクト: 8l/ucc-c-compiler
void dump_expr_compound_lit(const expr *e, dump *ctx)
{
	decl *const d = e->bits.complit.decl;

	dump_desc_expr(ctx, "compound literal", e);

	dump_inc(ctx);
	dump_init(ctx, d->bits.var.init.dinit);
	dump_dec(ctx);
}
コード例 #5
0
void NameSuite_DebugComp_1_t::dump ( FILE* f, val_t t, dat_t<1> reset ) {
  if (t == 0L) return dump_init(f);
  fprintf(f, "#%lu\n", t << 1);
  if (clk.cnt == 0)  goto L0;
K0:  if (reset != reset__prev)  goto L1;
K1:  if (NameSuite_DebugComp_1__io_ctrl_wb_wen != NameSuite_DebugComp_1__io_ctrl_wb_wen__prev)  goto L2;
K2:  if (NameSuite_DebugComp_1_dpath__io_ctrl_wb_wen != NameSuite_DebugComp_1_dpath__io_ctrl_wb_wen__prev)  goto L3;
K3:  if (NameSuite_DebugComp_1_dpath__reset != NameSuite_DebugComp_1_dpath__reset__prev)  goto L4;
K4:  if (NameSuite_DebugComp_1_dpath__wb_reg_ll_wb != NameSuite_DebugComp_1_dpath__wb_reg_ll_wb__prev)  goto L5;
K5:  if (NameSuite_DebugComp_1_dpath__io_ctrl_out != NameSuite_DebugComp_1_dpath__io_ctrl_out__prev)  goto L6;
K6:  if (NameSuite_DebugComp_1__io_ctrl_out != NameSuite_DebugComp_1__io_ctrl_out__prev)  goto L7;
K7:  fprintf(f, "#%lu\n", (t << 1) + 1);
  if (clk.cnt == 0)  goto Z0;
C0:  return;
L0:
  clk.values[0] = 1;
  dat_dump<1>(f, clk, 0x21);
  goto K0;
L1:
  reset__prev = reset;
  dat_dump<1>(f, reset, 0x22);
  goto K1;
L2:
  NameSuite_DebugComp_1__io_ctrl_wb_wen__prev = NameSuite_DebugComp_1__io_ctrl_wb_wen;
  dat_dump<1>(f, NameSuite_DebugComp_1__io_ctrl_wb_wen, 0x23);
  goto K2;
L3:
  NameSuite_DebugComp_1_dpath__io_ctrl_wb_wen__prev = NameSuite_DebugComp_1_dpath__io_ctrl_wb_wen;
  dat_dump<1>(f, NameSuite_DebugComp_1_dpath__io_ctrl_wb_wen, 0x24);
  goto K3;
L4:
  NameSuite_DebugComp_1_dpath__reset__prev = NameSuite_DebugComp_1_dpath__reset;
  dat_dump<1>(f, NameSuite_DebugComp_1_dpath__reset, 0x25);
  goto K4;
L5:
  NameSuite_DebugComp_1_dpath__wb_reg_ll_wb__prev = NameSuite_DebugComp_1_dpath__wb_reg_ll_wb;
  dat_dump<1>(f, NameSuite_DebugComp_1_dpath__wb_reg_ll_wb, 0x26);
  goto K5;
L6:
  NameSuite_DebugComp_1_dpath__io_ctrl_out__prev = NameSuite_DebugComp_1_dpath__io_ctrl_out;
  dat_dump<1>(f, NameSuite_DebugComp_1_dpath__io_ctrl_out, 0x27);
  goto K6;
L7:
  NameSuite_DebugComp_1__io_ctrl_out__prev = NameSuite_DebugComp_1__io_ctrl_out;
  dat_dump<1>(f, NameSuite_DebugComp_1__io_ctrl_out, 0x28);
  goto K7;
Z0:
  clk.values[0] = 0;
  dat_dump<1>(f, clk, 0x21);
  goto C0;
}
コード例 #6
0
void dump_init(dump *ctx, decl_init *dinit)
{
	if(dinit == DYNARRAY_NULL){
		dump_printf(ctx, "<null init>\n");
		return;
	}

	switch(dinit->type){
		case decl_init_scalar:
		{
			dump_expr(dinit->bits.expr, ctx);
			break;
		}

		case decl_init_brace:
		{
			decl_init **i;

			dump_desc(ctx, "brace init", dinit, &dinit->where);

			dump_inc(ctx);

			for(i = dinit->bits.ar.inits; i && *i; i++)
				dump_init(ctx, *i);

			dump_dec(ctx);
			break;
		}

		case decl_init_copy:
		{
			struct init_cpy *cpy = *dinit->bits.range_copy;
			dump_init(ctx, cpy->range_init);
			break;
		}
	}
}
コード例 #7
0
ファイル: filters.c プロジェクト: ricksladkey/vile
void
flt_dump_symtab(const char *table_name)
{
    CLASS *p;

    if (table_name == 0) {
	dump_init();
	for (p = classes; p != 0; p = p->next) {
	    flt_dump_symtab(p->name);
	}
    } else if ((p = find_symtab(table_name)) != 0) {
	dump_update(p->name);
	flt_message("%ctable %s\n", dump_meta_ch, p->name);
	dump_symtab(p, dump_class);
	dump_symtab(p, dump_keyword);
    }
}
コード例 #8
0
ファイル: infocmp.c プロジェクト: vocho/openqnx
static void file_comparison(int argc, char *argv[])
{
#define MAXCOMPARE	2
    /* someday we may allow comparisons on more files */
    int	filecount = 0;
    ENTRY	*heads[MAXCOMPARE];
    ENTRY	*tails[MAXCOMPARE];
    ENTRY	*qp, *rp;
    int		i, n;

    dump_init((char *)NULL, F_LITERAL, S_TERMINFO, 0, itrace, FALSE);

    for (n = 0; n < argc && n < MAXCOMPARE; n++)
    {
	if (freopen(argv[n], "r", stdin) == NULL)
	    _nc_err_abort("Can't open %s", argv[n]);

	_nc_head = _nc_tail = (ENTRY *)NULL;

	/* parse entries out of the source file */
	_nc_set_source(argv[n]);
	_nc_read_entry_source(stdin, NULL, TRUE, FALSE, NULLHOOK);

	if (itrace)
	    (void) fprintf(stderr, "Resolving file %d...\n", n-0);

	/* do use resolution */
	if (!_nc_resolve_uses())
	{
	    (void) fprintf(stderr,
			   "There are unresolved use entries in %s:\n",
			   argv[n]);
	    for_entry_list(qp)
		if (qp->nuses)
		{
		    (void) fputs(qp->tterm.term_names, stderr);
		    (void) fputc('\n', stderr);
		}
	    exit(EXIT_FAILURE);
	}

	heads[filecount] = _nc_head;
	tails[filecount] = _nc_tail;
	filecount++;
    }
コード例 #9
0
ファイル: dump_main.c プロジェクト: kejiewei/eresi
int	 main ()
{

  int	main_sd;
  int	input_fd = 0; // =stdin

  /* create the main socket */
  main_sd = main_socket ();  

  if (main_sd == (-1))
    {
      printf ("[EE] error on main socket\n");
      exit (-1);
    }

  // XXX how to get local id ?

  /* get local id */
  
  /* initialize dump */
  dump_init ("NULL");
  printf ("[+] Dump initialized\n");

  /* install readline handler */
  rl_callback_handler_install ("dump ->", lhandler);

  atexit (rl_callback_handler_remove);
	     
  /* loops for ever */
  main_loop (main_sd, input_fd);

  /* remove readline callback handler */
  rl_callback_handler_remove();

  printf ("[EE] DUMP end ???? \n");
    
  return 0;
}
コード例 #10
0
ファイル: dump.c プロジェクト: the1sky/pytrace
void dump_thread_init(void) {
  ring = ring_from_memory((void*) RING_ADDRESS, RB_SIZE);
  dump_init();
}
コード例 #11
0
ファイル: dump.c プロジェクト: the1sky/pytrace
void dump_process_init(void) {
  ring = shared_ring_init(1);
  dump_init();
}
コード例 #12
0
ファイル: dump_barplot.cpp プロジェクト: kayarre/reconbench
int main(int argc, char** argv)  {
	if(argc != 5)  {
		std::cerr << "usage: " << argv[0] << " evaluation_base shape pc_num data_base" << std::endl;
		return 1;
	}
	int arg_num = 1;
	string eval_base = argv[arg_num++];
	string shape = argv[arg_num++];
	int pc_num = atoi(argv[arg_num++]);

	string data_base = argv[arg_num++];
	string dist_filename = data_base + "_bardist.gnu";
	string dist_dataname = data_base + "_bardist.dat";
	string dist_eps = data_base + "_dist.eps";
	string angle_filename = data_base + "_barangle.gnu";
	string angle_dataname = data_base + "_barangle.dat";
	string angle_eps = data_base + "_angle.eps";

	FILE* dist_file = fopen(dist_filename.c_str(), "w");
	FILE* dist_data_file = fopen(dist_dataname.c_str(), "w");
	FILE* angle_file = fopen(angle_filename.c_str(), "w");
	FILE* angle_data_file = fopen(angle_dataname.c_str(), "w");

	vector<string> all_algorithms;
	all_algorithms.push_back("apss");
	all_algorithms.push_back("fourier");
	all_algorithms.push_back("imls");
	all_algorithms.push_back("mpu");
	all_algorithms.push_back("mpusmooth");
	all_algorithms.push_back("poisson");
	all_algorithms.push_back("rbf");
	all_algorithms.push_back("scattered");
	all_algorithms.push_back("spss");
	all_algorithms.push_back("wavelet");

	vector<string> algorithm_titles;
	algorithm_titles.push_back("APSS");
	algorithm_titles.push_back("Fouri");
	algorithm_titles.push_back("IMLS");
	algorithm_titles.push_back("MPU");
	algorithm_titles.push_back("MPUS");
	algorithm_titles.push_back("Pois");
	algorithm_titles.push_back("RBF");
	algorithm_titles.push_back("Scat");
	algorithm_titles.push_back("SPSS");
	algorithm_titles.push_back("Wave");

	vector<double> mean_dists;
	vector<double> max_dists;
	vector<double> mean_angles;

	vector<string> titles;
	vector<int> styles;
	int line_styles = 101;

	for(unsigned a = 0; a < all_algorithms.size(); a++)  {
		string algorithm = all_algorithms[a];

		char* eval_num = new char[30];
		sprintf(eval_num, "%u", pc_num);
		string base_alg_file = eval_base+"/"+algorithm+"/"+shape+"_"+eval_num;
		string dist_filename = base_alg_file+".dist";
		FILE* dist_file = fopen(dist_filename.c_str(), "rb");

		if(dist_file == 0)  {
			cerr << "bad dist file! " << base_alg_file << endl;
			line_styles++;
			continue;
		}

		size_t num_read = 0;
		double shape_dist[8];
		num_read = fread(shape_dist, sizeof(double), 8, dist_file);
		double angle_dist[8];
		num_read = fread(angle_dist, sizeof(double), 8, dist_file);
		fclose(dist_file);

		double pc_mean_dist = shape_dist[5] > shape_dist[6] ? shape_dist[5] : shape_dist[6];
		double pc_max_dist = shape_dist[4];
		double pc_mean_angle = angle_dist[5] > angle_dist[6] ? angle_dist[5] : angle_dist[6];

		mean_dists.push_back(pc_mean_dist);
		max_dists.push_back(pc_max_dist);
		mean_angles.push_back(pc_mean_angle);

		delete [] eval_num;

		titles.push_back(algorithm_titles[a]);
		styles.push_back(line_styles);

		line_styles++;
	}

	for(unsigned i = 0; i < mean_dists.size(); i++)  {
		if(i != (mean_dists.size()-1))
			fprintf(dist_data_file, "%.7f ", mean_dists[i]);
		else
			fprintf(dist_data_file, "%.7f\n", mean_dists[i]);
	}
	for(unsigned i = 0; i < max_dists.size(); i++)  {
		if(i != (max_dists.size()-1))
			fprintf(dist_data_file, "%.7f ", max_dists[i]);
		else
			fprintf(dist_data_file, "%.7f", max_dists[i]);
	}

	for(unsigned i = 0; i < mean_angles.size(); i++)  {
		if(i != (mean_angles.size()-1))
			fprintf(angle_data_file, "%.7f ", mean_angles[i]);
		else
			fprintf(angle_data_file, "%.7f", mean_angles[i]);
	}

	dump_init(dist_file, titles.size(), "Distance (mm)");
	dump_dist_plot(dist_file, dist_dataname, dist_eps, max_dists, mean_dists, styles, titles);
	dump_init(angle_file, titles.size(), "Angle ({/Symbol \\260})");
	dump_angle_plot(angle_file, angle_dataname, angle_eps, mean_angles, styles, titles);

	fclose(dist_file);
	fclose(angle_file);
	fclose(dist_data_file);
	fclose(angle_data_file);
}
コード例 #13
0
ファイル: numatop.c プロジェクト: anyc/numatop
/*
 * The main function.
 */
int
main(int argc, char *argv[])
{
	int ret = 1, debug_level = 0;
	FILE *log = NULL, *dump = NULL;
	char c;

	/*
	 * The numatop requires some authorities to setup perf and increase the hard limit of
	 * fd. So either the user runs as root or following condtions need to be satisfied.
	 *
	 * 1. Set "-1" in /proc/sys/kernel/perf_event_paranoid to let the non-root be able to
	 *    setup perf. e.g.
	 *    echo -1 > /proc/sys/kernel/perf_event_paranoid
	 *
	 * 2. The CAP_SYS_RESOURCE capability is required to user for increasing the hard
	 *    limit of fd.
	 */

	g_sortkey = SORT_KEY_CPU;
	g_precise = PRECISE_NORMAL;
	g_numatop_pid = getpid();
	g_run_secs = TIME_NSEC_MAX;
	optind = 1;
	opterr = 0;

	/*
	 * Parse command line arguments.
	 */
	while ((c = getopt(argc, argv, "d:l:o:f:t:hf:s:")) != EOF) {
		switch (c) {
		case 'h':
			print_usage(argv[0]);
			ret = 0;
			goto L_EXIT0;

		case 'l':
			debug_level = atoi(optarg);
			if ((debug_level < 0) || (debug_level > 2)) {
				stderr_print("Invalid log_level %d.\n",
				    debug_level);
				print_usage(argv[0]);
				goto L_EXIT0;
			}
			break;

		case 'f':
			if (optarg == NULL) {
				stderr_print("Invalid output file.\n");
				goto L_EXIT0;
			}

			if ((log = fopen(optarg, "w")) == NULL) {
				stderr_print("Cannot open '%s' for writing.\n",
				    optarg);
				goto L_EXIT0;
			}
			break;

		case 's':
			if (optarg == NULL) {
				print_usage(argv[0]);
				goto L_EXIT0;
			}

			if (strcasecmp(optarg, "high") == 0) {
				g_precise = PRECISE_HIGH;
				break;
			}

			if (strcasecmp(optarg, "low") == 0) {
				g_precise = PRECISE_LOW;
				break;
			}

			if (strcasecmp(optarg, "normal") == 0) {
				g_precise = PRECISE_NORMAL;
				break;
			}

			stderr_print("Invalid sampling_precision '%s'.\n",
			    optarg);
			print_usage(argv[0]);
			goto L_EXIT0;

		case 'd':
			if (optarg == NULL) {
				stderr_print("Invalid dump file.\n");
				goto L_EXIT0;
			}

			if ((dump = fopen(optarg, "w")) == NULL) {
				stderr_print("Cannot open '%s' for dump.\n",
				    optarg);
				goto L_EXIT0;
			}
			break;

		case 't':
			g_run_secs = atoi(optarg);
			if (g_run_secs <= 0) {
				stderr_print("Invalid run time %d.\n",
				    g_run_secs);
				print_usage(argv[0]);
				goto L_EXIT0;
			}
			break;

		case ':':
			stderr_print("Missed argument for option %c.\n",
			    optopt);
			print_usage(argv[0]);
			goto L_EXIT0;

		case '?':
			stderr_print("Unrecognized option %c.\n", optopt);
			print_usage(argv[0]);
			goto L_EXIT0;
		}
	}

	if (plat_detect() != 0) {
		stderr_print("CPU is not supported!\n");
		ret = 2;
		goto L_EXIT0;
	}

	/*
	 * It could be failed if user doesn't have authority.
	 */
	(void) ulimit_expand(PERF_FD_NUM);

	/*
	 * Get the number of online cores in system.
	 */
	if ((g_ncpus = sysfs_online_ncpus()) == -1) {
		stderr_print("Platform is not supported "
		    "(numatop supports up to %d CPUs)\n", NCPUS_MAX);
		goto L_EXIT0;
	}

	pagesize_init();
	gettimeofday(&g_tvbase, 0);

	if (debug_init(debug_level, log) != 0) {
		goto L_EXIT1;
	}

	debug_print(NULL, 2, "Detected %d online CPU.\n", g_ncpus);
	log = NULL;
	sym_init();

	if (dump_init(dump) != 0) {
		goto L_EXIT2;
	}

	dump = NULL;

	/*
	 * Calculate how many nanoseconds for a TSC cycle.
	 */
	calibrate();

	/*
	 * Initialize for the "window-switching" table.
	 */
	switch_table_init();

	if (proc_group_init() != 0) {
		goto L_EXIT3;
	}

	if (node_group_init() != 0) {
		stderr_print("The node/cpu number is out of range, \n"
			"numatop supports up to %d nodes and %d CPUs\n",
			NNODES_MAX, NCPUS_MAX);
		goto L_EXIT4;
	}

	if (disp_cons_ctl_init() != 0) {
		goto L_EXIT5;
	}

	/*
	 * Catch signals from terminal.
	 */
	if ((signal(SIGINT, sigint_handler) == SIG_ERR) ||
	    (signal(SIGHUP, sigint_handler) == SIG_ERR) ||
	    (signal(SIGQUIT, sigint_handler) == SIG_ERR) ||
	    (signal(SIGTERM, sigint_handler) == SIG_ERR) ||
	    (signal(SIGPIPE, sigint_handler) == SIG_ERR)) {
		goto L_EXIT6;
	}

	/*
	 * Initialize the perf sampling facility.
	 */
	if (perf_init() != 0) {
		debug_print(NULL, 2, "perf_init() is failed\n");
		goto L_EXIT6;
	}

	/*
	 * Initialize for display and create console thread & display thread.
	 */
	if (disp_init() != 0) {
		perf_fini();
		goto L_EXIT6;
	}

	/*
	 * Wait the disp thread to exit. The disp thread would
	 * exit when user hits the hotkey 'Q' or press "CTRL+C".
	 */
	disp_dispthr_quit_wait();

	/*
	 * Notify cons thread to exit.
	 */
	disp_consthr_quit();
	
	disp_fini();
	stderr_print("NumaTOP is exiting ...\n");
	(void) fflush(stdout);
	ret = 0;

L_EXIT6:
	disp_cons_ctl_fini();

L_EXIT5:
	node_group_fini();

L_EXIT4:
	proc_group_fini();

L_EXIT3:
	dump_fini();

L_EXIT2:
	sym_fini();
	debug_fini();

L_EXIT1:
	exit_msg_print();

L_EXIT0:
	if (dump != NULL) {
		(void) fclose(dump);
	}

	if (log != NULL) {
		(void) fclose(log);
	}

	return (ret);
}
コード例 #14
0
ファイル: main.c プロジェクト: roderickmackenzie/opvdm
int main(int argc, char *argv[])
{
    cal_path();
    setlocale(LC_MESSAGES, "");
    bindtextdomain("opvdm", get_lang_path());
    textdomain("opvdm");

    timer_init(0);
    timer_init(1);
    dbus_init();
    set_ewe_lock_file("", "");
    cell.onlypos = FALSE;

    char pwd[1000];
    if (getcwd(pwd, 1000) == NULL) {
        ewe("IO error\n");
    }

    dump_init(&cell);
    dump_load_config(&cell);

    remove("snapshots.zip");
    remove("light_dump.zip");

    hard_limit_init();

//char path[PATH_MAX];
//char dest[PATH_MAX];
//pid_t pid = getpid();
//sprintf(path, "/proc/%d/exe", pid);

//if (readlink(path, dest, PATH_MAX) == -1)
//{
//      printf("error\n");
//      exit(1);
//}
//  char *base = strrchr(dest, '/');
//*base='/';
//*(base+1)=0;
    set_plot_script_dir(pwd);

//set_plot_script_dir(char * in)
    if (scanarg(argv, argc, "--help") == TRUE) {
        printf("opvdm_core - Organic Photovoltaic Device Model\n");
        printf(copyright);
        printf("\n");
        printf("Usage: opvdm_core [options]\n");
        printf("\n");
        printf("Options:\n");
        printf("\n");
        printf("\t--outputpath\toutput data path");
        printf("\t--inputpath\t sets the input path\n");
        printf("\t--version\tdisplays the current version\n");
        printf("\t--zip_results\t zip the results\n");
        printf("\t--optics\t runs only optical simulation\n");
        printf("\t--cpus\t sets the number of CPUs\n");
        printf("\n");
        printf
        ("Additional information about opvdm is available at www.opvdm.com.\n");
        printf("\n");
        printf
        ("Report bugs to: [email protected]\n\n");
        exit(0);
    }
    if (scanarg(argv, argc, "--version") == TRUE) {
        printf("opvdm_core, Version %s\n", opvdm_ver);
        printf(copyright);
        printf(this_is_free_software);
        printf
        ("There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or\n");
        printf("FITNESS FOR A PARTICULAR PURPOSE.\n");
        printf("\n");
        exit(0);
    }

    if (geteuid() == 0) {
        ewe("Don't run me as root!\n");
    }

    set_dump_status(dump_stop_plot, FALSE);
    set_dump_status(dump_print_text, TRUE);

    set_io_dump(FALSE);
    srand(time(0));
    textcolor(fg_green);
    randomprint(_("Organic Photovoltaic Device Model (www.opvdm.com)\n"));
    randomprint(_
                ("You should have received a copy of the GNU General Public License\n"));
    randomprint(_
                ("along with this software.  If not, see www.gnu.org/licenses/.\n"));
    randomprint("\n");
    randomprint(_
                ("If you wish to collaborate in anyway please get in touch:\n"));
    randomprint(_("[email protected]\n"));
    randomprint(_("www.roderickmackenzie.eu/contact.html\n"));
    randomprint("\n");
    textcolor(fg_reset);

    globalserver.on = FALSE;
    globalserver.cpus = 1;
    globalserver.readconfig = TRUE;

    if (scanarg(argv, argc, "--outputpath") == TRUE) {
        strcpy(sim_output_path(),
               get_arg_plusone(argv, argc, "--outputpath"));
    } else {
        strcpy(sim_output_path(), pwd);
    }

    if (scanarg(argv, argc, "--inputpath") == TRUE) {
        strcpy(sim_input_path(),
               get_arg_plusone(argv, argc, "--inputpath"));
    } else {
        strcpy(sim_input_path(), sim_output_path());
    }

    dump_load_config(&cell);

    if (scanarg(argv, argc, "--onlypos") == TRUE) {
        cell.onlypos = TRUE;
    }

    char name[200];
    struct inp_file inp;
    inp_init(&inp);
    inp_load_from_path(&inp, sim_input_path(), "ver.inp");
    inp_check(&inp, 1.0);
    inp_search_string(&inp, name, "#core");
    inp_free(&inp);

    if (strcmp(name, opvdm_ver) != 0) {
        printf
        ("Software is version %s and the input files are version %s\n",
         opvdm_ver, name);
        exit(0);
    }

    gui_start();
    if (scanarg(argv, argc, "--optics") == FALSE)
        server_init(&globalserver);

    if (scanarg(argv, argc, "--lock") == TRUE) {
        server_set_dbus_finish_signal(&globalserver,
                                      get_arg_plusone(argv, argc,
                                              "--lock"));
    }

    int ret = 0;

    int do_fit = FALSE;

    if (scanarg(argv, argc, "--fit") == TRUE)
        do_fit = TRUE;

    FILE *f = fopen("fit.inp", "r");
    if (f != NULL) {
        fclose(f);
        inp_init(&inp);
        inp_load_from_path(&inp, pwd, "fit.inp");
        int fit_temp;
        inp_search_int(&inp, &fit_temp, "#do_fit");
        if (fit_temp == 1) {
            do_fit = TRUE;
        }

        inp_free(&inp);
    }

    if (do_fit == TRUE) {
        set_dump_status(dump_lock, FALSE);
        set_dump_status(dump_print_text, FALSE);
        set_dump_status(dump_iodump, FALSE);
        set_dump_status(dump_optics, FALSE);
        set_dump_status(dump_newton, FALSE);
        set_dump_status(dump_plot, FALSE);
        set_dump_status(dump_stop_plot, FALSE);
        set_dump_status(dump_opt_for_fit, FALSE);
        set_dump_status(dump_print_newtonerror, FALSE);
        set_dump_status(dump_print_converge, FALSE);
        set_dump_status(dump_print_pos_error, FALSE);
        set_dump_status(dump_lock, TRUE);
    }
#include "main_args.c"
    if (scanarg(argv, argc, "--optics") == TRUE) {
        gui_start();
        struct light two;
        light_init(&two, &cell, pwd);
        //light_set_dx(&cell.mylight,cell.ymesh[1]-cell.ymesh[0]);
        light_load_config(&two);
        two.disable_transfer_to_electrical_mesh = TRUE;
        set_dump_status(dump_lock, FALSE);
        set_dump_status(dump_optics, TRUE);
        set_dump_status(dump_optics_verbose, TRUE);
        double Psun;
        inp_init(&inp);
        inp_load_from_path(&inp, pwd, "light.inp");
        inp_search_double(&inp, &(Psun), "#Psun");
        Psun = 1.0;	//fabs(Psun);
        inp_free(&inp);

        light_solve_and_update(&cell, &two, Psun, 0.0);
        light_dump(&two);
        light_free(&two);
        complex_solver_free();
    } else {
        gen_dos_fd_gaus_fd();

        server_add_job(&globalserver, cell.outputpath, cell.inputpath);
        print_jobs(&globalserver);
        ret = server_run_jobs(&globalserver);

    }

    server_shut_down(&globalserver);

    if (scanarg(argv, argc, "--zip_results") == TRUE) {
        printf("zipping results\n");
        int ret;
        char temp[200];
        DIR *dir = opendir("snapshots");
        if (dir) {
            closedir(dir);
            ret =
                system("zip -r -j -q snapshots.zip ./snapshots/*");
            if (ret == -1) {
                printf("tar returned error\n");
            }

            join_path(2, temp, cell.outputpath, "snapshots");
            remove_dir(temp);

        }

        dir = opendir("light_dump");
        if (dir) {
            closedir(dir);
            ret =
                system
                ("zip -r -j -q light_dump.zip ./light_dump/*");
            if (ret == -1) {
                printf("tar returned error\n");
            }

            join_path(2, temp, cell.outputpath, "light_dump");
            remove_dir(temp);

        }

    }

    hard_limit_free();
    if (ret != 0) {
        return 1;
    }
    return 0;
}
コード例 #15
0
ファイル: cgaln.c プロジェクト: rnakato/Cgaln
static void argv_init(int argc, char **argv){
  int i;
  int nseq=0;
  global_variable_initialization();

  for(i=1; i<argc; i++){
    if(!strcmp(argv[i], "-r"))            reverse = 1;
    else if(!strcmp(argv[i], "-b"))       block = 1;
    else if(!strcmp(argv[i], "-debug"))   opt.debug = 1;
    else if(!strcmp(argv[i], "-nc"))      opt.chaining = 0;
    else if(!strcmp(argv[i], "-ia"))      iterative = 1;
    else if(!strcmp(argv[i], "-noext"))   ext_gappeddp = 0;
    else if(!strcmp(argv[i], "-sr"))      short_reverse = 1;
    else if(!strcmp(argv[i], "-pr"))      printregion = 1;
    else if(!strcmp(argv[i], "-fc"))      filtercln = 1;
    else if(!strcmp(argv[i], "-cons"))    consistent = 1;
    else if(!strcmp(argv[i], "-k1"))      par.kmer_ba = 11;
    else if(!strcmp(argv[i], "-k2"))      par.kmer_ba = 12;
    else if(!strcmp(argv[i], "-k3"))      par.kmer_ba = 13;
    else if(!strcmp(argv[i], "-t"))       strcpy(par.tabledir, argv[++i]);
    else if(!strcmp(argv[i], "-o"))       strcpy(par.outputfile, argv[++i]);
    else if(!strcmp(argv[i], "-nl"))      opt.boundary = 0;
    else if(!strncmp(argv[i], "-K", 2))   par.kmer_ba   = atoi(argv[i]+2);
    else if(!strncmp(argv[i], "-BS", 3))  par.blocksize = atoi(argv[i]+3);
    else if(!strncmp(argv[i], "-X", 2))   par.xdrop     = atoi(argv[i]+2);
    else if(!strncmp(argv[i], "-R", 2))   par.x_d_ratio = atoi(argv[i]+2);
    else if(!strncmp(argv[i], "-otype", 6)) opt.otype   = atoi(argv[i]+6);
    else{
      if(nseq==0){
	strcpy(idata_a->seqname, argv[i]);
	nseq++;
      }else if(nseq==1){
	strcpy(idata_b->seqname, argv[i]);
	nseq++;
      }else{
	nseq++;
      }
    }
  }
  if(nseq!=2){
    fprintf(stderr, "irregal inputfile number:%d\n", nseq);
    goto err;
  }
  if(!strcmp(par.outputfile, "")){
    fprintf(stderr, "please specify outputfile name.\n");
    goto err;
  }
  define_xdrop_and_shiftp(par.kmer_ba, par.blocksize);

  if(block) opt.otype=0;

  /*--- read summary ---*/
  read_summary(idata_a);
  read_summary(idata_b);
  dump_init();
  return;

 err:
  printf(Usage);
  exit(0);
}
コード例 #16
0
ファイル: trace.c プロジェクト: alonho/pytrace
static PyObject*
start_dumper(PyObject *self, PyObject *args) {
  dump_init(ring);
  dump_thread_start();
  return Py_BuildValue("");
}
コード例 #17
0
ファイル: jpmidi.c プロジェクト: jerash/jpmidi
int jpmidi_init()
{
    dump_init();
    listeners = g_array_new( FALSE, FALSE, sizeof( jpmidi_loadfile_listener_t));
    return 1; // Success
}
コード例 #18
0
ファイル: main.c プロジェクト: jerash/jpmidi
int main(int argc, char **argv)
{
    char opts[NELEM(long_opts) * 3 + 1];
    char *cp;
    int  c;
    struct option *op;

    /* Build up the short option string */
    cp = opts;
    for (op = long_opts; op < &long_opts[NELEM(long_opts)]; op++) {
        *cp++ = op->val;
        if (op->has_arg)
            *cp++ = ':';
    }


    /* Deal with the options */
    for (;;) {
        c = getopt_long(argc, argv, opts, long_opts, NULL);
        if (c == -1)
            break;

        switch(c) {
        case 'v':
            main_showversion();
            exit(0);
        case 'd':
            be_jack_client = 0;
            break;
	case 's':
	    be_server = 1;
	    break;
        default:
            main_showusage();
            exit(1);
        }
    }

    if (optind >= argc) {
        printf("No input files!\n");
        main_showusage();
        exit( 1);
    }

    if (optind < argc-1) {
        printf("Too many input files!\n");
        main_showusage();
        exit( 1);
    }

    if (!jpmidi_init()) {
        fprintf( stderr, "Failed to initialize jpmidi, errno = %d\n", errno);
        exit( errno);
    }

    dump_init();

    jack_nframes_t jack_sample_rate = 44100;
    
    if (be_jack_client)
    {
        if (jackclient_new( "jpmidi")) return 1;
        
        jack_sample_rate = jack_get_sample_rate(jackclient_get_client());
    }
    else printf("Not connecting to jack, assuming sample rate of %d\n", jack_sample_rate);


    root = jpmidi_loadfile(argv[optind], jack_sample_rate);
    printf("loaded %s\n", root->filename);

    if (be_jack_client && jackclient_activate()) return 1;
    
    /* launch either command line or server mode */
    if (be_server)
    {
	tcpserver(TCPPORT);
    }
    else
    {
	cmdline();
    }

    if (be_jack_client && jackclient_deactivate()) return 1;
    if (be_jack_client && jackclient_close()) return 1;
    
    return 0;
}
コード例 #19
0
void dump_decl(decl *d, dump *ctx, const char *desc)
{
	const int is_func = !!type_is(d->ref, type_func);
	type *ty;

	if(!desc){
		if(d->spel){
			desc = is_func ? "function" : "variable";
		}else{
			desc = "type";
		}
	}

	dump_desc_colour_newline(ctx, desc, d, &d->where,
			maybe_colour(ctx->fout, col_desc_decl), 0);

	if(d->proto)
		dump_printf_indent(ctx, 0, " prev %p", (void *)d->proto);

	if(d->spel)
		dump_printf_indent(ctx, 0, " %s", d->spel);

	dump_type(ctx, d->ref);

	if(d->store)
		dump_printf_indent(ctx, 0, " %s", decl_store_to_str(d->store));

	dump_printf_indent(ctx, 0, "\n");

	if(!is_func){
		type *tof = type_skip_non_tdefs(d->ref);
		if(tof->type == type_tdef && !tof->bits.tdef.decl){
			/* show typeof expr */
			dump_inc(ctx);
			dump_expr(tof->bits.tdef.type_of, ctx);
			dump_dec(ctx);
		}

		if(d->bits.var.field_width){
			dump_inc(ctx);
			dump_expr(d->bits.var.field_width, ctx);
			dump_dec(ctx);
		}

		if(!d->spel){
			dump_sue(ctx, d->ref);
		}else if(d->bits.var.init.dinit){
			dump_inc(ctx);
			dump_init(ctx, d->bits.var.init.dinit);
			dump_dec(ctx);
		}
	}

	dump_inc(ctx);
	dump_attributes(d->attr, ctx);
	ty = type_skip_non_attr(d->ref);
	if(ty && ty->type == type_attr)
		dump_attributes(ty->bits.attr, ctx);
	dump_dec(ctx);

	if(is_func && d->bits.func.code){
		funcargs *fa = type_funcargs(d->ref);

		dump_inc(ctx);
		dump_args(fa, ctx);
		dump_stmt(d->bits.func.code, ctx);
		dump_dec(ctx);
	}
}
コード例 #20
0
ファイル: sim_run.c プロジェクト: roderickmackenzie/gpvdm
int run_simulation(struct simulation *sim)
{
struct device cell;
log_clear(sim);

printf_log(sim,_("Run_simulation\n"));

device_init(&cell);
cell.onlypos=FALSE;

dump_init(sim,&cell);

set_dump_status(sim,dump_stop_plot, FALSE);
set_dump_status(sim,dump_print_text, TRUE);


char temp[1000];

cell.kl_in_newton=FALSE;

//if (strcmp(outputpath,"")!=0) strcpy(get_output_path(sim),outputpath);

//if (strcmp(inputpath,"")!=0) strcpy(get_input_path(sim),inputpath);

dump_load_config(sim,&cell);

int i;
int z;
int x;
int y;


join_path(2,temp,get_output_path(sim),"error.dat");
remove(temp);

join_path(2,temp,get_output_path(sim),"equilibrium");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"snapshots");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"light_dump");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"dynamic");
remove_dir(sim,temp);

join_path(2,temp,get_output_path(sim),"frequency");
remove_dir(sim,temp);



load_config(sim,&cell);

if (strcmp(sim->force_sim_mode,"")!=0)
{
	strcpy(cell.simmode,sim->force_sim_mode);
}

if (strcmp(cell.simmode,"opticalmodel@optics")!=0)
{
	solver_init(sim,cell.solver_name);
	newton_init(sim,cell.newton_name);

	printf_log(sim,_("Loading DoS for %d layers\n"),cell.my_epitaxy.electrical_layers);
	char tempn[100];
	char tempp[100];
	i=0;

	for (i=0;i<cell.my_epitaxy.electrical_layers;i++)
	{
		dos_init(&cell,i);
		printf_log(sim,"Load DoS %d/%d\n",i,cell.my_epitaxy.electrical_layers);
		sprintf(tempn,"%s_dosn.dat",cell.my_epitaxy.dos_file[i]);
		sprintf(tempp,"%s_dosp.dat",cell.my_epitaxy.dos_file[i]);
		load_dos(sim,&cell,tempn,tempp,i);
	}

	device_alloc_traps(&cell);

	if (get_dump_status(sim,dump_write_converge)==TRUE)
	{
	sim->converge = fopena(get_output_path(sim),"converge.dat","w");
	fclose(sim->converge);

	sim->tconverge=fopena(get_output_path(sim),"tconverge.dat","w");
	fclose(sim->tconverge);
	}

	mesh_cal_layer_widths(&cell);

	long double depth=0.0;
	long double percent=0.0;
	long double value=0.0;
	for (z=0;z<cell.zmeshpoints;z++)
	{
		for (x=0;x<cell.xmeshpoints;x++)
		{
			for (y=0;y<cell.ymeshpoints;y++)
			{

				depth=cell.ymesh[y]-cell.layer_start[cell.imat[z][x][y]];
				percent=depth/cell.layer_width[cell.imat[z][x][y]];
				cell.Nad[z][x][y]=get_dos_doping_start(&cell,cell.imat[z][x][y])+(get_dos_doping_stop(&cell,cell.imat[z][x][y])-get_dos_doping_start(&cell,cell.imat[z][x][y]))*percent;
			}
		}		
		
	}

	init_mat_arrays(&cell);




	for (z=0;z<cell.zmeshpoints;z++)
	{
		for (x=0;x<cell.xmeshpoints;x++)
		{
			for (y=0;y<cell.ymeshpoints;y++)
			{
				cell.phi[z][x][y]=0.0;
				cell.R[z][x][y]=0.0;
				cell.n[z][x][y]=0.0;
			}
		}
	}

	contacts_load(sim,&cell);

	cell.C=cell.xlen*cell.zlen*epsilon0*cell.epsilonr[0][0][0]/(cell.ylen+cell.other_layers);
	if (get_dump_status(sim,dump_print_text)==TRUE) printf_log(sim,"C=%Le\n",cell.C);
	cell.A=cell.xlen*cell.zlen;
	cell.Vol=cell.xlen*cell.zlen*cell.ylen;

	///////////////////////light model
	char old_model[100];
	gdouble old_Psun=0.0;
	old_Psun=light_get_sun(&cell.mylight);
	light_init(&cell.mylight);
	light_set_dx(&cell.mylight,cell.ymesh[1]-cell.ymesh[0]);
	light_load_config(sim,&cell.mylight);

	if (cell.led_on==TRUE)
	{
		strcpy(old_model,cell.mylight.mode);
		strcpy(cell.mylight.mode,"ray");
	}
	
	light_load_dlls(sim,&cell.mylight);
	light_setup_ray(sim,&cell,&cell.mylight);

	if (cell.led_on==TRUE)
	{
		cell.mylight.force_update=TRUE;

		light_set_sun(&(cell.mylight),1.0);
		light_set_sun_delta_at_wavelength(&(cell.mylight),cell.led_wavelength);
		light_solve_all(sim,&(cell.mylight));
		
		cell.mylight.force_update=FALSE;
		strcpy(cell.mylight.mode,old_model);
		light_set_sun(&(cell.mylight),old_Psun);
		light_free_dlls(sim,&cell.mylight);
		light_load_dlls(sim,&cell.mylight);
	}
	///////////////////////

	//update_arrays(&cell);

	contact_set_all_voltages(sim,&cell,0.0);
	get_initial(sim,&cell);

	remesh_shrink(&cell);

	if (cell.math_enable_pos_solver==TRUE)
	{
		for (z=0;z<cell.zmeshpoints;z++)
		{
			for (x=0;x<cell.xmeshpoints;x++)
			{
				solve_pos(sim,&cell,z,x);
			}
		}
	}


	time_init(sim,&cell);

	cell.N=0;
	cell.M=0;

	solver_realloc(sim,&cell);



	plot_open(sim);


	cell.go_time=FALSE;

	plot_now(sim,"plot");
	//set_solver_dump_every_matrix(1);

	find_n0(sim,&cell);
	//set_solver_dump_every_matrix(0);
	draw_gaus(&cell);


	if (cell.onlypos==TRUE)
	{
		join_path(2,temp,get_output_path(sim),"equilibrium");
		dump_1d_slice(sim,&cell,temp);
		device_free(sim,&cell);
		device_free_traps(&cell);
		mesh_free(sim,&cell);
		return 0;
	}
}


//Load the dll
if (is_domain(cell.simmode)!=0)
{
	char gussed_full_mode[200];
	if (guess_whole_sim_name(sim,gussed_full_mode,get_input_path(sim),cell.simmode)==0)
	{
		printf_log(sim,"I guess we are using running %s\n",gussed_full_mode);
		strcpy(cell.simmode,gussed_full_mode);
	}else
	{
		ewe(sim,"I could not guess which simulation to run from the mode %s\n",cell.simmode);
	}


}

run_electrical_dll(sim,&cell,strextract_domain(cell.simmode));


if (strcmp(cell.simmode,"opticalmodel@optics")!=0)
{
	device_free(sim,&cell);
	device_free_traps(&cell);
	mesh_free(sim,&cell);
	plot_close(sim);

	for (i=0;i<cell.my_epitaxy.electrical_layers;i++)
	{
		dos_free(&cell,i);
	}
	solver_free_memory(sim,&cell);

	newton_interface_free(sim);
	light_free(sim,&cell.mylight);
}



return cell.odes;
}