Differences

This shows you the differences between two versions of the page.

sep:software:sepscons [2009/02/12 11:07]
sjoerd
sep:software:sepscons [2015/05/27 02:06] (current)
Line 12: Line 12:
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. 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.
-===== Features =====+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()''.
-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. 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.
- +
-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 ====== ====== How to use SCons and SEPSCons ======
Line 38: Line 36:
In your SConstruct and SConscript files, you can make the functions and variables of SEPSCons available to SCons by using the python ''import'' command. In your SConstruct and SConscript files, you can make the functions and variables of SEPSCons available to SCons by using the python ''import'' command.
<code python> <code python>
-import SEPSCons+from SEPSCons import *
</code> </code>
 +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 ======
-====== SCons files of a typical SEPSCons project ======+===== 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:
<code python> <code python>
from SEPSCons import * from SEPSCons import *
</code> </code>
 +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:
<code python> <code python>
-fld = Folders( B='#bin', S='#src', M='#mod' )+fld = Folders( BLD='#bin', SRC='#src' )
</code> </code>
 +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.
<code python> <code python>
env = SEnvironment( tools=['ifort'], folders=fld ) env = SEnvironment( tools=['ifort'], folders=fld )
</code> </code>
 +We are now ready to define a program from a source code. Just supply the main f90 file to the SProgram function.
<code python> <code python>
-pro = SProgram('driver.f90')+env.SProgram('driver.f90')
</code> </code>
- +Running this scons file would create the program ''driver.x'' in the ''~/bin'' folder. The whole SConstruct file looks like:\\ 
 +''~/SConstruct''
<code python> <code python>
from SEPSCons import * from SEPSCons import *
-fld = Folders( B='#bin', S='#src', M='#mod' )+fld = Folders( BLD='#bin', SRC='#src')
env = SEnvironment( tools=['ifort'], folders=fld ) env = SEnvironment( tools=['ifort'], folders=fld )
-pro = SProgram('driver.f90')+env.SProgram('driver.f90')
</code> </code>
- +==== Build, Clean and Burn ==== 
- +Although the target of the above ''SConstruct'' file is ''~/bin/driver.x'', it is aliased under ''driver.x''. Thus running 
-Initialize an environment with the ifort compiler\\ \\ +<code> 
-''/localdir/SConstruct'' +>> scons driver.x
-<code python> +
-from SEPSCons import * +
-fld = Folders( B='#bin', S='#src', M='#mod' +
-env = SEnvironment( tools=['ifort'], folders=fld ) +
-pro = SProgram('driver.f90')+
</code> </code>
- +Would build the specific target. All intermediate files can be cleaned running scons with the clean flag: 
-Congratulation's, you are now ready to issue SCons and SEPSCons commands to foster research that can benefit the greater good of humankind+<code> 
- +>> scons -c driver.x 
- +</code> 
-====== SEPSCons functions ====== +or 
- +<code> 
-===== General ===== +>> scons --clean driver.x 
-Folders +</code> 
- +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 burned, just run SCons with the burn flag: 
-SEnvironment +<code> 
- +>> scons --burn driver.x 
- +</code> 
-===== Program and Library ===== +This will enable clean mode and while the target is not protected by ''Noclean''. Effectively removing all the files created by the initial build.
- +
-SProgram +
- +
- +
-SLibrary+
====== FFTW and OPENMP ====== ====== FFTW and OPENMP ======
Line 112: Line 118:
====== Old Make Library sets ====== ====== 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']\\ SEPLIBC   = ['sep']\\
SEPLIBF90 = ['sepf90','sep'] + env['F90LIBS']\\ SEPLIBF90 = ['sepf90','sep'] + env['F90LIBS']\\
/web/html/data/attic/sep/software/sepscons.1234436858.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