HELSINKI, OCT. 21 -- Soviet leader Mikhail Gorbachev is weighing the length of a brief trip to the United States later this year if this week's negotiations with Secretary of State George P. Shultz succeed in producing agreement on a U.S.-Soviet summit, a member of Shultz's party said today.

Shultz left Helsinki for Moscow on a hastily provided overnight train because of unusual and persistent fog that has closed down Moscow's airports for three days.

In a news conference shortly before leaving here, Shultz said with a smile, "I hope we will be able to get to Moscow," whether by train or on his U.S. Air Force jet. He appeared optimistic that the remaining issues standing in the way of a summit meeting could be resolved.

A senior U.S. official said Gorbachev's decision about how long to stay in the United States, and thus how much of his prestige to invest in the summit, is likely to depend in part on his assessment of the ratification prospects of the proposed U.S.-Soviet treaty banning medium- and shorter-range nuclear missiles. A member of Shultz's party said Gorbachev was weighing a trip of one, three or five days' duration.

If the ratification prospects for the pact, called an intermediate-range nuclear forces (INF) treaty, appear doubtful, Gorbachev is likely to choose a one-day, all-business visit to sign the treaty with minimal ceremony, an official said.

Brighter INF prospects could bring Gorbachev to Washington for a three-day visit that would include more extensive meetings with President Reagan aimed at major progress toward a U.S.-Soviet strategic arms limitation treaty and other accords in the final year of the Reagan administration.

A five-day visit, the official said, is likely to include travel around the United States and far more extensive U.S. and international media exposure for the Soviet leader. Even this option would be far short of the memorable 13-day tour in 1959 by Nikita S. Khrushchev, the first Soviet Communist Party leader to visit the United States.

In his news conference, Shultz said, "We've settled all the issues of principle" for an INF agreement. He added, however, that operational arrangements about how the treaty is to be applied and verified remain to be completed.

Officials in the Shultz party said it is unlikely that a final text of the extensive treaty will be completed by the time Shultz and Soviet Foreign Minister Eduard Shevardnadze finish their discussions in Moscow late Friday.

If all substantial issues are ironed out, however, U.S. officials said they hope that the Soviets will agree to approve the Reagan-Gorbachev summit without another high-level meeting.

In his news conference, Shultz strongly defended U.S. actions in the Persian Gulf since his last meeting with Gorbachev. He said the United States should "get a gold star" for attacking an Iranian ship that was laying mines in the Persian Gulf and declared, "We will protect our interests."

He also said he plans to talk to Shevardnadze and other Soviet leaders about the situation in Cambodia, which shows promise of diplomatic movement, and about Korea, especially prospects for peaceful 1988 Olympic Games.