In a ruling that may be unprecedented in drug-related cases, a U.S. District Court judge has ordered a Virginia man now serving a 40-year term for possession and sale of marijuana to be set free on grounds that his sentence amounts to unconstitutionally cruel an unusual punishment.

U.S. District Court Judge James C. Turk's decision will free Roger Trenton Davis, 31, of Wytheville, Va., who is serving two consecutive 20-year sentences at Powhatan State Correctional Center for the sale and possession of less than nine ounces of marijuana. Davis, who was convicted by a Wythe County Circuit Court jury in March, 1974, was also fined $20,000.

In a lengthy opinion made public Thursday, Turk wrote that "This court must necessarily conclude that a sentence of 40 years and a $20,000 fine is so grossly out of proportion to the severity of the crimes as to constitute cruel and unusual punishment in violation of the Eighth Amendment of the Constitution."

According to Ted Hogshire, Davis' attorney, Turk's decision may be the first time that a federal court has ruled a marijuana sentence cruel and unusual solely because of its length, not because the drugs law itself is unconstitutional.

Deputy Attorney General Reno S. Harp III said that his office will appeal the ruling to the U.S. Fourth Circuit Court of Appeals because "we obviously feel Judge Turk's decision is incorrect."

In explaining his decision, Turk wrote that "other than for the recent death penalty cases, the Eighth Amendment law is relatively undeveloped." In considering those capital punishment cases, the Supreme Court was obviously concerned with the "severity" and "degradation" of the punishment rather than with the length of the sentence, Turk said.

"The Supreme Court has never held that the sentence of imprisonment constituted cruel and unusual punishment solely because of its length," Turk noted.

However, "the length of an individual sentence is not immune from constitutional scrutiny" and the court has a right to question whether "the sentence of 40 years in the penitentiary and imposition of $20,000 in fines for possession and sale of nine ounces of marijuana is so grossly disproportionate that it ceases to be rational," Turk wrote.

While courts must avoid "an invasion" of the legislative process, Turk said they "should not shirk their responsibility to examine the propriety of applications of the law which work exceptional hardship on the sanctity and dignity of the individual."

Davis' 1974 trial and conviction attracted considerable media attention, not only because of the harshness of his sentence but also because of circumstances surrounding his trial.

Davis, who is black, was tried in the small, rural southwestern Virginia town of Wytheville (pop. 5,634) during an anti-drug fervor that sent a number of young people from the area to state institutions for drug offenses.

According to Nancy McGavok Davis (no relation) a drug counselor and long-time resident of the area, the popularity of Davis, whose last year in high school was also the first year of integrated schools in Wytheville, was "legendary."

"He could often be seen on Main Street surrounded by several of the prettiest white girls in town, all competing for his attention." Mrs. Davis wrote to Gov. Mills E. Godwin in an unsuccessful pardon appeal for Roger Davis two years ago.

He eventually married a white woman named Carol, who has driven 600 miles round-trip to visit her husband at Powhatan every Saturday since his imprisonment more than three years ago. According to Nancy Davis, Roger Davis was attacked by white youths for his interracial dating in high school and a cross was burned on his front lawn.

The police informant who bought four ounces of marijuana from Davis with money supplied by police was a convicted felon on furlough fron Bland Correctional Farm who had attempted suicide because he had been raped there, according to Davis' petition for a review of his sentence.

According to newspaper accounts of the trial, Davis, who had already been convicted of selling four LSD tablets in 1973, refused to plead guilty and avoid jury trial.

Davis' petition for a review of his sentence was filed a year ago through th joint efforts of the Washington based National Organization for the Reform of Marijuana Laws (NORML), the American Civil Liberties Union and the University of Virginia's Post-Conviction Legal Services.

While Turk refused to challenge the statute governing the sale of marijuana, he subtly questioned the need for the law whose purpose, Turk wrote was "to stop the sale of the questionable harmful drug."

Hogshire said Davis is "really pleased" and if bond can be raised he will walk out of Powhatan on Monday.