A numerical hydrodynamic model of the formation and evolution of fogs and stratus clouds is developed. The model is based on the equations of influx (budget) of heat, water vapor, and water content of fog. Equations for the wind velocity and the turbulence coefficient are derived within the theory of similarity. The continuity equation is involved to find the altitude dependence of the vertical velocity. Advective inflows of heat and humidity are written with the allowance for actual data, according to which they are proportional to hyperbolic tangent of the horizontal distance. As a boundary conditions near the Earth's surface, more physically justified equations of heat and humidity balance in the roughness layer are used. Fog parameters characterizing the role of various factors in fog formation and evolution are calculated.