We propose a flexible, software-defined optical switching fabric for cloud data centers, enabling multi-petabit per second network capacities. Our design is based on the cyclic interconnection pattern of arrayed waveguide grating (AWG) devices, whose routing functionality is complemented with recirculation fibers. Unlike traditional optical data center network proposals that rely on two independent fabrics for supporting mice and elephants, our design enables the support of flows of various sizes and requirements using a single AWG-based fabric and yields bandwidth flexibility by integrating wavelength and subwavelength switching granularities. There are two sets of connections paths in our design: dedicated paths between each pair of AWG input and output ports, and shared paths that are set up by multiple recirculation fibers. The recirculation fibers enable the statistical multiplexing of mice. As well, they provide for flexible, on-demand circuit provisioning between input and output ports. Applying Birkhoff-von Neumann matrix decomposition on a residual traffic matrix comprising the demands that cannot be supported through the dedicated paths, we come up with a weighted sum of permutation matrices that get mapped onto the set of available recirculation fibers. The calculated coefficients determine the proportion of a timeframe that the permutation matrices are serviced by distinct fibers. The matrix decomposition requires the combined scheduling of wavelength and time domains so that the AWG can operate as an adaptive flow switching device. Enhancing the functions of our wavelength-routing design with space switching using an optical MEMS switch results in extreme network scales, spanning millions of processing cores.