FORTRAN Short Course Week 4 Kate Thayer-Calder March 10, 2009.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

CSE 105 Structured Programming Language (C)
879 CISC Parallel Computation High Performance Fortran (HPF) Ibrahim Halil Saruhan Although the [Fortran] group broke new ground …
1 CS101 Introduction to Computing Lecture 17 Algorithms II.
FORTRAN Short Course Week 1 Kate T-C February 17, 2008.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
The Assembly Language Level
Programming Types of Testing.
Programming in Visual Basic
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Debugging Introduction to Computing Science and Programming I.
CSC1016 Coursework Clarification Derek Mortimer March 2010.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
General Computer Science for Engineers CISC 106 Lecture 21 Dr. John Cavazos Computer and Information Sciences 04/10/2009.
MATLAB Extras Week 16 – 5/12/09 Kate Musgrave
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
Lecture 1 The Basics (Review of Familiar Topics).
Complexity (Running Time)
Programming Introduction November 9 Unit 7. What is Programming? Besides being a huge industry? Programming is the process used to write computer programs.
Memory Management April 28, 2000 Instructor: Gary Kimura.
FORTRAN Short Course Week 3 Kate Thayer-Calder February 23, 2009.
1 Joe Meehean. 2 Testing is the process of executing a program with the intent of finding errors. -Glenford Myers.
C++ Crash Course Class 1 What is programming?. What’s this course about? Goal: Be able to design, write and run simple programs in C++ on a UNIX machine.
The Project AH Computing. Functional Requirements  What the product must do!  Examples attractive welcome screen all options available as clickable.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
FORTRAN Short Course Week 4 Kate Thayer-Calder March 10, 2009.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
General Programming Introduction to Computing Science and Programming I.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 13: An Introduction to C++
Errors And How to Handle Them. GIGO There is a saying in computer science: “Garbage in, garbage out.” Is this true, or is it just an excuse for bad programming?
Creating your first C++ program
Project 1 Due Date: September 25 th Quiz 4 is due September 28 th Quiz 5 is due October2th 1.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
IT253: Computer Organization
1 Intro to Java Week 12 (Slides courtesy of Charatan & Kans, chapter 8)
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Spring 2005, Gülcihan Özdemir Dağ Lecture 7, Page 1 BIL104E: Introduction to Scientific and Engineering Computing, Spring Lecture 7 Outline 7. 1.
Quiz 15 minutes Open note, open book, open computer Finding the answer – working to get it – is what helps you learn I don’t care how you find the answer,
Unix/Fortran Short Course Week 5 Kate T-C September 22, 2009.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
IT253: Computer Organization Lecture 9: Making a Processor: Single-Cycle Processor Design Tonga Institute of Higher Education.
A (VERY) SHORT INTRODUCTION TO MATLAB J.A. MARR George Mason University School of Physics, Astronomy and Computational Sciences.
FORTRAN History. FORTRAN - Interesting Facts n FORTRAN is the oldest Language actively in use today. n FORTRAN is still used for new software development.
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
HOW A COMPUTER PROCESSES DATA. What is hardware? Hardware is the electric, electronic and mechanical equipment that makes up a computer What is software?
JavaScript Functions. CSS Inheritance Which formatting applies? x y z input { display: block; } input.pref { background:red; } If you have a selector.
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
Introduction Chapter 1 1/22/16. Check zyBooks Completion Click on the boxes for each section.
CMPE13Cyrus Bazeghi 1 Chapter 11 Introduction to Programming in C.
Python 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
Computational Methods of Scientific Programming Lecturers Thomas A Herring, Room A, Chris Hill, Room ,
Chad’s C++ Tutorial Demo Outline. 1. What is C++? C++ is an object-oriented programming (OOP) language that is viewed by many as the best language for.
Chapter 7 Continued Arrays & Strings. Arrays of Structures Arrays can contain structures as well as simple data types. Let’s look at an example of this,
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
CSE 341 Section 1 (9/28) With thanks to Dan Grossman, et. al. from previous versions of these slides.
Software Testing Techniques
Primitive Data, Variables, Loops (Maybe)
UNIT-4 BLACKBOX AND WHITEBOX TESTING
John D. McGregor Session 9 Testing Vocabulary
CSE341: Programming Languages Section 1
Chapter 11 Introduction to Programming in C
Chapter 11 Introduction to Programming in C
Coding Concepts (Basics)
Bryan Burlingame 6 March 2019
Arrays.
Class code for pythonroom.com cchsp2cs
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

FORTRAN Short Course Week 4 Kate Thayer-Calder March 10, 2009

Any Questions?

Topics for this week IEEE Missing data Histograms Compiler Options Reading NetCDF data Zonal averages Averages and contour plots Another simple climate model Debugging strategies

IEEE (Eye-Triple-Eee) Institute of Electrical and Electronics Engineers Most members of any technical professional organization in the world. IEEE produces standards for almost everything computer related, and keeps them updated. Today, most IEEE standards have generally been adopted. IEEE 754 is the most widely-used standard for floating- point computation, and is followed by many hardware (CPU and FPU) and software implementations

INF and NaN INF is defined in the standard as the value given to any Real that is outside the limits of the type. Fortran (and IEEE) has +INF and -INF NaN (Not a Number) produced as the result of an improper floating point calculation. NaN is not equal to either INF. In fact, in the IEEE standard, NaN is not even equal to itself. INF or NaN are occasionally used as placeholders for missing data.

Missing Data Any observational dataset is going to have holes. If missing data is not given as an “outside the bounds” value (-9999 or ) it is often replaced with INF or NaN. Most Fortran implementations will read INF or NaN in as a Real value (it is a real Real), we need to check for it before doing calculations, or we’ll get a runtime error.

Histograms As an example of how to do calculations with missing data, we’re going to make a quick histogram. A histogram is a plot of the number of times a value is seen in the given dataset. All lons, lats and times will be binned together equally.

Compiler Flags As far as I can tell, there is no standard for Compiler options. You’ll have to look up the ones supported by your own compiler. I’ll give you some good ones from my (Absoft) Fortran 90/95 compiler. Many will likely be supported by most other compilers. If you want your code to be portable, don’t depend on compiler tricks and flags.

Compiler Flags -c compile without creating the executable -L[path] add a library search path -l[file] add a library file or module -O perform a group of basic optimization that will cause most code to run faster -v Verbose - prints out status info as the code is being compiled -w Supress output of warnings

Compiler Flags -ej causes all do loops to be executed at least once, regardless of iteration controls -Rb generate meta-code to check array boundaries -Rc validate sub-string indexes -Rs check for array conformance -YCSLASH directs the compiler to evaluate c-style escape characters in strings (/n, /t, /r)

NetCDF Data NetCDF is an I/O library that is widely used in the earth sciences. Once the files are installed, you can use their procedures to open and access the files Each files is “self-describing,” all of the data is annotated (dimension, units, range of values, missing data values, etc...) Examples: read_netCDF.f90 with data from NCEP (NCEP.Precip nc)

Zonal Average Example Modelers and Dynamicists like to look at the atmosphere in latitudinal bands. Don’t have to worry about missing data here... Loading in precip data is pretty simple if you know the parameters. When you do a zonal average, first average in time at each point and then average across all longitudes. Could come up with a less memory intensive way to get the same result... PlayWithPrecip.f90

Climatology Map Example Climatologies are straight-forward averages through time, and the result (for precip) is a two-dimensional map. NCEP has a land-mask map that you could use to fill in the land behind the data. How might you do the average if there were missing data? Anomalies are the result of subtracting the time average at each point - anomalies will still have all 3 (or 4) dimensions.

One last “Climate Model” We can time-step our simple model using a do loop. Build the model from smaller pieces to keep it simple and understandable. Abstracting the temp calculations into a separate function lets us use it as a “black box” Write out results at each timestep to the same file OR write out to a new file for each “year”

Debugging Code will rarely do what you expect on the first try (it always does what you told it to do though...) Compiler errors are usually straight-forward Runtime errors are harder File I/O errors Segmentation Fault Bus Error Wrong answer...

Debugging When things are doing what you expect them too... Print statements are the common first stop Simplify your code - do one thing at a time - test each piece seperately Work out the math by hand or in another program (matlab, idl...) Google! - look for documentation, descriptions of error codes, or examples that might work Talk to somebody!

What did we cover this week? IEEE Missing data Histograms Compiler Options Reading NetCDF data Zonal averages Averages and contour plots Another simple climate model Debugging strategies