The algorithm for phase unwrapping from the principal value of the phase gradient is proposed. The efficiency of this algorithm is studied using, as an example, adaptive focusing of an optical wave propagating through the turbulent atmosphere under conditions of strong scintillations of intensity.