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 26 of file ScriptTcl.h.


Constructor & Destructor Documentation

ScriptTcl::ScriptTcl (  ) 

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

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

ScriptTcl::~ScriptTcl (  ) 

Definition at line 2195 of file ScriptTcl.C.

References DebugM, and molfile_dcdplugin_fini().

02195                       {
02196   DebugM(3,"Destructing ScriptTcl\n");
02197 #ifdef NAMD_TCL
02198   if ( interp ) Tcl_DeleteInterp(interp);
02199   delete [] callbackname;
02200 #endif
02201 
02202   molfile_dcdplugin_fini();
02203 }


Member Function Documentation

void ScriptTcl::eval ( char *  script  ) 

Definition at line 2097 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02097                                  {
02098 
02099 #ifdef NAMD_TCL
02100   int code = Tcl_Eval(interp,script);
02101   const char *result = Tcl_GetStringResult(interp);
02102   if (*result != 0) CkPrintf("TCL: %s\n",result);
02103   if (code != TCL_OK) {
02104     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02105     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02106   }
02107 #else
02108   NAMD_bug("ScriptTcl::eval called without Tcl.");
02109 #endif
02110 
02111 }

void ScriptTcl::load ( char *  scriptFile  ) 

Definition at line 2154 of file ScriptTcl.C.

References NAMD_bug(), and NAMD_die().

Referenced by after_backend_init().

02154                                      {
02155 
02156 #ifdef NAMD_TCL
02157   int code = Tcl_EvalFile(interp,scriptFile);
02158   const char *result = Tcl_GetStringResult(interp);
02159   if (*result != 0) CkPrintf("TCL: %s\n",result);
02160   if (code != TCL_OK) {
02161     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02162     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02163   }
02164 #else
02165   NAMD_bug("ScriptTcl::load called without Tcl.");
02166 #endif
02167 
02168 }

void ScriptTcl::measure ( Vector  ) 

Definition at line 1233 of file ScriptTcl.C.

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

Referenced by Output::coordinate().

01233                                  {
01234   Measure::createCommands(interp);
01235   Node::Object()->coords = c;
01236   measure_result = Tcl_Eval(interp,measure_command);
01237   Node::Object()->coords = 0;
01238   Measure::deleteCommands(interp);
01239 }

void ScriptTcl::run (  ) 

Definition at line 2171 of file ScriptTcl.C.

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

Referenced by after_backend_init().

02171                     {
02172 #else
02173 void ScriptTcl::run(char *scriptFile) {
02174 
02175   if ( NULL == scriptFile || NULL == (config = new ConfigList(scriptFile)) ) {
02176     NAMD_die("Simulation config file is empty.");
02177   }
02178 #endif
02179 
02180   if (runWasCalled == 0) {
02181     initcheck();
02182     SimParameters *simParams = Node::Object()->simParameters;
02183     if ( simParams->minimizeCGOn ) runController(SCRIPT_MINIMIZE);
02184     else runController(SCRIPT_RUN);
02185     runWasCalled = 1;
02186   }
02187 
02188 #if CMK_HAS_PARTITION
02189   replica_barrier();
02190 #endif
02191   runController(SCRIPT_END);
02192 
02193 }

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

Definition at line 2137 of file ScriptTcl.C.

References NAMD_die().

Referenced by after_backend_init().

02137                                              {
02138   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02139   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02140   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02141   for ( int i=1; i<argc; ++i ) {
02142     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02143   }
02144   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02145   int code = Tcl_EvalFile(interp,argv[0]);
02146   if (code != TCL_OK) {
02147     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02148     NAMD_die(errorInfo ? errorInfo : "Unknown Tcl error");
02149   }
02150 }

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

Definition at line 2115 of file ScriptTcl.C.

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

Referenced by main().

02115                                           {
02116   Tcl_Interp *interp = Tcl_CreateInterp();
02117   psfgen_static_init(interp);
02118   eabf_static_init(interp);
02119   tcl_vector_math_init(interp);
02120   Tcl_SetVar(interp, "argv0", argv[0], TCL_GLOBAL_ONLY);
02121   Tcl_SetVar2Ex(interp, "argc", NULL, Tcl_NewIntObj(argc-1), TCL_GLOBAL_ONLY);
02122   Tcl_Obj *argvPtr = Tcl_NewListObj(0, NULL);
02123   for ( int i=1; i<argc; ++i ) {
02124     Tcl_ListObjAppendElement(NULL, argvPtr, Tcl_NewStringObj(argv[i],-1));
02125   }
02126   Tcl_SetVar2Ex(interp, "argv", NULL, argvPtr, TCL_GLOBAL_ONLY);
02127   int code = Tcl_EvalFile(interp,argv[0]);
02128   if (code != TCL_OK) {
02129     const char *errorInfo = Tcl_GetVar(interp,"errorInfo",0);
02130     fprintf(stderr,"%s\n",(errorInfo ? errorInfo : "Unknown Tcl error"));
02131     return -1;
02132   }
02133   return 0;
02134 }


Friends And Related Function Documentation

friend class colvarproxy_namd [friend]

Definition at line 60 of file ScriptTcl.h.

friend class Controller [friend]

Definition at line 58 of file ScriptTcl.h.

friend class DataExchanger [friend]

Definition at line 55 of file ScriptTcl.h.

friend class GlobalMasterTcl [friend]

Definition at line 59 of file ScriptTcl.h.


The documentation for this class was generated from the following files:
Generated on Mon Sep 25 01:17:20 2017 for NAMD by  doxygen 1.4.7