The nuclear-powered attack submarine USS Atlanta ran aground in the Strait of Gibraltar on Tuesday with such force that it punched a hole in a ballast tank and smashed the sonar gear in its nose, Navy officials said yesterday.

The officials stressed that no radiation leaked from the submarine's power plant and no crew members were injured.

The Atlanta accident occurred 28 days after another nuclear-powered submarine, the USS Nathanael Greene, ran aground in the Irish Sea for unexplained reasons. The Nathanael Greene, armed with 16 Poseidon nuclear missiles, was damaged so severely that the Navy decided to scrap it as part of a formula allowing President Reagan to remain within the limits of the unratified SALT II strategic arms limitation treaty when a new Trident missile submarine goes to sea, officials said.

Navy officials would only say that the Atlanta was passing through the Strait of Gibraltar when it ran aground. The officials refused to say whether the submarine was entering or leaving the Mediterranean. It is standard procedure to send attack subs into the Mediterranean to help guard Navy battle groups, such as the aircraft carrier forces that recently conducted air raids on Libya.

The Atlanta disengaged itself from the sloping sea bottom, officials said, and limped into port at Gibraltar despite water pouring through the holes in one of the ballast tanks, which are used to control the submarine's buoyancy. Water did not enter the crew compartment, which usually houses 168 men.

The Navy is investigating why the Atlanta, a Los Angeles-class submarine commissioned in 1982, ran aground and whether it can be repaired in Gibraltar or must be towed to its home port of Norfolk, officials said. Cmdr. William K. Castle Jr. is the Atlanta's skipper.

Submarines send sound waves ahead which, when bounced back, sketch the underwater terrain to warn of hills and other obstacles. The Strait of Gibraltar and the Irish Sea are well plotted, and it is unclear how the subs wandered into such shallow waters.

The Nathanael Greene ran aground April 1 and also managed to free itself and steam under its own power into the Scottish port of Holy Loch, Navy officials said. Although the hull was not punctured, the damage was described as major. A new commander was flown from Groton, Conn., to Holy Loch to pilot the submarine across the Atlantic to Charleston, S.C., for repairs, officials said.

Five years ago last month, the nuclear-powered missile submarine USS George Washington collided with the Japanese freighter Nissho Maru in the East China Sea off the southwest coast of Japan, killing the captain and a crew member on the freighter and causing an uproar in Japan. Thirteen other Japanese crewmen were rescued from the sinking freighter. The collision drew a formal apology from President Reagan to Japanese Prime Minister Zenko Suzuki.