All inmates discharged from federal prisons will be tested for the AIDS virus, and chief probation officers will be notified about infected former prisoners returning to their communities, Attorney General Edwin Meese III announced yesterday.

Meese also said all incoming federal prisoners will be tested for the acquired immune deficiency syndrome virus as will immigrants and illegal aliens applying for permanent residence under the amnesty program.

Prisoners found to be infected will receive medical treatment and counseling, he said, while aliens will be denied permanent residence but not deported. Immigrants seeking permanent residence will be barred.

"It is imperative that the federal government do everything it can to combat this rapidly growing public health problem," Meese told reporters at the Justice Department. These steps "constitute a reasonable and compassionate approach to this serious public health problem," he said.

Last week, President Reagan mandated AIDS testing for federal prisoners and immigrants and urged states to offer routine testing for marriage-license applicants, prisoners and others.

Public-health officials and civil libertarians have criticized the administration's policy, saying routine or mandatory testing, without new laws to outlaw discrimination and protect confidentiality of test results, will not stop the spread of AIDS.

That view was echoed by an official of the American Civil Liberties Union, which is considering a challenge of mandatory screening.

"These measures are not justified on public-health grounds," said Nan L. Hunter, the ACLU's coordinator for AIDS issues. "We don't accept that breach of confidentialty for people who are not prisoners . . . . Illegal aliens will be the last people on earth to come forward now."

The proposal by the Department of Health and Human Services to add AIDS infection to the list of contagious diseases for which immigrants can be barred was published in the Federal Register yesterday and would take effect in 60 days.

Until yesterday, the federal Bureau of Prisons, which houses 43,200 inmates, tested and isolated only those who showed clinical symptoms of AIDS. Since 1981, 284 inmates have been found infected with the virus, according to spokeswoman Maryellen Thoms. Many state prisons have adopted similar policies.

Meese also said he has ordered the National Institute of Justice, the department's research arm, to establish an AIDS clearinghouse to assist criminal-justice professionals "at ever-increasing risk of unknowingly contracting AIDS through contact with . . . offenders."

Meese said he does not know of any such case. "There is certainly a great deal of fear on the part of law-enforcement officers about that possibility," he said, because officers deal with drug addicts and may be pricked with a contaminated needle while making an arrest.

He defended D.C. police officers, who wore yellow rubber gloves while arresting protesters with AIDS last week. "I don't think it's an overreaction," he said.

In most cases, he said, notifying the chief probation officer shortly before an infected prisoner returns to the community should not affect employment or parole status.

"The most important thing we want to do is counsel an inmate" to take precautions upon leaving prison, Meese said.

Information "might affect the probation officer in the type of employment {a prisoner} was allowed to have," Meese said. "For example, if a person infected with AIDS was about to become a counselor in a day-care center, that might not be the best employment in the judgment of some probation officers."