<p>Weather models (or, as they are more commonly called in the field, atmospheric models) are computer programs that read in input data (initial conditions) and solve partial differential equations to produce a future state of the atmosphere. Although @JonEricson provides an overall good but anecdotal summary of what models do, here I describe the exact steps of what it takes for an atmospheric model to produce a forecast. This answer generally applies to ocean circulation and climate models as well. Many people believe that weather forecasters sit in front of a map and brainstorm where the cloud will go. This answer aims to provide an easy to understand but thorough explanation about how atmosphere and ocean prediction models work.</p>

<ol>
<li><p>The evolution of the atmosphere may be described by a system of partial differential equations (PDEs). Most commonly, these are <a href="http://en.wikipedia.org/wiki/Primitive_equations">primitive equations</a>, which consist of momentum equation (solving for velocity $\mathbf{v}$ or momentum $\mathbf{\rho v}$), continuity (or mass conservation equation) and thermal energy equation (solving for temperature $T$ and specific humidity $q$). Continuity equation is necessary for closure with the momentum equations. These equations may be approximated in many ways, yielding a reduced and/or simplified set of equations. Some of these approximations are hydrostatic, Boussinessq, anelastic etc. In the most complete form of the primitive equations for the atmosphere the prognostic state variables are $u$, $v$, $w$, $p$, $T$, $q$. An idealized atmosphere could also be simulated with just momentum and continuity equations (no thermodynamics), shallow water equations or just absolute vorticity equation. For an example of the latter, see the pioneering paper by <a href="http://onlinelibrary.wiley.com/doi/10.1111/j.2153-3490.1950.tb00336.x/abstract">Charney, Fjortoft and von Neumann (1950)</a> who numerically predicted 500 mb vorticity by integrating the absolute vorticity equation in time. Because their model was barotropic it could not produce cyclogenesis. However, they achieved the first successful numerical weather prediction in history and their model ran on the first general-purpose computer, <a href="http://en.wikipedia.org/wiki/Eniac">ENIAC</a>.</p></li>
<li><p>Now take the momentum equation for example:</p>

<p>$$\dfrac{\partial \rho \mathbf{v}}{\partial t} + \nabla (\rho \mathbf{v}^{2}) +2\Omega \times \rho \mathbf{v} = -\nabla p + \nu \nabla^{2}(\rho \mathbf{v}) + \Phi $$</p>

<p>From left to right, we have the time tendency of momentum, advection, Coriolis force, pressure gradient, viscous dissipation, and finally, any external forcing or subgrid tendency. Unfortunately, the advection term $\nabla(\rho\mathbf{v}^{2})$ is non-linear, and it is because of this term that the analytical solution to this equation is not known. This term is also the reason atmosphere and other fluids are chaotic in nature and small errors in $\mathbf{v}$ grow quickly because they multiply in this term. If the equation is linearized, $\nabla(\rho\mathbf{v}^{2})=0$, analytical solutions can be found. For example, Rossby, Kelvin, Poincare waves are all analytical solutions for a certain reduced set of linearized momentum or vorticity equations. It is important to identify that we need to have the non-linear advection term if we hope to produce accurate forecasts. Thus we solve the equations numerically.</p></li>
<li><p>How to solve these PDEs? Processors are not capable of doing derivatives - they know how to <em>add</em> and <em>multiply</em> numbers. All other operations are derived from these two. We need to somehow approximate partial derivatives using basic arithmetic operations. The domain of interest (say, the globe) is discretized on a grid. Each grid cell will have a value for each of the state variables. For example, take the pressure gradient term in x-direction:</p>

<p>$$\nabla_{x}p = \dfrac{\partial p}{\partial x} \approx \dfrac{\Delta p}{\Delta x} = \dfrac{p_{i+1,j}-p_{i-1,j}}{2\Delta x_{i,j}}
$$</p>

<p>where $i,j$ are the grid indices in $x,y$. This example used <a href="http://en.wikipedia.org/wiki/Finite_difference_method">finite differences</a>, centered in space. There are many other methods to discretize partial derivatives, and the ones that are in use in modern models are typically much more sophisticated than this example. If the grid spacing is not uniform, <a href="http://en.wikipedia.org/wiki/Finite-volume_method">finite volume methods</a> must be used if the predicted quantitity is to be conserved. <a href="http://en.wikipedia.org/wiki/Finite_element_method">Finite element methods</a> are more common for computational fluid dynamics problems defined on unstructured meshes in engineering, but can be used for atmosphere and ocean solvers as well. <a href="http://en.wikipedia.org/wiki/Spectral_method">Spectral methods</a> are used in some global models like <a href="http://en.wikipedia.org/wiki/Global_Forecast_System">GFS</a> and <a href="http://en.wikipedia.org/wiki/Integrated_Forecast_System">ECMWF</a>. </p></li>
<li><p>Processes unresolved on the grid scale (term $\Phi$) are implemented in the form of parameterization schemes. Parameterized processes may include turbulence and boundary layer mixing, cumulus convection, cloud microphysics, radiation, soil physics, chemical composition etc. Parameterization schemes are still a hot research topic and they keep improving. There are many different schemes for all of the physical processes listed above. Some work better than the others in different meteorological scenarios.</p></li>
<li><p>Once all the terms in all the equations have been discretized on paper, the discrete equations are written in the form of a computer code. Most atmosphere, ocean circulation, and ocean wave models are written in Fortran. This is mostly for historical reasons - having long history, Fortran had the luxury of having very mature compilers and very optimized linear algebra libraries. Nowadays, with very efficient C, C++ and Fortran compilers available, it is more a matter of preference. However, Fortran code is still most prevalent in atmosphere and ocean modeling, even in recently started projects. Finally, an example code line for the above pressure gradient term would look like this:</p>

<pre><code>dpdx(i,j,k) = 0.5*(p(i+1,j,k)-p(i-1,j,k))/dx(i,j)
</code></pre>

<p>The whole code is compiled into machine language that is then loaded on the processor(s). The model program is typically not user friendly with a fancy graphical interface - it is most commonly run from dumb terminals on high-performance multiprocessor clusters. </p></li>
<li><p>Once started, the program discretely steps through time into the future. The calculated values for state variables at every grid point are stored in an output file, typically every hour (simulation time). The output files can then be read by visualization and graphics software to produce pretty images of model forecast. These are then used as guidance to forecasters to provide a meaningful and reasonable forecast.</p></li>
</ol>

CC BY-SA 3.0
2015-04-25T21:56:04.977Z
I like this answer so much! It's concise but also complete.
sunt05
CC BY-SA 3.0
2014-05-01T03:56:25.257Z
2015-03-08T19:13:38.217Z
2015-03-08T19:13:38.217Z
milancurcic
<p>This is not a complete answer.  One aspect of weather models consists of <em>Data assimilation</em> or <em>4D-var</em>.</p>

<p>I agree that they are amazing, and the question <em>how do they work</em> is too broad to be answered.  So I recommend you read up on <a href="https://en.wikipedia.org/wiki/Data_assimilation" rel="noreferrer">data assimilation</a> and in particular <a href="http://old.ecmwf.int/newsevents/training/rcourse_notes/DATA_ASSIMILATION/ASSIM_CONCEPTS/Assim_concepts11.html" rel="noreferrer">4D-Var</a>.  Concepts are <em>somewhat</em> similar in inverse theory, but of much higher dimensionality.  In a tiny nutshell:</p>

<ul>
<li>At each time step and grid point, the model has a <em>background</em> consisting of the latest information it has on the entire atmosphere (and ocean!).  This is a huge quantity of information.</li>
<li>Then, every six hours or so, it feeds in a big chunk of information from measurements.  It uses a Bayesian method (see the 4D-Var link above) to combine the background and the measurements to make a <em>new</em> estimate of the state of the atmosphere.</li>
<li>Measurements are, naturally, only available for the present and past.  The rest is basically extrapolation.  But to get a good estimate, the model run starts at some time in the past; so the first part of the forecast is actually for the past or present (they don't show you that one in the models ;-).  </li>
</ul>

<p>Can't go into detail, but it's true, they are amazing!</p>

CC BY-SA 3.0
2014-04-15T21:11:18.943Z
2015-03-08T17:26:59.910Z
2015-03-08T17:26:59.910Z
gerrit
<p>Weather models and forecasts are governed by systems of <a href="http://en.wikipedia.org/wiki/Differential_equation">differential equations</a>. One starts with the current levels or values of causal variables: temperature, humidity, atmospheric pressure etc. One also has to factor in the "derivatives," or rates of change of these variables. Hence the need for differential equations, which incorporate both variables and their derivatives to explain various "wave" phenomena such as heat, light, and sound, etc.</p>

<p>Even with the current large body of raw knowledge over large parts of the earth, forecasting the weather is still a dicey business, because of the apparent "randomness" of various variables. (Some of them are truly random, others get explained better over time.) By "slicing and dicing" variables, (and benefiting from past experience, weather forecasts have slowly but surely gotten more accurate over time over larger spaces. Increased computational power has also helped. (Extending the length of time for more accurate forecasts is trickier, because there are still too many moving parts.) For now, it seems that the tools that we have are a "drop in the bucket" compared to the size of the earth and universe (some weather patterns may be caused by things happening in interplanetary space), so it is truly amazing that we can often come up with weather forecasts that are more or less accurate. </p>

CC BY-SA 3.0
2014-04-16T12:57:07.497Z
2014-04-16T12:57:07.497Z
Tom Au
<p>All numerical atmospheric models are built around calculations derived from <a href="http://en.wikipedia.org/wiki/Primitive_equations">primitive equations</a> that describe atmospheric flow. Vilhelm Bjerknes discovered the relationships and thereby became the father of numerical weather prediction. Conceptually, the equations can be thought of as describing how a parcel of air would move in relationship to its surroundings. For instance, we learn at a young age that hot air rises. The <a href="http://en.wikipedia.org/wiki/Hydrostatic_pressure#Hydrostatic_pressure">hydrostatic</a> vertical momentum equation explains why <em>and</em> quantifies under what condictions hot air would stop rising. (As the air rises it expands and cools until it reaches hydrostatic equilibrium.) The other equations consider other types of motion and heat transfer.</p>

<p>Unfortunately, the equations are nonlinear, which means that you can't simply plug in a few numbers and get useful results. Instead, weather models are simulations which divide the atmosphere into three-dimensional grids and calculate how matter and energy will flow from one cube of space into another during discrete time increments. Actual atmospheric flow is continuous, not discrete, so by necessity the models are approximations. Different models make different approximations appropriate to their specific purpose.</p>

<p>Numerical models have been improving over time for several reasons:</p>

<ol>
<li>More and better input data,</li>
<li>Tighter grids, and</li>
<li>Better approximations.</li>
</ol>

<p>Increasing computational power has allowed models to use smaller grid boxes. However, the number of computations increases exponentially with the number of boxes and the process suffers <a href="http://en.wikipedia.org/wiki/Finite_difference_method#Accuracy_and_order">diminishing returns</a>. On the input end of things, more and better sensors improve the accuracy of the initial conditions of the model. <a href="http://en.wikipedia.org/wiki/Synoptic_scale_meteorology">Synoptic scale</a> and <a href="http://en.wikipedia.org/wiki/Mesoscale_meteorology">mesoscale</a> models take input from <a href="http://en.wikipedia.org/wiki/General_Circulation_Model">General Circulation Models</a>, which helps set reasonable intial conditions. On the output end, <a href="http://en.wikipedia.org/wiki/Model_output_statistics">Model Output Statistics</a> do a remarkable job of estimating local weather by comparing the current model state with historical data of times when the model showed similar results.  Finally, <a href="http://en.wikipedia.org/wiki/Ensemble_forecasting">ensemble models</a> take the output of several models as input and produce a range of possibly outcomes.</p>

CC BY-SA 3.0
2014-04-16T00:54:44.930Z
You might also mention in your list of improvement reasons: better parameterization schemes for microphysics, radiation, land surface interaction, etc; tighter grids allowing explicit convection rather than parameterized convection; data assimilation.
casey
CC BY-SA 3.0
2014-04-16T01:09:22.657Z
@casey: I should perhaps mention that my firsthand knowledge of forecast models is over 15 (and closer to 20) years old. If you'd be willing to suggest an edit, I'd be happy to approve it. :-)
Jon Ericson
CC BY-SA 3.0
2014-04-15T22:30:36.593Z
2014-04-15T22:37:06.100Z
2014-04-15T22:37:06.100Z
Jon Ericson
<p>We use different weather models all the time, such as the <a href="http://en.wikipedia.org/wiki/Integrated_Forecast_System">ECMWF</a> and the <a href="http://en.wikipedia.org/wiki/Global_Forecast_System">GFS</a>. These models are simply <em>amazing</em> to me.</p>

<p>How do these models work? I know they have to take in various data points - what are these, and how does the model use it? Also, how do they come up with a forecast or a map of what will happen in the future?</p>

<meteorology><models><weather-forecasting><nwp>
How do weather models work?
hichris123
# How do weather models work?

(Asked by: username_0 on 2014-04-15)

We use different weather models all the time, such as the [ECMWF](http://en.wikipedia.org/wiki/Integrated_Forecast_System) and the [GFS](http://en.wikipedia.org/wiki/Global_Forecast_System). These models are simply *amazing* to me.

How do these models work? I know they have to take in various data points - what are these, and how does the model use it? Also, how do they come up with a forecast or a map of what will happen in the future?

**Tags:** meteorology, models, weather-forecasting, nwp


---

## 4 answers

### Answer by username_5 on 2014-04-15. Score: 30 | Accepted answer

All numerical atmospheric models are built around calculations derived from [primitive equations](http://en.wikipedia.org/wiki/Primitive_equations) that describe atmospheric flow. Vilhelm Bjerknes discovered the relationships and thereby became the father of numerical weather prediction. Conceptually, the equations can be thought of as describing how a parcel of air would move in relationship to its surroundings. For instance, we learn at a young age that hot air rises. The [hydrostatic](http://en.wikipedia.org/wiki/Hydrostatic_pressure#Hydrostatic_pressure) vertical momentum equation explains why *and* quantifies under what condictions hot air would stop rising. (As the air rises it expands and cools until it reaches hydrostatic equilibrium.) The other equations consider other types of motion and heat transfer.

Unfortunately, the equations are nonlinear, which means that you can't simply plug in a few numbers and get useful results. Instead, weather models are simulations which divide the atmosphere into three-dimensional grids and calculate how matter and energy will flow from one cube of space into another during discrete time increments. Actual atmospheric flow is continuous, not discrete, so by necessity the models are approximations. Different models make different approximations appropriate to their specific purpose.

Numerical models have been improving over time for several reasons:

1. More and better input data,
2. Tighter grids, and
3. Better approximations.

Increasing computational power has allowed models to use smaller grid boxes. However, the number of computations increases exponentially with the number of boxes and the process suffers [diminishing returns](http://en.wikipedia.org/wiki/Finite_difference_method#Accuracy_and_order). On the input end of things, more and better sensors improve the accuracy of the initial conditions of the model. [Synoptic scale](http://en.wikipedia.org/wiki/Synoptic_scale_meteorology) and [mesoscale](http://en.wikipedia.org/wiki/Mesoscale_meteorology) models take input from [General Circulation Models](http://en.wikipedia.org/wiki/General_Circulation_Model), which helps set reasonable intial conditions. On the output end, [Model Output Statistics](http://en.wikipedia.org/wiki/Model_output_statistics) do a remarkable job of estimating local weather by comparing the current model state with historical data of times when the model showed similar results. Finally, [ensemble models](http://en.wikipedia.org/wiki/Ensemble_forecasting) take the output of several models as input and produce a range of possibly outcomes.

> **Comments:**
> **username_6**: You might also mention in your list of improvement reasons: better parameterization schemes for microphysics, radiation, land surface interaction, etc; tighter grids allowing explicit convection rather than parameterized convection; data assimilation.  
> **username_5**: @username_6: I should perhaps mention that my firsthand knowledge of forecast models is over 15 (and closer to 20) years old. If you'd be willing to suggest an edit, I'd be happy to approve it. :-)  

---

### Answer by username_1 on 2014-05-01. Score: 23

Weather models (or, as they are more commonly called in the field, atmospheric models) are computer programs that read in input data (initial conditions) and solve partial differential equations to produce a future state of the atmosphere. Although @username_5 provides an overall good but anecdotal summary of what models do, here I describe the exact steps of what it takes for an atmospheric model to produce a forecast. This answer generally applies to ocean circulation and climate models as well. Many people believe that weather forecasters sit in front of a map and brainstorm where the cloud will go. This answer aims to provide an easy to understand but thorough explanation about how atmosphere and ocean prediction models work.

1. The evolution of the atmosphere may be described by a system of partial differential equations (PDEs). Most commonly, these are [primitive equations](http://en.wikipedia.org/wiki/Primitive_equations), which consist of momentum equation (solving for velocity $\mathbf{v}$ or momentum $\mathbf{\rho v}$), continuity (or mass conservation equation) and thermal energy equation (solving for temperature $T$ and specific humidity $q$). Continuity equation is necessary for closure with the momentum equations. These equations may be approximated in many ways, yielding a reduced and/or simplified set of equations. Some of these approximations are hydrostatic, Boussinessq, anelastic etc. In the most complete form of the primitive equations for the atmosphere the prognostic state variables are $u$, $v$, $w$, $p$, $T$, $q$. An idealized atmosphere could also be simulated with just momentum and continuity equations (no thermodynamics), shallow water equations or just absolute vorticity equation. For an example of the latter, see the pioneering paper by [Charney, Fjortoft and von Neumann (1950)](http://onlinelibrary.wiley.com/doi/10.1111/j.2153-3490.1950.tb00336.x/abstract) who numerically predicted 500 mb vorticity by integrating the absolute vorticity equation in time. Because their model was barotropic it could not produce cyclogenesis. However, they achieved the first successful numerical weather prediction in history and their model ran on the first general-purpose computer, [ENIAC](http://en.wikipedia.org/wiki/Eniac).
2. Now take the momentum equation for example:

   $$\dfrac{\partial \rho \mathbf{v}}{\partial t} + \nabla (\rho \mathbf{v}^{2}) +2\Omega \times \rho \mathbf{v} = -\nabla p + \nu \nabla^{2}(\rho \mathbf{v}) + \Phi $$

   From left to right, we have the time tendency of momentum, advection, Coriolis force, pressure gradient, viscous dissipation, and finally, any external forcing or subgrid tendency. Unfortunately, the advection term $\nabla(\rho\mathbf{v}^{2})$ is non-linear, and it is because of this term that the analytical solution to this equation is not known. This term is also the reason atmosphere and other fluids are chaotic in nature and small errors in $\mathbf{v}$ grow quickly because they multiply in this term. If the equation is linearized, $\nabla(\rho\mathbf{v}^{2})=0$, analytical solutions can be found. For example, Rossby, Kelvin, Poincare waves are all analytical solutions for a certain reduced set of linearized momentum or vorticity equations. It is important to identify that we need to have the non-linear advection term if we hope to produce accurate forecasts. Thus we solve the equations numerically.
3. How to solve these PDEs? Processors are not capable of doing derivatives - they know how to *add* and *multiply* numbers. All other operations are derived from these two. We need to somehow approximate partial derivatives using basic arithmetic operations. The domain of interest (say, the globe) is discretized on a grid. Each grid cell will have a value for each of the state variables. For example, take the pressure gradient term in x-direction:

   $$\nabla\_{x}p = \dfrac{\partial p}{\partial x} \approx \dfrac{\Delta p}{\Delta x} = \dfrac{p\_{i+1,j}-p\_{i-1,j}}{2\Delta x\_{i,j}}
   $$

   where $i,j$ are the grid indices in $x,y$. This example used [finite differences](http://en.wikipedia.org/wiki/Finite_difference_method), centered in space. There are many other methods to discretize partial derivatives, and the ones that are in use in modern models are typically much more sophisticated than this example. If the grid spacing is not uniform, [finite volume methods](http://en.wikipedia.org/wiki/Finite-volume_method) must be used if the predicted quantitity is to be conserved. [Finite element methods](http://en.wikipedia.org/wiki/Finite_element_method) are more common for computational fluid dynamics problems defined on unstructured meshes in engineering, but can be used for atmosphere and ocean solvers as well. [Spectral methods](http://en.wikipedia.org/wiki/Spectral_method) are used in some global models like [GFS](http://en.wikipedia.org/wiki/Global_Forecast_System) and [ECMWF](http://en.wikipedia.org/wiki/Integrated_Forecast_System).
4. Processes unresolved on the grid scale (term $\Phi$) are implemented in the form of parameterization schemes. Parameterized processes may include turbulence and boundary layer mixing, cumulus convection, cloud microphysics, radiation, soil physics, chemical composition etc. Parameterization schemes are still a hot research topic and they keep improving. There are many different schemes for all of the physical processes listed above. Some work better than the others in different meteorological scenarios.
5. Once all the terms in all the equations have been discretized on paper, the discrete equations are written in the form of a computer code. Most atmosphere, ocean circulation, and ocean wave models are written in Fortran. This is mostly for historical reasons - having long history, Fortran had the luxury of having very mature compilers and very optimized linear algebra libraries. Nowadays, with very efficient C, C++ and Fortran compilers available, it is more a matter of preference. However, Fortran code is still most prevalent in atmosphere and ocean modeling, even in recently started projects. Finally, an example code line for the above pressure gradient term would look like this:

   ```
   dpdx(i,j,k) = 0.5*(p(i+1,j,k)-p(i-1,j,k))/dx(i,j)

   ```

   The whole code is compiled into machine language that is then loaded on the processor(s). The model program is typically not user friendly with a fancy graphical interface - it is most commonly run from dumb terminals on high-performance multiprocessor clusters.
6. Once started, the program discretely steps through time into the future. The calculated values for state variables at every grid point are stored in an output file, typically every hour (simulation time). The output files can then be read by visualization and graphics software to produce pretty images of model forecast. These are then used as guidance to forecasters to provide a meaningful and reasonable forecast.

> **Comments:**
> **username_2**: I like this answer so much! It's concise but also complete.  

---

### Answer by username_3 on 2014-04-15. Score: 13

This is not a complete answer. One aspect of weather models consists of *Data assimilation* or *4D-var*.

I agree that they are amazing, and the question *how do they work* is too broad to be answered. So I recommend you read up on [data assimilation](https://en.wikipedia.org/wiki/Data_assimilation) and in particular [4D-Var](http://old.ecmwf.int/newsevents/training/rcourse_notes/DATA_ASSIMILATION/ASSIM_CONCEPTS/Assim_concepts11.html). Concepts are *somewhat* similar in inverse theory, but of much higher dimensionality. In a tiny nutshell:

* At each time step and grid point, the model has a *background* consisting of the latest information it has on the entire atmosphere (and ocean!). This is a huge quantity of information.
* Then, every six hours or so, it feeds in a big chunk of information from measurements. It uses a Bayesian method (see the 4D-Var link above) to combine the background and the measurements to make a *new* estimate of the state of the atmosphere.
* Measurements are, naturally, only available for the present and past. The rest is basically extrapolation. But to get a good estimate, the model run starts at some time in the past; so the first part of the forecast is actually for the past or present (they don't show you that one in the models ;-).

Can't go into detail, but it's true, they are amazing!


---

### Answer by username_4 on 2014-04-16. Score: 9

Weather models and forecasts are governed by systems of [differential equations](http://en.wikipedia.org/wiki/Differential_equation). One starts with the current levels or values of causal variables: temperature, humidity, atmospheric pressure etc. One also has to factor in the "derivatives," or rates of change of these variables. Hence the need for differential equations, which incorporate both variables and their derivatives to explain various "wave" phenomena such as heat, light, and sound, etc.

Even with the current large body of raw knowledge over large parts of the earth, forecasting the weather is still a dicey business, because of the apparent "randomness" of various variables. (Some of them are truly random, others get explained better over time.) By "slicing and dicing" variables, (and benefiting from past experience, weather forecasts have slowly but surely gotten more accurate over time over larger spaces. Increased computational power has also helped. (Extending the length of time for more accurate forecasts is trickier, because there are still too many moving parts.) For now, it seems that the tools that we have are a "drop in the bucket" compared to the size of the earth and universe (some weather patterns may be caused by things happening in interplanetary space), so it is truly amazing that we can often come up with weather forecasts that are more or less accurate.


---

