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 2104 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().

02104                      : scriptBarrier(scriptBarrierTag) {
02105   DebugM(3,"Constructing ScriptTcl\n");
02106 #ifdef NAMD_TCL
02107   interp = 0;
02108   callbackname = 0;
02109 #endif
02110   state = new NamdState;
02111   barrierStep = 0;
02112 
02113   molfile_dcdplugin_init();
02114   molfile_dcdplugin_register(NULL, register_cb);
02115 
02116   initWasCalled = 0;
02117   runWasCalled = 0;
02118 
02119 #ifdef NAMD_TCL
02120   config = new ConfigList;
02121 
02122   // Create interpreter
02123   interp = Tcl_CreateInterp();
02124   psfgen_static_init(interp);
02125   eabf_static_init(interp);
02126   tcl_vector_math_init(interp);
02127   Tcl_CreateCommand(interp, "python", Tcl_python,
02128     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02129   Tcl_CreateCommand(interp, "startup", Tcl_startup,
02130     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02131   Tcl_CreateCommand(interp, "exit", Tcl_exit,
02132     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02133   Tcl_CreateCommand(interp, "abort", Tcl_abort,
02134     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02135   Tcl_CreateCommand(interp, "numPes", Tcl_numPes,
02136     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02137   Tcl_CreateCommand(interp, "numNodes", Tcl_numNodes,
02138     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02139   Tcl_CreateCommand(interp, "numPhysicalNodes", Tcl_numPhysicalNodes,
02140     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02141   Tcl_CreateCommand(interp, "numReplicas", Tcl_numReplicas,
02142     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02143   Tcl_CreateCommand(interp, "myReplica", Tcl_myReplica,
02144     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02145   Tcl_CreateCommand(interp, "replicaEval", Tcl_replicaEval,
02146     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02147   Tcl_CreateCommand(interp, "replicaYield", Tcl_replicaYield,
02148     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02149   Tcl_CreateCommand(interp, "replicaSendrecv", Tcl_replicaSendrecv,
02150     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02151   Tcl_CreateCommand(interp, "replicaSend", Tcl_replicaSend,
02152     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02153   Tcl_CreateCommand(interp, "replicaRecv", Tcl_replicaRecv,
02154     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02155   Tcl_CreateCommand(interp, "replicaBarrier", Tcl_replicaBarrier,
02156     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02157   Tcl_CreateCommand(interp, "replicaAtomSendrecv", Tcl_replicaAtomSendrecv,
02158     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02159   Tcl_CreateCommand(interp, "replicaAtomSend", Tcl_replicaAtomSend,
02160     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02161   Tcl_CreateCommand(interp, "replicaAtomRecv", Tcl_replicaAtomRecv,
02162     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02163   Tcl_CreateCommand(interp, "stdout", Tcl_stdout,
02164     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02165   Tcl_CreateCommand(interp, "print", Tcl_print,
02166     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02167   Tcl_CreateCommand(interp, "unknown", Tcl_config,
02168     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02169   Tcl_CreateCommand(interp, "param", Tcl_config,
02170     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02171   Tcl_CreateCommand(interp, "isset", Tcl_isset_config,
02172     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02173   Tcl_CreateCommand(interp, "istrue", Tcl_istrue_config,
02174     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02175   Tcl_CreateCommand(interp, "run", Tcl_run,
02176     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02177   Tcl_CreateCommand(interp, "minimize", Tcl_minimize,
02178     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02179   Tcl_CreateCommand(interp, "move", Tcl_move,
02180     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02181   Tcl_CreateCommand(interp, "moveallby", Tcl_moveallby,
02182     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02183   Tcl_CreateCommand(interp, "output", Tcl_output,
02184     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02185   Tcl_CreateCommand(interp, "measure", Tcl_measure,
02186     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02187   Tcl_CreateCommand(interp, "colvarbias", Tcl_colvarbias,
02188     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02189   Tcl_CreateCommand(interp, "colvarvalue", Tcl_colvarvalue,
02190     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02191   Tcl_CreateObjCommand(interp, "cv", Tcl_colvars,
02192     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02193   Tcl_CreateCommand(interp, "colvarfreq", Tcl_colvarfreq,
02194     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02195   Tcl_CreateCommand(interp, "checkpoint", Tcl_checkpoint,
02196     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02197   Tcl_CreateCommand(interp, "revert", Tcl_revert,
02198     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02199   Tcl_CreateCommand(interp, "checkpointStore", Tcl_checkpointReplica,
02200     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02201   Tcl_CreateCommand(interp, "checkpointLoad", Tcl_checkpointReplica,
02202     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02203   Tcl_CreateCommand(interp, "checkpointSwap", Tcl_checkpointReplica,
02204     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02205   Tcl_CreateCommand(interp, "checkpointFree", Tcl_checkpointReplica,
02206     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02207   Tcl_CreateCommand(interp, "reinitvels", Tcl_reinitvels,
02208     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02209   Tcl_CreateCommand(interp, "rescalevels", Tcl_rescalevels,
02210     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02211   Tcl_CreateCommand(interp, "reinitatoms", Tcl_reinitatoms,
02212     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02213   Tcl_CreateCommand(interp, "replicaDcdFile", Tcl_replicaDcdFile,
02214     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02215   Tcl_CreateCommand(interp, "callback", Tcl_callback,
02216     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02217   Tcl_CreateCommand(interp, "coorfile", Tcl_coorfile,
02218     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02219   Tcl_CreateCommand(interp, "dumpbench", Tcl_dumpbench,
02220     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02221   Tcl_CreateObjCommand(interp, "consForceConfig", Tcl_consForceConfig,
02222     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02223   Tcl_CreateCommand(interp, "reloadCharges", Tcl_reloadCharges,
02224     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02225   // BEGIN gf
02226   Tcl_CreateCommand(interp, "reloadGridforceGrid", Tcl_reloadGridforceGrid,
02227     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02228   Tcl_CreateCommand(interp, "updateGridScale", Tcl_updateGridScale,
02229     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02230   // END gf
02231 #endif
02232 
02233 }

ScriptTcl::~ScriptTcl (  ) 

Definition at line 2345 of file ScriptTcl.C.

References DebugM, and molfile_dcdplugin_fini().

02345                       {
02346   DebugM(3,"Destructing ScriptTcl\n");
02347 #ifdef NAMD_TCL
02348   if ( interp ) Tcl_DeleteInterp(interp);
02349   delete [] callbackname;
02350 #endif
02351 
02352   molfile_dcdplugin_fini();
02353 }


Member Function Documentation

void ScriptTcl::eval ( char *  script  ) 

Definition at line 2247 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02247                                  {
02248 
02249 #ifdef NAMD_TCL
02250   int code = Tcl_Eval(interp,script);
02251   const char *result = Tcl_GetStringResult(interp);
02252   if (*result != 0) CkPrintf("TCL: %s\n",result);
02253   if (code != TCL_OK) {
02254     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02255     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02256   }
02257 #else
02258   NAMD_bug("ScriptTcl::eval called without Tcl.");
02259 #endif
02260 
02261 }

void ScriptTcl::load ( char *  scriptFile  ) 

Definition at line 2304 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02304                                      {
02305 
02306 #ifdef NAMD_TCL
02307   int code = Tcl_EvalFile(interp,scriptFile);
02308   const char *result = Tcl_GetStringResult(interp);
02309   if (*result != 0) CkPrintf("TCL: %s\n",result);
02310   if (code != TCL_OK) {
02311     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02312     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02313   }
02314 #else
02315   NAMD_bug("ScriptTcl::load called without Tcl.");
02316 #endif
02317 
02318 }

void ScriptTcl::measure ( Vector c  ) 

Definition at line 1387 of file ScriptTcl.C.

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

Referenced by Output::coordinate().

01387                                  {
01388   Measure::createCommands(interp);
01389   Node::Object()->coords = c;
01390   measure_result = Tcl_Eval(interp,measure_command);
01391   Node::Object()->coords = 0;
01392   Measure::deleteCommands(interp);
01393 }

void ScriptTcl::run ( void   ) 

Definition at line 2321 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().

02321                     {
02322 #else
02323 void ScriptTcl::run(char *scriptFile) {
02324 
02325   if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) {
02326     NAMD_die("Simulation config file is empty.");
02327   }
02328 #endif
02329 
02330   if (runWasCalled == 0) {
02331     initcheck();
02332     SimParameters *simParams = Node::Object()->simParameters;
02333     if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE);
02334     else runController(SCRIPT_RUN);
02335     runWasCalled = 1;
02336   }
02337 
02338 #if CMK_HAS_PARTITION
02339   replica_barrier();
02340 #endif
02341   runController(SCRIPT_END);
02342 
02343 }

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

Definition at line 2287 of file ScriptTcl.C.

References NAMD_die().

Referenced by after_backend_init().

02287                                              {
02288   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02289   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02290   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02291   for ( int i=1; i<argc; ++i ) {
02292     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02293   }
02294   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02295   int code = Tcl_EvalFile(interp,argv[0]);
02296   if (code != TCL_OK) {
02297     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02298     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02299   }
02300 }

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

Definition at line 2265 of file ScriptTcl.C.

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

Referenced by main().

02265                                           {
02266   Tcl_Interp *interp = Tcl_CreateInterp();
02267   psfgen_static_init(interp);
02268   eabf_static_init(interp);
02269   tcl_vector_math_init(interp);
02270   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02271   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02272   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02273   for ( int i=1; i<argc; ++i ) {
02274     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02275   }
02276   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02277   int code = Tcl_EvalFile(interp,argv[0]);
02278   if (code != TCL_OK) {
02279     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02280     fprintf(stderr,"%s\n",(errorInfo ? errorInfo : "Unknown Tcl error"));
02281     return -1;
02282   }
02283   return 0;
02284 }


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 5 Aug 2020 for NAMD by  doxygen 1.6.1