Basic Fortran I/O Concepts

Size: px
Start display at page:

Download "Basic Fortran I/O Concepts"

Transcription

1 Basic Fortran I/O Concepts LECTURE OUTLINE Free versus Directed I/O Edit Descriptors Carriage Control Numeric Control Character Control Spacing Control Repeat Specifier Read and Write to Files Examples!! Assignment Free vs. List Directed I/O Free Formatting A simplified method for input and output without detailed formatting instructions Output variables and strings are sent to the output device without instructions. An asterisk is used in place of the format specifier The computer formats the output according to internal rules You specify the output, the computer specifies the format Simple, but it provides NO flexibility Free-format example: WRITE(*,*) 'PROJECTILE VELOCITY =', VF free format specifier String label Variable value

2 List Directed Input and Output Provides the flexibility the free formatting doesn't have You specify the exact format of the output Method is a bit tedious, but you have complete control Utilizes a group of edit descriptors Example of List Directed output: WRITE(*,20) VO, VF 20 FORMAT (' ', T15, 'INITIAL PROJECTILE VELOCITY =', F10.4/& &T15, 'FINAL PROJECTILE VELOCITY =', F10.4) Examples: Formatted Write Statements WRITE (*,25) Q, LOAD 100 FORMAT (' THE MASS AND LOAD VALUES ARE ',F8.1,' AND ',F8.1) You are not limited to the format statement, the specifier can occur in numerous configurations: WRITE (*,30) Q, LOAD 30 FORMAT (T20,2F15.3) WRITE (*, '(T20,2F15.3)') Q, LOAD CHARACTER(LEN=35)::TEXT TEXT='(T20,2F15.3)' WRITE (*,TEXT) Q, LOAD!STANDARD FORMAT STATEMENT!FORMAT IN CHARACTER CONSTANT!FORMAT IN CHARACTER VARIABLE

3 Edit Descriptors What do they describe? The alignment of the output The number of decimal places to be written Spacing between the output, both horizontal and vertical Horizontal alignment Carriage Control Carriage control is a nearly obsolete feature of Fortran, but is kept for maximum portability of your code. What it does: Resets printer and announces a new line of text Controls vertical spacing, i.e. single space, double space, new page. Numeric Descriptors Integer Descriptor Real Descriptors for Double Precision I F, E, ES, G D Other Descriptors Function Descriptor Character A Tab to T New line / Grouping ( ) Repetition [coefficient]

4 Carriage Control Character Position: Start New Line Double Space New Page No New Line Initializes Printer for output First character in line to be printed determines line spacing action. (' ') ('0') ('1') ('+') Use on line printers to control paper feed and vertical spacing. Laser printers ignore this convention!! Keep for portability and to avoid problems if carriage control is encountered! Integer Output -- The I Descriptor Provide format for all integer output Format: riw or riw.m Example Source Code: INTEGER :: A=-25, B=5, C=-55, D=11 WRITE (*, 110) A,A+25,B,C,D WRITE (*, 120) A,A+25,B,C,D WRITE (*, 130) A,A+25,B,C,D 110 FORMAT (' ', 5I8)!40 spaces total 120 FORMAT (' ', 2I8.0, 2I8, I10.6 )!42 spaces total 130 FORMAT (' ', 2I8.3, 2I8, I5 )!37 spaces total Output: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Field Spacing Illustrator

5 Real Output -- The F Descriptor Format: Provide format for all REAL output rfw.d Example Source Code: Note that space is required for decimal points and negative signs. And, if you want to separate data on the same row, best to allow a few extra spaces! Output: REAL :: P=-198.3, Q=9.43, R=787.4 WRITE (*, 110) P, Q, R WRITE (*, 120) P, Q, R 110 FORMAT (' ', 3F7.3 ) 120 FORMAT (' ', 3F10.2 ) ******* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Field Spacing Illustrator Real Output -- The E Descriptor Provide exponential notation for all REAL output Format: rew.d w d + 8 Example Source Code: Output: REAL :: N=6.023E23, BW=2.4E10, LIGHT=3.0E8,NEG=-8.0 WRITE (*, 100) N, BW, LIGHT, NEG WRITE (*, 101) N, BW, LIGHT, NEG WRITE (*, 102) N, BW, LIGHT, NEG 100 FORMAT (' ', 4E14.4 ) 101 FORMAT (' ', 4E10.4 ) 102 FORMAT (' ', 4E9.4 ) E E E E E E E E E E E+09********* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

6 Real Output -- The ES Descriptor Provide SCIENTIFIC notation for all REAL output Format: resw.d w d + 8 Example Source Code: REAL :: N=6.023E23, BW=2.4E10, LIGHT=3.0E8,NEG=-8.0 WRITE (*, 100) N, BW, LIGHT, NEG 100 FORMAT (' ', 4ES14.4 ) Output: E E E E+00 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Horizontal Positioning -- The X and T Descriptor The X Descriptor Format: Provide horizontal spacing, one space at a time. Does not work on ELF90 nx The T Descriptor To advance to a specified field space, similar to a tab character in word processing Format: Tc c=column number

7 Horizontal Positioning -- The X and T Descriptor X Descriptor Example REAL:: MASS=1.529, VOLUME=0.65 DENSITY=MASS/VOLUME WRITE(*, 110) WRITE(*, 120) MASS, VOLUME, DENSITY 110 FORMAT (' TEST RESULTS FROM LABORATORY MEASUREMENT'/& &'MASS, KG VOLUME, CC DENSITY,G/CC) 120 FORMAT (' ',F7.2,5X,F10.2,7X,F12.2)!Or, a better, easier, and ELF90 compatible approach is below: 120 FORMAT (' ',F7.2,F15.2,F19.2) Output: TEST RESULTS FROM LABORATORY MEASUREMENT MASS, KG VOLUME, CC DENSITY,G/CC ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Horizontal Positioning -- The X and T Descriptor T Descriptor Example Output: WRITE(*,23) WRITE(*,19) TEMP1, X1, EXPAN1 WRITE(*,19) TEMP2, X2, EXPAN2 WRITE(*,19) TEMP3, X3, EXPAN3 WRITE(*,19) TEMP4, X4, EXPAN4 WRITE(*,19) TEMP5, X5, EXPAN5 23 FORMAT (' ', T4,'TEMP (oc)', T15, 'LENGTH OF & &BAR (CM)', T35, 'EXPANSION (%)') 19 FORMAT (' ', T5, F6.1, T15, F9.3, T33, F9.3) STOP END TEMP (oc) LENGTH OF BAR (CM) EXPANSION (%) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

8 Character Output -- The A Descriptor Format: Example Source Code: Output: Provide format for all Character output ran CHARACTER(LEN=50)::COURSE COURSE = 'INTRO TO COMPUTING FOR ENG' WRITE(*,100) COURSE 100 FORMAT (' ', A13)!PARTIAL VARIABLE WRITE(*,110) COURSE 110 FORMAT (' ', A50)!FULL VARIABLE INTRO TO COMP INTRO TO COMPUTING FOR ENG ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^Field Spacing Illustrator Reading and Writing to Files Places to store data --avoid reentry each time program is run Save and store output Fortran files are sequential access Key I/O File Statements are: Using Files: Some Essential commands Open a file, assign a unit number, and give status Close file, terminate association with unit number Read data from an established unit number/file. Write data to an established unit number/file. OPEN CLOSE READ WRITE

9 Unit Numbers Unit Number Conventions and Practices I/O number 5 is reserved for input from keyboard [Fortran convention, Used at Rutgers] I/O number 6 is reserved for output to screen [Fortran convention, Used at Rutgers] Pick any other number you like to name your files. 3, 28, 64, Your file will be named accordingly, i.e DATA.F03 The OPEN Statement Format: To associate a file with a I/O number OPEN (open_list) Open_list options UNIT= int_expr Any integer except 5 or 6 FILE= char_expr Any name you want STATUS= char_expr Old, New, Replace ACTION= char_expr Read or Write IOSTAT= int_var Not Input, the computer returns this one: Open successful, then IOSTAT=0 EOF on READ, then IOSTAT < 0 Other Error, IOSTAT > 0 = Error Code

10 Using Files with Fortran90 Fortran 90 has excellent file access capability. One of the most important features is the IOSTAT=clause feature, which enables you to trap file access errors and prevent your program from crashing during execution. An example of the form for IOSTAT is: READ (20,*,IOSTAT=STATUS) where the READ statement accesses data from a disk file associated with the unit number 20, and free-form I/O is utilized as represented by the asterisk, *. The system returns a value for IOSTAT that indicates success or failure in accessing the file. Using Files with Fortran90 The use of this construction is shown well in an example given by Chapman in the textbook. Refer to page 191, example 4-3. The problem has two objectives: To read real values from a data file To detect any errors and the end of file when it occurs.

11 Using Files with Fortran90 PSEUDOCODE!! Get file name from user Assign unit number and open the file Check for errors on open If no open error then read data Continue to check IOSTAT for error flag as data is read If error, exit with error message If end of file, exit with completion message Using Files with Fortran90 Start THE ALGORITHM -- In Flowchart Format Num = 0 READ value READ filename OPEN filename Status = = 0? true Num = Num + 1 false Status > 0? true WRITE 'Error Reading Line' false WRITE 'End of file', num Status = = 0? true WRITE num, value false WRITE 'Error Opening File, Status =' Stop Source: Fortran 90/95 for Scientists and Engineers by Stephen Chapman. Published by McGraw Hill, 1998, page 193.

12 Example Problem [4-3, page 191] THE PROGRAM -- Setup program PROGRAM READ IMPLICIT NONE! DECLARE VARIABLES CHARACTER(LEN=20) :: FILENAME! NAME OF FILE TO OPEN INTEGER :: NVALS = 0! NUMBER OF VALUES READ INTEGER :: STATUS! I/O STATUS REAL :: VALUE! THE REAL VALUE READ IN! GET THE FILE NAME AND ECHO IT BACK TO THE USER. WRITE (*,*) 'PLEASE ENTER INPUT FILE NAME: ' READ (*,*) FILENAME WRITE (*,1000) FILENAME 1000 FORMAT (' ','THE INPUT FILE NAME IS: ', A) Example Problem [4-3, page 191] THE PROGRAM -- Open file and read values! OPEN THE FILE AND CHECK FOR ERRORS ON OPEN. OPEN (UNIT=3, FILE=FILENAME, STATUS=' OLD ', ACTION='READ', & IOSTAT=STATUS ) OPENIF: IF ( STATUS == 0 ) THEN! OPEN WAS OK. READ VALUES. READLOOP: DO READ (3,*,IOSTAT=STATUS) VALUE! GET NEXT VALUE IF ( STATUS /= 0 ) EXIT! EXIT IF NOT VALID NVALS = NVALS + 1! VALID: INCREASE WRITE (*,1010) NVALS, VALUE! ECHO TO SCREEN 1010 FORMAT (' ','LINE ', I6, ': VALUE = ',F10.4) END DO READLOOP! THE WHILE LOOP HAS TERMINATED. WAS IT BECAUSE OF A READ! ERROR OR BECAUSE OF THE END OF THE INPUT FILE?

13 Example Problem [4-3, page 191] THE PROGRAM -- Read has terminated, report why --Finish up READIF: IF ( STATUS > 0 ) THEN! A READ ERROR OCCURRED. TELL USER WRITE (*,1020) NVALS FORMAT ('0','AN ERROR OCCURRED READING LINE ', I6) ELSE! THE END OF THE DATA WAS REACHED. TELL USER. WRITE (*,1030) NVALS 1030 FORMAT ('0','END OF FILE REACHED. THERE WERE ', I6, & ' VALUES IN THE FILE.') END IF READIF ELSE OPENIF WRITE (*,1040) STATUS 1040 FORMAT (' ',' ERROR OPENING FILE: IOSTAT = ', I6 ) END IF OPENIF!CLOSE FILE CLOSE ( UNIT=3 ) STOP END PROGRAM READ Key Fortran90 Programming Issues I/O Format Descriptors Use carriage control by placing the correct descriptor in column one of the output field. Match data type with format specifier type Use asterisk rather than 5 or 6 when indicating default devices Use STATUS='OLD' and ACTION='READ' for input files to protect data. Use STATUS='NEW' for all output files to protect existing files. Use IOSTAT= with file read commands to detect errors and EOF Source: Fortran 90/95 for Scientists and Engineers by Stephen Chapman. Published by McGraw Hill, 1998, page 206.

14 Homework Assignment -- Week 4 Read Chapter 4 -- pp Do problems: 3 (p. 209) -- Topic: Getting Started 9 (p. 210) -- Topic: Real variable format 13 (p. 211) -- Topic: 24 h clock program Assignments are due next week in lecture

File Input and Output

File Input and Output 5. Input and Output File Input and Output read(i,j) write(i,j) j is the statement number of format statement. i is the I/O unit or logical unit associated with device or file. non-negative integer from

More information

Lecture-6 Lubna Ahmed

Lecture-6 Lubna Ahmed Lecture-6 Lubna Ahmed 1 Input/output Input/output List directed input/output Formatted (or user formatted) input/output 2 List directed Input/output Statements List directed I/O are said to be in free

More information

8-1-1 The open statement

8-1-1 The open statement Fortran Chapter 8 讀 讀 讀 兩 (1) 讀 讀 來 讀 料 (2) 讀 讀 來 讀 (1) 料都 理 來 易 (2) 料 ( ) 讀 省 1 8-1-1 The open statement OPEN(unit = int_expr, file = char_expr, status = char_expr, action = char_expr, iostat = int_var)

More information

FORTRAN 90: Formatted Input/Output. Meteorology 227 Fall 2018

FORTRAN 90: Formatted Input/Output. Meteorology 227 Fall 2018 FORTRAN 90: Formatted Input/Output Meteorology 227 Fall 2018 Formatted Output Two output statements in FORTRAN PRINT and WRITE PRINT format-descriptor, output-list What is a format descriptor? * A character

More information

write (unit=*,fmt=*) i =, i! will print: i = 3

write (unit=*,fmt=*) i =, i! will print: i = 3 I/O (F book, chapters 9, 10 and 15) All I/O in Fortran90 is record-based, typically with record delimiters of some kind. This is in contrast to C, which has stream I/O, with no record delimiters required.

More information

Introduction to FORTRAN. Structured Programming

Introduction to FORTRAN. Structured Programming Introduction to by Dr. Ibrahim A. Assakkaf Spring 2000 Department of Civil and Environmental Engineering University of Maryland Slide No. 1 Control Structures In a structured program, the logical flow

More information

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation

C++ Programming Language Lecture 2 Problem Analysis and Solution Representation C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department Program Development Cycle Program development

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran Advanced I/O and Files Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran p. 2/??

More information

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

Computational Methods of Scientific Programming. Lecturers Thomas A Herring Chris Hill 12.010 Computational Methods of Scientific Programming Lecturers Thomas A Herring Chris Hill Review of last lecture Start examining the FORTRAN language Development of the language Philosophy of language:

More information

Edit Descriptors. Decimal form. Fw.d Exponential form Ew.d Ew.dEe Scientific form ESw.d ESw.dEe Engineering form ENw.d ENw.dEe.

Edit Descriptors. Decimal form. Fw.d Exponential form Ew.d Ew.dEe Scientific form ESw.d ESw.dEe Engineering form ENw.d ENw.dEe. Format Edit Descriptors The tedious part of using Fortran format is to master many format edit descriptors. Each edit descriptor tells the system how to handle certain type of values or activity. Each

More information

NO CALCULATOR ALLOWED!!

NO CALCULATOR ALLOWED!! CPSC 203 500 EXAM TWO Fall 2005 NO CALCULATOR ALLOWED!! Full Name (Please Print): UIN: Score Possible Points Prog Points Part One 33 pts Part Two 30 pts Part Three 20 pts Part Four 25 pts Total 108 pts

More information

C for Engineers and Scientists

C for Engineers and Scientists C for Engineers and Scientists An Interpretive Approach Harry H. Cheng University of California, Davis 0.8 0.6 j0(t) j1(t) j2(t) j3(t) 0.4 Bessel functions 0.2 0-0.2-0.4-0.6 1 2 3 4 5 6 7 8 9 10 t Copyright

More information

1 Characters & Strings in Fortran

1 Characters & Strings in Fortran Handout Four March 2, 2006 1 Characters & Strings in Fortran 1.1 Declaration In handout two of your notes (section 2.3) you were briefly shown how to declare various character types. A table similar to

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING. Zerihun Alemayehu AAiT.CED Rm E119B

ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING. Zerihun Alemayehu AAiT.CED Rm E119B ADVANCED INPUT AND OUTPUT FORTRAN PROGRAMMING Zerihun Alemayehu AAiT.CED Rm E119B SIMPLE INPUT AND OUTPUT READ, WRITE and PRINT statements are called list-directed READ*, a, b, c READ(*,*) a, b, c PRINT*,

More information

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code

CS102: Standard I/O. %<flag(s)><width><precision><size>conversion-code CS102: Standard I/O Our next topic is standard input and standard output in C. The adjective "standard" when applied to "input" or "output" could be interpreted to mean "default". Typically, standard output

More information

A. Run-Time Error Messages

A. Run-Time Error Messages Appendix A A. Table A-1 lists possible Fortran run-time I/O errors. Other errors given by the operating system may also occur (refer to the intro(2) and perror(3f) reference pages for details). Each error

More information

Computational Astrophysics AS 3013 Lecture 6:

Computational Astrophysics AS 3013 Lecture 6: Computational Astrophysics AS 3013 Lecture 6: 1) formated input/output 2) file input/output 3) safety checks FORTRAN 90: formatted input/output list-directed (or default) format READ *, variable list PRINT

More information

Two-Dimensional Projectile Motion

Two-Dimensional Projectile Motion Two-Dimensional Projectile Motion I. Introduction. This experiment involves the study of motion using a CCD video camera in which a sequence of video frames (a movie ) is recorded onto computer disk and

More information

Our Strategy for Learning Fortran 90

Our Strategy for Learning Fortran 90 Our Strategy for Learning Fortran 90 We want to consider some computational problems which build in complexity. evaluating an integral solving nonlinear equations vector/matrix operations fitting data

More information

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1

BIL 104E Introduction to Scientific and Engineering Computing. Lecture 1 BIL 104E Introduction to Scientific and Engineering Computing Lecture 1 Introduction As engineers and scientists why do we need computers? We use computers to solve a variety of problems ranging from evaluation

More information

CROSSREF Manual. Tools and Utilities Library

CROSSREF Manual. Tools and Utilities Library Tools and Utilities Library CROSSREF Manual Abstract This manual describes the CROSSREF cross-referencing utility, including how to use it with C, COBOL 74, COBOL85, EXTENDED BASIC, FORTRAN, Pascal, SCREEN

More information

Introduction to Fortran Programming. - input / output -

Introduction to Fortran Programming. - input / output - Introduction to Fortran Programming - input / output - read statement Grammar read(unit numbers, Format) Input1, Input2, Substitute "UNIT numbers" into "Input target" according to "format" UNIT=* or 5

More information

Introduction to Modern Fortran

Introduction to Modern Fortran Introduction to Modern Fortran p. 1/?? Introduction to Modern Fortran More About I/O and Files Nick Maclaren Computing Service nmm1@cam.ac.uk, ext. 34761 November 2007 Introduction to Modern Fortran p.

More information

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A

CSCE150A. Administrivia. Overview. Hardware. Software. Example. Program. Pseudocode. Flowchart. Control Structures. Hello World Program CSCE150A Computer Science & Engineering 150A Problem Solving Using Computers Lecture 01 - Course Introduction Stephen Scott (Adapted from Christopher M. Bourke) Roll Syllabus Course Webpage: http://cse.unl.edu/~sscott/teach/classes/cse150af09/

More information

Computer Science & Engineering 150A Problem Solving Using Computers

Computer Science & Engineering 150A Problem Solving Using Computers Computer Science & Engineering 150A Problem Solving Using Computers Lecture 01 - Course Introduction Stephen Scott (Adapted from Christopher M. Bourke) 1 / 43 Fall 2009 Roll Syllabus Course Webpage: http://cse.unl.edu/~sscott/teach/classes/cse150af09/

More information

Problem Solving and Program Design - Chapter 1. Cory L. Strope

Problem Solving and Program Design - Chapter 1. Cory L. Strope Problem Solving and Program Design - Chapter 1 Cory L. Strope Overview of Computers and Programming Computer Hardware Computer Software Software Development (Problem Solving) Pseudocode Flowchart Intro.

More information

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #29 Arrays in C Introduction to Programming in C Department of Computer Science and Engineering Lecture No. #29 Arrays in C (Refer Slide Time: 00:08) This session will learn about arrays in C. Now, what is the word array

More information

Section 2.4 Sequences and Summations

Section 2.4 Sequences and Summations Section 2.4 Sequences and Summations Definition: A sequence is a function from a subset of the natural numbers (usually of the form {0, 1, 2,... } to a set S. Note: the sets and {0, 1, 2, 3,..., k} {1,

More information

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York

CSc 10200! Introduction to Computing. Lecture 1 Edgardo Molina Fall 2013 City College of New York CSc 10200! Introduction to Computing Lecture 1 Edgardo Molina Fall 2013 City College of New York 1 Introduction to Computing Lectures: Tuesday and Thursday s (2-2:50 pm) Location: NAC 1/202 Recitation:

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

BLM2031 Structured Programming. Zeyneb KURT

BLM2031 Structured Programming. Zeyneb KURT BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help

More information

PROBLEM SOLVING WITH FORTRAN 90

PROBLEM SOLVING WITH FORTRAN 90 David R. Brooks PROBLEM SOLVING WITH FORTRAN 90 FOR SCIENTISTS AND ENGINEERS Springer Contents Preface v 1.1 Overview for Instructors v 1.1.1 The Case for Fortran 90 vi 1.1.2 Structure of the Text vii

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2016 Instructor: Justin Hsia Teaching Assistants: Chris Ma Hunter Zahn John Kaltenbach Kevin Bi Sachin Mehta Suraj Bhat Thomas Neuman Waylon Huang Xi Liu Yufang Sun http://xkcd.com/899/

More information

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure

Review for COSC 120 8/31/2017. Review for COSC 120 Computer Systems. Review for COSC 120 Computer Structure Computer Systems Computer System Computer Structure C++ Environment Imperative vs. object-oriented programming in C++ Input / Output Primitive data types Software Banking System Compiler Music Player Text

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

Scientific Notation & Significant Figures. Mergenthaler Vo-Tech HS Mrs. Judith B. Abergos Chemistry 2013

Scientific Notation & Significant Figures. Mergenthaler Vo-Tech HS Mrs. Judith B. Abergos Chemistry 2013 Scientific Notation & Significant Figures Mergenthaler Vo-Tech HS Mrs. Judith B. Abergos Chemistry 2013 Significant Figures Significant Figures digits that show how precise a measurement is The more significant

More information

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards

MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL. John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards MATVEC: MATRIX-VECTOR COMPUTATION LANGUAGE REFERENCE MANUAL John C. Murphy jcm2105 Programming Languages and Translators Professor Stephen Edwards Language Reference Manual Introduction The purpose of

More information

SWEN-250 Personal SE. Introduction to C

SWEN-250 Personal SE. Introduction to C SWEN-250 Personal SE Introduction to C A Bit of History Developed in the early to mid 70s Dennis Ritchie as a systems programming language. Adopted by Ken Thompson to write Unix on a the PDP-11. At the

More information

Course Topics - Outline

Course Topics - Outline Course Topics - Outline Lecture 1 - Introduction Lecture 2 - Lexical conventions Lecture 3 - Data types Lecture 4 - Operators Lecture 5 - Behavioral modeling A Lecture 6 Behavioral modeling B Lecture 7

More information

Part 2,Number Systems Questions

Part 2,Number Systems Questions Part 2,Number Systems Questions This study guide is provided as an aid in helping you to study for the ECE Department s 18-240, Fundamentals of Computer Engineering. The guide is a collection of previous

More information

BIL101E: Introduction to Computers and Information systems Lecture 8

BIL101E: Introduction to Computers and Information systems Lecture 8 BIL101E: Introduction to Computers and Information systems Lecture 8 8.1 Algorithms 8.2 Pseudocode 8.3 Control Structures 8.4 Decision Making: Equality and Relational Operators 8.5 The if Selection Structure

More information

Introduction to Programming, Aug-Dec 2008

Introduction to Programming, Aug-Dec 2008 Introduction to Programming, Aug-Dec 2008 Lecture 1, Monday 4 Aug 2008 Administrative matters Resource material Textbooks and other resource material for the course: The Craft of Functional Programming

More information

Introduction. C provides two styles of flow control:

Introduction. C provides two styles of flow control: Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if

More information

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program

CMPT 102 Introduction to Scientific Computer Programming. Input and Output. Your first program CMPT 102 Introduction to Scientific Computer Programming Input and Output Janice Regan, CMPT 102, Sept. 2006 0 Your first program /* My first C program */ /* make the computer print the string Hello world

More information

Excel Tips. Contents. By Dick Evans

Excel Tips. Contents. By Dick Evans Excel Tips By Dick Evans Contents Pasting Data into an Excel Worksheet... 2 Divide by Zero Errors... 2 Creating a Dropdown List... 2 Using the Built In Dropdown List... 3 Entering Data with Forms... 4

More information

STUDENT LESSON A12 Iterations

STUDENT LESSON A12 Iterations STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of

More information

Introduction to the SAM Student Guide 4. How to Use SAM 5. Logging in the First Time as a Pre-registered Student 5 Profile Information 7

Introduction to the SAM Student Guide 4. How to Use SAM 5. Logging in the First Time as a Pre-registered Student 5 Profile Information 7 Contents Introduction to the SAM Student Guide 4 How to Use SAM 5 Logging in the First Time as a Pre-registered Student 5 Profile Information 7 Logging into SAM as a New User 9 Forgot Password 14 Grace

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan Administrivia Lab

More information

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved.

C How to Program, 6/e by Pearson Education, Inc. All Rights Reserved. C How to Program, 6/e 1992-2010 by Pearson Education, Inc. An important part of the solution to any problem is the presentation of the results. In this chapter, we discuss in depth the formatting features

More information

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur

Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Problem Solving through Programming In C Prof. Anupam Basu Department of Computer Science & Engineering Indian Institute of Technology, Kharagpur Lecture 18 Switch Statement (Contd.) And Introduction to

More information

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1

Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1 Week 1 Introduction to Computer and Algorithm (Part1) UniMAP Sem II 11/12 DKT121: Basic Computer Programming 1 General Information Contributes 3 units: 2 hours lectures 2 hours labs and tutorials Main

More information

Excel Introduction to Excel Databases & Data Tables

Excel Introduction to Excel Databases & Data Tables Creating an Excel Database Key field: Each record should have some field(s) that helps to uniquely identify them, put these fields at the start of your database. In an Excel database each column is a field

More information

Computational Methods of Scientific Programming Fall 2007

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

More information

C++ For Science and Engineering Lecture 12

C++ For Science and Engineering Lecture 12 C++ For Science and Engineering Lecture 12 John Chrispell Tulane University Monday September 20, 2010 Comparing C-Style strings Note the following listing dosn t do what you probably think it does (assuming

More information

Chapter 3 Structured Program Development

Chapter 3 Structured Program Development 1 Chapter 3 Structured Program Development Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 3 - Structured Program Development Outline 3.1 Introduction

More information

More About WHILE Loops

More About WHILE Loops More About WHILE Loops http://people.sc.fsu.edu/ jburkardt/isc/week04 lecture 07.pdf... ISC3313: Introduction to Scientific Computing with C++ Summer Semester 2011... John Burkardt Department of Scientific

More information

Chapter 2 THE STRUCTURE OF C LANGUAGE

Chapter 2 THE STRUCTURE OF C LANGUAGE Lecture # 5 Chapter 2 THE STRUCTURE OF C LANGUAGE 1 Compiled by SIA CHEE KIONG DEPARTMENT OF MATERIAL AND DESIGN ENGINEERING FACULTY OF MECHANICAL AND MANUFACTURING ENGINEERING Contents Introduction to

More information

ECE331: Hardware Organization and Design

ECE331: Hardware Organization and Design ECE331: Hardware Organization and Design Lecture 10: Multiplication & Floating Point Representation Adapted from Computer Organization and Design, Patterson & Hennessy, UCB MIPS Division Two 32-bit registers

More information

PROJECTILE MOTION PURPOSE

PROJECTILE MOTION PURPOSE PURPOSE The purpose of this experiment is to study the motion of an object in two dimensions. The motion of the projectile is analyzed using Newton's laws of motion. During the motion of the projectile,

More information

Numerical Methods in Scientific Computation

Numerical Methods in Scientific Computation Numerical Methods in Scientific Computation Programming and Software Introduction to error analysis 1 Packages vs. Programming Packages MATLAB Excel Mathematica Maple Packages do the work for you Most

More information

Unit 3 Fill Series, Functions, Sorting

Unit 3 Fill Series, Functions, Sorting Unit 3 Fill Series, Functions, Sorting Fill enter repetitive values or formulas in an indicated direction Using the Fill command is much faster than using copy and paste you can do entire operation in

More information

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 10: Asymptotic Complexity and CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims Lecture 10: Asymptotic Complexity and What Makes a Good Algorithm? Suppose you have two possible algorithms or

More information

The steps to create Table1 using Microsoft Excel are illustrated on the following pages.

The steps to create Table1 using Microsoft Excel are illustrated on the following pages. Tables can be created in Microsoft Excel in three ways: (1) Simply by typing in the data in the columns and rows of the spread sheet. Then add the appropriate table headings and applying boarders were

More information

Practical Numerical Methods in Physics and Astronomy. Lecture 1 Intro & IEEE Variable Types and Arithmetic

Practical Numerical Methods in Physics and Astronomy. Lecture 1 Intro & IEEE Variable Types and Arithmetic Practical Numerical Methods in Physics and Astronomy Lecture 1 Intro & IEEE Variable Types and Arithmetic Pat Scott Department of Physics, McGill University January 16, 2013 Slides available from http://www.physics.mcgill.ca/

More information

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center

Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Unit 3 Functions Review, Fill Series, Sorting, Merge & Center Function built-in formula that performs simple or complex calculations automatically names a function instead of using operators (+, -, *,

More information

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL

The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Comp 541 Digital Logic and Computer Design Fall 2014 Lab #4: Sequential Design: Counters Issued Wed 9/10/14; Due Wed 9/17/14 (11:59pm) This lab assignment

More information

Introduction to Microsoft Excel

Introduction to Microsoft Excel Intro to Excel Introduction to Microsoft Excel OVERVIEW In this lab, you will become familiar with the general layout and features of Microsoft Excel spreadsheet computer application. Excel has many features,

More information

Beginning Excel for Windows

Beginning Excel for Windows Beginning Excel for Windows Version: 2002 Academic Computing Support Information Technology Services Tennessee Technological University September 2003 1. Opening Excel for Windows and Setting the Toolbars

More information

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O)

CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) CPE 101, reusing/mod slides from a UW course (used by permission) Lecture 5: Input and Output (I/O) Overview (5) Topics Output: printf Input: scanf Basic format codes More on initializing variables 2000

More information

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2

Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Introduction to C++ General Rules, Conventions and Styles CS 16: Solving Problems with Computers I Lecture #2 Ziad Matni Dept. of Computer Science, UCSB Administrative This class is currently FULL and

More information

Chapter 4: Programming with MATLAB

Chapter 4: Programming with MATLAB Chapter 4: Programming with MATLAB Topics Covered: Programming Overview Relational Operators and Logical Variables Logical Operators and Functions Conditional Statements For Loops While Loops Debugging

More information

ENT 189: COMPUTER PROGRAMMING. H/P: Home page:

ENT 189: COMPUTER PROGRAMMING.   H/P: Home page: ENT 189: COMPUTER PROGRAMMING Dr. PAULRAJ M P, Associate Professor, School of Mechatronic Engineering, #42- Level 2, Ulu Pauh New Campus 02600-Arau. PERLIS Email: paul@unimap.edu.my H/P: 017 5103757 Home

More information

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018

C++ Basics. Lecture 2 COP 3014 Spring January 8, 2018 C++ Basics Lecture 2 COP 3014 Spring 2018 January 8, 2018 Structure of a C++ Program Sequence of statements, typically grouped into functions. function: a subprogram. a section of a program performing

More information

COMP2121: Microprocessors and Interfacing. Number Systems

COMP2121: Microprocessors and Interfacing. Number Systems COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting

More information

Introduction to Spreadsheets

Introduction to Spreadsheets Introduction to Spreadsheets Spreadsheets are computer programs that were designed for use in business. However, scientists quickly saw how useful they could be for analyzing data. As the programs have

More information

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy.

Math 340 Fall 2014, Victor Matveev. Binary system, round-off errors, loss of significance, and double precision accuracy. Math 340 Fall 2014, Victor Matveev Binary system, round-off errors, loss of significance, and double precision accuracy. 1. Bits and the binary number system A bit is one digit in a binary representation

More information

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2.

} Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = / 2; 3. int x = 5 / ; 4. double x = 5 / 2. Class #10: Understanding Primitives and Assignments Software Design I (CS 120): M. Allen, 19 Sep. 18 Java Arithmetic } Evaluate the following expressions: 1. int x = 5 / 2 + 2; 2. int x = 2 + 5 / 2; 3.

More information

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 7 Input/Output Reading: Bowman, Chapters 10-12 READING FROM THE TERMINAL The READ procedure is used to read from the terminal. IDL

More information

CS 2604 Minor Project 1 Summer 2000

CS 2604 Minor Project 1 Summer 2000 RPN Calculator For this project, you will design and implement a simple integer calculator, which interprets reverse Polish notation (RPN) expressions. There is no graphical interface. Calculator input

More information

Document Imaging User Guide

Document Imaging User Guide Release 4.9 IMAGING TECHNOLOGY GROUP Document Imaging Systems Document Imaging User Guide IMAGING TECHNOLOGY GROUP IMIGIT tm Document Imaging User Guide Release 4.91 March 2007 Imaging Technology Group

More information

printf( Please enter another number: ); scanf( %d, &num2);

printf( Please enter another number: ); scanf( %d, &num2); CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful

More information

Significant Figures & Scientific Notation

Significant Figures & Scientific Notation Significant Figures & Scientific Notation Measurements are important in science (particularly chemistry!) Quantity that contains both a number and a unit Must be able to say how correct a measurement is

More information

Topic 6: A Quick Intro To C

Topic 6: A Quick Intro To C Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions

More information

Programming with Python

Programming with Python Programming with Python Dr Ben Dudson Department of Physics, University of York 21st January 2011 http://www-users.york.ac.uk/ bd512/teaching.shtml Dr Ben Dudson Introduction to Programming - Lecture 2

More information

Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker. Repetition. A Table of Values 9/20/2007

Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker. Repetition. A Table of Values 9/20/2007 Computers in Engineering COMP 208 Repetition and Storage Michael A. Hawker Repetition To fully take advantage of the speed of a computer, we must be able to instruct it to do a lot of work The program

More information

Introduction to C Programming

Introduction to C Programming 1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print

More information

Goals for This Lecture:

Goals for This Lecture: Goals for This Lecture: Learn how to use gnuplot to make simple plots of data from a file. Introduce some basic I/O concepts Using Gnuplot to Plot data from a file Gnuplot (pronounced Ga-new-plot ) is

More information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Lecture 4 Input & Output Lecturer : Ebrahim Jahandar Borrowed from lecturer notes by Omid Jafarinezhad Outline printf scanf putchar getchar getch getche Input and Output in

More information

6.25 x Type the given number into the calculator. 2. Click Mode, and select SCI. Then hit enter twice

6.25 x Type the given number into the calculator. 2. Click Mode, and select SCI. Then hit enter twice Name Date: Lesson 1-4: Scientific Notation Learning Goals: #1: How do we convert in and out of scientific notation? Scientific Notation Scientific Notation is a way of writing numbers that accommodates

More information

Numerical Methods in Physics. Lecture 1 Intro & IEEE Variable Types and Arithmetic

Numerical Methods in Physics. Lecture 1 Intro & IEEE Variable Types and Arithmetic Variable types Numerical Methods in Physics Lecture 1 Intro & IEEE Variable Types and Arithmetic Pat Scott Department of Physics, Imperial College November 1, 2016 Slides available from http://astro.ic.ac.uk/pscott/

More information

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture)

COSC 243. Data Representation 3. Lecture 3 - Data Representation 3 1. COSC 243 (Computer Architecture) COSC 243 Data Representation 3 Lecture 3 - Data Representation 3 1 Data Representation Test Material Lectures 1, 2, and 3 Tutorials 1b, 2a, and 2b During Tutorial a Next Week 12 th and 13 th March If you

More information

Fundamental of Programming (C)

Fundamental of Programming (C) Borrowed from lecturer notes by Omid Jafarinezhad Fundamental of Programming (C) Lecturer: Vahid Khodabakhshi CE 43 - Fall 97 Lecture 4 Input and Output Department of Computer Engineering Outline printf

More information

X Language Definition

X Language Definition X Language Definition David May: November 1, 2016 The X Language X is a simple sequential programming language. It is easy to compile and an X compiler written in X is available to simplify porting between

More information

Linear Programming Terminology

Linear Programming Terminology Linear Programming Terminology The carpenter problem is an example of a linear program. T and B (the number of tables and bookcases to produce weekly) are decision variables. The profit function is an

More information

Floating Point. CSE 351 Autumn Instructor: Justin Hsia

Floating Point. CSE 351 Autumn Instructor: Justin Hsia Floating Point CSE 351 Autumn 2017 Instructor: Justin Hsia Teaching Assistants: Lucas Wotton Michael Zhang Parker DeWilde Ryan Wong Sam Gehman Sam Wolfson Savanna Yee Vinny Palaniappan http://xkcd.com/571/

More information

2. Numbers In, Numbers Out

2. Numbers In, Numbers Out COMP1917: Computing 1 2. Numbers In, Numbers Out Reading: Moffat, Chapter 2. COMP1917 15s2 2. Numbers In, Numbers Out 1 The Art of Programming Think about the problem Write down a proposed solution Break

More information

INTRODUCTION 1 AND REVIEW

INTRODUCTION 1 AND REVIEW INTRODUTION 1 AND REVIEW hapter SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN. Programming: Advanced Objectives You will learn: Program structure. Program statements. Datatypes. Pointers. Arrays. Structures.

More information

Compiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3

Compiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3 Compiling C++ Programs Flow Control in C++ CS 16: Solving Problems with Computers I Lecture #3 Ziad Matni Dept. of Computer Science, UCSB Compiling Programs in C++ Input and Output Streams Simple Flow

More information

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University

ITC213: STRUCTURED PROGRAMMING. Bhaskar Shrestha National College of Computer Studies Tribhuvan University ITC213: STRUCTURED PROGRAMMING Bhaskar Shrestha National College of Computer Studies Tribhuvan University Lecture 07: Data Input and Output Readings: Chapter 4 Input /Output Operations A program needs

More information