[gmx-developers] Using C++ with Gromacs

Peter Eastman peastman at stanford.edu
Thu May 8 22:25:17 CEST 2008

Success!  After far too many hours, I finally came up with the  
following mystical incantation which convinces automake to compile my  
file to its own library, then link it with mdrun:

noinst_LTLIBRARIES += libopenmminterface.la
libopenmminterface_la_SOURCES = md_openmm.cpp
mdrun_LINK = $(CXXLINK)

I know, written out that way it looks so innocuous.  How difficult  
could that possibly be? :)  You don't want to know how many hours when  
into that last line.  I still haven't managed to get it to produce a  
dynamic library, but I'll worry about that later.

On May 8, 2008, at 12:07 AM, Erik Lindahl wrote:

> Nothing wrong with that (we have different target audiences), but  
> for Gromacs portability means we compile out-of-the-box using  
> combinations like portland compilers and UNICOS (Cray XT4), 5-year- 
> old versions of IBM XLC on AIX (since that might be compiler your  
> local supercomputing center has a supported MPI version for), IRIX,  
> HP aC on Itanium, whatever special BLAS/LAPACK libraries the vendor  
> provides, etc.

Very true.  As in all such things, it's just a matter of your  
requirements.  You pick what platforms you need to support, and that  
limits what technologies you can use.  I'm happy to say, "We only  
support gcc 4.x and Visual Studio 2005," but you obviously have  
different requirements.

> However, this does _not_ mean we shouldn't do much more object  
> oriented interfaces and data abstraction in Gromacs (we're working  
> on that, but there's a lot of old code to clean up), it's just that  
> we'll need to accomplish it with handles rather than formal classes,  
> and forego some of the more advanced c++ stuff.

It's also good to remember that "using C++" can mean many different  
things.  After all, C++ is a superset of C, so strictly speak, every C  
program *is* a C++ program.  C++ then adds a lot of features, some of  
which are more problematic than others.  There are even a few features  
that started out in C++ and later got added to C (like the const  
keyword).  My impression is that if you even just stay away from  
templates and multiple inheritance, that alone will do a lot to reduce  
the compatibility issues.

Anyway, many thanks to everyone for your time and assistance.  I  
really appreciate it!  Hopefully we'll have something good to show in  
the not too distant future.


More information about the gromacs.org_gmx-developers mailing list