President Carter took a short train ride to the gritty industrial heartland of Maryland today and spent the morning stumping for his energy programs and doing a litle old-fashioned ethnic politicking on the side.

At each of his two main stops, first in a poor, predominantly black East Baltimore community and then at the national convention of the Sons of Italy, Carter rieterated his call to arms, asking for unified national support "to win the energy war."

At the same time, from the moment he stepped off Amtrak's 8:38 Metroliner inside the dingy, tiled halls of Pennsylvania Station, Carter showed a campaingner's eagerness to feel the touch of a crowd's hands.

After touring a solar-powered East Baltimore home and inspecting a nearby school that is being converted into apartments, Carter and his wife, Rosalyn, spent five minutes crisscrossing a single inner-city intersection, shaking hands and waving as a ripple of cheers followed them.

The campaign flavor of the six-hour trip was enhanced later when Carter, speaking to 1,100 members of the Sons of Italy, praised the ethnic diversity of "this American mosaic" and introduced his traveling companion -- Atorney General-designate Benjamin Civiletti, retired federal judge John Sirica and Rep. Rario Biaggi (D-n.y.).

Then after paying his respects to ethnic diversity in general and Itallians in particular, Carter returned to his central theme of the past weeks: the nation's energy woes and how to cope with them.

He rebuked Congress for not advancing his energy initiatives, saying the legislators "have yielded to the narrow interest on energy issues time and again."

The presindent then asked the national gathering at the downtown Baltimore Hilton to pressure their congressmen to enact "a strong windfall profits tax" on oil company profits. "America needs the revenues from that tax to finance a vast effort to increase energy conservation," he said.

These familiar refrains were punctuated with presidential declarations of support for mass transportation systems -- "trains represent the future and not the past in America transportation" -- and for solar energy.

During his morning tour in East Baltimore, Carter stood before the solar-powered home of 30-year-old city clerk Genitha Rhyne and declared that solar heating systems "are going to be all over the nation in the future." Reerring to the organization of Petroleum Exporting Countries, he said, "There's no way for them to embargo the sun."

The statement evoked a brief wave of applause from the predominantly black crowd of about 800 people, but throughout Carter's short address in the hot sun, the enthusiasm of his audience seemed muted.

A number of Maryland politicians were sharing the spotlight with the president, including such Democrats as Baltimore Mayor William Donald Schaefer, Gov. Harry Huges, Sen.Paul Sarbanes and Rep. Parren J. Mitchell and Republican Sen. Charles McC. Mathias.

But of all of them, Carter had public praise only for Shcaefer, who endorsed a 1980 Carter presidential candidacy about six weeks ago. "You've got a great mayor in Don Schaefer," said the president, who sported a large yellow "Baltimore is Best" button on his lapel for most of the morning.

He then went on to praise, at some length, the city's housing programs and its most recent "weatherization" programs, which have employed government-paid CETA workers to insultate homes for an average cost of $275.

Carter's decision to ride the train came as a surprise, and even when word leaked out in advance, the White House refused to confirm it until the last moment, apparently for security reasons.

He rode on a regularly scheduled train, but all the seats in one car were bought up for the president and his entourage. Most reporters rode buses to Baltimore.

Carter returned to Washington by train in the early afternoon, after a lunch of chicken cacciatore, salad and spumoni in Chiapparelli's Restaurant in the Little section.

At the close of the meal, flanked by former mayor Thomas D'Alesandro Jr. and City Councilman Dominic (Mimi) DiPietro, Carter stepped out onto the restaurant's small second-floor balcony and waved and blew kisses to a crowd in the narrow street.

"He said to us, 'Mayor, Mimi' -- he called me Mimi -- 'take me out to the balcony,"' DiPietro recalled a few minutes later as he held court in nearby Sabatino's restaurant.

"I sat next to Rosalynn too," said the broad, squat politician as he lit a cigar. "I got to kiss her," he added.

"What do you think he was going to say," a companion down the table roared. "No? Get away?"

The raucous laughter rose and fell as DiPietro, a favorite in this part of town, continued to spin out the story of his lunch with the president.

In another corner of the restaurant, a waiter asked some customers if they knew why Carter had decided to go to Chiapparelli's rather than Sabatino's, which is a well-known haunt for Maryland politicians.

"I'll tell you," the waiter confided when his audience professed ignorance. "Maybe the president is supersititious. [former vice president Spiro] Agnew used to come here -- and he's no longer around. [Former governor] Marvin Mandel used to come here -- and he's no longer around.

"Then [former health, education and welfare secretary] Joseph Califano ate here two months ago," the waiter concluded with finalty. CAPTION: Picture 1, With ex-mayor Thomas D'Alesandro Jr., President Carter and company wind up a half visit to Baltimore. AP; Picture 2, with fingers, Tyra Foster of East Baltimore tells the president how old she is. UPI