ScriptTcl Class Reference

#include <ScriptTcl.h>

List of all members.

Public Member Functions

 ScriptTcl ()
 ~ScriptTcl ()
void eval (char *script)
void load (char *scriptFile)
void run ()
void tclmain (int, char **)
void measure (Vector *)

Static Public Member Functions

static int tclsh (int, char **)

Friends

class DataExchanger
class Controller
class GlobalMasterTcl
class colvarproxy_namd

Detailed Description

Definition at line 25 of file ScriptTcl.h.


Constructor & Destructor Documentation

ScriptTcl::ScriptTcl (  ) 

Definition at line 2036 of file ScriptTcl.C.

References DebugM, eabf_static_init(), molfile_dcdplugin_init(), molfile_dcdplugin_register(), psfgen_static_init(), register_cb(), and tcl_vector_math_init().

02036                      : scriptBarrier(scriptBarrierTag) {
02037   DebugM(3,"Constructing ScriptTcl\n");
02038 #ifdef NAMD_TCL
02039   interp = 0;
02040   callbackname = 0;
02041 #endif
02042   state = new NamdState;
02043   barrierStep = 0;
02044 
02045   molfile_dcdplugin_init();
02046   molfile_dcdplugin_register(NULL, register_cb);
02047 
02048   initWasCalled = 0;
02049   runWasCalled = 0;
02050 
02051 #ifdef NAMD_TCL
02052   config = new ConfigList;
02053 
02054   // Create interpreter
02055   interp = Tcl_CreateInterp();
02056   psfgen_static_init(interp);
02057   eabf_static_init(interp);
02058   tcl_vector_math_init(interp);
02059   Tcl_CreateCommand(interp, "python", Tcl_python,
02060     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02061   Tcl_CreateCommand(interp, "startup", Tcl_startup,
02062     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02063   Tcl_CreateCommand(interp, "exit", Tcl_exit,
02064     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02065   Tcl_CreateCommand(interp, "abort", Tcl_abort,
02066     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02067   Tcl_CreateCommand(interp, "numPes", Tcl_numPes,
02068     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02069   Tcl_CreateCommand(interp, "numNodes", Tcl_numNodes,
02070     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02071   Tcl_CreateCommand(interp, "numPhysicalNodes", Tcl_numPhysicalNodes,
02072     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02073   Tcl_CreateCommand(interp, "numReplicas", Tcl_numReplicas,
02074     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02075   Tcl_CreateCommand(interp, "myReplica", Tcl_myReplica,
02076     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02077   Tcl_CreateCommand(interp, "replicaEval", Tcl_replicaEval,
02078     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02079   Tcl_CreateCommand(interp, "replicaYield", Tcl_replicaYield,
02080     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02081   Tcl_CreateCommand(interp, "replicaSendrecv", Tcl_replicaSendrecv,
02082     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02083   Tcl_CreateCommand(interp, "replicaSend", Tcl_replicaSend,
02084     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02085   Tcl_CreateCommand(interp, "replicaRecv", Tcl_replicaRecv,
02086     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02087   Tcl_CreateCommand(interp, "replicaBarrier", Tcl_replicaBarrier,
02088     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02089   Tcl_CreateCommand(interp, "replicaAtomSendrecv", Tcl_replicaAtomSendrecv,
02090     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02091   Tcl_CreateCommand(interp, "replicaAtomSend", Tcl_replicaAtomSend,
02092     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02093   Tcl_CreateCommand(interp, "replicaAtomRecv", Tcl_replicaAtomRecv,
02094     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02095   Tcl_CreateCommand(interp, "stdout", Tcl_stdout,
02096     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02097   Tcl_CreateCommand(interp, "print", Tcl_print,
02098     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02099   Tcl_CreateCommand(interp, "unknown", Tcl_config,
02100     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02101   Tcl_CreateCommand(interp, "param", Tcl_config,
02102     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02103   Tcl_CreateCommand(interp, "isset", Tcl_isset_config,
02104     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02105   Tcl_CreateCommand(interp, "istrue", Tcl_istrue_config,
02106     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02107   Tcl_CreateCommand(interp, "run", Tcl_run,
02108     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02109   Tcl_CreateCommand(interp, "minimize", Tcl_minimize,
02110     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02111   Tcl_CreateCommand(interp, "move", Tcl_move,
02112     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02113   Tcl_CreateCommand(interp, "moveallby", Tcl_moveallby,
02114     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02115   Tcl_CreateCommand(interp, "output", Tcl_output,
02116     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02117   Tcl_CreateCommand(interp, "measure", Tcl_measure,
02118     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02119   Tcl_CreateCommand(interp, "colvarbias", Tcl_colvarbias,
02120     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02121   Tcl_CreateCommand(interp, "colvarvalue", Tcl_colvarvalue,
02122     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02123   Tcl_CreateObjCommand(interp, "cv", Tcl_colvars,
02124     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02125   Tcl_CreateCommand(interp, "colvarfreq", Tcl_colvarfreq,
02126     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02127   Tcl_CreateCommand(interp, "checkpoint", Tcl_checkpoint,
02128     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02129   Tcl_CreateCommand(interp, "revert", Tcl_revert,
02130     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02131   Tcl_CreateCommand(interp, "checkpointStore", Tcl_checkpointReplica,
02132     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02133   Tcl_CreateCommand(interp, "checkpointLoad", Tcl_checkpointReplica,
02134     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02135   Tcl_CreateCommand(interp, "checkpointSwap", Tcl_checkpointReplica,
02136     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02137   Tcl_CreateCommand(interp, "checkpointFree", Tcl_checkpointReplica,
02138     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02139   Tcl_CreateCommand(interp, "reinitvels", Tcl_reinitvels,
02140     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02141   Tcl_CreateCommand(interp, "rescalevels", Tcl_rescalevels,
02142     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02143   Tcl_CreateCommand(interp, "reinitatoms", Tcl_reinitatoms,
02144     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02145   Tcl_CreateCommand(interp, "replicaDcdFile", Tcl_replicaDcdFile,
02146     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02147   Tcl_CreateCommand(interp, "callback", Tcl_callback,
02148     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02149   Tcl_CreateCommand(interp, "coorfile", Tcl_coorfile,
02150     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02151   Tcl_CreateCommand(interp, "dumpbench", Tcl_dumpbench,
02152     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02153   Tcl_CreateObjCommand(interp, "consForceConfig", Tcl_consForceConfig,
02154     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02155   Tcl_CreateCommand(interp, "reloadCharges", Tcl_reloadCharges,
02156     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02157   // BEGIN gf
02158   Tcl_CreateCommand(interp, "reloadGridforceGrid", Tcl_reloadGridforceGrid,
02159     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02160   Tcl_CreateCommand(interp, "updateGridScale", Tcl_updateGridScale,
02161     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02162   // END gf
02163 #endif
02164 
02165 }

ScriptTcl::~ScriptTcl (  ) 

Definition at line 2277 of file ScriptTcl.C.

References DebugM, and molfile_dcdplugin_fini().

02277                       {
02278   DebugM(3,"Destructing ScriptTcl\n");
02279 #ifdef NAMD_TCL
02280   if ( interp ) Tcl_DeleteInterp(interp);
02281   delete [] callbackname;
02282 #endif
02283 
02284   molfile_dcdplugin_fini();
02285 }


Member Function Documentation

void ScriptTcl::eval ( char *  script  ) 

Definition at line 2179 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02179                                  {
02180 
02181 #ifdef NAMD_TCL
02182   int code = Tcl_Eval(interp,script);
02183   const char *result = Tcl_GetStringResult(interp);
02184   if (*result != 0) CkPrintf("TCL: %s\n",result);
02185   if (code != TCL_OK) {
02186     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02187     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02188   }
02189 #else
02190   NAMD_bug("ScriptTcl::eval called without Tcl.");
02191 #endif
02192 
02193 }

void ScriptTcl::load ( char *  scriptFile  ) 

Definition at line 2236 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02236                                      {
02237 
02238 #ifdef NAMD_TCL
02239   int code = Tcl_EvalFile(interp,scriptFile);
02240   const char *result = Tcl_GetStringResult(interp);
02241   if (*result != 0) CkPrintf("TCL: %s\n",result);
02242   if (code != TCL_OK) {
02243     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02244     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02245   }
02246 #else
02247   NAMD_bug("ScriptTcl::load called without Tcl.");
02248 #endif
02249 
02250 }

void ScriptTcl::measure ( Vector c  ) 

Definition at line 1315 of file ScriptTcl.C.

References Node::coords, Measure::createCommands(), Measure::deleteCommands(), and Node::Object().

Referenced by Output::coordinate().

01315                                  {
01316   Measure::createCommands(interp);
01317   Node::Object()->coords = c;
01318   measure_result = Tcl_Eval(interp,measure_command);
01319   Node::Object()->coords = 0;
01320   Measure::deleteCommands(interp);
01321 }

void ScriptTcl::run ( void   ) 

Definition at line 2253 of file ScriptTcl.C.

References SimParameters::minimizeCGOn, NAMD_die(), Node::Object(), replica_barrier(), SCRIPT_END, SCRIPT_MINIMIZE, and Node::simParameters.

Referenced by after_backend_init().

02253                     {
02254 #else
02255 void ScriptTcl::run(char *scriptFile) {
02256 
02257   if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) {
02258     NAMD_die("Simulation config file is empty.");
02259   }
02260 #endif
02261 
02262   if (runWasCalled == 0) {
02263     initcheck();
02264     SimParameters *simParams = Node::Object()->simParameters;
02265     if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE);
02266     else runController(SCRIPT_RUN);
02267     runWasCalled = 1;
02268   }
02269 
02270 #if CMK_HAS_PARTITION
02271   replica_barrier();
02272 #endif
02273   runController(SCRIPT_END);
02274 
02275 }

void ScriptTcl::tclmain ( int  argc,
char **  argv 
)

Definition at line 2219 of file ScriptTcl.C.

References NAMD_die().

Referenced by after_backend_init().

02219                                              {
02220   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02221   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02222   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02223   for ( int i=1; i<argc; ++i ) {
02224     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02225   }
02226   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02227   int code = Tcl_EvalFile(interp,argv[0]);
02228   if (code != TCL_OK) {
02229     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02230     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02231   }
02232 }

int ScriptTcl::tclsh ( int  argc,
char **  argv 
) [static]

Definition at line 2197 of file ScriptTcl.C.

References eabf_static_init(), psfgen_static_init(), and tcl_vector_math_init().

Referenced by main().

02197                                           {
02198   Tcl_Interp *interp = Tcl_CreateInterp();
02199   psfgen_static_init(interp);
02200   eabf_static_init(interp);
02201   tcl_vector_math_init(interp);
02202   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02203   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02204   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02205   for ( int i=1; i<argc; ++i ) {
02206     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02207   }
02208   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02209   int code = Tcl_EvalFile(interp,argv[0]);
02210   if (code != TCL_OK) {
02211     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02212     fprintf(stderr,"%s\n",(errorInfo ? errorInfo : "Unknown Tcl error"));
02213     return -1;
02214   }
02215   return 0;
02216 }


Friends And Related Function Documentation

friend class colvarproxy_namd [friend]

Definition at line 59 of file ScriptTcl.h.

friend class Controller [friend]

Definition at line 57 of file ScriptTcl.h.

friend class DataExchanger [friend]

Definition at line 54 of file ScriptTcl.h.

friend class GlobalMasterTcl [friend]

Definition at line 58 of file ScriptTcl.h.


The documentation for this class was generated from the following files:

Generated on 20 Oct 2019 for NAMD by  doxygen 1.6.1