The frequency-domain finite-difference (FDFD) method is an effective tool for implementing frequency-domain seismic modeling, inversion, and migration. However, the computational cost for the FDFD method dealing with large models is prohibitive, limiting its application. As a common strategy to improve the computational efficiency, a nonuniform grid is usually adopted in the time-domain finite-difference method instead of the FDFD method. We have developed a generalized average-derivative optimal scheme (GADOS) that can perform frequency-domain acoustic-wave modeling on continuous nonuniform grids in the vertical and horizontal directions. Before we begin the calculations, we optimize numerous stencils in which the grid spacing ratios are different to obtain a large dictionary composed of many groups of optimal coefficients. We consider the continuous nonuniform grids as a gathering of nonuniform nine-point stencils (i.e., the stencil of the GADOS) and select the proper weighted coefficients for every stencil to ensure that the numerical dispersion is minimal in the global area. All the phase-velocity errors of the GADOS for different grid spacing ratios are less than even if the number of grid points per wavelength is as small as four after the weighted coefficients are optimized by minimizing the numerical dispersion. Compared with the average-derivative optimal scheme (ADOS), simulating seismic waves with the GADOS on nonuniform grids reduce the computational cost with the premise of ensuring sufficient accuracy. Several numerical examples are presented to illustrate the feasibility and efficiency of the GADOS on continuous nonuniform grids.