  Context. The solar irradiance is known to change on time scales of minutes to
decades, and it is suspected that its substantial fluctua- tions are partially
responsible for climate variations. Aims. We are developing a solar atmosphere
code that allows the physical modeling of the entire solar spectrum composed of
quiet Sun and active regions. This code is a tool for modeling the variability
of the solar irradiance and understanding its influence on Earth. Methods. We
exploit further development of the radiative transfer code COSI that now
incorporates the calculation of molecular lines. We validated COSI under the
conditions of local thermodynamic equilibrium (LTE) against the synthetic
spectra calculated with the ATLAS code. The synthetic solar spectra were also
calculated in non-local thermodynamic equilibrium (NLTE) and compared to the
available measured spectra. In doing so we have defined the main problems of
the modeling, e.g., the lack of opacity in the UV part of the spectrum and the
inconsistency in the calculations of the visible continuum level, and we
describe a solution to these problems. Results. The improved version of COSI
allows us to reach good agreement between the calculated and observed solar
spectra as measured by SOLSTICE and SIM onboard the SORCE satellite and ATLAS 3
mission operated from the Space Shuttle. We find that NLTE effects are very
important for the modeling of the solar spectrum even in the visual part of the
spectrum and for its variability over the entire solar spectrum. In addition to
the strong effect on the UV part of the spectrum, NLTE effects influence the
concentration of the negative ion of hydrogen, which results in a significant
change of the visible continuum level and the irradiance variability.
