Harry Styles will have to live like a World War II soldier to prepare for his first film role.

The One Direction star has been cast in director Christopher Nolan's forthcoming World War II epic Dunkirk.

The film will tell the story of how in 1940 British soldiers were shipped across the English Channel in a mass evacuation which saved them from being captured by Nazi troops.

In preparation for the role, the 22-year-old former boyband star will reportedly live on a ship without running water to experience the conditions World War II soldiers faced.

“Harry is used to living the life of luxury so this will be a very interesting experience," a source tells British newspaper The Sun. “He knows this boot camp at sea is a big part of the job and is keen to get stuck in. But this will be tough and producers are trying to make life on board as realistic as possible.”

The Steal My Girl singer will reportedly spend several days living with his co-stars Tom Hardy, Mark Rylance and Kenneth Branagh on the ship, which will be moored in a secret location of the South coast of England.

While living on the vessel the actors will have to live off the rations allotted to a soldier in 1940 and will be cut off from modern technology.

Harry's role in the movie, which was confirmed last month (Mar16), will likely see him have to cut his famous locks to mirror the authentic look of serviceman from the period.

By starting his acting career with a part in a war film, Harry is following in the footsteps of Beatles star John Lennon, whose first role in a non-Beatles film was in the 1967 military comedy How I Won The War.