It was 36 years ago this Fourth of July that the first American troops entered Berlin to take up their occupation duties. It was 18 years ago this June 26 that President Kennedy made his "Ich bin ein Berliner" speech, reaffirming the American commitment to the freedom of the city that the Soviets had severed, two years earlier, with their infamous wall.

So it was appropriate that halfway between those two anniversary dates, on June 30, a man who has been at the center of American policy in postwar Germany came back to Berlin for a welcome from the city and the U.S. Berlin Command.

John J. McCloy, the first American civilian high commissioner for Germany, is 86 now, but spry of step, quick of wit and as focused in his analysis as in his reminiscence. He dominated an Aspen Institute of Berlin seminar on U.S.-European differences in foreign policy, not just by his presence but by the pointedness of his observations. And he mazed his hosts by going straight from the conference table to long evenings at the opera and ballet with no sign of fatigue.

McCloy was welcomed back to Berlin by the city's new governing mayor, Richard von Weizsacker, and one morning was honored by the army with a military view and the unveiling of his portrait at the headquarters of the Berlin Command.

The old man was touching and funny, as he told how he had persuaded Franklin D. Roosevelt that Gen. Lucius D. Clay would be a better choice than himself for the first U.S. high commissioner, and, when asked by President Truman to succeed Clay, was able to say to the perplexed chief executive, "It's not the first time that job has been offered to me."

But as McCloy made clear in the seminar, he is concerned at the strains in the U.S.-German alliance that he and his contemporaries forged from the ruins of World War II, strains that show in the rising German criticism of the Reagan administration's nuclear policy. And he is worried that the younger generation of Germans and Americans may not appreciate even what Berlin symbolizes as a showcase of freedom behind the Iron Curtain.

On the latter point, at least, there may be solid -- and not just sentimental -- reasons for reassuring McCloy. The West Berliners celebrated their freedom this year in the most practical way possible, at the polling place, voting in von Weizsacker in a stunning rebuke to the Social Democrats who had run the city since liberation days and had grown sloppy and even corrupt in the process.

On the evening of his portrait ceremony, there was another celebration of freedom -- a peaceful protest march through the downtown streets by some 5,000 youths, protesting the shortage of housing. With the memories of the Berlin of Nazi days, it was something to see the police lined up, with clubs and shields ready, to protect the store windows from being shattered -- but making no move to interfere with the protest.

And later in the day, when I visited some of the American troops who had participated in the McCloy ceremony, there was reassurance of another kind. Most of these men are too young, of course, to have any memories of the Berlin blockade, the Berlin Wall's erection or Kennedy's speech -- let alone of Berlin, the Nazi capital, reduced to rubble in the war.

Berlin is now considered "good duty" for the 7,000 Americans in the military contingent. There is good housing for those with families who serve a three-year tour. The tour for single or unaccompanied enlisted men has been reduced recently from two years to 18 months, helping their morale. Because the operating costs of the Berlin garrison are paid by the West German government (since the city is still formally "occupied territory"), the post has avoided some of the stringencies imposed by recent Pentagon budget squeezes.

The mission remains part symbol, part substance. The troops train constantly in MOUT -- military operations in urban territory, practicing house-to-house fighting in mock-up buildings. But with 22 enemy divisions encircling them, the U.S. British and French contingents are primarily a tripwire force.

The sense of isolation is a problem. "There are 112 miles of wall," one sergeant remarked, "and you can only go around so many times without feeling like a rat in a maze." Idleness is also a problem. Troops train intensively for six weeks, patrol and pull other details for six weeks, then have six weeks of relative leisure.

The city of Berlin is, according to Col. David H. Harris and Lt. Col. Robert H. Wood, "awash" with drugs, and controlling drug abuse is a challenge for the officers and non-coms. But the attentiveness of company commanders like Capts. Warren Crecy and Dave Benjamin and Sgts. Gregory McGuire and Timothy Johnson -- plus a "buddy system" that matches a new arrival with a Berlin veteran of his own age, rank and background -- is, they say, reducing the problem.

Meanwhile, the army continues to show the flag in a fashion McCloy would approve, making daily "flag tours" in U.S. Army sedans through East Berlin and encouraging Americans in uniform to visit the old Communist sector, in order to demonstrate the Americans' right of access.

And there are daily wall patrols, visible from the watchtowers on the Communist side. "There aren't many places where you train with the enemy surrounding you 360 degrees around the compass," Col. Harris remarked.

Even for those who lack McCloy's memories, Berlin remains a very special place.