It was 1973 in Maceio, Brazil, and thousands of people had gathered at the port to send off the hospital ship that had brought American doctors and technology to help them. But Dr. William Walsh's ship, the renowned S.S. HOPE, was out of gas.

The 1970s energy crunch was in full force, and in desperation, Walsh turned to the president of Brazil, who at the last minute provided a tanker with 10,000 barrels of fuel. As the nervous Bethesda doctor watched, the fuel transfer was made while the farewell ceremonies went on.

"They were loading the ship right there with thousands of barrels of fuel, and with all those people waving goodbye . . . . Well, if you think we could tell them all to stop smoking, you've got another thought coming," he said with a laugh. "It was terrifying."

The episode was only one of dozens of exciting and gratifying experiences Walsh has found in the nearly 30 years he has headed Project HOPE, an organization that has served as a sort of medical peace corps to developing countries around the world. On Tuesday, he was honored for his work when President Reagan awarded him the Presidential Medal of Freedom.

Walsh, 67, a heart specialist with a thriving practice, was a medical officer aboard a destroyer in the Pacific Ocean during World War II when he saw the need for health care in the island nations he had visited.

"I could see that most of the indigenous population had never experienced modern medical care as we knew it then," he said. "Many of them had never even seen a doctor in their lives."

Some of the problems, such as vitamin deficiencies, were relatively easy to treat. But others required some ingenuity. "Barbasol shaving cream was great for treating a tropical ulcer," he said. "They thought it was a miracle!"

He started Project HOPE (Health Opportunity for People Everywhere) in 1958 after persuading President Eisenhower to donate an unused Navy hospital ship.

Fuel shortages and the cost of replaceable parts for the old ship finally made it necessary to retire the HOPE in 1974. But the organization, which now operates out of Millwood, Va., with an annual budget of about $40 million, continues to work throughout the world and on the United States' southwest border offering medical technology and training to doctors and nurses from countries that ask for it.

Currently, Project HOPE operates in Egypt, Poland, Portugal, Swaziland and in every country in Central America except Nicaragua. It has worked extensively in Africa and the Caribbean, and it runs the only school of hospital administration in China.

In the ceremony at the White House Tuesday, Reagan said: "William Walsh has spent a lifetime giving hope to others. For 14 years in ports around the world, millions cheered the {S.S. Hope}. Medical care and training -- these were the cargo that it carried."

Others, including Ecuador's ambassador, Mario Ribadeneira, have praised Project HOPE as a "good example of humanitarianism."

"It does not just offer a rhetorical commitment to provide help, but is an actual and effective relief program," he said.

Funding for HOPE's work comes from private donations and the annual HOPE ball in Washington.

The heart of Project HOPE's philosophy is that medical teams from the organization visit a country only when they have been invited, and they do not see themselves as a charitable organization.

"We only go if you're willing to help yourself," Walsh said. "No matter how little you have to share in this program, we're working with you, not for you. We're not a charity throwing stuff at you. You become a partner, and if we're doing something you don't like, you can tell us."

Walsh is surprised at the reaction of people who cannot understand the willingness of his crew to work without pay.

"They are doing what what they really went to medical school for. They are honestly out there to save lives, and to teach people to save their own lives," he explained.

Walsh, whose father was a doctor during the Depression, said, "Medicine was a very personal thing for me."

In the days before Blue Cross and Blue Shield, "I spent three days a week in the clinic taking care of people who couldn't afford to pay for medical care, and I just assumed that it was my obligation."

Walsh said he is "compulsive" about working and has been involved in every one of HOPE's projects around the world but tries never to be away from his family for more than a few months at a time.

Walsh and his wife Helen have lived in the same house in the Sumner area of Bethesda for 30 years.

Walsh says his family has always been supportive of his career decision, and eventually two of his three sons became involved with what they call the "family business."

Walsh said of his work: "It is, of course, enormously satisfying to be able to help people, and I have also been very lucky. With the use of the ship in particular we were able to help focus the attention of the western world on the need for international health care."

Ambassador Ribadeneira agreed, adding: "There is, in my opinion, little knowledge of what Latin America is all about among many Americans. What is valuable about a project of this nature is that they can see the problems there and also the opportunities."

CAPTION:Walsh received the Presidential Medal of Freedom fof Project HOPE work.