  A high-precision numerical sound field is the basis of underwater target
detection, positioning and communication. A line source in a plane is a common
type of sound source in computational ocean acoustics. The exciting waveguide
in a range-dependent ocean environment is often structurally complicated;
however, traditional algorithms often assume that the waveguide has a simple
seabed boundary and that the line source is located at a horizontal range of 0
m, although this ideal situation is rarely encountered in the actual ocean. In
this paper, a novel algorithm is designed that can solve for the sound field
excited by a line source at any position in a range-dependent ocean
environment. The proposed algorithm uses the classic stepwise approximation
approach to address the range dependence of the environment and uses the
Chebyshev--Tau spectral method to solve for the horizontal wavenumbers and
modes of approximately range-independent segments. Once the modal information
of these flat segments has been obtained, a global matrix is constructed to
solve for the coupling coefficients of all segments, and finally, the complete
sound field is synthesized. Numerical experiments using a robust numerical
program developed based on this algorithm verify the correctness and usability
of our novel algorithm and software. Furthermore, a detailed analysis and test
of the computational cost of this algorithm show that it is efficient.
