HOW MANY of the 1,800 Cubans who have spent the past 14 months in Atlanta's federal penitentiary, the remainder of 1980's so-called "Freedom Flotilla," really deserve to be there? We may never know exactly, but it seems fair to recognize that the callous incarceration of so many refugees without benefit of trial for such a dismally long period reads like a story more appropriate to Cuba than to this country. Under the circumstances, Monday's decision by U.S. District Court Judge Marvin Shoob in Atlanta to order the Immigration and Naturalization Service to free 322 of the prisoners today (once sponsors have been found for them) and later to release all but the provably dangerous criminals and mentally ill among the remainder comes not a moment too soon.

From the statements made by INS and Justice Department officials at the hearing, it is fair to assume that without Judge Shoob's timely prodding, the government might have delayed indefinitely the task, first of sorting out the actual "undesirables," and then of terminating its indefensible jailing of legitimate refugees, most of whom have not been charged with crimes committed within the United States. Some time ago, Attorney General William French Smith stereotyped the entire group of imprisoned Cubans as "hard core" criminals.

But Judge Shoob also exposed the misleading nature of that allegation. Justice Department and INS officials conceded that many of those whom the judge plans to set free initially had been held in Atlanta's maximum security federal prison for 14 months solely because they arrived in the United States lacking valid entry documents--in short, they were "hard core" illegals comparable to those millions for whom the president has proposed a general amnesty. Others among the Atlanta 1,800, it turned out, had been detained only because offenses had been committed against them in detention centers; still others alleged that INS officials had encouraged them to admit to nonexistent Cuban criminal records. Most disturbing of all, the deputy director of INS's prison processing center for Cubans admitted that an unspecified number of the refugees had signed statements written in English--which the Cubans may not have understood--without first having had their "confessions" translated into Spanish.

Once Congress returns, the House and Senate immigration subcommittees should review the full bureaucratic record of this shameful episode, which stains the country's humanitarian achievement in having worked assiduously to absorb the majority of Mariel boat people. We grant the serious difficulties confronted by the INS's overworked and poorly funded staff in coping with the emergency. Still, we urge Judge Shoob to continue his efforts until immigration officials somehow manage to process for release the apparently large number of bona fide political refugees, while at the same time identifying promptly and holding in jail only genuine hard-core criminals. As for those suffering from mental illness, they should be transferred at once to proper facilities where they can begin receiving overdue examinations and treatment. We can only hope, finally, that this belated evidence of American justice in action has afforded those Cuban refugees scheduled to be set free a model more closely resembling the rule of law in a demoncratic society for which they risked their lives in the first place.