Four-fold rise in sex offenders at Barlinnie jail
The number of sex offenders in Scotland's largest jail, Barlinnie, has almost quadrupled in the past five years.
Across the country, the number of older prisoners convicted of historical sex crimes has also risen.
The prisons inspectorate said it was a challenge the prison service must be prepared to meet.
The Scottish Prison Service (SPS) is now buying in social care services like those provided in the community.
The twin problems were highlighted by David Strang, Chief Inspector of Prisons for Scotland in a report on Barlinnie Prison in Glasgow.
In an otherwise positive report, he identified the increase of the number of sexual offenders as a challenge for management.
"The population of men convicted of sexual offences has more than quadrupled here at Barlinnie, and that provides extra challenges for staff," he said.
Sex offenders require to be segregated from mainstream prisoners, and the jail's E Hall now houses 246 men jailed for sex crimes.
"They are kept separate for activities, for education and for work, and that adds complication for the prison," he said.
Across Scotland, there were 7,416 prisoners on 2 September, with more than 1,100 convicted sex offenders - 15% of the total, the SPS said.
Barlinnie's total of 246 sex offenders is about 20% of its population.
Many have been convicted of historical crimes, dating back decades.
John Farrell is typical. The 73-year-old former head teacher and priest was jailed for five years in August for abusing boys.
His co-accused, Paul Kelly, 64, received a 10-year sentence for his abuse of boys at the former St. Ninian's school in Fife.
The SPS said 12% of its prisoners in Scotland are over 50, with more than 100 older than 65.
Head of communications Tom Fox said this means the SPS is now having to buy in social care services like those provided for elderly people in the community.
This included help with dressing and washing and supporting prisoners during their daily activities.
"We're seeing increasing numbers of people getting sentences for offences committed 30, 40, even 50 years ago," he said.
"These prisoners come with all the psycho-geriatric problems that people of that age group have in the community.
"And we're having to cater for that."
He said while new prisons were being fitted with accessible cells and other facilities, it was difficult to ensure older jails like Barlinnie, which opened in 1882, could cater for elderly or disabled inmates.
But the chief inspector of prisons warned: "Management must ensure that they have the resources required to adapt to the new challenges they face."
The Crown Office (COPFS) said sexual crimes now account for 70% of its work in High Court cases.
And the latest Scottish government figures showed the number of people convicted for sexual crimes continued to rise.
There was an eight per cent increase overall in 2014-15 compared to the previous 12 months - up from 1,057 to 1,145.
The government said higher numbers of sexual offences may be, in part, explained by increased reporting in the wake of high profile cases such as Jimmy Savile and Rolf Harris.