A shallow, shear flow produced by a constant Lorentz force in a closed rectangular domain is studied by means of laboratory experiments and numerical simulations. We consider different horizontal aspect ratios of the container and magnitudes of the electromagnetic forcing. The shear flow consists of two parallel opposing jets along the long side of the rectangular tanks. Two characteristic stages were observed. First, the flow evolution is dominated by the imposed forcing, producing a linear increase in time of the velocity of the jets. During the second stage, the shear flow becomes unstable and a vortex pattern is generated, which depends on the aspect ratio of the tank. We show that these coherent structures are able to survive during long periods of time, even in the presence of the continuous forcing. Additionally, quasi-regular variations in time of global quantities (two-dimensional (2D) energy and enstrophy) was found. An analysis of the quasi-two-dimensional (Q2D) energy equation reveals that these oscillations are the result of a competition between the injection of energy by the forcing at a localized area and the global bottom friction over the whole domain. The capacity of the system to gain and dissipate energy is in contrast with an exact balance between these two effects, usually assumed in many situations. Numerical simulations based on a quasi-two-dimensional model reproduced the main experimental results, confirming that the essential dynamics of the flow is approximately bidimensional. C 2015 AIP Publishing LLC. [http://dx.