FORTRAN Block data subprograms 2. Common blocks 3. Entry points 4. Function subprograms 5. Main program 6. Subroutines

Similar documents
Evolution of Fortran. Presented by: Tauqeer Ahmad. Seminar on Languages for Scientific Computing

Fortran. (FORmula TRANslator) History

Review More Arrays Modules Final Review

Name :. Roll No. :... Invigilator s Signature : INTRODUCTION TO PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

Variable A variable is a value that can change during the execution of a program.

LECTURE 18. Control Flow

Introduction to Modern Fortran

Chapter 8 :: Composite Types

EMBEDDED SYSTEMS PROGRAMMING Language Basics

Computers in Engineering. Subroutines Michael A. Hawker

Functional Programming. Big Picture. Design of Programming Languages

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


Chapter 7. - FORTRAN I control statements were based directly on IBM 704 hardware

Introduction. A. Bellaachia Page: 1

Semantic Analysis. How to Ensure Type-Safety. What Are Types? Static vs. Dynamic Typing. Type Checking. Last time: CS412/CS413

A quick guide to Fortran

Programming Languages

An interesting related problem is Buffon s Needle which was first proposed in the mid-1700 s.

Structure of Programming Languages Lecture 5

FORTRAN 90: Functions, Modules, and Subroutines. Meteorology 227 Fall 2017

DC69 C# &.NET DEC 2015

Fortran90 Bindings for Charm++

Run-Time Data Structures

NOTE: Answer ANY FOUR of the following 6 sections:

EMBEDDED SYSTEMS PROGRAMMING Language Basics

Introduction to C Language

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

B.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University

Statement level control structures

FORM 2 (Please put your name and form # on the scantron!!!!)

Concepts of Programming Languages

G Programming Languages - Fall 2012

multiple variables having the same value multiple variables having the same identifier multiple uses of the same variable

P.G.TRB - COMPUTER SCIENCE. c) data processing language d) none of the above

C-LANGUAGE CURRICULAM

! Those values must be stored somewhere! Therefore, variables must somehow be bound. ! How?

PHPoC vs PHP > Overview. Overview

Sample Copy. Not for Distribution.

Computers in Engineering COMP 208. Subprograms. Subroutines. Subroutines Michael A. Hawker

COMP 250 Winter 2011 Reading: Java background January 5, 2011

COMPILER DESIGN LECTURE NOTES

11/6/17. Functional programming. FP Foundations, Scheme (2) LISP Data Types. LISP Data Types. LISP Data Types. Scheme. LISP: John McCarthy 1958 MIT

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

6. Pointers, Structs, and Arrays. 1. Juli 2011

Lecture 9: Parameter Passing, Generics and Polymorphism, Exceptions

C++ (Non for C Programmer) (BT307) 40 Hours

PHPoC. PHPoC vs PHP. Version 1.1. Sollae Systems Co., Ttd. PHPoC Forum: Homepage:

9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5

G Programming Languages - Fall 2012

Chapter 3. Fortran Statements

Names, Bindings, Scopes

ENERGY 211 / CME 211. Functions

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Principles of Programming Languages. Lecture Outline

6. Pointers, Structs, and Arrays. March 14 & 15, 2011

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

SOURCE LANGUAGE DESCRIPTION

The role of semantic analysis in a compiler

11. a b c d e. 12. a b c d e. 13. a b c d e. 14. a b c d e. 15. a b c d e

Our Strategy for Learning Fortran 90

Integers A standard integer uses 4 bytes, holds numbers to

Cell Processor and Playstation 3

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

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

TDDE18 & 726G77. Functions

names names identifiers variables subroutines constants

COP4020 Programming Languages. Control Flow Prof. Robert van Engelen

CS 415 Midterm Exam Spring 2002

Computers in Engineering. Moving From Fortran to C Michael A. Hawker

Subroutine Linkage Wheeler Jump control program

Reflection Seismology (SCPY 482) An Introduction to Fortran 90 Programming

Side Effects (3A) Young Won Lim 1/13/18

Mathematical Computing

CIS24 Project #3. Student Name: Chun Chung Cheung Course Section: SA Date: 4/28/2003 Professor: Kopec. Subject: Functional Programming Language (ML)

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Chapter 8. Statement-Level Control Structures

CSCI 3155: Principles of Programming Languages Exam preparation #1 2007

SUBPROGRAMS AND MODULES

ME 461 C review Session Fall 2009 S. Keres

Chapter 1. Section 1.4 Subprograms or functions. CS 50 - Hathairat Rattanasook

Chapter 9. Def: The subprogram call and return operations of a language are together called its subprogram linkage

CS 351 Design of Large Programs Programming Abstractions

Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

Chapter 6 Control Flow. June 9, 2015

IECD Institute for Entrepreneurship and Career Development Bharathidasan University, Tiruchirappalli 23.

FORTRAN WATFIV. Mohammed Aslam CIS 24 Prof. Kopec Report 01 Date: 03/03/03

C Language, Token, Keywords, Constant, variable

Chapter 10 Implementing Subprograms

Subprograms, Subroutines, and Functions

CSCI 171 Chapter Outlines

Computer Science & Engineering 150A Problem Solving Using Computers

StackVsHeap SPL/2010 SPL/20

BASIC ELEMENTS OF A COMPUTER PROGRAM

ECE 122. Engineering Problem Solving with Java

C introduction: part 1

CS 3360 Design and Implementation of Programming Languages. Exam 1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Computer Science & Engineering 150A Problem Solving Using Computers. Chapter 3. Existing Information. Notes. Notes. Notes. Lecture 03 - Functions

Compilers. Prerequisites

Transcription:

FORTRAN77 The first FORTRAN compiler was a milestone in the history of computing, at that time computers had very small memories (on the order of 15KB, it was common then to count memory capacities in bits), they were slow and had very primitive operating systems (if they had them at all). The pioneers of FORTRAN didn't invent the idea of writing programs in a High Level Language (HLL) and compiling the source code to object code with an optimizing compiler, but they produced the first successful HLL [1]. This wonderful first FORTRAN compiler was designed and written from scratch in 1954-57 by an IBM team. In 1977, a current version language FORTRAN77 came out. Since FORTRAN77 is quite good at handling character strings as well as numbers and also has powerful file-handling and input/output facilities, it is suitable for a much wider range of applications than before [2]. FORTRAN77 is very simple to learn and to use. Now let us see what the most basic concept of FORTRAN77 is. All programs start with PROGRAM program-name, SUBROUTINE subroutine-name or FUNCTION function-name and end with END. The first five characters on a line are reserved for line numbers; the sixth character is reserved for a continuation character. If the first character is a C, the line is just comment. Common block used for global variables. Throughout any program of more than one programming unit, no two of the following can have the same name: 1. Block data subprograms 2. Common blocks 3. Entry points 4. Function subprograms 5. Main program 6. Subroutines There are different variable types: INTEGER Constants (+123, -344, 345, -0123), REAL Constants (1.098, -4.985, +. 00343,.423E5), CHARACTER*n Constant ( 12, STRING, WE D BEST ), LOGICAL Constants (.TRUE. or.false.). READ Statement and PRINT Statement (READ *, list or PRINT *, list). FORTRAN77 does not use >, >=, <, <=, ==, /=, $$,, but.gt.,.ge.,.lt.,.le.,.eq.,.ne..and..or. instead. All arrays start at 1instead of 0. INTEGER A(3) has three elements A(1), A(2), A(3). INTEGER B(l:u) (l<u) means to set up an array named B whose first element is B(l) and whose last element is B(u). Negative values of l,u are allowed. A value of zero for any of these quantities indicates that the value does not refer to an object. Zero is the FORTRAN77 equivalent of NULL. Any nonzero value is or should be a valid object reference. If the statement implicit none is used, all variables must be declared.

There are different types of loops in FORTRAN77. The common thread among all types is the LOOP Repeat sequence with an exit condition included somewhere therein. 1. Read-loop: Read and Exit if final data 2. Pretest loop: Exit if condition 3. Posttest loop: Repeat if condition 4. DO-loop: For v=s, s+i, s+2i e In addition to the ability to automatically repeat complex sequences of commands, computers can also select an appropriate list of operations based on the result of previous calculations. IF (test of condition) THEN or IF (test of condition) THEN Then-block Then-block ELSE ELSEIF ( ) THEN Else-block Else-if-block ENDIF ELSE ENDIF Else-block There are three types of subprograms: subroutines, functions, and block data subprograms. The subroutines and functions are called procedures, which are invoked from other procedures or from the main program. The block data subprograms are handled by the loader. Subroutines: call of a subroutine: call integrate(test) will call the subroutine integrate with the argument test passed. If the function modifies test its value is returned. The use of functions is almost similar. FUNCTIONS Statement: we assign the total tax to the name of the FUNCTION, as if the FUNCTION s name were a memory cell. The value is then transmitted back to the statement that references the FUNCTION. Except for this, FUNCTIONs are written in the same way as SUBROUTINES: header statement, parameter declaration, body, and END. The primary difference between them is the contexts in which they are used. AFUNCTION returns one value; a SUBROUTINE may return any number of values (through its arguments). A FUNCTION reference looks like a mathematical operation; a SUBROUTINE CALL looks like a transfer of control [3].

A block data subprogram contains no executable statements. The purpose of a block data subprogram is to initialize COMMON regions via DATA statements. For example, BLOCK DATA REAL PI COMMON /CONST/ PI DATA PI /3.14159/ END FORTRAN77 doesn t have libraries, pointers and recursion. It also can use in data structures. From the Fortran point of view, all information for input or output is organized in files. Files reside on I/O devices and may be connected for processing by a Fortran program. Compared with FORTRAN IV, FORTRAN77 added: DO loops with a decreasing control variable (index). Block if statements IF... THEN... ELSE... ENDIF (before F77 there were only IF GOTO). Pretest of DO loops, before F77 DO loops were always executed at least once, so you had to add an IF GOTO before the loop. CHARACTER data type (before characters were always stored inside INTEGER variables). Apostrophe delimited character string constants. Main program termination without a STOP statement. From above we can tell FORTRAN77 is similar with C. They have similar data type and functions statement. FORTRAN 77 tends to be easier for non-experts to learn than C, because its 'mental model of the computer' is much simpler. FORTRAN 77 generally requires much less computer science knowledge of the programmer than C does, and is thus much easier to use. In the conclusion, we can say FORTRAN77 is a useful and basic language in modern programming. Fortran is now one of the most widely used computer languages in the world with compilers available for almost every type of computer on the market [1]. We should take a look at it and understand how to program through it. References 1 Code Tuning co-guide, 1998 Lahey Fortran Users' Conference, 1-1. Retrieved Feb. 15, 2003 from the World Wide Web: http://www.ibiblio.org/pub/languages/fortran/ch1-1.ht ml 2 Page, Clive G., UK (2001, December 21st). Professional Programmer's Guide to Fortran77, 1.2 (Article 1). Retrieved February 15, 2003 from the World Wide Web: http://www.star.le.ac.uk/~cgp/prof77.html#tth_sec1

3 Page,Rex L., Didday, Richard L., &Alpert, Elizabeth(1983). FORTRAN 77 for humans, 2 (pp.210-211). Minnesota: WEST. 4 Page, Clive G., UK (2001, December 21st). Professional Programmer's Guide to Fortran77, 1.2 (Article 1). Retrieved February 15, 2003 from the World Wide Web: http://www.star.le.ac.uk/~cgp/prof77.html#tth_sec1 The example of SUBROUTINE: Comment: When called, increment page number and print it. C SUBROUTINE NEWPGE (PAGE) INTEGER PAGE PAGE = PAGE + 1 PRINT * PRINT * PRINT * PRINT *, PRINT *, RETURN END LEAVE SOME SPACE BEFORE NEW PAGE BOOK REPORT E100 SILAS MARNER, BY GEORGE ELIOT The example of the whole program: Comment: Program to print SILAS MARNER BOOK REPORT C VARIABLES: C PGENUM CURRENT PAGE NUMBER (UPDATED BY SUBROUTINE NEWPGE) C REPORT---ARRAY TO STORE CURRENT LINE C LINE ---NUMBER OF LINES PRINTED SO FAR ON CURRENT PAGE INTEGER PGENUM, LINE, PGELEN CHARACTER* 60 REPORT, FINIS PGELEN = 35 FINIS = *END* C PGENUM=0 CALL NEWPGE (PGENUM) PRINT *, REVIEW OF PRINT *, SILAS MARNER TITLE PAGE C LINE = PGELEN +1 200 READ *, REPORT BODY OF REPORT

IF (REPORT.EQ. FINIS) GO TO 300 LINE = LINE +1 IF (LINE.GT. PGELEN) THEN LINE =1 CALL NEWPGE (PGENUM) ENDIF PRINT *, REPORT GO TO 200 300 END

FORTRAN77 Attribute Score Syntax (simple and easy) 10 Strongly Type System (binding) 10 Orthogonal 10 Function 8 Clarity of Code 9 Program Control 9 Powerful (basic of the higher language) 10 User Field (computation) 8