00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022 #include <string.h>
00023 #include "tcl.h"
00024 #include "TclCommands.h"
00025 #include "tcl_commands.h"
00026 #include "config.h"
00027 #include "utilities.h"
00028 #include "CUDAKernels.h"
00029 #include "WKFThreads.h"
00030 #include "vmd.h"
00031
00032 class VMDApp;
00033
00034 #define SIMPLE_TCL_OPT(string,result) \
00035 if (!strcmp(argv[1], string)) { \
00036 Tcl_AppendResult(interp, result, NULL); \
00037 return TCL_OK; \
00038 }
00039
00040 static int vmdinfo_tcl(ClientData, Tcl_Interp *interp,
00041 int argc, const char *argv[]) {
00042 VMDApp *app = (VMDApp *)Tcl_GetAssocData(interp, "VMDApp", NULL);
00043
00044 if (argc == 2) {
00045 SIMPLE_TCL_OPT("version", VMDVERSION);
00046 SIMPLE_TCL_OPT("versionmsg", VERSION_MSG);
00047 SIMPLE_TCL_OPT("authors", VMD_AUTHORS);
00048 SIMPLE_TCL_OPT("arch", VMD_ARCH);
00049 SIMPLE_TCL_OPT("options", VMD_OPTIONS);
00050 SIMPLE_TCL_OPT("www", VMD_HOMEPAGE);
00051 SIMPLE_TCL_OPT("wwwhelp", VMD_HELPPAGE);
00052
00053
00054
00055 if (!strcmp(argv[1], "freemem")) {
00056 long vmdcorefree = vmd_get_avail_physmem_mb();
00057 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00058 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(vmdcorefree));
00059 Tcl_SetObjResult(interp, tcl_result);
00060 return TCL_OK;
00061 }
00062
00063
00064
00065 if (!strcmp(argv[1], "numcpus")) {
00066 #if defined(VMDTHREADS)
00067 int numcpus = wkf_thread_numprocessors();
00068 #else
00069 int numcpus = 1;
00070 #endif
00071 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00072 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(numcpus));
00073 Tcl_SetObjResult(interp, tcl_result);
00074 return TCL_OK;
00075 }
00076
00077
00078
00079 if (!strcmp(argv[1], "cpuaffinity")) {
00080 int numcpus = -1;
00081 int *cpuaffinitylist = NULL;
00082
00083 #if defined(VMDTHREADS)
00084 cpuaffinitylist = wkf_cpu_affinitylist(&numcpus);
00085 #endif
00086 if (numcpus > 0 && cpuaffinitylist != NULL) {
00087 int i;
00088 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00089 for (i=0; i<numcpus; i++)
00090 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(cpuaffinitylist[i]));
00091 Tcl_SetObjResult(interp, tcl_result);
00092 return TCL_OK;
00093 }
00094
00095 if (cpuaffinitylist != NULL)
00096 free(cpuaffinitylist);
00097
00098 Tcl_AppendResult(interp, "CPU affinity query unavailable on this platform", NULL);
00099 return TCL_ERROR;
00100 }
00101
00102
00103
00104 if (!strcmp(argv[1], "numcudadevices")) {
00105 int numdevices;
00106 #if defined(VMDCUDA)
00107 vmd_cuda_num_devices(&numdevices);
00108 #else
00109 numdevices = 0;
00110 #endif
00111 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00112 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(numdevices));
00113 Tcl_SetObjResult(interp, tcl_result);
00114 return TCL_OK;
00115 }
00116
00117
00118 if (!strcmp(argv[1], "dispdev")) {
00119 const char *disp = VMDgetDisplayTypeName();
00120 Tcl_AppendResult(interp, disp, NULL);
00121 return TCL_OK;
00122 }
00123
00124
00125 if (!strcmp(argv[1], "nodename")) {
00126 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00127 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewStringObj(app->par_name(), strlen(app->par_name())));
00128 Tcl_SetObjResult(interp, tcl_result);
00129 return TCL_OK;
00130 }
00131
00132
00133 if (!strcmp(argv[1], "noderank")) {
00134 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00135 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(app->par_rank()));
00136 Tcl_SetObjResult(interp, tcl_result);
00137 return TCL_OK;
00138 }
00139
00140
00141 if (!strcmp(argv[1], "nodecount")) {
00142 Tcl_Obj *tcl_result = Tcl_NewListObj(0, NULL);
00143 Tcl_ListObjAppendElement(interp, tcl_result, Tcl_NewIntObj(app->par_size()));
00144 Tcl_SetObjResult(interp, tcl_result);
00145 return TCL_OK;
00146 }
00147 }
00148
00149 Tcl_AppendResult(interp,
00150 "vmdinfo: version | versionmsg | authors | arch | \n"
00151 "freemem | numcpus | cpuaffinity | numcudadevices | \n"
00152 "displaytype | nodename | noderank | nodecount | \n"
00153 "options | www | wwwhelp", NULL);
00154 return TCL_ERROR;
00155 }
00156
00157
00158 int Vmd_Init(Tcl_Interp *interp) {
00159 VMDApp *app = (VMDApp *)Tcl_GetAssocData(interp, "VMDApp", NULL);
00160
00161 Tcl_CreateCommand(interp, "vmdinfo", vmdinfo_tcl,
00162 (ClientData) NULL, (Tcl_CmdDeleteProc *) NULL);
00163
00164 Tcl_CreateCommand(interp, "vmdbench", text_cmd_vmdbench,
00165 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00166
00167 Tcl_CreateCommand(interp, "animate", text_cmd_animate,
00168 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00169
00170 Tcl_CreateCommand(interp, "color", text_cmd_color,
00171 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00172
00173 Tcl_CreateCommand(interp, "axes", text_cmd_axes,
00174 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00175
00176 Tcl_CreateCommand(interp, "display", text_cmd_display,
00177 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00178
00179 Tcl_CreateCommand(interp, "imd", text_cmd_imd,
00180 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00181
00182 Tcl_CreateCommand(interp, "vmdcollab", text_cmd_collab,
00183 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00184
00185 Tcl_CreateCommand(interp, "vmd_label", text_cmd_label,
00186 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00187
00188 Tcl_CreateCommand(interp, "light", text_cmd_light,
00189 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00190
00191 Tcl_CreateCommand(interp, "pointlight", text_cmd_point_light,
00192 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00193
00194 Tcl_CreateCommand(interp, "material", text_cmd_material,
00195 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00196
00197 Tcl_CreateCommand(interp, "vmd_menu", text_cmd_menu,
00198 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00199
00200 Tcl_CreateCommand(interp, "stage", text_cmd_stage,
00201 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00202
00203 Tcl_CreateCommand(interp, "light", text_cmd_light,
00204 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00205
00206 Tcl_CreateCommand(interp, "user", text_cmd_user,
00207 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00208
00209 Tcl_CreateCommand(interp, "mol", text_cmd_mol,
00210 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00211
00212 Tcl_CreateCommand(interp, "molecule", text_cmd_mol,
00213 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00214
00215 Tcl_CreateCommand(interp, "mouse", text_cmd_mouse,
00216 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00217
00218 Tcl_CreateCommand(interp, "mobile", text_cmd_mobile,
00219 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00220
00221 Tcl_CreateCommand(interp, "spaceball", text_cmd_spaceball,
00222 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00223
00224 Tcl_CreateCommand(interp, "plugin", text_cmd_plugin,
00225 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00226
00227 Tcl_CreateCommand(interp, "render", text_cmd_render,
00228 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00229
00230 #if defined(VMDTK) && !defined(_MSC_VER)
00231 Tcl_CreateCommand(interp, "tkrender", text_cmd_tkrender,
00232 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00233 #endif
00234
00235 Tcl_CreateCommand(interp, "rock", text_cmd_rock,
00236 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00237
00238 Tcl_CreateCommand(interp, "rotate", text_cmd_rotate,
00239 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00240
00241 Tcl_CreateCommand(interp, "rotmat", text_cmd_rotmat,
00242 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00243
00244 Tcl_CreateCommand(interp, "vmd_scale", text_cmd_scale,
00245 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00246
00247 Tcl_CreateCommand(interp, "translate", text_cmd_translate,
00248 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00249
00250 Tcl_CreateCommand(interp, "sleep", text_cmd_sleep,
00251 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00252
00253 Tcl_CreateCommand(interp, "tool", text_cmd_tool,
00254 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00255
00256 Tcl_CreateObjCommand(interp, "measure", obj_measure,
00257 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00258
00259 Tcl_CreateObjCommand(interp, "rawtimestep", cmd_rawtimestep,
00260 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00261
00262 Tcl_CreateObjCommand(interp, "gettimestep", cmd_gettimestep,
00263 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00264
00265 #ifdef VMDPYTHON
00266 Tcl_CreateCommand(interp, "gopython", text_cmd_gopython,
00267 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00268 #endif
00269
00270 #if defined(VMDTKCON)
00271 Tcl_CreateObjCommand(interp,"vmdcon",tcl_vmdcon,
00272 (ClientData)NULL, (Tcl_CmdDeleteProc*)NULL);
00273 #endif
00274
00275 Tcl_CreateObjCommand(interp, "volmap", obj_volmap,
00276 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00277
00278 Tcl_CreateCommand(interp, "parallel", text_cmd_parallel,
00279 (ClientData) app, (Tcl_CmdDeleteProc *) NULL);
00280
00281 return TCL_OK;
00282 }
00283