Naval Seaman in formation when entering/leaving port?

Every time I see pictures of navy ships entering or leaving ports, the crew is standing along the edge of the deck, spaced out, at parade rest. Is there some kind of navy tradition that they do this? Or are they just doing it for the cameras.

Manning the Rails
This custom evolved from the centuries-old practice of “manning the yards.” Men aboard sailing ships stood evenly spaced on all the yards and gave three cheers to honor a distinguished person.
Now, men and women are stationed along the rails of a ship when honors are rendered to the President, the heads of foreign states, or members of reigning royal families. Men and women so stationed do not salute. Navy ships will often man the rails when entering a port or returning to the ship’s home port at the end of a deployment.

Here is a picture of Manning the Yards:

Let me know if you’d like a really good picture of the crew of the Buque Guayas manning the rails on their way out of Monterey, California last summer. There’s no worry about me violating the copyright as I took the picture myself with my handy digital camera. The crew is in the rigging along the masts. The Guayas is Ecuador’s naval training ship, a tall sailing ship.

Actually, if you’d like, I can send you the whole slideshow.