Cooperative control of multiple mobile robots is an attractive and challenging problem which has drawn considerable attention in the recent past. This paper introduces a scalable decentralized control algorithm to navigate a group of mobile robots (swarm) into a predefined shape in 2D space. The proposed architecture uses artificial forces to control mobile agents into the shape and spread them inside the shape while avoiding intermember collisions. The theoretical analysis of the swarm behavior describes the motion of the complete swarm and individual members in relevant situations. We use computer simulated case studies to verify the theoretical assertions and to demonstrate the robustness of the swarm under external disturbances such as death of agents, change of shape etc. Also the performance of the proposed distributed swarm control architecture was investigated in the presence of realistic implementation issues such as localization errors, communication range limitations, boundedness of forces etc.