The existing real-time iterative closest contour point (ICCP) algorithm uses fixed matching sequence length, which is set according to human experience and cannot obtain the best positioning accuracy on all tracks. This paper proposes a real-time ICCP algorithm with the optimized matching sequence length (OMSL-ICCP) based on the analysis of the shortcomings of the existing real-time ICCP. The optimal matching sequence length of OMSL-ICCP under the current measured gravity anomaly sequence is obtained by the golden section search. The Hausdorff distance is utilized to obtain the search range of the closest contour point, which can effectively shrink the search range of the closest contour point. And the gravitation field algorithm is applied to further improve the positioning accuracy. In simulation tests with different gravity sensor measurement noises, different INS positioning errors and different gravity map resolutions, the difference of positioning performance between the existing real-time ICCP and the OMSL-ICCP is compared. Under the same test conditions, the simulation results show that the positioning accuracy of OMSL-ICCP is higher than the positioning accuracy obtained by the existing real-time ICCP algorithm with the optimal sequence length.INDEX TERMS Gravity aided positioning, real-time ICCP, golden section search, gravitation field algorithm, Hausdorff distance.