From: John Stone (johns_at_ks.uiuc.edu)
Date: Mon Apr 09 2007 - 16:52:50 CDT

Hi,
  Before you commit to adding/changing the C/C++ source code in VMD,
it might be useful to investigate what your scripts are doing. It is
often possible to make scripts run up to 100 times faster by fixing various
small programming mistakes that cause VMD to do unnecessary work, or make
use of poor-performing scripting constructs. A well-written analysis
script can often end up within a small factor of C/C++ depending on what
the bulk of your code is doing. If most of what you're doing is processing
atom selections etc, then rewriting in C/C++ probably won't help, and most
of your performanc gains would likely come from making more efficient use
of the selections you're using. If you like, we would be happy to help
by looking at your script to see what the bulk of your runtime is spent on.

If you're indeed doing things that need to be implemented in C/C++ for
performance, there are still multiple ways to accomplish this:
  1) Write a dynamically loadable shared library plugin, wrapped with
     SWIG, for loading into the Tcl or Python interpreters in VMD.
     The SWIG wrappers will expose the functionality as new VMD commands.
     You can look at the way psfgen, libalchemify, idatm, autopsf/psfcheck,
     and various other dynamically loaded C/C++ plugins if you need a
     examples or a template to work from.

  2) Add the routines to Measure.[Ch], TclMeasure.[Ch], Python, etc,
     exposing them as new VMD commands.

If you just need the arithmetic processing speed of C/C++ and the
convenience of more complex data strcutures, then 1) is the best choice.

If you need direct access to internal VMD data structures, atom selections,
multithreading or multiprocessor calculations, then 2) is the way to go.

Let me know which direction you think best suites your project.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Mon, Apr 09, 2007 at 04:59:18PM -0400, lanhua wrote:
> Hi,
> I wrote a tcl script to do some calculations over trajectories, it seems very slow. So I am considering to modify or add some subroutines in measure.C, is that possible. But I have no idea how to realize it. Could you tell me the detailed things like what programs or package should be downloaded, how to compile it,etc. Or is there a way to include a C or C++ program in tcl script?
> Thanks a lot!
>
>
>
> Best regards,
>
> lanhua
> lh2122_at_columbia.edu
> 2007-04-09

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078