The article presents an algorithm for calculating operating modes (both steady-state and non-steady-state) of non-isothermal oil pipelines in complex conditions. The proposed algorithm is used for pipelines with several pumping stations and for individual pipeline sections (both above-ground and underground). Calculations can be carried out in a given temperature range, which increases their accuracy. In addition, the algorithm takes into account changes in the operating mode, the influence of additional pumps on the main pipeline and heat points located along the pipeline. It also allows to determine the internal heat transfer coefficient. This algorithm can be applied to fluids of any rheological model. It has been tested on real main and industrial pipelines. It is supplied together with a software package.