Based on the angular spectrum representation and strict modal theory, the propagation of linearly polarized Gaussian beams through a bar relief diffraction grating whose characteristic size is comparable with the wavelength, and the influence of errors of grating structure parameters on the maximum intensity in the relief layer are studied. It is shown that the propagation behavior of beams in each layer is different. The intensity in the relief part is higher than that in the unfilled part. The influence of errors of the grating period on the maximum intensity in the relief layer is dominant. By using the simulated anneal algorithm, system parameters are optimized to control the output beam intensity profile.