The federal program that was designed to do away with massive rice surpluses is working so well that the government is under pressure to let farmers boost production to avoid rice shortages in 1988.

Rice shortages? It seems almost unimaginable. Less than two years ago surplus rice stocks were jamming U.S. warehouses. Even so, U.S. prices were uncompetitively high and, as a result, a four-year slide in exports continued. Farmers despaired.

But today the surplus has essentially disappeared. Drought in Asia and a new federal program that put tens of thousands of tons of U.S. surplus on the world market at bargain rates have combined to tighten the supply-demand picture and send prices sharply upward.

The turnaround in rice is due in part to a sharp shift in U.S. farm policy laid out by Congress in the 1985 farm bill -- in effect, a subsidize-and-dump approach aimed at making American rice, cotton and honey producers competitive in the world market through a device called a "marketing loan."

Although costly to the Treasury and criticized as predatory, the idea is to help U.S. farmers regain lost export market shares by forcing commodity prices down and discouraging lower-cost or subsidized foreign competitors. As part of the deal, the government does not acquire unsold surpluses.

The early apparent success of the marketing loan for honey, rice and cotton -- all three have made dramatic gains on world markets -- has been such that some members of Congress have put intense pressure on the administration, without success, to allow marketing loans for other commodities.

The tight rice supply situation has set off a lobbying battle for the heart and mind of Agriculture Secretary Richard E. Lyng, who soon will announce details of a 1988 rice-support program that will influence farming and marketing decisions around the globe.

With the government of Thailand heavily involved in the jousting, the rice program is another example of increasing multinational sensitivity over efforts by the United States to regain shares of world agricultural markets.

Players in the rice skirmish include farmers, lawmakers, rice millers, the Office of Management and Budget and Thailand -- all of whom are debating how much land Lyng should require rice farmers to withhold from production next year. Farmers' subsidies are tied to acre-idling requirements.

The Agriculture Department attempts to match supply with demand, and yet hold down spending on the rice program, by regulating U.S. output through an acreage reduction program (ARP). This year's program required farmers to retire 35 percent of their rice land to get their subsidy payments.

But Lyng is walking something of a regulatory tightrope, made trickier by the imponderables of statistics and weather. If production is curbed too much, supplies could diminish but government outlays would be held down too. If too much production is unleashed, government subsidy costs could go up and world prices could be driven down.

Part of the argument is over whose crop statistics are more reliable. The USDA is projecting that supplies will be tight but adequate in 1988. The millers, who make money by milling and storing rice, contend that the world supplies will be so tight that Lyng should cut the ARP to 10 percent and let farmers produce more.

Farmers, contending that supply balance has been achieved, are urging the secretary to continue the ARP at 35 percent. The OMB, concerned about high budget costs of the rice program, is reported to be pushing strongly for a large ARP to hold down spending. Greater production would bring with it higher subsidy payments to farmers.

The marketing loan was designed to lower prices and yet maintain farmers' incomes through government payments. While subsidy payments go up, government storage and interest costs come down as surpluses are eliminated by putting all rice on the market. In addition to direct subsidy payments, rice growers keep the difference between the U.S. loan rate and the world price.

Under a traditional loan program, the government would set a loan rate for the rice, $4 a bushel, for example. If the farmer could not sell the rice for that much he would forfeit the loan. The farmer would keep the borrowed $4. The government would keep the rice and be responsible for handling it, storing it and eventually selling it.

Under the new program, the government sets a loan rate, say the same $4 a bushel. The farmer, however, must sell the rice. If he can sell it for only $3, he will receive from the government the $1 difference between the sale price and the loan rate. The government incurs no handling and storage costs.

According to USDA calculations, in addition to his sale price the average farmer receives about $335 per acre in direct subsidy and the difference between the U.S. loan and the world price. Government costs have been close to $1 billion for each of the first two years of the program.

Although the five-year cost of the marketing loan program is expected to be about $700 million more than a traditional price-support loan program, analysts argue that the difference will be made up for in additional port and industry jobs, export income and tax revenues, as well as lower consumer costs.

Critics of the marketing loan, including Thailand, charge that it is in effect a "dumping" program that runs counter to expressed U.S. policy by flooding the market with rice while subsidizing production at home.

Thailand, the world's leading rice producer and exporter, argued heatedly last year that the U.S. program would hurt its farmers by cutting their income and market dominance. Thailand argues that the program reduced farmers' income by $600 million in 1986, even though a major drought this year helped push prices back up. Rice, grown on roughly half of its cropland, is a key element in the Thai economy.

"Increasing U.S. planting acreage when the Thai rice crop is expected to return to normal levels would result, once again, in oversupply and depressed prices," warned a Thai Embassy position paper circulated at USDA and on Capitol Hill. "This would hurt Thai and U.S. farmers and prove costly to the U.S. government and taxpayers."

The scenario is unfolding almost precisely as rice-state legislators predicted when they convinced Congress to adopt the new marketing loan idea. While expensive for taxpayers, it was intended to make rice more competitive and to rid the government of the huge costs of acquiring and storing unsaleable surplus.

"Our rice program is working, even though it has had a big up-front cost for the taxpayer, just as we all knew it would," said Sen. David H. Pryor (D-Ark.), one of the champions of the marketing loan. "But the budget exposure of the program is lessening and there is a new optimism among farmers that I have not sensed in the last 10 years."

"Bad weather abroad and the declining dollar have had a strong impact," Pryor added, "but the program is beginning to put money in the farmers' pockets. . . . Now, the buyers are calling the farmers and they are being mighty nice -- and that's a change. . . . But we must be careful about overproduction or we'll get right back in that same surplus situation."