WHEN THE GOVERNMENT of Iranian Prime Minister Shahpour Bakhtiar collapsed on Feb. 11, 1979, civil order collapsed as well, and for the next two days, jubilant mobs sacked government buildings throughout Iran. At the Defense Ministry in Teheran, military police put up a desultory fight and fled. Secure areas were left unguarded; technical data, classified manuals and intelligence findings were available to anyone bold enough to enter the ministry.

According to former senior officials, of the CIA and Air Force intelligence, it is certain that Soviet agents were bold enough. When the last vestige of the shah's government fell, the United States lost more than an ally. It lost to the Soviet Union information vital to America's own defense.

The U.S. Navy was damaged most. Compromised in Iran:

* The F-14 fighter, keystone of long-range fleet defense. The airframe and engines, though advanced, held no great secrets for the Soviets. Of much greater interest were the electronics and missiles on the F-14:

* The AN/AWG-9 radar and weapons control system.

* The AIM-54A Phoenix long-range air-to-air missile.

* The ASG-18 fire-control radar, which gives the Phoenix its exceptional accuracy.

* The ALR-45 radar warning set.

* The ALQ-100/126 electronics counter-measures suite, designed to both jam and deceive Soviet-built radars.

The U.S. Army (and thus NATO's infantry and armor) also suffered security losses in Iran. The Soviets gained insights about:

* The Improved HAWK surface-to-air missile, the Army's basic element of ground defense.

* The AN/TSQ-73 command system, which directs the Improved HAWK.

* The BGM-71 TOW antitank missile, which NATO regards as a primary means of neutralizing the 4-to-1 Soviet advantage in tanks in Europe.

"We know for a fact that the Soviets did lay their hands on a lot of the hardware, not just the manuals," Ryan Emerson of International Intelligence Report told Stephen Werbe in the Oct. 15, 1980 Christian Science Monitor. Security at military bases immediately after Bakhtiar's fall was uneven at best. In the weeks after Feb. 11, Islamic Guards policed the installations. The Carter administration cited this fact to rebut reports that the F-14s in Iran had been examined by unfriendly agents. But the claim of uninterrupted security for American-supplied weapons was dropped after it was learned that most of the Islamic Guards were irregulars and volunteers.

With the Iranian experience in mind, the Reagan administration's decision to sell Saudi Arabia five E-3A AWACS radar and control aircraft seems hard to believe. The AWACS is central to both American security and the defense of Western Europe. So Reliant is NATO on the "C3 doctrine" (command, control and communications) and so important is the AWACS to fulfilling the tenets of that doctrine (early warning, intelligence collection and battlefield coordination) that it is questionable how much political and military restraint the U.S.S.R. would show in Europe if the Soviet leadership were convinced that the AWACS could be neutralized.

Equally disturbing, is the fact that the Saudis have received or will soon take delivery on a number of first-line weapons no less crucial to America's own defense than the ones compromised in Iran. The Saudis are politically unstable. Worse, the Soviets have the wherewithal to penetrate porous Saudi Security even if there is no revolution.

In providing Saudi Arabia with the AWACS, F-15S. Sidewinders, shipboard defense systems and other weapons just now being delivered to America's own forces, the United States is risking its own security and that of NATO. In essence, we are offering the Soviets a windfall in military intelligence at least twice as damaging as the one reaped by the KGB in Iran.

In the months since the AWACS sale was announced, the administration has tried to defuse opposition by claiming that the planes the Saudis will receive will be stripped-down models. This is no more accurate than the Carter administration's description of the F-15 as a "defensive aircraft." The E-3As destined for Saudi Arabia will in fact be "Block 30/35" versions, the most advanced model of the AWACS, and superior to those sold to NATO (the Block 25 model).

The administration has suggested that it will delete certain advanced subsystems on the planes destined for Saudi Arabia. But there is evidence and precedent which indicate that when the planes are delivered, most once-deleted systems will be on board.

Block 30/35 AWACS normally will carry the following equipment -- every piece of which is on the cutting edge of technology and of intense interest to Soviet intelligence.

* The AN/APY-1 radar, which on the Block 30/35 aircraft will be redesignated AN/APY-2 because of its added ability to track ships under way or at anchor. This radar has lookdown capacity, meaning it can separate the images of aircraft from the radar echoes of the ground or the sea. The AN-APY-2 can see targets over the horizon and by virtue of its carefully shaped radar beam, is difficult to detect and jam.

* The AN/PX-103 secure mode IFF system. IFF means "identification, friend or foe." The AN/PX-103 uses coded signals to "interrogate" unidentified aircraft, and judging by the response, displays on a console which planes detected by the main radar are friendly and which are potential targets. The AN/PX-103 is integrated with and utilizes a secure data communications system called TADIL-C, which is installed in the disc-shaped radome mounted above the fuselage. This radome also houses the antennas of the main AN/APY-2 radar.

In addition to identifying friends and adversaries, the AN/APX-103 simultaneously allows the AWACS to maintain air traffic control over a wide area. The Reagan Administration has indicated that the Saudis will receive a commercial IFF instead of the AN-/APX-103. But this would require a redesign of the radome and antenna suite. It would also require a technically difficult separation of the components and computer programs of the AN/APX-103 from those used in the main radar.

* The AWACS computer software. The central computer of the AWACS is nothing special (though the Block 30/35 aircraft will carry a computer four times as powerful as the one on unmodified U.S. Air Force E-3As.) It is the software, even more than the electronics, which makes the AWACS such a powerful system. The Saudis will receive:

* The executive programs, which coordinate radar tracking and the sequence of operations onboard the aircraft.

* The surveillance programs, which sift hard information from the welter of signals collected every second by the radar.

* The identification programs, which constantly change the codes used by the IFF and sort responses.

* The communications programs, which intergrate the multiple voice and data networks which link the AWACS to ground stations.

* The display programs, which translate data into visual images on the consoles of the AWACS.

* The battle command programs, which allow the general staff to utilize information collected by the AWACS and to execute orders to the battlefield on the basis of it.

* And the electronic-counter-counter-measures (ECCM) programs, which enable the main radar to resist efforts by the enemy to blind it or misinform it.

Administration officials have stated that the Saudis will not receive ECCM capacity. This assertion is certain to be repudiated. ECCM on the AWACS radar is a matter of high-level computer code, much of it embedded in other computer programs. In order to deny the Saudis the ECCM capability, the U.S. would have to completely rewrite many of the other programs listed above, so thoroughly is the ability to resist countermeasures integrated by design throughout the AWACS.

In fact, the ECCM capacity simply cannot be deleted. The writing of software is one of the most cash- and labor-intensive enterprises of the technological age. The U.S. already has hundreds of millions of dollars and literally work centuries invested in the AWACS software. More important, software reflects even more than hardware the modus operandi of America's military intelligence.

How the software sifts, what the software assigns importance to, all these things illustrate the philosophy and analytical framework of the designers and users of the AWACS. Hardware, once compromised to the enemy, can be redesigned and updated. But replacing software is like changing the way you perceive and think.

Finally, the Block 30/35 AWACS will normally come equipped with the JTIDS (Joint Tactical Information Distribution System). This device is a combined secure communications network, IFF system, precision navigation system and data collection and distribution center.

NATO plans to equip every ship, plane, tank, ground radar, SAM battery and infantry unit with a JTIDS transceiver. With battlefield information constantly flowing to central JTIDS processors on board each AWACS, Western commanders will have the ability to monitor every area of the battlefield and launch, without fear of countermeasure, integrate attacks against the enemy.

JTIDS is still under development, and the administration has stated that the Saudis will not receive this system, basic to NATO's operations. Yet for the five E-3A's to operate in proper coordination with the Saudi Air Force, a system like JTIDS will be necessary. In 1978, one of the authors wrote in a memorandum opposing the sale of F-15S to Saudi Arabia:

"An F-15 sale will require that the U.S. sell the Saudis advanced airborne radar systems such as the E-2C or E-3A AWACS."

The State Department responded to this contention in a memorandum (Feb. 18, 1978) drafted at the request of Rep. Lee H. Hamilton (D-Ind.). It stated:

"An F-15 sale will not lead to the sale of the E-2C or E-3A. The F-15 has an excellent radar. Were the Saudis to purchase an aircraft with a less effective radar than the F-15, they would be more likely to seek an airborne radar system. The Saudis have expressed no interest in either the E-2C or AWACS."

Analogously, any commitment tendered now y the Reagan administration not to enhance the capability of the AWACS with the JTIDS must be viewed in light of this discarded assurance.

Bureaucratic pressures will certainly add impetus to such a decision: The U.S. Air Force pushed the AWACS sale in order to lower the unit costs on the planes it was buying and to establish a foothold for a permanent military presence in Saudi Arabia.

The administration's own rationale for the Saudi AWACS assumes the need for interoperability with American forces which might be dispatched to protect Saudi Arabia in an emergency. By 1985, the Rapid Deployment Force will be equipped with JTIDS. So will the AWACS now based in Saudi Arabia. These planes are part of the U.S. inventory and will be upgraded accordingly. But by selling five E-3A's to Saudi Arabia, and by pledging to withhold JTIDS, the Reagan administration and the Saudis will face the prospect of having a Saudi-owned AWACS force which is less capable of defending the kingdom, and less able to assist U.S. forces than the "loaner" unit it replaced.

There is just no way the U.S. military will allow such a circumstance to occur. Given that under current law, any weapon system costing less than $7 million may be sold abroad without congressional review, there will be little to stop a quiet decision to upgrade the Saudi AWACS with JTIDS.

Moreover, by delivery time in 1985, the Saudis will have had four years to cite Arab pride, petro-friendship and security needs in order to justify the addition of JTIDS and other deleted subsystems. This is part of the process known as after-sale upgrading. There is an instructive precedent in the aftermath of the F-15 battle. In May 1978, the Carter administration told members of Congress that the Saudis would not receive some of the top-of-the-line avionics standard on the F-15. But three months later, Electronic Warfare/Defense Electronics reported that:

". . . the United States is planning to include the same avionics in Saudi Arabia's F-15s as that installed in U.S. F-15 aircraft, a high DoD [Department of Defense] source revealed to EW/DE. When asked if this included Loral's advanced ALR-56 radar warning receiver and Northrup's ALQ-135 computer-controlled jammer, he replied, '. . . all the avionics will be the same.'"

After-sale upgrades also have enabled the Saudis to acquire -- without congressional review -- the more advanced F15C instead of the F-15As originally requested; F-5E fighters with aerial refueling capacity and the ability to launch Maverick air-to-ground missiles, and a more sophisticated model of the Maverick itself.

At least one official in the Reagan White House has acknowledged privately that by 1985, the after-sale upgrading process will have worked once again, and that the AWACS bound for Saudi Arabia will be fully equipped, promises to Congress notwithstanding.

Even if the Congress votes resolutions of disapproval, the United States will only have lessened its security exposure in Saudi Arabia by perhaps a third. Other systems now in the country or destined for delivery are essential for the effective performance of America's Air Force and Navy against Soviet-armed forces. These include:

* The F-15 fighter/bomber, the mainstay of NATO's tactical air threat until the year 2000. The Soviets have an abiding interest in the F-15's engine, the F-100. A fighter engine is only as good as its combustion chamber, and the F-100 utilizes a level of metallurgical magic that in its own way is as sophisticated as the electronics on the AWACS. Also of interest on the F-15:

* The AN/APG-63 radar, described by Air Force Gen. John Vogt as "so far advanced that it is something of a decade ahead of anything else."

The AN/ASN-109 inertial navigation system.

* The ALR-56 radar warning receiver and the ALQ-135 ECM. The two units have only been in production for four years, and encompass in their designs every insight the U.S. gained in the YOM Kippur War and after about the workings of Soviet radars.

* The AIM-9L, Sidewinder air-to air missile. The most advanced short-range air-to-air missile in the world, two were used to shoot down the Libyan Su-22s in the Gulf of Sidra. Sale of the AIM-9L is part of the AWACS package, and Congress still has the opportunity to block the transaction.

In April, a number of U.S. Air Force pilots wrote a letter to Rep. Tom Lantos (D-Cal.) warning against the sale of the AIM-9L to the Saudis. They noted the sophistication of the weapon and predicted a degradation of America's security if the AIM-9L were to fall into the hands of the Soviets. They were correct. The Soviets lag badly behind the U.S., Israel and France in both air-to-air missile design and lookdown radar capability. By adding knowledge of the AIM-9L to that now known about the Phoenix, the Soviets could eliminate one of the few remaining areas of military technology in which they trail the U.A.

* The AGM-65B Maverick air-to-ground missile. Carried mainly on Saudi F-5E fighters, the 65B Maverick is a "fire-and-forget" weapon which has been in production only three years.

Like the Air Force, the U.S. Navy may suddenly find itself less secure because of what gets penetrated by the Soviets in Saudi Arabia. The Saudis have purchased:

* The RGM-84A Harpoon anti-shipping missile. This is the principal all-weather weapon for fleet defense. The Harpoon is now being installed on nearly every class of American warship, and has only been in service since 1977. The Saudis are also purchasing:

* The AN/SWG-1(V) weapon control system, which channels data from the ship's radars to the Harpoon while the missile is in flight, and which makes the Harpoon a notably lethal weapon.

* The Phalanx Close-In Weapon System (CIWS). Basically a radar-directed automatic machine-gun, the Phalanx is literally the last ditch defense system for the American fleet. It is only now being installed on American naval vessels after emerging from a high-priority development program. The critical time environment in which the Phalanx's radar must perform means that a compromise of this system could only be compensated at a great cost in both money and research.

With the AWACS sale formally submitted to Congress, witnesses for the State Department will assert -- as they did during the hearings on the F-15s -- that Saudi Arabia possesses modern security infrastructures. This (they will say), combined with the loyalties forged in the desert make Saudi Arabia a secure place for even the most sophisticated American weapons. When the witnesses from Foggy Bottom give these assurances, they will be talking through their hats.

The Saudi security apparatus is a Potemkin village. The system put together by Prince Turki al-Faisal (the Foreign Liaison Bureau and General Intelligence Directorate) has police units, spies, counterspies, computers, communications and camouflaged offices. What the Saudi security system lacks is security.

Like every other modern institution which has sprouted in the kingdom, the Saudi security system is nascent. And like every other technology-dependent infrastructure in the kingdom, it lacks both trained operatives and experienced executives. The Saudi security system is hamstrung by a dearth of experts and planners who feel at home in a high-technology environment. Worse, Prince Turki has failed to instill a guiding sense of mission, cohesion and ideology.

Intelligence gathering and counter-intelligence are businesses which put a premium on personnel and experience. It takes decades to put together an effective system in which senior administrators trust each other and know the strengths and weaknesses of their agents and protective infrastructures.

Saudi security problems are compounded by shortcomings outside the two intelligence services. Soldiers and police are neither well-educated nor adequately schooled in protective techniques. The same things that make them hard to train also make them indifferent to security procedures and insensitive to real or potential breaches.

The armed forces should have their own powerful and semi-autonomous security units, but the royal family has kept military intelligence on a short leash. The ruling princes fear that any elite, secure, self-contained and well-armed group might attempt a coup d'etat. Their fears are not unjustified, but this paranoia doesn't enhance the security of American weapons in the kingdom.

The worst problem is the number of aliens at military installations. Pakistanis train Air Force pilots. There are more than 400 Pakistani engineers and technicians with officer rank attached to the Saudi military. Pakistanis also serve as Air Force mechanics, as do Taiwanese. South Koreans work at Saudi naval facilities. Yemenis are ubiquitous, performing "menial" tasks as waiters, cooks and maintenance men. Egyptians and Pakistanis work as administrators and teachers both on base and in nearby compounds.

The Saudi military itself is laced with Saudi citizens who sympathize politically with Iraq, Iran, Syria, Libya, Egypt and/or the Soviet Union. (This is a common circumstance in Arab armies.)

It does not require too much imagination to realize that clandestine communists, or pro-Iraqi, pro-Syrian or pro-Libyan Saudi officers would be targeted by Soviet intelligence as likely conduits of information about American weapons in the kingdom. The covert KGB presence in Saudi Arabia is growing. and is supported by major stations in Kuwait and Aden.

In essence, Saudi dependence upon the importation of skilled and unskilled personnel makes the kingdom a permanently unsecured area. The United States can dismiss this, but the Soviets will not.

Having created so many opportunities for security breach, the Saudi royal family may very well facilitate the ultimate intelligence compromise by getting itself overthrown. Weapons such as the AWACS and F-15 mean that when a coup attempt comes again, the sheer firepower at the disposal of the ring-leaders will increase their chances for success.

Interestingly, the simple presence of high-tech weapons in the country destabilizes the royal family. It is a two-edged sword: many Saudis feel proud to know that their country is the recipient of the most powerful arms in the world. But for other Saudis, this is evidence of the overweaning self-aggrandizement of the royal family.

The royal family, hamstringing the military politically (while simultaneously trying to buy its favor with lush salaries, luxurious quarters and gold-plated cutlery in the mess halls) relies upon the National Guard to assure its safety. But this tribal force is just that -- a throwback, bound by loyalties which were tested and found wanting in the takeover of the Grand Mosque in Mecca in 1979. The National Guard's fundamental problem is that it is not an elite force, like the commando units of Egypt and Israel. It lacks their training, techniques, command structure and political awareness. Here again, the waxing firepower of the Saudi armed forces makes it increasingly unlikely that the National Guard could successfully protect the royal family.

But what has drawn the least attention, and yet is the likeliest source of a coup attempt is the tumult in the royal family itself. The conventional wisdom is that the family operates by consensus, mollifies complainers and assures that no one kills the goose that lays the golden eggs. But that is a misperception of current dynamics within the family. There are two competitions for power and wealth now underway: one is taking place among the senior princes; the other pits the senior princes as a group against lesser, peripheral members of the royal family.

The Wall Street Journal reported early in May that a number of senior princes and their sons had been involved in schemes to sell oil to Japanese, Italian and Thai buyers in exchange for commissions which would have totaled millions of dollars. It is logical to ask: Why are some of the richest men in the world risking public embarrassment in pursuit of foreign payoffs -- even payoff exceeding $100 million a year? Greed? Boredom? Power?

The answer appears to be power. The consensus process within the royal family is breaking down as the demise of the infirm King Khalid looms. The battle over the line of succession after Crown Prince Fahd has been brutal, unending and only partly resolved. The senior princes and their avaricious sons are developing their own parochial and irreconcilable agendas. These command ever more loyalty as the disagreement about policy for family and kingdom continues. Fahd's succession is likely to exacerbate this fractionization, for he is neither a builder of coalitions nor a crusher of adversaries.

There is a story going around the intelligence community about the coup preparations of one of the senior princes. "Why should I care if a revolution costs me $100 million?" the prince is reported to have told a confidant. "The day after I become king, my income that day will be twice as great."

The workings of the royal family destabilize the monarchy in another way. Power and oil revenues are concentrated at the center. The senior princes are under pressure from lesser family members to decentralize the family enterprise.

As with political power, the king and the senior princes divide the lion's share of oil revenues reserved for the royal family as a whole. (Aside from the senior princes, the only Saudi citizens who regularly command truly large chunks of oil money are the heads of the vassal tribes around the country.) Three days, lesser family members get payments which may total several million dollars, but which are essentially token in nature. Their share of actual power is limited

It is now clear that any move by the senior princes to share power with the outer circles is unlikely to occur because of the conflicts inside the senior group. Moreover, any devolution of power will not broaden the popularity of the senior princes or the family itself. What little power that is spun off from the center will be seized by less senior princes long before it has a chance to filter to the periphery.

More important, the burgeoning non-royal groups (the military, the technocrat-administrators, the entrepreneurs and the middle class) remain as powerless as before. Shut out and effectively disenfranchised, these groups are becoming a fertile agar for revolution. And unlike the shah, the Saudis have yet to undertake even a pretense of reforms.

Sadly, the worse-case scenario for the United States (massive security breach of its defenses) can happen even if the worst-case scenario for the Saudis (overthrow) does not occur. Whether the sieve-like quality of Saudi security is really important ultimately depends on the ability of the Soviet Union to get classified information and put it to use.

The deliberate structuring of the KGB to collect the maximum amount of technical data in the West and extract the maximum benefit from it has been well documented. This is a certainty: the Soviets use what they collect, and they are willing to collect it anywhere. The so-called "velocity of information" is swift between the scientific and technical directorate of the KGB and the research institutes of the Soviet military.

A compromise of American technical secrets in Saudi Arabia would help the Soviets to build systems they do not now possess, and improve systems they are currently developing. The Soviets already possess the ability to build most of the weapons sufficient to confront the U.S. But if the AWACS or F-15 (along, recall, with their subsystems) are compromised to the Soviets, the U.S.S.R. will focus not on duplicating the American components but on defeating them electronically. As in simple itelligence collection, electronic countermeasures have a much higher prospect of success when you have a known, defined target in mind.

Even if the Soviets acquire only a few pertinent facts about a radar or communications device, they will be much aided in their ability to build an effective ECM against it. Soviet science is uneven, but it is renowned for its mastery of electronic theory and the associated mathematics. The Soviets are fully capable of building devices to impair and deceive any system in the U.S. arsenal -- given sufficient data.

Seemingly innocuous information about signal strength, bandwidth, pulse frequency, receiver sensitivity, selectivity, antenna characteristics and a thousand other minutiae is enough to focus research towards completion of an effective ECM. Physical examination of components provides information not only about how they work, but how they were made. Inspection of components functioning as a system allows one to discover systemic weakpoints. And there is no telling what could be done with some particular knowledge of a computer system, its operating software, its access routines and its codes.

Advanced systems such as AWACS crucial to America's defense are acquired only at a great cost; research and development expenses are astronomical, because what is being designed is not merely a component, but a never-before assembled technology for building it.

Conversely, ECM research is very cost-efficient. With the right investment, you can render obsolete, even useless, billions of dollars worth of your enemy's weapons (and its investment in research and development). One acquires much of the enemy's technology without paying nearly as much for it in money or time. Moreover, the analysis which produces the ECM elucidates where the enemy is heading for the next generation of weapons. It also illuminates, as noted earlier, what he thinks is important, and how he detects and measures and classifies it.

In the largest sense, these realities dictate a much more conservative and vigilant American policy for the protection of our technical prowess. In the immediate sense, they suggest that the United States should revise its plans to put a gamut of first line weapons in the hands of a nation -- Saudi Arabia -- patently incapable of protecting them.

If the United States wants to signal that it is unwilling to give unintentional assistance to Soviet military planners, it should withdraw the offer of the AWACS to Saudi Arabia. Reevaluation of the 1978 F-15 sale would not be unjustified either. Given the centrality of the AWACS to the security of the West, a refusal by the administration to cancel the sale should persuade the Congress that it must protect our interests, and vote resolutions of disapproval.