Hello,
there is a true story about a type IX boat from Lt. Kaminski, which was unable to dive in the Caribbean. It fought off four different planes, and an airship for hours, until it was finally sunk by a destroyer that had been radioed in for help. Who still has the SHII manual can read part of the story there.
Against common belief here in the forum a boat with anything more than a single MG in early war was well able to defend itself against aircraft - assumed its engines and rudder were in working order. The AA traps or "Flak-Falle" boats were only useless because they were built at a time where England was able to mass up lots of planes which would overwhelm every boat sooner or later by sheer mass attacks from different directions. If you play the training mission in GWX2.1 at full realism you will know what i mean

.
The dilemma for a U-boat was always to either stay on the surface and fight it out, but then also be aware of the possibility of incoming reenforcements, called for by a circling aircraft, or dive as fast as possible.
It was always the problem if the boat could submerge and change course and depth fast enough when a plane was sighted. The white wash in the sea where the boat dived could be seen for some minutes - if not in SHIII though.
A typical attack procedure happened that way: A plane sights a U-boat, before the boat spots the plane. If the plane can make use of low clouds it will use it for an attack. If not it will probably use the sun in its back to decrease the distance until being seen, thus shortening the time the boat has left to dive. The first bomb run would be always made, however if the boat would stay at the surface and man its AA guns ("Flak" in german for "Flug-Abwehr-Kanone") the plane would not go in for a second attack, or even break a second or further attack if the boat was able to show its tail to the attacker, enabling the AA to shoot at the plane.
A plane usually only attacked when the boat was observed preparing to dive. If the boat obviously intended to stay surfaced and fight it out the plane would circle the boat out of AA range until it was observed preparing to dive, in which case the plane would again attack immediately. In fact there were a lot of fake dives, so the boat was doing as if preparing to dive, but suddenly blew ballast and immediately manned the AA again. A plane would then break its attack and circle again out of AA range. There area lot of stories telling the tactics through the war.
Problem for a boat remaining surfaced was that the plane would call for reenforcements consisting either of planes or escort ships. All they could hope for was the plane's fuel would force the plane to leave before renforcements showed up.
Greetings,
Catfish