S4 : a free electromagnetic solver for layered periodic structures. We describe S4 , a free implementation of the Fourier modal method (FMM), which has also been commonly referred to as rigorous coupled wave analysis (RCWA), for simulating electromagnetic propagation through 3D structures with 2D periodicity. We detail design aspects that allow S 4 to be a flexible platform for these types of simulations. In particular, we highlight the ability to select different FMM formulations, user scripting, and extensibility of program capabilities for eigenmode computations.