Fortran MATTHEW CARS ON History of FORTRAN FORTRAN

  • Slides: 14
Download presentation
Fortran MATTHEW CARS ON

Fortran MATTHEW CARS ON

History of FORTRAN • FORTRAN 66 • FORTRAN 0 • 1954; First High Level

History of FORTRAN • FORTRAN 66 • FORTRAN 0 • 1954; First High Level Language • FORTRAN I • FORTRAN 77 • 1957; First Compiled Language • FORTRAN II 1958 • 1958; Independent Subroutines • FORTRAN IV • 1966 -67; First Standard 1960 • 1960; Most Used Version • 1977 -78; IMPLICIT and Block Control • Fortran 90 • 1991 -92; Free-form code • Fortran 95 • 1997; FORALL and ALLOCATABLE

Fortran Compiler Support for Fortran 2003/2008 • http: //fortranwiki. org/fortran/show/Fortran+2003+status • http: //fortranwiki. org/fortran/show/Fortran+2008+status

Fortran Compiler Support for Fortran 2003/2008 • http: //fortranwiki. org/fortran/show/Fortran+2003+status • http: //fortranwiki. org/fortran/show/Fortran+2008+status

Fortran Overview • Variable names up to 31 characters • Case-insensitive • Strong typed

Fortran Overview • Variable names up to 31 characters • Case-insensitive • Strong typed • Static binding

Data Types • INTEGER REAL (KIND=2) : : x = 10. 25 • REAL

Data Types • INTEGER REAL (KIND=2) : : x = 10. 25 • REAL (KIND=8) : : x = 10. 25 • COMPLEX • LOGICAL • CHARACTER : : char = ‘a’ • DERIVED TYPES CHARACTER (LEN=5) : : string = “Hello”

Arrays • INTEGER, DIMENSION(10, 10) : : array • INTEGER, DIMENSION(: , : )

Arrays • INTEGER, DIMENSION(10, 10) : : array • INTEGER, DIMENSION(: , : ) : : array • CHARACTER, DIMENSION(10) : : array_of_characters • CHARACTER(LEN=5), DIMENSION(10) : : array_of_strings

Derived Types F ort ran 90/ 95 For tr an 2003 TYPE car TYPE

Derived Types F ort ran 90/ 95 For tr an 2003 TYPE car TYPE circle REAL : : weight REAL : : length INTEGER : : id_number END TYPE car REAL : : radius CONTAINS PROCEDURE : : area END TYPE circle

Operators and Expressions OPERA TOR P RE C EDE NCE 1. Exponentiation (**) 2.

Operators and Expressions OPERA TOR P RE C EDE NCE 1. Exponentiation (**) 2. Multiplication/Division REAL : : w, x, y, z 3. Addition/Subtraction w=5 4. ( <, <=, >, >=, ==, /= ) x=2 5. . NOT. y = -w**x ! Outputs: -25 6. . AND. z = (-w)**x ! Outputs: 25 7. . OR. 8. . XOR. , . EQV. , . NEQV.

Control Structures • IF-ELSE-END IF • SELECT CASE (<parameter>) • DO <variable> = INITIAL_VAL,

Control Structures • IF-ELSE-END IF • SELECT CASE (<parameter>) • DO <variable> = INITIAL_VAL, END_VAL, STEP • DO WHILE (<logical expression>) • FORALL (I=1: 100, J=1: 100) A(I, J)=I*(I+J)

Subprograms FUNCTION S UBROUTIN E FUNCTION cube(x) result(y) SUBROUTINE half_cube(x, y, z) INTEGER, INTENT(IN)

Subprograms FUNCTION S UBROUTIN E FUNCTION cube(x) result(y) SUBROUTINE half_cube(x, y, z) INTEGER, INTENT(IN) : : x INTEGER, INTENT(IN) INTEGER : : y INTEGER, INTENT(OUT) : : y, z y = x**3 END FUNCTION cube PROGRAM test IMPLICIT NONE y = x/2 z = x**3 END SUBROUTINE half_cube PROGRAM test INTEGER : : cube … print *, cube(4) CALL half_cube(x, y, z) END PROGRAM : : x

Readability • Easy to read • Free form source code • Procedural language base

Readability • Easy to read • Free form source code • Procedural language base • Use of END program statements

Writability • FORmula TRANslator • Inclusion of complex data types • Fewer control structures

Writability • FORmula TRANslator • Inclusion of complex data types • Fewer control structures and libraries

Reliability • Strong typing and Static Binding • Simple to read and write =

Reliability • Strong typing and Static Binding • Simple to read and write = easy to maintain • “I don’t know what the language of the year 2000 will look like, but I know it will be called Fortran. ” Tony Hoare, Turing award winner 1980

Cost • Easy to learn • Free compiler • Backward compatibility

Cost • Easy to learn • Free compiler • Backward compatibility