Skip to main content

Lessons I have learnt during E3SM development

I have been involved with the E3SM development since I joined PNNL as a postdoc. Over the course of time, I have learnt a lot from the E3SM model. I also found many issues within the model, which reflects lots of similar struggles in the lifespan of software engineering.

Here I list a few major ones that we all dislike but they are around in almost every project we have worked on.

  • Excessive usage of existing framework even it is not meant to
Working in a large project means that you should NOT re-invent the wheels if they are already there. But more often, developers tend to use existing data types and functions even when they were not designed to do so. The reason is simple: it is easier to use existing ones than to create new ones. For example, in E3SM, there was not a data type to transfer data between river and land. Instead, developers use the data type designed for atmosphere and land to do the job. While it is ok to do so, it added unnecessary confusion for future development activities. This type of issue is actually easy to fix. So I created a new type and followed the pattern of other data type. There are lots of details of course but it is the right way to do it.

  • Too many temporary solutions
Developers usually do not want to spend too much time on how to do a task in a sustainable way. Instead, developers tend to choose the approach that simply works for now. Because we all have lots of deadlines.
Some would argue that a working solution is a good solution. While yes and no. For a complex Earth system model, some temporary solutions can cause lots of issues or production delays because they are not sustainable.  You might have to spend way much more time to fix the issues than deal with it from the beginning. 

  • Functions can be extremely fragmented if not well designed
As a complex model, each module within the system is supposed to do only one task. However, modelers are often not sure how to discretize the processes. For example, snow dynamics involve with calculation of energy balance (solar radiation, ET, etc.). But should we update the snow status after each process? What happens when there is no snow after we calculated shortwave radiation?
This challenge is difficult to deal with because it is difficult to have a big picture when you have hundreds of processes going on and no one is an expert on everything. By the model was released, some algorithms were written decades ago and no one really have the resources to keep tracks of everything.

  • Collaboration requires timely updates
With many developers working on different branches, it becomes a challenge to update all the changes with strong dependency. Ideally, development in one branch should not change the behavior of another branch. However, in reality, because of the fragmentation and dependency, we have to spend great effort to make sure they are compatible with each other.

I will keep update this list.


Popular posts from this blog

Spatial datasets operations: mask raster using region of interest

Climate change related studies usually involve spatial datasets extraction from a larger domain.
In this article, I will briefly discuss some potential issues and solutions.

In the most common scenario, we need to extract a raster file using a polygon based shapefile. And I will focus as an example.

In a typical desktop application such as ArcMap or ENVI, this is usually done with a tool called clip or extract using mask or ROI.

Before any analysis can be done, it is the best practice to project all datasets into the same projection.

If you are lucky enough, you may find that the polygon you will use actually matches up with the raster grid perfectly. But it rarely happens unless you created the shapefile using "fishnet" or other approaches.

What if luck is not with you? The algorithm within these tool usually will make the best estimate of the value based on the location. The nearest re-sample, but not limited to, will be used to calculate the value. But what about the outp…

Numerical simulation: ode/pde solver and spin-up

For Earth Science model development, I inevitably have to deal with ODE and PDE equations. I also have come across some discussion related to this topic, i.e.,

In an attempt to answer this question, as well as redefine the problem I am dealing with, I decided to organize some materials to illustrate our current state on this topic.

Models are essentially equations. In Earth Science, these equations are usually ODE or PDE. So I want to discuss this from a mathematical perspective.

Ideally, we want to solve these ODE/PDE with initial condition (IC) and boundary condition (BC) using various numerical methods.

Because of the nature of geology, everything is similar to its neighbors. So we can construct a system of equations which may have multiple equation for each single grid cell. Now we have an array of equation…

Watershed Delineation On A Hexagonal Mesh Grid: Part A

One of our recent publications is "Watershed Delineation On A Hexagonal Mesh Grid" published on Environmental Modeling and Software (link).
Here I want to provide some behind the scene details of this study.

(The figures are high resolution, you might need to zoom in to view.)

First, I'd like to introduce the motivation of this work. Many of us including me have done lots of watershed/catchment hydrology modeling. For example, one of my recent publications is a three-dimensional carbon-water cycle modeling work (link), which uses lots of watershed hydrology algorithms.
In principle, watershed hydrology should be applied to large spatial domain, even global scale. But why no one is doing it?  I will use the popular USDA SWAT model as an example. Why no one is setting up a SWAT model globally? 
There are several reasons we cannot use SWAT at global scale: We cannot produce a global DEM with a desired map projection. SWAT model relies on stream network, which depends on DEM.…