C++ programming

Alan Scheinine scheinin at crs4.it
Tue Oct 22 04:48:10 EDT 2002


At the moment I am writing a program in Fortran, C, and C++.  The
most reusable parts are in C because I want colleagues who do not
know C++ to be able to use and understand some of the basic building
blocks such as the linear algebra parts, which could be used in other
projects.  I write C++ because I find it easier.  The program is
for a group in geophysics in which some members only know Fortran and
Fortran90, so I wrote wrappers for large blocks of code that they can
use at a high level.

The comment about templates and inlining is interesting, since it
helps towards choosing the right language for particular tasks.

In the past I wrote Fortran 77 for a finite-element code on an
unstructured grid, because at the time fluid dynamics was mostly
a Fortran world.  If I had to do it again, I would use C++
for the unstructured grid.  The type of code organization that
C++ permits seems (to me) to be very appropriate for unstructured
grids.  The program was parallel, domain decomposition using MPI
for communication between processes.  For the sake of optimization
and flexibility I needed lists of which domains touched other
domains and whether they were on the same or different processor
for both source and destination, with the result of having
five-dimensional arrays in Fortran -- and this was the evolved
version that I tried to make simple and efficient.  Even with
complete documentation of the meaning of the arrays, other people
found the program confusing.  Though I have not written a C++ version,
my impression is that I could have a program that would be easier
to understand by using C++ (and not less efficient).
Perhaps my brief example does not provide enough details to be
convincing, in any case, my point is that if something is
intrinsically complicated then careful use of C++ may be the most
easy way of clearly organizing an algorithm.

Alan Scheinine
_______________________________________________
Beowulf mailing list, Beowulf at beowulf.org
To change your subscription (digest mode or unsubscribe) visit http://www.beowulf.org/mailman/listinfo/beowulf



More information about the Beowulf mailing list