Chris Woodyard, Matt Krantz, and Bill Keveney

USA TODAY

LOS ANGELES — The gunman in a murder-suicide at the University of California Los Angeles was a graduate student who apparently nursed long-simmering hostility toward the victim, his former engineering professor, who he accused of stealing his computer code, according to police and local media reports.

The gunman was identified Thursday as Mainak Sarkar, an engineering graduate student, according to Officer Jenny Houser, spokeswoman for the Los Angeles Police Department. The victim was identified as William S. Klug, 39, a professor of mechanical and aerospace engineering engineering.

The bodies of both men were found Wednesday inside an office in the UCLA engineering building.

The motive remained unclear although police said they would focus on Sarkar's grades and a "longer-standing" poor relationship between the two men, KABC-TV reports.

KNBC-TV, quoting unidentified law enforcement sources, reported that Sarkar apparently had a strained relationship with Klug and "may have believed the professor had misused” his computer code.

Klug, according to the Los Angeles Times, was a target of Sarkar's anger on social media for months, including a post on March 10 calling the professor a "very sick person” who should not be trusted. The newspaper, quoting police, believed that Klug had stolen his computer code and given it to someone else.

“I urge every new student coming to UCLA to stay away from this guy,” Sarkar wrote, according to the Times. "He made me really sick. Your enemy is my enemy. But your friend can do a lot more harm. Be careful about whom you trust.”

The mid-morning shooting sent dozens of police and SWAT units to the university and prompted a lockdown for thousands on the sprawling campus. Classes resumed on Thursday.

Police Chief Charlie Beck said on Wednesday that three shots were heard and a weapon was found at the scene of the shooting inside an office in the engineering building. He could not confirm reports a suicide note was found. He declared the university safe about two hours after initial reports of a possible shooter on campus.

The shootings came at one of the most stressful times of the year on campus — the week before finals, said Chris Lama, 23, a bioengineering student.

Students and faculty mourned Klug, who was described as a popular teacher on campus.

“Bill was an absolutely wonderful man, just the nicest guy you would ever want to meet,” said UCLA professor Alan Garfinkel. “Devoted family man, superb mentor and teacher to so many students. He was my close colleague and friend. Our research together was to build a computer model of the heart, a 50 million variable ‘virtual heart’ that could be used to test drugs.”

Peter Gianusso, who headed the El Segundo Little League where Klug coached, said he “exemplified what Little League was all about: character, courage and loyalty.”

“He had a special relationship with his son through baseball, was a great coach, spent countless hours on the field with the boys and girls of El Segundo Little League,” Gianusso said.

The initial reports of the shooting prompted Los Angeles Police to issue a tactical alert, which puts all officers on alert citywide. Scores of police armed with assault rifles and shotguns converged on campus, some rushing to scene from more than 10 miles away.

"We have literally hundreds of police officers and agents on campus," UCLA Police Chief James Herren said. "We are dedicated to ensuring the safety of the community. It is something we have trained to do."

Los Angeles police said the department and campus police received multiple reports of gunshots on campus around 10 a.m. UCLA notified students to shelter in place via a message sent to smartphones.

The incident caught many students by surprise. "I'm very scared," said Jordan Zhu, 23, a statistics student who had planned to go to class in the engineering building at about the same time the shooting occurred.

Adeel Bajwa, a graduate student in electric engineering, said he was "just scared"

"I'm worried that all my colleagues are OK," he added.

Before the all clear, teams of officers searched buildings as students emerged with their hands in the air and police patted them down and searched backpacks. Ambulances and fire crews stood by as a precaution.