Police frogmen scoured the underwater pilings along the East River in search of bombs. Spotter helicopters hovered overhead. Teams of mounted policemen stood ready to divert traffic at the first wail of a motorcade siren.

It was all part of the preparation for the United Nations General Assembly, which opened its 40th anniversary session in New York today, primed for a three-month onslaught by scores of presidents and prime ministers and three kings.

The gala celebration opened amid relative calm this afternoon with the uncontested election of Spanish Ambassador Jaime de Pinies as assembly president.

Apart from the stringent precautions, there was an atmosphere of hope -- though not of expectation -- that the intense interest in the United Nations on this anniversary would revive its youthful vigor and idealism as a focus for efforts to solve the world's political problems.

The VIPs will begin pouring in Monday, when Secretary of State George P. Shultz and the presidents of Peru and Brazil are among those listed to speak on the first day of the assembly's general debate.

The new Soviet foreign minister, Eduard Shevardnadze, will make his U.N. debut the following day. More than 100 other foreign ministers from among the 159 members are expected in New York next week to address the assembly and -- perhaps more importantly -- to talk one-on-one with their fellow foreign ministers in hotel rooms around town.

The foreign ministers of the 15 Security Council members will participate in a special commemorative session to explore the anniversary theme: how the council can play a larger role in settling disputes.

Shultz and Shevardnadze are to meet privately to lay the groundwork for the November summit in Geneva between President Reagan and the new Soviet Communist Party chief, Mikhail Gorbachev. Gorbachev is the one major figure who has officially declined the invitation to participate in anniversary celebrations.

Most of the others will arrive the week before the United Nation's official birthday, Oct. 24, when Reagan is scheduled to make his fourth annual speech to the assembly.

The decision of both superpowers to dissociate their meeting from the U.N. gala has served as a reminder of the caution with which Washington and Moscow view multilateral diplomatic forums.

Among those who have accepted invitations are three kings -- Hussein of Jordan, Hassan II of Morocco, and Juan Carlos of Spain. Libya's Muammar Qaddafi is scheduled to make his first sortie to the United States in October as well.

His presence, in the same building at the same time as Poland's Gen. Wojciech Jaruzelski, Pakistan's Gen. Muhammad Zia ul-Haq, India's Prime Minister Rajiv Gandhi and British Prime Minister Margaret Thatcher -- all potential terrorist targets -- has prompted the unprecedented security operation.

Attempts are being made to get national security contingents to coordinate with the United Nations, city police, State Department and the U.S. Secret Service.

The city's chief of security operations for the anniversary, Borough Commander Gerard Kerins, said today that the New York Police Department had installed its first field computer operation across the street from the United Nations to regulate 25 scheduled demonstrations with the motorcades that will inevitably cause traffic gridlock in midtown Manhattan.

The climactic traffic event -- a luncheon Oct. 23 for 55 heads of state -- is likely to end by spewing out 55 motorcades of three to 45 vehicles apiece into the already jammed intersections of Manhattan's East Side.

As the meetings, speeches and formal receptions go on, the working diplomats here will congregate in their basement meeting rooms, plugging away at the record 150 items on the assembly's agenda.

The African group is expected to dramatize the South African issue by seeking a special high-level resolution limited to the challenge to apartheid.

Diplomats are also struggling to draft a unanimous declaration outlining the norms of international behavior established by the United Nations in the past 40 years. Differences have arisen between the West and the Third World on what should be emphasized.