- CSF213-L6
- 2.2C Loop Control
- Read Image Example Structure
- Visual Basic Tutorial
- IntroCS Part 5
- CENG 106 Lab6.pdf
- A Summary of C++ Course
- Java Programming.docx
- Intro-to-R-Part-VII
- Utsi Halleffect
- Lec (1) Part (2) Introduction to Micro c Programming
- SEC573_PythonCheatSheet_06272016
- Looping case study
- Writing Control Structures
- Python-Cht3.pdf
- Microsoft Visual C# .NET in 24 Hours
- SardinaCOE112-A2
- C++ basic programs
- Developed by Yatendra Kashyap
- The Ring programming language version 1.3 book - Part 7 of 88
- c Programming
- About Language Keywords.help
- Assignment 5 Sem
- Unix 2
- 08 Oct Essentialofitcsl0102-0201
- Doc 1
- Introduction to FlowCharts
- UNIT I
- ICSE Class 10 Computer Application 2005
- 13mca11-Problem Solving Using c
- Representation of a 2D Line by Straight Line Elements
- GLS.FOR
- REGLS.FOR
- Outline of the Boundary Element Method
- Discretization of the Laplace Integral Operators
- Representation of an Axisymmetric Surface by Conical Panels
- regls_bas
- Boundary Representation in the Boundary Element Method
- GLS_T.FOR
- gls_bas
- Computation of the Discrete Forms of the Laplace Integral Operators
- gls.xls
- Representation of a Surface by Triangular Panels
- Numerical Solution of a General Linear System of Equations.pdf
- The Laplace Integral Operators
- gl8.bas
- gl8tests.bas
- GLT7.FOR
- Polynomial Test Problems for Quadrature Rules on the Standard Triangle
- GL8.FOR
- GL8TESTS.FOR
- glt7tests.bas
- CLUTESTS.FOR
- GLT7TESTS.FOR
- Geometry codes in matlab
- GEOM.xlsm User Guide
- GEOM2D.FOR User Guide
- GEOM3D.FOR User Guide
- glt7.bas
- Approximation of Integrals Over Rectangular Regions

uk

Fortran 77: Loops

If a piece of code needs to be executed repeatedly then a loop structure can be used. In most programming languages, using loops is the means to getting a computer to do any significant work. There is only one defined loop structures in Fortran 77; the DO loop. The DO loop can only be used in cases when the number of loops can be defined on entry to the loop. Alternative loop structures can be created by using a combination of the IF and GOTO statements. The DO Loop The syntax of the DO loop is as follows: DO <label>, <loop control varable>=<initial value>,<final value>,<step size> <statement1> <statement2>

.....

<statementN>

<label> CONTINUE

In this example J takes the values 1,2,3,4,5 and J*J is output for each values of J.

C ********************** C DO LOOP C ********************** PROGRAM DOLOOP INTEGER J DO 10 J=1,5 WRITE(*,*) J*J 10 CONTINUE STOP END

In the above example the number step in J from one execution of the loop to the next is one; this is the default value. We can have steps of alternative size. For example in the next piece of code the step size is 2 (placed after the 1 and the 5). In this code J takes the values 1, 3, 5.

www.computing.me.uk

C ********************** C DO LOOP 2 C ********************** PROGRAM DO2LOOP INTEGER J DO 10 J=1,5,2 WRITE(*,*) J*J 10 CONTINUE STOP END The step size in a loop does not have to be a whole number. In the following example the step size is 0.5. C ********************** C DO LOOP 3 C ********************** PROGRAM DO3LOOP REAL X DO 10 X=1.0,5,0.5 WRITE(*,*) X*X 10 CONTINUE STOP END

The step size in a loop does not have to be positive. In the following example the step size is -1.

C ********************** C DO LOOP 4 C ********************** PROGRAM DO4LOOP INTEGER J DO 10 J=4,2,-1 WRITE(*,*) J*J 10 CONTINUE STOP END

The <initial value>,<final value>, and <step size> may all be variables, but they cannot be changed

inside the loop.

www.computing.me.uk Mock while loop

A while loop continues while a condition is met. Fortran 77 does not have an explicit while loop, but one can be created using the GOTO statement. For example, in the following loop, X is continued to halve while X is greater than 1 and the loop terminates.

C ********************** C WHILE LOOP C ********************** PROGRAM WHLOOP REAL X X=10.0 10 IF (X.GT.1) THEN X=X/2 WRITE(*,*) X GOTO 10 ENDIF STOP END Mock repeat loop

A repeat loop continues until a condition is met. Fortran 77 does not have an explicit repeat loop, but one can be created using the GOTO statement. For example, in the following loop, X is continued to halve until X is no longer greater than 1 and the loop terminates.

C ********************** C REPEAT LOOP C ********************** PROGRAM RELOOP REAL X X=10.0 10 CONTINUE X=X/2 WRITE(*,*) X IF (X.GT.1) GOTO 10 STOP END

Good Practice Tip For readability, always indent the statements inside a loop.

- CSF213-L6Uploaded byNilayan Ahmed
- 2.2C Loop ControlUploaded byRahul Lavhande
- Read Image Example StructureUploaded byelamaran_vlsi
- Visual Basic TutorialUploaded bydnlkaba
- IntroCS Part 5Uploaded byAlfred Stafasani
- CENG 106 Lab6.pdfUploaded byWassen Hejjawi
- A Summary of C++ CourseUploaded byIslam Helmy
- Java Programming.docxUploaded byDominic Albert Santos
- Intro-to-R-Part-VIIUploaded bycaliterra
- Utsi HalleffectUploaded bymhsgh2003
- Lec (1) Part (2) Introduction to Micro c ProgrammingUploaded byKhadiga Abdallah
- SEC573_PythonCheatSheet_06272016Uploaded byeltuerca71
- Looping case studyUploaded byMukesh Kumar Singh
- Writing Control StructuresUploaded byHeriberto Espino
- Python-Cht3.pdfUploaded byShaheer43
- Microsoft Visual C# .NET in 24 HoursUploaded byapi-19669084
- SardinaCOE112-A2Uploaded byKent Johnric Sardina
- C++ basic programsUploaded byMohammad Arshad
- Developed by Yatendra KashyapUploaded bynuvvu_roja
- The Ring programming language version 1.3 book - Part 7 of 88Uploaded byMahmoud Samir Fayed
- c ProgrammingUploaded byRenjith Regi
- About Language Keywords.helpUploaded bySumit Deswal
- Assignment 5 SemUploaded byJomon Johny
- Unix 2Uploaded byChaitanya Diddi
- 08 Oct Essentialofitcsl0102-0201Uploaded byMrityunjay Aryan
- Doc 1Uploaded bySunny Jamwal
- Introduction to FlowChartsUploaded byBINJAD
- UNIT IUploaded byvnirmalacse
- ICSE Class 10 Computer Application 2005Uploaded bysachintrox
- 13mca11-Problem Solving Using cUploaded byKeerthana Sudarshan

- Representation of a 2D Line by Straight Line ElementsUploaded byrodwellhead
- GLS.FORUploaded byrodwellhead
- REGLS.FORUploaded byrodwellhead
- Outline of the Boundary Element MethodUploaded byrodwellhead
- Discretization of the Laplace Integral OperatorsUploaded byrodwellhead
- Representation of an Axisymmetric Surface by Conical PanelsUploaded byrodwellhead
- regls_basUploaded byrodwellhead
- Boundary Representation in the Boundary Element MethodUploaded byrodwellhead
- GLS_T.FORUploaded byrodwellhead
- gls_basUploaded byrodwellhead
- Computation of the Discrete Forms of the Laplace Integral OperatorsUploaded byrodwellhead
- gls.xlsUploaded byrodwellhead
- Representation of a Surface by Triangular PanelsUploaded byrodwellhead
- Numerical Solution of a General Linear System of Equations.pdfUploaded byrodwellhead
- The Laplace Integral OperatorsUploaded byrodwellhead
- gl8.basUploaded byrodwellhead
- gl8tests.basUploaded byrodwellhead
- GLT7.FORUploaded byrodwellhead
- Polynomial Test Problems for Quadrature Rules on the Standard TriangleUploaded byrodwellhead
- GL8.FORUploaded byrodwellhead
- GL8TESTS.FORUploaded byrodwellhead
- glt7tests.basUploaded byrodwellhead
- CLUTESTS.FORUploaded byrodwellhead
- GLT7TESTS.FORUploaded byrodwellhead
- Geometry codes in matlabUploaded byrodwellhead
- GEOM.xlsm User GuideUploaded byrodwellhead
- GEOM2D.FOR User GuideUploaded byrodwellhead
- GEOM3D.FOR User GuideUploaded byrodwellhead
- glt7.basUploaded byrodwellhead
- Approximation of Integrals Over Rectangular RegionsUploaded byrodwellhead