HIRLAM on Linux

Toon Moene

Introduction.

Ever since I have been able to compile the HIRLAM Forecast model using just the publicly available f2c Fortran-to-C translator and the C compiler on my NeXTStation (a derivative of the GNU C compiler) in July 1992, I was convinced that in the end, it would be possible to run HIRLAM on a Linux system. And (since the conversion of the analysis code to 32 bits in 1996) indeed it is.

Caveats.

I tested all that I describe below on a 300 Mhz Pentium II based machine with 64 Mbyte of memory (and 6 Gbytes of disk). However, it should work on other Linux systems too (either Sparc, Alpha, PPC or MIPS based). Note that the 4.6.3 version of HIRLAM uses so much memory that on machines with just 64 Mbyte of memory it is advisable to only use 16 layers in the vertical when running the standard test suite - in fact, even then you will be swapping; for running the test suite as is, you need a 256 Mbyte machine.

Prerequisites.

Actually, very few. A recent distribution of Linux is required, for instance Red Hat 6.0 or 6.1, SuSE 6.1, Debian 2.1 or Caldera 2.3 (I personally use Red Hat 5.2 because that was the newest when I bought my laptop, but other distributions should work as well).

Because HIRLAM tends to use quite a lot of stack space, a preliminary action has to be taken to assure that you get enough of it. The following worked for me:

As root, write a short file /etc/initscript as follows:

ulimit -s 131072
eval exec "$4"
and reboot your system. For an explanation, see man initscript.

Compilers.

Although I thought that Red Hat distributed the full GCC compiler suite - which includes FORTRAN - on my 5.2 system I couldn't find it. So I installed gcc-2.95.2 (get if from: http://gcc.gnu.org/gcc-2.95/gcc-2.95.2.html).

After you transferred it to your system:

% tar zxvf gcc-2.95.2.tar.gz                    # Unpack the compiler
% mkdir obj                                     # Create build directory
% cd obj                                        # Go there
% ../egcs-2.95.2/configure && make bootstrap    # Configure & build
% su                                            # Become root
<root password>                                 #  on your system
# make install                                  # And install ....
# exit                                          # Exit root shell
This will install the C, C++ and FORTRAN compilers into /usr/local/bin, i.e. they will not overwrite the compilers that come with the system, but normally will be the ones used, because /usr/local/bin precedes /usr/bin in your PATH.

If you are convinced the compilers are working correctly, you can delete the gcc-2.95.2 and obj directories - they are not needed after the installation of the compilers has been completed.

Installing HIRLAM.

I tested this with the HIRLAM Reference System current at the time of writing, namely version 4.6.3. I refer you to the standard README file that comes with the HIRLAM suite you can obtain from ecgate1.ecmwf.int using the script ~nkg/LocalInstall/Getref.

I changed the following in Env_system:

CS=G77
...
OS=LINUX
...
ENDIAN=LITTLE export ENDIAN
...
MAKE=make
CO=co
MKDIR="mkdir -p"
WHENCE=whence
...
This is actually one of the nice things about Linux systems: All the necessary GNU utilities are already installed for you.

Don't forget to put the correct directory information for this modified Env_system into ~/hl_scr/Hirlam !

You need to copy qsub, qstat, qdel, whence and ja from the directory emulations to ~/hl_util/bin; then set the execute bit on them with chmod +x ~/hl_util/bin/*

Running the test suite.

Now you should be able to run the test suite (analysis and 6 hour forecast for 1995070300 and analysis and 6 hour forecast for 1995070306 subsequently).

In the ref directory in your home directory (created by the HIRLAM installation script) issue the command:

	~/hl_scr/Hirlam start
Note that no DTG is nessary - the test suite DTG is assumed automatically.

Endianess issues.

Although you can run HIRLAM off the testsuite data as provided by the GetRef script on either big- or little-endian machines, ASIMOF files transferred from a little endian machine (like an Intel PC or an Alpha) can not be read on MIPS, PPC or Sparc (big endian) machines and vice versa. If you try to use diasim on it, you will get an error like the following:
% ./diasim.x IN199507
 DIAGNOSIS OF FILE 
 IN199507
 JPLREC LESS THAN THE NUMBER OF FIELDS
 JPLREC:        3000,NFLD:   150994944
Fortran abort routine called
In that case you forgot to specify ENDIAN=LITTLE in your Env_system, or you are trying to read an ASIMOF file from a big endian machine on your Intel or Alpha system.

Acknowledgements.

I would like to thank Ray McGrath and Laura Rontu for input on using HIRLAM on Linux, some of which is reflected in this document.

Advanced Usage.

Those of you with time to spare could try and add the option -fbounds-check to the OPT flags for g77 in the Makefile. This will check all array accesses for array bound overruns.

Success !