90 likes | 197 Views
Fortran 90. Background. The programming language Fortran is the dominating language for technical and scientific applications. It was developed originally at IBM in 1954 under the supervision of John Backus. John Backus in New Mexico, 1976. Description of Fortran.
E N D
Background The programming language Fortran is the dominating language for technical and scientific applications. It was developed originally at IBM in 1954 under the supervision of John Backus. John Backus in New Mexico, 1976
Description of Fortran -Fortran is the language for number crunching but would not use for database development -Fortran is superior to other languages for numerical computation, many diverse and reliable libraries of routines are available, an official standard exists which helps towards portability.
Advantages of Fortran -Fortran is a simple language -Fortran has always existed -Fortran compilers are generally available -Earlier the first programming language -Good at numerical analysis and technicalcal culations -Efficient compilers -The dominating language on supercomputers
Data Types and Constants 1. INTEGER a string of digits with an optional sign 0, -345, 789, +123 2 .REAL may be in scientific exponential form Decimal Form: 123.45, .123, 123. Exponential Form: 12.34E3, 123.3E+3 3. CHARACTER a string of characters enclosed between apostrophes or double quotes ‘John’ and “John”
Free Format Output The WRITE Statement WRITE(*,*) WRITE(*,*) expr-1, expr-2, …, expr-n Output The READ Statement READ(*,*) READ(*,*) var-1, var-2, …, var-n
Example PROGRAM VerticalBarChart IMPLICIT NONE CHARACTER(LEN=*), PARAMETER :: Part1 = "(1X, I5, A," CHARACTER(LEN=*), PARAMETER :: Part2 = "A, A, I2, A)" CHARACTER(LEN=2) :: Repetition CHARACTER(LEN=10), PARAMETER :: InputFormat = "(I5/(5I5))" INTEGER :: Number, i, j INTEGER, DIMENSION(1:100) :: Data READ(*,InputFormat) Number, (Data(i), i=1, Number) DO i = 1, Number IF (Data(i) /= 0) THEN WRITE(Repetition,"(I2)") Data(i) WRITE(*,Part1 // Repetition // Part2) Data(i), " |“, ("*",j=1,Data(i))," (", Data(i), ")" ELSE WRITE(*,"(1X, I5, A, I2, A)") Data(i), " | (", Data(i), ")" END IF END DO END PROGRAM VerticalBarChart
Example Suppose the input data consist of the following: 14 8 27 24 40 45 38 26 16 3 5 4 0 2 1 The output of the program is: 8 |******** ( 8) 27 |*************************** (27) 24 |************************ (24) 40 |**************************************** (40) 45 |********************************************* (45) 38 |************************************** (38) 26 |************************** (26) 16 |**************** (16) 3 |*** ( 3) 5 |***** ( 5) 4 |**** ( 4) 0 | ( 0) 2 |** ( 2) 1 |* ( 1)
Resources http://www.cs.mtu.edu/~shene/COURSES/cs201/NOTES/fortran.html http://www.nsc.liu.se/~boein/f77to90/f77to90.html#index