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

01965                      : scriptBarrier(scriptBarrierTag) {
01966   DebugM(3,"Constructing ScriptTcl\n");
01967 #ifdef NAMD_TCL
01968   interp = 0;
01969   callbackname = 0;
01970 #endif
01971   state = new NamdState;
01972   barrierStep = 0;
01973 
01974   molfile_dcdplugin_init();
01975   molfile_dcdplugin_register(NULL, register_cb);
01976 
01977   initWasCalled = 0;
01978   runWasCalled = 0;
01979 
01980 #ifdef NAMD_TCL
01981   config = new ConfigList;
01982 
01983   // Create interpreter
01984   interp = Tcl_CreateInterp();
01985   psfgen_static_init(interp);
01986   eabf_static_init(interp);
01987   tcl_vector_math_init(interp);
01988   Tcl_CreateCommand(interp, "python", Tcl_python,
01989     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
01990   Tcl_CreateCommand(interp, "startup", Tcl_startup,
01991     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
01992   Tcl_CreateCommand(interp, "exit", Tcl_exit,
01993     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
01994   Tcl_CreateCommand(interp, "abort", Tcl_abort,
01995     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
01996   Tcl_CreateCommand(interp, "numPes", Tcl_numPes,
01997     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
01998   Tcl_CreateCommand(interp, "numNodes", Tcl_numNodes,
01999     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02000   Tcl_CreateCommand(interp, "numPhysicalNodes", Tcl_numPhysicalNodes,
02001     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02002   Tcl_CreateCommand(interp, "numReplicas", Tcl_numReplicas,
02003     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02004   Tcl_CreateCommand(interp, "myReplica", Tcl_myReplica,
02005     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02006   Tcl_CreateCommand(interp, "replicaEval", Tcl_replicaEval,
02007     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02008   Tcl_CreateCommand(interp, "replicaYield", Tcl_replicaYield,
02009     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02010   Tcl_CreateCommand(interp, "replicaSendrecv", Tcl_replicaSendrecv,
02011     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02012   Tcl_CreateCommand(interp, "replicaSend", Tcl_replicaSend,
02013     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02014   Tcl_CreateCommand(interp, "replicaRecv", Tcl_replicaRecv,
02015     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02016   Tcl_CreateCommand(interp, "replicaBarrier", Tcl_replicaBarrier,
02017     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02018   Tcl_CreateCommand(interp, "replicaAtomSendrecv", Tcl_replicaAtomSendrecv,
02019     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02020   Tcl_CreateCommand(interp, "replicaAtomSend", Tcl_replicaAtomSend,
02021     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02022   Tcl_CreateCommand(interp, "replicaAtomRecv", Tcl_replicaAtomRecv,
02023     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02024   Tcl_CreateCommand(interp, "stdout", Tcl_stdout,
02025     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02026   Tcl_CreateCommand(interp, "print", Tcl_print,
02027     (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
02028   Tcl_CreateCommand(interp, "unknown", Tcl_config,
02029     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02030   Tcl_CreateCommand(interp, "param", Tcl_config,
02031     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02032   Tcl_CreateCommand(interp, "isset", Tcl_isset_config,
02033     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02034   Tcl_CreateCommand(interp, "istrue", Tcl_istrue_config,
02035     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02036   Tcl_CreateCommand(interp, "run", Tcl_run,
02037     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02038   Tcl_CreateCommand(interp, "minimize", Tcl_minimize,
02039     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02040   Tcl_CreateCommand(interp, "move", Tcl_move,
02041     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02042   Tcl_CreateCommand(interp, "moveallby", Tcl_moveallby,
02043     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02044   Tcl_CreateCommand(interp, "output", Tcl_output,
02045     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02046   Tcl_CreateCommand(interp, "measure", Tcl_measure,
02047     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02048   Tcl_CreateCommand(interp, "colvarbias", Tcl_colvarbias,
02049     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02050   Tcl_CreateCommand(interp, "colvarvalue", Tcl_colvarvalue,
02051     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02052   Tcl_CreateObjCommand(interp, "cv", Tcl_colvars,
02053     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02054   Tcl_CreateCommand(interp, "colvarfreq", Tcl_colvarfreq,
02055     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02056   Tcl_CreateCommand(interp, "checkpoint", Tcl_checkpoint,
02057     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02058   Tcl_CreateCommand(interp, "revert", Tcl_revert,
02059     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02060   Tcl_CreateCommand(interp, "checkpointStore", Tcl_checkpointReplica,
02061     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02062   Tcl_CreateCommand(interp, "checkpointLoad", Tcl_checkpointReplica,
02063     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02064   Tcl_CreateCommand(interp, "checkpointSwap", Tcl_checkpointReplica,
02065     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02066   Tcl_CreateCommand(interp, "checkpointFree", Tcl_checkpointReplica,
02067     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02068   Tcl_CreateCommand(interp, "reinitvels", Tcl_reinitvels,
02069     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02070   Tcl_CreateCommand(interp, "rescalevels", Tcl_rescalevels,
02071     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02072   Tcl_CreateCommand(interp, "reinitatoms", Tcl_reinitatoms,
02073     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02074   Tcl_CreateCommand(interp, "replicaDcdFile", Tcl_replicaDcdFile,
02075     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02076   Tcl_CreateCommand(interp, "callback", Tcl_callback,
02077     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02078   Tcl_CreateCommand(interp, "coorfile", Tcl_coorfile,
02079     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02080   Tcl_CreateCommand(interp, "dumpbench", Tcl_dumpbench,
02081     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02082   Tcl_CreateObjCommand(interp, "consForceConfig", Tcl_consForceConfig,
02083     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02084   Tcl_CreateCommand(interp, "reloadCharges", Tcl_reloadCharges,
02085     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02086   // BEGIN gf
02087   Tcl_CreateCommand(interp, "reloadGridforceGrid", Tcl_reloadGridforceGrid,
02088     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02089   Tcl_CreateCommand(interp, "updateGridScale", Tcl_updateGridScale,
02090     (ClientData) this, (Tcl_CmdDeleteProc *) NULL);
02091   // END gf
02092 #endif
02093 
02094 }

ScriptTcl::~ScriptTcl (  ) 

Definition at line 2206 of file ScriptTcl.C.

References DebugM, and molfile_dcdplugin_fini().

02206                       {
02207   DebugM(3,"Destructing ScriptTcl\n");
02208 #ifdef NAMD_TCL
02209   if ( interp ) Tcl_DeleteInterp(interp);
02210   delete [] callbackname;
02211 #endif
02212 
02213   molfile_dcdplugin_fini();
02214 }


Member Function Documentation

void ScriptTcl::eval ( char *  script  ) 

Definition at line 2108 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02108                                  {
02109 
02110 #ifdef NAMD_TCL
02111   int code = Tcl_Eval(interp,script);
02112   const char *result = Tcl_GetStringResult(interp);
02113   if (*result != 0) CkPrintf("TCL: %s\n",result);
02114   if (code != TCL_OK) {
02115     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02116     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02117   }
02118 #else
02119   NAMD_bug("ScriptTcl::eval called without Tcl.");
02120 #endif
02121 
02122 }

void ScriptTcl::load ( char *  scriptFile  ) 

Definition at line 2165 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02165                                      {
02166 
02167 #ifdef NAMD_TCL
02168   int code = Tcl_EvalFile(interp,scriptFile);
02169   const char *result = Tcl_GetStringResult(interp);
02170   if (*result != 0) CkPrintf("TCL: %s\n",result);
02171   if (code != TCL_OK) {
02172     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02173     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02174   }
02175 #else
02176   NAMD_bug("ScriptTcl::load called without Tcl.");
02177 #endif
02178 
02179 }

void ScriptTcl::measure ( Vector  ) 

Definition at line 1244 of file ScriptTcl.C.

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

Referenced by Output::coordinate().

01244                                  {
01245   Measure::createCommands(interp);
01246   Node::Object()->coords = c;
01247   measure_result = Tcl_Eval(interp,measure_command);
01248   Node::Object()->coords = 0;
01249   Measure::deleteCommands(interp);
01250 }

void ScriptTcl::run (  ) 

Definition at line 2182 of file ScriptTcl.C.

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

Referenced by after_backend_init().

02182                     {
02183 #else
02184 void ScriptTcl::run(char *scriptFile) {
02185 
02186   if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) {
02187     NAMD_die("Simulation config file is empty.");
02188   }
02189 #endif
02190 
02191   if (runWasCalled == 0) {
02192     initcheck();
02193     SimParameters *simParams = Node::Object()->simParameters;
02194     if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE);
02195     else runController(SCRIPT_RUN);
02196     runWasCalled = 1;
02197   }
02198 
02199 #if CMK_HAS_PARTITION
02200   replica_barrier();
02201 #endif
02202   runController(SCRIPT_END);
02203 
02204 }

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

Definition at line 2148 of file ScriptTcl.C.

References NAMD_die().

Referenced by after_backend_init().

02148                                              {
02149   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02150   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02151   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02152   for ( int i=1; i<argc; ++i ) {
02153     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02154   }
02155   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02156   int code = Tcl_EvalFile(interp,argv[0]);
02157   if (code != TCL_OK) {
02158     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02159     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02160   }
02161 }

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

Definition at line 2126 of file ScriptTcl.C.

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

Referenced by main().

02126                                           {
02127   Tcl_Interp *interp = Tcl_CreateInterp();
02128   psfgen_static_init(interp);
02129   eabf_static_init(interp);
02130   tcl_vector_math_init(interp);
02131   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02132   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02133   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02134   for ( int i=1; i<argc; ++i ) {
02135     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02136   }
02137   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02138   int code = Tcl_EvalFile(interp,argv[0]);
02139   if (code != TCL_OK) {
02140     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02141     fprintf(stderr,"%s\n",(errorInfo ? errorInfo : "Unknown Tcl error"));
02142     return -1;
02143   }
02144   return 0;
02145 }


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 Mon Jun 18 01:17:20 2018 for NAMD by  doxygen 1.4.7