示例#1
0
int init_grid_post_set_grid(FTYPE (*prim)[NSTORE2][NSTORE3][NPR], FTYPE (*pstag)[NSTORE2][NSTORE3][NPR], FTYPE (*ucons)[NSTORE2][NSTORE3][NPR], FTYPE (*vpot)[NSTORE1+SHIFTSTORE1][NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3], FTYPE (*Bhat)[NSTORE2][NSTORE3][NPR], FTYPE (*panalytic)[NSTORE2][NSTORE3][NPR], FTYPE (*pstaganalytic)[NSTORE2][NSTORE3][NPR], FTYPE (*vpotanalytic)[NSTORE1+SHIFTSTORE1][NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3], FTYPE (*Bhatanalytic)[NSTORE2][NSTORE3][NPR], FTYPE (*F1)[NSTORE2][NSTORE3][NPR], FTYPE (*F2)[NSTORE2][NSTORE3][NPR], FTYPE (*F3)[NSTORE2][NSTORE3][NPR], FTYPE (*Atemp)[NSTORE1+SHIFTSTORE1][NSTORE2+SHIFTSTORE2][NSTORE3+SHIFTSTORE3])
{
  int i,j,k;
  FTYPE X[NDIM],V[NDIM],r,th;
  extern void check_spc_singularities_user(void);

  // some calculations, althogh perhaps calculated already, definitely need to make sure computed
  Rhor=rhor_calc(0);
  Risco=rmso_calc(PROGRADERISCO);



  beta = 1.e2 ;   // AKMARK: plasma beta (pgas/pmag)
  randfact = 4.e-2; //sas: as Jon used for 3D runs but use it for 2D as well

  toruskappa = 0.01;   // AKMARK: entropy constant KK from mathematica file
  torusn = 2. - 1.97;   // AKMARK: n from mathematica file (power of lambda in DHK03)
  torusrmax = 20.;   // AKMARK: torus pressure max

  // AKMARK: torus inner radius
#if(WHICHPROBLEM==NORMALTORUS)
  //rin = Risco;
  rin = 6. ;
  toruskappa = 1e-3; 
  torusrmax = 12.; 
#elif(WHICHPROBLEM==THINDISKFROMMATHEMATICA || WHICHPROBLEM==THICKDISKFROMMATHEMATICA)
  rin = 20. ;
#elif(WHICHPROBLEM==THINTORUS)
  rin = 10. ;
#elif(WHICHPROBLEM==KEPDISK)
  //rin = (1. + h_over_r)*Risco;
  rin = Risco;
#elif(WHICHPROBLEM==GRBJET)
  rin = Risco;
#endif

  


#if( ANALYTICMEMORY == 1 && WHICHPROBLEM != THINDISKFROMMATHEMATICA && WHICHPROBLEM != THICKDISKFROMMATHEMATICA )
  //SASMARK restart: need to populate panalytic with IC's; DO NOT do this 
  //when reading the ICs in from a file since then need to carry the file around
  if( RESTARTMODE==1 ) { //restarting -> set panalytic to initital conditions
    // user function that should fill p with primitives (but use ulast so don't overwrite unew read-in from file)
    MYFUN(init_primitives(panalytic,pstaganalytic,GLOBALPOINT(utemparray),vpotanalytic,Bhatanalytic,panalytic,pstaganalytic,vpotanalytic,Bhatanalytic,F1,F2,F3,Atemp),"initbase.c:init()", "init_primitives()", 0);
    //to have initial vector potential to be saved in panalytic array
  }
#endif
  // check rmin
  check_rmin();


  // check that singularities are properly represented by code
  check_spc_singularities_user();

  
  return(0);

}
示例#2
0
文件: game.c 项目: rhencke/fuzzball
int
init_game(const char *infile, const char *outfile)
{
	FILE *f;

	if ((f = fopen(MACRO_FILE, "rb")) == NULL)
		log_status("INIT: Macro storage file %s is tweaked.", MACRO_FILE);
	else {
		macroload(f);
		fclose(f);
	}

	in_filename = (char *) string_dup(infile);
	if ((input_file = fopen(infile, "rb")) == NULL)
		return -1;

#ifdef DELTADUMPS
	if ((delta_outfile = fopen(DELTAFILE_NAME, "wb")) == NULL)
		return -1;

	if ((delta_infile = fopen(DELTAFILE_NAME, "rb")) == NULL)
		return -1;
#endif

	db_free();
	init_primitives();			/* init muf compiler */
	mesg_init();				/* init mpi interpreter */
	SRANDOM(getpid());			/* init random number generator */
	tune_load_parmsfile(NOTHING);	/* load @tune parms from file */

	/* ok, read the db in */
	log_status("LOADING: %s", infile);
	fprintf(stderr, "LOADING: %s\n", infile);
	if (db_read(input_file) < 0)
		return -1;
	log_status("LOADING: %s (done)", infile);
	fprintf(stderr, "LOADING: %s (done)\n", infile);

	/* set up dumper */
	if (dumpfile)
		free((void *) dumpfile);
	dumpfile = alloc_string(outfile);

	if (!db_conversion_flag) {
		/* initialize the _sys/startuptime property */
		add_property((dbref) 0, "_sys/startuptime", NULL, (int) time((time_t *) NULL));
		add_property((dbref) 0, "_sys/maxpennies", NULL, tp_max_pennies);
		add_property((dbref) 0, "_sys/dumpinterval", NULL, tp_dump_interval);
		add_property((dbref) 0, "_sys/max_connects", NULL, 0);
	}

	return 0;
}
示例#3
0
文件: irvm.c 项目: pablooliveira/irvm
/* IRVM entry function */
void
irvm (void)
{
  /* init IRVM modules */
  init_id ();
  init_context ();
  init_primitives ();
  init_mem ();

  /* register the destroy handler */
  atexit (destroy);

  /* parse the input */
  int status = yyparse ();
  fclose (yyin);
  if (status != 0)
    errx (1, "Parsing failed");

  /* decorate the tree */
  compute_exec_order (irtree);
  bind_labels (irtree);

  /* if necessary check that input is valid LIR */
  if (low && !checklir ())
    errx (129, "input is not valid LIR");

  /* find MAIN IR label */
  struct Node *main_label = find_label (mainid);

  if (main_label == NULL)
    errx (1, "label main not found");

  set_temp (argid[0], 0);

  /* execute the IR program */
  execute (main_label, trace);
}
/*
  Create a minimal web browser that has Emacsy integrated into it.
 */
int main(int argc, char* argv[])
{
  int err;
  // Initialize GNU Guile.
  scm_init_guile();
  // Initialize Emacsy.
  err = emacsy_initialize();
  if (err) 
    return err;

  // Register the primitive procedures that control the browser.
  init_primitives();  

  // You can evaluate S-expressions here.
  scm_c_eval_string("(use-modules (system repl error-handling))"
                    "(define (safe-load filename)              "
                    "  (call-with-error-handling               "
                    "    (lambda () (load filename))))         ");

  // But to make the application easy to mold, it's best to load the
  // Scheme code from a file.
  const char *startup_script = "emacsy-webkit-gtk-w-buffers.scm";
  if (access(startup_script, R_OK) != -1) {
    printf("Loading '%s'.\n", startup_script);

    // We could load the file like this:
    //scm_c_primitive_load(".emacy-webkit-gtk.scm");

    // But this will drop us into a REPL if anything goes wrong.
    scm_call_1(scm_c_private_ref("guile-user", "safe-load"),
               scm_from_locale_string(startup_script));
  } else {
    printf("Did not find '%s'.\n", startup_script);
  }

  // Initialize GTK+.
  gtk_init(&argc, &argv);

  // Create an 800x600 window that will contain the browser instance.
  GtkWidget *main_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_window_set_default_size(GTK_WINDOW(main_window), 800, 600);
  //gtk_window_set_size(GTK_WINDOW(main_window), 800, 600);
  
  GdkGeometry geom_struct;
  geom_struct.max_width = 800;
  geom_struct.max_height = 600;
  gtk_window_set_geometry_hints(GTK_WINDOW(main_window),
                                NULL,
                                &geom_struct,
                                GDK_HINT_MAX_SIZE);
  /* you might need to use GTK_STATE_ACTIVE or GTK_STATE_PRELIGHT */
  GdkColor black = {0, 0x0, 0x0, 0x0};
  GdkColor white = {0, 0xFFFF, 0xFFFF, 0xFFFF};
  gtk_widget_modify_bg(GTK_WINDOW(main_window), GTK_STATE_NORMAL, &black);
  gtk_widget_modify_fg(GTK_WINDOW(main_window), GTK_STATE_NORMAL, &white);

  // Create a browser instance
  /* web_view = WEBKIT_WEB_VIEW(webkit_web_view_new()); */
  /* webkit_web_view_set_highlight_text_matches(web_view, TRUE); */
  web_view = NULL;

  // Create a scrollable area, and put the browser instance into it
  scrolled_window = gtk_scrolled_window_new(NULL, NULL);
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window),
                                 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
  scm_c_eval_string("(new-tab)");
  //gtk_container_add(GTK_CONTAINER(scrolled_window), GTK_WIDGET(web_view));

  // Set up callbacks so that if either the main window or the browser
  // instance is closed, the program will exit.
  g_signal_connect(main_window, "destroy", G_CALLBACK(destroy_window), NULL);
  //g_signal_connect(web_view, "close-web-view", G_CALLBACK(close_window), main_window);


  // This label will be where we display Emacsy's echo-area.
  label = gtk_label_new("label");
  gtk_misc_set_alignment(GTK_MISC(label), 0.0f, 0.0f);
  gtk_label_set_use_underline(GTK_LABEL(label), FALSE);
  gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
  gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE);
  gtk_label_set_max_width_chars(GTK_LABEL(label), 160);

  modeline = gtk_label_new("modeline");
  gtk_misc_set_alignment(GTK_MISC(modeline), 0.0f, 0.0f);
  gtk_label_set_use_underline(GTK_LABEL(modeline), FALSE);
  gtk_label_set_line_wrap(GTK_LABEL(modeline), TRUE);
  gtk_label_set_single_line_mode(GTK_LABEL(modeline), TRUE);
  gtk_label_set_max_width_chars(GTK_LABEL(modeline), 160);


  // While idle, process events in Emacsy and upate the echo-area.
  g_idle_add((GSourceFunc) process_and_update_emacsy, NULL);

  // Handle key press and release events.
  g_signal_connect(main_window, "key_press_event", G_CALLBACK(key_press), NULL);
  g_signal_connect(main_window, "key_release_event", G_CALLBACK(key_press), NULL);
    
  GtkWidget *vbox;
  vbox = gtk_vbox_new(FALSE, 1);
  gtk_container_add(GTK_CONTAINER(vbox), scrolled_window);
  gtk_box_pack_start(GTK_BOX(vbox), modeline, FALSE, FALSE, 0);
  gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);

  // Put the scrollable area into the main window.
  gtk_container_add(GTK_CONTAINER(main_window), vbox);


  // Load a web page into the browser instance.
  webkit_web_view_load_uri(web_view, 
                           "http://shanecelis.github.io/2013/06/15/the-garden/");

  // Make sure that when the browser area becomes visible, it will get mouse
  // and keyboard events.
  gtk_widget_grab_focus(GTK_WIDGET(web_view));

  // Make sure the main window and all its contents are visible.
  gtk_widget_show_all(main_window);
  gtk_window_set_resizable(GTK_WINDOW(main_window), FALSE);

  // Run the main GTK+ event loop.
  gtk_main();

  return 0;
}