A federal judge yesterday ordered the Army to upgrade automatically to "honorable" the discharges of about 10,000 Vietnam-era veterans who had been thrown out of the service after being forced to undergo testing for drug abuse.

The soldiers had received either "general" or "undesirable" discharges after they were found to be drug abusers in a compulsory urinalysis testing program ordered by President Nixon in 1971.

They claimed successfully in the case decided yesterday that their rights against self-incrimination had been violated when they were compelled to participate in the program without being informed of the possible consequences, and had suffered since because their discharges were less than honorable.

Military law specialists said the ruling by U.S. District Judge Barrington D. Parker is the first in which a federal judge has ordered a blanket upgrading of a large group of veterans. Army attorneys had argued earlier in the case that such a ruling would damage the "integrity of the discharge system" and would be "an unprecedented abandonment to the court of an essentially military function."

Parker rejected those arguments and specifically ordered the Army to begin a search for those possibly affected by his ruling, issue a press release announcing the new program, mail the honorable discharge certificates to those it can locate and report regularly on the progress it is making to the attorneys for the veterans in the case.

The suit was filed in 1977 by the veterans education project of the American Civil Liberties Union on behalf of an Army private who had been discharged in 1974 as a result of the program.

Parker had ruled last August in favor of Antonio Giles, 30, of Suffolk, Va., and ordered an honorable discharge for him at that time. Yesterday's ruling applies the same relief to any soldier who received a less-than- honorable discharge after an administrative hearing in which evidence of the compulsory urinalysis program was introduced.

Bart Stichman, the attorney who represented the soldiers, said more than 4.4 million urinalysis tests were conducted during one 14-month period at the neight of the testing program. "The testing procedures were illegal because they did not include a warning to the soldiers that they did not have to participate," Stichman said.

Giles, who could not be reached for comment yesterday, had told two Army doctors at the time of his enlistment in 1972 that he had previously used heroin for a six-month period. However, they accepted him for enlistment and later sent him to Thailand.

While in Thailand, he failed 10 or 20 urine tests and refused to participate in at least three others. As a result, he was issued a general discharge.

The Army has three levels of administrative discharges -- honorable, general and undesirable. Soldiers leaving the service with honorable and general discharges are elegible for veteran's benefits, but those with undesirable discharges can receive such benefits only after individual consideration of the circumstances of their discharges.

Giles' attorneys argued, however, and Parker agreed, that a general discharge based on drug abuse is "punitive in nature. It is a lifetime stigma which adversely affects the plaintiff's reputation and standing in the community and causes him embarrassment and a loss of self-esteem."

Parker noted that employment opportunities are restricted for persons with general discharges, and the ACLU cited a study of employers and educators who said they were adversely influenced by a general discharge notification on an individual's application.

The U.S. Court of Military Appeals ruled in 1975 that the urinalysis testing program was illegal when the evidence was used in an administrative hearing without the participant being warned, and the Army changed its regulations at the time to stop issuing less-than-honorable discharges in such situations.

Giles and the 10,000 or so others, however, received their discharges prior to the 1975 military court ruling and had been unable to get their discharges upgraded retroactively. Both Parker and the ACLU attorneys noted also that the alleged purpose of the drug testing program had been to target persons for drug counseling, and not to discharge them.

Army attorneys had argued at one point that it would be too costly to locate and notify those affected by the ruling. However, after it became clear that the Army had the computer capability to attempt to locate the veterans, the Army continued to oppose the ruling, arguing that it was unfair to "hundreds of thousands of veterans who have earned their honorable discharges."

Assistant U.S. Atorney John Oliver Birch, who represented the Army, argued in court papers that many of those discharged under the drug-testing program would have been discharged for other, non-drug-related reasons. He maintained the Army should have the option of reviewing each discharge on a case-by-case basis.

Stichman said the ACLU veterans project has a toll-free telephone line (1-800 -- 424-5402) for veterans to call if they believe they are affected by the suit.

Stichman said the toll-free number if also open to all Navy, Marine, or Air Force veterans who may have been ordered to submit to the drug testing. The ACLU estimates there are 3.4 million veterans with less-than-honorable discharges for various reasons who could apply for the review of their discharges and that two-thirds of them -- those with undesirable discharges before 1965 -- should apply by Dec. 31 for such a review.