Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Similar documents
Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming Fall 2008

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming Fall 2007

Computational Methods of Scientific Programming Fall 2008

Computational Methods of Scientific Programming. Matlab Lecture 4 Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill

APPENDIX B. Fortran Hints

Computational Methods of Scientific Programming Lecture 8. Today s lecture Start C/C++ Basic language features

CS61C Machine Structures. Lecture 4 C Pointers and Arrays. 1/25/2006 John Wawrzynek. www-inst.eecs.berkeley.edu/~cs61c/

Lecture 6: Assembly Programs

CSE 374 Programming Concepts & Tools. Hal Perkins Fall 2015 Lecture 15 Testing

Computational Methods of Scientific Programming. Matlab Lecture 3 Lecturers Thomas A Herring Chris Hill

Computational Methods of Scientific Programming Fall 2007

Debugging Guide. Mixed expressions that produce non desired results are used. Example (both a, b are real):

Interlude: Problem Solving

CSC C69: OPERATING SYSTEMS

CS61C : Machine Structures

CSCI341. Lecture 22, MIPS Programming: Directives, Linkers, Loaders, Memory

TESTING, DEBUGGING, EXCEPTIONS, ASSERTIONS

Computational Methods of Scientific Programming Fall 2008

Binding and Storage. COMP 524: Programming Language Concepts Björn B. Brandenburg. The University of North Carolina at Chapel Hill

Bindel, Fall 2011 Applications of Parallel Computers (CS 5220) Tuning on a single core

CS61C : Machine Structures

lecture notes September 2, How to sort?

WELCOME! (download slides and.py files and follow along!) LECTURE 1

Agenda. Peer Instruction Question 1. Peer Instruction Answer 1. Peer Instruction Question 2 6/22/2011

Scientific Programming in C X. More features & Fortran interface

Midterm 1. Administrivia. Virtualizing Resources. CS162 Operating Systems and Systems Programming Lecture 12. Address Translation

IRIX is moving in the n32 direction, and n32 is now the default, but the toolchain still supports o32. When we started supporting native mode o32 was

Exercises: Instructions and Advice

CS61C : Machine Structures

HW1 due Monday by 9:30am Assignment online, submission details to come

C++ Support Classes (Data and Variables)

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

6.172 Performance Engineering of Software Systems Spring Lecture 9. P after. Figure 1: A diagram of the stack (Image by MIT OpenCourseWare.

Review Functions Subroutines Flow Control Summary

Optimising with the IBM compilers

Number Review. Lecture #3 More C intro, C Strings, Arrays, & Malloc Variables. Clarification about counting down

15 Sharing Main Memory Segmentation and Paging

INFS 214: Introduction to Computing

Goals for This Lecture:

Lec 13: Linking and Memory. Kavita Bala CS 3410, Fall 2008 Computer Science Cornell University. Announcements

CSCI-1200 Data Structures Fall 2018 Lecture 5 Pointers, Arrays, & Pointer Arithmetic

Discussion 1H Notes (Week 3, April 14) TA: Brian Choi Section Webpage:

Introduction to Fortran Programming. -Internal subprograms (1)-

DECOMPOSITION, ABSTRACTION, FUNCTIONS

Review! * follows a pointer to its value! & gets the address of a variable! Pearce, Summer 2010 UCB! ! int x = 1000; Pearce, Summer 2010 UCB!

CS61C : Machine Structures

" n=0 n!(2n +1) Homework #2 Due Thursday, October 20, 2011

Start working on a real ( easy as in having an exact closed form solution) problem - consider the wave equation: x t

6.096 Introduction to C++

16 Sharing Main Memory Segmentation and Paging

4. COMPILING AND RUNNING FORTRAN PROGRAMS

Prepared By : Ms. Sanchari Saha ( Asst. Professor) Department : Computer Science & Engineering

A heap, a stack, a bottle and a rack. Johan Montelius HT2017

How To Think Like A Computer Scientist, chapter 3; chapter 6, sections

Bit Hacks Project 1. Last Updated: October 3, 2010

Important Project Dates

Lecture 10 Exceptions and Interrupts. How are exceptions generated?

CS 61C: Great Ideas in Computer Architecture C Pointers. Instructors: Vladimir Stojanovic & Nicholas Weaver

Principles of Operating Systems

ECS 153 Discussion Section. April 6, 2015

Due dates are as mentioned above. Checkoff interviews for PS2 and PS3 will be held together and will happen between October 4 and 8.

Computational Methods of Scientific Programming

1.00 Lecture 4. Promotion

18.01 Single Variable Calculus Fall 2006

DEBUGGING TIPS. 1 Introduction COMPUTER SCIENCE 61A

NAGWare f95 Recent and Future Developments

A First Book of ANSI C Fourth Edition. Chapter 8 Arrays

Linux Memory Layout. Lecture 6B Machine-Level Programming V: Miscellaneous Topics. Linux Memory Allocation. Text & Stack Example. Topics.

Run Time Environment. Procedure Abstraction. The Procedure as a Control Abstraction. The Procedure as a Control Abstraction

Numerical Modelling in Fortran: day 2. Paul Tackley, 2017

6.00 Introduction to Computer Science and Programming Fall 2008

Numerical Methods in Scientific Computation

Welcome to Lab! Feel free to get started until we start talking! The lab document is located on the course website:

Boot Camp. Dave Eckhardt Bruce Maggs

ENCM 339 Fall 2017: Editing and Running Programs in the Lab

More C Pointer Dangers

Numerical Modelling in Fortran: day 3. Paul Tackley, 2017

GDB Tutorial. A Walkthrough with Examples. CMSC Spring Last modified March 22, GDB Tutorial

CS 162 Operating Systems and Systems Programming Professor: Anthony D. Joseph Spring Lecture 13: Address Translation

Homework #3 CS2255 Fall 2012

Administrivia. Deadlock Prevention Techniques. Handling Deadlock. Deadlock Avoidance

Scientific Computing. Algorithm Analysis

6.033 Spring Lecture #6. Monolithic kernels vs. Microkernels Virtual Machines spring 2018 Katrina LaCurts

18-600: Recitation #3

The print queue was too long. The print queue is always too long shortly before assignments are due. Print your documentation

CS/IT 114 Introduction to Java, Part 1 FALL 2016 CLASS 10: OCT. 6TH INSTRUCTOR: JIAYIN WANG

Embedded Systems. 2. Software Development. Lothar Thiele. Computer Engineering and Networks Laboratory

MTAT Software Engineering. Written Exam 17 January Start: 9:15 End: 11:45

COMP1730/COMP6730 Programming for Scientists. Data: Values, types and expressions.

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

CPS221 Lecture: Operating System Protection

MICROSOFT VISUAL STUDIO AND C PROGRAMMING

CS 526 Advanced Topics in Compiler Construction. 1 of 12

File Systems. OS Overview I/O. Swap. Management. Operations CPU. Hard Drive. Management. Memory. Hard Drive. CSI3131 Topics. Structure.

Transcription:

12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill

Review of Lecture 5 Looked at Fortran commands in more detail Control through if and do statements. Logical expressions in Fortran.eq..ne..gt..ge..lt..le. Logical expressions.not..and..or. Looping with do j = start, end, inc and do while constructions. Include, common, and parameter statements as methods of communicating between modules Data and Save statements as methods of initialization and ensuring that modules remember values. 9/27/2011 12.010 Lec 06 2

Final topics Most of today's class will on trying Fortran program. Errors in Fortran programs can occur 3 places: Compile errors: Nature of error is reported and the line number in the source code with the problem. It is best to work from the first to last error. In some cases, an early error can generate many later errors (so try to fix the major problems often other compile errors disappear once these are fixed). Forgetting to end do loops and if statements will often generate many errors. 9/27/2011 12.010 Lec 06 3

Errors 02 Linking errors: Most common here is undefined external which means you seems to call a subroutine or function and the linker can not find the routine you are referring to. In some machines, you might get errors about real*8 variables not being on even byte boundaries. Usually only a problem when you are doing tricky Fortran code. 9/27/2011 12.010 Lec 06 4

Errors 03 Runtime errors: IOSTAT errors associated with file reading and writing. NaN - Not a number, generated when illegal operations are performed (e.g., sqrt(negative number) not stored to a complex variable Inf - Infinite result (usually divide by zero or tan(p/2) Segmentation violation/bus error. These are worst types of errors because where the program stops may not be related at all to where the error is. Common causes are: Incorrect calling arguments and subroutine/function definition Exceeding the bounds of an array 9/27/2011 12.010 Lec 06 5

Errors 04 With optimized code (-On where n=0 5) can generate very strange errors which are not your fault (although the cleaner the code the less likely this is to occur) Try compiling with out optimization (this does not say that you don t have a bug since things move around in memory with different optimization. 9/27/2011 12.010 Lec 06 6

Final comments Other useful utilities (on Unix systems) size program to tell you the size of a program e.g. % size poly_area make Used to organize large program by specification of dependency of modules (e.g., object modules depend of source code and include files, programs depend of libraries and object modules) make checks the dependencies and re-compiles and links only those things that depend of things that have changed. ar and ranlib create libraries and indexes them for faster loading. 9/27/2011 12.010 Lec 06 7

Remainder of class Remainder of class we develop and debug fortran programs. Programs will be written in class to Compute root-mean-square scatter (RMS) of random numbers generated with the intrinsic rand function Students with laptops might want to bring them along so that can work on their own system or on athena. There is wireless internet in the room. 9/27/2011 12.010 Lec 06 8

RMS calculation Root mean square (RMS) scatter is computed by: RMS = RMS = n (x i x ) 2 i=1 n i=1 (n 1) (x i ) 2 nx 2 (n 1) x = x i /n Notice that in the second form, the values do not need to be saved. n i=1 9/27/2011 12.010 Lec 06 9

MIT OpenCourseWare http://ocw.mit.edu 12.010 Computational Methods of Scientific Programming Fall 2011 For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.