--- trunk/SConstruct 2009/06/16 06:32:15 2474 +++ trunk/SConstruct 2009/11/27 05:03:09 2787 @@ -1,7 +1,7 @@ ######################################################## # -# Copyright (c) 2003-2008 by University of Queensland +# Copyright (c) 2003-2009 by University of Queensland # Earth Systems Science Computational Center (ESSCC) # http://www.uq.edu.au/esscc # @@ -16,6 +16,8 @@ EnsurePythonVersion(2,3) import sys, os, re, socket, platform, stat +# For copy() +import shutil # Add our extensions if os.path.isdir('scons'): sys.path.append('scons') @@ -33,18 +35,24 @@ prefix = ARGUMENTS.get('prefix', Dir('#.').abspath) +#Holds names of variables from the calling environment which need to be passed +#to tools +env_export=[] + #Determine where to read options from use: #1. command line #2. scons/_options.py #3. name as part of a cluster options_file=ARGUMENTS.get('options_file', None) +effective_hostname=socket.gethostname().split('.')[0] if not options_file: - hostname = re.sub("[^0-9a-zA-Z]", "_", socket.gethostname().split('.')[0]) - options_file = os.path.join("scons",hostname+"_options.py") + mangledhostname = re.sub("[^0-9a-zA-Z]", "_", effective_hostname) + options_file = os.path.join("scons",mangledhostname+"_options.py") #If there is no options file with that name see if there is a substitute if not os.path.isfile(options_file): - tmp = scons_extensions.effectiveName(hostname) - options_file = os.path.join("scons",tmp+"_options.py") + effective_hostname = scons_extensions.effectiveName(effective_hostname) + mangledhostname = re.sub("[^0-9a-zA-Z]", "_", effective_hostname) + options_file = os.path.join("scons",mangledhostname+"_options.py") if not os.path.isfile(options_file): print "Options file not found (expected '%s')" % options_file @@ -94,6 +102,7 @@ BoolVariable('usepedantic', 'Compile with -pedantic if using gcc', 'no'), BoolVariable('usewarnings','Compile with warnings as errors if using gcc','yes'), ('forcelazy','for testing use only - set the default value for autolazy','leave_alone'), + ('forcecollres','for testing use only - set the default value for force resolving collective ops','leave_alone'), # Python ('python_path', 'Path to Python includes', '/usr/include/'+python_version), ('python_lib_path', 'Path to Python libs', usr_lib), @@ -115,7 +124,7 @@ ('mpi_path', 'Path to MPI includes', '/usr/include'), ('mpi_run', 'mpirun name' , 'mpiexec -np 1'), ('mpi_lib_path', 'Path to MPI libs (needs to be added to the LD_LIBRARY_PATH)', usr_lib), - ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', ['mpich' , 'pthread', 'rt']), + ('mpi_libs', 'MPI libraries to link with (needs to be shared!)', []), ('mpi_flavour','Type of MPI execution environment','none'), # ParMETIS BoolVariable('useparmetis', 'Compile parallel version using ParMETIS', 'yes'), @@ -152,14 +161,23 @@ ('blas_path', 'Path to BLAS includes', '/usr/include/suitesparse'), ('blas_lib_path', 'Path to BLAS libs', usr_lib), ('blas_libs', 'BLAS libraries to link with', ['blas']), +#Lapack options + BoolVariable('uselapack','switch on/off use of Lapack','no'), + ('lapack_path', 'Path to Lapack includes','/usr/include'), + ('lapack_lib_path', 'Path to Lapack libs', usr_lib), + ('lapack_libs', 'Lapack libraries to link with', []), + ('lapack_type', '{clapack,mkl}','clapack'), # An option for specifying the compiler tools set (see windows branch). ('tools_names', 'allow control over the tools in the env setup', ['intelc']), # finer control over library building, intel aggressive global optimisation # works with dynamic libraries on windows. ('share_esysUtils', 'control static or dynamic esysUtils lib', False), - ('share_paso', 'control static or dynamic paso lib', False) + ('share_paso', 'control static or dynamic paso lib', False), + ('env_export','Environment variables to be passed to children',[]) ) + + ############ Specify which compilers to use #################### # intelc uses regular expressions improperly and emits a warning about @@ -170,7 +188,7 @@ env = Environment(tools = ['default'] + env['tools_names'], options = opts) else: - if socket.gethostname().split('.')[0] == 'service0': + if effective_hostname == 'service0': env = Environment(tools = ['default', 'intelc'], options = opts) elif os.uname()[4]=='ia64': env = Environment(tools = ['default', 'intelc'], options = opts) @@ -180,6 +198,21 @@ env = Environment(tools = ['default'], options = opts) Help(opts.GenerateHelpText(env)) + +############ Make sure target directories exist ################ + +if not os.path.isdir(env['bininstall']): + os.makedirs(env['bininstall']) +if not os.path.isdir(env['libinstall']): + os.makedirs(env['libinstall']) +if not os.path.isdir(env['pyinstall']): + os.makedirs(env['pyinstall']) + +########## Copy required environment vars ###################### + +for i in env['env_export']: + env.Append(ENV = {i:os.environ[i]}) + ############ Fill in compiler options if not set above ######### # Backwards compatibility: allow dodebug=yes and useMPI=yes @@ -210,7 +243,7 @@ cc_debug = "-g -O0 -DDOASSERT -DDOPROF -DBOUNDS_CHECK" omp_optim = "-fopenmp" omp_debug = "-fopenmp" - omp_libs = ['gomp'] + omp_libs = [] pedantic = "-pedantic-errors -Wno-long-long" fatalwarning = "-Werror" sysheaderopt = "-isystem " @@ -243,10 +276,20 @@ #set up the autolazy values if env['forcelazy'] != "leave_alone": if env['forcelazy'] == 'on': - env.Append(CPPDEFINES='FAUTOLAZYON') + env.Append(CPPDEFINES=['FAUTOLAZYON']) else: if env['forcelazy'] == 'off': - env.Append(CPPDEFINES='FAUTOLAZYOFF') + env.Append(CPPDEFINES=['FAUTOLAZYOFF']) + +#set up the colective resolve values +if env['forcecollres'] != "leave_alone": + print env['forcecollres'] + if env['forcecollres'] == 'on': + env.Append(CPPDEFINES=['FRESCOLLECTON']) + else: + if env['forcecollres'] == 'off': + env.Append(CPPDEFINES=['FRESCOLLECTOFF']) + # OpenMP is disabled if useopenmp=no or both variables omp_optim and omp_debug are empty if not env["useopenmp"]: @@ -506,6 +549,7 @@ if env['usemkl'] and not conf.CheckCHeader('mkl_solver.h'): env['usemkl'] = 0 if env['usemkl'] and not conf.CheckFunc('pardiso'): env['usemkl'] = 0 + # Add MKL to environment env if it was found if env['usemkl']: env = conf.Finish() @@ -566,6 +610,25 @@ env.AppendUnique(LIBPATH = [env['silo_lib_path']]) env.Append(CPPDEFINES = ['HAVE_SILO']) +########### Lapack (optional) ################################## + + +if env['uselapack']: + env.AppendUnique(CPPDEFINES='USE_LAPACK') + env.AppendUnique(CPPPATH = [env['lapack_path']]) + env.AppendUnique(LIBPATH =[env['lapack_lib_path']]) + + env.Append(LIBPATH = '/usr/lib/atlas') + env.Append(LIBS = [env['lapack_libs']]) + if env['lapack_type']=='mkl': + if not env['usemkl']: + env['uselapack']=0 + print "mkl_lapack requires mkl" + else: + env.AppendUnique(CPPDEFINES='MKL_LAPACK') + + + ############ Add the compiler flags ############################ # Enable debug by choosing either cc_debug or cc_optim @@ -689,6 +752,8 @@ else: print " Not using ParMETIS (requires MPI)" if env['usepapi']: print " Using PAPI" else: print " Not using PAPI" +if env['uselapack']: print " Using Lapack" +else: print " Not using Lapack" if env['usedebug']: print " Compiling for debug" else: print " Not compiling for debug" print " Installing in", prefix @@ -755,7 +820,9 @@ ############### Record python interpreter version ############## if not IS_WINDOWS_PLATFORM: + versionstring="Python "+str(sys.version_info[0])+"."+str(sys.version_info[1])+"."+str(sys.version_info[2]) + if sys.version_info[4] >0 : versionstring+="rc%s"%sys.version_info[4] os.system("echo "+versionstring+" > "+os.path.join(env['libinstall'],"pyversion")) ############## Populate the buildvars file ##################### @@ -792,7 +859,12 @@ out+="n" buildvars.write(out+"\n") buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n') - +buildvars.write("lapack=") +if env['uselapack']: + buildvars.write('y') +else: + buildvars.write('n') +buildvars.write('\n') buildvars.close() @@ -853,6 +925,8 @@ ############ Targets to build the documentation ################ +env.Alias('api_epydoc','install_all') + env.Alias('docs', ['examples_tarfile', 'examples_zipfile', 'api_epydoc', 'api_doxygen', 'guide_pdf', 'guide_html','install_pdf']) if not IS_WINDOWS_PLATFORM: @@ -871,3 +945,7 @@ print "Error attempting to write unittests file." sys.exit(1) + #Make sure that the escript wrapper is in place + if not os.path.isfile(os.path.join(env['bininstall'],'escript')): + print "Copying escript wrapper" + shutil.copy("bin/escript",os.path.join(env['bininstall'],'escript'))