Sound propagation in a range-dependent ocean environment has long been a matter of widespread concern in ocean acoustics. Stepwise coupled modes is one of the main methods to solve range-dependent acoustic propagation problems. Underwater sound propagation satisfies a Helmholtz equation, the solution of which represents the core of computational ocean acoustics. Due to its high accuracy in solving differential equations, the spectral method has been introduced into computational ocean acoustics in recent years and has achieved remarkable results. However, the existing underwater acoustic propagation algorithms based on the spectral method can calculate only range-independent ocean acoustic waveguides, which excludes applications in more general range-dependent environments. In this paper, a complete and efficient algorithm is designed using an improved global matrix of coupled modes to solve the range dependence of the ocean environment and using the Chebyshev-Tau spectral method to precisely solve the eigenmodes in a stepped range-independent stair. Based on this algorithm, a complete and efficient numerical program is developed, and the numerical simulation results verify that this algorithm is extremely computationally fast and accurate for various range dependence and seabed environments.