This is an old revision of the document!


SCons is an Open Source software construction tool based on Python. It is intended as a replacement for the classic Make utility and has the capability of a script language. In short, SCons is an easier, more reliable and faster way to build software. Or at least, that is what their website claims. There is a learning curve to SCons and Python, there are advantages and disadvantages for SCons with respect to Make. There are many ways to perform the same actions in SCons, each with it's own advantages and disadvantages. The road to success with SCons is to make clever use of the advantages and to suffer least from the disadvantages.

Carefull reading the SCons users guide is the key. Please read more on A good Python tutorial can be found on .


SEPSCons is a python file that contains a series of functions that make it easy to use SCons and SEPlib software in research projects. SEPSCons is currently fine tuned for the SEP computing environment. As the project expands, the configuration to work on our internal network and cluster computers will be decoupled from the functionality added by SEPSCons.

It is already said that there are many ways to get to the same result in SCons. The examples on this page are often straight forward and offer for much flexibility.


The main feature of SEPSCons is a initiation function, that configures a SCons construction environment for our SEP computing environment. After initiating a SEPSCons construction environment one can still change construction keys using the SCons functions env.Replace(), env.Append() or env.Prepend().

Very important for your research is the proper implementation of a directory tree to carefully organize the project. A common organization scheme would include a source folder (/src), a binary folder (/bin) and a result folder (/fig). These folders are implementing using SCons functionality. In addition to above three directories, separate module (/mod) and object (/obj) folders can avoid cluttering of intermediate files into the binary folder. To that objective SEPSCons initiated environments have a MODDIR-key and the OBJDIR-key. The module files are automatically placed in the module folder by the (fortran) compiler. Object files are placed in the object folder, when the alternative SEPSCons builder commands env.OProgram and env.OLibrary() are used (see below). These recursively declare Object build entries and than a Program respectively Library build entry.

How to use SCons and SEPSCons

To use SCons and SEPSCons you will have to modify the sourcing file of your favourite shell terminal such that both SCons and SEPSCons are added to your Python path. For example in cshell, you need to modify your .cshrc file to contain

set path = ($path /opt/scons-1.0.1/bin)
setenv PYTHONPATH ${PYTHONPATH}:/opt/scons-1.0.1/lib/
setenv PYTHONPATH ${PYTHONPATH}:/opt/sepscons/

You are now ready to use SCons and SEPSCons. SCons can be run from the shell terminal by issuing the command scons

~$ scons

This would cause SCons to read the local SConstruct file, build or update a dependency tree, and build all targets that end up in the SCons variable BUILD_TARGETS. The variable BUILD_TARGETS contains either the default targets specified in the SConstruct and SConscript files or it contains the command line target that can be supplied to scons by specification in the shell terminal call to SCons.

~$ scons target

In your SConstruct and SConscript files, you can make the functions and variables of SEPSCons available to SCons by using the python import command.

import SEPSCons

SCons files of a typical SEPSCons project

SCons is used by a SConstruct file. To run this SConstruct file, this file is best placed in your /localdir/. This SConstruct-file, is the equivalent of a Makefile, all commands you whish to make available for your project can be written in this SConstruct-file. Presently, we only aim to construct executables, so at this stage the contents of SConstruct are best be kept minimal. We only whish to specify a /localdir/src/ folder and a localdir/bin/ folder.


import SEPSCons
SConscript( ['src/SConscript'], variant_dir = 'bin', duplicate = 0 )

Strictly speaking, the import SDRSCons command is redundant here, because we do not use any the functionalities or variables made available in SEPSCons. SConscript() is a SCons function that makes all SCons commands inside the specified SConscript file available to SCons. The variant_dir variable that is passed on to this SConscript file is the folder that is used as the target folder for the builds specified in the included SConscript file. the duplicate variable is set to be 0 to avoid the default but unnecessary copying of source files from the /localdir/src/ folder to the /localdir/bin folder prior to the compiler execution inside the /localdir/bin folder. Instead, SCons now issues a compiler execution command that specifies the source and binary folders.

The SConscript file contains SCons Program() and (optional) Object() functions that are necessary to construct a executable from it's source file(s). We start by importing the SEPSCons module and initializing a SCons default construction environment in this example named env. We than continue to initialize this env SConstruction environment as a SEPSCons environment by calling the SEPSCons function init( ). This associates a SEPlib version to this SConstruction environment and configured the Fortran and C compiler Flags of SCons for our computing environment. We also enabled a set of variables and functions to this environment that will come in useful working with the SEP computing environment.

Initialize an environment with the ifort compiler

from SEPSCons import *
fld = Folders( B='#bin', S='#src', M='#mod' )
env = SEnvironment( tools=['ifort'], folders=fld )

Notice how we supply the optional argument LIBS='$SEPLIBF90'. SEPLIBF90 is a pre-defined set of libraries for Fortran that make the most basic SEPlib libraries available. It's c counterpart is named $SEPLIBC. For many c programs, the Fortran library set would work as well.

Congratulation's, you are now ready to issue SCons and SEPSCons commands to foster research that can benefit the greater good of humankind.

SEPSCons functions




Program and Library




Configure your environment for FFTW:

env.Append( F90PATH = ['/opt/FFTW/include'] )
env.Append( LIBS    = ['fftw3','fftw3f'] )
env.Append( LIBPATH = ['/opt/FFTW/lib' ] )

Configure your environment for OPENMP:

env.Append( F90FLAGS  = ' -openmp' )
env.Append( LINKFLAGS = ' -openmp' )

Old Make Library sets

SEPLIBC = ['sep']
SEPLIBF90 = ['sepf90','sep'] + env['F90LIBS']
SEPLIB3DC = ['sep3d','sep']
SEPLIB3DF90 = ['sep3df90','sep3d','sepf90','sep'] + env['F90LIBS']
SUPERSETC = ['superset','sep3d','sep']
SUPERSETF90 = ['supersetf90','superset','sep3df90','sep3d','sepf90','sep'] + env['F90LIBS']
VPLOTC = ['vplot']
VPLOTF90 = ['vplotf90','vplot']
GLPLOT = ['glplot']
GEEF90 = ['sepgeef90']
GEELIB = ['sepgeef90','sep2df90','sep3df90','sep3d','sepf90','sep'] + env['F90LIBS']
SEPMATHC = ['sepmath']
SEPMATHF90 = ['sepmathf90']
SEPAUXCC = ['sepaux']
SEPAUXF90 = ['sepauxf90','sepaux']
SEPFFTC = ['sepfft','sepfftf90','sepfft'] + env['SEPMATH']
SEPFFTF90 = ['sepfftf90','sepfft','sepfftf90','sepfft','sepauxf90','sepaux']
SEPCONVERTC = ['sepconvert']
SEPCONVERTF90 = ['sepconvertf90',' sepconvert']
SEPVECTORC = ['sepvector']
SEPVECTORF90 = ['sepvectorf90','sepvector']
SEPFILTER = ['sepfilter']
SEPTRAVELC = ['septravel','sepaux']
SEPTRAVELF90 = ['septravelf90','septravel']
SEPVELANF90 = ['sepvelanf90']
SEPFILTERF = ['sepfilterf90', 'sepvectorf90','sepvector']
BEILIB90 = ['bei90'] + env['GEELIB']
BEILIB = ['bei']

TDFLIB = ['tdf']
BEILIB = ['bei']
PVILIB = ['pvi']
GEMLIBF = ['gem']
TDFLIBF = ['tdf']
BEILIBF = ['bei']
PVILIBF = ['pvi']


Currently, we are using Sergey Fomel's document building scripts for SCons that are part of his RSF Madagascar seismic software package.

Madagascar is installed on pompei. And uses a older version of SCons than SEPSCons does. Therefore it is best to keep your report folder seperated from your main folder (for example in a sub-folder), untill we have removed the incompatibilities. Also, you can only compile your paper on pompei.

Your .cshrc file should include, after your SEPCons entry (see below)

setenv RSFROOT /opt/RSF/
set path = ($path $RSFROOT/bin)

In your report folder you need a SConscript like


from rsftex import *
/web/html/data/attic/sep/software/sepscons.1234436722.txt.gz · Last modified: 2015/05/26 22:41 (external edit) Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0