ELSEVIER Advances in Engineering Software 22 (1995) 1.53-168 0 1995 Elsevier Sciace Liited Printed in Great Britain. All rights reserved 0965-9978(95)00021-6 0965~9978/95/$09.50 Case study: an incremental approach to re-engineering a legacy FORTRAN Computational Fluid Dynamics code in C++ J. Ewer, B. Knight & D. Cowell The University of Greenwich, Wellington Street, Woolwich, London SE18 6PF, UK (Received 7 December 1994; accepted 1 May 1995) This article describes a practical approach to the manual re-engineering of numerical software systems. The strategy has been applied to re-develop a medium sized FORTRAN-77 Computational Fluid Dynamics (CFD) code into C++. The motivation for software reverse-engineering is described, as are the special problems which influence the re-use of a legacy numerical code. The aim of this casestudy was to extract the implicit logical structure from the legacy code to form the basis of a C++ version using an imposed object-oriented design. An important secondary consideration was for the preservation of tried and tested numerical algorithms without excessive degradation of run-time performance. To this end an incremental re-engineering strategy was adopted that consisted of nine main stages, with extensive regression testing between each stage. The stagesused in this development are described in this paper, with examples to illustrate the techniques employed and the problems encountered. This paper concludes with an appraisal of the development strategy used and a discussion of the central problems that have been addressedin this case study. Key work: re-engineering, reverse-engineering, Computational Fluid Dynamics, CFD, FORTRAN-77, C++, numerical software. 1 INTRODUCTION Many numerical analysis codes currently in use were originally developed as research tools by self-taught programmers without the use of any software engineer- ing methodology. This has led to a situation where ‘legacy’ code is still in use - often in safety critical applications - but where the code is largely ‘black-box’ as far as support staff are concerned. This would not present a major problem if such systemshad no need for change, but this is very seldom the case. Industry continually demands code enhancements and adapta- tions to underlying models, thus posing a serious maintenance problem. Perfective and adaptive maintenance have long been recognised as considerable tasks in themselves. Boehm’ comments that these tasks often exceed the scope and effort applied to the original development. This problem is exacerbated by the informal development of many Please note that the authors acknowledge all registered Trade Mark names and Copyright names mentioned in this text. legacy systemsand the poor or non-existent documenta- tion of research codes. When existing software reachesa state where a required adaptation can no longer be easily implemented, the developer is faced with a number of available options. These range from the extremes of the creation of a new system from scratch, to extensive modification and development within the existing system. Both of these extremes are fraught with difficulties in terms of time and effort, quality assurance, reliability and consistency. These difficulties are particularly acute with numerical codes which have been developed over a number of years by many different engineers, often in a variety of critical situations. Trust in the legacy code is often the determining factor in deciding whether to move to new methods. A relatively recent approach to the problem of adapting and maintaining legacy systems is to use re- engineering techniques. These attempt to use legacy code as a template for an improved system that can then be more effectively maintained. Again, there are a number of extreme approaches to re-engineering. One extreme is 153