int appinit(Tcl_Interp *interp)
{
  if (Tcl_Init(interp) == TCL_ERROR)
    return TCL_ERROR;

#ifdef TK
  if (Tk_Init(interp) == TCL_ERROR)
    return TCL_ERROR;
#endif

  /*
    installation of tcl commands
  */
  register_tcl_commands(interp);
  register_global_variables(interp);

  /* evaluate the Tcl initialization script */
  char *scriptdir = getenv("ESPRESSO_SCRIPTS");
  if (!scriptdir)
    scriptdir = get_default_scriptsdir();
  
  /*  fprintf(stderr,"Script directory: %s\n", scriptdir);*/

  char cwd[1024];
  if ((getcwd(cwd, 1024) == NULL) || (chdir(scriptdir) != 0)) {
    fprintf(stderr,
	    "\n\ncould not change to script dir %s, please check ESPRESSO_SCRIPTS.\n\n\n",
	    scriptdir);
    exit(1);
  }
  if (Tcl_EvalFile(interp, "init.tcl") == TCL_ERROR) {
    fprintf(stderr, "\n\nerror in initialization script: %s\n\n\n",
	    Tcl_GetStringResult(interp));
    exit(1);
  }
  if (chdir(cwd) != 0) {
    fprintf(stderr,
	    "\n\ncould not change back to execution dir %s ????\n\n\n",
	    cwd);
    exit(1);
  }

  return (TCL_OK);
}
Beispiel #2
0
static void init_tcl(Tcl_Interp *interp)
{
  char cwd[1024];
  char *scriptdir;

  /*
    installation of tcl commands
  */

  /* in cells.c */
  REGISTER_COMMAND("cellsystem", tclcommand_cellsystem);
  /* in integrate.c */
  REGISTER_COMMAND("invalidate_system", tclcommand_invalidate_system);
  REGISTER_COMMAND("integrate", tclcommand_integrate);
  /* in global.c */
  REGISTER_COMMAND("setmd", tclcommand_setmd);
  /* in grid.c */
  REGISTER_COMMAND("change_volume", tclcommand_change_volume);
  /* in global.c */
  REGISTER_COMMAND("code_info", tclcommand_code_info);
  /* in interaction_data.c */
  REGISTER_COMMAND("inter",tclcommand_inter);
  /* in particle_data.c */
  REGISTER_COMMAND("part",tclcommand_part);
  /* in file binaryfile.c */
  REGISTER_COMMAND("writemd", tclcommand_writemd);
  REGISTER_COMMAND("readmd", tclcommand_readmd);
  /* in file statistics.c */
  REGISTER_COMMAND("analyze", tclcommand_analyze);
  /* in file polymer.c */
  REGISTER_COMMAND("polymer", tclcommand_polymer);
  REGISTER_COMMAND("counterions", tclcommand_counterions);
  REGISTER_COMMAND("salt", tclcommand_salt);
  REGISTER_COMMAND("velocities", tclcommand_velocities);
  REGISTER_COMMAND("maxwell_velocities", tclcommand_maxwell_velocities);
  REGISTER_COMMAND("crosslink", tclcommand_crosslink);
  REGISTER_COMMAND("diamond", tclcommand_diamond);
  REGISTER_COMMAND("icosaeder", tclcommand_icosaeder);
  /* in file imd.c */
  REGISTER_COMMAND("imd", tclcommand_imd);
  /* in file random.c */
  REGISTER_COMMAND("t_random", tclcommand_t_random);
  REGISTER_COMMAND("bit_random", tclcommand_bit_random);
  /* in file blockfile_tcl.c */
  REGISTER_COMMAND("blockfile", tclcommand_blockfile);
  /* in constraint.c */
  REGISTER_COMMAND("constraint", tclcommand_constraint);
  /* in uwerr.c */
  REGISTER_COMMAND("uwerr", tclcommand_uwerr);
  /* in nemd.c */
  REGISTER_COMMAND("nemd", tclcommand_nemd);
  /* in thermostat.c */
  REGISTER_COMMAND("thermostat", tclcommand_thermostat);
  /* in bin.c */
  REGISTER_COMMAND("bin", tclcommand_bin);
  /* in lb.c */

  REGISTER_COMMAND("lbfluid", tclcommand_lbfluid);
  REGISTER_COMMAND("lbnode", tclcommand_lbnode);
  REGISTER_COMMAND("lbboundary", tclcommand_lbboundary);
  /* in utils.h */
  REGISTER_COMMAND("replacestdchannel", tclcommand_replacestdchannel);
  /* in iccp3m.h */
#ifdef ELECTROSTATICS
#ifdef ELP3M
  REGISTER_COMMAND("iccp3m", tclcommand_iccp3m);
#endif 
#endif 
  /* in adresso.h */
  REGISTER_COMMAND("adress", tclcommand_adress);
#ifdef ADRESS
  /** #ifdef THERMODYNAMIC_FORCE */
  REGISTER_COMMAND("thermodynamic_force", tclcommand_thermodynamic_force);
  /** #endif */
  REGISTER_COMMAND("update_adress_weights", tclcommand_update_adress_weights);
#endif
#ifdef METADYNAMICS
  /* in metadynamics.c */
  REGISTER_COMMAND("metadynamics", tclcommand_metadynamics);
#endif
#ifdef LB_GPU
  /* in lbgpu_cfile.c */
  REGISTER_COMMAND("lbnode_exf", tclcommand_lbnode_extforce_gpu);

  REGISTER_COMMAND("lbprint", tclcommand_lbprint_gpu);
#endif
#ifdef CUDA
  REGISTER_COMMAND("cuda", tclcommand_cuda);
#endif

  /* evaluate the Tcl initialization script */
  scriptdir = getenv("ESPRESSO_SCRIPTS");
  if (!scriptdir)
    scriptdir = get_default_scriptsdir();
  
  fprintf(stderr,"%d: Script directory: %s\n", this_node, scriptdir);

  if ((getcwd(cwd, 1024) == NULL) || (chdir(scriptdir) != 0)) {
    fprintf(stderr,
	    "\n\ncould not change to script dir %s, please check ESPRESSO_SCRIPTS.\n\n\n",
	    scriptdir);
    exit(-1);
  }
  if (Tcl_EvalFile(interp, "init.tcl") == TCL_ERROR) {
    fprintf(stderr, "\n\nerror in initialization script: %s\n\n\n",
	    Tcl_GetStringResult(interp));
    exit(-1);
  }
  if (chdir(cwd) != 0) {
    fprintf(stderr,
	    "\n\ncould not change back to execution dir %s ????\n\n\n",
	    cwd);
    exit(-1);
  }
}