Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

What is FORTRAN ?

No description

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of What is FORTRAN ?

What is FORTRAN ?
1st generation language.
Most accepted compiled programming language.
Machine dependent
Major contribution is the use of algebraic notation

Stands for IBM Mathematical FORmula TRANslation System but abbreviated to FORmula TRANslation
FORTRAN 0 was developed by a IBM research team headed by John Backus in 1954.
Was the first high-level programming language

History of FORTRAN
John Backus
1924-1988

The design of FORTRAN made it easier to translate mathematical formulas into code.
FORTRAN originally began as a digital code interpreter for the IBM 701
At that time it was called Speedcoding
The point of FORTRAN was to make programming easier.

More History
FORTRAN I 1957
Was the first compiler
By 1958 over 50% of software was in FORTRAN
Cut development time.
2 weeks to 2 hours

FORTRAN II - IV
FORTRAN IV
Explicit type declarations
Logical selection (IF) statement
Subprogram names could be parameter
ANSI standard in 1966

FORTRAN 77
FORTRAN 77 replaced FORTRAN IV as the new standard.
It retained most of the features of IV
It added
Character string handling
Logical loop control statements
And a If with a optional else statement


Data Types
FORTRAN 77 explicitly permits data types of integer, real, double precision, complex, logical, and characters.

Real Data Types
Represent decimal numbers
It uses scientific notation
3E5 300000
.123E-3 .000123

Double Precision Data Types
Extended precision floating point
Instead of E it used D
1D2 100


Complex Data Types
Built in complex number data type
Which occupies 2 bytes
The first byte in the pair represents the real part of the complex data type.
The second byte represents the imaginary part of the complex item

represented as follows
Numeric Value
(4.61,-6.81) 4.61 – 6.81i
(-10,5) -10+5i

Program Structure
A FORTRAN program is a collection of subprogram definitions.
Subprograms may be a FUNCTION that returns values, a SUBROUTINE that dosen’t return a value, and one must be the “main program”

Main Program
The main program receives control of the processor when an executable program is loaded for execution.
There can be only one main program in an executable program.
That main program is identified by the fact that it does not have a FUNCTION, SUBROUTINE, or BLOCK DATA statement as its initial statement.

Intrinsic Functions
FORTRAN has many intrinsic functions
Examples
SQRT( ) square root
FLOAT( ),INT ( ) type conversions
COS( ),SIN( ), TAN( ) trig functions

Statement Functions
Statement functions are one line defined functions that is internal to the program unit in which it is defined
Example of a statement function
ROOT(A,B,C) = (-B+SQRT(B**2-4.0*A*C))/(2.0*A)

Control Structures
GOTO statements
IF statements
DO statement
CONTINUE statement
STOP and PAUSE statements
END statement

GOTO Statements
The GOTO statement is used to direct program control to indicated by the statement number specified in the respective GOTO statement
Three types of GOTO statements
Unconditional GOTO 100
Computed GOTO(1,2,3)I
Assigned GOTO I,(1,2,3)

IF Statements
Contains IF, ELSE IF, ELSE, END IF
Example
IF(Q) THEN
A=B
C=D
ELSE IF (R) THEN
E=F
G=H
ELSE
X=Y
Z=W
END IF

DO Statement
The DO statement is used to establish a controlled loop
Example DO
DO 10 I = 1,10,1

CONTINUE,STOP PAUSE, and END STATEMENT
The CONTINUE statement serves as a point of reference in a program
No operational function is performed
It is frequently used in DO loops to provide a terminal statement
EVALUATION
Readability
Readability
FORTRAN 77 is not to hard to read on a small scale, but when many GOTO statements are involved it gets very difficult
But FORTRAN 90 is much more easy to read
Identifiers can only be six characters long

Writability
Enhanced orthogonality
Enhanced expressivity
Easy file accessing
Recursion and Derived data types
Compile-time initialization of local variables
Separate pointer assignment operator (good and bad)
Reliability
Is not very reliable
Only static type checking
Lack of exception handling

Cost
Cheap
Lots of free resources/compilers
A fairly easy language to learn

FORTRAN 90 AND 95
FORTRAN 90 (ANSI standard in 1990)
Support
Array Programing
Object base programing

FORTRAN violates several programming principles
Zero-One-Infinity Principle
The only reasonable numbers in a programming language design are zero, one and infinity. A special case of the regularity principle.



Defense in depth Principle
If an error gets through one line of defense then it should be caught by the next line of defense.



 Regularity Principle
Language rules should be applied universally without exception.




 Structured Programming Principle
The static structure of a program should correspond in a simple way to the dynamic structure of the program.




Syntactic consistency principle
Things which look similar should be similar, and things which look different should be different.


Fortran Violations
Fortran 77 arbitrarily limits identifier names to 6 characters.
Fortran 77 arbitrarily limits arrays to 3 dimensions.
Fortran Violations
FORTRAN does not have exception handling or type chcking.

Do20I=1,100
If mistakenly put . instead of ,
Do20I=1.100

FORTRAN take is as a valid automation variable declaration
Fortran Violations
FORTRAN - Can store strings in integers

Perimits Hollerith constants to be used as parameters.

Int[6]
Letter[H]
Fortran Violations
GOTO statements are required in Fortran 77 to emulate while loops, and there are three similar looking versions of the GOTO statement with different behavior.
Fortran Violations
The simple, computed , and assigned goto statements in Fortran are different but look similar.

GOTO N - Basic GOTO

GOTO (L1, L2,...., LN)E - Computed GOTO

GOTO L,(L1,L2,...., LN) - Assign GOTO
Assign 20 to L
Fortran violations
Fortran uses :
* for multiplication and ** for exponents
= for assignment and == for equal
+ for addition and ++ for increment
Fortran Questions
What is the difference between a Subprogram and a Subroutine ?
A subroutine is one type of a subprogram. A Function is another, and a BLOCKDATA routine is a third.
Q1
Answer
What are the Five Arithmetic Operators of FORTRAN?
+, -, *, /, **
Q2
Answer
What are the six relational operators in FORTRAN?
.LT., .LE., .GT., .EQ., .NE.
Q3
Answer
What is the first line of every FORTRAN program and what does it tell the compiler?
Program
Q4
Answer
Rewrite this code to use the DO WHILE statement:

DO I=1,N,-1
SUM = SUM + I
END DO
Answer
Q5
I = N
DO WHILE (I .GT. N)
SUM = SUM + I
I = I - 1
END DO
Write a function that will take a number and return a number that is the original
number taken to a given exponent.
Answer
Q6
REAL FUNCTION POW(NUM, EXPO)
POW = NUM ** EXPO
RETURN
END
FORTRAN II
Independent compilation
Fix the bugs
FORTRAN III
Was developed, but it was never widely distributed
FORTRAN 95 (latest ANSI standard version)
FORTRAN 90/95 allows user defined types.
The END statement marks the physical end of a program

The STOP and PAUSE statements do a similar task
The STOP terminates execution
The PAUSE terminates execution, but leaves the program in a resumable state
Cost
Reliability
Writability
Interpretation:
A programming language construct should be limited to being singular, zero or able to scale to infinitely.

Interpretation:
There should exist multiple checks for errors in a program such that error detection is maximized.

Interpretation:
There should not exist any exceptions to grammar rules.
Interpretation:
The execution of a program should be easy to trace given its source code.

Interpretation:
The language should have visually different constructs to avoid confusion between similar symbols for constructs.
Full transcript