An unusual alliance of manufacturers and environmental groups has formed to try to prevent what for many people around the world would be a disaster of gigantic proportions: a shortage of chocolate.

For while the world's appetite for chocolate grows more voracious each year, cocoa farms around the globe are failing, under siege from fungal and viral diseases and insects.For decades, cocoa farming has escaped such problems by moving to new areas in the tropics, even new countries or continents, where growers find more rain forest to establish cocoa farms.

But now they are running out of new forests to turn to. Researchers predict a shortfall in beans from the cacao tree, the raw material from which chocolate is made, in as little as five to 10 years.

"We're running out of places in the world" to plant cocoa, said Carol Knight, vice president of scientific affairs at the American Cocoa Research Institute, a nonprofit group that tracks cocoa bean supply. "We have to figure out how to grow it sustainably. Nobody wants to lose chocolate."

To that end, representatives from the Mars, Cadbury, Nestle and Hershey chocolate companies met with conservation groups last month at the Smithsonian Tropical Research Institute in Panama to talk about strategies for sustainable farming.

Sustainability is a broad notion that includes keeping farms partially forested to preserve biodiversity, farming without large doses of pesticides, fungicides or fertilizers, and replanting rather than abandoning farms.

For cocoa, researchers say, sustainability will require a shift away from the large plantations carved out of the rain forests to the smaller farms where cacao trees are grown in the shade of larger trees. Plantation trees, exposed to the sun, require more fertilizer, fungicide and pesticide, and are at greater risk of the spread of pests and disease.

For conservation advocates, this is all good news. A shift away from plantations could prove a boon to small farmers and help preserve rain forests and the many plant and animal species that appear to flourish in the natural environment of a cocoa grove.

But the task of designing the small-scale cocoa farm of the future is daunting because little is known about how best to grow the trees.

The cacao tree evolved in the New World tropics under the shade of taller trees. After six years or so, the slow-growing tree produces fruit, large pods about the size and shape of a small football that contain about 40 cocoa beans, each the size of a lima bean. They can be roasted, ground and mixed with sugar and milk to produce chocolate.

But for reasons that researchers say they do not yet understand, the cacao tree seems particularly vulnerable to pests. Walter Rodriguez, president of a cocoa-growing cooperative of small farmers in Costa Rica, speaking through an interpreter, said that in Costa Rica, the fungus monilia has been a devastating problem.

"In 1978, '79, when monilia came," he said, "the trees remained but the harvest disappeared." In West Africa, black pod disease, a cousin of potato blight, can cause crop losses of up to 80 percent in a wet year.

"There are diseases in South America that are threatening to wipe out the industry there," Jim Gockowski, an agricultural economist at the International Institute of Tropical Agriculture, said by telephone from Cameroon. "And the rest of the world if they spread."

Once disease strikes, trees not only produce fewer beans but beans of less quality and, some say, poorer flavor. In hopes of increasing production, some farmers, like those in Malaysia, have planted hundreds of acres of trees on cleared land, but the trees, bereft of shade from taller trees, appear to be far more vulnerable to diseases and pests.