RELAP5-3D in Fortran 90 Dr. George L Mesina RELAP5 International Users Seminar Nov 18-20, 2008 Idaho Falls, ID
Overview • High-level description of conversion • Database & executable code conversion • Effect of conversion on users and development • Current status • Alpha version tentative release schedule • Summary
F90 Project High-Level Description • Like working on the Winchester House
The Winchester House • Sarah Winchester, heir to Winchester Gun Fortune, built the Winchester Mansion until 1922. • Believed she couldn’t die while house under construction. • Builders worked 24 hours/day, every day, for 38 years. • Room elevations vary within a story, stairs cross stories or lead nowhere, doors open into walls, etc. • Registered as California Historical Landmark with the National Park Service as "a large, odd dwelling with an unknown number of rooms.“ • First count: 140 rooms, later counts: up to 160.
Winchester House • Floor plan developed daily as needed. No overarching plan. • So convoluted, people got lost. Like a 3D maze. • Despite construction and labyrinth, Sarah entertained visitors and gave tours.
RELAP5-Winchester F90 Analogy • RELAP5-3D had a maze-like floor plan (database) • has a huge number of rooms (subroutines) • with ongoing construction (by code developers) • and visitors and tours (users, code usage) • Riemke Repairs Davis Doors Weaver Windows • Excavator Ed Fisher Fascia Judd Additions Nestle Nooks
The Winchester Fortran 90 Analogy • Fortran 90 Project is analogous to: • Replace ALL plumbing & wiring (convert to F90) • Without affecting the work crews (developers) • Or impacting the owner (users)
Fortran 90 Other Objectives • Decomplexify the 3D labyrinth into a clear floor plan. Translation – Make an elegantly simple database. • Fix long-standing problems left by previous builders Translation – Solve some User Trouble Reports. • Don’t slow down anyone else’s work Translation – Don’t impact code runtime • When done, every room left exactly as before Translation – ALL test problems must work with no changes to the calculations • Sound like a job you’d want?
Why Convert to Fortran 90? • Numerous advantages to users • Listed later in presentation • Easier to read and develop • Better for V&V • Reduced maintenance costs • Increase code longevity
Decomplexifying the Database • Eliminate all equivalence statements • These create multiple names for a single memory location • Accidental data destruction • Real equivalent-to integer created severe complications • Derived type arrays organize the data w/in a group
Decomplexifying the Database • Example: original component database • Number of components • Data common to all components • Index array of component start indices • Variable length component data stored contiguouslyOR a “referral” index • Problems: correct indexing, overruns • Derived types and sub-derived types simplify data grouping and accessing
Decomplexifying the Database • Convert comdecks to modules with: 1. Derived type and other data 2. Data dictionary and other documentation within file 3. Service subroutines process module’s data • Constructors and Destructors • Restart Read and Write • Some have other auxiliary routines
Converting Source Code • Major aspects of conversion - Declarations • Modules replace COMDECKS for data access. • Introduction of derived types to organize data into efficient and logical data groupings. • Declarations with “universal” numeric types to reduce numeric precision problems. • Elimination of real-to-integer equivalences.
Converting Source Code • Major aspects – Executable Code • Internal subroutines used to simplify code • Restart controlled by subroutines dedicated to a group of data rather than entire database. • Fortran 90 pointers introduced • Case and multi-else if-statements introduced • Array processing replaces loops in places • Complete rewrites of some subroutines.
Converting Source Code • Fortran conversion - Statements • Obsolescent coding eliminated or replaced. • Machine dependent coding replaced by Fortran 90 intrinsic functions and subroutines. • IF-THEN and IF-THEN-ELSE constructs replace most “GO TO” statements. • ENDDO and ENDIF replace most CONTINUE statements • USE statements replace INCLUDE statements
Converting Source Code • Derived type references replace FA- equivalent arrays. • Ordinal indexing replace fa-indices, simplifies loops. • Fortran 90 pointers replace fa-index based pointers, greatly simplifies pointers.
User Advantages • Machine independent plot file • Can write a plot file on a Windows or Linux platform with any chip • After binary transfer, can use file to make plots on any other such platform • Self-sizing memory • No longer will your code run out of memory before your machine does. • Memory is allocated according to the size requirements of your input
User Advantages • Some previously unrecognized problems corrected • For example, time-step lower limit enforced. • PVM multiple-RHS limit with BPLU solver fixed. • Source Code Users • Can now read and understand code better • Simpler to add new data to database and program data services • Simpler to add new code that uses new or old data • Documentation easier to find and read
User Advantages • Longevity • Obsolete and machine-specific coding removed • Adjusting code to new machine chips and operating systems simpler in F90 • Easier to train new team members (even if they only know C++ or Java but not Fortran) • The code will last
Features not currently available • RGUI – RELAP5-3D Graphical User Interface • Used to show transient calculations in 3D and color, to make movies of the screen display, etc. • Conversion postponed • The following will not be converted • Severe Core Damage Model coding (SCDAP) • IAEA Graphical User Interface • Nuclear Plant Analyzer
Status of Current Version 2.8.3 • An INL internal version created Nov 1, 2008 • Converted => do not reference Fortran77 database. • 81% of all 643 “relap” files • 100% of 135 “envrl” files • Transient semi-implicit solution fully converted • V2.8.3 Runs all previous test cases and new ones. • Answers same as earlier version except where modified for code physics developments or bug fixes
Status of Current Version 2.8.3 • - INL internal version, Nov 1, 2008 • Code speed affected by remaining transfers • Slowdown = Time(v2.8.3) / Time(v184.108.40.206) – 1 • tank.i = 0%, typp12002.i = 36% • worst case: pb_ss_air.i – 133% • Most transfers are in syssol.F. • Plan to eliminate all transfers and regain virtually all speed.
Tentative Development/Release Schedule • Version 2.8.3 - INL internal version, 11/08 • Transient semi-implicit solution free of FA array • Version 2.8.4 - INL planned internal version, 12/08 • Transient free of FA array • Version 2.8.5 - INL planned internal version, 1/09 • Fortran 90 conversion complete • Version 2.9.0 – tentative external release, 2/09 • ALPHA version • Will run all previous test cases and new ones.
Thanks to F90 Project Contributors • Dr George Mesina: PI • Dr. Richard Riemke • Nolan Anderson • Hope Forsman • Richard Moore • Dr. Paul Murray • Consultants: Richard Wagner, Dr. Walt Weaver • Summer students: Joshua Hykes, Riley Cumberland