## Chapter 4Astrophysical and other libraries

### 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:

• CCP7 was a Collaborative Computational Project, ‘concerned with the calculation of theoretical models suitable for the interpretation of stellar and interstellar spectra’. As well as promoting the use of advanced computers in astronomy, it developed a library of stellar-atmosphere and spectroscopy codes. The project finished in April 2001, but the resources it produced are still useful.
• Simon Jeffery makes available a number of tools for stellar atmosphere calculations.
• At Robert Kurucz’s home page you can obtain copies of his ATLAS and other codes, along with grids of model atmospheres.
• PHOENIX: state-of-the-art M-star model atmospheres.

Atomic and molecular data:

• The Opacity Project is a collaborative project to produce the atomic data required for stellar envelope calculations. The project makes the results generally available both through a database called ‘TOPbase’, and by anonymous FTP.
• Other opacity data is available from the OPAL code. As well as making precalculated opacity tables available, you can make requests for new tables to be generated.
• Atomic data at Kentucky and Harvard
• JPL Molecular Spectroscopy
• The Vienna Atomic Line Database (VALD) is an excellent site with up-to-date atomic data needed for spectrum synthesis.

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

• Cloudy is a arge-scale plasma simulation code that is widely used across the astronomical community as an aid in the interpretation of spectroscopic data.
• DUSTY is a dust-shell modelling code, also originating at Kentucky.

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

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 http://www.netlib.org, 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.