For all their foresight, it is safe bet that Marx, Lenin and the other founders of socialism never dreamed that someday a Communist government would have to stage-manage a triumphal state visit by a pope, let alone a Polish pope, to Poland.

It is the very unlikeliness of the whole business that explains a good deal about the awkwardness of the Polish government's preparations for Pope John Paul II's visit. This nine-day extravaganza poses mind-boggling logistical problems, such as how to handle crowds of more than a million at about a dozen locations around the country or how to put up a thousand fussy journalists in a town with one small hotel.

(Solution: Have them stay in college dormitories or railway sleeping cars.)

But the biggest problem-with the outcome as yet unresolved-is how to keep the intense nationalism and religious fervor of the occasion under control without angering the population. One answer was to prohibit the sale of alcohol wherever the pope travels. Poles, of course, love to tipple, especially vodka. And the hope apparently is that less consumption will mean less boisterousness. Sober solemnity is the objective.

In Warsaw, thus far, the experiment has worked. Propriety has reigned. In fact, the overall politeness of everyone, police included, has been remarkable.

Television is another big headache. A Communist government, not surprisingly, is reluctant to advertise public adoration for a figure like the pope. So last week's newspaper TV schedules came out only for Sunday through Thursday while the haggling with church representatives went on.

Finally, late Friday, it was agreed that major events on the first and last day would get nationwide treatment while the rest of the stops would be televised locally wherever the pope is. Every evening there will be extensive reports on the national evening news. A compromise.

Probably the biggest preparation gaffe was the celebrated $350 accreditation fee. After protests from Western governments and news organizations, charge was withdrawn. The subject is painful for officials of Interpress, the Polish press agency in charge of arrangements for the trip.

Everyone misunderstood, they say. They insist the fee was not for entry. It was to pay for a package of services such as closed-circuit television, travel assistance and telex and telephone facilities. Now reporters are billed separately for each service, which is an accounting nightmare.

All those who already paid their $350 are getting credit, including an item described as 500 zlotys "pocket money." This is a source of much amusement to Poles who know that on the black (or as it is known here, the "open") market, 500 zlotys is worth about $3.50.

Still Interpress is trying. The press center, steamy in the midst of a Warsaw heat wave, has been notably helpful, staffed mainly by young women, teachers, interpreters and so on, who have remained determinedly cheerful despite an onslaught of foreigners bewildered by intricate timetables and pay schedules.

Not that the Polish authorities are selfless. They have increased the price of a deluxe hotel room, for instance, to $120 a day and have tried to milk the U.S. television networks for tens of thousands of dollars in transmission fees. When the networks refused, the charges were slashed. Another compromise.

The Poles maintain that their good will has been costly. With one thing and another it is going to cost them $15 million for facilities to host John Paul II, according to one government estimate.

Official jumpiness about what journalists write while here also has been noted. Thursday night, a rumor swept the press center that Prime Minister Piotr Jaroszewicz, who suffered a heart attack last month, had died.

The story was that the party leadership was in a quandry over whether to announce the demise while the pope was around and whether the Holy Father would attend the funeral. Apparently the whole thing was nonsense. "Jaroszewicz will outlive us all," a member of the party Central Committee confided.

But one European news agency reporter, claiming he had heard Polish television broadcasters discuss what color to wear for the sad announcement, filed the report. His ambassador was promptly informed that the reporter should stop writing stories at once and would be expelled.

Another recent bit of Polish government awkwardness, although not connnected with the pope's visit, involved U.S. Ambassador William Schaufele. On April 10, under the headline "Rather Odd Diplomacy," an unsigned "letter to the editor" appeared in the newspaper Zycie Warszawy. The letter attacked two Schaufele speeches, on in New York, the other in Warsaw, saying that the ambassador had, among other things, dwelled on "Polish anti-Semitism."

"It is probably for the first time that we are dealing with such an astonishing tone and nature of statements," the letter writer asserted, "diverging widely from...diplomatic tradition."

Now an assault of this kind on the U.S. ambassador is no joke in a country like Poland-and no accident. It was surely approved at a very high level in the Communist Party apparatus.

Schaufele decided to respond. So he sent a three-page letter of his own, rebutting the attack and saying it contained "errors of fact and reason." "In keeping with the jealously protected American traditions of free speech and the right of the people to know," Schaufele wrote, "American diplomats cannot adopt the example of governments in some other societies which are somewhat less than candid."

At the end, Schaufele added: "If the editors of Zyclie Warszawy decide to delete any parts of this letter before printing it, I request that a notation to that effect be made in your newspaper."

There was undoubtedly another party huddle about what to do. In the end the letter was printed in full-including the P.S. CAPTION: Picture 1, Polish girls rejoice at having kissed the hand of Pope John Paul II in Warsaw. UPI; Picture 2, Pope John Paul II talks with Polish Communist leader Edward Gierek. AP