[gmx-developers] Using C++ with Gromacs
Peter Eastman
peastman at stanford.edu
Thu May 8 01:08:55 CEST 2008
On May 7, 2008, at 3:10 PM, Axel Kohlmeyer wrote:
> who said that you have to map _all_ of your library?
> but if you are writing an alternate version of do_md()
> you _are_ essentially writing a C API.
Yes, but it's a Gromacs specific API. It involves Gromacs data types,
not OpenMM data types, and is only ever intended to be called by
Gromacs.
I should explain that we eventually hope to have OpenMM integrated
into a large number of different programs that are written in a number
of different languages: C, C++, Fortran, Python, Java, TCL, etc. It's
obviously impractical for the library to provide a complete "generic"
API for every language anyone might ever want to call it from, much
less a separate API for every possible application. So we decided to
create a single API, make it as simple and clean as possible, and then
accept that applications written in other languages would need to
include a wrapper layer to invoke it. C++ was then the clear choice
for that API: it's fairly easy to integrate with code in any language,
even interpreted ones, and it has the necessary features to create a
clean API of the sort we wanted (in contrast to C or Fortran, which
would have required a very convoluted, very unnatural API).
So yes, essentially what I'm doing is creating a Gromacs specific C
API. If necessary, I could split that into a separate library, have
Gromacs link to that library, and have that library in turn link to
OpenMM. In the long run we may even decide that's the best approach
for maintainability. But in the short term, it *should* be much
simpler and less work to just figure out the proper incantation to
tell automake that one particular file is written in C++. After all,
it's supposed to be a standard feature of automake, and Gromacs
already includes code written in C, Fortran, and assembly. (But then,
when has "should" ever made a difference where computers were
concerned?) :)
Peter
More information about the gromacs.org_gmx-developers
mailing list