The nation's top soldier left office yesterday with the warning that it would be throwing money in a "bottomless pit" to try to prepare the United States for a long nuclear war with the Soviet Union.

Gen. David C. Jones, chairman of the Joint Chiefs of Staff for the last four years, said he doubted that any nuclear exchange between the Soviets and the United States could be contained, but would escalate into an all-out war.

Rather than spend the billions of dollars it would take to prepare the nation for a protracted nuclear war, Jones said, it would make more sense to build up American forces for more likely non-nuclear conflicts in distant trouble spots.

"I don't see much of a chance of nuclear war being limited or protracted," said Jones, who has pondered various doomsday scenarios during much of his 40 years in uniform. "I see great difficulty" in keeping any kind of nuclear exchange between the United States and the Soviet Union from escalating.

Defining "protracted nuclear war" as one lasting "weeks or months," the 60-year-old four-star general said: "If you really put a lot of emphasis on it, you've got a bottomless pit in terms of dollars."

He said that even if one were to say " 'I'm going to do everything to try to fight a protracted nuclear war,' the resources for that are too great" even if the Reagan administration achieves its goal of increasing defense spending by 7 percent a year after allowing for inflation.

With that increase, he said, "We're going to have a hard time doing what is already on the books. We are in the priority business. We have greater needs" than trying to prepare the United States for protracted nuclear war, needs such as paying for the forces and weapons needed to rush to distant trouble spots.

His contention that there is not enough money in sight to gear up for lengthy nuclear wars came in response to questions about the guidance Defense Secretary Caspar W. Weinberger recently issued to the military services to help them structure their forces in the five-year period from fiscal years 1984 through 1988.

In a headline May 30, The New York Times portrayed the guidance as the "first strategy for fighting a long nuclear war," and said in an accompanying article that the Reagan administration was embarked on a "new nuclear strategy."

The Times report brought a public protest from the Soviet Union and denials from U.S. officials that waging protracted nuclear war is "something that we are planning to do." Officials also said there was little new in the guidance.

At a briefing, a high Pentagon official, who could not be identified under the ground rules, said:

"The important thing to bear in mind here is that no one is suggesting in this guidance that a protracted nuclear war is a good thing, a desirable thing, something that we want to do, something that we are planning to do. But the capability of dealing with a protracted attack upon us is important to develop, because if we develop the capability . . . , we can hope to deter it.

"We can hope to prevent it from ever coming. What was being said at that point in the guidance was that we may face a protracted nuclear war; that the capability seems to be there on the other side; it is therefore vital that we try to develop a capability that can be perceived correctly as being able to deal with this kind of ghastly situation . . . . We would be derelict in our duty if we did not plan to meet this kind of possible attack."

Jones said yesterday that he considered the Weinberger guidance "evolutionary" rather than "revolutionary." He said the big decisions that would be required to prepare the United States for protracted nuclear war, such as a massive civil defense program, have not been made.

What the United States has done so far to prepare for limited and/or protracted nuclear war includes giving missile-launching systems the capability to respond in kind to a Soviet attack--such as firing only a few warheads at strictly military targets--and hardening communication links so that the president and other decision makers could keep in touch with military commanders during a nuclear attack.

James R. Schlesinger, defense secretary from 1973 to 1975, pushed the development of missile-firing systems for limited nuclear war. Shortly before leaving office, President Carter issued directives calling for improved command, control and communications for nuclear war and the targeting of Soviet decision makers and military targets.

Presidential Directive 59, issued in 1980, stressed that the Soviets should not be allowed to win either a conventional or a nuclear war for want of adequate U.S. responses. President Reagan has built upon that concept in his five-year strategic program, partly by allocating more money than his predecessors for command and control equipment needed to wage nuclear war.

The Weinberger guidance for structuring the armed forces for fiscal 1984 through 1988 includes these statements about protracted nuclear war:

"Should deterrence fail and strategic nuclear war with the U.S.S.R. occur, the United States must prevail and be able to force the Soviet Union to seek earliest termination of hostilities on terms favorable to the United States. This requires:

"Forces capable, under all conditions of war initiation, of attacking a wide range of targets, even when retaliating to a massive strike received without strategic warning . . . .

"Employment plans that assure U.S. strategic nuclear forces can render ineffective the total Soviet, and Soviet allied, military and political power structure through attacks on political/military leadership and associated control facilities, nuclear and conventional forces and industry critical to military power . . . .

"Forces that will maintain, throughout a protracted conflict period and afterward, the capability to inflict very high levels of damage against the industrial/economic base of the Soviet Union and her allies so that they have a strong incentive to seek conflict termination short of an all-out attack on our cities and economic assets.

"U.S. strategic nuclear forces and supporting" communications, control and command systems "capable of supporting controlled nuclear counterattacks over a protracted period while maintaining a reserve of nuclear forces sufficient for trans- and post-attack protection and coercion . . . ."