This is an old revision of the document!


SCons

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 www.scons.org. A good Python tutorial can be found on http://docs.python.org/tut/ .

SEPSCons

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 an Environment initiation function wrapped around the SCons Environment function. This function 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. SEPSCons handles these with with a class Folders. This class is regularly used by other SEPSCons functions to evaluate where to build from and where to build to.

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.

from SEPSCons import *

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

General

Folders

SEnvironment

Program and Library

SProgram

SLibrary

Elementary SEPSCons

This section goes step by step through an elementary SEPSCons example. Though more complicated builds are not much more involved. In the project folder, you open a file SConstruct where as a first step you import SEPSCons:

from SEPSCons import *

The second step is to define the folder structure of your project. You will typically want to define a source folder SRC and a build folder BLD. Use the SEPSCons folder function like this:

fld = Folders( BLD='#bin', SRC='#src' )

Secondly, we will need to initilize a scons environment with for example the tool 'ifort' that operates with the specified folder structure fld using the SEnvironment function.

env = SEnvironment( tools=['ifort'], folders=fld )

We are now ready to define a program from a source code. Just supply the main f90 file to the SProgram function.

env.SProgram('driver.f90')

Running this scons file would create the program driver.x in the ~/bin folder. The whole SConstruct file looks like:
~/SConstruct

from SEPSCons import *
fld = Folders( BLD='#bin', SRC='#src')
env = SEnvironment( tools=['ifort'], folders=fld )
env.SProgram('driver.f90')

Build, Clean and Burn

Although the target of the above SConstruct file is ~/bin/driver.x, it is aliased under driver.x. Thus running

>> scons driver.x

Would build the specific target. All intermediate files can be cleaned running scons with the clean flag:

>> scons -c driver.x

or

>> scons --clean driver.x

The final target file ~/bin/driver.x was kept save from the clean because SProgram protected it with the SCons Noclean function. When the target needs to be nurned, just run SCons with the burn flag:

>> scons --burn driver.x

This will enable clean mode and while the target is not protected by Noclean. Effectively removing all the files created by the initial build.

FFTW and OPENMP

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

When you start to build executables with SCons, you might want to know these old Make file library sets. It will help you figure out which libraries you need to add to the Build Environments to get your programs to compile.

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']

RSFTex

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/
setenv PYTHONPATH ${PYTHONPATH}:$RSFROOT/lib
set path = ($path $RSFROOT/bin)

In your report folder you need a SConscript like

/localdir/report/SConstruct

from rsftex import *
 
End(resdir='Fig',use='color,amsmath,amssymb,amsfonts')
/web/html/data/attic/sep/software/sepscons.1234492597.txt.gz · Last modified: 2015/05/26 22:41 (external edit)
www.chimeric.de 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