Compilers and Libraries

Compilers: C, C++, Fortran, Java

The main compilers expected to be used are the GNU ones: these are available on pretty well any Unix system, cover several languages, and were used to build our systems as well as probably pretty well every extra program on it. It's just possible that someone will have a desire to try some other compiler, so two others are mentioned. The optimisations that the compiler uses can make a big difference to the execution speed and (in some cases) can affect the numerical results (!). This is discussed further on the optimisation page.

Note that any program can be installed and run by the user, in for example the home-directory (for smallish programs) or /local (for enormous things), using the environment to override system-installed versions.

GNU Compilers: GCC

The GNU Compiler Collection (version 4.1.2 as of 2007-10), is installed on all our systems: it has been used to build all of the system and open-source applications. The commands gcc, g++ and gfortran can be used to compile C, C++ and Fortran. gcj is a GNU Java compiler, but there are also Sun JDK java programs (javac, java) available. See the GCC manual pages, e.g. `man gcc', `man gfortran', for more information about options, Choosing the right options for the language version can be important in some cases, e.g. taking speed-advantage of the available processors, getting the desired treatment of floating point numbers (see optimisation page), or interpreting the code according to the desired standard -- for example, --std=c99 will allow the C99 extensions to C, such as complex types and specific integer lengths.

A very good Introduction to GCC is available on the web or as a book (we have a copy): it's a strongly recommended couple of hours' reading for anyone seriously considering compiled languages. The full GCC Online Documentation is much more detailed.

Sun Studio Compilers

Sun Studio (12) is a set of `parallelizing C, C++, Fortran and Java compilers', together with the NetBeans programming IDE (Integrated Development Environment), profiling, debugging and thread-optimisation. The command `sunstudio' starts the whole NetBeans-based GUI IDE. The compilers for direct command-line use are named starting with `sun', e.g. sunf95 for Fortran95: just type `sun' in a shell then press Tab a couple of times to list them. Manual pages may be a little hard to find, since they choose the general names such as `cc' rather than suncc. Try, e.g. man /opt/sunstudio12/man/man1/cc.1 in order to be sure of which page you're going to get (in this case, the cc manual, for suncc). I hope I've configured the environment adequately, so that it all compiles and links without extra paths being needed; it worked for me! I haven't used these compilers except for testing, as GCC was fine for my needs.

Intel Compilers

The Intel Compilers produce generally rather faster executables (some ten or few tens of percent) than GNU and Sun compilers, for Intel processors and sometimes even for AMD! This is based on my tests with a few Fortran or C solvers for ODEs. They are not free, except for personal (non-work) use. We do not currently have a licence for work use, but the Intel C and Fortran compilers (`icc', `ifort') are still present on from when a demo was used for testing speed on some fortran routines. If anyone tests these compilers and finds enough advantage in speed or some other parameter, that it's worth using them seriously, we can get a licence for them and possibly for the Intel `Math Kernel Libraries' that are also available but not installed. So far, the moderate speed-improvement (often around 10-20%) hasn't caused me to give up on GCC, which is more widely available. See the manual pages for the above compiler commands.

Java

Java is a programming language with a flavour of C and particularly C++, but with automated memory management. Its major distinction is that the language specification includes a mass of expected libraries for all manner of purposes. The intended way of using Java programs is to compile them into a `byte-code' form for an abstract Java virtual machine, then to have this virtual machine implemented on various hardware/operating-system combinations; the result is the ability to compile a program almost to machine code, then to use this compiled form on any computer that has a Java `runtime environment' (JRE) available. Other methods of compilation include conversion to a common language such as C, or compilation to native machine code; these implementations are unlikely to provide the full set of available libraries.

We have several versions of the blackdown and Sun Java development and runtime environments, as can be seen in the /opt/*jdk* directories. The commands `javac' and `java' compile and run Java programs. The command `java-config-2' allows setting of which version the user would like as default. Extensive documentation of the language and libraries is available locally in /usr/share/doc/java-sdk-docs-VERSION/html/index.html (change `VERSION' for whichever version you want, e.g. 1.5.0) or online, or along with example code within the SunStudio IDE (GUI editor/compiler/debugger). The GNU `gcj' is a part of gcc, providing another way of compiling Java code.

Java is sometimes used as a quite portable way to write programs that save time on the usual memory management issues of C or C++ but that don't pay such a price in performance as typical `scripting' languages.

A few available Libraries

Writing typical simulations from scratch in a language such as Fortran or C would be an error-prone waste of time. Fortunately there are lots of libraries and available programs already available, sometimes making for very fast simulations. ``Don't reinvent the wheel.''

It is possible to interface the compiled programs to convenient scripting and plotting languages such as Python and Matlab.

GSL: GNU Scientific Library

GSL is a useful set of numerical routines that can be used in C and Fortran programs. Its manual is available on the web, and we have a printed copy in the division's collection. The functions clearly are quite physics oriented, which is nice for us!

Other Libraries

Optimised (`Atlas') BLAS and LAPACK routines, are already installed. The Intel MKL has already been mentioned above, in relation to the Intel compilers. We do not have this at the moment.

Other links: Network.com, etc.

network.com is one of many sites with some links to details of potentially interesting libraries and interpreters, e.g. linear programming, FEM solution, Spice.

A large collection of FEM functions, able to be used directly for FEM solutions, is available at OOFEM. A (non-FEM) PDE solver Bacol has helped me with some 1D parabolic problems.


Page started: 2007-11-xx
Last change: 2008-12-01