1 / 18

Fortran 77

Fortran 77. By Tanatorn Somboonvorakit, ID: 49540453. Fortran 77 first designed. The standard definition of Fortran was updated in the late 1970's and a new standard, ANSI X3.9-1978, was published by the American National Standards Institute .

emiko
Download Presentation

Fortran 77

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Fortran 77 By Tanatorn Somboonvorakit, ID: 49540453

  2. Fortran 77 first designed The standard definition of Fortran was updated in the late 1970's and a new standard, ANSI X3.9-1978, was published by the American National Standards Institute. This standard was subsequently (in 1980) adopted by the International Standards Organization (ISO) as an International Standard (IS 1539 : 1980). The language is commonly known as FORTRAN 77

  3. The goals ofthis language • Fortran, which originally stood for IBM Mathematical FORmula TRANslation System but has been abbreviated to FORmula TRANslation, is the oldest of the established “high-level” languages. • Use for scientific computation

  4. Designed by … A group in IBM during the late 1950s.

  5. Problem domain was Fortran 77 intended for Fortran programs could be processed very efficiently, led to Fortran being the most heavily-used programming language for non-commercial applications. By the mid 1970s virtually every computer, mini or mainframe, was supplied with a standard-conforming FORTRAN 66 language processing system. It was therefore possible to write programs in Fortran on any one system and be reasonably confident that these could be moved fairly easily to work on any other system.

  6. Some main features of the language Compilers, which usually support a small number of extensions have, become very efficient. Populate Scientific installations all over the world.

  7. How widely is the language used ? This version of the language is widespread use. The standard is Fortran 66 and have been develop to Fortran 77, Fortran 88 and 90. Now this language is still use until today.

  8. About the Language Arithmetic expressions Operator Operation + Addition or unary + - Subtraction or unary – * Multiplication / Division ** Exponentiation The READ statement The READ statement is used to assign values to variables by reading data from input. Form : READ *, variable_list Example : READ *, VAR1, VAR2, VAR3

  9. Variables A variable is a unique name which a Fortran program applies to a word of memory and uses to refer to it. A variable consists of '''1 to 6 upper case alphabetic characters and decimal digits''', beginning with an alphabetic character. Examples: VOL TEMP A2 COLUMN IBM370

  10. The PRINT statement Output can be printed using the PRINT statement. Form : PRINT *, output_list Example : PRINT *, 'THE RESULTS ARE', X ,'AND',Y The PROGRAM statement A program can optionally be given a name by beginning it with a single PROGRAM statement. Form : PROGRAMprogram_name Example : PROGRAM TESTPROGRAM

  11. The END and STOP statements Each program must conclude with the statement END, which marks the end of the program. There must be no previous END statement. The statement STOP stops execution of the program. Comments The letter ‘C’ or an asterisk in column one causes the compiler to ignore the rest of the line, which may therefore be used as a comment to provide information for anyone reading the program.

  12. Relational expressions A relational expression is a logical expression which states a relationship between two expressions, evaluating to .TRUE. if the relationship applies or .FALSE. otherwise. A relational expression has the form: arithmetic_expression relational_operator arithmetic_expression The relational operators are: Meaning .LT. Less than .LE. Less than or equal to .EQ. Equal to .NE. Not equal to .GE. Greater than or equal to .GT. Greater than

  13. Thus examples of relational expressions are: N.GE.0 X.LT.Y B**2 - 4*A*C .GT. 0. Composite logical expressions Form: L1 logical_operator L2 Meaning .AND. Both L1and L2 are .TRUE. .OR. Either L1 or L2 or both are .TRUE. .EQV. Both L1 and L2have the same value (.TRUE. or .FALSE.) .NEQV. L1 and L2 have different values (one .TRUE. and one .FALSE.) Example : (A.LT.B) .OR. (C.LT.D)

  14. The logical IF statement The logical IF statement is used to execute an instruction conditionally. Form : IF (logical_expression) executable_statement Example : IF (A.LT.B) SUM = SUM + A The block IF structure The block IF structure is more powerful, permitting the conditional execution of one of a number of alternative sequences of instructions.

  15. described informally as : an IF block, followed by : one or more optional ELSE IF blocks, followed by : an optional ELSE block, followed by : END IF Example : IF (HRS .LE. 40) THEN SALARY = HRS * RATE ELSE IF (HRS .LE. 50) THEN SALARY = 40.0 * RATE + (HRS – 40.0) * RATE * 1.5 ELSE SALARY = 40.0 * RATE + 10.0 * RATE * 1.5 + (HRS – 50.0) * RATE * 2.0 END IF Form : IF (logical_expression) THEN ….Fortran statements…. ELSE IF (logical_expression) THEN ….Fortran statements…. ELSE ….Fortran statements…. END IF

  16. The DO-loop A DO loop is a sequence of statements beginning with a DO statement. Form : DOlabel, var = e1, e2, [,e3] label is the label of an executable statement sequentially following the DO statement called theterminal statementof the DO loop. var is an INTEGER or REAL variable called theloop control variable. e1, e2 and e3are arithmetic expressions.(i.e. INTEGER or REAL constants) Example : DO 10, I = 1,5 DO 10, I = 0,100,5

  17. Nested DO loops Example : DO 20, ….. ………… DO 10, ….. ………… 20 CONTINUE ………. 10 CONTINUE Example : DO 20, ….. ………… DO 10, ….. ………… 10 CONTINUE ………. 20 CONTINUE VALID INVALID

  18. A simple program PROGRAM PETROL INTEGER STOPS, FILLUP C C THESE VARIABLES WOULD OTHERWISE BE TYPED REAL BY DEFAULT C ANY TYPE SPECIFICATIONS MUST PRECEDE THE FIRST EXECUTABLE STATEMENT C READ *, KM, STOPS, FILLUP USED = 40 * STOPS + FILLUP C COMPUTES THE PETROL USED AND CONVERTS IT TO REAL KPL = KM / USED + 0.5 C 0.5 IS ADDED TO ENSURE THAT THE RESULT IS ROUNDED PRINT *, ‘AVERAGE KPL WAS’, KPL END

More Related