While we wait to see how the Americans being held hostages in the U.S. embassy in Tehran get out, it may be useful to examine how the Iranians holding them got in.

They -- some 500 students -- got in by hurdling the eight-foot brick wall and pushing through the several iron gates that surround the embassy compound. That compound -- in its location (downtown), its dimensions (at least a couple of hundred yards long on each side) and its seeming indifference to security (the long low wall) -- is an elegant monument to the privileged position the United States used to enjoy in Iran.

The revolution that brought Ayatollah Khomeini to power last February included a violent seizure of the embassy. That forced on Washington the question of closing down the embassy or at least moving to more discreet and secure quarters. In the first case the political signal of withdrawal was deemed unwise, and in the second the logistics were deemed prohibitive. Instead, the embassy cut its personnel by more than nine-tenths to a level -- currently 75 -- regarded as bare-bones.

Through this period, the security plan was essentially what it is at all American posts(and for that matter at all foreign embassies everywhere): the Marines constitute a plate glass window that intruder must break to gain entry. The embassy contains special areas for sensitive business in which some people can take refuge for a while. But finally, security depends on the local authorities.

After February, Americans diplomats insist, they worked hard on the Iranian authorities to provide effective security. As evidence that this was not a feckless policy, a State Department official told me that only three days before the embassy was seized, and a full 10 days after the shaw had reached New York, a protest march on the embassy had been planned and the authorities had steered it away. That set the embassy up for the surprise that hit three days later.

The operational response to an unexpected takeover attempt was, by prearrangement, in the hands of the Marine commander. When the students -- 500 of them, seemingly unarmed -- poured over the walls, he ordered his men to throw some tear gas but otherwise to hold fire, fearing a shoot-out.

The suddenness of the students' swarm and their numbers made it unfeasible, the State Department says, for embassy people to barricade themselves in the chancery until early relief could arrive. Since the government had evaporated, early relief would not have arrived anyway. And American force was unavailable.

So. Security could have been better: another location, more Marines, higher fence, shooting orders, timely evacuation, etc. It is at least arguable that the invaders would have thought twice if they had known the price would be high.

To believe this, however, you must grant the possibility of some kind of bunker siege involving substantially loss of American life. It is a measure of the current public temper that many Americans, feeling humiliated by Khomeini and believing that this crisis would never have occurred if Carter had not earlier dissipated respect for himself and the United States, indicate now that they would have accepted the risk: the Mayaguez syndrome.

Yet if preparation for a shoot-out is not simply incompatible with the effort any government makes to get along with a host country, then it certainly was incompatible with the effort the United States was making to build up a constructive link with the new Iran. If you think it necessary to plan for the bunker, you have identified precisely the condition that calls not for improving security but for cutting ties.

The administration's real vulnerablility, I think, lies in its expectation -- hardheaded in its pursuit of oil, softheaded in its pursuit of Third World favor -- that things were settling down in Iran; that the moderates were prevailing; that the extremists could be trimmed to size; that the United States would gain more from betting on the future (by providing its presence, arms, grain, heating fuel, schooling, etc.) than from cutting itself out of the game.

It remains only to dispense with the suggestion that Carter's critics precipitated the crisis by forcing the administration to admit the shah. This is untrue. The Iranian revolution was disintegrating. Khomeini seized on the issue at hand. This works not against critics but against Carter. I sense a new rage, a disgust, building in this country against the president. He will pay.