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

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

ScriptTcl::~ScriptTcl (  ) 

Definition at line 2314 of file ScriptTcl.C.

References DebugM, and molfile_dcdplugin_fini().

02314                       {
02315   DebugM(3,"Destructing ScriptTcl\n");
02316 #ifdef NAMD_TCL
02317   if ( interp ) Tcl_DeleteInterp(interp);
02318   delete [] callbackname;
02319 #endif
02320 
02321   molfile_dcdplugin_fini();
02322 }


Member Function Documentation

void ScriptTcl::eval ( char *  script  ) 

Definition at line 2216 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02216                                  {
02217 
02218 #ifdef NAMD_TCL
02219   int code = Tcl_Eval(interp,script);
02220   const char *result = Tcl_GetStringResult(interp);
02221   if (*result != 0) CkPrintf("TCL: %s\n",result);
02222   if (code != TCL_OK) {
02223     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02224     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02225   }
02226 #else
02227   NAMD_bug("ScriptTcl::eval called without Tcl.");
02228 #endif
02229 
02230 }

void ScriptTcl::load ( char *  scriptFile  ) 

Definition at line 2273 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02273                                      {
02274 
02275 #ifdef NAMD_TCL
02276   int code = Tcl_EvalFile(interp,scriptFile);
02277   const char *result = Tcl_GetStringResult(interp);
02278   if (*result != 0) CkPrintf("TCL: %s\n",result);
02279   if (code != TCL_OK) {
02280     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02281     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02282   }
02283 #else
02284   NAMD_bug("ScriptTcl::load called without Tcl.");
02285 #endif
02286 
02287 }

void ScriptTcl::measure ( Vector c  ) 

Definition at line 1343 of file ScriptTcl.C.

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

Referenced by Output::coordinate().

01343                                  {
01344   Measure::createCommands(interp);
01345   Node::Object()->coords = c;
01346   measure_result = Tcl_Eval(interp,measure_command);
01347   Node::Object()->coords = 0;
01348   Measure::deleteCommands(interp);
01349 }

void ScriptTcl::run ( void   ) 

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

02290                     {
02291 #else
02292 void ScriptTcl::run(char *scriptFile) {
02293 
02294   if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) {
02295     NAMD_die("Simulation config file is empty.");
02296   }
02297 #endif
02298 
02299   if (runWasCalled == 0) {
02300     initcheck();
02301     SimParameters *simParams = Node::Object()->simParameters;
02302     if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE);
02303     else runController(SCRIPT_RUN);
02304     runWasCalled = 1;
02305   }
02306 
02307 #if CMK_HAS_PARTITION
02308   replica_barrier();
02309 #endif
02310   runController(SCRIPT_END);
02311 
02312 }

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

Definition at line 2256 of file ScriptTcl.C.

References NAMD_die().

Referenced by after_backend_init().

02256                                              {
02257   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02258   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02259   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02260   for ( int i=1; i<argc; ++i ) {
02261     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02262   }
02263   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02264   int code = Tcl_EvalFile(interp,argv[0]);
02265   if (code != TCL_OK) {
02266     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02267     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02268   }
02269 }

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

Definition at line 2234 of file ScriptTcl.C.

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

Referenced by main().

02234                                           {
02235   Tcl_Interp *interp = Tcl_CreateInterp();
02236   psfgen_static_init(interp);
02237   eabf_static_init(interp);
02238   tcl_vector_math_init(interp);
02239   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02240   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02241   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02242   for ( int i=1; i<argc; ++i ) {
02243     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02244   }
02245   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02246   int code = Tcl_EvalFile(interp,argv[0]);
02247   if (code != TCL_OK) {
02248     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02249     fprintf(stderr,"%s\n",(errorInfo ? errorInfo : "Unknown Tcl error"));
02250     return -1;
02251   }
02252   return 0;
02253 }


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 6 Dec 2019 for NAMD by  doxygen 1.6.1