  We propose an Adaptive Perfectly Matched Layer (APML) to be used in
diffraction grating modeling. With a properly tailored co-ordinate stretching
depending both on the incident field and on grating parameters, the APML may
efficiently absorb diffracted orders near grazing angles (the so-called Wood's
anomalies). The new design is implemented in a finite element method (FEM)
scheme and applied on a numerical example of a dielectric slit grating. Its
performances are compared with classical PML with constant stretching
coefficient.
