Chapter 4
Astrophysical and other libraries

 4.1 Astrophysical modelling codes
 4.2 General-purpose and numerical libraries
  4.2.1 Reading and writing data
 4.3 Link farms

4.1 Astrophysical modelling codes

This section aims to be no more than a set of pointers to more complete information and resources. I’m no expert in this field, myself, so if I’ve missed some important resource, or miscontextualised something, please do let me know.

Stellar atmosphere codes:

Atomic and molecular data:

Astronomical chemistry (loosely) — dust, clouds and the interstellar medium:

A number of CFD codes are available to buy or download. This is a collection of pointers and notes about a large number of CFD codes, from a variety of sources.

Thanks to [SJ], [BS] and [AS] for much of the content of this section.

4.2 General-purpose and numerical libraries

There are numerous software libraries available. Many of these are free, many are public domain. The difference between the two is that ‘public-domain software’ is in some sense ‘ownerless’: it’s yours to play with, or modify, or exploit, as you wish, with only good manners requiring you to acknowledge the source (this is not an authoritative statement of copyright law, by the way...). ‘Free’ software, on the other hand, is still copyrighted, but you may have a free licence to use it for certain purposes. One of the best known of these licences is the GNU General Public Licence, which gives you very good access to the code, limited only by the requirement that programs produced using GPL’d code are themselves made as freely availale. Other licences might make the code available to academic users only, or only for non-commercial use. The GNU project have a useful collection of free and not-so-free licences, which is useful even though they are sometimes a little fervent about the issues. The type of licence makes a difference if you plan to redistribute your code. See also the observations about libraries, and thoughtless use of them, in 2.3.

Probably the most commonly used numerical library is the NAG library. This is a long-established, and very highly thought-of, library, which contains codes to deal with a broad range of numerical problems. The routines tend to come in several versions, typically a highly general, and highly configurable, one, accompanied by easy-to-use drivers. The NAG library is expensive, but Starlink’s size allows it to negotiate with NAG to provide the library at all Starlink sites. The routines are generally in Fortran, but C versions of some of them are becoming available.

The PDA library is a collection of public-domain and free routines, assembled by Starlink, and intended to replace the NAG library in Starlink application code. The collection was assembled using GAMS, with routines drawn from FFTPACK, SLATEC, NMS, OPT, plus other isolated sources. If you need to use one of the available algorithms, then the advantage of using the library version is that the (possibly non-trivial) work of building it for your architecture has already been done, leaving you able to simply link against the library. The collection is fully documented in SUN/194.

The remaining libraries are typically free.

In your search for codes, you would do well to start at GAMS: Guide to Available Mathematical Software. This describes itself as ‘A cross-index and virtual repository of mathematical and statistical software components of use in computational science and engineering’. You can either search for the code you need by keyword, or work through their classification of problems (a classification which is occasionally used more widely) to find references. They point to both free and commercial software.

The first collection to be aware of is Netlib. The archive is based at, but there are UK mirrors Although there are some facilities which are primarily available at Netlib, it also mirrors several other archives.

NHSE, the (US) National High-Performance Software Exchange, is ‘a distributed collection of software, documents, data, and information of interest to the high performance and parallel computing community’. NHSE is part of Netlib, and incorporates software repositories HPC-netlib for high-performance software, PTlib for parallel tools, and CSIR for chemistry software.

The CERN program library includes CERNLIB, which consists of a number of component libraries. This is a long-standing and well-known library of general-purpose Fortran (typically) numerical routines with, obviously, some bias towards particle physics. The service is free to all HEP users, and to physics departments in CERN member states, with separate non-commercial and commercial rates available. There is a FAQ.

JPL has a Computational Mathematics Library. These appear to be free, but no longer formally supported by JPL.

The ACM Transactions on Mathematical Software (TOMS) is a journal produced by the ACM. The software discussed in there is available at GAMS, and mirrored at HENSA.

The Scientific Computing Division of the (US) National Center for Atmospheric Research, has an overview of mathematical and statistical packages. Not all the packages reviewed there are freely available, but the discussions are useful.

PORT is a collection of general maths subroutines. Its description of itself is on the front page: ‘The PORT Mathematical Subroutine Library (third edition) is a collection of Fortran 77 routines that address many traditional areas of mathematical software, including approximation, ordinary and partial differential equations, linear algebra and eigensystems, optimization, quadrature, root finding, special functions, and Fourier transforms, but excluding statistical calculations. PORT stands for Portable, Outstanding, Reliable, and Tested.’ Some routines are public-domain when, for example, they are developments of public routines, others have a non-commercial-use licence condition.

Slatec is ‘a comprehensive software library containing over 1400 general purpose mathematical and statistical routines written in Fortran 77.’

Specifically concerned with minimisation, minpack (or at netlib), is a library for solving linear and nonlinear minimisation problems. It has documentation within the source code.

4.2.1 Reading and writing data

The codes you write do not exist in isolation, and at some point you will have to read data from, or write it to, files. You might, therefore, need to read or write one of a number of standard data formats. Clive Davenhall wrote an article on this in the September 1998 issue of the Starlink Bulletin. This covered reading and writing using the IMG library (SUN/160), using NDF files and the HDS files they are a special case of (SUN/33 and SUN/92 respectively), and reading and writing FITS files (SUN/136).

You can convert between different data formats using the CONVERT package, documented in SUN/55. CONVERT is extremely easy to use, and converting a FITS file, say, to an NDF is as easy as

  fits2ndf myfile.fits myfile

If you have to read or write FITS files, then visit the FITS home page for the FITS users guide and the cfitsio library. Although FITS files have a very simple format, there are enough ways of getting things wrong that you will, as usual, save yourself time in the long run by taking the trouble to use the cfitsio library. It’s easier than you might think: the Quick Start Guide contains most of what you’ll ever need to know. Note that, although the library is called cfitsio, it’s designed to be used with Fortran as well, and the programmer’s reference guide comes in two flavours.

Once the data is there, you will need to visualise it. See 3.3 for some pointers to suitable software.

4.3 Link farms AstroWeb is one of the most useful link collection, because it has been developed by the astronomy community. The TOMS list of web resources for mathematical software is a collection of pointers maths software on the web.

Yahoo has managed to assemble a respectable collection of pointers to Scientific software at, as well as more specific pointers to maths (, physics ( and astronomy ( resources.