{"id":1819,"date":"2010-08-11T20:24:23","date_gmt":"2010-08-12T00:24:23","guid":{"rendered":"http:\/\/www.easterbrook.ca\/steve\/?p=1819"},"modified":"2015-02-24T21:22:37","modified_gmt":"2015-02-25T02:22:37","slug":"high-level-architecture-of-earth-system-models","status":"publish","type":"post","link":"https:\/\/www.easterbrook.ca\/steve\/2010\/08\/high-level-architecture-of-earth-system-models\/","title":{"rendered":"High level architecture of earth system models"},"content":{"rendered":"<p>To get myself familiar with the models at each of the climate centers I&#8217;m visiting this summer, I&#8217;ve tried to find high level architectural diagrams of the software structure. Unfortunately, there seem to be very few such diagrams around. Climate scientists tend to think of their models in terms of <a title=\"Take a look at the way the ECHAM5 is introduced in this document, for an example\" href=\"http:\/\/www.mpimet.mpg.de\/fileadmin\/models\/echam\/mpi_report_349.pdf\" target=\"_blank\">a set of equations<\/a>, and differentiate between models on the basis of which particular equations each implements. Hence, their documentation doesn&#8217;t contain the <a title=\"E.g. the various architectural and process views in the 4+1 model (LGT wikipedia)\" href=\"http:\/\/en.wikipedia.org\/wiki\/4%2B1_Architectural_View_Model\" target=\"_blank\">kinds of views<\/a> on the software that a software engineer might expect. It presents the equations, often followed with comments about the numerical algorithms that implement them. This also means they don&#8217;t find automated documentation tools such as <a title=\"Doxygen documentation tool\" href=\"http:\/\/www.stack.nl\/~dimitri\/doxygen\/\" target=\"_blank\">Doxygen<\/a> very helpful, because they don&#8217;t want to describe their models in terms of code structure (the folks at <a title=\"Max-Planck Institute for Meteorology, in Hamburg\" href=\"http:\/\/www.mpimet.mpg.de\/en\/home.html\" target=\"_blank\">MPI-M<\/a> here do use Doxygen, but it doesn&#8217;t give them the <a title=\"Serendipity: Documenting Climate Models\" href=\"http:\/\/www.easterbrook.ca\/steve\/?p=1234\" target=\"_blank\">kind of documentation<\/a> they most want).<\/p>\n<p>But for my benefit, as I&#8217;m a visual thinker, and perhaps to better explain to others what is in these <a title=\"Serendipity: Growth of Code Complexity\" href=\"http:\/\/www.easterbrook.ca\/steve\/?p=694\" target=\"_blank\">huge hunks of code<\/a>, I need diagrams. There are some schematics like this around (taken from <a title=\"The Enigma Project\" href=\"http:\/\/www.mpimet.mpg.de\/en\/wissenschaft\/gefoerderte-projekte\/enigma.html\" target=\"_blank\">an MPI-M project site<\/a>):<\/p>\n<p style=\"text-align: center;\">\n<p><a href=\"http:\/\/www.easterbrook.ca\/steve\/wp-content\/0c5e5ca1d3.jpg\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-4136 size-full aligncenter\" src=\"http:\/\/www.easterbrook.ca\/steve\/wp-content\/0c5e5ca1d3.jpg\" alt=\"0c5e5ca1d3\" width=\"400\" height=\"264\" srcset=\"https:\/\/www.easterbrook.ca\/steve\/wp-content\/0c5e5ca1d3.jpg 400w, https:\/\/www.easterbrook.ca\/steve\/wp-content\/0c5e5ca1d3-300x198.jpg 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><\/p>\n<p>But it&#8217;s not quite what I want. It shows the major components:<\/p>\n<ul>\n<li>ECHAM &#8211; atmosphere dynamics and physics,<\/li>\n<li>HAM &#8211; aerosols,<\/li>\n<li>MESSy &#8211; atmospheric chemistry,<\/li>\n<li>MPI-OM &#8211; ocean dynamics and physics,<\/li>\n<li>HAMOCC &#8211; ocean biogeochemistry,<\/li>\n<li>JSBACH &#8211; land surface processes,<\/li>\n<li>HD &#8211; hydrology,<\/li>\n<li>and the coupler, PRISM,<\/li>\n<\/ul>\n<p>&#8230;but it only shows a few of the connectors, and many of the arrows are unlabeled.\u00a0I need something that more clearly distinguishes the different kinds of connector, and perhaps shows where various subcomponents fit in (in part because I want to think about why particular compositional choices have been made).<\/p>\n<p>The closest I can find to what I need is the Bretherton diagram, produced back in the mid 1980&#8217;s to explain what earth system science is all about:<\/p>\n<div style=\"width: 534px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.geo.uni-bremen.de\/geomod\/staff\/gerrit\/irvine\/art\/bretherton_color.gif\"><img decoding=\"async\" loading=\"lazy\" class=\" \" title=\"The Bretherton Diagram of earth system processes\" src=\"http:\/\/www.geo.uni-bremen.de\/geomod\/staff\/gerrit\/irvine\/art\/bretherton_color.gif\" alt=\"\" width=\"524\" height=\"344\" \/><\/a><p class=\"wp-caption-text\">The Bretherton Diagram of earth system processes (click to see bigger, as this is probably not readable!)<\/p><\/div>\n<p style=\"text-align: left;\">It&#8217;s not a diagram of an earth system model <em>per se<\/em>, but rather of the set of systems that such a model might simulate. There&#8217;s a lot of detail here, but it does clearly show the major systems (orange rectangles &#8211; these roughly correspond to model components) and subsystems (green rectangles), along with data sources and sinks (the brown ovals) and the connectors (pale blue rectangles, representing the data passed between components).<\/p>\n<p style=\"text-align: left;\">The diagram allows me to make a number of points. First, we can distinguish between two types of model:<\/p>\n<ul>\n<li>a Global Climate Model, also known as a General Circulation Model (GCM), or Atmosphere-Ocean coupled model (AO-GCM), which only simulates the physical and dynamic processes in the atmosphere and ocean. Where a GCM does include parts of the other processes, it it typically only to supply appropriate boundary conditions.<\/li>\n<li>an Earth System Model (ESM), which also includes the terrestrial and marine biogeochemical processes, snow and ice dynamics, atmospheric chemistry, aerosols, and so on &#8211; i.e. it\u00a0includes simulations of most of the rest of the diagram.<\/li>\n<\/ul>\n<p>Over the past decade, AO-GCMs have steadily evolved to become ESMs, although there are many intermediate forms around. In the last IPCC assessment, nearly all the models\u00a0used for the assessment runs were\u00a0AO-GCMs. For the next assessment, many of them will be ESMs.<\/p>\n<p>Second, perhaps obviously, the diagram doesn&#8217;t show any infrastructure code. Some of this is substantial &#8211; for example an atmosphere-ocean coupler is a substantial component in its own right, often performing elaborate data transformations, such as re-gridding, interpolation, and synchronization. But this does reflect the way in which scientists often neglect the infrastructure code, because it is not really relevant to the science.<\/p>\n<p>Third, the diagram treats all the connectors in the same way, because, at some level, they are all just data fields, representing physical quantities (mass, energy) that cross subsystem boundaries. However, there&#8217;s a wide range of different ways in which these connectors are implemented &#8211; in some cases binding the components tightly together with complex data sharing and control coupling, and in other cases keeping them very loose. The implementation choices are based on a mix of historical accident, expediency, program performance concerns, and the sheer complexity of the physical boundaries between the actual earth subsystems. For example, within an atmosphere model, the dynamical core (which computes the basic thermodynamics of air flow) is distinct from the radiation code (which computes how visible light, along with other parts of the spectrum, are scattered or absorbed by the various layers of air) and the moist processes (i.e. humidity and clouds). But the complexity of the interactions between these processes is sufficiently high that they are tightly bound together &#8211; it&#8217;s not currently possible to treat any of these parts as swappable components (at least in the current generation of models), although during development, some parts can be run in isolation for unit testing e.g.\u00a0<a title=\"Christiane Jablonowski: testing the dynamical core\" href=\"http:\/\/www-personal.umich.edu\/~cjablono\/project.html#held-suarez\" target=\"_blank\">the dynanamical core is tested in isolation<\/a>, but then most other subcomponents depend on it.<\/p>\n<p>On the other hand, the interface between atmosphere and ocean is relatively simple &#8212; it&#8217;s the ocean surface &#8212; and as this also represents the interface between two distinct scientific disciplines (atmospheric physics and oceanography), atmosphere models and ocean model are always (?) loosely coupled. It&#8217;s common now for the two to operate on different grids (different resolution, or even different <a title=\"Phil Jones (not the one from CRU) has nice 2 page summary of different types of grid \" href=\"http:\/\/esg-pcmdi.llnl.gov\/review-folder\/collaborations_partnerships\/ESGRegridding2pager.pdf\" target=\"_blank\">shape<\/a>), and the translation of the various data to be passed between them is handled by a coupler. Some schematic diagrams do show <a title=\"The MPI-Met PRISM Earth System Modeling Guide\" href=\"http:\/\/prism.dkrz.de\/Workpackages\/WP3i\/Documentations\/prism_rep08.pdf\" target=\"_blank\">how the coupler is connected<\/a>:<\/p>\n<div id=\"attachment_1824\" style=\"width: 508px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.easterbrook.ca\/steve\/wp-content\/Picture-19.png\"><img aria-describedby=\"caption-attachment-1824\" decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-1824\" title=\"Atmosphere-Ocean coupling\" src=\"http:\/\/www.easterbrook.ca\/steve\/wp-content\/Picture-19.png\" alt=\"Atmosphere-Ocean coupling via the OASIS coupler (source: Figure 4.2 in the MPI-Met PRISM Earth System Model Adaptation Guide) \" width=\"498\" height=\"302\" srcset=\"https:\/\/www.easterbrook.ca\/steve\/wp-content\/Picture-19.png 830w, https:\/\/www.easterbrook.ca\/steve\/wp-content\/Picture-19-300x182.png 300w\" sizes=\"(max-width: 498px) 100vw, 498px\" \/><\/a><p id=\"caption-attachment-1824\" class=\"wp-caption-text\">Atmosphere-Ocean coupling via the OASIS coupler (source: Figure 4.2 in the MPI-Met PRISM Earth System Model Adaptation Guide)<\/p><\/div>\n<p>Other interfaces are harder to define than the atmosphere-ocean interface. For example, the atmosphere and the terrestrial processes are harder to decouple: Which parts of the water cycle should be handled by the atmosphere model and which should be handled by the land surface model? Which module should handle evaporation from plants and soil? In some models, such as ECHAM, the land surface is embedded within the atmosphere model, and called as a subroutine at each time step. In part this is historical accident &#8211; the original atmosphere model had no vegetation processes, but used soil heat and moisture parameterization as a boundary condition. The land surface model, JSBACH, was developed by pulling out as much of this code as possible, and developing it into a separate vegetation model, and this is sometimes run as a standalone model by the land surface community. But it still shares some of the atmosphere infrastructure code for data handling, so its not as loosely coupled as the ocean is. By contrast, in <a title=\"CESM, the NCAR community model\" href=\"http:\/\/www.cesm.ucar.edu\/\" target=\"_blank\">CESM<\/a>, the land surface model is a distinct component, interacting with the atmosphere model only via the coupler. This facilitates the switching of different land and\/or atmosphere components into the coupled scheme, and also allows the land surface model to have a different grid.<\/p>\n<p>The interface between the ocean model and the sea ice model is also tricky, not least because the area covered by the ice varies with the seasonal cycle. So if you use a coupler to keep the two components separate, the coupler needs information about which grid points contain ice and which do not at each timestep, and it has to alter its behaviour accordingly. For this reason, the sea ice is often treated as a subroutine of the ocean model, which then avoids having to expose all this information to the coupler. But again we have the same trade-off. Working through the coupler ensures they are self-contained components and can be swapped for other compatible models as needed; but at the cost of increasing the complexity of the coupler interfaces, reducing information hiding, and making future changes harder.<\/p>\n<p>Similar challenges occur for:<\/p>\n<ul>\n<li>the coupling between the atmosphere and the <em>atmospheric chemistry<\/em> (which handles chemical processes as gases and various types of pollution are mixed up by atmospheric dynamics).<\/li>\n<li>the coupling between the ocean and <em>marine biogeochemistry<\/em> (which handles the way ocean life absorbs and emits various chemicals while floating around on ocean currents).<\/li>\n<li>the coupling between the land surface processes and <em>terrestrial hydrology<\/em> (which includes rivers, lakes, wetlands and so on). Oh, and between both of these and the atmosphere, as water moves around so freely. Oh, and the ocean as well, because we have to account for how outflows from rivers enter\u00a0the ocean at coastlines all around the world.<\/li>\n<li>&#8230;and so on, as we account for more and more of the earth&#8217;s system into the models.<\/li>\n<\/ul>\n<p>Overall, it seems that the complexity of the interactions between the various earth system processes is so high that traditional approaches to software modularity don&#8217;t work. Information hiding is hard to do, because these processes are so tightly inter-twined. A full object-oriented approach would be a radical departure from how these models are built currently, with the classes built on the data objects (the pale blue boxes in the Bretherton diagram) rather than the processes (the green boxes). But the computational demands of the processes in the green boxes is so high that the only way to make them efficient is to give them full access to the low level data structures. So any attempt to abstract away these processes from the data objects they operate on will lead to a model that is too inefficient to be useful.<\/p>\n<p>Which brings me back to the question of how to draw pictures of the architecture so that I can compare the coupling and modularity of different models. I&#8217;m thinking the best approach might be to start with the Bretherton diagram, and then overlay it to show how various subsystems are grouped into components, and which connectors are handled by a separate coupler.<\/p>\n<p><em>Postscript: While looking for good diagrams, I came across <\/em><a title=\"Samuel Mann's Computing for Sustainability blog\" href=\"http:\/\/computingforsustainability.wordpress.com\/2009\/03\/15\/visualising-sustainability\/\" target=\"_blank\"><em>this incredible collection of visualizations<\/em><\/a><em> of various aspects of sustainability, some of which are brilliant, while others are just kooky.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>To get myself familiar with the models at each of the climate centers I&#8217;m visiting this summer, I&#8217;ve tried to find high level architectural diagrams of the software structure. Unfortunately, there seem to be very few such diagrams around. Climate scientists tend to think of their models in terms of a set of equations, and [&hellip;]<\/p>\n","protected":false},"author":392,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"aioseo_notices":[],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/posts\/1819"}],"collection":[{"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/users\/392"}],"replies":[{"embeddable":true,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/comments?post=1819"}],"version-history":[{"count":9,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/posts\/1819\/revisions"}],"predecessor-version":[{"id":4138,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/posts\/1819\/revisions\/4138"}],"wp:attachment":[{"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/media?parent=1819"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/categories?post=1819"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.easterbrook.ca\/steve\/wp-json\/wp\/v2\/tags?post=1819"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}