Astrophysics: Libraries

Various suites include libraries, both for their own internal use and for users to link their own programs to. In addition to the following, we can often make libraries available on request via MacPorts (qv), provided they and their dependents are not excessively large. Alternatively, if you have the source distribution for a particular library to hand, we can help you install it under your own home directory, or preferably under /Data on your local system, with the build-time flags of your own choice; sourcecode distributions where the build-time instructions mention running ./configure are often especially amenable to this. There is also the MyMacPorts facility (qv), which offers a halfway house between these two approaches.

Please see also:

On using environment variables

Activating a suite with libraries in it will set certain environment variables in your current shell, including ${DYLD_LIBRARY_PATH} and/or ${DYLD_FRAMEWORK_PATH} and their variants, in one easy-to-use package. This will permit your compiled program to find various run-time libraries and frameworks, both at build time and at runtime.

Using environment variables to pass information in this way, instead of hand-copying pathnames, is one of the standard tricks of programming. It's the same basic idea as that behind (eg) using variables inside programs, and libraries of common subroutines. (Typing something long and complicated in by hand should only be done once: when writing a shell script or Makefile. That way, you need only get it right once. If you use the environment variables set by the Activation, we've done most of the typing for you, and will endeavour to keep it up-to-date on your behalf.)

  • Good News: If you say (eg) "Activate starlink", you won't need to change your script or Makefile if you change versions of (in this case) StarLink, using an obscure and site-dependent absolute pathname.

  • Bad News: You do need to Activate the appropriate version of (eg) Starlink before doing the build and/or running your executable; and you do need to be consistent (eg building with one version, then Activating another version before use, will end in tears). This can be especially mystifying if you've logged out and back in again, or are attempting to run the program in a different Terminal and/or xterm. But you'll need to set such things as ${DYLD_LIBRARY_PATH} appropriately anyway, otherwise your executables may not be able to find the correct dynamic libraries at run time; and the easiest, most consistent and least error-prone way to do that is to have used the same Activation as at build time.

  • Ugly News: MacPorts needs no Activation, and Activating MyMacPorts doesn't (yet) affect library or make-related environment variables, in the interests of not blowing other software (eg the main MacPorts) out of the water. Please see the respective pages for the pathnames you'll neeed to use.

Please see Applications Setup for more information.


Use the PGPLOT and/or CFITSIO libraries within Starlink (qv), which don't make use of AquaTerm.

  • Good News: Because you're not using the X-hostile AquaTerm, you can run your program from off-site via an SSH connection, without needing to use VNC.

  • Bad News: You'll need to do the Activation step for Starlink in your current shell.

  • Ugly News: The result won't necessarily look as pretty, and some other functionality may be missing.

The alternative method, which used MacPorts's 32-bit gcc and gfortran (and attendant libraries), has been withdrawn. Please see also Where has g77 gone to?

MacPorts's instance of libcpgplot.dylib (at the time of writing) is believed to be be broken for use other than by MacPorts's build of Miriad.


NAG libraries are not installed by default, but are currently available in the Development category of Self-Service. As usual, please check what's already installed before proceeding: installation of these libraries take tens of minutes on a fast local connection, and perhaps overnight over WiFi or from offsite. In particular, you can say:

gcctest -a
Activate installed naglib
Activate help naglib

.... at the shell prompt, to (respectively) check which compilers are installed, see what NAG software (if any) has already been installed, and determine the Applications Setup usage for the NAG libraries.

  • NAG Libraries: Libraries for the GNU C compiler (gcc), and for Intel's Fortran compiler (ifort).

    • Astrophysics systems have gcc ready-installed, in the command-line part of XCode Tools. Intel compilers are available via Self-Service, and will also have been preinstalled on Mountain Lion systems.

  • NAG Fortran Compiler: NAG's own Fortran compiler (nagfor), plus the matching NAG library set.

    • Please note: The library documentation refers to f95, or perhaps f90. Please use nagfor instead in your scripts and Makefiles if at all possible.

There are also two support packages (which are rather quicker to install):

  • NAG Licence Update: Update just the licence file, whose contents change on an annual basis.

    • Updating the library set just to get a licence update is contraindicated. If and when the library itself needs to be updated, we will circulate information to that effect.

      • Confession 2013/06/21: This has now come to pass: the 64-bit C library has changed from Mark 09 to Mark 23. Those of you using this C library will need to install the whole schebang, and re-link your programs. (If you're using hand-copied command-line incantations in your Makefiles, you'll also need to amend them. .... What do you mean, "what Makefiles" (grin) ? --- see above and Makefiles for Beginners for how to Do It Right.)

  • NAG Test-and-Demo set: Test the NAG libraries, and in particular whether the licence server is playing nicely today.

    • This is installed as a "tarball" in /Local/nagtest, which you'll need to unpack and build under your home directory. After installation, please see /Local/nagtest/README for directions, and for usage (and abusage) information.

NAG software is available under a site licence. If you wish to use it on a laptop outside the Department, and for other details (including licence expiry dates), please see:

NAG Serial Libraries

For offsite systems, and for new production code, it is well worth investigating alternatives such as the GNU Scientific Library: at the time of writing, I find that Activate search gsl shows that GSL is available within MacPorts and StarLink, and (with a misleading version number) in the deprecated SciSoft. Astrophysics's MacPorts distribution now also features FGSL, the Fortran binding for GSL.

Categories: Apple | Astrophysics | Development | Mac | NAG