A coupled model of water, heat and mass transfer using object orientation to improve flexibility and functionality

https://doi.org/10.1016/S1364-8152(00)00062-1Get rights and content

Abstract

The challenge of our software development is to introduce user-friendly document-orientation and graphical features that are typical in Windows software and to retain the possibility of easily extending existing legacy Fortran code. Keys to this development were the use of five development tools and our special management of shared memory. Numerical development of the code was thus continued in Fortran while the newly introduced multiple-document interface allows the new graphical features that are considered more user friendly (e.g. tool bar, status bar, animation, etc.) can be further refined and adjusted using Visual C++6.0 and the MS Visual Studio. Object orientation makes it possible to include modules with different type of dependencies that restrict the user interface to the specific use of the model. A large number of sub-models are combined and all input/output data have been adapted to an object-oriented standard. Multiple-run features and built-in links to a common database are new important features.

Introduction

In the last three decades scientific programming has shifted from structured design (e.g. top–down) to object-oriented design. As software is expensive to create, it is attractive to reuse some of the code written under the former design philosophy. Often the simple approach is to convert C to C++ or FORTRAN 77 to Fortran 90 suffices, but in some cases a higher degree of object orientation is needed or a pure object-oriented language (e.g. Smalltalk) is needed. The more complicated situations can often be addressed by multi-language programming. A variety of approaches exist to allow some reuse: wrapping1 the old code in new object-oriented code to make objects, shared memory, and calls in mixed-language programming. Typical mixed-language programs involve wrapping functions and data in the more object-oriented language (C++) and making external function calls to functions in the other language. Several texts illustrate this approach including Barton and Nackman (1994).

Today many powerful tools such as MatLab and PowerSim provide powerful solutions in general simulation. However, for the development of powerful models that can be distributed independently (without site or individual license fees) the options are more limited especially if a significant legacy Fortran code is present.

Through experience several requirements for the user interface and developer's extension of programs have arisen:

  • 1.

    The software should be easy to use even for non-specialists including students lacking computer expertise.

  • 2.

    The software should be easy to modify by other model developers.

  • 3.

    The software should allow extensions to be written in a language that most scientists and engineers know or can quickly and easily master.

  • 4.

    The software should provide adequate solutions even to advanced practical and pedagogical problems.

The purpose of the present paper is to present how we transferred the code from an old and widely used program for simulation of water and heat flows in soils that was first presented by Jansson and Haldin (1979). The program was first written on a PDP computer during the 1970s using Fortran IV and has been later converted to newer versions of Fortran and linked with different shell and utility programs developed for IBM PC compatibles using DOS and Windows. It is assumed that the readers of this paper know either C++ or Fortran and have an interest in model development especially conversion to mixed-language environments.

Section snippets

Conceptual background to the model

The CoupModel is a process model for modelling thermal and hydrologic processes and the correspondent biological processes that regulates carbon and nitrogen transfer in a soil–plant–atmosphere environment. The CoupModel has been developed from the previous SOIL and SOILN models. The previous models have been used successfully on IBM-PC compatibles with DOS for about ten years. Data (parameters and variables) were defined in the source code and appropriate values are assigned by using a variety

Design and requirement on software

In the DOS environment a formal division was made among a C program for handling the user interface, a FORTRAN 77 program for the calculations, and a mixed-language program for input and output of time series data. The division allowed different parts of the program to be developed independently. However, a number of disadvantages became apparent:

  • Static memory allocation at a fixed physical location was imposed by the FORTRAN 77.

  • Structural changes were carried out only by simultaneous changes

Methods used for implementation of model

For conversion to the 32-bit Windows environment five different tools were selected: Microsoft (MS) Visual C++5.0, Compaq Visual Fortran, Microsoft Foundation Classes (MFC) 4.2, Bits Per Second's Graphics Server, and MS Visual Studio 97. The languages support object orientation, the MFC provides resources and controls, the graphics server supports scientific graphing, and the Visual Studio supports development especially in mixed-language development. These tools helped in meeting the design

Implementation techniques and features of the new CoupModel

Different important features were implemented to allow the new flexibility and to create a structure that satisfied our requirement on the software for the new CoupModel. The most important ones are described below.

Implementation steps in regular model development

The following steps help one to preserve modularity and orthogonality in model design so that changes, testing, and debugging can be easily and quickly done:

  • 1.

    Does the new implementation require a new structure in the model? If so, the developer must ascertain whether the implementation will require a new group or if it will suffice to change the structure within an existing group.

  • 2.

    If a new module is required, careful consideration must be given to the linkage with existing modules. In particular,

Discussion

The choice of software development tools complements our development of shared memory and application of multithreading. The legacy structure and relations between Fortran modules is retained for ease of adding new computational components to the model. However, the design process is essentially a one-step process due to the integration of useful features and shared memory.

Although the legacy code has been kept in use, the approach to further model development has become more object-oriented

Conclusions and recommendations

The retention of legacy Fortran code with the addition of fully object-oriented modules accessing shared memory is the primary accomplishment of the CoupModel development. Key to this development were the use of five development tools and our custom management of shared memory. Although the management of shared memory was more complicated than using the MDI architecture it allowed the existing Fortran code to be used without a costly conversion to a completely different language. The CoupModel

Acknowledgements

The authors are listed in alphabetical order to reflect their equal shares in this paper. The programming work has partly been made by students and partly by the authors. Of major importance has been the former work made by Jan Claréus and his contribution in the early discussion on the strategy for the new software development.

References (7)

There are more references available in the full text version of this article.

Cited by (0)

View full text