Presentation is loading. Please wait.

Presentation is loading. Please wait.

A BIT MORE ON… REPETITIVE EXECUTION MET 50. The “IF” statement In Meteorology, it is common to use the letters I,J,K to denote counters. “I” is the counter.

Similar presentations


Presentation on theme: "A BIT MORE ON… REPETITIVE EXECUTION MET 50. The “IF” statement In Meteorology, it is common to use the letters I,J,K to denote counters. “I” is the counter."— Presentation transcript:

1 A BIT MORE ON… REPETITIVE EXECUTION MET 50

2 The “IF” statement In Meteorology, it is common to use the letters I,J,K to denote counters. “I” is the counter to tell us where we are west  east “J” is the counter to tell us where we are north  south “K” is the counter to tell us where we are up  down 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 2

3 The “IF” statement I=1 could be Greenwich I=2 would be east of Greenwich (say 100 km east) I=3 would be 100 km further east etc. I=IMAX would be west of Greenwich (say 100 km west) J=1 could be the south pole J=2 would be north of the south pole (say 100 km north) J=3 would be 100 km further north etc. J=JMAX would be the north pole K=1 could be the ground K=2 would be above that (say 1 km above) K=3 would be 1 km further up etc. K=KMAX could be the top of atmosphere 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 3

4 The “IF” statement And then, you would see loops like this: DO I = 1, IMAX DO J = 1, JMAX DO K = 1, KMAX (important meteorological calculations) ENDDO 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 4

5 The “IF” statement How does this look in “old” Fortran 77 code??? DO 10 I = 1, IMAX (important meteorological calculations) 10 CONTINUE 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 5

6 The “IF” statement How does this look in “old” Fortran 77 code??? DO 10 I = 1, IMAX (important meteorological calculations) 10 CONTINUE Here, “10” is a statement label – something which has mostly vanished in Fortran 90. A statement label can have any integer value from 1 to 9999. 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 6

7 The “IF” statement Statement label goes in columns 2-5. Why??? Because we used to use cards, and columns 1-6 on the cards were special! 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 7

8 The “IF” statement History lesson…cards… 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 8 Col 1 2345678910…80 C State ment Numb ers State ment Numb ers Continu ation Code 10END CPRINT DO12 12END

9 The “IF” statement DO 10 I = 1, IMAX (important meteorological calculations) 10 CONTINUE So this says: Starting @ 1 st line, and going until I = IMAX (same as Fortran 90) Perform the computations inside the loop. Once I = IMAX, don’t loop back – instead, “continue” on from statement # 10. 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 9

10 The “IF” statement In 3D? DO 10 I = 1, IMAX DO 20 J = 1, JMAX DO 30 K = 1, KMAX (important meteorological calculations) 30 CONTINUE 20 CONTINUE 10 CONTINUE 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 10

11 The “IF” statement Where… DO 10 I = 1, IMAX DO 20 J = 1, JMAX DO 30 K = 1, KMAX (important meteorological calculations) 30 CONTINUE 20 CONTINUE 10 CONTINUE 4) column 7+ etc. etc. 9/29/2011 MET 50, FALL 2011, CHAPTER 4 PART 2 11


Download ppt "A BIT MORE ON… REPETITIVE EXECUTION MET 50. The “IF” statement In Meteorology, it is common to use the letters I,J,K to denote counters. “I” is the counter."

Similar presentations


Ads by Google