How to Compile or Re-compile deMon2k

Once deMon2k is installed on your system, you might want to recompile an executable because you need to change some parameters or include some modifications. Or you want to compile an executable of a different type, e.g. an executable for execution in parallel. The deMon2k program is shipped with two compilation scripts called CREX and crex (CReate EXecutable). CREX is intended for the master version, crex for an individual version.

The CREX script can be used to recompile or create a (new) master version of deMon2k. This is done by the installation script also. The "master" version is intended to be an "original" version, i.e. a version without any user modifications of the source code. If, during the installation, you have created, for example, a standard version "std" and you want to generate a debug version "dbg", you can do this by running CREX. The master version is usually installed in a directory accessible to all users of a machine. The standard directory is /usr/local. Therefore, you should do this installation as root. CREX expects the following settings:

    $CREX_ROOT=/usr/local              ! or another directory where 
                                       ! deMon2k is/will be installed;
                                       ! you have to export this variable 
    $CREX_ROOT/deMon/.default-version  ! contains the version number 
                                       ! x.y.z of the version to be 
                                       ! compiled
    $CREX_ROOT/deMon/x.y.z/source/     ! directory for source files
    $CREX_ROOT/deMon/x.y.z/include/    ! directory for include files
    $CREX_ROOT/deMon/x.y.z/database/   ! directory for database files
The variable $CREX_ROOT must point to the directory where the master version of deMon2k is installed, if it is not installed in /usr/local. If all required files are there, then type
If you are running on a LINUX system, a menu similar to the following one will appear:
    Select compiler (Linux only).

      1. Portland Group pgf90
      2. Intel Fortran 90
      3. xlf (IBM)
      4. GNU Fortran 90 (gfortran)

    Enter a number:
Choose your compiler and type <Enter> (the menu above is not shown after a successful basic installation). Next, choose which kind of executable is to be created.
    Choose a compilation type:

      1. Debug compilation
      2. Standard compilation
      3. Optimization compilation
      4. Parallel MPI compilation
      5. Parallel debug compilation

    Select a number:
After your selection of the compile type, CREX will start the compilation (you will not see this menu in the basic installation because the compile type was chosen earlier). If compilation and linking is successful, CREX will terminate with the message
    Executable program deMon.x.y.z.* created.
    Normal termination of CREX.
The executable is written to
where the * stands for the type of executable that was created, e.g. std if you have generated a standard version. If the compilation fails, the message
    Abnormal termination of CREX.
appears. In this case you should check the README file in the directory deMon.x.y.z for troubleshooting.

A local version of deMon2k can be created with the crex script. Thus, each user can create a personal version of deMon2k by adding or modifying source and/or include files without changing the master version. The crex script will compile only the modified files and link them with the unchanged files of the master version. For this reason, the crex script is also well-suited to exchange local developments with other users or between research groups. The crex script expects the following settings:

    $CREX_ROOT=/usr/local              ! or another directory where 
                                       ! the master version of deMon2k
                                       ! is installed. The default 
                                       ! is /usr/local
    $CREX_ROOT/deMon/.default-version  ! specifies deMon2k master version
    $CREX_ROOT/deMon/x.y.z/object.*/   ! that contains all object files 
                                       ! of the x.y.z.* version. The "*"
                                       ! denotes the kind of version, 
                                       ! e.g. "std"
    $HOME/demon/                       ! main directory for the local 
                                       ! version (lower-case characters!)
    $HOME/demon/.default-version       ! specifies local deMon2k version
    $HOME/demon/x.y.z/source/          ! contains the modified source 
                                       ! files that are compiled and 
                                       ! then linked to the x.y.z 
                                       ! master version
    $HOME/demon/x.y.z/include/         ! contains modified include files 
                                       ! (directory must exist, 
                                       ! but can be empty)
and follow the instructions. They are similar to those of the CREX script (see above). After successful compilation, the executable is written to
If the compilation is unsuccessful, the message
    Abnormal termination of crex.
appears. In this case you should check the README file in the directory deMon.x.y.z for trouble shooting.