President Sind Barre's sudden trip to China is the action of a man caught between a rock and a hard place. He is in bad trouble, having not yet mastered a military coup generated by his failure to take the Ogaden province of Ethiopia.

He has burned his bridges with the Russians, his former allies who turned on him and helped the Ethiopians defeat Somali forces in the Ogaden. The United States has set tough conditions for giving him the help he needs. So his visit to China is a desperate measure.

I arrived in this country at precisely the moment the coup got under way - six in the morning on April 9. Government and U. S. sources told me rebellious army units had seized the radio transmitter and made an attack against the barracks, five miles outside of Mogadishu, where the president lives.

Around 11 in the morning I drove out to visit the barracks with two European journalists. Two new tanks were stationed at the entrance to the military camp. Soldiers armed with machine guns were visible along the hills around the camp. Militia had established checkpoints every 10 yards on the road near the camp. We were stopped and frisked. At one point we saw an office being held prisoner by policemen.

Coming back to town we stopped at the compound housing the Marine detachment that guards the U.S. embassy. It is less than a quarter of a mile from the president's house. One of the Marines told me that he had been awakened about eight by a "loud blast." Afterward there were tanks moving about, and small arms fire. "By 10 in the morning," he said, expressing a view that briefly became dominant, "it was all over."

But subsequent event demonstrated it was not all over. Security measures have been steadily tightened.

The most obvious difficulty is that some of the rebels got away. Rumor, which is now rampant, has it that a battalion of tanks and a battalion of infantry are standing outside the city ready to attack again. They are said to be under the command of a colonel who was responsible for missile operations in the Ogaden campaign.

The general attitude of the army, moreover, reflects lasting scars from the defeat in the Ogaden. Casualties are estimated to have run at about 50 per cent - some 10,000 to 15,000 men.

Half a dozen officers were executed in the first week of march for refusing orders to retreat. Two generals who served as vice ministers of defense during the Ogaden fighting were given nondefense tasks in a ministerial shake-up on April 1. Three dozen more military men have reportedly been executed since the coup.

The mutinous mood of the army dovetails with general public criticism of the president. He is blamed for going all out against the Ethiopians and their Russian patrons without first firmly tying down American support.

Resentment of the president seems to divide this country along regional and tribal lines. In the northern part of the Somalia, just opposite the Ogaden, feelings are said to run especially high. One rumor is that in the capital of the north, Hargeisa, the radio has turned against the regime.

Under those conditions, the president east about for an international solution. The Russians, having been milked by him for arms and then betrayed when he wanted a go at Ethiopia, would have none of him. He learned that when he spoke to the Soviet ambassador after the attempted coup.

America could really help with arms. Weapons would solve the sting of defeat with the balm of a promise the regime might live to fight the Ethiopians some other day. But the United States insisted that, before getting arms, the president renounce in perpetuity any territorial claims on other countries. He balked at signing what amounts to a quit-claim on lands he covets.

The visit to China is a way of seeming to turn down both superpowers. But the Chinese cannot really help; they don't have the weapons or the means to get them here on time.

So my guess is that eventually he will be turning back to the United States. Washington will be asked to provide security cover for a neutralist Somalia backed by communist China. Which is an intriguing possibility.