1 BIL106E Introduction to Scientific & Engineering Computing.

Slides:



Advertisements
Similar presentations
Introduction to Computer Programming Nai-Wei Lin Department of Computer Science and Information Engineering National Chung Cheng University.
Advertisements

ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Lecture 1: Overview of Computers & Programming
Overview of Programming and Problem Solving ROBERT REAVES.
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
COSC 120 Computer Programming
17 March, 2000 CS1001 Lecture 2 Programming and problem solving Software engineering practices.
BIL102F Introduction to Scientific & Engineering Computing.
Chapter Chapter Goals Describe the layers of a computer system Describe the concept of abstraction and its relationship to computing Describe.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design First Edition by Tony Gaddis.
Introduction Extended and Concise Prelude to Programming Concepts and Design Copyright © 2003 Scott/Jones, Inc.. All rights reserved. 1 Introduction.
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Introduction to Computers and Programming. Some definitions Algorithm: –A procedure for solving a problem –A sequence of discrete steps that defines such.
Chapter 1: An Overview of Computers and Programming Languages
©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. COMPSCI 125 Introduction to Computer Science I.
Ceng 230 Programming with C
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages C++ Programming:
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 1 Introduction.
CIS 260 Computer Programming I in C Prof. Timothy Arndt.
Chapter 1 The Big Picture Chapter Goals Describe the layers of a computer system Describe the concept of abstraction and its relationship to computing.
CS190/295 Programming in Python for Life Sciences: Lecture 1 Instructor: Xiaohui Xie University of California, Irvine.
CS102 Introduction to Computer Programming
Chapter 01 Nell Dale & John Lewis.
Copyright © 2012 Pearson Education, Inc. Chapter 1: Introduction to Computers and Programming.
Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 1 Introduction to Computers and Programming.
CS 161 INTRO TO PROGRAMMING I Dr. Blaise W. Liffick Fall
Chapter Introduction to Computers and Programming 1.
CSC 125 Introduction to C++ Programming Chapter 1 Introduction to Computers and Programming.
Introduction COMP104: Fundamentals and Methodology.
BACS 287 Basics of Programming BACS 287.
CS 1 •This is Computer Science 1. •Who is Professor Adams?
BIL106E Introduction to Scientific & Engineering Computing Sources: Programming in F (T.M.R. Ellis and Ivor R. Philips)
Chapter 1: Introduction to Computers and Programming.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 1: Introduction to Computers and Programming.
CISC105 General Computer Science Class 1 – 6/5/2006.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy.
Chapter 1 The Big Picture.
C++ Programming Language Lecture 1 Introduction By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
Visual C++ Programming: Concepts and Projects
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 1: Introduction.
Advanced Computer Architecture 0 Lecture # 1 Introduction by Husnain Sherazi.
1 Week 2 n Organizational matters n Fortran 90 (subset F): Basics n Example programs in detail.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
Fundamental Programming: Fundamental Programming K.Chinnasarn, Ph.D.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 1: An Overview of Computers and Programming Languages.
School of Computer Science & Information Technology G6DICP Introduction to Computer Programming Milena Radenkovic.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and.
BIL102 Introduction to Scientific & Engineering Computing.
Computing Systems & Programming ECE Fundamental Concepts Chapter 1 Engineering Problem Solving.
Programming in C++ Dale/Weems/Headington Chapter 1 Overview of Programming and Problem Solving.
Chapter 1 : Overview of Computer and Programming By Suraya Alias
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 1 Introduction to Computers and Programming.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
BIL104E Introduction to Scientific & Engineering Computing.
The Hashemite University Computer Engineering Department
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Copyright © 2014, 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with C++ Early Objects Eighth Edition by Tony Gaddis,
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Chapter 1: An Overview of Computers and Programming Languages
COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
C++ Programming: From Problem Analysis to Program Design
Programming COMP104: Fundamentals and Methodology Introduction.
Computers: Hardware and Software
Introduction to Computer Programming
ICS103 Programming in C 1: Overview of Computers And Programming
Introduction to computing
Presentation transcript:

1 BIL106E Introduction to Scientific & Engineering Computing

2 Instructor  Selman Nas, Ph.D.  University of Michigan  Assistant Professor at I.T.U.  Department of Aerospace Engineering   URL:  Voice:

Introduction to Computers and Information Systems  A first introduction to the world of computers and scientific computing  Basic skills in using computers for communication and scientific computing  Basic skills for efficient use of information systems: Windows and linux compiling and editing environment Library systems (IMSL, LINPACK, LAPACK, etc.) Scientific visualization

Introduction to Scientific and Engineering Computing  Basic skills for scientific/engineering problem solving using computers: Data structures and algorithms Windows and linux compiling and editing environmentLibrary systems (IMSL, LINPACK, LAPACK, etc.) Library systems (IMSL, LINPACK, LAPACK, etc.) Scientific visualization  Programming skills in a (standard) language  Skills for integrating the computing chain: Analyze  Program  Run  Visualize Windows and linux compiling and editing environment

“Intranet-assisted” course:  Everything (almost) will be available at the Web site   An important fraction of our interaction will be via  It is imperative that you should have an address and be comfortable with a browser (Internet Explorer or Netscape)

6 Working environment  Windows NT Browser, mail, etc. F_world, powerstation (visual Fortran)  Linux Text editor (staroffice, emacs, vi, joe, etc.), or advanced text editor Compiler (F90) Mail (pine, etc.)

IMPORTANT  What you will be reading on this screen will always be available at the Web site  Taking notes: it’s up to you to decide!

Textbook(s)  Programming in F T.M.R. Ellis and Ivor R. Philips M.I.L.’s Reserve Section Photocopies available Fen-Edebiyat printshop  Essential Fortran 90 & 95 Loren P. Meissner M.I.L.’s Reserve Section

Schedule (2+2)  2+2 credıt hours  50 min. lecture + 10 min. break + 50 min. lecture + 10 min. break min. Lab

Requirements  Homework assignments [20%] Every week (except the first one) Pick it up from Web site; turn it in by Due is one week after (e.g. Week1  Week3, Week2  Week4, etc.)  Midterms [40% = 2 x 20%] 2 midterms 7th and 12 th week On paper (for the moment!)  Final Exam [40%] On paper (for the moment!) Class Attendance

11 Tentative Program

12 Tentative Program

13 Tentative Program

14 Introduction to computing  What is a computer? The computer is an automatic device that performs calculations and makes decisions and has capacity for storing and instantly recalling vast amount of information  Why we use a programming language ? The main reason for learning a programming language is to use the computer to model and solve the scientific and engineering problems

How do we use computers in science and engineering?  To organize and analyze data Excel, Access, staroffice, SQL, etc.  To understand the implications of a model of (i.e. to simulate) a natural or human-made system

Engineering simulation of the natural/artificial systems  Build a conceptual  quantitative model (most of the time, write down the appropriate equations)  Formulate a solution to these equations using numerical methods Data structures + algorithms  Program these data structures and algorithms in a language  Run the program and analyze its output using visualization techniques

A brief history of computing machines  Early computing devices 1822: Charles Babbage - Difference Engine - Analytical Engine Ada Augusta - the first programmer 1944: Mark I, an electromechanical computer  Electronic computers  First generation - vacuum tubes 1946: ENIAC - Electronic Numerical Integrator and Computer UNIVAC - Universal Automatic Computer  Second generation [ ]: transistors 1958: IBM : PDP-8, the first minicomputer  Third generation [‘60-’70]: integrated circuits  1964: IBM System/360  Fourth generation: VLSI Recommended reading: Ellis’s book pages:1-13

19 History & Background FOR TRAN  Fortran is created in mid 1950’s and stands for (FORmula TRANslation)  The American National Standards Institute (ANSI) published the first FORTRAN standard in Later the updated ANSI FORTRAN standard was known as FORTRAN 77  More refined, extended and improved version of this language is released as Fortran 90. New features are: (1) Replacement of the old fixed format for programs with a free form (2) Longer names for objects, making programs easier to read (3) New control constructs for selective and repetitive execution (4) New kinds of subprograms to facilitate modular programming (5) Powerful new array-processing mechanisms

20 History & Background (6) Programmer-defined data types (7) Dynamic memory allocation and pointers for constructing complex data structures PROS and CONS: Array handling and number crunching are Fortran’s traditional strong features Except for equivalence and common statements which create some nasty problems (not included in Fortran 90)  Some tools are available that can perform most of the work of converting legacy Fortran codes to modern style

So, why Fortran?  Concise language and advanced features for scientific computing (like array handling)  Smart compilers producing efficient machine code  Legacy: high-quality mathematical libraries (IMSL, NAG, LAPACK…) available  New version have features helpful for parallelization

22 Fortran 90 and its subsets  Compilers for Fortran 90 (or 95) are big and expensive and they do not discourage use of inessential Fortran features. Allows to use Fortran Legacy codes which include thousands of programs and routines in standard libraries such as IMSL (International Mathematics and Statistics Library), NAG (Numerical Algorithm Group), LAPACK and LINPACK.  We may use subsets contain all of the most powerful features that Fortran users need, while providing compatibility with the full Fortran standard language.  The subsets are excellent languages for introductory programming interaction. They have the features that are needed for applied programming in science and engineering (including arrays and complex arithmetic).  They provide a way to teach the good parts of Fortran without exposing students to the bad parts.

23 Fortran 90 and its subsets  They are : inexpensive (or even free) and good teaching tools allow to create well organized and easily maintainable programs powerful and efficient  In our course, we will use Fortran 90.

Software in Science & Engineering  [Ready-made] Analysis and simulation environments  Custom-made programs [codes] You (or your team) write (program) them from scratch Legacy codes: you have to understand and modify them

Programming in the ‘90’s:  Structured programming of the ‘70’s Pascal + C + Fortran 77 + Ada +...  Object-oriented programming of the ‘80’s Smalltalk + C++  ‘90’s Java + Fortran 90/95 HPF, MPI, Open MP (Parallel systems) C#

Fortran 90: Link to the Past  Fortran 90/95 É Fortran 77  All Fortran 77 programs will work with Fortran 90 compilers

The F language  F Fortran 90 F Fortran 77 Fortran 90

The F language  Easy to learn to implement to understand  Powerful enough for use in large programs

program Radioactive_Decay ! ! This program calculates the amount of a radioactive substance that ! remains after a specified time, given an initial amount and its ! half-life. Variables used are: ! InitalAmount : initial amount of substance (mg) ! HalfLife : half-life of substance (days) ! Time : time at which the amount remaining is calculated (days) ! AmountRemaining : amount of substance remaining (mg) ! ! Input: InitialAmount, HalfLife, Time ! Output: AmountRemaining ! implicit none real :: InitialAmount, HalfLife, Time, AmountRemaining ! Get values for InitialAmount, HalfLife, and Time. print *, "Enter initial amount (mg) of substance, its half-life (days)" print *, "and time (days) at which to find amount remaining:" read *, InitialAmount, HalfLife, Time ! Compute the amount remaining at the specified time. AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife) ! Display AmountRemaining. print *, "Amount remaining =", AmountRemaining, "mg" end program Radioactive_Decay

program Radioactive_Decay ! ! This program calculates the amount of a radioactive substance that ! remains after a specified time, given an initial amount and its ! half-life. Variables used are: ! InitalAmount : initial amount of substance (mg) ! HalfLife : half-life of substance (days) ! Time : time at which the amount remaining is calculated (days) ! AmountRemaining : amount of substance remaining (mg) ! ! Input: InitialAmount, HalfLife, Time ! Output: AmountRemaining ! implicit none real :: InitialAmount, HalfLife, Time, AmountRemaining ! Get values for InitialAmount, HalfLife, and Time. print *, "Enter initial amount (mg) of substance, its half-life (days)" print *, "and time (days) at which to find amount remaining:" read *, InitialAmount, HalfLife, Time ! Compute the amount remaining at the specified time. AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife) ! Display AmountRemaining. print *, "Amount remaining =", AmountRemaining, "mg" end program Radioactive_Decay

program Radioactive_Decay ! ! This program calculates the amount of a radioactive substance that ! remains after a specified time, given an initial amount and its ! half-life. Variables used are: ! InitalAmount : initial amount of substance (mg) ! HalfLife : half-life of substance (days) ! Time : time at which the amount remaining is calculated (days) ! AmountRemaining : amount of substance remaining (mg) ! ! Input: InitialAmount, HalfLife, Time ! Output: AmountRemaining ! implicit none real :: InitialAmount, HalfLife, Time, AmountRemaining ! Get values for InitialAmount, HalfLife, and Time. print *, "Enter initial amount (mg) of substance, its half-life (days)" print *, "and time (days) at which to find amount remaining:" read *, InitialAmount, HalfLife, Time ! Compute the amount remaining at the specified time. AmountRemaining = InitialAmount * 0.5 ** (Time / HalfLife) ! Display AmountRemaining. print *, "Amount remaining =", AmountRemaining, "mg" end program Radioactive_Decay

32 Computer Structure  A computer, usually, has three main parts (1) input devices (keyboard, mouse etc.), (2) output devices (screen, printer etc.) and (3) hard disc (external memory, motherboard, sound card etc.)  Central Processing Unit, or CPU is the heart of a computer. Controls the operation of the entire system performs the arithmetic and logic operations stores and retrieves instructions and data  Arithmetical and logical operations are carried out by ALU (Arithmetic Logic Unit) of the CPU.  RAM (Random Access Memory) or main memory is the place to store the instructions and data of the programs being executed (volatile memory).  ROM (Read Only Memory) is nonvolatile memory used to store critical information, such as start-up instructions which is too important to lose.

33 Computer Structure Input Devices Output Devices Control Unit Arithmetic- Logic Unit Main Memory External Memory CPU = Central Processing Unit Major Components of a computing system

34 Computer Structure  Registers are a set of special high-speed memory locations within the CPU  Access speed within the register is thousands of times faster than access speed in RAM MEMORY MEASUREMENT  The memory unit of a computer is two-state devices. Then it is natural to use a binary scheme (using only the two binary digits {bits} 0 and 1 to represent information in a computer).  Bytes = 8. Bits  Memory is commonly measured in bytes, and a block of 2 10 = 1024 bytes = 1 K 1 MB = 1024 K = = = 2 20 = 1,048,576 bytes. Or = 2 23 = 8,384,608 bits.

35 Memory & Compiling  Bytes are grouped together into WORDS  The number of bits in a word is equal to the number of bits in a CPU register  The word size thus varies from one computer to another  Common word sizes are 16 bits (=2 bytes) and 32 bits (=4 bytes) COMPILING  Most programs are written in a high-level language such as Fortran and a compiler translates each statement in the program into a sequence of basic machine (or assembly) language instructions. Machine language consists of two parts: (1) a numerical opcode (multiply, add, store etc.), (2) the address of the operand.

36 Compiling Process Source Program (High-level language) Compiler Object Program (machine language) Compilation errors Run-time errors Steps of execution of a Fortran program

37 Programming and Problem Solving Program-development process consists of at least five steps: 1) Problem analysis and specification The first stage in solving the problem is to analyze the problem and formulate a precise specification of it 2) Data organization and algorithm design Determine how to organize and store the data in the problem. Develop procedures to process the data and produce the required output. These procedures are called algorithms. 3) Program coding Coding is the process of implementing data objects and algorithms in some programming language.  A Simple program begins with the PROGRAM, and ends with the END PROGRAM statements

38 Programming and Problem Solving A simple program PROGRAM test PRINT *, ”Hello!” END PROGRAM test 4) Execution and testing This is the checking step that the algorithm and program are correct. Compile (produce an object file) {compile-time errors} + run {run-time errors}: IMPORTANT!! Logic errors that arise in the design of the algorithm or in the coding of the program are very hard to find. 5) Program maintenance In real world applications, programs need to modify to improve their performance.

39 Basic statements  A program is just a sequence of lines of text. Execution of the program is a separate process that goes on inside the computer when the program is executed. The program statements are static, or fixed, while the execution process is dynamic, or changing. The statements exists in space, and the execution occurs in a time dimension. First instruction Last instruction Execution of first instruction Execution of last instruction Correspondence between the program and its execution process

40 Basic statements Control Constructs There are three ways to change the normal execution sequence 1) Branch structure: If statement 2) Loop structure: do statement 3) Procedure reference: statement procedure Assignment Average = (X + Y) / 2.0 (X+Y)/ Average Y X How F assigns the value of the expression (X+Y)/2.0 to average

41 Basic FORTRAN 90 statements Type declarations The principal data types for F numerical data are: 1) real, 2) integer, 3) complex, 4) logical, and 5) character. Input and Output read (unit=*, fmt=*) Input list write (unit=*, fmt=*) Output list Repetition do statement Block of statements to be repeated end do

42 First Steps in F Programming  From problem to program in three basic steps: 1. Specify the problem clearly 2. Analyse the problem and break it down into its fundamental elements 3. Code the program according to the plan developed at step 2. Additionally there is also a 4 th step 4. Test the program exhaustively, and repeat steps 2 and 3 as necessary

43 First Steps in F Programming Reading Homework: Ellis’s Book  Read pages between  Do self-test exercises 2.1