2. Installation

2.1. Getting the code

The code is available on a git repository, hosted on github: https://github.com/ita-solar/rh. If you don’t have git installed and just want to get started, the easiest way is to download a zip file with the latest revision: https://github.com/ita-solar/rh/archive/master.zip. If you have git installed and would like to be up-to-date with the repository, you can do a git clone:

git clone https://github.com/ita-solar/rh.git

or using SSH:

git clone git@github.com:ita-solar/rh.git

Whether you unpack the zip file or do one of the above it will create a directory called rh in your current path. This directory will have the following subdirectories:

Directory Contents
rh Main RH source
rh/Atmos Used to keep atmosphere files
rh/Atoms_example Used to keep atom files, line and wavelength lists (example)
rh/idl Old RH IDL routines, not used
rh/Molecules Used to keep molecule files
rh/python Utility Python programs
rh/rh15d. Source files for RH 1.5D
rh/rhf1d Source files for 1D geometry, deprecated, do not use
rh/rhsphere Source files for spherical geometry, deprecated, do not use
rh/tools Associate C programs for RH, not tested.

Warning

The source code directories for other geometries (rhf1d, rhsphere) are still in the code tree, but they are deprecated and will be removed soon. With the latest changes related to rh15d, they are not guaranteed to work or even run. Do not use.

2.2. Dependencies

2.2.1. HDF5

RH 1.5D makes use of the HDF5 library to read the atmosphere files and write the output. It is not possible to run the code without this library. RH 1.5D requires HDF5 version 1.8.1 or newer (including versions 1.10.x).

Note

RH 1.5D previously made use of the netCDF4 library for its output (which in turn also required HDF5). The latest changes mean RH 1.5D needs only HDF5. Because netCDF4 files are also HDF5 files, the output is still readable in the same way as before and input files in netCDF version 4 format can still be read in the same way by RH 1.5D. If you used input atmospheres in netCDF version 3 format, then these will have to be converted to HDF5. It is recommended that new atmosphere files be created in HDF5 only.

Because HDF5 is commonly used in high-performance computing, many supercomputers already have them available. In Fram, they can be loaded as (also loading the intel compilers):

module load HDF5/1.8.19-intel-2018a intel/2018a

in Pleiades:

module load hdf5/1.8.18_mpt

in Vilje:

module load intelcomp/18.0.1 mpt/2.14 hdf5/1.8.19

in Hexagon:

module load cray-hdf5-parallel

and at ITA’s Linux system:

module load hdf5/Intel/1.8.19 Intel_parallel_studio/2018/3.051

2.2.2. MPI

RH 1.5D is parallelised via MPI, therefore an MPI library is necessary even if running with only one CPU. These are readily available in supercomputers and clusters, but not always in individual workstations. In such cases, users will have to manually install both MPI and HDF5 libraries (HDF5 should be compiled with the MPI library so that the parallel I/O module works).

If using Linux or MacOS, HDF5 is available in a variety of ways. The safest bet is to download and compile HDF5 from the source, enabling parallel builds in the ./configure script, e.g.:

./configure (...) --enable-parallel

An easier way, but not guaranteed to work every time, is to install both MPI and HDF5 with parallel support is via the Anaconda Python distribution. Once you install Anaconda (version 3.6 or above), you can install the hdf5-parallel package, which installs both MPI and HDF5 and has been tested with RH 1.5D:

conda install -c spectraldns hdf5-parallel

Warning

If you obtain pre-compiled binaries or packages for HDF5, you need to make sure they have parallel support enabled. Most available packages do not have parallel support. This includes typical packages from Linux distributions and the hdf5 Anaconda package (but not the above hdf5-parallel package).

2.3. Compilation

Compilation of RH 1.5D consists of two steps:

  1. Compilation of the geometry-independent main libraries (librh.a and librh_f90.a)
  2. Compilation of the rh15d_mpi tree and main binaries

RH 1.5D has been compiled in a variety of architectures and compilers, including gcc, the Intel compilers, and clang. As for MPI implementations, it has been tested with SGI’s mpt, OpenMPI, mpich, mvapich, and Intel’s MPI.

2.3.1. Makefile configuration

RH 1.5D does not automatically look for the compilers and libraries. You need to tell RH which compilers to use and where to find the HDF5 library by editing the file rh/Makefile.config. This file is also used to set up any additional compiler or linker flags, if appropriate. Changes to any other Makefiles are not necessary. It is also no longer necessary to set the environment variables OS and CPU, as in previous versions.

For HDF5_DIR, please enter the base directory for the library (not the directory with the lib* files), so that both library and include files are used. In Fram and Hexagon this is already stored in the HDF5_DIR environment variable, so you can comment that line in Makefile.config. If your version of HDF5 was not built as a shared binary, you need to link HDF5 and other used libraries directly (you will need to set at least -lz in LDFLAGS).

There are two steps in the compilation: main libraries and rh15d binaries. To speed up compilation, you can use parallel builds (e.g. make -j8) in all steps of the compilation.

2.3.2. Main libraries

The common RH files are put in a library under the base directory. After editing Makefile.config, build the main libraries with make on the rh directory. If successful, the compilation will produce the two library files librh.a and librh_f90.a.

2.3.3. Program binaries

The rh15d contains the source files for the 1.5D version. After compiling the main library, go to that directory and compile the binaries with make. The following executables will be created:

File Description
rh15d_ray_pool Main RH 1.5D binary, uses a job pool (see Binaries and execution)
rh15d_ray Alternative RH 1.5D binary. Deprecated. This program runs much slower than rh15d_ray_pool and is kept for backwards compatibility only. Will be removed in a future revision.
rh15d_lteray Special binary for running in LTE

2.4. Run directory

Once compiled, you can copy or link the binaries to a run directory. This directory will contain all the necessary input files, and it should contain two subdirectories called output and scratch.

Warning

If the subdirectories output and scratch do not exist in the directory where the code is run, the code will crash with an obscure error message.