Queen Elizabeth II went out on the town last night for an unscheduled celebration of her arrival back on at least partially dry land. Fierce storms forced the cancellation of her cruise up the California coast on her yacht Britannia, and she flew here today from Long Beach with Prince Philip and First Lady Nancy Reagan.

Although the dinner she hosted at Trader Vic's restaurant was unannounced, IRA supporters chanting anti-British slogans tracked the queen down. Keeping the 50 protesters at a distance were San Francisco riot police, who had surrounded the building. Inside the restaurant, Secret Service agents had been discreetly seated among unsuspecting restaurant patrons.

The queen and the duke of Edinburgh invited about 60 people, including Mrs. Reagan, the royal entourage and American staff members accompanying her on the visit, to a dinner of Indonesian lamb roast, listed on the menu at $18.75 a plate. The dinner was held in an upstairs, wood-paneled banquet area called The Trafalgar Room--the only part of the restuarant without Polynesian decor.

The White House reserved the banquet room early in the morning. Restaurant owner Victor J. Bergeron, who also has a Trader Vic's in London, has played host to other VIPs in San Francisco, including the late Eqyptian president Anwar Sadat and former president Jimmy Carter. Of the British royal family, "they know of him," said one of the waiters.

It was an impromptu thank-you dinner that the queen arranged for those on both sides of the Atlantic who have been involved in planning her trip. Among the guests were White House Social Secretary Muffie Brandon; Mrs. Reagan's staff director, James Rosebush; White House Deputy Chief of Staff Michael K. Deaver; British Ambassador Sir Oliver Wright and Lady Wright; the Duchess of Grafton; the queen's lady-in-waiting, her personal secretary and others.

Downstairs, regular diners got small paper British and American flags in their drinks, and waiters, when prodded, talked about the royal presence. Some said Nancy Reagan and the duke had waved to them as they arrived, but, said one, the queen hadn't. "She's queen, you know, and she couldn't do something like that," explained one waiter.

Earlier, when the queen checked into the St. Francis Hotel, she found the London Suite was already booked by some friends of hers, President and Mrs. Reagan, but she got one equally posh: the Presidential Suite, done up in red damask and fresh orchids. It is the queen's first night on shore, in yet another change in her rain-soaked tour..

A British consular officer said the decision to fly here was more a question of scheduling than a "bumpy passage" that the Britannia's passengers might have had to endure.

"If it was only a question of bumps, she might indeed have gone, but a combination of that and keeping to a close schedule forced the change," said Vice Consul John Houlton of Los Angeles.

The St. Francis, as an onshore haven for the British monarch, was in the contingency plans of British and American advance teams, but there were reports that the switch in signals had become a security nightmare. It was in 1975, as President Gerald Ford walked out of the St. Francis, that Sara Jane Moore took a shot at him.

Officials deny any security problems now, however, claiming that the Secret Service has the whole thing under control.

Certainly Secret Service agents are here in force, if those who crowded aboard a flight from Santa Barbara to San Francisco this morning, many of them in Levis and Adidas, are any indication. They nearly filled the waiting room at Santa Barbara Airport as they lined up to check in. The line moved slowly, since those with firearms had to declare them to airline agents.

At the hotel, British security was in evidence and taking precautions. By 2 p.m. today, one agent was overheard telling another, as they walked down a corridor, that the queen's suite still hadn't been secured.

But having contingency plans is part of the advance man's game. "On all stops, you have to have a rain plan," said Eric Rosenberger, a consultant hired by the White House to head the American advance team. "But we hadn't made all the preparations."

A British Embassy spokesman expanded on that. "I don't think we had a contingency plan for tornadoes. The visit was supposed to be a cheerful look at the West Coast, and once the weather changed, people simply got into high gear," said Charles Anson.

Air Force Two landed in San Francisco at 4:33 p.m. and taxied to an isolated area where the party, met by San Francisco Mayor Dianne Feinstein and Cyril Magnin, the city's 83-year-old chief of protocol, boarded a motorcade for the drive into the city. Dozens of police in yellow slickers roamed near the airport.

Feinstein said she greeted the queen and told her, "I apologize for the weather." She said the queen replied, "Oh, it doesn't matter. I'm so pleased to be here."

A crowd estimated by police at 3,000 people, including about a dozen protesters and a man with a 60-pound portrait of the queen made of jellybeans, greeted the party at the St. Francis Hotel.

The queen dispatched a letter to California Gov. George Deukmejian saying she and Prince Philip, "have been very saddened by the loss of life and damage caused by the storms in California and send our sincere sympathies to you and everyone in the state who has been affected."

With the unexpected arrival of the royal party, the St. Francis management had a discreet "no comment" on any aspects of the queen's stay that involved what she would eat and what her suite looked like.

"All I can say is that, as does any well-respected hotel, the St. Francis has contingency plans," said a spokeswoman who could not reveal her name. "Heads of state have been staying here since 1904. The last monarch was the emperor of Japan in 1975."

The St. Francis is also the hotel where President Nixon stayed in 1969 and where he entertained South Korea's President Chung Hee Park at a state dinner. That night, in Union Square across the street from the St. Francis, thousands of demonstrators gathered to protest the Vietnam war with chants of "Ho Ho Ho Chi Minh."

This time it's Irish Northern Aid (Noraid), threatening to disturb the peace. Mayor Feinstein told local Irish activists today she would try to give the British monarch a 1978 Amnesty International report about Britain's mistreatment of Northern Ireland prisoners.

President Reagan, who is scheduled to arrive Thursday, won't go unnoticed either. In another scheduled protest, about 600 of the city's destitute are expected to turn up Thursday night at the San Francisco Civic Center in tuxedos, ruffled shirts and cummerbunds--and dine on hot dogs. The fancy duds were distributed this week by the Rev. Cecil Williams, of Glide Memorial Church, as a way of drawing attention to the contrast in life styles between rich and poor.

At one point today the White House was considering yet another change in the queen's schedule, which would have taken her, Prince Philip and Mrs. Reagan down a San Francisco peninsula to Alviso, near San Jose, where about 2,000 residents were left homeless after a levee on Coyote Creek burst. That inspection trip was ruled out, however, because it was beyond the perimeters established by security officials.