Creating Shareable Models By: Eric Hutton CSDMS - Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There Be.

Slides:



Advertisements
Similar presentations
Chapter 11 Introduction to Programming in C
Advertisements

CS 11 C track: lecture 7 Last week: structs, typedef, linked lists This week: hash tables more on the C preprocessor extern const.
P5, M1, D1.
CS0007: Introduction to Computer Programming Console Output, Variables, Literals, and Introduction to Type.
The Web Warrior Guide to Web Design Technologies
R Mohammed Wahaj. What is R R is a programming language which is geared towards using a statistical approach and graphics Statisticians and data miners.
C Programming - Lecture 7 This lecture we will learn: –How to write documentation. Internal docs. External docs. User docs. (But not much about this).
CIS 101: Computer Programming and Problem Solving Lecture 8 Usman Roshan Department of Computer Science NJIT.
10-Jun-15 Fibonacci Numbers A simple example of program design.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Contributing source code to CSDMS Albert Kettner.
Apache Axis: A Set of Java Tools for SOAP Web Services.
Creating Shareable Models By: Eric Hutton CSDMS is the Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There.
CS 240: Data Structures Tuesday, June 5 th Programming Semantics, Software Life Cycle.
Software Metrics Testing MINIX 3. Introduction What is Metrics Analysis? Metrics Analysis is a field of Static Analysis. Show us structural attributes.
Guide To UNIX Using Linux Third Edition
Programming Part 1 Armond R. Smith Zhenying Wu. Overview of this Class ● Transition from FTC -> FRC ● Using Your Resources ● Java Keywords o Data Types.
Language Issues Misunderstimated? Sublimable? Hopefuller? "I know how hard it is for you to put food on your family.” "I know the human being and fish.
Doxygen and Javadoc By Derzsy Noemi.
Generics, Proxy, and The Compile Time Type Checking Debate You are either with us or against us. Please snarf the code for today’s class.
From C++ to C#. Web programming The course is on web programming using ASP.Net and C# The course is on web programming using ASP.Net and C# ASP.Net is.
Struts 2.0 an Overview ( )
1 Introduction to Tool chains. 2 Tool chain for the Sitara Family (but it is true for other ARM based devices as well) A tool chain is a collection of.
Arc: Programming Options Dr Andy Evans. Programming ArcGIS ArcGIS: Most popular commercial GIS. Out of the box functionality good, but occasionally: You.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Hello AP Computer Science!. What are some of the things that you have used computers for?
Writing your own Madagascar applications Sergey Fomel University of Texas at Austin August 30, 2006 Vancouver, BC.
Enabling the ARM Learning in INDIA ARM DEVELOPMENT TOOL SETUP.
Nachos Phase 1 Code -Hints and Comments
Research Code Andrew Rosenberg with RA Manual: Notes on Writing Code by Matthew Gentzkow and Jesse Shapiro Chicago Booth and
Data Structures Week 5 Further Data Structures The story so far  We understand the notion of an abstract data type.  Saw some fundamental operations.
Lecture 61 CS110 Lecture 6 Thursday, February 12, 2004 Announcements –hw2 due today Agenda –questions –testing –modeling text files –declarations (classes,
Chapter 3.5 Memory and I/O Systems. 2 Memory Management Memory problems are one of the leading causes of bugs in programs (60-80%) MUCH worse in languages.
Scons Writing Solid Code Overview What is scons? scons Basics Other cools scons stuff Resources.
1 ENERGY 211 / CME 211 Lecture 26 November 19, 2008.
Chris Marks. 1.1 I can describe what types of information are needed. Logo Idea 1 I do not want this logo to be my final logo because it looks rubbish.
EPSII 59:006 Spring Introduction to C More Administrative Details The C Programming Language How a computer processes programs Your first C program.
Chapter 13. Procedural programming vs OOP  Procedural programming focuses on accomplishing tasks (“verbs” are important).  Object-oriented programming.
240-Current Research Easily Extensible Systems, Octave, Input Formats, SOA.
Debugging and Profiling With some help from Software Carpentry resources.
10-Nov-15 Java Object Oriented Programming What is it?
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Documentation. Your documentation must fit the needs of your audience. It’s always better to say one thing that is useful, as opposed to many things that.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Fall 2002CS 150: Intro. to Computing1 Streams and File I/O (That is, Input/Output) OR How you read data from files and write data to files.
More Methods and Arrays Material from Chapters 5 to 7 that we didn’t cover in 1226.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
M1G Introduction to Programming 2 5. Completing the program.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Introduction Selenium IDE is a Firefox extension that allows you to record, edit, and debug tests for HTML Easy record and playback Intelligent field selection.
CS 261 Fall 2009 Dynamic Array Introduction (aka Vector, ArrayList)
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Introduction to Computer Programming - Project 2 Intro to Digital Technology.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Introduction to Exceptions in Java CS201, SW Development Methods.
CSCE 240 – Intro to Software Engineering Lecture 3.
Software Development.
Introduction to Python
Testing and Debugging.
Statement atoms The 'atomic' components of a statement are: delimiters (indents, semicolons, etc.); keywords (built into the language); identifiers (names.
Some Tips for Using Eclipse
Sentinel logic, flags, break Taken from notes by Dr. Neil Moore
Topic 1: Problem Solving
Coding Concepts (Basics)
Type & Typeclass Syntax in function
ENERGY 211 / CME 211 Lecture 27 November 21, 2008.
Contributing source code to CSDMS
Presentation transcript:

Creating Shareable Models By: Eric Hutton CSDMS - Community Surface Dynamics Modeling System (pronounced ˈ s ɪ stəms) Image by Flickr user Let There Be More Light

A model can more easily be used by others if it is readable and has an API Readable Application Programming Interface (API) Someone new to your code should be able to give it a quick read a know what’s going on. The interface will allow someone to use it without worrying about implementation details.

But before all that though, choose a license and a language The GNU General Public License is a good choice. But there are hundreds more. For example, MIT Apache LGPL GPLv3 OSL As far as languages, C is a good choice.

Writing readable code mostly means sticking to a standard The code should speak for itself. It doesn’t just mean adding more comments. Super simple things help: Spaces instead of tabs Useful variable names – especially for global variables and function names Underscores in names – water_density is better than iCantReadThis In the end though, just be consistent.

Makefiles and configure scripts help to make code portable The usual way to compile a software distribution on UNIX is, >./configure > make Creates a make file specific to your system Compiles the code Compile with –Wall compile flag and pay attention to the warnings.

If your code comes with documentation, it is more likely to be used by others There are tools that help with this javadoc (Java) doctest (Python) Doxygen (C, C++, Java, Python, Fortran) These all generate documentation from comments within your code.

Our models are difficult to couple because of implementation details Some reasons that models are difficult to link or share: Languages Time steps Numerical schemes Complexity These are all implementation details. The user shouldn’t have to worry about these details. Design an interface!

A modeling interface hides implementation details from the application developer A coastal evolution model, say Lots of crazy, hard to understand code You

A modeling interface hides implementation details from the application developer A coastal evolution model, sayYou That’s more like it

For our models a useful interface is IRF I is for Initialize R is for Run F is for Finalize int main() { initialize_stuff(); run_until_stop_time(); print_output(); return SUCCESS; }

When designing interfaces it is often easiest to start at the end int main() { CEM_state* s = cem_init(); double *d0, *d1; Setup the model run Run the model for 25 years Get the water depths cem_run_until( s, 25. ); d0 = cem_get_water_depth( s ); Run the model for an additional 75 years and get water depths cem_run_until( s, 100. ); d1 = cem_get_water_depth( s ); Do whatever needs to be done before quitting cem_finalize( s ); return SUCCESS; }

The initialize step sets up a new model run (instance) Things that might be done within the initialize method: Create a new state for the model Allocate memory Set initial conditions Pretty much anything that is done before the time looping begins

The finalize step destroys an existing model run (instance) Things that might be done within the finalize method: Free resources Close files Print final output Pretty much anything that is done after the time looping ends

The run step advances the current state of the model forward in time The run method advances the model from its current state to a future state. run_until( t1 ); run_until( t2 ); t1t2

Oftentimes it is useful to create a data type that holds the current state of the model This is the hard part. Identify all of the variables that need to be remembered to advance the model forward in time. Collect these variables (I generally wrap them in a struct or class). I suppose a common block or a set of global variables would do. This data structure can then be passed to the various methods of the API.

Getters and setters are used to interact with the model’s state The state structure should be opaque to the user – that is implementation stuff Instead, use get and set functions. For instance, get_water_depth( ); set_input_file( “input” ); It is up to the API designer to decide what variables are allowed to be get/set.

Refactoring your code in this way should not change model output …unless you find (and fix) a bug. To make sure that you don’t add bugs when refactoring, Make lots of tests Run these tests often Keep in mind that output may not be byte-for-byte comparable to your benchmarks

In conclusion, Questions? Sharing models is good. Write code that someone else can understand. Pick a standard and stick to it. Create an API. Leave implementation details to the experts. Worry about your own model.