--- trunk/SConstruct 2009/07/20 06:20:06 2548 +++ trunk/SConstruct 2009/12/10 05:03:11 2820 @@ -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() @@ -560,11 +604,30 @@ # Add the path to Silo to environment env if it was found. # Note that we do not add the libs since they are only needed for the -# escriptreader library and tools. +# escriptexport library and tools. if env['usesilo']: env.AppendUnique(CPPPATH = [env['silo_path']]) env.AppendUnique(LIBPATH = [env['silo_lib_path']]) - env.Append(CPPDEFINES = ['HAVE_SILO']) + env.Append(CPPDEFINES = ['USE_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 ############################ @@ -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 @@ -722,8 +787,9 @@ ) env.SConscript(dirs = ['tools/CppUnitTest/src'], build_dir='build/$PLATFORM/tools/CppUnitTest', duplicate=0) -env.SConscript(dirs = ['tools/libescriptreader/src'], build_dir='build/$PLATFORM/tools/libescriptreader', duplicate=0) +env.SConscript(dirs = ['tools/escriptconvert'], build_dir='build/$PLATFORM/tools/escriptconvert', duplicate=0) env.SConscript(dirs = ['paso/src'], build_dir='build/$PLATFORM/paso', duplicate=0) +env.SConscript(dirs = ['dataexporter/src'], build_dir='build/$PLATFORM/dataexporter', duplicate=0) env.SConscript(dirs = ['escript/src'], build_dir='build/$PLATFORM/escript', duplicate=0) env.SConscript(dirs = ['esysUtils/src'], build_dir='build/$PLATFORM/esysUtils', duplicate=0) env.SConscript(dirs = ['finley/src'], build_dir='build/$PLATFORM/finley', duplicate=0) @@ -755,7 +821,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 +860,17 @@ out+="n" buildvars.write(out+"\n") buildvars.write("mpi_flavour="+env['mpi_flavour']+'\n') - +out="lapack=" +if env['uselapack']: + out+="y" +else: + out+="n" +out+="\nsilo=" +if env['usesilo']: + out+="y" +else: + out+="n" +buildvars.write(out+"\n") buildvars.close() @@ -808,6 +886,9 @@ env.Alias('build_paso', ['target_install_paso_headers', 'target_paso_a']) env.Alias('install_paso', ['build_paso', 'target_install_paso_a']) +env.Alias('build_dataexporter', ['target_install_escriptexport_headers', 'target_escriptexport_so', 'target_escriptexportcpp_so']) +env.Alias('install_dataexporter', ['build_dataexporter', 'target_install_escriptexport_so', 'target_install_escriptexportcpp_so', 'target_install_dataexporter_py']) + env.Alias('build_escript', ['target_install_escript_headers', 'target_escript_so', 'target_escriptcpp_so']) env.Alias('install_escript', ['build_escript', 'target_install_escript_so', 'target_install_escriptcpp_so', 'target_install_escript_py']) @@ -818,17 +899,19 @@ build_all_list = [] build_all_list += ['build_esysUtils'] build_all_list += ['build_paso'] +build_all_list += ['build_dataexporter'] build_all_list += ['build_escript'] build_all_list += ['build_finley'] if env['usempi']: build_all_list += ['target_pythonMPI_exe'] #if not IS_WINDOWS_PLATFORM: build_all_list += ['target_escript_wrapper'] -if env['usesilo']: build_all_list += ['target_escript2silo'] +if env['usesilo']: build_all_list += ['target_escriptconvert'] env.Alias('build_all', build_all_list) install_all_list = [] install_all_list += ['target_init'] install_all_list += ['install_esysUtils'] install_all_list += ['install_paso'] +install_all_list += ['install_dataexporter'] install_all_list += ['install_escript'] install_all_list += ['install_finley'] install_all_list += ['target_install_pyvisi_py'] @@ -836,7 +919,7 @@ install_all_list += ['target_install_pycad_py'] if env['usempi']: install_all_list += ['target_install_pythonMPI_exe'] #if not IS_WINDOWS_PLATFORM: install_all_list += ['target_install_escript_wrapper'] -if env['usesilo']: install_all_list += ['target_install_escript2silo'] +if env['usesilo']: install_all_list += ['target_install_escriptconvert'] install_all_list += ['remember_options'] env.Alias('install_all', install_all_list) @@ -851,6 +934,7 @@ env.Alias('all_tests', ['install_all', 'target_install_cppunittest_a', 'run_tests', 'py_tests']) env.Alias('build_full',['install_all','build_tests','build_py_tests']) + ############ Targets to build the documentation ################ env.Alias('api_epydoc','install_all') @@ -873,3 +957,11 @@ 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')) + +############ Targets to build PasoTests suite ################ + +env.Alias('build_PasoTests','build/'+build_platform+'/paso/profiling/PasoTests')