Fortran 77 By Tanatorn Somboonvorakit, ID: 49540453.

Slides:



Advertisements
Similar presentations
INTEC CS160 - Jeanine Ingber Engineering Problem Solving with C Fundamental Concepts Chapter 3 Control Structures and Data Files.
Advertisements

1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Lecture 2 Introduction to C Programming
Introduction to C Programming
 2000 Prentice Hall, Inc. All rights reserved. Chapter 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line.
Introduction to C Programming
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Computer Science 1620 Variables and Memory. Review Examples: write a program that calculates and displays the average of the numbers 45, 69, and 106.
1 Outline 13.1Introduction 13.2A Simple Program: Printing a Line of Text in a Web Page 13.3Another JavaScript Program: Adding Integers 13.4Memory Concepts.
Chapter 2 Basic Elements of Fortan
 2007 Pearson Education, Inc. All rights reserved Introduction to C Programming.
Introduction to C Programming
VB .NET Programming Fundamentals
Pseudocode.
Introduction to FORTRAN-90 University of Liverpool course.
COMPUTER SCIENCE I C++ INTRODUCTION
A Variable is symbolic name that can be given different values. Variables are stored in particular places in the computer ‘s memory. When a variable is.
Fortran 1- Basics Chapters 1-2 in your Fortran book.
Fundamentals of C and C++ Programming Control Structures and Functions.
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
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.
Chapter 8 High-Level Programming Languages. 8-2 Chapter Goals Describe the translation process and distinguish between assembly, compilation, interpretation,
Flow of Control Part 1: Selection
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 2 Chapter 2 - Introduction to C Programming.
Introduction to C Programming Angela Chih-Wei Tang ( 唐 之 瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2010 Fall.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
Lecture 2: Introduction to C Programming. OBJECTIVES In this lecture you will learn:  To use simple input and output statements.  The fundamental data.
Selection Relational Expressions A condition or logical expression is an expression that can only take the values true or false. A.
Basic Control Structures
1 ELEC 206 Chapter 3 Control Structures 5-Step Problem Solving Methodology 1. State the problem clearly. 2. Describe the input and output. 3. Work a.
CS 100Lecture 21 CS100J: Lecture 2 n Previous Lecture –Programming Concepts n problem, algorithm, program, computer, input, output, sequential execution,
Program Development C# Programming January 30, 2007 Professor J. Sciame.
Lecture III Start programming in Fortran Yi Lin Jan 11, 2007.
CHAPTER 1 INTRODUCTION TO COMPUTING 1.1 Introduction.
Introduction to Computer Sciences References: [1] Fortran 95/2003 for Scientists and Engineers (3e) by Stephen J. Chapman. [2] Using Fortran 90 by Chester.
Part:2.  Keywords are words with special meaning in JavaScript  Keyword var ◦ Used to declare the names of variables ◦ A variable is a location in the.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Chapter 2 - Introduction to C Programming Outline.
The Hashemite University Computer Engineering Department
 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.
 2007 Pearson Education, Inc. All rights reserved. A Simple C Program 1 /* ************************************************* *** Program: hello_world.
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.
An Introduction to Programming with C++ Sixth Edition Chapter 5 The Selection Structure.
From Algorithms to Programs Both are sets of instructions on how to do a task Algorithm: –talking to humans, easy to understand –in plain (English) language.
1 Lecture 2 - Introduction to C Programming Outline 2.1Introduction 2.2A Simple C Program: Printing a Line of Text 2.3Another Simple C Program: Adding.
Chapter 2 - Introduction to C Programming
ITEC113 Algorithms and Programming Techniques
Revision Lecture
The Selection Structure
Engineering Problem Solving with C++, Etter/Ingber
Chapter 2 - Introduction to C Programming
Chapter 10 Programming Fundamentals with JavaScript
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Arithmetic operations, decisions and looping
Chapter 2 - Introduction to C Programming
Chapter 2 - Introduction to C Programming
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Chapter 2 - Introduction to C Programming
3 Control Statements:.
Chapter 2 - Introduction to C Programming
Introduction to Programming Using Python PART 2
Algorithms computer as the tool process – algorithm
Boolean Expressions to Make Comparisons
Chapter 2 - Introduction to C Programming
DATA TYPES AND OPERATIONS
Introduction to C Programming
REPETITION Why Repetition?
Presentation transcript:

Fortran 77 By Tanatorn Somboonvorakit, ID:

The standard definition of Fortran was updated in the late 1970's and a new standard, ANSI X , was published by the American National Standards Institute. This standard was subsequently (in 1980) adopted by the International Standards Organization (ISO) as an International Standard (IS 1539 : 1980). The language is commonly known as FORTRAN 77 Fortran 77 first designed

The goals of this language Fortran, which originally stood for IBM Mathematical FORmula TRANslation System but has been abbreviated to FORmula TRANslation, is the oldest of the established “high-level” languages. Use for scientific computation

Designed by … A group in IBM during the late 1950s.

Problem domain was Fortran 77 intended for Fortran programs could be processed very efficiently, led to Fortran being the most heavily-used programming language for non-commercial applications. By the mid 1970s virtually every computer, mini or mainframe, was supplied with a standard- conforming FORTRAN 66 language processing system. It was therefore possible to write programs in Fortran on any one system and be reasonably confident that these could be moved fairly easily to work on any other system.

Some main features of the language Compilers, which usually support a small number of extensions have, become very efficient. Populate Scientific installations all over the world.

How widely is the language used ? This version of the language is widespread use. The standard is Fortran 66 and have been develop to Fortran 77, Fortran 88 and 90. Now this language is still use until today.

About the Language Arithmetic expressions Operator Operation + Addition or unary + - Subtraction or unary – * Multiplication / Division ** Exponentiation The READ statement The READ statement is used to assign values to variables by reading data from input. Form : READ *, variable_list Example : READ *, VAR1, VAR2, VAR3

Variables A variable is a unique name which a Fortran program applies to a word of memory and uses to refer to it. A variable consists of '''1 to 6 upper case alphabetic characters and decimal digits''', beginning with an alphabetic character. Examples: VOL TEMP A2 COLUMN IBM370

The PRINT statement Output can be printed using the PRINT statement. Form : PRINT *, output_list Example : PRINT *, 'THE RESULTS ARE', X,'AND',Y The PROGRAM statement A program can optionally be given a name by beginning it with a single PROGRAM statement. Form : PROGRAM program_name Example : PROGRAM TESTPROGRAM

The END and STOP statements Each program must conclude with the statement END, which marks the end of the program. There must be no previous END statement. The statement STOP stops execution of the program. Comments The letter ‘C’ or an asterisk in column one causes the compiler to ignore the rest of the line, which may therefore be used as a comment to provide information for anyone reading the program.

Relational expressions A relational expression is a logical expression which states a relationship between two expressions, evaluating to.TRUE. if the relationship applies or.FALSE. otherwise. A relational expression has the form: arithmetic_expression relational_operator arithmetic_expression The relational operators are: Meaning.LT. Less than.LE. Less than or equal to.EQ. Equal to.NE. Not equal to.GE. Greater than or equal to.GT. Greater than

Thus examples of relational expressions are: N.GE.0 X.LT.Y B**2 - 4*A*C.GT. 0. Composite logical expressions Form: L1 logical_operator L2 Meaning.AND. Both L1 and L2 are.TRUE..OR. Either L1 or L2 or both are.TRUE..EQV. Both L1 and L2 have the same value (.TRUE. or.FALSE.).NEQV. L1 and L2 have different values (one.TRUE. and one.FALSE.) Example : (A.LT.B).OR. (C.LT.D)

The logical IF statement The logical IF statement is used to execute an instruction conditionally. Form : IF (logical_expression) executable_statement Example : IF (A.LT.B) SUM = SUM + A The block IF structure The block IF structure is more powerful, permitting the conditional execution of one of a number of alternative sequences of instructions.

described informally as : an IF block, followed by : one or more optional ELSE IF blocks, followed by : an optional ELSE block, followed by : END IF Form : IF (logical_expression) THEN ….Fortran statements…. ELSE IF (logical_expression) THEN ….Fortran statements…. ELSE ….Fortran statements…. END IF Example : IF (HRS.LE. 40) THEN SALARY = HRS * RATE ELSE IF (HRS.LE. 50) THEN SALARY = 40.0 * RATE + (HRS – 40.0) * RATE * 1.5 ELSE SALARY = 40.0 * RATE * RATE * (HRS – 50.0) * RATE * 2.0 END IF

The DO-loop A DO loop is a sequence of statements beginning with a DO statement. Form : DO label, var = e1, e2, [,e3] label is the label of an executable statement sequentially following the DO statement called the terminal statement of the DO loop. var is an INTEGER or REAL variable called the loop control variable. e1, e2 and e3 are arithmetic expressions. ( i.e. INTEGER or REAL constants ) Example : DO 10, I = 1,5 DO 10, I = 0,100,5

Nested DO loops Example : DO 20, ….. ………… DO 10, ….. ………… 10 CONTINUE ………. 20CONTINUE Example : DO 20, ….. ………… DO 10, ….. ………… 20CONTINUE ………. 10CONTINUE VALID INVALID

A simple program PROGRAM PETROL INTEGER STOPS, FILLUP C C THESE VARIABLES WOULD OTHERWISE BE TYPED REAL BY DEFAULT C ANY TYPE SPECIFICATIONS MUST PRECEDE THE FIRST EXECUTABLE STATEMENT C READ *, KM, STOPS, FILLUP USED = 40 * STOPS + FILLUP C COMPUTES THE PETROL USED AND CONVERTS IT TO REAL KPL = KM / USED C 0.5 IS ADDED TO ENSURE THAT THE RESULT IS ROUNDED PRINT *, ‘AVERAGE KPL WAS’, KPL END