Angola is a country living through a nightmare. It is fighting two wars, attempting to repel invasions from the white troops of South Africa and to put down a continuing guerrilla war by black rebels, while its economy collapses.

To defend the country from South Africa's increasingly harsh attacks, Angola needs Soviet and Cuban troops, who have already shed their blood in Angola's name. But to reconstruct its potentially rich economy, it needs the West for investment, which the Marxist government eagerly encourages, and for the trade of its oil and minerals.

The intermittent warfare in southern Angola is turning the region into a scorched wasteland -- Africa's version of war-battered southern Lebanon. Half a million Angolans have been uprooted and made homeless by warfare since 1975, and last month's South African raid added 130,000 refugees to that total, according to estimates of the United Nations Disaster Relief Organization.

Beyond these enormous human costs are equally important political stakes.

Angola has become the battlefield on which the Soviet Union and South Africa, arch foes, have developed surprisingly similar objectives, built around their expectations of gains from a continuation and increase in hostilities.

Moderate Western and African diplomats here fear that U.S. prestige and power in Africa could become hostage to that struggle.

Access to vital minerals is also at stake for the United States, which is Angola's largest trading partner but which refuses to recognize the Marxist government in Luanda because of the presence of about 15,000 Cuban troops and 1,000 Soviet military advisers.

The fate of Angola is of major significance to the development of southern Africa as a whole. It is the only country in the region that does not depend upon South Africa for its economic welfare. Its railways and ports, if fully operative, provide an alternative to dependence on South African routes. The prospects of economic success there would disrupt South Africa's argument that black Africa is dying economically.

During the Carter administration, there was also evidence that Angola might become one of those symbolically important Third World countries that reduce their Soviet connections as Western trade and investment increase. Last year after a visit to Havana, President Eduardo dos Santos said cooperation with Cuba should be reviewed. Before, Angola needed quantity, he said, adding that now it needed quality. That was taken by diplomats here as code words for a turn to the West by Angola.

The recent sharp changes in the nature of the warfare that has ravaged Angola have slowed any such turn, however, as South African troops have invaded deep into southern Angola and Pretoria's fighter-bombers have roamed freely over an area the size of New York state. At the same time, the Reagan administration has singled out Angola as a potentially hostile target, and presumably Angolan dependence on the Soviets and Cubans has not lessened as a result.

The constant warfare Angola has faced since its 1975 independence has crippled all the efforts made to restore economic health to a country that was the jewel in Portugal's worldwide colonial empire. Possibly more than any other colony, it existed for the benefit of the mother country, with its coffee, diamond and oil exports providing important foreign exchange earnings for Portugal.

Today, people stand in line for hours to obtain scarce commodities, the money is worthless and the economy has gone down since independence. The flight of more than 90 percent of the 350,000 Portuguese settlers has left the country bereft of managerial talent.

"Before independence most Angolans didn't have money, but there were many things to buy," one Angolan said. "Now they have money, but there is nothing to buy." Gross domestic production in the country dropped by 10 percent in the 1970s from the levels of the 1960s--the biggest decline recorded by any country, according to the World Bank. Food has become the second largest import, just behind arms to fight the wars, in a country that exported food when Portugal ruled.

Luanda was once a capital noted for its Mediterranean-style beauty. Now, beneath billboards proclaiming "the year of discipline and control," the streets are littered with trash and flanked by the shells of half-finished buildings, the cranes frozen in the same positions as when their Portuguese operators left in 1975.

The palm-lined harbor retains its charm. There, passing by the gorgeous, pink, 19th century national bank building, one could believe one were in Nice -- if it were not for the deserted streets. Elsewhere, there are reminders of the country's recent past. Two squares are dominated by military vehicles where monuments of the Portuguese used to stand.

Most of the small amount of new construction has been carried out by the Cubans, who bring in their own construction crews. Large blocks of apartments have been built opposite Luanda's shantytown area by teams of Cubans. Many are inhabited by foreign workers, including the Cubans.

There are some indications that the Angolans have tired of the Cuban presence after six years, but officials will talk only about the friendship between the two countries. Angolan officials repeatedly stress, however, that the Cubans will leave as soon as the South African threat disappears.

Angola makes no attempt to hide the Cuban troops or Soviet advisers. The Cubans are seen openly in Luanda, Lubango, the military headquarters in the south, and Cabinda, and some Cubans serve in the bodyguard of President dos Santos.

Taking a picture of the Cuban Embassy, which is bristling with antennas, almost got me arrested, but it did result in my gaining entry to talk with Gilberto Morejon Bello, the second secretary.

My interview was short on substance. Morejon said he did not know how many Cuban troops are in the country. "That's a military secret," he said with a smile. He did provide a figure of about 1,500 Cuban civilians in the medical, education, construction, technical and agricultural fields. Western analysts, however, believe there are about three times that number of Cuban civilians in Angola.

Morejon said about 500 Angolans are being trained in Cuba in similar fields.

"The Cubans are in Angola because the Angolan government asked us to come. If Angola wants us to go, we'll go," he said, adding, "we have very good relations with the Angolan government and people." The situation in southern Angola, he said during the time of the South African invasion, was "very, very dangerous."

The conspicuous foreign troops and advisers continue one characteristic of Angola's long colonial subjugation, which predates by centuries Europe's principal colonial drive in Africa. Next year will mark the 500th anniversary of Portuguese explorers first setting foot in the country in the Congo River basin in the extreme north.

It is unlikely that the occasion will be commemorated. Portuguese influence started in 1575 with the founding of Luanda. Exactly 400 years later -- after a bloody, 14-year guerrilla war -- the country, twice the size of Texas but with only about 7 million population, won its independence.

Angola has known nothing but war for 20 years. Portugal agreed to grant independence in 1975, but a civil war erupted among the three guerrilla factions that had been fighting the Portuguese since l961 and suddenly had a chance to gain power.

The current government of the multiracial Popular Movement for the Liberation of Angola is in fact a product of East-West strife. The Marxist MPLA won power militarily with the aid of Cuban troops and Soviet arms.

The U.S. Central Intelligence Agency provided arms and funds for mercenaries to the National Union for the Total Independence of Angola (UNITA), an anti-Marxist group led by Jonas Savimbi that has carried out a separate, low-key guerrilla war since independence in 1975.

The U.S. support for UNITA and another tribal-based group during the independence war encouraged South Africa to send its troops across the border and enter the fray on the side of UNITA.

The Portuguese, including the Army and officials, simply fled, leaving the country to chaos and civil war -- an abysmal end to Portugal's five centuries in Africa.

As a result, nationwide elections have never been held in Angola, as called for under the independence agreement.

The 2,000 South African troops decided to withdraw when the U.S. Congress, in a wave of post-Vietnam sentiment, passed the Clark amendment banning any military aid to forces in Angola.

The Reagan administration is now pressuring Congress to rescind the amendment. Many diplomats think such a move would curtail diplomatic intiatives by the United States, since it would allow open assistance to UNITA, already besmirched in the eyes of most black African nations because of its South African connections.

For years South Africa, in addition to supporting UNITA, has sent troops across the border from Namibia to attack guerrillas of the Southwest Africa People's Organization (SWAPO), which is fighting to end South African rule of Namibia. Some Soviet advisers have been killed or captured by South African forces in the attacks on SWAPO bases, which have also come close to areas where Cubans are quartered.

As a result of the two invasions in the last 15 months, South African forces have become a permanent presence in southern Angola, according to some analysts. There is widespread belief that South Africa is attempting to install UNITA in the salient where the offensive occurred, Cunene Province, which is about 300 miles west of Savimbi's stronghold in Cuando-Cubango Province.

This would provide a buffer zone protecting Namibia from SWAPO raids and thus allow South Africa to try to legitimize the multiracial government it has installed and ignore a U.N. settlement plan calling for internationally supervised elections.

The South Africans have been encouraged in these efforts by what they feel is the understanding of the Reagan administration. The latest, and possibly most important, move was a U.S. veto last month of a U.N. Security Council resolution condemning the South African invasion of Angola.

Many black African leaders have said the U.S. veto has encouraged South Africa to continue its military course, rather than seek a peaceful solution through the United Nations.

Western diplomats are concerned that the United States and Europe could split over Namibia and Angola. Washington stood alone in its veto at the Security Council in contrast to a vote earlier this year when Britain and France joined in vetoing a resolution calling for economic sanctions against Pretoria.

There is no sign that Angola's support for SWAPO will slacken, even in the absence of prospects for a settlement. Luanda has hinted that it may be forced to ask the Cuban troops to help repel the South Africans, a move that could seriously widen the war, if South African incursions continue.

Angola has yet to recover from the 1975-76 civil war, in which it is estimated that more people were killed than during the entire 14-year liberation struggle. Evidence of destruction from that war still can be seen along the roads in southern Angola.

For the last year, Angola has been seeking to broaden its relations with the West and move away from dependence on the Soviet Union and its allies.

Trade with France and Britain has increased, West Germany recently opened an embassy and Angola has sought to expand its relations with Yugoslavia and Algeria, two champions of the nonaligned.

Of the 17 foreign aid projects in the country, 11 are from the West and two from Yugoslavia. Now that relations have improved, Portugal, the former colonial master, is playing an increasingly important assistance role. There are now more than 800 Portuguese economic development advisers, known as "cooperates," and the number is increasing.

Pointing to the shift, a Western ambassador said: "My technicians are going to sleep in a house tonight in Lubango where Soviet technicians slept until yesterday."

He cautioned, however, not to expect any abrupt Angolan move from the Soviets to the West, like that of Egyptian President Anwar Sadat almost a decade ago.

"Angola will try to use both sides," he said.

He noted that the Soviets have not gained much from their relationship with Angola. The Soviets do have a fishing treaty, but there are reports of difficulties in renewing it. Angolans frequently complain that the Soviets are taking all the fish.

The diplomat added, however, that the South African invasion could reverse Angola's overtures to the West.

"Soviet influence had been declining, but the South Africans are now helping the Soviets to increase it again . . . . If you're fighting the South Africans these days, you certainly don't ask for American military advisers," he said.

Another diplomat said, "The South Africans are doing a good job for the Soviets."

For the West the best solution is a settlement on Namibia. Diplomats agree that as long as South Africa seeks to maintain the status quo, the situation will just get worse in southern Angola. That settlement, they say, depends in large part on the United States. Next: Angola's second war