Blog

ClimaCoupler.jl: A modular, efficient ESM coupler in Julia

By Julia Sloan.

Earth System Models (ESMs) provide valuable insights into the behavior of our planet’s complex interconnected physical systems. CliMA is developing an ESM composed of multiple component models, including atmosphere, ocean, and land. Each of these component models can be run on their own, which is useful for studying each of these domains independently and facilitates testing, calibration, and validation during model development. To gain understanding of the entire global system and predict future climate change, we need to run all of the component models together, including the feedback between them. This is where the coupling component, ClimaCoupler.jl, comes into play; the coupler enables communication and the exchange of water, energy, momentum, and tracers such as carbon between component models. Figure 1 shows the relationship between the coupler and component models.

Figure 1: A simple diagram showing the relationship between component models and the coupler, which exchanges information between them. Component models can easily be added, removed, or replaced with ClimaCoupler’s modular structure.

The Role of a Coupler

The coupler is responsible for exchanging many different fluxes between component models, some of which can be seen in Figure 2. To ensure that each of these fluxes is available to the coupler, it is necessary to specify an interface that each component model must comply with. Since the fluxes depend on the states of the respective component models, it is also necessary for the coupler to provide visibility into the states of the component models. For example, heat fluxes and evaporation depend on land/ocean surface temperatures and the wind and temperature stratification in the atmosphere above. The specific functions required to be implemented vary depending on whether the coupling is between the atmosphere and ocean or land. We maintain as simple an interface as possible to facilitate coupling of new component models. All required and optional functions for the component model interfaces are documented in the ClimaCoupler.jl Interfacer module documentation.

 

Figure 2: Examples of some fluxes and other properties that the coupler keeps track of and exchanges between component models (between the atmosphere and ocean in this case). Some of these values, such as precipitation and surface temperature, are calculated within the component models, but others, such as turbulent fluxes, are calculated within the coupler itself because they depend on the states of both component models.

As we solve the complex equations of the planet’s physical systems, it is imperative that we maintain physically consistent results and, in particular, conserve quantities such as energy and water in the exchanges between component models; otherwise, for example, if energy conservation is violated, a climate model will drift to warmer or colder climates. Therefore, as the coupler links together the component models, it also makes sure that we conserve these key features of the overall system. 

In addition to exchanging information between component models and maintaining conservation, ClimaCoupler is responsible for handling the timestepping of each component. Currently, ClimaCoupler only supports sequential coupling, meaning that when the overall system is stepped forward by one timestep, the component models are timestepped one after the other. This is in contrast to concurrent coupling, when each component model is simultaneously run for one timestep. In both cases, fluxes are exchanged after all component models have been timestepped. Implementing concurrent coupling is on our roadmap of features to be added in the coming months.

Benefits of using Julia

Implementation of the coupler in the Julia programming language provides a variety of benefits. When adapting to the coupler’s interface, component models are able to take advantage of Julia’s multiple dispatch by internally adding methods that extend coupler functions without changing the source code of the coupler. This would not be possible in other languages, where it would be required to add these functions to the codebase of ClimaCoupler.jl itself. Additionally, writing the CliMA codebase in Julia allows us to leverage the impressive computational performance of GPUs. For example, running the same coupled simulation on a CPU with 64 processes versus on 4 GPUs, we see a 24x increase in simulated years per day (SYPD). ClimaCoupler.jl has been developed with a clean interface and high performance in mind, and the use of Julia helps us reach these goals.

Next Steps

We are routinely running coupled atmosphere-land simulations with sequential coupling. Extending ClimaCoupler to include concurrent coupling is an immediate need. This will provide performance improvements in simulations, as the models would each perform their internal computation in parallel rather than waiting for each other. In terms of maintaining clarity in the code, we are in the process of extracting parts of ClimaCoupler that aren’t strictly relevant to the task of a coupler into a new package, ClimaUtilities.jl. For example, we currently have file reading and regridding infrastructure in ClimaCoupler that could be used by other parts of the CliMA ecosystem. Another major goal for the coupling work is to couple with CliMA’s ocean model, ClimaOcean.jl. This will allow us to run global simulations with atmosphere, ocean, and land all coupled together, leading to increasingly accurate climate simulations and predictions.