SlideShare uma empresa Scribd logo
1 de 37
Baixar para ler offline
CIVIL HTI
Fortran 77
Series Lectures
Dr. A.M.K. Shaltout
2016
Variables,Types and Declarations
Variable Names
Variable names in Fortran consist of any letters from a-z or digits 0-9
Fortran 77 does not distinguish between upper and lower case
Types and declarations
The most common declarations are:
Integer characters: I, J, K, L, M, N
integer list of variables
real list of variables
Examples:
VOL TEMP A2 COLUMN IBM370
Column position rules :
Fortran 77 is not a free-format language, but has a very strict set of rules for
how the source code should be formatted. The most important rules are the
column position rules:
 Col. 1 : Blank, or a "c" or "*" for comments
 Col. 2-5 : Statement label (optional)
 Col. 6 : Continuation of previous line (optional)
 Col. 7-72 : Statements
Statement Format
 FORTRAN 77 requires a fixed format for programs
PROGRAM MAIN
C COMMENTS ARE ALLOWED IF A “C” IS PLACED IN COLUMN #1
DIMENSION X(10)
READ(5,*) (X(I),I=1,10)
WRITE(6,1000) X
1000 FORMAT(1X,’THIS IS A VERY LONG LINE OF TEXT TO SHOW HOW TO CONTINUE ’
* ‘THE STATEMENT TO A SECOND LINE’,/,10F12.4)
1-5
Label
6 7-72 Statements 73-80
Optional
Line #s
Any character: continuation line
Flowchart Symbols
Basic
Oval
Parallelogram
Rectangle
Diamond
Hybrid
Name Symbol Use in Flowchart
Denotes the beginning or end of the program
Denotes an input operation
Denotes an output operation
Denotes a decision (or branch) to be made.
The program should continue along one of
two routes. (e.g. IF/THEN/ELSE)
Denotes a process to be carried out
e.g. addition, subtraction, division etc.
Flow line Denotes the direction of logic flow in the program
Pseudocode & Algorithm
 Example 1: Write an algorithm to determine a
student’s final grade and indicate whether it is
passing or failing. The final grade is calculated
as the average of four marks.
Pseudocode & Algorithm
Pseudocode:
 Input a set of 4 marks
 Calculate their average by summing and dividing by 4
 if average is below 50
Print “FAIL”
else
Print “PASS”
Pseudocode & Algorithm
 Detailed Algorithm
 Step 1: Input M1,M2,M3,M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE < 50) then
Print “FAIL”
else
Print “PASS”
endif
Example
PRINT
“PASS”
Step 1: Input M1,M2,M3,M4
Step 2: GRADE  (M1+M2+M3+M4)/4
Step 3: if (GRADE <50) then
Print “FAIL”
else
Print “PASS”
endif
START
Input
M1,M2,M3,M4
GRADE(M1+M2+M3+M4)/4
IS
GRADE<5
0
PRINT
“FAIL”
STOP
YN
Example 2
 Write an algorithm and draw a flowchart to
convert the length in feet to centimeter.
Pseudocode:
 Input the length in feet (Lft)
 Calculate the length in cm (Lcm) by
multiplying LFT with 30
 Print length in cm (LCM)
Example 2
Algorithm
 Step 1: Input Lft
 Step 2: Lcm  Lft x 30
 Step 3: Print Lcm
START
Input
Lft
Lcm  Lft x 30
Print
Lcm
STOP
Flowchart
Example 3
Write an algorithm and draw a flowchart that will
read the two sides of a rectangle and calculate its
area.
Pseudocode
• Input the width (W) and Length (L) of a rectangle
• Calculate the area (A) by multiplying L with W
• Print A
Example 3
Algorithm
• Step 1: Input W,L
• Step 2: A  L x W
• Step 3: Print A
START
Input
W, L
A  L x W
Print
A
STOP
Example 4
• Write an algorithm and draw a flowchart that will
calculate the roots of a quadratic equation
• Hint: d = sqrt ( ), and the roots are: x1 =
(–b + d)/2a and x2 = (–b – d)/2a
2
0ax bx c  
2
4b ac
Example 4
Pseudocode:
• Input the coefficients (a, b, c) of the quadratic
equation
• Calculate d
• Calculate x1
• Calculate x2
• Print x1 and x2
Example 4
• Algorithm:
• Step 1: Input a, b, c
• Step 2: d  sqrt ( )
• Step 3: x1  (–b + d) / (2 x a)
• Step 4: x2  (–b – d) / (2 x a)
• Step 5: Print x1, x2
START
Input
a, b, c
d  sqrt(b x b – 4 x a x c)
Print
x1 ,x2
STOP
x1 (–b + d) / (2 x a)
X2  (–b – d) / (2 x a)
4b b a c   
Program Organisation
 A Fortran program generally consists of a main program (or driver) and
possibly several subprograms (or procedures or subroutines). For now we
will assume all the statements are in the main program; subprograms will be
treated later. The structure of a main program is:
program name
declarations
statements
stop
end
Create a new text file
Numeric Expressions
 Very similar to other languages
 Arithmetic operators:
 Precedence: **
Examples:
x = 3 + 4
y = a*b
z = radius ** 2
z=x-y
z=x/y
programming fortran 77 Slide01

Mais conteúdo relacionado

Mais procurados

Quantum mechanics
Quantum mechanics Quantum mechanics
Quantum mechanics
Kumar
 
Semiconductor nanodevices
Semiconductor nanodevicesSemiconductor nanodevices
Semiconductor nanodevices
Atif Syed
 

Mais procurados (20)

Energy bands and gaps in semiconductor
Energy bands and gaps in semiconductorEnergy bands and gaps in semiconductor
Energy bands and gaps in semiconductor
 
Fermi dirac distribution
Fermi dirac distributionFermi dirac distribution
Fermi dirac distribution
 
Curie temperature of ferrites
Curie temperature of ferritesCurie temperature of ferrites
Curie temperature of ferrites
 
Liquid drop model
Liquid drop modelLiquid drop model
Liquid drop model
 
Quantum mechanics
Quantum mechanics Quantum mechanics
Quantum mechanics
 
Semiconductor nanodevices
Semiconductor nanodevicesSemiconductor nanodevices
Semiconductor nanodevices
 
Quantum number and Pauli exclusion principle
Quantum number and Pauli exclusion principleQuantum number and Pauli exclusion principle
Quantum number and Pauli exclusion principle
 
Dielectric Material and properties
Dielectric Material and propertiesDielectric Material and properties
Dielectric Material and properties
 
Unit 3
Unit 3Unit 3
Unit 3
 
Exchange Interaction and their Consequences.pptx
Exchange Interaction and their Consequences.pptxExchange Interaction and their Consequences.pptx
Exchange Interaction and their Consequences.pptx
 
Dielectric Spectroscopy and Dielectric Permittivity Physical Nature
Dielectric Spectroscopy and Dielectric Permittivity Physical NatureDielectric Spectroscopy and Dielectric Permittivity Physical Nature
Dielectric Spectroscopy and Dielectric Permittivity Physical Nature
 
13.2
13.213.2
13.2
 
Potential Energy Surface & Molecular Graphics
Potential Energy Surface & Molecular GraphicsPotential Energy Surface & Molecular Graphics
Potential Energy Surface & Molecular Graphics
 
Graphene
GrapheneGraphene
Graphene
 
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
UCSD NANO106 - 03 - Lattice Directions and Planes, Reciprocal Lattice and Coo...
 
The Nuclear Shell Model
The Nuclear Shell ModelThe Nuclear Shell Model
The Nuclear Shell Model
 
Quark particles
Quark particlesQuark particles
Quark particles
 
Lecture9 1
Lecture9 1Lecture9 1
Lecture9 1
 
Fortran tutorial
Fortran tutorialFortran tutorial
Fortran tutorial
 
Energy band and energy gap by Pratimesh pathak
Energy band and energy gap by Pratimesh pathakEnergy band and energy gap by Pratimesh pathak
Energy band and energy gap by Pratimesh pathak
 

Semelhante a programming fortran 77 Slide01

Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
rajnidhiman
 

Semelhante a programming fortran 77 Slide01 (20)

256958.ppt
256958.ppt256958.ppt
256958.ppt
 
Algorithms and Flowcharts
Algorithms and FlowchartsAlgorithms and Flowcharts
Algorithms and Flowcharts
 
01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt01 Algorithms And Flowcharts.ppt
01 Algorithms And Flowcharts.ppt
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Algorithms and flowcharts
Algorithms and flowchartsAlgorithms and flowcharts
Algorithms and flowcharts
 
algorithms and flow chart overview.pdf
algorithms and flow chart overview.pdfalgorithms and flow chart overview.pdf
algorithms and flow chart overview.pdf
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Algorithmsandflowcharts1
Algorithmsandflowcharts1Algorithmsandflowcharts1
Algorithmsandflowcharts1
 
Basic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and FlowchartsBasic Slides on Algorithms and Flowcharts
Basic Slides on Algorithms and Flowcharts
 
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.pptLecture1-Algorithms-and-Flowcharts-ppt.ppt
Lecture1-Algorithms-and-Flowcharts-ppt.ppt
 
AlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdfAlgorithmAndFlowChart.pdf
AlgorithmAndFlowChart.pdf
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
 
Algorithms and Flowchart.ppt
Algorithms and Flowchart.pptAlgorithms and Flowchart.ppt
Algorithms and Flowchart.ppt
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 
3 algorithm-and-flowchart
3 algorithm-and-flowchart3 algorithm-and-flowchart
3 algorithm-and-flowchart
 
ALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTSALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS
 
Python basics
Python basicsPython basics
Python basics
 
Introduction%20C.pptx
Introduction%20C.pptxIntroduction%20C.pptx
Introduction%20C.pptx
 
Programming with c language practical manual
Programming with c language practical manualProgramming with c language practical manual
Programming with c language practical manual
 
C programming
C programmingC programming
C programming
 

Mais de Ahmed Gamal

Mais de Ahmed Gamal (20)

Graduation book - BFRP
Graduation book - BFRPGraduation book - BFRP
Graduation book - BFRP
 
hti traininig 2018
hti traininig 2018hti traininig 2018
hti traininig 2018
 
Resource management
Resource managementResource management
Resource management
 
Pert2 management
Pert2 managementPert2 management
Pert2 management
 
Pert management
Pert management Pert management
Pert management
 
Lob management
Lob managementLob management
Lob management
 
Lec 2 construction management
Lec 2 construction managementLec 2 construction management
Lec 2 construction management
 
Earned value management
Earned value managementEarned value management
Earned value management
 
Crash management
Crash managementCrash management
Crash management
 
Cm ch4 scheduling
Cm ch4 schedulingCm ch4 scheduling
Cm ch4 scheduling
 
Cash flow
Cash flowCash flow
Cash flow
 
1- construction management
1-  construction management1-  construction management
1- construction management
 
تدريب 2 التجمع الخامس و نادي مدينتي
تدريب 2 التجمع الخامس و نادي مدينتيتدريب 2 التجمع الخامس و نادي مدينتي
تدريب 2 التجمع الخامس و نادي مدينتي
 
01 introduction and layout of steel (1)
01 introduction and layout of steel (1)01 introduction and layout of steel (1)
01 introduction and layout of steel (1)
 
الامن الصناعي
الامن الصناعيالامن الصناعي
الامن الصناعي
 
7 fatigue
7  fatigue7  fatigue
7 fatigue
 
5 hardness
5  hardness5  hardness
5 hardness
 
4 static shear
4  static shear4  static shear
4 static shear
 
3 bending test
3  bending test3  bending test
3 bending test
 
2 compression
2  compression2  compression
2 compression
 

Último

result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
Tonystark477637
 

Último (20)

Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Glass Ceramics: Processing and Properties
Glass Ceramics: Processing and PropertiesGlass Ceramics: Processing and Properties
Glass Ceramics: Processing and Properties
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Pargaon  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Pargaon 6297143586 Call Hot Indian Gi...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 

programming fortran 77 Slide01

  • 1. CIVIL HTI Fortran 77 Series Lectures Dr. A.M.K. Shaltout 2016
  • 2.
  • 3. Variables,Types and Declarations Variable Names Variable names in Fortran consist of any letters from a-z or digits 0-9 Fortran 77 does not distinguish between upper and lower case Types and declarations The most common declarations are: Integer characters: I, J, K, L, M, N integer list of variables real list of variables Examples: VOL TEMP A2 COLUMN IBM370
  • 4.
  • 5.
  • 6. Column position rules : Fortran 77 is not a free-format language, but has a very strict set of rules for how the source code should be formatted. The most important rules are the column position rules:  Col. 1 : Blank, or a "c" or "*" for comments  Col. 2-5 : Statement label (optional)  Col. 6 : Continuation of previous line (optional)  Col. 7-72 : Statements
  • 7. Statement Format  FORTRAN 77 requires a fixed format for programs PROGRAM MAIN C COMMENTS ARE ALLOWED IF A “C” IS PLACED IN COLUMN #1 DIMENSION X(10) READ(5,*) (X(I),I=1,10) WRITE(6,1000) X 1000 FORMAT(1X,’THIS IS A VERY LONG LINE OF TEXT TO SHOW HOW TO CONTINUE ’ * ‘THE STATEMENT TO A SECOND LINE’,/,10F12.4) 1-5 Label 6 7-72 Statements 73-80 Optional Line #s Any character: continuation line
  • 8.
  • 9. Flowchart Symbols Basic Oval Parallelogram Rectangle Diamond Hybrid Name Symbol Use in Flowchart Denotes the beginning or end of the program Denotes an input operation Denotes an output operation Denotes a decision (or branch) to be made. The program should continue along one of two routes. (e.g. IF/THEN/ELSE) Denotes a process to be carried out e.g. addition, subtraction, division etc. Flow line Denotes the direction of logic flow in the program
  • 10. Pseudocode & Algorithm  Example 1: Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks.
  • 11. Pseudocode & Algorithm Pseudocode:  Input a set of 4 marks  Calculate their average by summing and dividing by 4  if average is below 50 Print “FAIL” else Print “PASS”
  • 12. Pseudocode & Algorithm  Detailed Algorithm  Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE < 50) then Print “FAIL” else Print “PASS” endif
  • 13. Example PRINT “PASS” Step 1: Input M1,M2,M3,M4 Step 2: GRADE  (M1+M2+M3+M4)/4 Step 3: if (GRADE <50) then Print “FAIL” else Print “PASS” endif START Input M1,M2,M3,M4 GRADE(M1+M2+M3+M4)/4 IS GRADE<5 0 PRINT “FAIL” STOP YN
  • 14. Example 2  Write an algorithm and draw a flowchart to convert the length in feet to centimeter. Pseudocode:  Input the length in feet (Lft)  Calculate the length in cm (Lcm) by multiplying LFT with 30  Print length in cm (LCM)
  • 15. Example 2 Algorithm  Step 1: Input Lft  Step 2: Lcm  Lft x 30  Step 3: Print Lcm START Input Lft Lcm  Lft x 30 Print Lcm STOP Flowchart
  • 16. Example 3 Write an algorithm and draw a flowchart that will read the two sides of a rectangle and calculate its area. Pseudocode • Input the width (W) and Length (L) of a rectangle • Calculate the area (A) by multiplying L with W • Print A
  • 17. Example 3 Algorithm • Step 1: Input W,L • Step 2: A  L x W • Step 3: Print A START Input W, L A  L x W Print A STOP
  • 18. Example 4 • Write an algorithm and draw a flowchart that will calculate the roots of a quadratic equation • Hint: d = sqrt ( ), and the roots are: x1 = (–b + d)/2a and x2 = (–b – d)/2a 2 0ax bx c   2 4b ac
  • 19. Example 4 Pseudocode: • Input the coefficients (a, b, c) of the quadratic equation • Calculate d • Calculate x1 • Calculate x2 • Print x1 and x2
  • 20. Example 4 • Algorithm: • Step 1: Input a, b, c • Step 2: d  sqrt ( ) • Step 3: x1  (–b + d) / (2 x a) • Step 4: x2  (–b – d) / (2 x a) • Step 5: Print x1, x2 START Input a, b, c d  sqrt(b x b – 4 x a x c) Print x1 ,x2 STOP x1 (–b + d) / (2 x a) X2  (–b – d) / (2 x a) 4b b a c   
  • 21. Program Organisation  A Fortran program generally consists of a main program (or driver) and possibly several subprograms (or procedures or subroutines). For now we will assume all the statements are in the main program; subprograms will be treated later. The structure of a main program is: program name declarations statements stop end
  • 22.
  • 23.
  • 24. Create a new text file
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36. Numeric Expressions  Very similar to other languages  Arithmetic operators:  Precedence: ** Examples: x = 3 + 4 y = a*b z = radius ** 2 z=x-y z=x/y