Thermocapillary convection in a rectangular cavity with a top 287free surface has been considered. The top free surface of the cavity is subjected to inhomogeneous heating, which generates a bulk fluid motion. The Navier-Stokes equations and the energy equation have been solved by a finite-difference method with a boundary-fitted curvilinear coordinate system, which is generated numerically and always places the coordinate line coincident with the current boundary surfaces. The solutions that describe the thermocapillary convection and interface shape of the free surface are found iteratively for both fixed heights and fixed angles of the contact between the free surface and the solid side walls. The influence of the capillary, Reynolds, and Prandtt numbers on the flow field, the temperature distribution, and the free-surface deformation is considered. The results for a shallow cavity with small capillary, Reynolds, and Marangoni numbers are in qualitative and quantitative agreement with the previous asymptotic results.