From: Peter Freddolino (
Date: Wed May 23 2007 - 19:18:48 CDT

To add on to Axel's advice, one specific and relatively easy way of
calling C/C++ code from Tcl is to use swig ( to
create a wrapper; this is, for example, the approach used for the
autopsf plugin. This is one of those "not specific to vmd" techniques;
you can use it from any tcl program (or, for that matter, several other
scripting languages).


Axel Kohlmeyer wrote:
> On Wed, 23 May 2007, Yinglong Miao wrote:
> YM> Dear VMD developers/users,
> dear long,
> YM> I have been reading online VMD Plugin Programmer's Guide, but still
> YM> have not find answers for my specific problem. I want to write a TCL
> YM> package as a plugin to VMD, while in the TCL package script, I want to
> YM> call Fortran/C subroutines for the core procedures, which are very
> YM> computationally intensive. So can I develop an efficient Fortran
> YM> program and archive it into a binary library file with those
> YM> computation subroutines so that I can them in TCL scripts? If yes, how
> the way you do it, is mostly not VMD specific, but more
> a generic extension of the TCL interpreter. so it may be
> useful to look at how you do this in the general TCL
> literature (online or hardcopy).
> what you propose is doable, how easy it is depends a lot on
> what you want to input into the plugin and how generic it is
> and/or whether you need and access to VMD internal data.
> there are several plugins in the VMD plugin library, that
> use compiled extensions to the VMD interpreter. if you need
> a simpler example, i can also send you my first version of the
> measure gofr command, which was implemented as a plugin.
> if possible, i would recommend to avoid writing plugins in
> Fortran or C++ (c++ is usally ok, if you avoid the STL based
> parts of the c++ runtime. i.e. write c with classes),
> so you don't have to deal with loading the appropriate runtime
> library (which may be incompatible to what VMD was compiled with).
> YM> to include a binary library in a TCL package? Or can anyone tell me
> YM> other ways to call Fortran/C subroutines in TCL to speed up the
> YM> calculation?
> the alternative would be to hook up your functionality directly
> into VMD (e.g. as an additional measure subcommand), but that
> requirest that you recompile VMD for your purposes.
> another option would be that you write your data to a file and
> then call a separate program (SURF, STRIDE, and MSMS for example
> are used like this) and read in the resulting output. whether
> this is more convenient or efficient depends a lot on the kind
> of analysis that you have in mind and how much data you are
> shuffling around.
> cheers,
> axel.
> YM>
> YM> Any suggestios will be greatly appreciated.
> YM>
> YM> Best regards,
> YM> Long
> YM>
> YM> --
> YM> Yinglong Miao
> YM> Ph.D. Candidate
> YM> Center for Cell and Virus Theory
> YM> Department of Chemistry, C203A
> YM> Indiana University
> YM> 800 E. Kirkwood Ave.
> YM> Bloomington, Indiana 47405
> YM> 1-812-856-0981 (office)
> YM> 1-812-857-6205 (home)
> YM>
> YM>