Installing libRadtran on Macbook Air (Mountain Lion)

Some of you may know libRadtran – the library for radiative transfer. It’s a great tool for all those interested in radiative transfer of the atmosphere. The library is open source and freely available on

For those users not so familiar with unix environments, it may be a little bit tricky sometimes to get those kinds of tools compiled and running. Especially if we include the dependencies the software requires for some (not all) features.

Therefore I just made some notes during the latest full installation of libradtran on my system (which is a Macbook Air running Mountain Lion [Mac OS X 10.8]).

General information

Make sure you have gfortran and gcc compilers installed. The latter one normally is shipped with XCode. The installation may also work with other fortran-compilers, which I haven’t tested here. Make sure all the packages below are compiled with the same compilers.

libRadtran dependencies are:
- GNU scientific library
- Netcdf (depends on HDF5, zlib if we want to install Netcdf-4)

Check the INSTALL-file in the package for detail information for which tasks each of these packages above is required.

Environment variables that affect ‘configure’ include: CFLAGS for C compiler flags, CPPFLAGS for C preprocessor flags, LDFLAGS for linker flags.

Set /install/path/ to your desired installation path, which may be e.g. /usr/local/ (which is also normally the standard path) or any other path where you have write access.


Here is the full list of steps I took to get libRadtran up and running:

For each of the packages:
- Download the tar.gz of the current version.
- extract in bash terminal with:

tar -xvf name.tar.gz

- go to the extracted folder in the bash terminal via

cd name/
  • 1. build and install zlib

    ./configure --prefix=/install/path/
    make check

    if everything is okay (means no errors occure):

    make install
  • 2. build and install hdf5
    ./configure --prefix=/install/path/ --with-zlib=/install/path/
    make check
  • 3. install and install netcdf
    CPPFLAGS=-I/install/path/include LDFLAGS=-L/install/path/lib ./configure --prefix=/install/path/ 
    make check

    When everything works fine you should get a message like the following:

    | Congratulations! You have successfully installed netCDF!    |
    |                                                             |
    | You can use script "nc-config" to find out the relevant     |
    | compiler options to build your application. Enter           |
    |                                                             |
    |     nc-config --help                                        |
    |                                                             |
    | for additional information.                                 |
  • 4. install GSL (Gnu Scientific Library)

    Use CFLAGS=”-Os” in case singular value decomposition fails (optimization may reduce precision), which was the case for me on the first try.

    CFLAGS=-Os CPPFLAGS=-I/install/path/include LDFLAGS=-L/install/path/lib ./configure --prefix=/install/path/ --disable-shared --disable-dependency-tracking
    make check
    make install

    You can test if the GSL library is working fine also via a small c-program:

    #include <stdio.h>
    #include <gsl/gsl_sf_bessel.h>
    main (void)
      double x = 5.0;
      double y = gsl_sf_bessel_J0 (x);
      printf ("J0(%g) = %.18e\n", x, y);
      return 0;
    The output is shown below, and should be correct to double-precision accuracy,2
    J0(5) = -1.775967713143382920e-01

    Save this as a text-file with name gsl_test.cpp.

    Compile it with:

    g++ gsl_test.cpp -L/install/path/lib -I/install/path/include -lgsl -lgslcblas -lm
  • 5. install gmp

    CPPFLAGS=-I/install/path/include LDFLAGS=-L/install/path/lib ./configure --prefix=/install/path/
    make check
    make install
  • 6. install libRadtran

    CFLAGS=-I/install/path/include LDFLAGS=-L/install/path/lib ./configure --prefix=/install/path/
    make check
  • Test libradtran

    Then you can try to run libradtran with one of the example INPUT-files from the folder ./examples/ that comes with the package.

    uvspec < INPUT

    Then libradtran should start to calculate. Compare the results with the results-file for the corresponding input-file.
    See also the documentation PDF and the README and INSTALL files for further information. These are nicely written and normally should help solving most issues.

You like this article? Then you may want to subscribe to our RSS-Feed.

Add a comment

No comments yet!

Write the first comment now!


No Trackbacks yet.