-
Notifications
You must be signed in to change notification settings - Fork 7
The build system
Bruce chose to use the SCons software construction tool to manage the building and installation of the many parts of feff85exafs. From the SCons website:
Think of SCons as an improved, cross-platform substitute for the
classic Make utility with integrated functionality similar to
autoconf/automake and compiler caches such as ccache. In short,
SCons is an easier, more reliable and faster way to build
software.
Because one of the main targets for feff85exafs development is Matt Newville's Larch, SCons is attractive choice as it is also a Python-based tool. In fact, the SConstruct files (i.e. the SCons equivalent of a Makefile) are themselves python scripts. Thus anyone sufficiently famliar with python to be happy using Larch should also be happy enough using SCons.
The build system should work on all the major platforms -- linux, Windows, and Mac. SCons fits that requirement, although the feff85excafs build system has not yet been tested on Windows or Mac.
In the src/
directory, there is a file called FeffBuild.py
, which is used to configure the compilation and installation environments appropriately for different platforms and different Fortran & C compilers. It is also used to define "factories" (i.e. compilation or installation targets) used throughout the build system.
At this time, compilation has only been tested using gcc and gfortran on an Ubuntu machine. As we get more experience, FeffBuild.py
will grow.
From the top directory, simply typing
~> scons
at the command line will build everything, including the executable components and the various libraries.
Similarly,
~> scons install
or
~> sudo scons install
will install all the libraries and executables to places appropriate to the system.
system | libraries | binaries |
---|---|---|
linux | /usr/local/lib |
/usr/local/bin |
Windows | C:\\someplace |
C:\\someplace |
Mac | /someplace |
/someplace |
Each subdirectory underneath src
has its own SConstruct
file. (In fact, the top level SConstruct simply recurses into each subdirectory.) Thus you can enter any sudbirectory and do scons
or scons install
to build just that part of Feff.
Several subdirectories -- RDINP/
, POT/
, XSPH/
, PATH/
, GENFMT/
, and FF2X/
-- contain code and instructions for building executables for Feff's components as well as libraries used by Feff and by the various wrappers.
Others -- ATOM/
, COMMON/
, DEBYE/
, EXCH/
, FOVRG/
, HEADERS/
, JSON/
, MATH/
, and PAR/
-- contain code which is compiled into libraries used by the executables and the wrappers. HEADERS/
contains many of the header files used throughout Feff.
Before attempting to build the wrappers, you must build and install the rest of feff85exafs following the instructions above.
As part of the installation process, certain files will be copied from src/GENFMT/
to various places in the wrappers/
directory. Without those files, it is impossible to build certain wrappers.
An example Fortran program using the Fortran entry point -- the onepath
library -- is in the wrappers/fortran/
directory. There is also a SConstruct
file for using SCons to compile the program. The example program will use a phase.bin
file from a prior Feff calculation on copper metal to make feffNNNN.dat
files for the first (first shell single scattering) and founrth (double scattering) paths.
An example C program uses the phase.bin
file from the Fortran folder to write the same two feffNNNN.dat
files. This simple program demonstrates how to interact with the struct that is used to encapsolate all the data associated with the feffNNNN.dat
file. Again, a SConstruct
file is provided to compile the C code into an executable.
When the GENFMT portion of Feff was compiled, SWIG was used to generate a thin Python wrapper around the feffpath
C library. This SWIG wrapper is weird and ungainly, so a proper python module / Larch plugin called scatteringpath.py
is provided. This is intended to be installed as a part of Larch. To build and install, do
python setup.py build_ext --inplace
sudo python setup.py install_data
To test the python wrapper,
nosetests --verbosity=3
When the GENFMT portion of Feff was compiled, SWIG was used to generate a thin Perl wrapper around the feffpath
C library. This SWIG wrapper is weird and ungainly, so a proper perl module using Moose called Xray::FeffPath
is provided. To build and install, do
perl Makefile.PL
make
make test
sudo make install
Wrappers for other languages are welcome. Feel free to fork feff85exafs, add a new wrapper to the wrappers\
directory, and make a pull request!
An experiment being conducted with feff85exafs is to replace most of Feff's weird intermediate text files -- the things called modN.inp
, xsect.bin
, geom.dat
, global.dat
, and so on -- with JSON files containing the equivalent information. To make this happen, Bruce used a Fortran 2003 implementation of the JSON spec: https://github.com/jacobwilliams/json-fortran
This works, but it imposes an additional compiler constraint on feff85exafs. Along with a Fortran 77 compiler (for most of Feff) and a C compiler (for the wrappers), you also need a Fortran 90 compiler that knows Fortran 2003 extensions.
Using gfortran, version 4.9.2 or higher is required. Version 4.8 is known not to compile json-fortran correctly.
We currently have no experience with other compilers, but the json-fortran github page claims that the Intel compiler and Visual Studio 2010 can be made to work.
A recent version of json-fortran is in the source tree in src/
and gets compiled along with the rest of Feff.