20.07.2015 Views

PhD Thesis - staffweb - University of Greenwich

PhD Thesis - staffweb - University of Greenwich

PhD Thesis - staffweb - University of Greenwich

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX 2 : Journal Paper "Case Study : An Incremental Approach to Re-Engineeringa Legacy FORTRAN C.F.D. Code in C++", Ewer J., Knight B. and Cowell D.,Advances in Engineering S<strong>of</strong>tware, Vol. 22, pp 153-168, 1995Non-standard FORTRAN include files were used to pass data between routines.These include files contained the COMMON data declarations that ensured that only onedeclaration existed for each variable. Any identified utility routines kept the parameter listarguments for the passing <strong>of</strong> data. In some instances COMMON was used inappropriatelyfor passing data to utility routines. This problem was quite easy to identify because <strong>of</strong> thenecessary introduction <strong>of</strong> many simple assignment statements (putting data into theCOMMON variables) just before the utility routine call. Figure 4 demonstrates the passing<strong>of</strong> data in COMMON blocks.Data items were grouped into named COMMON blocks with related items, as theywere identified. This identification was facilitated mostly by the dimensions <strong>of</strong> the arraysand the limited amount <strong>of</strong> subroutine header information available. Tentative groupingswere made based on the declared array sizes and these were revised as actual array variableusage was identified within the source code. For example arrays with dimensions <strong>of</strong>(1..NOCELL) indicated cell properties <strong>of</strong> some sort whilst those dimensioned as(1..NOFACE) were face properties. Many <strong>of</strong> the single variables were identified as beingsuitable for COMMON by simple inspection <strong>of</strong> their usage. Switch control variables tendedto be more appropriately passed as arguments to routines. It was preferable to err on the side<strong>of</strong> caution because <strong>of</strong> the slight potential for naming conflicts between new COMMONvariables and dummy arguments.Legacy FORTRANbecomesCALL HBOUND( H(ICELL), .. ) CALL HBOUND( ICELL, .. )SUBROUTINE HBOUND( HVAL, .. ) SUBROUTINE HBOUND( ICELL, .. )REAL HVALINCLUDE 'DATABASE.INC'HVAL = HVAL * ...INTEGER ICELLH(ICELL) = H(ICELL) * ...Figure 5 :Revised argument passing for COMMON data.Dummy argument names (within subroutines) were replaced with direct access tothe newly defined COMMON array variables. Where subroutines were receiving argumentswhich were single array elements it was necessary to ensure that the appropriate array indexwas available within the subroutine. The code fragment (Figure 5) indicates how arrayindex values were passed instead <strong>of</strong> the array elements.Stage (2):Name and algorithm clarification.FORTRAN-77 standard 6 character identifiers and routine names were replacedwith longer, lower case, names that convey functional meaning and usage. SPAG was usedto automatically rename the identifiers as it prevents and reports renaming conflicts. Some<strong>of</strong> the initial name changes are detailed in Figure 6.Appendix 11.2 Page 142-10 10

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!