Somalia went on a full war footing last night as the government declared a state of emergency and announced it was formally committing its regular armed forces to the fighting with Ethiopia in the Ogaden desert.

In a late-night announcement broadcast over Somali radio, the government recalled all retired soldiers and reservists to active duty and appealed to the nation for volunteers in defense of the "unity and the existence" of Somalia.

An official statement said the government was forced to take these steps because of the intervention of the Soviet Union and Cuba on the Ethiopian side.

It has been known for many months that regular Somali forces are deeply involved in the Ogaden war, but up to now Somalia forces are deeply involved in the Ogaden war, but up to now Somalia has maintained that it was merely helping indigenous ethnic Somali guerrillas in Oganden throw off Ethiopian occupation of what it considers to be Somalian territory.

The formal entry into the war is unlikely to affect the military situation, which has turned against Somalia since Soviet and Cuban aid and advisers began to flow into Ethiopia late last year.

The action does change the political climate, however.

Ethiopians and Somalis have contested the Oregon-sized Ogaden region for almost a century. The two countries fought a short war over it in 1963 in which Ethiopia was victorious. Last summer, Somali-backed guerrilla forces captured about 90 percent of the region. Ethiopia, aided by Soviets and Cubans, launched a counteroffensive last week to regain the area.

This latest action, the government statement here said, "forces Somalia to defend itself against the naked aggression and to increase its assistance to the liberation forces by dispatching units of its own regular army to the conflict."

Last night's statement was seen by western analysts here as being at least in part a response to U.S. Secretary of State Cyrus Vance's statement that the United States would continue to refrain from supplying Somalia with weapons and that Washington wanted the withdrawal of "Somali forces" from the Ogaden.

Vance indicated that the United States may change its policy if the expanding Ethiopian offensive spills across the Somali borders.

The confrontation, however, may possibly lead to a growing internationalization of the Ogaden war. Egypt has already provided $30 million in arms to Somalia. Other countries in the region, especially Iran and Saudi Arabia, are expected to side with Somalia and possibly offer military aid should the situation deteriorate.

The government statement last night said Somalia was "astonished" by the refusal of the West to respond in kind to the Soviet intervention. It criticized the United States and other western allies for "not taking their responsibility."

Somalia, it said, would fight relying on its own resources. These are slim, since the country broke its long relationship with the Soviet Union last fall but failed to find alternate sources of arms.

The government statement was issued in the name of the Central Committee of the Somali Revolutionary Socialist Party, which just completed a two-day review of the Ogaden situation. The review followed a visit to the front by President Mohammed Siad Barre.

Reports circulating here indicated that Siad Barre was deeply discouraged by the deteriorating military situation and by his feeling that this country was left unfairly isolated by Western powers.

The Somalis, having wrested the Ogaden from Ethiopian control last summer after decades of futile efforts to gain it by other means, now face the possibility of losing it back. They also fear that the Ethiopians and their allies will not stop until this country has been brought to its knees and perhaps has been forced to return to the Soviet orbit.

It was not clear what the effect of the state of emergency would be. The government already has virtually full powers.

But up to now Mogadishu has hardly been on a war footing. The cafes are thronged with young men who are apparently now subject to a callup.

The Somalis and their allies in the Western Somali Liberation Front have made it clear that they have no illusions about their ability to stand up to the armed might of the Soviets and the Cubans. But this country's pride is at stake, and the Somalis appear to have painted themselves into a corner from which the moves announced last night, however cosmetic, may be the only way out.

It is also not known how the Somali people, who has been screened from most of the bad news so far, will react as the government begins to try to change the atmosphere here.