Skip to content
Snippets Groups Projects

Script for installation of OpenFOAM and related ThirdParty packages

This script has been created to ease compiling OpenFOAM with various combinations of ThirdParty packages. It is named legacyCompile, since this represents a common situation in which the standard system toolchain is a bit out of date.

During the compilation, all output messages will be shown on screen as well as saved in log files. You will find all log files under the log/ folder.

Although the script has been tested with a variety of OS (mostly Linux) and package versions, it may not work for all users and environments.

So use it at your own risk


Prerequisites

  1. The legacyCompile script needs to have execution rights and be configured according to the package versions desired. For configuration, please see below.

  2. All packages, including OpenFOAM, ThirdParty, and those packs related to ThirdParty need to be stored under the packages/ subdirectory.

  3. Names of all packaged files must be as defined under default or under user-preference. For example, if under user-preference you have mesa-10.3.2, the file name should NOT be MesaLib-10.3.2.tgz.

    The same may apply to the following:

    • MesaLib-x.y.z files (replace by mesa-x.y.z)
    • llvm-x.y.z.src TarFile (remove .src part in filename and in subdir)
    • cfe-x.y.z.src TarFile must be moved to llvm-x.y.z/tools/clang
    • openmp-x.y.z.src TarFile must be moved to llvm-x.y.z/tools/openmp
    • ParaView-v* TarFile (remove -source part in filename and in subdir) Note: when unpacking ParaView, it may create a subdir with suffix -source. Please remove this suffix as well and tar the package again.
    • And potentially others, except QT files, which have a completely different naming anyhow.

    Please modify names by hand if required.

  4. OpenFOAM and ThirdParty packs need to unpack to a subdirectory with the same name as the file names (without extension). Hence if you have ThirdParty-v1612+.tgz, it should not unpack to ThirdParty-plus/ subdir.

  5. If you use clang as compiler, it must be the same version as llvm.


Configuration

Users need to define the desired packages and versions to use for the OpenFOAM compilation. The packages and versions need to be input under the section [software], stating whether the default version is to be used, or the user needs to use a different version. If both entries have information, the user-preference will prevail. In any case, a suitable tar/zip file with packageName-versionNumber needs to be placed under subdir packages/. The value ompiType refers to the openmpi type (system|third).

[software]
# Preferred software versions etc. Use 'third' for ThirdParty.
#---------------------+-------------------+-------------------+
#   package           | default           | user-preference   |
#---------------------+-------------------+-------------------+
    boost               boost_1_62_0
    cgal                CGAL-4.9
    fftw                fftw-3.3.5
    openmpi             openmpi-1.10.4
    scotch              scotch_6.0.3
    paraview            ParaView-5.0.1
    cmake               cmake-system        cmake-3.5.2
    vtk                 none                VTK-7.1.0
    mesa                none                mesa-13.0.1
    qt                  system              qt-4.8.7
    llvm                llvm-3.7.0
    gcc                 system              gcc-4.8.5
    gmp                 system              gmp-6.1.1
    mpfr                system              mpfr-3.1.5
    mpc                 system              mpc-1.0.3
    label               32
    precision           DP

    ompiType            system              third
    compilerType        system              third
    compiler            Gcc                 Gcc
#--------------------------------------------------------------

Usage

./legacyCompile [OPTIONS] OPERATION [...OPERATION] configFile
options:
  -purge                Purge old directories before unpacking (CAUTION)
  -int32  | -int64      Label width
  -SP     | -DP         Precision
  -sigfpe | -no-sigfpe  Activate/deactivate FOAM_SIGFPE handling
  -help

operations:
  -unpack           Unpack sources, configure
  -third            Compile ThirdParty
  -foam             Compile OpenFOAM
  -list             List configured versions only
  -all              Alias for -unpack -third -foam
  -rebuild          Alias for -third -foam

The script contains the three essential operations:

  1. unpack (the -unpack option)
  2. compile/recompile ThirdParty packages (the -third option)
  3. compile/recompile OpenFOAM (the -foam option)

The -all shortcut is a simple way to do all three together. The -rebuild shortcut just does -third and -foam (without the unpack stage).

  • To compile first time (from scratch) with default label size and precision:

    ./legacyCompile -all configFile

  • To repeat the same, overwriting any existing installation:

    ./legacyCompile -all -purge configFile

  • To unpack all packages and configure some OpenFOAM settings without compiling:

    ./legacyCompile -unpack configFile ./legacyCompile -unpack -purge configFile # Caution: removes existing installation

To compile with 64 bit label size in single precission:

./legacyCompile -all -int64 -SP configFile

If you change your third-party package selections or the preferred configuration (SP, DP etc), you will need the -unpack operation, which also includes some configuration operations.

./legacyCompile -unpack configFile

To (re)compile ThirdParty and OpenFOAM individually:

./legacyCompile -unpack -third -purge configFile
(to compile ThirdParty from scratch)

./legacyCompile -foam configFile
(to compile OpenFOAM from existing ThirdParty)

To compile with 32 bit label size in single precission:

./legacyCompile -all -int64 -SP configFile

Notes

The standard compilation of OpenFOAM and ThirdParty (as done by OpenFOAM itself) will only rebuild the out-of-date parts.

Since the building of individual ThirdParty infrastructure components (eg, the compiler itself, paraview, etc) are all essentially forced builds, the legacyCompile script uses the log files to detect if an infrastructure component has already been built or not.

If you experience issues when building such a subcomponent (eg, building Clang), you should remove the corrsponding logfile(s) before recompiling with the '-unpack -third` options.


2017-06-29