Good FORTRAN Programs



Similar documents
Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

Project Planning. COSC345 Lecture 3 Slides: Andrew Trotman Dramatic presentation: Richard O Keefe. Software Engineering 2013

Introduction to Embedded Systems. Software Update Problem

Chapter 13: Program Development and Programming Languages

Software Development. Topic 1 The Software Development Process

Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Compiler I: Syntax Analysis Human Thought

Basic Testing Concepts and Terminology

System Structures. Services Interface Structure

HPC Wales Skills Academy Course Catalogue 2015

Experiences with 2-D and 3-D Mathematical Plots on the Java Platform

Outline. 1 Denitions. 2 Principles. 4 Implementation and Evaluation. 5 Debugging. 6 References

Types Of Operating Systems

Higher Computing. Software Development. LO1 Software Development process

Chapter 12 Programming Concepts and Languages

Fourth generation techniques (4GT)

Testing Introduction. IEEE Definitions

Logistics. Software Testing. Logistics. Logistics. Plan for this week. Before we begin. Project. Final exam. Questions?

3 SOFTWARE AND PROGRAMMING LANGUAGES

Introduction. What is an Operating System?

Flowchart Techniques

Levels of Software Testing. Functional Testing

Lecture 17: Requirements Specifications

Software Testing. Definition: Testing is a process of executing a program with data, with the sole intention of finding errors in the program.

CS 3530 Operating Systems. L02 OS Intro Part 1 Dr. Ken Hoganson

Total Quality Management (TQM) Quality, Success and Failure. Total Quality Management (TQM) vs. Process Reengineering (BPR)

Software Engineering. Software Development Process Models. Lecturer: Giuseppe Santucci

Chapter 13: Program Development and Programming Languages


How To Improve Software Quality

Software Testing Interview Questions

50 Computer Science MI-SG-FLD050-02

Interpreters and virtual machines. Interpreters. Interpreters. Why interpreters? Tree-based interpreters. Text-based interpreters

Jonathan Worthington Scarborough Linux User Group

How To Visualize Performance Data In A Computer Program

Objectives. Chapter 2: Operating-System Structures. Operating System Services (Cont.) Operating System Services. Operating System Services (Cont.

Testing & Verification of Digital Circuits ECE/CS 5745/6745. Hardware Verification using Symbolic Computation

ADVANCED SCHOOL OF SYSTEMS AND DATA STUDIES (ASSDAS) PROGRAM: CTech in Computer Science

EMC Publishing. Ontario Curriculum Computer and Information Science Grade 11

Software Engineering. How does software fail? Terminology CS / COE 1530

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Data Analysis 1. SET08104 Database Systems. Napier University

find model parameters, to validate models, and to develop inputs for models. c 1994 Raj Jain 7.1

Appendix M INFORMATION TECHNOLOGY (IT) YOUTH APPRENTICESHIP

Thomas Jefferson High School for Science and Technology Program of Studies Foundations of Computer Science. Unit of Study / Textbook Correlation

Test Specification. Introduction

Chapter 1. Dr. Chris Irwin Davis Phone: (972) Office: ECSS CS-4337 Organization of Programming Languages

Different Approaches to White Box Testing Technique for Finding Errors

26. Legacy Systems. Objectives. Contents. Legacy systems 1

CS 40 Computing for the Web

SECTION 2 PROGRAMMING & DEVELOPMENT

Chapter 11: Integrationand System Testing

CS3600 SYSTEMS AND NETWORKS

Axiomatic design of software systems

Overview Motivating Examples Interleaving Model Semantics of Correctness Testing, Debugging, and Verification

x86 ISA Modifications to support Virtual Machines

COS 318: Operating Systems

Software Engineering for LabVIEW Applications. Elijah Kerry LabVIEW Product Manager

CSTE Mock Test - Part III Questions Along with Answers

Design Compiler Graphical Create a Better Starting Point for Faster Physical Implementation

Software Quality. Software Quality Assurance and Software Reuse. Three Important Points. Quality Factors

Chapter 1: Introduction. What is an Operating System?

Lectures 5-6: Taylor Series

Improved Software Testing Using McCabe IQ Coverage Analysis

SOFTWARE-IMPLEMENTED SAFETY LOGIC Angela E. Summers, Ph.D., P.E., President, SIS-TECH Solutions, LP

How To Write a Technical Lab Report with Practical Examples

Language Evaluation Criteria. Evaluation Criteria: Readability. Evaluation Criteria: Writability. ICOM 4036 Programming Languages

Chapter 3: Operating-System Structures. System Components Operating System Services System Calls System Programs System Structure Virtual Machines

Classnotes 5: 1. Design and Information Flow A data flow diagram (DFD) is a graphical technique that is used to depict information flow, i.e.

White Paper. The Power of Siebel escripting at Runtime. Bringing Siebel Developer Closer to Rapid Application Development

Software Engineering. So(ware Evolu1on

2.2 INFORMATION SERVICES Documentation of computer services, computer system management, and computer network management.

COMP5426 Parallel and Distributed Computing. Distributed Systems: Client/Server and Clusters

Software testing. Objectives

HSL and its out-of-core solver

Loss & Continuity Testing with MPO/ MTP Connectors

Establishing Great Software Development Process(es) for Your Organization. By Dale Mayes

Hypercosm. Studio.

Software Design and Development

THE NAS KERNEL BENCHMARK PROGRAM

Intro to scientific programming (with Python) Pietro Berkes, Brandeis University


Architectures and Platforms

Debugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go

I PUC - Computer Science. Practical s Syllabus. Contents

Software Engineering Techniques

Stack machines The MIPS assembly language A simple source language Stack-machine implementation of the simple language Readings:

Introduction to Software Engineering. 8. Software Quality

Advanced compiler construction. General course information. Teacher & assistant. Course goals. Evaluation. Grading scheme. Michel Schinz

COMPUTER SCIENCE (5651) Test at a Glance

Configuration Management: An Object-Based Method Barbara Dumas

Compilers. Introduction to Compilers. Lecture 1. Spring term. Mick O Donnell: michael.odonnell@uam.es Alfonso Ortega: alfonso.ortega@uam.

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

Transcription:

Good FORTRAN Programs Nick West Postgraduate Computing Lectures Good Fortran 1

What is a Good FORTRAN Program? It Works May be ~ impossible to prove e.g. Operating system. Robust Can handle bad data e.g. I/O error or unfriendly user! User Friendly Not user hostile! Questions - clear, offer help, diagnose bad replies. Multi-path? Allow backoff. No unnerving silence! Restartable. Maintainable Environment dynamic! Well structured - minor changes - easy to find & fix and are local. Postgraduate Computing Lectures Good Fortran 2

What is a GOOD FORTRAN Program? (cont.) Extendable To similar tasks. Portable Use standard compilers and libraries. Postgraduate Computing Lectures Good Fortran 3

Stages of Program Development Design Analysis of problem. Outline design in English and Maths. Detailed specification. Coding Pseudo coding. Language specific translation. Testing Components in test-bed (bottom-up). Skeleton (top-down). Common Fault:- Not enough time on design and testing Coding should be ~ mechanical - if not design incomplete. Postgraduate Computing Lectures Good Fortran 4

Design: General Clear Statements in English and Maths Write them down! Specify I/O & Actions Consider Possible Strategies What are the intermediate data structures? Postgraduate Computing Lectures Good Fortran 5

General Design (cont.) Limit Special Requirements CPU intensive? Divide or make restartable. Isolate specific device code (graphics packages do this for displays). Task Generalisation Plan Testing Write down verification procedures. Plan diagnostic printout of internal data structures and program flow. Take Great Care at this Stage! Mistakes may be very expensive! In HEP have used SA/SD Structured Analysis. Structured Design. Postgraduate Computing Lectures Good Fortran 6

Design: Detailed Now use:- Routine Names Calling sequences & Black Box spec. Data Structures Precise descriptions of each data item for:- COMMON blocks. I/O records. Two Common Techniques:- Bottom-Up. Top-Down. Postgraduate Computing Lectures Good Fortran 7

Bottom-Up Design Example, a Graphics Package Layer 0: Pen Up/Down. Move in X/Y Layer 1: Move (Pen Up, Move). Draw (Pen Down, Move) Layer 2: Draw Line (Move, Join) Layer 3: Draw Char (Move, Draw Line).... Layer n: Draw Histogram, Plot Function. Principles:- Each layer uses services from layers below. Each layer provides complete and consistent model to layer above. Only layer 1 talks to hardware. Postgraduate Computing Lectures Good Fortran 8

Top-Down Design Divide and Conquer Separate program into few logically independent sections. Repeat with each section as necessary. Implement each section at each level as a subroutine. Has Enormous Advantages Simplifies problem. Testing: Can test sections separately. Maintenance: easy to find and fix. Extendable: Plug in new section e.g. new processor. Postgraduate Computing Lectures Good Fortran 9

Top-Down Design (cont.) Structuring Separate and simplify. Minimise Interconnections. Separate Out:- Machine Dependencies:- I/O Generalise to machine independent concept. Use bottom-up to implement. Control & Processing Boss & Slave Model:- BOSS - decides what to do. SLAVES - do the work. COMMONS Keep separate data in separate commons. Postgraduate Computing Lectures Good Fortran 10

Top-Down Design (cont.) SUBROUTINES Either - general function (test: could it go in library?) Or - Called by one routine (its Boss). Interfaces In FORTRAN either COMMON or Arg list. Long Range i.e. upper level, use arg list (easy to replace). Restrict COMMONs to lower level, tightly coupled and localise use (esp. modification). E.g. Graphics Package Pen X,Y in COMMON. Use directly within package. Provide subroutine for caller. Postgraduate Computing Lectures Good Fortran 11

Design: Error Paths Error Paths May dominate program design (esp. interactive ones) because:- If an error can occur it will (and if it can t it probably will). To deal with an error must detect and analyse. Standard data may have few process paths, but errors are deviations, they may have many. Example 1000 data items, 10 bad => 1% error rate 1 good data path, 10 error path => 90% error handling Postgraduate Computing Lectures Good Fortran 12

Coding Star System: * worth thinking about. ** only break for good reason. *** never break. COMMON Blocks *** Meaningful names (e.g. I - useless). Although 6 letters names is FORTRAN77 standard, most FORTRAN compilers permit more. ** Avoid simple names e.g. SUM (used locally). *** Identical definition in all routines. * Use a unique prefix on all variables.. * Use INCLUDE (not official FORTRAN77 - would be *** if it was). Postgraduate Computing Lectures Good Fortran 13

Coding (cont.) SUBROUTINES *** Continue top-down - divide code into blocks. *** Minimise/eliminate GOTOs. If possible only jump down to next block. Sacrifice a little efficiency for fewer flow paths. ** Only jump up as an iteration. ** Use labels that reflect block structure e.g 100-199 for first block. *** Keep labels in ascending order. *** Give variables meaningful names. ** Avoid long routines - 200 lines is getting too long. * Collect formats at the end - helps if used multiple times and when adding more. ** Use IMPLICIT NONE if possible (not FORTRAN77). Postgraduate Computing Lectures Good Fortran 14

Coding (cont.) SUBROUTINES (cont.) *** Always comment routine. A good scheme:- 1 or 2 line summary. Author names and a revision history of changes. Description of interface:- Arg. list Specify what are input } COMMONs and output Details of implementation. Separate out and comment each block. *** Take time to layout code professionally - indenting code and aligning material makes it more readable (and can highlight mistakes!) Postgraduate Computing Lectures Good Fortran 15

Program Modification Either Function or Performance Function Golden Rule: How would I designed it if I were starting now? Not: What is the absolute minimum change. It may get job done faster but shortens program lifetime! Performance Optimise compilation. Use Performance Analysers to find hot spots and then recode. If all else fails, take a fresh look at intermediate data. Postgraduate Computing Lectures Good Fortran 16

Testing May be easy to ~ impossible. With complex programs it is very hard to prove free of bugs (except by redefining them as features ). Minimise Bugs by Well Structured with Fewest Possible Flow Paths. Testing Methods:- Desk Check - take time to read slowly checking:- Flow paths. Calling sequences. Formulae. Bottom-Up testing - Test lowest level modules using a Test Bed. Test levels above. Postgraduate Computing Lectures Good Fortran 17

Testing (cont.) Testing Methods (cont.) Top-Down Testing - Start with top levels with almost dummy modules. Add more function step by step. Good for complex program development. Minimum Condition:- Test every line of code. Remember to retest after fixing bugs. Leave in Switchable Debug Printout Useful despite powerful debuggers. Postgraduate Computing Lectures Good Fortran 18