  The upper critical field in MgB2 is investigated in the framework of the
two-gap Ginzburg-Landau theory. A variational solution of linearized
Ginzburg-Landau equations agrees well with the Landau level expansion and
demonstrates that spatial distributions of the gap functions are different in
the two bands and change with temperature. The temperature variation of the
ratio of two gaps is responsible for the upward temperature dependence of
in-plane Hc2 as well as for the deviation of its out-of-plane behavior from the
standard angular dependence. The hexagonal in-plane modulations of Hc2 can
change sign with decreasing temperature.
