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.





Comments

Popular posts from this blog

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.,

https://www.researchgate.net/post/What_does_one_mean_by_Model_Spin_Up_Time

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.
https://en.wikipedia.org/wiki/Initial_value_problem
https://en.wikipedia.org/wiki/Boundary_value_problem

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…

A modern way of automate calibration of a hydrologic model

Calibration of hydrologic model can be tedious, that is why we spent great efforts to automate this process. And sometimes we need some tool that is universal, reusable, so that we don't have to re-invent the wheel again and again.

Today I want to introduce a very effective framework to conduct a hydrologic model calibration. I call it framework because you can apply this method to any model and use any of your preferred language in some steps.

Here is the framework:
Let me explain what is going on:
PEST generate new parameter file based on a simple template;PEST call Python interface to start model simulation;Python interface translates parameter file to model input files;Python interface launches SWAT simulation;Python interface extracts results; andPEST analyzes result and updates parameters.
A few highlights here:
This is an example for a SWAT model, and you can change it to any model you are calibrating;I used Python, but you can also use any other language such as C/C++ or eve…

Surface water hydrology modeling: deal with different types of precipitation

In surface water hydrology, precipitation is one of the most important components.
However, within most hydrology models, it is unclear of how precipitation is actually represented.
For example, in a typical water cycle illustration from Wiki, precipitation is described as
Here is the question, what form does precipitation actually take when it falls to land surface? Water can be in either liquid (water, rain), solid (ice, snow) or gas (water vapor) forms. How about precipitation? Surely most of time precipitation is either rain of snow. In some cases, it takes form in hail, etc.
Since the physical proprieties of water and snow are significantly different, it is necessary to distinguish them within surface water hydrology models. In some scenarios, rain and snow may co-exist in a mixed precipitation event. In this case, surface water hydrology models need to deal with both of them. The difficulty is how to manage the two-phase mass and energy balance. A complete comparison of how diffe…