We describe the physical model, numerical algorithms, and software structure of a model consisting of the Weather Research and Forecasting (WRF) model, coupled with the fire-spread model (SFIRE) module. In every time step, the fire model inputs the surface wind, which drives the fire, and outputs the heat flux from the fire into the atmosphere, which in turn influences the atmosphere. SFIRE is implemented by the level set method, which allows a submesh representation of the burning region and a flexible implementation of various kinds of ignition. The coupled model is capable of running on a cluster faster than real time even with fine resolution in dekameters. It is available as a part of the Open Wildland Fire Modeling (OpenWFM) environment at <a href="http://openwfm.org" target="_blank">http://openwfm.org</a>, which contains also utilities for visualization, diagnostics, and data processing, including an extended version of the WRF Preprocessing System (WPS). The SFIRE code with a subset of the features is distributed with WRF 3.3 as WRF-Fire.