There is some confusion here since you state that the gyroscope is giving you readings where the software indicates that it is the gyroscope that wasn't initialized.
The accelerometer is integrated into the same chip as the magnetometer which on that breakout board is a STM LSM303D(datasheet ). This chips contains a MEMS type magnetic field sensor. STM is secrative about the exact type of sensing element, it is likely that it can be succeptible to damage at strong magnetic fields and the high flux density and divergent field lines close to the surface of a magnet may cause other damage.
The surface or rare-earth magnets (e.g. neodymium) can have considerable field strength near the surface, if you bring the magnet very close to the sensor the field strength can be a significant fraction of 1T and there may be enough flux density to significantly damage a sensitive device like a mems sensor.\$1000\mu\ T\ = 10 G\$ which the magnetometer datasheet says should be fine, but I suspect the strength of the field was a good deal higher. The constant readings and software error message is likely indicative of damage to the relevant sensor chip the readings being garbage data or default values from an uninitialized sensor.
In general there are any number of ways that a strong magnet close to the board can cause damage to one of the sensor chips. A uniform 1milliTesla field is probably less damaging than the highly divergent field at the business end of a magnet.
The magentometer/accelerometer should handle magnetic fields up to 10,000 G according to the datasheet, however I suspect that the gyroscope (the device giving you an error message) with its mems gyroscopic sensor (likely a PZT but STM doesn't say) may be more susceptible to damage (datasheet).
Both the accelerometer and the gyro provide delta measurements. If you need an absolute reference, you need to provide it by another means. Even gravity is not a reliable reference because you can't tell what component of your acceleration is due to gravity and what is due to motion.
The accelerometers are not very good for angle measurements on their own. They measure linear acceleration, not rotation or angle. You can get a crude orientation out of them by assuming everything is static and therefore the acceleration vector is due entirely to gravity. The challenge is that the accel can't tell the difference between gravity and motion-- if you move the device, the acceleration will be the sum of gravity and motion leading to an ambiguous result.
A magnetometer can give an absolute reference to the earth's magnetic field, but it is sloppy and easily distorted.
The IMU probably has a reference frame labeled on the device that will give you a clue as to the internal arrangement of sensors, but that is still subject to manufacturing tolerances and is probably not labeled with care.
A common solution is to calibrate the device periodically using a technique known as a ZUPT (zero velocity update). Place the device in a known orientation, don't move it, let the filters settle out, and call that your global frame. From then, calculate your deltas from that pose. Errors will grow quickly, so you'll need to repeat this procedure periodically.
The ZUPT will cancel out accumulated measurement errors due to drift and bias, but if you want to coordinate measurements from multiple sensors (3 accelerometers, 3 gyros, for example) then you need to do an alignment calibration. You don't know how well aligned the various sensors are-- how orthogonal are the x,y and z accels and pitch, roll and yaw gyros to each other (they can't be perfect). Also, how coaxial is the yaw gyro with the z accelerometer, etc. This will require making controlled movements of the sensor set to check alignment. Generally this only needs to be done infrequently, and possibly at the factory. Your IMU may have the calibration parameters stored in it.
Every sensor is independent, so the system needs to have the various devices referenced to each other. That is what I referred to as an alignment calibration. That gives you a (non-orthogonal) coordinate system relative to some origin on the IMU itself. Then there are errors that will build over run time that need to be canceled, which the ZUPT will help with. As far as tying to a global reference frame external to the IMU, that needs to be done by some other form of measurement. Possibly by ZUPTing in a known reference pose, or by some external measurement system that can reference your local to global frames.
Best Answer
Generally you determine angle by using the accelerometer readings. This only works is the unit is not accelerating at the time but you can do a quick sanity check that sqrt(x*x + y *y + z *z) = 1g +/- some error margin. If that is true then you probably aren't accelerating.
For any given axis the amount it is away from pointing straight up will be given by angle = cos-1(reading in g).
If you know how far each axis is from vertical then you can work out your orientation relative to the ground.
If you are accelerating then assuming you knew your orientation before hand you can calculate your current orientation by using the gyro readings to measure the change in orientation. However anything calculated this way will drift away from the correct answer so you will need to correct it once you stop accelerating.
You can use the magnetometer as a sanity check and a method of tracking rotation but it's not very reliable for calculating absolute heading without first being calibrated for your current environment.
All of the readings from an IMU will be very noisy unless you are using a very expensive one, expect to have to average and filter a lot to get smooth results out. In this situation expensive means the price has at least 4 digits before the decimal point.