We present a new algorithm that enables the analysis of large two-dimensional optical gratings with very small feature sizes using the Fourier modal method (FMM). With the conventional algorithm such structures cannot be solved because of limitations in computer memory and calculation time. By dividing the grating into several smaller subgratings and solving them sequentially, both memory requirement and calculation time can be reduced dramatically. We have calculated a grating with 32 × 32 pixels for a different number of subgratings. We show that the increased performance is directly related to the size of the subgratings. The field-stitched calculations prove to be very accurate and agree well with the predictions from the standard FMM approach. © 2009 Optical Society of America.