Despite more than 2,000 miles of shared border, multi-billion-dollar yearly trade, similar geopolitical outlooks and the fact that millions of Mexican citizens live north of the border, Mexico and the United States do not often speak kindly of each other.

To Mexicans interviewed here over the past several weeks, in advance of President Carter's visit here beginning Wednesday, the United States is a neighbor that has fostered and maintained an unequal relationship based on exploitation, greed and lack of sensitivity.

To many Americans, Mexico complains too nuch and blames the United States for the fact that it is underdeveloped and disorganized, overpopulated and cannot compete in the world marketplace.

Beneath the stereotypes and rhetoric, however, a new factor -- Mexican oil -- has entered the relationship. At least on the southern side of the Rio Grande, there is hope for a change.

Domestically, Mexico hopes that oil income, expected to reach $5 billion next year, will enable it to diversify its production and reach a steady annual growth rate of 8 to 10 percent until at least 1990.

"By that time," industrial development director Ernesto Marcos said, "we can solve the unemployment problem" that affects at least 40 percent of Mexican workers.

Mexico realizes that its vastly overprotected, capital-intensive industry will have to change. High growth rates in the late 1960s and early 1970s meant little more than making the rich richer, until the entire system came crashing down with high inflation and devaluation of the currency in 1976.

Attainment of domestic goals of oilpaid production increase and full employment, as well as continued political stability, will be enhanced significantly by international cooperation in finding new markets for Mexican goods. Continued opportunities for unemployed Mexicans to work in other countries -- specifically the United States -- also will contribute to Mexican stability, at least for the foreseeable future.

To Mexican President Jose Lopez Portillo, it all boils down to a simple equation. If the United States wants to buy Mexican oil and natural gas, it must be prepared to discuss the three major aspects of U.S.-Mexican relations -- energy, trade and immigration -- as a package.

"Of course, it's impossible to link [immigration] and oil directly," Lopez Portillo said at a news conference Friday. "The risk we run if we state problems in a simplistic way is that it seems that we are practicing blackmail.

"But I believe both fall within the same general framework... The migratory problems will be resolved as we strengthen our economy.

"We do not believe that [migrants] and oil should be points of contention" with the United States, Lopez Portillo said. "But rather, oil should be used to finance development, and the creation of jobs and the solution to the migrant problems. If we associate this with the trade problems that are facing this country, this is to view the problems as a package."

Lopez Portillo speaks in general terms rather than specifics, but by indicating what he expects out of President Carter's visit, he is putting some of his own political prestige on the line.

There is heavy sentiment in Mexico against any oil or gas deal with the United States, which leftist political groups denounced last week as "the greediest and most aggressive power in history."

Intensely nationalistic about their energy resources, and convinced that illegal aliens are abused and mistreated, independent labor unions demonstrated here last Wednesday to the chant of "Don't send our oil north" and "Carter, we're not for sale."

Lopez Portillo, however, clearly knows that Mexico's trade relationship with the United States -- which now buys 70 percent of Mexico's goods -- is unlikely to diminish. His problem is getting better conditions for that trade while he is able and convincing the Mexican public he has struck a shrewd deal.

"The president has a real dilemma," said political analyst Mario Ojeda of El Colegio de Mexico, a leading university. "On the one hand he feels he has to obtain economic benefits from the United States to increase the standard of living here. But he also knows there are certain limits to the trade-offs he can make."

Carter reportedly wants what Lopez Portillo wants -- a stable, productive and growing Mexico that can be counted on to contribute steadily to the pool of petroleum for sale in the world.

The problem is obviously whether Carter can contribute what Mexico feels should be Washington's part of the bargain. The Mexican demands are not only high, but, in the eyes of many U.S. officials, based on inaccurate interpretations of U.S. policy.

On the trade issue, Lopez Portillo has said, "What is of interest to us is that trade be organized in a reasonable manner with time periods of sufficient length to guarantee us the terms and to avoid sudden shifts in customs regulations... that often cause failure for our attempts to export."

Basically, Mexican exports to the United States are controlled in two ways. One way, primarily applied to agricultural products, is through quality and packaging controls.

The Mexicans complain, for example, that their exports of tomatoes to the U.S. winter market are controlled by competing Florida tomato growers, who in the absence of any other concerned group, dictate Agriculture Department policy Thus, Mexican producers charge, tomato size and quality controls are changed at the whim of U.S. growers, often leaving wrong-sized Mexican tomatoes, grown under last year's standards, to rot.

The other way trade is controlled is through tariff and quota regulations.

Mexico says both the quotas and tariff restrictions are unfair because they do not take into account the volume of U.S.-Mexican trade, or the areas in which Mexico is trying to expand.

For example, industrial production director Marcos said, "We have built a factory for wool suits. We're convinced we could substitute for European suppliers in the United States. We now have the machinery to produce 100,000 suits a year. But what is our quota? Two thousand."

"We even have quotas, for maquiladoras ," south-of-the-border U.S. assembly plants that use cheap Mexican labor. In those that manufacture clothing, he said, "the fabric is not Mexican, not even the thread is Mexican. We just sew things together, yet it all goes on our quota," and does nothing to develop Mexican industry.

What Mexico wants, Marcos said, is a comprehensive U.S. trade policy for Mexico that is not dictated by a thousand small pressure groups.

"If you talk about tomatoes, there is somebody who makes tomato policy," he said. "The same with suits. But what if you talk about Mexico policy? With so much U.S. interest [in Mexico] it's impossible that they can't look at it as a whole."

Whether Carter, who must answer to those pressure groups as well as to other U.S. trading partners, can guarantee a change and special attention to Mexican needs, however, is questionable.

The third issue -- immigration -- provokes strong emotion here. As many as a million illegal immigrants cross the Mexican border each year. In the United States, where many believe the illegal Mexicans take jobs away from Americans, there is considerable pressure to seal the frontier.

"The only measures I could take," Lopez Portillo said in a recent interview, "would be physical measures, police measures, which I categorically refuse to contemplate. It is not a crime to look for work, and I refuse to consider it as such."

The best Lopez Portillo can hope for, analysts here said, is a continuation of the status quo, with U.S. border patrols, either through design or ineptness, catching a small percentage of Mexicans and tacitly allowing the rest to cross.