1 / 11

MET 50

MET 50. A bit more on… Repetitive EXECUTION. 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

sileas
Download Presentation

MET 50

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. MET 50 A bit more on… Repetitive EXECUTION

  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 MET 50, FALL 2011, CHAPTER 4 PART 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 MET 50, FALL 2011, CHAPTER 4 PART 2

  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 ENDDO ENDDO MET 50, FALL 2011, CHAPTER 4 PART 2

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

  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. MET 50, FALL 2011, CHAPTER 4 PART 2

  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! MET 50, FALL 2011, CHAPTER 4 PART 2

  8. The “IF” statement History lesson…cards… MET 50, FALL 2011, CHAPTER 4 PART 2

  9. The “IF” statement DO 10 I = 1, IMAX (important meteorological calculations) 10 CONTINUE So this says: Starting @ 1st 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. MET 50, FALL 2011, CHAPTER 4 PART 2

  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 MET 50, FALL 2011, CHAPTER 4 PART 2

  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 column 7+ etc. etc. MET 50, FALL 2011, CHAPTER 4 PART 2

More Related