HOW TO INSTALL CRAFT (version 1.2)

version 1.2

CraFT is written mostly in C (C99) and some features are written
in Fortran (F90 in a F77 manner).
Its installation has been tested on Linux Debian
but it should be able to be compiled on any Unix system.

The following text gives some details on how to compile it.

In this package, craft is accompanied with programs grouped into 3 packages:

  • microstructures:
    which includes several programs that generate microstructures
    ( xyzt, jmak, ns, ds, tire_euler_phase, pico )
  • xhmv: which is a simple 2d image viewer (I wrote it several years ago,
    but it can be useful)
  • imageprocessing: which enables simple operations on images
    (calculations, statistics, …)
3d microstructure (Voronoi tesselation)


  1. For all the codes (craft, xhmv, microstructures), you need:
    • Gnu make
    • a C compiler with C99 features + a Fortran 90 compiler
      • either gnu compilers: gcc + gfortran
      • or Intel compilers : icc + ifort
  2. To install craft, you need:
    • FFTW3
      You can download it from or as a package of your linux distibution
      (if it is your os).

      [ Remark:
      CraFT uses fast Fourier transforms. It could be implemented with different
      FFT packages (previous versions of the algorithm used many other FFT packages)
      but this version has been implemented with FFTW3 package.
      If you prefer to use another FFT package, I’m afraid you will have to modify
      craft_fft_image.c file.

    • lapack, blas
      You can download lapack and blas libraries from or as packages of your linux distribution.
    • hdf5 : HDF5 version > 1.8.0 (optional. See file)
  3. To install xhmv, you need:
    • X11 library
    • gtk+-2.0

Compiling CraFT (and companions)

    • If necessary edit and modify what you need in file
      present in this directory.

      In this file, you should just have:

      1. to choose the compilers you want to use.
        Set COMPILERS variable:
        • COMPILERS=intel
          if you want to use icc and ifort
        • COMPILERS=gnu
          if you want to use gcc and gfortran
      2. to choose to use OpenMP parallelization option by setting
        OPENMP variable to yes or no
      3. to choose to get a static or a dynamic executable by
        setting STATIC_LIBRARIES to yes or no
      4. to set the directories where fftw3 libraries and include files
        have been installed.
      5. set XHMV to yes or no if you want or don’t want to install xhmv
        (simple 2d image viewer)
      6. set use_HDF5 to yes if you want craft to be able to store intermediate
        calculation in HDF5 files, in order to be able to re-launch the calculation

      Of course, you can change other things in (typically
      CFLAGS, FFLAGS variables) but it is not necessary. has been initially set to compile with gcc anf gfortran compiler
      without OpenMP options, and to build an executable using dynamic libraries.

    • You can compile the different packages separately by typing in the current
      directory (the one containing this INSTALL file) one of the following commands:
      make craft
      make xhmv
      make microstructures
      make imageprocessing
    • Typing
      make all
      compile every packages.
    • Typing ‘make’ (or ‘make default’) is equivalent to ‘make craft’.

      This should build the executables:

      • bin/craft (CraFT program)

      and some tools:

      • bin/i3dtovtk (converts “i3d” CraFT image files into simple legacy VTK file format)
      • bin/vtktoi3d (converts simple legacy VTK files into “i3d” CraFT image file format)
      • bin/vtk2ppm (converts a simple legacy VTK file of scalar values into an image in PPM format)
      • bin/vtkstat (displays some infos about images in “i3d” or VTK format )
      • bin/general_i3d (creates a descriptor file for use of a i3d file in 3D scientific visualization
        program OpenDX)
      • bin/vtk_split (splits a VTK image of a symmetrical 2th order tensor field
        into images of its 6 scalar components)
      • bin/variables2image (convert an HDF5 generated by CraFT into VTK images of the fields
      • bin/image2variables it contains and vice-versa)
    • Typing ‘make xhmv’ generates the following executable codes:
      • bin/xhmv
    • Typing ‘make microstructures’ generates the following executable codes:
      • bin/xyzt generates a file of positions of points in a
        given volume and a given time interval
      • bin/jmak generates an image of a Voronoi, Johnson-Mehl or
        Laguerre tesselation
      • bin/tire_euler_phase generates a file of random orientations of grains
      • bin/ns generates a file of positions of centers of impenetrable
        spheres in a given volume
      • bin/ds generates an image from a file built with ns or sc
      • bin/sc generates a file of positions of centers of impenetrable
        spheres grouped in spherical clusters.
    • Typing ‘make imageprocessing’ generates the following codes:
      • bin/ciop enables simple operations on vtk or i3d images (addition, multiplication, …),
      • bin/general_i3d generates a header for OpenDX visualization (only for i3d images),
      • bin/histogram calculates the histogram of the input data,
      • bin/vtk_split split a vtk file with multicomponent voxels into scalar images of its components,
      • bin/vtkstat calculates statistics of the input image (vtk or i3d),
      • bin/i3dtovtk transforms a i3d image into a vtk image,
      • bin/vtktoi3d transforms a vtk image into a i3d image.
  • In order to clean all what has been compiled, type:
    make clean