If a permanent magnet has both a homogeneous polarization inside the material and a linear demagnetization characteristic in external fields, its magnetic field can be expressed using a surface pole model. For magnets satisfying these conditions and, in addition, having a rectangular shape, the fields at any given-point in space can be calculated analytically. An algorithm for this calculation is presented in a form that can easily be implemented into a computer program. In our experiments we used Nd,Fe,,B magnets to support low pressure glow discharges by magnetic fields. The magnets can be seen as composed of elementary magnets with rectangular shape, for which the magnetic field distribution is calculable. We present results of field calculations for various configurations of permanent magnets that we used in hollow cathode and Penning discharges.