Fortran 90
-
Upload
jermaine-sweet -
Category
Documents
-
view
20 -
download
0
description
Transcript of Fortran 90
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.
Background
John Backus in New Mexico, 1976
-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.
Description 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
Advantages of Fortran
1. INTEGER a string of digit s with an optional sign
0, -345, 789, +1232 .REAL may be in
scientific exponential formDecimal Form:
123.45, .123, 123.Exponential Form:
12.34E3, 123.3E+33. CHARACTER a string of characters enclosed between apostrophes or double quotes
‘John’ and “John”
Data Types and Constants
Output The WRITE StatementWRITE(*,*)WRITE(*,*) expr-1, expr-2, …, expr-n
Output The READ StatementREAD(*,*)READ(*,*) var-1, var-2, …, var-n
Free Format
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)
Example
http://www.cs.mtu.edu/~shene/COURSES/cs201/
NOTES/fortran.html
http://www.nsc.liu.se/~boein/f77to90/f77to90.html#index
Resources