Introduction to Fortran 90/95

Download Introduction to Fortran 90/95

Post on 09-Jan-2016

84 views

Category:

Documents

6 download

Embed Size (px)

DESCRIPTION

Introduction to Fortran 90/95. 1390. . : () : 3 : 1 : ( code ) () - PowerPoint PPT Presentation

TRANSCRIPT

<ul><li><p> *Introduction to Fortran 90/95 1390</p></li><li><p> : () : 3: 1 : (code) () </p><p> *</p></li><li><p> . :30 : 1389/9/15 70 : 1389/10/26 : Max{0.3midterm+0.7final, final} . *</p></li><li><p> * : 90 90 : : Fortran 90/95 Fortran 90/95 : : </p></li><li><p> * ( ) (codes) (compile) (*.exe) </p></li><li><p> * () </p><p>c=a+bd=a*b</p></li><li><p> *</p></li><li><p> FORmula TRANslation invented 19548 by John Backus and his team at IBMFORTRAN 66 (ISO Standard 1972)FORTRAN 77 (1980)Fortran 90 (1991)Fortran 95 (1996)Fortran 2003 (2004)Fortran 2008 (ongoing)</p><p> *</p></li><li><p> *Fortran AlphabetsA B C D E Fa b c d e f .0 1 2 3 4 5 6 7 8 9 , ( ) * + - / : = - ! &amp; $ ; &lt; &gt; ? . % _ blank</p></li><li><p> * . . 31 . . (underline) . . :Conut, AliX900g, I1025R2_D2, R2D2_ :M.t.u, R2-D26feet_system A_name_made_up_of_more_than_31_letterstoo long, 38 characters</p></li><li><p> * . 90 : </p></li><li><p> * integercorrect: 0, -345, 789, +1234incorrect: 12.0, --4, 5+realcorrect: 123.45, .123, 123., -0.12, +0.12incorrect: 65complexx+iy</p></li><li> * charactercorrect: 'Ali' or "Ali" (content: Ali and length: 3), 'Ali is #2' (content: Ali is #2 and length: 9)special case: 'Ali''s apple' (content: Alis apple and length: 11) incorrect: 'you and me, 'Tech's seminar', 'have a nice day"Correct: "Ali's apple" (string) .Logical .A</li><li><p> * . (syntax) :Integer :: j, icountReal :: wide, angleLogical :: tryCharacter(Len = 5) :: nameCharacter(Len = 10) :: city, nation*20, box, bug*1Character :: answer, marital_statusanswer and marital_status are each of length 1 :: integer real logical character .</p></li><li><p> * integer Real . i,j,k,l,m,n . :integeric, kzip, name, l_georealzip, code, geoNames starting with IN are INTEGEROnes with AH and OZ are REAL</p></li><li><p> implicit none implicit none . .implicit noneinteger :: ice, cokereal :: var, kind *</p></li><li><p> . parameterInteger :: count = 0, I = 5, J = 100Real :: max = 1005.25, min = -0.01Character(Len=10) :: light = AmberLogical :: red = .TRUE., blue = &amp; .FALSE., green = .FALSE. *</p></li><li><p> * Parameter .integer, parameter :: limit = 100real, parameter :: pi = 3.14159, twopi = 2*piinteger, parameter :: month_in_a_year = 12: integer, real ... (::) (::) . Character(Len=*), parameter :: &amp;error = 'unknown'</p></li><li><p> * </p></li><li><p> * 1:X + Y * Z is equivalent to X + (Y * Z)X + Y / 7.0 is equivalent to X + (Y / 7.0)A B + C is equivalent to (A B) + CA + B ** C is equivalent to A + (B ** C) A ** 2 is equivalent to (A ** 2)A ((( B + C))) is equivalent to A (B + C)You can force any order you like(X + Y) * ZAdds X to Y and then multiplies by Z</p></li><li><p> * 2:A / B * C is it A / (B * C) or (A / B) * C?A ** B ** C is it A ** (B ** C) or (A ** B) ** C?Fortran specifies that:A / B * C is equivalent to (A / B) * CA ** B ** C is equivalent to A ** (B ** C)Yes, ** binds from right to left!</p></li><li><p> * : .a+2b*b-4*a*cA&gt;B (=) .Delta = b*b-4*a*cArea = pi*r**2count = count+1</p></li><li><p> Division always truncates towards zeroIf K = 4 and L = 5, then K+L/2 is 6(-7)/3 and 7/(-3) are both -2 INTEGER :: K = 5REAL :: X = 1.3X = X+K/2That will add 2.0 to X, not 2.5K/2 is still an INTEGER expression *</p></li><li><p> * N = 10./3(value of N is 3)X = 10/3(value of X is 3.0)Y = 10/3.(value of Y is 3.33333)10./33.33333 N310/3 3 X 3.10/3. 3.33333 Y 3.33333 . </p></li><li><p> * (1) </p></li><li><p> * (2)</p></li><li><p> * print write . :print*, expr_1, expr_2, (format) .write(*,*) expr_1, expr_2, . . .Print*write(*,*)</p></li><li><p> * (1) . read .read(*,*) var_1, var_2, write . read . read read*, var_1, var_2, (format) .</p></li><li><p> * (2) read . . read .</p></li><li><p> * Program solve_equationReal :: a,b,cReal :: dReal :: root1, root2! read in coefficient a,b,cPrint*,a,b,c please:read*,a,b,c! compute the square root of discriminant dd = sqrt(b*b-4*a*c)! solve equationroot1 = (-b+d)/(2*a) ! first rootroot2 = (-b-d)/(2*a) ! second root! display the resultswrite(*,*) Roots are, root1, and, root2End Program solve_equation</p></li><li><p> *Text EditorCompilerlinklibsystemPhase I: TranslationPhase II: LinkagePhase III: Execution</p><p>*</p></li></ul>