TO the east and west of the irrigated green of the Imperial Valley stretch vast expanses of desert. Nothing but a few stubby concrete markers indicate the international border of Mexico and the United States.Bumping along that imaginary line in four-wheel drive, US Border Patrol Agent Rick Lopez scans for disturbances of the sand. Agents regularly grade smooth a six-foot swath for miles along the border so that fresh footprints can easily be seen. Out in this barren region, the odd human footprints among the snake tracks and scurry marks of rodents are always headed north and indicate one thing - a desperate illegal entry into the US. The uninterrupted desert, like a cruel mirage, can seem to be a quiet, back-door route to the US. But between here and the job mecca of Los Angeles are 180 miles of desert, a lot of snakes, no water sources, and a couple of military bombing ranges. And, if that weren't ordinarily dangerous enough, the temperatures at this time of year - 110 F. dry degrees on a normal day - make the desert quite deadly. Every summer here has its casualties, and this one is no exception. Last month a 27-year-old Mexican man died in the heat after swimming the treacherous All-American Canal and trekking 40 miles across the desert without enough water. "When the temperatures turn from hot to hell down here in mid-July to September, our agents take on a different attitude... . They know someone is in danger [when tracks are headed into the desert]. The job shifts from enforcement to humanitarian," explains Johnny N. Williams, chief patrol agent for the region. His agents apprehend about 35,000 illegal immigrants annually in the region. Those apprehended on the open desert are a small, but no less worrisome, percentage of the total. The deadly chance that undocumented aliens take on the desert was tragically headlined in July 1987 when 18 Mexican men died in 130-degree F. temperatures inside a railroad car sealed after they had hitched it along the Texas-Mexico border near El Paso. It is not uncommon for illegal immigrants to die singly, without publicity, in just as gruesome circumstances, Mr. Williams says. And many more cases of near-deaths - of desperate immigrants carrying babies or leading elderly grandparents across the desert, never with enough water to survive - are a part of Border Patrol lore. This is a side of the Border Patrol's work that often gets overlooked in the controversies that surround US immigration law. The image of the uniformed and armed border enforcer versus the timid and poor masses of job-seeking immigrants is a distorted and unfair image, agents frequently remind reporters. Indeed, in this region the Border Patrol has been under fire for an agent's shooting of a Mexican youth on the border fence last fall. The case is still under investigation, but Border Patrol officials privately point to the youth's record of more than 24 US arrests, suggesting a strong precedent for behavior that might have elicited the shooting. That incident is at odds however with most immigrants' feelings about la migra, as US agents are known. Interviews with illegal immigrants indicate that they have little fear of abuse from Border Patrol agents. Ironically, the Border Patrol's rescue activities often put the agency in the peculiar role of advocate for illegal immigrants. Immigrants in distress in the desert "is such a critical problem that we make signs up in Spanish to distribute in the [Mexican] desert," says Ed Riley, a Border Patrol intelligence agent. The signs, as well as pamphlets handed out at bus stations, warn immigrants that two to three gallons of water per day are necessary to survive the desert heat. Williams also notes that the Border Patrol has lobbied for hand holds and scalloped or staircased banks to be included in any renovation of the All-American Canal, which parallels the border to bring Colorado River water to the Imperial Valley. In rural border areas, old-style Indian-tracking techniques are part of the everyday work of Border Patrol agents. On an evening ride with Mr. Lopez through the border town of Calexico, a Mexican man jumped the border fence and bolted into the dark. Lopez only had to examine the swath of graded soil along the border to see the fresh footprints and find a characteristic circular marking at the toe of the shoe print. So when he crossed the nearby border highway, Lopez could identify the shoe prints among many other footprints on the shoulder of the road. The agent could then see from the footprints that the immigrant had darted left toward a field where the trail became an easy-to-follow path of bent alfalfa. The quiet capture of the out-of-breath immigrant took less than 10 minutes. But on the open desert, tracking can take longer - perhaps even days at a time, says Lopez. As a trail disappears, agents must search out the logical places for it to reappear. N the case of the immigrant who died last month, agents knew time was of the essence. When agents found a cluster of footprints - indicating a group of perhaps 20 people - near a barren stretch of Interstate 8 east of here, they were able to tell that the group had passed sometime since the last Border Patrol check for footprints and may have had time enough to get deep into the desert. With temperatures during daylight hours steadily in the triple digits, agents also know that the group could not be carrying the amount of water they needed to survive even a day. Instead of simply following the footprints, airplanes were used to help agents leapfrog along the trail. This "sign cutting" can save hours of searching for prints. Even so, Mr. Riley says, when the Border Patrol agents finally spotted the group of immigrants, they were too late. "The people were looking for help and water," he says, and they led agents to the man who had died just before any agents arrived. Riley says that documents found on the dead man indicate he had been caught and returned to Mexico by Border Patrol agents just 24 hours earlier and 40 miles southeast of where he died. "It's a treacherous journey, but basically they're going to come no matter what happens - they have their needs," he observes.