next up previous contents
Next: 3 Shallow and Deep Up: IMPL_repdoc Previous: 1 Introduction   Contents

2 Motivation and Assessment Strategy

The ESMF must provide an F90 interface and, less critically in the short term, a C++ interface. [5] An immediate question arises as to whether the ESMF should be implemented in F90 or whether it may be implemented in some other language and wrapped in F90. The wrapping approach is certainly not new, as many systems libraries (MPI [6], netCDF [11], etc..) with Fortran interfaces are programmed in C. The strategy selected must offer excellent performance, robustness, concise and maintainable code, and interfaces natural for the application programmer. It is also useful for both library and application programmers facing complex software tasks to be able to use a language rich in data structures and object-oriented (OO) constructs.

We consider C, C++ and F90 all viable implementation language candidates, as each has a significant base of developers and all currently support high-performance applications. C offers excellent portability and performance but has weaker support for object-oriented features, such as polymorphism, that F90 and C++ can offer. Interfacing C to F90 and to C++ is routine but can be ponderous. Interfacing F90 and C++ directly, with either as the implementation language, is relatively uncommon and no standard, mature approach exists. There are a number of efforts currently underway intended to address this gap. [9,10] The ESMF team maintains a productive collaboration with Chasm, perhaps the most mature tool available for automatic generation of C++/F90 interfaces. The potential for using Chasm in ESMF is discussed in Section 13.1.

In order to evaluate implementation and interoperability strategies we have prepared a series of examples. All are implemented in C++ and F90, and in each case we obtained C++ and F90 interfaces. C implementations are presented or discussed where they offer special insights - since C-based strategies are relatively well-understood, we have not focused on them. In the examples we have tried to retain a programming style natural for the calling language. For example, we have tried not to impose a strong C++ accent on F90 when it wraps C++ code.

The examples illustrate the aspects of implementation language and language interoperability that we believe are relevant for the ESMF. We begin with a discussion of shallow and deep classes, two different strategies for handling the inter-language interface. We next explore language features such as inheritance and templating, looking at both the capabilities of implementation languages and the degree to which these OO concepts can carry across the language boundary. We look carefully at performance, using both single-processor examples that quantify implementation language capabilities, and a pertinent large-scale example that includes both communication and the overhead costs of language wrapping. Finally we examine some of the details of language interoperability, such as handling pointer size and storage order.

We have run all examples on AIX, IRIX, Sun and Linux compilers.


next up previous contents
Next: 3 Shallow and Deep Up: IMPL_repdoc Previous: 1 Introduction   Contents
esmf_support@list.woc.noaa.gov