The scene is straight from an Alistair Maclean novel. Ships ride at anchor in bomb-proof caverns blasted from sheer rock behind cliff walls, exits protected by cantilevered rocks. Coastal artillery guns poke long barrels from emplacements also deep in rock. . . .
Reserves of imported oil (Sweden has none of its own and relies on oil for 70 percent of its energy) lie in underground tunnels below groundwater level. When needed, the oil is extracted by pumping in water. . . .
Bulldozers push precious salt into white mini-mountains (Sweden has to import salt as well as oil) and workmen convert the mounds to war reserves by covering them with roofs that slope to the ground on all sides. Chemicals, metals, and other raw materials worth $1 billion, as well as ammunition and equipment, are stored in secret dumps all over the country. . . .
Every male between ages 18 and 47 must serve up to 15 months in the military, with five refresher courses. And the Navy has new torpedoes and is buying updated sonar gear in an urgent program to boost its ability to track, hunt and hit intruding submarines. . . .
These are just some of the ways that Sweden, the strong man of Scandinavia, is trying to boost its own defenses.
Sweden wants both to preserve and make credible its diplomatic and military neutrality, and to maintain the delicate balance of forces in Northern Europe. Its strength and determination are under new North Atlantic Treaty Organization (NATO) scrutiny these days following a government report here that Soviet submarines penetrated Swedish waters 40 times last year alone.
''Yes, it was shocking, in a way, that they could do it,'' said Defense Minister Anders Thunborg in an interview in his office here. ''I am asked questions about it all the time. We must try to close our loopholes.''
The task is formidable. Sweden is very large - the size of West Germany, Switzerland, Austria, the Netherlands, and Belgium combined. But instead of 100 million people it contains only 81/2 million. Moreover, its rocky coastline is 1 ,245 miles long - enough, if laid end to end, to stretch from Copenhagen to Florence. And one in four Swedes live in communities containing fewer than 500 people.
But polls show that the vast majority of people here appear determined to keep their defense as credible as possible.
To Western diplomats in Stockholm it is in NATO's interest to see Sweden rise to the Soviet challenge. Sweden may be neutral in policy, but it shares the West's values and outlook, and it stands between the Soviets and NATO bases in Norway and Denmark.
Stockholm already devotes about 8 percent of its budget (3.3 percent of gross domestic product) each year to defense. Mr. Thunborg estimates that its famed high-technology industries make a remarkable 80 percent of all military equipment here at home.
Sweden builds its own jet fighters and reconnaissance aircraft (the Viggen, the Draken, and the new Gripen), its own low-profile, turretless S-class tank, armed vehicles, coastal artillery, antitank missiles, and 12 submarines.
It imports some things - US engines for its fighters and US Sidewinder missiles for the Viggen.
''But,'' Mr. Thunborg said, eight years ago our Viggen interceptor was 45 percent foreign. Now our new Gripen will be only 30-35 percent foreign.''
For manpower, Sweden relies on a core of professional and reserve officers. It has about 43,000 permanently employed military people, trains 50,000 conscripts a year, gives refresher courses to 85,000 more, and claims to be able to mobilize rapidly 800,000 people, many within 72 hours.
The most urgent task now is to show the Soviet Union, which has just shrugged off a strong Swedish protest at last year's submarine intrusions, that it will defend its own territory. This depends on the government's will to act - and it also means reversing years of neglect and improving antisubmarine warfare (ASW) equipment and skills.
After a submarine incident in 1980, the ASW budget was expanded by 150 million Swedish kronor (about $20 million). The new Social Democratic government has already allocated 200 million more kronor, according to Mr. Thunborg. And now a governent commission has recommended an extra 250 million kronor on top of that. The minister indicates that the money will be found, but that a decision on where it is to come from will not be taken until June.
Some Western diplomats here question whether this is enough to buy effective aircraft. Mr. Thunborg stresses that he does not want a plane as large as the US Orion, which is designed to patrol the high seas.
''The Baltic is different,'' he said. ''It is rocky, which means sonar equipment produces many echoes. It is shallower, and it contains less salt. That also affects sonar equipment.''
He wants smaller aircraft than the Orion, and more helicopters. ''We have had only seven (helicopters) for ASW work,'' he says, ''but soon we will have 10, and eventually, 14.''
Until now, Swedish helicopters and mine fields have been designed for war and not for forcing submarines to surface in peacetime. But new torpedoes have been designed and are now coming into service. Prime Minister Olof Palme said in an interview it was essential that Sweden be ready to use them to defend its neutrality, and he indicated that he would not hesitate to give an order to sink a submarine if necessary.
The Navy relies on fast, light patrol boats as well as helicopters and sophisticated 120-mm coastal artillery guns. Army and Air Force each receive about 35 percent of the defense budget, and the Navy only about 15 percent. Mr. Thunborg does not see the proportions changing despite the Soviet threat.
The proposed Swedish defense budget for 1983-84 is 22,075 million kronor or about $3.0 billion, an 8 percent rise from the year before.