AN era of Scottish and military history ends today with the closure of the air-sea rescue centre at seventeenth-century Pitreavie Castle, near Dunfermline.

The castle, a former mansion house, was built about 1638 by Sir Henry Wardlaw. It was acquired by the RAF in 1938 for the peppercorn sum of #12,000 and later also became Maritime Headquarters of the Royal Navy, headed by the Flag Officer Scotland and Northern Ireland.

During the Second World War, Pitreavie Castle played a major role in the war effort including planning the attack on the German battleship Tirpitz during Russian convoy runs.

As headquarters for 18 Group Coastal Command, the castle had responsibility for more than 20 squadrons, diverting aircraft to penetrate marauding enemy planes, ships, and submarines. Prime Minister Winston Churchill visited the headquarters twice to see for himself how the operation was being handled.

This week, however, senior RAF and Royal Navy officials reminisced about other Pitreavie events which touched the world - Piper Alpha, The Braer oil tanker incident, and countless rescues on Scottish mountains and in the seas around our coast - as they prepared to vacate the castle and move to new headquarters.

Mr Craig Lindsay, RAF spokesman in Scotland, said: ``Many important operations have been conducted from Pitreavie Castle over the years, including the raid on the Tirpitz, with which, at that time, 617 Squadron was involved, and, in recent years, involvement in Piper Alpha and the Braer incidents.''

Officially the Royal Navy HQ will now operate from Faslane on the Clyde, and future search and rescue services will be co-ordinated from Kinloss in Morayshire.

Pitreavie, whose history goes back to the days of Oliver Cromwell, will be officially closed up by April. However, it may be on the threshold of a new lease of life.

Waiting in the wings is local company, Fife Enterprise, which hopes to make it the centrepiece for one or more blue chip companies.

It has been actively involved with the Ministry of Defence Lands Procurement Division, with a sale of the site - already agreed in principle - for a major development of what is known as the east corridor.

Essentially, that is a plan for a huge housing and industrial development of land taking in the Pitreavie Castle site, and stretching to the M90 motorway to the east.

Mr Robert MacKenzie, chief executive of Fife Enterprise, is anxious to see a deal concluded over the sale of the castle.

``Our hope is that it can be used as an integral part of a major development in the area. It could be used as a business centre, for either one company, or as mixed use.

``There is a great demand for business space in the area, and we are in negotiation with the Ministry of Defence Land Agency, with hopefully, conclusion of that later this year,'' he said.

But the enormous cellar at Pitreavie Castle, its undergound operations room known as ``the pit'', will not be part of the sale.

It is being closed up, removing any opportunity for it to become a tourist attraction like its counterpart underground bunker at Anstruther in East Fife. The high-security entry, guarded by armed personnel, will be shut off and demolished, and the area landscaped.

A spokeswoman for the Ministry of Defence said: ``A feasibility study was done, but it was felt that limitations of entry and space were a problem.''