Since in general the observed stellar spectra cannot be directly inverted to yield the unknown physical quantities such as temperature, elemental abundance or magnetic field strength, they have to be compared with a large variety of synthesised spectra. Obviously, the choice of physical input quantities, numerical techniques, and assumptions concerning the magnetic geometry is crucial for any realistic modelling of the physical world.
These applications are numerically very intensive. The opacity has to be sampled at sufficiently close frequencies to fully resolve the spectral lines and the equation of radiative transfer solved at each of these frequencies. For homogeneous stellar surfaces and in the absence of macroscopic velocity fields one can immediately calculate the emerging flux, but more generally one has to carry out a spatial integration on a 2D grid duly taking into account Doppler shifts and changes in physical quantities over the visible stellar surface.
At the core of all codes in use one therefore finds SUBROUTINES (not PROCEDURES since in the conservative astronomical community FORTRAN dominates everywhere) designed to calculate line shapes and to solve the equation of transfer. These subroutines are embedded in (usually unstructured) codes that provide for the application to the particular problem such as radially and/or nonradially pulsating stars or magnetic stars.
We want to mention 4 points which have led to the choice of Ada:
In Ada the self-adaptive grid could be designed as an Ada-package, hiding the implementation details, providing well defined services. The 'physics' parts of the software only contain simple calls to these services. The implemention of this package was easy: dynamic allocation of array-slices, passive iterators and recursive invocation reduced the lines of code to a fraction and increased the readability of the code. Experiments to enhance the performance of the surface grid do no longer affect the 'physics' code.
The definition of Ada-packages representing abstract data types leads to a 'single-point-of-change' design. A simple modification (followed by massive recompilation) and a new variation of the physical model can be examined. The Ada library system allows even more elaborate variant control.
For the unexperienced who has grown up with FORTRAN IV and who has lived with FORTRAN 77 (Stift) it took a few weeks to completely switch to Ada (possibly previous experience with ALGOL has helped). Students with no programming experience have mastered Ada without any problems (rather better than FORTRAN). The main difficulties arose with the use of generics and exceptions, so these features remained unused in the beginning. Advances were propagated by private communication. No CASE tools were used. On the whole the transition worked out smooth, painless and highly rewarding.
Numerical performance is of utmost importance in most complex astrophysical codes, so the first thing we did was to conduct some performance tests comparing the old FORTRAN with the new Ada versions. Although we had the biased condition of decades of experience in efficient FORTRAN-coding and only some months of Ada experience, the Ada programs had roughly the same speed as their FORTRAN counterparts (at most 15% slower)!
The full advantages of Ada showed up when one of us (Stift) extended the original Ada code to synthesise full spectral regions with dozens of blends in all 4 Stokes parameters for rotating and pulsating magnetic stars. A previous attempt in FORTRAN was only partly successful after weeks of programming because of the limited possibilities of FORTRAN. In Ada the different objects could easily be represented by appropriately defined types, leading to the solution of the problem by an Ada-novice in a mere 2 days! There seems to exist no limit to the complexity of problems that can be effectively dealt with in Ada.
To do things that were not possible before (in an amazingly short time-scale), breaking the complexity barrier, are convincing arguments for a transition! The enhanced readability of the code lead to the statement: "Ada is the real FORmula TRANslator!"
Univ.Doz. Dr. Martin J. Stift Institute for Astronomy, Tuerkenschanzstrasse 17, A-1180 Wien, Austria Tel.: +43 (1) 470 68 00 91 E-mail: Stift@astro.ast.univie.ac.at Gerhard Koenighofer Institute for Astronomy, Tuerkenschanzstrasse 17, A-1180 Wien, Austria and Swing Entwicklung Betrieblicher Informationssysteme Ges.m.b.H Glasauerg. 32, A-1130 Wien, Austria E-mail: Koenighofer@astro.ast.univie.ac.at