Skip to main content
U.S. Department of Energy
Office of Scientific and Technical Information

Restructuring of RELAP5-3D

Conference ·
OSTI ID:911882
The RELAP5-3D source code is unstructured with many interwoven logic flow paths. By restructuring the code, it becomes easier to read and understand, which reduces the time and money required for code development, debugging, and maintenance. A structured program is comprised of blocks of code with one entry and exit point and downward logic flow. IF tests and DO loops inherently create structured code, while GOTO statements are the main cause of unstructured code. FOR_STRUCT is a commercial software package that converts unstructured FORTRAN into structured programming; it was used to restructure individual subroutines. Primarily it transforms GOTO statements, ARITHMETIC IF statements, and COMPUTED GOTO statements into IF-ELSEIF-ELSE tests and DO loops. The complexity of RELAP5-3D complicated the task. First, FOR_STRUCT cannot completely restructure all the complex coding contained in RELAP5-3D. An iterative approach of multiple FOR_STRUCT applications gave some additional improvements. Second, FOR_STRUCT cannot restructure FORTRAN 90 coding, and RELAP5-3D is partially written in FORTRAN 90. Unix scripts for pre-processing subroutines into coding that FOR_STRUCT could handle and post-processing it back into FORTRAN 90 were written. Finally, FOR_STRUCT does not have the ability to restructure the RELAP5-3D code which contains pre-compiler directives. Variations of a file were processed with different pre-compiler options switched on or off, ensuring that every block of code was restructured. Then the variations were recombined to create a completely restructured source file. Unix scripts were written to perform these tasks, as well as to make some minor formatting improvements. In total, 447 files comprising some 180,000 lines of FORTRAN code were restructured. These showed significant reduction in the number of logic jumps contained as measured by reduction in the number of GOTO statements and line labels. The average number of GOTO statements per subroutine dropped from 8.8 before restructuring to 5.3 afterwards, a reduction of 40%. The maximum number of GOTO statements in any subroutine dropped from 213 to 99, a factor of 2.1. Finally, the maximum number of statement labels dropped from 210 to 43, a factor of nearly 5. While many blocks of code remain unstructured, a much greater fraction of the code is now structured. These measurements indicate a serious reduction in degree of interweaving of logic paths.
Research Organization:
Idaho National Laboratory (INL)
Sponsoring Organization:
DOE - NE
DOE Contract Number:
AC07-99ID13727
OSTI ID:
911882
Report Number(s):
INL/CON-05-00719
Country of Publication:
United States
Language:
English

Similar Records

STOMP-W
Software · Tue Feb 20 19:00:00 EST 2018 · OSTI ID:code-8732

Streamlining of the RELAP5-3D Code
Conference · Thu Nov 01 00:00:00 EDT 2007 · OSTI ID:938454

RELAP5-3D Architectural Developments in 2004
Conference · Sun Aug 01 00:00:00 EDT 2004 · OSTI ID:911041