April 14, 2004 1 ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Programming Languages (ICE 1341) Lecture #13 Programming Languages (ICE 1341)

Slides:



Advertisements
Similar presentations
Overview of programming in C C is a fast, efficient, flexible programming language Paradigm: C is procedural (like Fortran, Pascal), not object oriented.
Advertisements

ICE1341 Programming Languages Spring 2005 Lecture #13 Lecture #13 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
879 CISC Parallel Computation High Performance Fortran (HPF) Ibrahim Halil Saruhan Although the [Fortran] group broke new ground …
Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
Fortran Jordan Martin Steven Devine. Background Developed by IBM in the 1950s Designed for use in scientific and engineering fields Originally written.
ICE1341 Programming Languages Spring 2005 Lecture #15 Lecture #15 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
FORTRAN Short Course Week 1 Kate T-C February 17, 2008.
ICE1341 Programming Languages Spring 2005 Lecture #12 Lecture #12 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
CS 415: Programming Languages Algol Aaron Bloomfield Fall 2005.
Chapter 5: Elementary Data Types Properties of types and objects –Data objects, variables and constants –Data types –Declarations –Type checking –Assignment.
COEN Expressions and Assignment
Compiler Construction
ICE1341 Programming Languages Spring 2005 Lecture #14 Lecture #14 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Introduction to Fortran Fortran Evolution Drawbacks of FORTRAN 77 Fortran 90 New features Advantages of Additions.
Program Design and Development
CSCE Syntax Details Fortran is not case sensitive; any use of capitals is for the programmer’s convenience. All programs are “wrapped” with PROGRAM.
CSE S. Tanimoto Syntax and Types 1 Representation, Syntax, Paradigms, Types Representation Formal Syntax Paradigms Data Types Type Inference.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
ICE1341 Programming Languages Spring 2005 Lecture #3 Lecture #3 In-Young Ko iko.AT. icu.ac.kr iko.AT. icu.ac.kr Information and Communications University.
Recitation 1 Programming for Engineers in Python.
Introduction to FORTRAN-90 University of Liverpool course.
CSE 341, S. Tanimoto Concepts 1- 1 Programming Language Concepts Formal Syntax Paradigms Data Types Polymorphism.
Introduction to Computer Algorithmics and Programming Ceng 113 Variables and Operators in C.
Introduction to FORTRAN
May 21, ICE 1341 – Programming Languages (Lecture #21) In-Young Ko Programming Languages (ICE 1341) Lecture #21 Programming Languages (ICE 1341)
CIS Computer Programming Logic
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
CS 403 Programming Language Theory Class 2 - August 29, 2000.
March 12, ICE 1341 – Programming Languages (Lecture #6) In-Young Ko Programming Languages (ICE 1341) Lecture #6 Programming Languages (ICE 1341)
C Programming n General Information on C n Data Types n Arithmetic Operators n Relational Operators n if, if-else, for, while by Kulapan Waranyuwat.
Scientific Computing Division A tutorial Introduction to Fortran Siddhartha Ghosh Consulting Services Group.
April 23, ICE 1341 – Programming Languages (Lecture #16) In-Young Ko Programming Languages (ICE 1341) Lecture #16 Programming Languages (ICE 1341)
FORTRAN FORmula TRANslator -Anand Trivedi. HISTORY  Designed and written from scratch in by an IBM team lead by John W. Backus as the first.
Class Review. Basic Unix Commands list files in a directory: ls list files in a directory: ls remove files: rm remove files: rm rename files: mv rename.
Summary of what we learned yesterday Basics of C++ Format of a program Syntax of literals, keywords, symbols, variables Simple data types and arithmetic.
Fortran 77 By Tanatorn Somboonvorakit, ID:
April 2, ICE 1341 – Programming Languages (Lecture #12) In-Young Ko Programming Languages (ICE 1341) Lecture #12 Programming Languages (ICE 1341)
April 16, ICE 1341 – Programming Languages (Lecture #14) In-Young Ko Programming Languages (ICE 1341) Lecture #14 Programming Languages (ICE 1341)
8-1 Compilers Compiler A program that translates a high-level language program into machine code High-level languages provide a richer set of instructions.
Lecture III Start programming in Fortran Yi Lin Jan 11, 2007.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
Introduction to Computer Sciences References: [1] Fortran 95/2003 for Scientists and Engineers (3e) by Stephen J. Chapman. [2] Using Fortran 90 by Chester.
March 31, ICE 1341 – Programming Languages (Lecture #11) In-Young Ko Programming Languages (ICE 1341) Lecture #11 Programming Languages (ICE 1341)
Textbook C for Scientists and Engineers © Prentice Hall 1997 Available at NUS CO-OP at S$35.10.
 Constants A constant is a fixed value of a data type that cannot be changed Integer Constants Whole numbers → Do not have decimal points Examples: 83.
Ch Ch jcmt CSE 3302 Programming Languages CSE3302 Programming Languages Dr. Carter Tiernan.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Chapter 3: Introducing the Microsoft.NET Framework and Visual Basic.NET Visual Basic.NET Programming: From Problem Analysis to Program Design.
1 jcmt Summer 2003Programming Languages CSE3302 Programming Languages Summer 2003 Dr. Carter Tiernan.
INTRODUCTION TO PROGRAMING System Development Mansoura October 2015.
Information and Computer Sciences University of Hawaii, Manoa
Zuse’s Plankalkül – 1945 Never implemented Problems Zuse Solved
Chapter 7: Expressions and Assignment Statements
ECE Application Programming
Representation, Syntax, Paradigms, Types
Chapter 7: Expressions and Assignment Statements
Chapter 10 Programming Fundamentals with JavaScript
Arithmetic operations, decisions and looping
Midterm Review Programming in Fortran
Representation, Syntax, Paradigms, Types
` Structured Programming & Flowchart
Representation, Syntax, Paradigms, Types
CS150 Introduction to Computer Science 1
Representation, Syntax, Paradigms, Types
The structure of programming
Summary of what we learned yesterday
Unit 3: Variables in Java
PRESENTED BY ADNAN M. UZAIR NOMAN
DATA TYPES AND OPERATIONS
REPETITION Why Repetition?
Presentation transcript:

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Programming Languages (ICE 1341) Lecture #13 Programming Languages (ICE 1341) Lecture #13 April 14, 2004 In-Young Ko iko.AT. icu.ac.kr Information and Communications University (ICU) iko.AT. icu.ac.kr

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Announcements The solution of the midterm exam is now available on the class homepage The solution of the midterm exam is now available on the class homepage

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko FORTRAN (Formula Translating System) Designed to efficiently translate mathematical formulas into IBM 704 machine code Designed to efficiently translate mathematical formulas into IBM 704 machine code IBM 704 (1954) “The first mass-produced computer with core memory and floating- point arithmetic” Photo: Lawrence Livermore National Laboratory

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko FORTRAN Coding Format FORTRAN programs were written in a coding form with a strict formatting rule Continuation (6) FORTRAN Statement (7-72) Identification Sequence (73-80) Statement Number (1-5) J.W. Perry Cole, ANSI FORTRAN IV, wcb

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Punched Cards Coded FORTRAN programs were converted onto punched cards for loading Photos:

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Early FORTRAN Versions FORTRAN I (1957) FORTRAN I (1957) Names could have up to six characters (IBM 704 has a 6-bit BCD character set and 36-bit word) Names could have up to six characters (IBM 704 has a 6-bit BCD character set and 36-bit word) Post-test counting loop ( DO ), Formatted I/O, User- defined subprograms, Three-way selection statement (arithmetic IF ) Post-test counting loop ( DO ), Formatted I/O, User- defined subprograms, Three-way selection statement (arithmetic IF ) No data typing statements (Implicit Type Declaration – Variables whose names begin with I, J, K, L, M, and N are integer types, all others are floating point) No data typing statements (Implicit Type Declaration – Variables whose names begin with I, J, K, L, M, and N are integer types, all others are floating point) FORTRAN II (1958) FORTRAN II (1958) Independent compilation of subroutines Independent compilation of subroutines * AW Lecture Notes

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Later FORTRAN Versions FORTRAN IV ( ) – ANSI standard in 1966 FORTRAN IV ( ) – ANSI standard in 1966 Explicit type declarations Explicit type declarations Logical selection statement Logical selection statement Subprogram names could be parameters Subprogram names could be parameters FORTRAN 77 (1978) FORTRAN 77 (1978) Character string handling Character string handling Logical loop control statement Logical loop control statement IF-THEN-ELSE statement IF-THEN-ELSE statement FORTRAN 90 (1990) FORTRAN 90 (1990) Free coding format Free coding format Modules, Dynamic arrays, Pointers, Recursion, CASE statement Modules, Dynamic arrays, Pointers, Recursion, CASE statement * AW Lecture Notes

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko A Sample FORTRAN Program C *** This is a sample FORTRAN IV program PROGRAM SAMPLE READ (5, 990) A, B 990FORMAT (F5.2, F5.2) SUM = A + B WRITE (6, 81) A, B, SUM 81FORMAT (1X, F5.2, 3X, F5.2, 3X, F6.2) STOPEND J.W. Perry Cole, ANSI FORTRAN IV, wcb

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko FORTRAN Data Types (1) Integer Integer Implicit Typing: Variables whose names begin with I~N Implicit Typing: Variables whose names begin with I~N Explicit Declaration Explicit Declaration e.g., INTEGER A, TOTAL Real – Single precision floating point number Real – Single precision floating point number Implicit Typing: Variables whose names begin with other than A~H or O-Z Implicit Typing: Variables whose names begin with other than A~H or O-Z Explicit Declaration Explicit Declaration e.g., REAL J, R Double precision floating point number Double precision floating point number e.g., DOUBLE PRECISION A, X

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko FORTRAN Data Types (2) Complex e.g., COMPLEX A, B, C Complex e.g., COMPLEX A, B, C A = (3.5, -7.24) A = (3.5, -7.24) B = (-8.21, 5.67) B = (-8.21, 5.67) C = A + B C = A + B Character Character e.g., CHARACTER C, NAME*20, ADDR*30 CHARACTER*20 STR1, STR2 CHARACTER*20 STR1, STR2 Character constants: e.g., ‘C’, ‘Go ICU’ Character constants: e.g., ‘C’, ‘Go ICU’ Hollerith Strings: e.g., 1HC, 5HGoICU Hollerith Strings: e.g., 1HC, 5HGoICU Logical (Boolean) Logical (Boolean) e.g., LOGICAL X, Y, FLAG Logical constants:.TRUE. or.FALSE. Logical constants:.TRUE. or.FALSE.

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Variable Initializations and Arrays Variable Initializations Variable Initializations e.g., DATA A/1.0/, L/2/, B,C/4.0, 5.0/ DATA ARYX(3)/1.333/, T(1),T(2),T(3)/3*0.0/ DATA ARYX(3)/1.333/, T(1),T(2),T(3)/3*0.0/ DATA C(1)/1HS/, C(2)/1HD/, TAG/3HYes DATA C(1)/1HS/, C(2)/1HD/, TAG/3HYes Arrays Arrays e.g., DIMENSION A(5), B(10,7), N(3,5,20) INTEGER X(7,5) INTEGER X(7,5) REAL MATRIX(-6:4, 7, -5:10), K REAL MATRIX(-6:4, 7, -5:10), K DIMENSION K(20) DIMENSION K(20) J.W. Perry Cole, ANSI FORTRAN IV, wcb

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko FORTRAN Operators Arithmetic Operators: +, -, *, /, ** (exponentiation) Arithmetic Operators: +, -, *, /, ** (exponentiation) Mixed mode expressions – evaluated in integer mode if all operands are integer, evaluated in real mode otherwise Mixed mode expressions – evaluated in integer mode if all operands are integer, evaluated in real mode otherwise e.g., 86.3 * K + R / 16.5 ** J  All are evaluated in real Relational Operators:.LT.,.LE.,.GT.,.GE.,.EQ.,.NE. Relational Operators:.LT.,.LE.,.GT.,.GE.,.EQ.,.NE. e.g., IF (RESULT.LT. 0.0) STOP Logical Operators:.AND.,.OR.,.NOT. Logical Operators:.AND.,.OR.,.NOT. e.g., IF (N.EQ. 1.OR..NOT. R.LT. 0.0) GOTO 75 Multiple Assignment Statements Multiple Assignment Statements e.g., A = I = V = W =.2 * R + X  A truncated value will be assigned to A and I  A truncated value will be assigned to A and I

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Program Flow Control GotoGOTO (10, 20, 30) KCOUNT GotoGOTO (10, 20, 30) KCOUNT Logical IFIF (K.LT. 1) K = K + 1 Logical IFIF (K.LT. 1) K = K + 1 Arithmetic IFIF (A / T – S) 10, 20, 30 Arithmetic IFIF (A / T – S) 10, 20, 30 Block IFIF (M.GT. 15) THEN M = M / 3 Block IFIF (M.GT. 15) THEN M = M / 3 ELSE M = M * 3 ENDIF Do loopsDO 10 I = 1, N, 2 Do loopsDO 10 I = 1, N, 2 SUM = SUM + I SUM = SUM + I 10 CONTINUE 10 CONTINUE

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Data Input Standard I/O Units: stdin (5), stdout (6) Standard I/O Units: stdin (5), stdout (6) READ (5, 99) NUM, VAL, STR 99FORMAT (I3, 2X, F5.2, 1X, A20) READ (5, 98) N1, N2, N3, STR1, STR2 98FORMAT (3I5, //2A15) READ (5, *) L, SUM, NAME OPEN (UNIT=10, FILE=‘data.txt’, * STATUS=‘OLD’) * STATUS=‘OLD’) READ (10, *) N, A, X, S

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Data Output Carriage Control Codes: 1H1 (new page), 1H0 (double space), 1Hb (single space)… Carriage Control Codes: 1H1 (new page), 1H0 (double space), 1Hb (single space)… WRITE (6, 97) A, B, C 97FORMAT (1H1,//3F8.2) WRITE (6, 96) X, Y, SUM 96FORMAT (1H0, 4HX =, F4.1, 3X, 4HY =, * F4.1, 4X, 6HSUM =, F5.1, 20(1H*)) * F4.1, 4X, 6HSUM =, F5.1, 20(1H*)) PRINT *, ‘X = ’, X, ‘Y = ’, Y, ‘SUM = ’, SUM OPEN (UNIT=11, FILE=‘data.txt’, * STATUS=‘NEW’) * STATUS=‘NEW’) WRITE (11, *) ‘Result = ’, SUM

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Subprograms - Subroutines SUBROUTINE SUMMARY(X, N, TOT) DIMENSION X(20) TOT = 0.0 DO 10 I = 1, N TOT = TOT + X(I) TOT = TOT + X(I) 10CONTINUE RETURNEND J.W. Perry Cole, ANSI FORTRAN IV, wcb

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Subprograms - Functions FUNCTION TOTAL(X, N) DIMENSION X(20) TOTAL = 0.0 DO 10 I = 1, N TOTAL = TOTAL + X(I) TOTAL = TOTAL + X(I) 10CONTINUE RETURNEND

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Subprogram Calls PROGRAM SAMPLE2 DIMENSION A(10), B(20) READ (5, 99) A 99FORMAT (10F4.2) CALL SUMMARY(A, 10, SUM) WRITE (6, 98) A, SUM 98FORMAT (1, H0, 10F7.2/, 6HSUM =, F7.2) READ (5, 99) B WRITE (6, 98) B, TOTAL(SUM, 10) STOPEND

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko GNU FORTRAN77 Compiler Download G77 from: Download G77 from: G77 Installation and Execution Instructions: G77 Installation and Execution Instructions: ators/Fortran_g77/GettingStartedGnuFortran.pdf ators/Fortran_g77/GettingStartedGnuFortran.pdf FORTRAN77 Tutorial: FORTRAN77 Tutorial: FORTRAN77 Language Reference: FORTRAN77 Language Reference:

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Homework #4 – A Weather Data Retrieval Program (1) Install G77 on your computer and practice how to compile and run FORTRAN programs Install G77 on your computer and practice how to compile and run FORTRAN programs Download a weather data file that contains the latest week’s weather information from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/data.txt Download a weather data file that contains the latest week’s weather information from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/data.txt ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/data.txt Download the weather station list from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/stnlist-sorted.txt Download the weather station list from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/stnlist-sorted.txt ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/stnlist-sorted.txt Check the weather data file format from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/README.TXT Check the weather data file format from: ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/README.TXT ftp://ftp.ncdc.noaa.gov/pub/data/globalsod/README.TXT

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Homework #4 – A Weather Data Retrieval Program (2) Write a FORTRAN program that accepts a city name (e.g., TAEJON, SEOUL, PARIS), and prints the lowest and highest temperatures (in Celsius), and sea-level pressure values for the latest week like: Write a FORTRAN program that accepts a city name (e.g., TAEJON, SEOUL, PARIS), and prints the lowest and highest temperatures (in Celsius), and sea-level pressure values for the latest week like: City: TAEJON DateMINMAXSLP …

April 14, ICE 1341 – Programming Languages (Lecture #13) In-Young Ko Homework #4 – A Weather Data Retrieval Program (3) To retrieve weather information for a city, use the weather station number that is firstly matched against the city name in the station list To retrieve weather information for a city, use the weather station number that is firstly matched against the city name in the station list Use INDEX function to match a city name from the station list Use INDEX function to match a city name from the station list IF (INDEX(NAME, ‘ICU’).GT. 0) PRINT *, ‘Matched!’ PRINT *, ‘Matched!’ Submit the source program electronically by Midnight of Wednesday April 28, 2004 Submit the source program electronically by Midnight of Wednesday April 28, 2004 Please do not collaborate with other students! Please do not collaborate with other students!