Agriculture Secretary John R. Block yesterday announced a program to take up to a fifth of the nation's wheat land out of production to bolster sagging prices and reduce a mounting surplus of grain.

But wheat growers said the program would not work, while consumer groups charged it would drive up food costs.

Block also said again that he favors negotiating a new grain sales agreement with the Soviet Union, even though other administration officials have said this is politically impossible as long as the Soviets continue to support martial law in Poland.

Short of a new agreement, Block suggested extending the expiring one but for larger amounts than now provided. The Soviets are major buyers of U.S. grain, and financially strapped U.S. farmers have been pressing the administration to expand the present agreement.

The Senate yesterday passed a nonbinding resolution urging the Reagan admnistration immediately to resume talks with the Soviets on a pact, and House Minority Leader Robert H. Michel (R-Ill.) said he had urged Reagan at least to extend the current agreement "with some raised limits."

Under the program announced yesterday, farmers must set aside 20 percent of land they have traditionally used for wheat in order to be eligible for federal income-support payments and crop loans. As a further enticement, participants will be offered advance payment of half their support payments.

This year's program called on wheat farmers to leave fallow 15 percent of their land and offered no advance payment.

The income-support payments made to wheat farmers next crop year will be the difference between the market prices they receive and a target price set by law at $4.30 a bushel.

Wheat is selling at about $3.20 per bushel, down from $3.55 last July, according to the National Association of Wheat Growers.

Record wheat harvests and resulting low prices have been a persistent political and budgetary problem for the administration. For two years in a row it has tried to limit production despite its professed preference for free markets. Experts anticipate another record crop this year.

Agriculture department officials predicted that the advance payments--estimated at 25 cents per bushel--could put up to $400 million in the hands of cash-hungry farmers who might receive the money as early as September. Block said that he expected the program to take between 6 million and 10 million acres of wheat out of production.

Block also announced $300 million in guaranteed loans to countries that want to buy American grain, raising available credit to $2.8 billion.

Block contended that the set-aside program would have only a "negligible" effect on food prices because of an enormous wheat surplus and because farm costs--as opposed to the costs of food processing and transportation--account for relatively little of the food dollar.

But Ellen Haas, director of the Community Nutrition Institute's consumer division, argued that "there is no way" the set-aside program won't drive up prices. "The simple law of supply and demand means that the more you cut back in acreage, the higher prices go," she said.

Farmers' groups criticized the program for not going far enough to help wheat growers.

"It's better than no program, that's for sure, but the effect is not as significant as it could have been," said Margie Williams of the National Association of Wheat Growers.

Charles Frazier of the National Farmers Organization said the group would encourage its members to participate, but said the program "will not produce profitable prices" for wheat growers.

"Our farmers are all going broke out there in the country," he said.