Run the aspect tool r.slope.aspect.
Try the < min_slope option set to a very low number. The unclassified areas are your flat area. Play with the setting to get it just how you like. You can then use r.reclass to reclass the aspects created so something like -1 and the gap areas as 1. Now multiply this my the original raster and all your areas are positive.
A better, simpler, and FOSS soultion exists for your specifi need. Just use GDALDEM. Your flat area will get -9999 in one simple operation.