After the battle of the Pellenor Fields in The Lord of the Rings: The Return of the King, Pippin searched for Merry on the battlefield. The last time they spoke, Merry was still in Rohan. How, aside from divine intuition, did Pippin know that Merry was with the army? Is there anything in the movies or the book that would explain this? Éowyn, the only person who knew that Merry wasn't left at Dwimorberg, was badly injured.
In the book, they meet inside the gates of the City. Pippin says that Gandalf send him to look for Merry. From beginning of the chapter "The Houses of Healing":