Index: /trunk/gui/scripts/visviewer.tcl
===================================================================
--- /trunk/gui/scripts/visviewer.tcl	(revision 4096)
+++ /trunk/gui/scripts/visviewer.tcl	(revision 4097)
@@ -36,10 +36,12 @@
     private variable _afterId -1
     private variable _icon 0
-    # Number of milliseconds to wait before idle timeout.  If greater than 0,
-    # automatically disconnect from the visualization server when idle timeout
-    # is reached.
+
+    # Number of milliseconds to wait before idle timeout.  If greater than
+    # 0, automatically disconnect from the visualization server when idle
+    # timeout is reached.
     private variable _idleTimeout 43200000; # 12 hours
     #private variable _idleTimeout 5000;    # 5 seconds
     #private variable _idleTimeout 0;       # No timeout
+
     protected variable _maxConnects 100
     protected variable _outbuf       ;    # buffer for outgoing commands
@@ -285,5 +287,14 @@
             continue
         }
-        puts stderr "render server is $data"
+        # The response should be in the form "serverName major.minor ...".
+        set pattern {^[A-Za-z]+ [0-9].[0-9].*}
+
+        while { ![regexp $pattern $data match] } {
+            puts stderr "$data"
+            if { [gets $_sid data] <= 0 } {
+                exit -1
+            }
+        }
+        puts stderr "Render server is $data"
         # We're connected. Cancel any pending serverDown events and
         # release the busy window over the hull.
@@ -388,6 +399,6 @@
 #
 #   Helper routine called from a file event to send data when the
-#   connection is writable (i.e. not blocked).  Sets a magic
-#   variable _done($this) when we're done.
+#   connection is writable (i.e. not blocked).  Sets a magic variable
+#   _done($this) when we're done.
 #
 itcl::body Rappture::VisViewer::SendHelper {} {
@@ -404,8 +415,8 @@
 #
 #   Helper routine called from a file event to send data when the
-#   connection is writable (i.e. not blocked).  Sends data in chunks 
-#   of 8k (or less).  Sets magic variable _done($this) to indicate
-#   that we're either finished (success) or could not send bytes to
-#   the server (failure).
+#   connection is writable (i.e. not blocked).  Sends data in chunks of 8k
+#   (or less).  Sets magic variable _done($this) to indicate that we're
+#   either finished (success) or could not send bytes to the server
+#   (failure).
 #
 itcl::body Rappture::VisViewer::SendHelper.old {} {
@@ -455,6 +466,7 @@
     set _buffer(out) ""
     if { [IsConnected] } {
-        # The connection may have closed while we were writing to the server.
-        # This can happen if what we sent the server caused it to barf.
+        # The connection may have closed while we were writing to the
+        # server.  This can happen if what we sent the server caused it to
+        # barf.
         fileevent $_sid writable ""
         flush $_sid
@@ -504,8 +516,8 @@
 # ReceiveHelper --
 #
-#   Helper routine called from a file event when the connection is 
-#   readable (i.e. a command response has been sent by the rendering 
-#   server.  Reads the incoming command and executes it in a safe 
-#   interpreter to handle the action.
+#   Helper routine called from a file event when the connection is readable
+#   (i.e. a command response has been sent by the rendering server.  Reads
+#   the incoming command and executes it in a safe interpreter to handle
+#   the action.
 #
 #       Note: This routine currently only handles command responses from
@@ -561,6 +573,6 @@
 # Color2RGB --
 #
-#   Converts a color name to a list of r,g,b values needed for the
-#   engine.  Each r/g/b component is scaled in the # range 0-1.
+#   Converts a color name to a list of r,g,b values needed for the engine.
+#   Each r/g/b component is scaled in the # range 0-1.
 #
 itcl::body Rappture::VisViewer::Color2RGB {color} {
@@ -589,8 +601,8 @@
 # SendEcho --
 #
-#     Used internally to echo sent data to clients interested in this widget.
-#     If the -sendcommand option is set, then it is invoked in the global scope
-#     with the <channel> and <data> values as arguments.  Otherwise, this does
-#     nothing.
+#     Used internally to echo sent data to clients interested in this
+#     widget.  If the -sendcommand opti on is set, then it is invoked in
+#     the global scope with the <channel> and <data> values as arguments.
+#     Otherwise, this does nothing.
 #
 itcl::body Rappture::VisViewer::SendEcho {channel {data ""}} {
@@ -610,7 +622,7 @@
 #
 #     Echoes received data to clients interested in this widget.  If the
-#     -receivecommand option is set, then it is invoked in the global
-#     scope with the <channel> and <data> values as arguments.  Otherwise,
-#     this does nothing.
+#     -receivecommand option is set, then it is invoked in the global scope
+#     with the <channel> and <data> values as arguments.  Otherwise, this
+#     does nothing.
 #
 itcl::body Rappture::VisViewer::ReceiveEcho {channel {data ""}} {
Index: /trunk/packages/vizservers/nanoscale/renderservers.tcl.in
===================================================================
--- /trunk/packages/vizservers/nanoscale/renderservers.tcl.in	(revision 4096)
+++ /trunk/packages/vizservers/nanoscale/renderservers.tcl.in	(revision 4097)
@@ -81,6 +81,9 @@
 #
 register_server vmdshow 2018 {
-    /usr/bin/vmd -startup ${libdir}/vmd/vmdserver.tcl -args -stdio
+    ${libdir}/vmd/vmd_LINUXAMD64 -startup ${libdir}/vmd/vmdserver.tcl -args -stdio
 } {
+    VMDDIR ${libdir}/vmd
+    SURF_BIN ${libdir}/vmd/surf
     LD_LIBRARY_PATH ${libdir}
 }
+
Index: /trunk/packages/vizservers/vmd/INSTALL.txt
===================================================================
--- /trunk/packages/vizservers/vmd/INSTALL.txt	(revision 4097)
+++ /trunk/packages/vizservers/vmd/INSTALL.txt	(revision 4097)
@@ -0,0 +1,46 @@
+
+# 1. Create a build directory
+
+mkdir build
+cd build
+
+# 2. Untar the vmd and plugin sources
+#    This creates a "plugins" and "vmd-1.9.1" subdirectories.
+
+tar -xvf ../vmd-1.9.1.src.tar.gz
+
+BUILDDIR=$PWD/vmd-1.9.1
+
+patch -p1 < ../vmd-hubzero.patch
+
+# 3. Build the plugins.
+
+cd plugins
+
+PLUGINDIR=$BUILDDIR/plugin
+
+# Use the dated rappture directory, not the link.
+RPDIR=/opt/hubzero/rappture/20130724
+
+export PLUGINDIR
+
+# 3. Build the plugins.
+
+make LINUXAMD64 TCLINC=-I$RPDIR/include TCLLIB=-L$RPDIR/lib
+
+# 3. Install the plugins.
+
+make distrib
+
+# 3. Build vmd itself.
+
+cd ../vmd-1.9.1
+
+mkdir LINUXAMD64
+
+cd src
+
+make RPDIR=$RPDIR
+make install
+
+
Index: /trunk/packages/vizservers/vmd/vmd-hubzero.patch
===================================================================
--- /trunk/packages/vizservers/vmd/vmd-hubzero.patch	(revision 4097)
+++ /trunk/packages/vizservers/vmd/vmd-hubzero.patch	(revision 4097)
@@ -0,0 +1,370 @@
+diff -u -r ../orig/plugins/Make-arch ./plugins/Make-arch
+--- ../orig/plugins/Make-arch	2011-09-17 22:55:03.000000000 -0400
++++ ./plugins/Make-arch	2013-12-23 16:32:12.000000000 -0500
+@@ -365,7 +365,7 @@
+ 	"DEF = -D" \
+ 	"CCFLAGS = -m64 -O2 -fPIC -Wall" \
+ 	"CXXFLAGS = -m64 -O2 -fPIC -Wall" \
+-	"TCLLDFLAGS = -ltcl8.5 -ldl" \
++	"TCLLDFLAGS = -ltcl8.4 -ldl" \
+ 	"NETCDFLDFLAGS = -lnetcdf " \
+ 	"AR = ar" \
+ 	"NM = nm -p" \
+diff -u -r ../orig/vmd-1.9.1/configure.options ./vmd-1.9.1/configure.options
+--- ../orig/vmd-1.9.1/configure.options	2012-02-02 02:53:54.000000000 -0500
++++ ./vmd-1.9.1/configure.options	2013-12-23 16:32:12.000000000 -0500
+@@ -1 +1 @@
+-WIN32 TCL MSVC
++LINUXAMD64 OPENGL TK IMD XINPUT TCL PTHREADS
+diff -u -r ../orig/vmd-1.9.1/src/Makefile ./vmd-1.9.1/src/Makefile
+--- ../orig/vmd-1.9.1/src/Makefile	2012-02-02 02:54:49.000000000 -0500
++++ ./vmd-1.9.1/src/Makefile	2013-12-23 18:36:37.000000000 -0500
+@@ -1,6 +1,6 @@
+ 
+ # Makefile for vmd
+-# VMD for WIN32, version 1.9.1 (February 1, 2012)
++# VMD for LINUXAMD64, version 1.9.1 (December 20, 2013)
+ 
+ #.SILENT:
+ 
+@@ -16,15 +16,25 @@
+ COMPRESS    = compress
+ GNUCOMPRESS = /usr/local/bin/gzip
+ LATEX       = latex
+-
++#RAPPTURE    = /opt/hubzero/rappture/vmd
+ # makefile configuration
+-VPATH                   = .:../WIN32
++VPATH                   = .:../LINUXAMD64
+ SHELL                   = /bin/sh
+ .SUFFIXES: .C .c .cu ..c .i .o
+ 
+ 
+ # C++ source files
+-VMD_CCPP    =	Animation.C \
++VMD_CCPP    =	OpenGLDisplayDevice.C \
++		OpenGLExtensions.C \
++		OpenGLRenderer.C \
++		OpenGLShader.C \
++		OpenGLCache.C \
++		IMDMgr.C \
++		IMDSim.C \
++		IMDSimThread.C \
++		CmdIMD.C \
++		imd.C \
++		Animation.C \
+ 		ArtDisplayDevice.C \
+ 		AtomColor.C \
+ 		AtomParser.C \
+@@ -219,7 +229,17 @@
+ VMD_CU      = 	
+ 
+ # Header files
+-VMD_H       = 	Animation.h \
++VMD_H       = 	OpenGLDisplayDevice.h \
++		OpenGLExtensions.h \
++		OpenGLRenderer.h \
++		OpenGLShader.h \
++		OpenGLCache.h \
++		imd.h \
++		IMDMgr.h \
++		IMDSim.h \
++		IMDSimThread.h \
++		CmdIMD.h \
++		Animation.h \
+ 		ArtDisplayDevice.h \
+ 		Atom.h \
+ 		AtomColor.h \
+@@ -380,42 +400,43 @@
+ 
+ VMD_EXTRA          = 	
+ 
+-VMD_OTHER_EXE      = 	../lib/stride/stride_WIN32 ../lib/surf/surf_WIN32 ../lib/tachyon/tachyon_WIN32
++VMD_OTHER_EXE      = 	../lib/stride/stride_LINUXAMD64 ../lib/surf/surf_LINUXAMD64 ../lib/tachyon/tachyon_LINUXAMD64
+ 
+-VMD_OTHER_NAMES    = 	stride_WIN32
++VMD_OTHER_NAMES    = 	stride_LINUXAMD64
+ 
+ VMD_MAIN_DIR_FILES = 	Announcement FEEDBACK LICENSE README configure
+ 
+ # Turn things into objects
+ VMD_OBJS    =   $(VMD_CCPP:.C=.o) $(VMD_CC:.c=.o) $(VMD_CU:.cu=.o)
+ 
+-INCDIRS     = -I../lib/tcl/include -I../plugins/include -I../plugins/WIN32/molfile -I.
+ 
+-LIBS        = -ltcl8.5  -lmolfile_plugin -lm $(VMDEXTRALIBS)
++INCDIRS     =   -I$(RPDIR)/include  -I../lib/tcl/include -I../lib/tk/include -I../plugins/include -I../plugins/LINUXAMD64/molfile -I.
++
++LIBS        = -L$(RPDIR)/lib -lGL -lGLU -lX11  -lXi -lpthread -ltk8.4 -lX11 -ltcl8.4  -lmolfile_plugin -lm -ldl $(VMDEXTRALIBS)
+ 
+-LIBDIRS     = -L../lib/tcl/lib_WIN32  -L../plugins/WIN32/molfile 
++LIBDIRS     =     -L../lib/tcl/lib_LINUXAMD64 -L../lib/tk/lib_LINUXAMD64  -L../plugins/LINUXAMD64/molfile 
+ 
+-DEFINES     = -DVMDQUICKSURF -DVMDWITHCARBS -DVMDPOLYHEDRA -DVMDSURF -DVMDMSMS -DVMDPBCSMOOTH -DVMDTCL  -DVMDSTATICPLUGINS 
++DEFINES     = -DVMDOPENGL -DVMDIMD -DVMDXINPUT -DVMDTHREADS -DWKFTHREADS -DUSEPOSIXTHREADS -D_REENTRANT -DVMDQUICKSURF -DVMDWITHCARBS -DVMDPOLYHEDRA -DVMDSURF -DVMDMSMS -DVMDPBCSMOOTH -DVMDTCL -DVMDTK  -DVMDSTATICPLUGINS 
+ 
+ # compiler and compiler directives 
+-CC          = cl.exe
+-CFLAGS      =  -DARCH_WIN32 $(DEFINES) $(INCDIRS) 
++CC          = gcc
++CFLAGS      = -m64 -Wall -O6 -ffast-math -DARCH_LINUXAMD64 $(DEFINES) $(INCDIRS) 
+ 
+-CCPP	    = cl.exe
+-CPPFLAGS    = /O2 /G5 /nologo /MT /DWIN32 -Dstrcasecmp=strupcmp /TP -DARCH_WIN32 $(DEFINES) $(INCDIRS) 
++CCPP	    = g++
++CPPFLAGS    = -m64 -fno-for-scope -Wno-deprecated -Wall -O6 -ffast-math  -DARCH_LINUXAMD64 $(DEFINES) $(INCDIRS) 
+ 
+ NVCC        = /usr/local/encap/cuda-4.0/bin/nvcc
+-NVCCFLAGS   = --ptxas-options=-v -gencode arch=compute_10,code=sm_10 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 --ftz=true  -DARCH_WIN32 $(DEFINES) $(INCDIRS)
++NVCCFLAGS   = --ptxas-options=-v -gencode arch=compute_10,code=sm_10 -gencode arch=compute_13,code=sm_13 -gencode arch=compute_20,code=sm_20 --ftz=true  -DARCH_LINUXAMD64 $(DEFINES) $(INCDIRS)
+ 
+ COMPILERC   = echo
+ RCFLAGS     = No resource compiler required on this platform.
+ 
+-DEPEND      = -M
++DEPEND      = -MM
+ DEPENDFILE  = Makedata.depend
+ 
+-LOADLIBES   = $(LIBDIRS) $(LIBS) 
++LOADLIBES   = $(LIBDIRS) $(LIBS) -rdynamic
+ 
+-LEX 	    = lex
++LEX 	    = flex
+ YACC	    = yacc
+ YFLAGS      = -d
+ 
+@@ -425,15 +446,15 @@
+ 
+ .C.o: 
+ 	$(ECHO) "Compiling " $< " --> " $*.o " ..."; \
+-	$(CCPP) $(CPPFLAGS) -c $< /Fo../WIN32/$@
++	$(CCPP) $(CPPFLAGS) -c $< -o ../LINUXAMD64/$@
+ 
+ .c.o:
+ 	$(ECHO) "Compiling " $< " --> " $*.o " ..."; \
+-	$(CC) $(CFLAGS) -c $< /Fo../WIN32/$@
++	$(CC) $(CFLAGS) -c $< -o ../LINUXAMD64/$@
+ 
+ .cu.o:
+ 	$(ECHO) "Compiling " $< " --> " $*.o " ..."; \
+-	$(NVCC) $(NVCCFLAGS) -c $< /Fo../WIN32/$@
++	$(NVCC) $(NVCCFLAGS) -c $< -o ../LINUXAMD64/$@
+ 
+ .y.o:
+ 
+@@ -442,83 +463,83 @@
+ ########## Targets
+ 
+ ### Source targets
+-all default:   vmd_WIN32
++all default:   vmd_LINUXAMD64
+ 
+-vmd_WIN32: y.tab.h $(VMD_OBJS)
++vmd_LINUXAMD64: y.tab.h $(VMD_OBJS)
+ 	$(ECHO) "Linking " $@ "..."; \
+-	$(CD) ../WIN32 ; \
+-	if [ ! -r ./ ]; then \
+-	  ln -s ../src/ ./ ; \
++	$(CD) ../LINUXAMD64 ; \
++	if [ ! -r ./foobar ]; then \
++	  ln -s ../src/foobar ./foobar ; \
+ 	fi; \
+ 	$(CCPP) $(CPPFLAGS) -I../src -o $@ $(VMD_OBJS) $(LOADLIBES) ; 
+ 	$(COMPILERC) $(RCFLAGS)
+ 
+ install:
+-	if [ ! -d "/usr/local/lib/vmd" ]; then \
+-		$(MAKEDIR) "/usr/local/lib/vmd" ; \
++	if [ ! -d "$(RPDIR)/lib/vmd" ]; then \
++		$(MAKEDIR) "$(RPDIR)/lib/vmd" ; \
+ 	fi ; \
+-	if [ ! -d "/usr/local/bin" ]; then \
+-		$(MAKEDIR) "/usr/local/bin" ; \
++	if [ ! -d "$(RPDIR)/bin" ]; then \
++		$(MAKEDIR) "$(RPDIR)/bin" ; \
+ 	fi ; \
+-	if [ ! -d "/usr/local/lib/vmd"/doc ]; then \
+-		$(MAKEDIR) "/usr/local/lib/vmd"/doc; \
++	if [ ! -d "$(RPDIR)/doc" ]; then \
++		$(MAKEDIR) "$(RPDIR)/doc"; \
+ 	fi
+-	-$(COPY) ../Announcement  "/usr/local/lib/vmd"
+-	-$(COPY) ../README        "/usr/local/lib/vmd"
+-	-$(COPY) ../LICENSE       "/usr/local/lib/vmd"
+-	-$(COPY) ../doc/ug.pdf        "/usr/local/lib/vmd"/doc
+-	if [ -f /usr/local/lib/vmd/vmd_WIN32 ]; then \
+-           $(MOVE) "/usr/local/lib/vmd/vmd_WIN32" "/usr/local/lib/vmd/OLD_vmd_WIN32" ; $(DELETE) "/usr/local/lib/vmd/OLD_vmd_WIN32" ; fi
+-	-$(COPY) ../WIN32/vmd_WIN32 "/usr/local/lib/vmd"
+-	if [ -d "../lib/redistrib/lib_WIN32" ]; then \
+-		$(CD) ../lib/redistrib/lib_WIN32; $(TAR) -cf - ./* | \
+-		(cd "/usr/local/lib/vmd" ; $(TAR) -xf -) \
++	-$(COPY) ../Announcement  "$(RPDIR)/lib/vmd"
++	-$(COPY) ../README        "$(RPDIR)/lib/vmd"
++	-$(COPY) ../LICENSE       "$(RPDIR)/lib/vmd"
++	-$(COPY) ../doc/ug.pdf        "$(RPDIR)/lib/vmd"/doc
++	if [ -f $(RPDIR)/lib/vmd/vmd_LINUXAMD64 ]; then \
++           $(MOVE) "$(RPDIR)/lib/vmd/vmd_LINUXAMD64" "$(RPDIR)/lib/vmd/OLD_vmd_LINUXAMD64" ; $(DELETE) "$(RPDIR)/lib/vmd/OLD_vmd_LINUXAMD64" ; fi
++	-$(COPY) ../LINUXAMD64/vmd_LINUXAMD64 "$(RPDIR)/lib/vmd"
++	if [ -d "../lib/redistrib/lib_LINUXAMD64" ]; then \
++		$(CD) ../lib/redistrib/lib_LINUXAMD64; $(TAR) -cf - ./* | \
++		(cd "$(RPDIR)/lib/vmd" ; $(TAR) -xf -) \
+ 	fi ;
+-	-$(COPY) ../lib/stride/stride_WIN32 ../lib/surf/surf_WIN32 ../lib/tachyon/tachyon_WIN32 "/usr/local/lib/vmd"
++	-$(COPY) ../lib/stride/stride_LINUXAMD64 ../lib/surf/surf_LINUXAMD64 ../lib/tachyon/tachyon_LINUXAMD64 "$(RPDIR)/lib/vmd"
+ 	-$(CD) ..; $(TAR) -cf - scripts | \
+-	(cd "/usr/local/lib/vmd" ; $(TAR) -xf -)
++	(cd "$(RPDIR)/lib/vmd" ; $(TAR) -xf -)
+ 	-$(CD) ../lib; $(TAR) -cf - scripts | \
+-	(cd "/usr/local/lib/vmd" ; $(TAR) -xf -)
++	(cd "$(RPDIR)/lib/vmd" ; $(TAR) -xf -)
+ 	-$(CD) ..; $(TAR) -cf - python | \
+-	(cd "/usr/local/lib/vmd"/scripts ; $(TAR) -xf -)
++	(cd "$(RPDIR)/lib/vmd"/scripts ; $(TAR) -xf -)
+ 	-$(CD) ..; $(TAR) -cf - plugins | \
+-	(cd "/usr/local/lib/vmd" ; $(TAR) -xf -)
++	(cd "$(RPDIR)/lib/vmd" ; $(TAR) -xf -)
+ 	-$(CD) ..; $(TAR) -cf - shaders | \
+-	(cd "/usr/local/lib/vmd" ; $(TAR) -xf -)
+-	-$(COPY) ../data/.vmdrc ../data/.vmdsensors ../data/vmd_completion.dat "/usr/local/lib/vmd"
++	(cd "$(RPDIR)/lib/vmd" ; $(TAR) -xf -)
++	-$(COPY) ../data/.vmdrc ../data/.vmdsensors ../data/vmd_completion.dat "$(RPDIR)/lib/vmd"
+ 	$(CD) ../bin ; \
+ 	if [ -f run_vmd_tmp ]; then $(DELETE) run_vmd_tmp; fi ; \
+ 	if [ ! -x "/bin/csh" ]; then \
+ 		$(ECHO) "Info: /bin/csh shell not found, installing Bourne shell startup script instead" ; \
+ 		$(ECHO) '#!/bin/sh' >> run_vmd_tmp ; \
+-		$(ECHO) 'defaultvmddir="/usr/local/lib/vmd"' >> run_vmd_tmp ; \
++		$(ECHO) 'defaultvmddir="$(RPDIR)/lib/vmd"' >> run_vmd_tmp ; \
+ 		$(ECHO) 'vmdbasename=vmd' >> run_vmd_tmp ; \
+ 		cat vmd.sh >> run_vmd_tmp ; \
+ 	else \
+ 		$(ECHO) '#!/bin/csh' >> run_vmd_tmp ; \
+-		$(ECHO) 'set defaultvmddir="/usr/local/lib/vmd"' >> run_vmd_tmp ; \
++		$(ECHO) 'set defaultvmddir="$(RPDIR)/lib/vmd"' >> run_vmd_tmp ; \
+ 		$(ECHO) 'set vmdbasename=vmd' >> run_vmd_tmp ; \
+ 		cat vmd.csh >> run_vmd_tmp ; \
+ 	fi ; \
+ 	chmod +x run_vmd_tmp ; \
+-	$(COPY) run_vmd_tmp "/usr/local/bin"/vmd ; \
++	$(COPY) run_vmd_tmp $(RPDIR)/bin ; \
+ 	$(DELETE) run_vmd_tmp
+-	$(ECHO) Make sure "/usr/local/bin"/vmd is in your path.
++	$(ECHO) Make sure $(RPDIR)/bin is in your path.
+ 	$(ECHO) "VMD installation complete.  Enjoy!"
+ 
+ ##### remove most of the cruft
+ clean:
+-	$(CD) ../WIN32 ; \
++	$(CD) ../LINUXAMD64 ; \
+ 		$(DELETE) *.o *.warnings *.depend.old core
+ 
+ veryclean: clean
+-	$(CD) ../WIN32 ; \
+-	  $(DELETEDIR) ; \
+-	  $(DELETE) vmd_WIN32
++	$(CD) ../LINUXAMD64 ; \
++	  $(DELETEDIR) foobar; \
++	  $(DELETE) vmd_LINUXAMD64
+ 	$(CD) ../src ; \
+ 	  $(DELETE) *.o *.a *~ core; \
+-	  $(DELETEDIR) ; \
+-	  $(DELETE) vmd_WIN32
++	  $(DELETEDIR) foobar; \
++	  $(DELETE) vmd_LINUXAMD64
+ 	$(CD) ../doc ; \
+ 	  $(DELETE) *~ core
+ 
+@@ -551,7 +572,7 @@
+ 	done; \
+ 	$(ECHO) ParseTree.o AtomLexer.o AtomParser.o: y.tab.h \
+                 >> $(DEPENDFILE); \
+-	$(COPY) $(DEPENDFILE) $(DEPENDFILE).WIN32 ; \
++	$(COPY) $(DEPENDFILE) $(DEPENDFILE).LINUXAMD64 ; \
+ 	else \
+ 	  $(ECHO) "Cannot find dependencies; your compiler does not support dependency checking."; \
+         fi
+diff -u -r ../orig/vmd-1.9.1/src/OpenGLDisplayDevice.C ./vmd-1.9.1/src/OpenGLDisplayDevice.C
+--- ../orig/vmd-1.9.1/src/OpenGLDisplayDevice.C	2012-02-02 02:54:52.000000000 -0500
++++ ./vmd-1.9.1/src/OpenGLDisplayDevice.C	2013-12-27 15:11:45.000000000 -0500
+@@ -601,7 +601,10 @@
+     wmhints.decorations = 1; // 1 (true) window decorations enabled
+   }
+ 
+-  Atom wmproperty = XInternAtom(dpy, "_MOTIF_WM_HINTS", True);
++  wmhints.decorations = 0;	     // Don't turn on decorations (no wm)
++
++  // Intern the atom even if it doesn't exist (no wm).
++  Atom wmproperty = XInternAtom(dpy, "_MOTIF_WM_HINTS", False);
+   XChangeProperty(dpy, win, wmproperty, wmproperty, 32, 
+                   PropModeReplace, (unsigned char *) &wmhints, 5);
+ 
+@@ -824,7 +827,7 @@
+     return (Window)0;
+   }
+ 
+-  Atom wmDeleteWindow = XInternAtom(glxsrv.dpy, "WM_DELETE_WINDOW", False);
++  Atom wmDeleteWindow = XInternAtom(glxsrv.dpy, "WM_DELETE_WINDOW", True);
+ 
+   // (5) create an OpenGL rendering context
+   if(!(glxsrv.cx = glXCreateContext(glxsrv.dpy, vi, None, GL_TRUE))) {
+diff -u -r ../orig/vmd-1.9.1/src/TclTextInterp.C ./vmd-1.9.1/src/TclTextInterp.C
+--- ../orig/vmd-1.9.1/src/TclTextInterp.C	2012-02-02 02:54:55.000000000 -0500
++++ ./vmd-1.9.1/src/TclTextInterp.C	2013-12-23 16:32:12.000000000 -0500
+@@ -340,7 +340,7 @@
+   gotPartial = 0;
+ 
+   callLevel++;
+-  Tcl_RecordAndEvalObj(interp, commandPtr, 0);
++  Tcl_EvalObjEx(interp, commandPtr, 0);
+   callLevel--;
+ 
+ #if TCL_MINOR_VERSION >= 4
+@@ -376,7 +376,7 @@
+ }
+ 
+ int TclTextInterp::evalString(const char *s) {
+-  if (Tcl_RecordAndEval(interp, s, 0) != TCL_OK) {
++  if (Tcl_Eval(interp, s) != TCL_OK) {
+     // Don't print error message if there's nothing to show.
+     if (strlen(Tcl_GetStringResult(interp))) 
+       msgErr << Tcl_GetStringResult(interp) << sendmsg;
+@@ -431,7 +431,7 @@
+     // check if "exit" was called
+     if (app->exitFlag) break;
+ 
+-    Tcl_RecordAndEvalObj(interp, cmdPtr, 0);
++    Tcl_EvalObjEx(interp, cmdPtr, 0);
+ 
+ #if TCL_MINOR_VERSION >= 4
+     Tcl_DecrRefCount(cmdPtr);
+diff -u -r ../orig/vmd-1.9.1/src/config.h ./vmd-1.9.1/src/config.h
+--- ../orig/vmd-1.9.1/src/config.h	2012-02-02 02:54:58.000000000 -0500
++++ ./vmd-1.9.1/src/config.h	2013-12-23 16:32:12.000000000 -0500
+@@ -1,10 +1,10 @@
+ #ifndef CONFIG_OPTIONS_H
+ #define CONFIG_OPTIONS_H
+ #define VMDVERSION "1.9.1"
+-#define VERSION_MSG "VMD for WIN32, version 1.9.1 (February 1, 2012)"
++#define VERSION_MSG "VMD for LINUXAMD64, version 1.9.1 (December 20, 2013)"
+ /* You should not change this value */
+ #define CMDLEN 15
+-#define DEF_VMDIMAGEVIEWER "explorer %s"
++#define DEF_VMDIMAGEVIEWER "display %s"
+ #define DEF_VMDENVVAR "/usr/local/lib/vmd"
+ #define INIT_DEFDISPLAY DISPLAY_WIN
+ #define INIT_DEFTITLE TITLE_ON
+@@ -15,10 +15,10 @@
+ #define VMD_AUTHORS_LINE2 "J. Gullingsrud, D. Hardy, W. Humphrey, B. Isralewitz, S. Izrailev, "
+ #define VMD_AUTHORS_LINE3 "A. Kohlmeyer, D. Norris, J. Saam, J. Stone, J. Ulrich"
+ #define VMD_AUTHORS_LINE4 ""
+-#define VMD_STARTUP "vmd.rc"
+-#define PYVMD_STARTUP "pyvmd.rc"
+-#define VMD_ARCH "WIN32"
+-#define VMD_OPTIONS "WIN32 TCL MSVC"
++#define VMD_STARTUP ".vmdrc"
++#define PYVMD_STARTUP ".pyvmdrc"
++#define VMD_ARCH "LINUXAMD64"
++#define VMD_OPTIONS "LINUXAMD64 OPENGL TK IMD XINPUT TCL PTHREADS"
+ #define VMD_HOMEPAGE "http://www.ks.uiuc.edu/Research/vmd/"
+ #define VMD_HELPPAGE "http://www.ks.uiuc.edu/Research/vmd/"
+ #define VMD_CMD_PROMPT "vmd > "
Index: /trunk/packages/vizservers/vmd/vmdserver.tcl
===================================================================
--- /trunk/packages/vizservers/vmd/vmdserver.tcl	(revision 4097)
+++ /trunk/packages/vizservers/vmd/vmdserver.tcl	(revision 4097)
@@ -0,0 +1,514 @@
+# ----------------------------------------------------------------------
+#  HUBZERO: server for VMD
+#
+#  This program runs VMD and acts as a server for client applications.
+# ----------------------------------------------------------------------
+#  Michael McLennan (mmclennan@purdue.edu)
+# ======================================================================
+#  Copyright (c) 2013 - HUBzero Foundation, LLC
+# ======================================================================
+
+set ::tcl_interactive 0
+
+# parse command line args
+set Paradigm "socket"
+while {[llength $argv] > 0} {
+    set opt [lindex $argv 0]
+    set argv [lrange $argv 1 end]
+
+    switch -- $opt {
+        -socket { set Paradigm "socket" }
+        -stdio  { set Paradigm "stdio" }
+        default {
+            puts stderr "bad option \"$opt\": should be -socket or -stdio"
+        }
+    }
+}
+
+# use this to take snapshots to send to clients
+image create photo SnapShot
+
+# set the screen to a good size
+#display resize 300 300
+
+# initialize work queue and epoch counter (see server_send_image)
+set Epoch 0
+set Work(queue) ""
+set Sendqueue ""
+
+set parser [interp create -safe]
+
+foreach cmd {
+  vmdinfo
+  vmdbench
+  animate
+  color
+  axes
+  display
+  imd
+  vmdcollab
+  vmd_label
+  light
+  material
+  vmd_menu
+  stage
+  light
+  user
+  mol
+  molinfo
+  molecule
+  mouse
+  mobile
+  spaceball
+  plugin
+  render
+  tkrender
+  rock
+  rotate
+  rotmat
+  vmd_scale
+  translate
+  sleep
+  tool
+  measure
+  rawtimestep
+  gettimestep
+  vmdcon
+  volmap
+  parallel
+} {
+    $parser alias $cmd $cmd
+}
+
+# ----------------------------------------------------------------------
+# USAGE: tellme "command template with %v" command arg arg...
+#
+# Executes the "command arg arg..." string in the server and substitutes
+# the result into the template string in place of each "%v" field.
+# Sends the result back to the client.
+# ----------------------------------------------------------------------
+proc cmd_tellme {fmt args} {
+    global parser client
+
+    # evaluate args as a command and subst the result in the fmt string
+    if {[catch {$parser eval $args} result] == 0} {
+        server_send_result $client "nv>[string map [list %v $result] $fmt]"
+    } else {
+        server_oops $client $result
+    }
+}
+$parser alias tellme cmd_tellme
+
+# ----------------------------------------------------------------------
+# USAGE: reset
+#
+# Executes the "command arg arg..." string in the server and substitutes
+# the result into the template string in place of each "%v" field.
+# Sends the result back to the client.
+# ----------------------------------------------------------------------
+proc cmd_reset {} {
+    global client
+
+    # reset the view so we get a good scale matrix below
+    display resetview
+
+    # reset scale -- figure out size by querying molinfo for first molecule
+    set nmol [lindex [molinfo list] 0]
+    if {$nmol ne ""} {
+        set matrix [molinfo $nmol get scale_matrix]
+        set sf [lindex [lindex [lindex $matrix 0] 0] 0]
+        vmd_scale to $sf
+        server_send_result $client "nv>scale $sf"
+    }
+
+    axes location off
+}
+$parser alias reset cmd_reset
+
+# ----------------------------------------------------------------------
+# USAGE: resize <w> <h>
+#
+# Resizes the visualization window to the given width <w> and height
+# <h>.  The next image sent should be this size.
+# ----------------------------------------------------------------------
+proc cmd_resize {w h} {
+    display resize $w $h
+    display update
+}
+$parser alias resize cmd_resize
+
+# ----------------------------------------------------------------------
+# USAGE: load <file> <file>...
+#
+# Loads the molecule data from one or more files, which may be PDB,
+# DCD, PSF, etc.
+# ----------------------------------------------------------------------
+proc cmd_load {args} {
+    # clear all existing molecules
+    foreach nmol [molinfo list] {
+        mol delete $nmol
+    }
+
+    # clear any existing views
+    cmd_view forget
+
+    # load new files
+    set op "new"
+    foreach file $args {
+        mol $op $file waitfor all
+        set op "addfile"
+    }
+}
+$parser alias load cmd_load
+
+# ----------------------------------------------------------------------
+# USAGE: view define <name> <script>
+# USAGE: view show <name>
+# USAGE: view clear
+# USAGE: view forget ?<name> <name>...?
+#
+# Used to define and manipulate views of the trajectory information
+# loaded previously by the "load" command.  The "define" operation
+# defines the script that loads a view called <name>.  The "show"
+# operation executes that script to show the view.  The "clear"
+# operation clears the current view (usually in preparation for 
+# showing another view).  The "forget" operation erases one or more
+# view definitions; if no names are specified, then all views are
+# forgotten.
+# ----------------------------------------------------------------------
+proc cmd_view {option args} {
+    global Views parser
+    switch -- $option {
+        define {
+            if {[llength $args] != 2} {
+                error "wrong # args: should be \"view define name script\""
+            }
+            set name [lindex $args 0]
+            set script [lindex $args 1]
+            set Views($name) $script
+        }
+        show {
+            if {[llength $args] != 1} {
+                error "wrong # args: should be \"view show name\""
+            }
+	    set name [lindex $args 0]
+            if {![info exists Views($name)]} {
+                error "bad view name \"$name\": should be one of [join [array names Views] {, }]"
+            }
+
+            # clear the old view
+            cmd_view clear
+
+            # use a safe interp to keep things safe
+            if {[catch {$parser eval $Views($name)} result]} {
+                error "$result\nwhile loading view \"$name\""
+            }
+        }
+        clear {
+            set numOfRep [lindex [mol list top] 12]
+            for {set i 1} {$i <= $numOfRep} {incr i} {
+                mol delrep top 0
+            }
+            cmd_reset
+        }
+        forget {
+            if {[llength $args] == 0} {
+                set args [array names Views]
+            }
+            foreach name $args {
+                catch {unset Views($name)}
+            }
+        }
+        default {
+            error "bad option \"$option\": should be define, show, clear, forget"
+        }
+    }
+}
+$parser alias view cmd_view
+
+# ----------------------------------------------------------------------
+# USAGE: frames time <epochValue> <start> ?<finish>? ?<inc>?
+# USAGE: frames rotate <epochValue> <xa> <ya> <za> <number>
+# USAGE: frames max
+#
+# Used to request one or more frames for an animation.  A "time"
+# animation is a series of frames between two time points.  A "rotate"
+# animation is a series of frames that rotate the view 360 degrees.
+#
+# The <epochValue> is passed by the client to indicate the relevance of
+# the request.  Whenever the client enters a new epoch, it is no longer
+# concerned with any earlier epochs, so the server can ignore pending
+# images that are out of date.  The server sends back the epoch with
+# all frames so the client can understand if the frames are relevant.
+#
+# For a "time" animation, the <start> is a number of a requested frame.
+# The <finish> is the last frame in the series.  The <inc> is the step
+# by which the frames should be generated, which may be larger than 1.
+#
+# For a "rotate" animation, the <xa>,<ya>,<za> angles indicate the
+# direction of the rotation.  The <number> is the number of frames
+# requested for a full 360 degree rotation.
+#
+# The "frames max" query returns the maximum number of frames in the
+# trajectory.  The server uses this to figure out the limits of
+# animation.
+# ----------------------------------------------------------------------
+proc cmd_frames {what args} {
+    global client Epoch Work
+
+    # check incoming parameters
+    switch -- $what {
+      time {
+        set epochValue [lindex $args 0]
+        set start [lindex $args 1]
+        set finish [lindex $args 2]
+        if {$finish eq ""} { set finish $start }
+        set inc [lindex $args 3]
+        if {$inc eq ""} { set inc 1 }
+
+        if {![string is integer $finish]} {
+            server_oops $client "bad animation end \"$finish\" should be integer"
+            return
+        }
+        if {![string is integer $inc] || $inc == 0} {
+            server_oops $client "bad animation inc \"$inc\" should be non-zero integer"
+            return
+        }
+        if {($finish < $start && $inc > 0) || ($finish > $start && $inc < 0)} {
+            server_oops $client "bad animation limits: from $start to $finish by $inc"
+        }
+
+        # new epoch? then clean out work queue
+        if {$epochValue > $Epoch} {
+            catch {unset Work}
+            set Work(queue) ""
+            set Epoch $epochValue
+        }
+
+        # add these frames to the queue
+        if {$inc > 0} {
+            # generate frames in play>> direction
+            for {set n $start} {$n <= $finish} {incr n $inc} {
+                if {![info exists Work($n)]} {
+                    lappend Work(queue) [list epoch $epochValue frame $n num $n]
+                    set Work($n) 1
+                }
+            }
+        } else {
+            # generate frames in <<play direction
+            for {set n $start} {$n >= $finish} {incr n $inc} {
+                if {![info exists Work($n)]} {
+                    lappend Work(queue) [list epoch $epochValue frame $n num $n]
+                    set Work($n) 1
+                }
+            }
+        }
+      }
+      rotate {
+        set epochValue [lindex $args 0]
+        set mx [lindex $args 1]
+        if {![string is double -strict $mx]} {
+            server_oops $client "bad mx rotation value \"$mx\" should be double"
+            return
+        }
+        set my [lindex $args 2]
+        if {![string is double -strict $my]} {
+            server_oops $client "bad my rotation value \"$my\" should be double"
+            return
+        }
+        set mz [lindex $args 3]
+        if {![string is double -strict $mz]} {
+            server_oops $client "bad mz rotation value \"$mz\" should be double"
+            return
+        }
+        set num [lindex $args 4]
+        if {![string is integer -strict $num] || $num <= 0} {
+            server_oops $client "bad number of rotation frames \"$num\" should be integer > 0"
+            return
+        }
+
+        set rot [list $mx $my $mz]
+        for {set n 0} {$n < $num} {incr n} {
+            lappend Work(queue) [list epoch $epochValue rotate $rot num $n]
+            set Work($n) 1
+        }
+      }
+      max {
+        set nmol [lindex [molinfo list] 0]
+        if {$nmol ne ""} {
+            return [molinfo $nmol get numframes]
+        }
+        return 0
+      }
+      default {
+        error "bad option \"$what\": should be time, rotate, max"
+      }
+    }
+
+    # service the queue at some point
+    server_send_image -eventually
+}
+$parser alias frames cmd_frames
+
+# ----------------------------------------------------------------------
+# SERVER CORE
+# ----------------------------------------------------------------------
+proc server_accept {cid addr port} {
+    fileevent $cid readable [list server_handle $cid $cid]
+    fconfigure $cid -buffering none -blocking 0
+
+    # identify server type to this client
+    puts $cid "vmd 0.1"
+}
+
+proc server_handle {cin cout} {
+    global parser buffer client
+
+    if {[gets $cin request] < 0} {
+        # when client drops connection, we can exit
+        # nanoscale will spawn a new server next time we need it
+        server_exit $cin $cout
+    } else {
+        append buffer($cin) $request "\n"
+        if {[info complete $buffer($cin)]} {
+            set request $buffer($cin)
+            set buffer($cin) ""
+            set client $cout
+            if {[catch {$parser eval $request} result] == 0} {
+                server_send_image -eventually
+            } else {
+                server_oops $cout $result
+            }
+        }
+    }
+}
+
+proc server_send {cout} {
+    global Epoch Sendqueue
+
+    # grab the next chunk of output and send it along
+    # discard any chunks from an older epoch
+    while {[llength $Sendqueue] > 0} {
+        set chunk [lindex $Sendqueue 0]
+        set Sendqueue [lrange $Sendqueue 1 end]
+
+        catch {unset data}; array set data $chunk
+        if {$data(epoch) == $Epoch} {
+            catch {puts $cout $data(cmd)}
+
+            # if this command has a binary data block, send it specially
+            if {[string length $data(bytes)] > 0} {
+                fconfigure $cout -translation binary
+                catch {puts $cout $data(bytes)}
+                fconfigure $cout -translation auto
+            }
+            break
+        }
+    }
+
+    # nothing left? Then stop callbacks until we get more
+    if {[llength $Sendqueue] == 0} {
+        fileevent $cout writable ""
+        server_send_image -eventually
+    }
+}
+
+proc server_exit {cin cout} {
+    catch {close $cin}
+    catch {exit 0}
+}
+
+# ----------------------------------------------------------------------
+# SERVER RESPONSES
+# ----------------------------------------------------------------------
+#
+
+#set the screen to a good size
+display resize 300 300
+
+
+# turn off constant updates -- only need them during server_send_image
+display update off
+
+proc server_send_image {{when -now}} {
+    global client Epoch Work Sendqueue
+
+    if {$when eq "-eventually"} {
+        after cancel server_send_image
+        after 1 server_send_image
+        return
+    } elseif {$when ne "-now"} {
+        error "bad option \"$when\" for server_send_image: should be -now or -eventually"
+    }
+
+    # loop through requests in the work queue and skip any from an older epoch
+    while {1} {
+        if {[llength $Work(queue)] == 0} {
+            return
+        }
+
+        set rec [lindex $Work(queue) 0]
+        set Work(queue) [lrange $Work(queue) 1 end]
+
+        catch {unset item}; array set item $rec
+        if {$item(epoch) < $Epoch} {
+            catch {unset Work($item(num))}
+            continue
+        }
+
+        # set the frame characteristics and render this frame
+        if {[info exists item(frame)]} {
+            animate goto $item(frame)
+        } elseif {[info exists item(rotate)]} {
+            foreach {mx my mz} $item(rotate) break
+            rotate x by $mx
+            rotate y by $my
+            rotate z by $mz
+        } else {
+            puts "ERROR: bad work frame: [array get item]"
+        }
+        catch {unset Work($item(num))}
+        break
+    }
+
+    # force VMD to update and grab the screen
+    display update
+    tkrender SnapShot
+
+    set data [SnapShot data -format PPM]
+    server_send_result $client "nv>image epoch $item(epoch) frame $item(num) length [string length $data]" $data
+
+    # if there's more work in the queue, try again later
+    if {[llength $Work(queue)] > 0} {
+        after 1 server_send_image
+    }
+}
+
+proc server_send_result {cout cmd {data ""}} {
+    global Epoch Sendqueue
+
+    # add this result to the output queue
+    # wait until the client is ready, then send the output
+    lappend Sendqueue [list epoch $Epoch cmd $cmd bytes $data]
+    fileevent $cout writable [list server_send $cout]
+}
+
+proc server_oops {cout mesg} {
+    # remove newlines -- all lines must start with nv>
+    set mesg [string map {\n " "} $mesg]
+    server_send_result $cout "nv>oops [list $mesg]"
+}
+
+if {$Paradigm eq "socket"} {
+    socket -server server_accept 2018
+} else {
+    fileevent stdin readable [list server_handle stdin stdout]
+
+    # identify server type to this client
+    puts stdout "vmd 0.1"
+    flush stdout
+    fconfigure stdout -buffering none -blocking 0
+}
+
+# vmd automatically drops into an event loop at this point...
+set ::tcl_interactive 0
