15d5a5a7bSMatthew Knepley#!/usr/bin/env python 22787667cSMatthew G Knepleyimport os, sys 34f8a5b45SBarry Smithimport commands 4a1eda5bfSSatish Balay# to load ~/.pythonrc.py before inserting correct BuildSystem to path 5a1eda5bfSSatish Balayimport user 67c9abfe7SSatish BalayextraLogs = [] 7b0b472b0SSatish Balaypetsc_arch = '' 84b8aa89bSBarry Smith 92787667cSMatthew G Knepleyimport urllib 102787667cSMatthew G Knepleyimport tarfile 112787667cSMatthew G Knepley 122787667cSMatthew G Knepleydef untar(tar, path = '.', leading = ''): 132787667cSMatthew G Knepley if leading: 142787667cSMatthew G Knepley entries = [t.name for t in tar.getmembers()] 152787667cSMatthew G Knepley prefix = os.path.commonprefix(entries) 162787667cSMatthew G Knepley if prefix: 172787667cSMatthew G Knepley for tarinfo in tar.getmembers(): 182787667cSMatthew G Knepley tail = tarinfo.name.split(prefix, 1)[1] 192787667cSMatthew G Knepley tarinfo.name = os.path.join(leading, tail) 202787667cSMatthew G Knepley for tarinfo in tar.getmembers(): 212787667cSMatthew G Knepley tar.extract(tarinfo, path) 222787667cSMatthew G Knepley return 232787667cSMatthew G Knepley 242787667cSMatthew G Knepleydef downloadPackage(url, filename, targetDirname): 252787667cSMatthew G Knepley '''Download the tarball for a package at url, save it as filename, and untar it into targetDirname''' 262787667cSMatthew G Knepley filename, headers = urllib.urlretrieve(url, filename) 272787667cSMatthew G Knepley tar = tarfile.open(filename, 'r:gz') 282787667cSMatthew G Knepley untar(tar, targetDirname, leading = filename.split('.')[0]) 292787667cSMatthew G Knepley return 302787667cSMatthew G Knepley 3144b0d7f9SSatish Balay# Use en_US as language so that BuildSystem parses compiler messages in english 329b436e4bSSatish Balayif 'LC_LOCAL' in os.environ and os.environ['LC_LOCAL'] != '' and os.environ['LC_LOCAL'] != 'en_US' and os.environ['LC_LOCAL']!= 'en_US.UTF-8': os.environ['LC_LOCAL'] = 'en_US.UTF-8' 339b436e4bSSatish Balayif 'LANG' in os.environ and os.environ['LANG'] != '' and os.environ['LANG'] != 'en_US' and os.environ['LANG'] != 'en_US.UTF-8': os.environ['LANG'] = 'en_US.UTF-8' 3444b0d7f9SSatish Balay 356b66766aSSatish Balayif not hasattr(sys, 'version_info') or not sys.version_info[0] == 2 or not sys.version_info[1] >= 3: 366b66766aSSatish Balay print '*** You must have Python2 version 2.3 or higher to run ./configure *****' 37495ffa62SBarry Smith print '* Python is easy to install for end users or sys-admin. *' 3832077d6dSBarry Smith print '* http://www.python.org/download/ *' 3932077d6dSBarry Smith print '* *' 40495ffa62SBarry Smith print '* You CANNOT configure PETSc without Python *' 41495ffa62SBarry Smith print '* http://www.mcs.anl.gov/petsc/petsc-as/documentation/installation.html *' 42a0022257SSatish Balay print '*******************************************************************************' 43b26a8723SBarry Smith sys.exit(4) 442fb34ac0SMatthew Knepley 454d18482cSSatish Balayif sys.platform == 'win32': 464d18482cSSatish Balay print '**** Windows python detected. ****' 474d18482cSSatish Balay print sys.version,'on',sys.platform 484d18482cSSatish Balay print '' 494d18482cSSatish Balay print '** You must use cygwin python, but not windows python with PETSc configure. ***' 504d18482cSSatish Balay sys.exit(4) 514d18482cSSatish Balay 52ccb279e1SMatthew Knepleydef check_for_option_mistakes(opts): 5345faeebdSBarry Smith for opt in opts[1:]: 54cda0060aSMatthew Knepley name = opt.split('=')[0] 55ccb279e1SMatthew Knepley if name.find('_') >= 0: 56ccb279e1SMatthew Knepley exception = False 57f3fbd535SBarry Smith for exc in ['superlu_dist', 'PETSC_ARCH', 'PETSC_DIR', 'CXX_CXXFLAGS', 'LD_SHARED', 'CC_LINKER_FLAGS', 'CXX_LINKER_FLAGS', 'FC_LINKER_FLAGS', 'AR_FLAGS', 'C_VERSION', 'CXX_VERSION', 'FC_VERSION', 'size_t', 'MPI_Comm','MPI_Fint']: 58ccb279e1SMatthew Knepley if name.find(exc) >= 0: 59ccb279e1SMatthew Knepley exception = True 60ccb279e1SMatthew Knepley if not exception: 61ccb279e1SMatthew Knepley raise ValueError('The option '+name+' should probably be '+name.replace('_', '-')); 62ab610953SSatish Balay if opt.find('=') >=0: 63ab610953SSatish Balay optval = opt.split('=')[1] 64ab610953SSatish Balay if optval == 'ifneeded': 65ab610953SSatish Balay raise ValueError('The option '+opt+' should probably be '+opt.replace('ifneeded', '1')); 66ccb279e1SMatthew Knepley return 67ccb279e1SMatthew Knepley 6859e9bfd6SSatish Balaydef check_petsc_arch(opts): 69c43ea0feSSatish Balay # If PETSC_ARCH not specified - use script name (if not configure.py) 70b0b472b0SSatish Balay global petsc_arch 71c43ea0feSSatish Balay found = 0 7259e9bfd6SSatish Balay for name in opts: 73c43ea0feSSatish Balay if name.find('PETSC_ARCH=') >= 0: 74b0b472b0SSatish Balay petsc_arch=name.split('=')[1] 75c43ea0feSSatish Balay found = 1 7659e9bfd6SSatish Balay break 7759e9bfd6SSatish Balay # If not yet specified - use the filename of script 78c43ea0feSSatish Balay if not found: 7959e9bfd6SSatish Balay filename = os.path.basename(sys.argv[0]) 80e68ebbecSBarry Smith if not filename.startswith('configure') and not filename.startswith('reconfigure') and not filename.startswith('setup'): 81b0b472b0SSatish Balay petsc_arch=os.path.splitext(os.path.basename(sys.argv[0]))[0] 82b0b472b0SSatish Balay useName = 'PETSC_ARCH='+petsc_arch 8359e9bfd6SSatish Balay opts.append(useName) 841937db7aSSatish Balay return 0 854b8aa89bSBarry Smith 861921852fSSatish Balaydef chkwinf90(): 876a8f6897SSatish Balay for arg in sys.argv: 881921852fSSatish Balay if (arg.find('win32fe') >= 0 and (arg.find('f90') >=0 or arg.find('ifort') >=0)): 896a8f6897SSatish Balay return 1 906a8f6897SSatish Balay return 0 916a8f6897SSatish Balay 926a8f6897SSatish Balaydef chkcygwinlink(): 931921852fSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and os.path.exists('/usr/bin/link.exe') and chkwinf90(): 946a8f6897SSatish Balay if '--ignore-cygwin-link' in sys.argv: return 0 956a8f6897SSatish Balay print '===============================================================================' 961921852fSSatish Balay print ' *** Cygwin /usr/bin/link detected! Compiles with CVF/Intel f90 can break! **' 976a8f6897SSatish Balay print ' *** To workarround do: "mv /usr/bin/link.exe /usr/bin/link-cygwin.exe" **' 986a8f6897SSatish Balay print ' *** Or to ignore this check, use configure option: --ignore-cygwin-link **' 996a8f6897SSatish Balay print '===============================================================================' 1006a8f6897SSatish Balay sys.exit(3) 1016a8f6897SSatish Balay return 0 1026a8f6897SSatish Balay 10385ef4d1eSSatish Balaydef chkbrokencygwin(): 1049dabcff0SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 1059dabcff0SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c cygwin').read() 1069dabcff0SSatish Balay if buf.find('1.5.11-1') > -1: 107a0022257SSatish Balay print '===============================================================================' 108e2e64c6bSBarry Smith print ' *** cygwin-1.5.11-1 detected. ./configure fails with this version ***' 1091937db7aSSatish Balay print ' *** Please upgrade to cygwin-1.5.12-1 or newer version. This can ***' 1101937db7aSSatish Balay print ' *** be done by running cygwin-setup, selecting "next" all the way.***' 111a0022257SSatish Balay print '===============================================================================' 1121937db7aSSatish Balay sys.exit(3) 1139dabcff0SSatish Balay return 0 1149dabcff0SSatish Balay 11585ef4d1eSSatish Balaydef chkusingwindowspython(): 1161937db7aSSatish Balay if os.path.exists('/usr/bin/cygcheck.exe') and sys.platform != 'cygwin': 117a0022257SSatish Balay print '===============================================================================' 118e2e64c6bSBarry Smith print ' *** Non-cygwin python detected. Please rerun ./configure **' 119a0022257SSatish Balay print ' *** with cygwin-python. ***' 120a0022257SSatish Balay print '===============================================================================' 1211937db7aSSatish Balay sys.exit(3) 12285ef4d1eSSatish Balay return 0 12385ef4d1eSSatish Balay 12485ef4d1eSSatish Balaydef chkcygwinpythonver(): 12571384062SSatish Balay if os.path.exists('/usr/bin/cygcheck.exe'): 12671384062SSatish Balay buf = os.popen('/usr/bin/cygcheck.exe -c python').read() 127c4b7e894SSatish Balay if (buf.find('2.4') > -1) or (buf.find('2.5') > -1) or (buf.find('2.6') > -1): 1281937db7aSSatish Balay sys.argv.append('--useThreads=0') 1291937db7aSSatish Balay extraLogs.append('''\ 130a0022257SSatish Balay=============================================================================== 131a0022257SSatish Balay** Cygwin-python-2.4/2.5/2.6 detected. Threads do not work correctly with this 132e2e64c6bSBarry Smith** version. Disabling thread usage for this run of ./configure ******* 133a0022257SSatish Balay===============================================================================''') 13471384062SSatish Balay return 0 13571384062SSatish Balay 1361937db7aSSatish Balaydef chkrhl9(): 1371937db7aSSatish Balay if os.path.exists('/etc/redhat-release'): 138836c2c52SSatish Balay try: 139594eb360SSatish Balay file = open('/etc/redhat-release','r') 140836c2c52SSatish Balay buf = file.read() 141836c2c52SSatish Balay file.close() 142836c2c52SSatish Balay except: 143836c2c52SSatish Balay # can't read file - assume dangerous RHL9 1441937db7aSSatish Balay buf = 'Shrike' 145836c2c52SSatish Balay if buf.find('Shrike') > -1: 1461937db7aSSatish Balay sys.argv.append('--useThreads=0') 1471937db7aSSatish Balay extraLogs.append('''\ 148a0022257SSatish Balay============================================================================== 1491937db7aSSatish Balay *** RHL9 detected. Threads do not work correctly with this distribution *** 150e2e64c6bSBarry Smith ****** Disabling thread usage for this run of ./configure ********* 151a0022257SSatish Balay===============================================================================''') 152836c2c52SSatish Balay return 0 153836c2c52SSatish Balay 154da58527dSSatish Balaydef check_broken_configure_log_links(): 155da58527dSSatish Balay '''Sometime symlinks can get broken if the original files are deleted. Delete such broken links''' 156da58527dSSatish Balay import os 157da58527dSSatish Balay for logfile in ['configure.log','configure.log.bkp']: 158da58527dSSatish Balay if os.path.islink(logfile) and not os.path.isfile(logfile): os.remove(logfile) 159da58527dSSatish Balay return 160da58527dSSatish Balay 161da1d79b4SSatish Balaydef move_configure_log(framework): 162da1d79b4SSatish Balay '''Move configure.log to PETSC_ARCH/conf - and update configure.log.bkp in both locations appropriately''' 163b0b472b0SSatish Balay global petsc_arch 164b0b472b0SSatish Balay 165b0b472b0SSatish Balay if hasattr(framework,'arch'): petsc_arch = framework.arch 166b0b472b0SSatish Balay if hasattr(framework,'logName'): curr_file = framework.logName 167b0b472b0SSatish Balay else: curr_file = 'configure.log' 168b0b472b0SSatish Balay 169b0b472b0SSatish Balay if petsc_arch: 170da1d79b4SSatish Balay import shutil 171da1d79b4SSatish Balay import os 172b0b472b0SSatish Balay 173b0b472b0SSatish Balay # Just in case - confdir is not created 174b0b472b0SSatish Balay conf_dir = os.path.join(petsc_arch,'conf') 175b0b472b0SSatish Balay if not os.path.isdir(petsc_arch): os.mkdir(petsc_arch) 176b0b472b0SSatish Balay if not os.path.isdir(conf_dir): os.mkdir(conf_dir) 177b0b472b0SSatish Balay 178da1d79b4SSatish Balay curr_bkp = curr_file + '.bkp' 179b0b472b0SSatish Balay new_file = os.path.join(conf_dir,curr_file) 180da1d79b4SSatish Balay new_bkp = new_file + '.bkp' 181da1d79b4SSatish Balay 182da1d79b4SSatish Balay # Keep backup in $PETSC_ARCH/conf location 183da1d79b4SSatish Balay if os.path.isfile(new_bkp): os.remove(new_bkp) 184da1d79b4SSatish Balay if os.path.isfile(new_file): os.rename(new_file,new_bkp) 1859e50940cSSatish Balay if os.path.isfile(curr_file): 1869e50940cSSatish Balay shutil.copyfile(curr_file,new_file) 1879e50940cSSatish Balay os.remove(curr_file) 188da58527dSSatish Balay if os.path.isfile(new_file): os.symlink(new_file,curr_file) 189da1d79b4SSatish Balay # If the old bkp is using the same PETSC_ARCH/conf - then update bkp link 190da1d79b4SSatish Balay if os.path.realpath(curr_bkp) == os.path.realpath(new_file): 191da58527dSSatish Balay if os.path.isfile(curr_bkp): os.remove(curr_bkp) 192da58527dSSatish Balay if os.path.isfile(new_bkp): os.symlink(new_bkp,curr_bkp) 193da1d79b4SSatish Balay return 194da1d79b4SSatish Balay 1955d5a5a7bSMatthew Knepleydef petsc_configure(configure_options): 196a0022257SSatish Balay print '===============================================================================' 19759e9bfd6SSatish Balay print ' Configuring PETSc to compile on your system ' 198a0022257SSatish Balay print '===============================================================================' 19959e9bfd6SSatish Balay 200a258c2c4SMatthew G Knepley try: 201c43ea0feSSatish Balay # Command line arguments take precedence (but don't destroy argv[0]) 202c43ea0feSSatish Balay sys.argv = sys.argv[:1] + configure_options + sys.argv[1:] 203ccb279e1SMatthew Knepley check_for_option_mistakes(sys.argv) 204a258c2c4SMatthew G Knepley except (TypeError, ValueError), e: 205a258c2c4SMatthew G Knepley emsg = str(e) 206a258c2c4SMatthew G Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 207a258c2c4SMatthew G Knepley msg ='*******************************************************************************\n'\ 208a258c2c4SMatthew G Knepley +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 209a258c2c4SMatthew G Knepley +'-------------------------------------------------------------------------------\n' \ 210a258c2c4SMatthew G Knepley +emsg+'*******************************************************************************\n' 211a258c2c4SMatthew G Knepley sys.exit(msg) 21259e9bfd6SSatish Balay # check PETSC_ARCH 21359e9bfd6SSatish Balay check_petsc_arch(sys.argv) 214da58527dSSatish Balay check_broken_configure_log_links() 2155fb2c094SBarry Smith 216c22cdea9SBarry Smith # support a few standard configure option types 217ed6a7445SBarry Smith for l in range(0,len(sys.argv)): 218c22cdea9SBarry Smith name = sys.argv[l] 219637cc2ebSSatish Balay if name.find('enable-') >= 0: 220193cd51eSMatthew Knepley if name.find('=') == -1: 221193cd51eSMatthew Knepley sys.argv[l] = name.replace('enable-','with-')+'=1' 222193cd51eSMatthew Knepley else: 223193cd51eSMatthew Knepley head, tail = name.split('=', 1) 224193cd51eSMatthew Knepley sys.argv[l] = head.replace('enable-','with-')+'='+tail 225637cc2ebSSatish Balay if name.find('disable-') >= 0: 226193cd51eSMatthew Knepley if name.find('=') == -1: 227193cd51eSMatthew Knepley sys.argv[l] = name.replace('disable-','with-')+'=0' 228193cd51eSMatthew Knepley else: 229193cd51eSMatthew Knepley head, tail = name.split('=', 1) 230193cd51eSMatthew Knepley if tail == '1': tail = '0' 231193cd51eSMatthew Knepley sys.argv[l] = head.replace('disable-','with-')+'='+tail 232637cc2ebSSatish Balay if name.find('without-') >= 0: 233193cd51eSMatthew Knepley if name.find('=') == -1: 234193cd51eSMatthew Knepley sys.argv[l] = name.replace('without-','with-')+'=0' 235193cd51eSMatthew Knepley else: 236193cd51eSMatthew Knepley head, tail = name.split('=', 1) 237193cd51eSMatthew Knepley if tail == '1': tail = '0' 238193cd51eSMatthew Knepley sys.argv[l] = head.replace('without-','with-')+'='+tail 239adc3e427SMatthew Knepley 2409dabcff0SSatish Balay # Check for broken cygwin 2411937db7aSSatish Balay chkbrokencygwin() 242d65f3bddSMatthew Knepley # Disable threads on RHL9 2431937db7aSSatish Balay chkrhl9() 24485ef4d1eSSatish Balay # Make sure cygwin-python is used on windows 2451937db7aSSatish Balay chkusingwindowspython() 24685ef4d1eSSatish Balay # Threads don't work for cygwin & python-2.4, 2.5 etc.. 2471937db7aSSatish Balay chkcygwinpythonver() 2486a8f6897SSatish Balay chkcygwinlink() 2499dabcff0SSatish Balay 25087282423SMatthew Knepley # Should be run from the toplevel 251dbca6d9dSSatish Balay configDir = os.path.abspath('config') 252f8833479SBarry Smith bsDir = os.path.join(configDir, 'BuildSystem') 253f8833479SBarry Smith if not os.path.isdir(configDir): 2545d5a5a7bSMatthew Knepley raise RuntimeError('Run configure from $PETSC_DIR, not '+os.path.abspath('.')) 25587282423SMatthew Knepley if not os.path.isdir(bsDir): 256a0022257SSatish Balay print '===============================================================================' 257dbca6d9dSSatish Balay print '''++ Could not locate BuildSystem in %s.''' % configDir 2582787667cSMatthew G Knepley print '''++ Downloading it from http://petsc.cs.iit.edu/petsc/BuildSystem''' 259a0022257SSatish Balay print '===============================================================================' 260f94377afSLisandro Dalcin downloadPackage('http://petsc.cs.iit.edu/petsc/BuildSystem/archive/tip.tar.gz', 'BuildSystem.tar.gz', configDir) 2614f8a5b45SBarry Smith 26287282423SMatthew Knepley sys.path.insert(0, bsDir) 263f8833479SBarry Smith sys.path.insert(0, configDir) 264e69ef9dfSMatthew Knepley import config.base 2655d5a5a7bSMatthew Knepley import config.framework 266f56be888SMatthew Knepley import cPickle 2674f8a5b45SBarry Smith 2689dd2fdb1SMatthew Knepley framework = None 2699dd2fdb1SMatthew Knepley try: 2701a784507SMatthew Knepley framework = config.framework.Framework(['--configModules=PETSc.Configure','--optionsModule=PETSc.compilerOptions']+sys.argv[1:], loadArgDB = 0) 271d65f3bddSMatthew Knepley framework.setup() 272d65f3bddSMatthew Knepley framework.logPrint('\n'.join(extraLogs)) 273f24f64feSBarry Smith framework.configure(out = sys.stdout) 274358ebc22SMatthew Knepley framework.storeSubstitutions(framework.argDB) 275f56be888SMatthew Knepley framework.argDB['configureCache'] = cPickle.dumps(framework) 2767cfd0b05SBarry Smith import PETSc.packages 2777cfd0b05SBarry Smith for i in framework.packages: 2787cfd0b05SBarry Smith if hasattr(i,'postProcess'): 2797cfd0b05SBarry Smith i.postProcess() 2807c939e48SSatish Balay framework.printSummary() 28112c1d45bSMatthew G Knepley framework.argDB.save(force = True) 2827cfd0b05SBarry Smith framework.logClear() 283eefa2c0fSBarry Smith framework.closeLog() 2849e50940cSSatish Balay try: 285da1d79b4SSatish Balay move_configure_log(framework) 2869e50940cSSatish Balay except: 2879e50940cSSatish Balay # perhaps print an error about unable to shuffle logs? 2889e50940cSSatish Balay pass 289dd50d019SBarry Smith return 0 290e69ef9dfSMatthew Knepley except (RuntimeError, config.base.ConfigureSetupError), e: 2917d670a3cSBarry Smith emsg = str(e) 29242351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 293a0022257SSatish Balay msg ='*******************************************************************************\n'\ 294fe09c992SBarry Smith +' UNABLE to CONFIGURE with GIVEN OPTIONS (see configure.log for details):\n' \ 295a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 296a0022257SSatish Balay +emsg+'*******************************************************************************\n' 297e9f3bb17SBarry Smith se = '' 2989dd2fdb1SMatthew Knepley except (TypeError, ValueError), e: 2997d670a3cSBarry Smith emsg = str(e) 30042351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 301a0022257SSatish Balay msg ='*******************************************************************************\n'\ 302e2e64c6bSBarry Smith +' ERROR in COMMAND LINE ARGUMENT to ./configure \n' \ 303a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 304a0022257SSatish Balay +emsg+'*******************************************************************************\n' 3051a02243aSBarry Smith se = '' 30696dc2fe8SMatthew Knepley except ImportError, e : 3077d670a3cSBarry Smith emsg = str(e) 30842351d26SSatish Balay if not emsg.endswith('\n'): emsg = emsg+'\n' 309a0022257SSatish Balay msg ='*******************************************************************************\n'\ 310e2e64c6bSBarry Smith +' UNABLE to FIND MODULE for ./configure \n' \ 311a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 312a0022257SSatish Balay +emsg+'*******************************************************************************\n' 31396dc2fe8SMatthew Knepley se = '' 31401def6f0SMatthew Knepley except OSError, e : 31501def6f0SMatthew Knepley emsg = str(e) 31601def6f0SMatthew Knepley if not emsg.endswith('\n'): emsg = emsg+'\n' 317a0022257SSatish Balay msg ='*******************************************************************************\n'\ 318e2e64c6bSBarry Smith +' UNABLE to EXECUTE BINARIES for ./configure \n' \ 319a0022257SSatish Balay +'-------------------------------------------------------------------------------\n' \ 320a0022257SSatish Balay +emsg+'*******************************************************************************\n' 32101def6f0SMatthew Knepley se = '' 322d7d3c4beSMatthew Knepley except SystemExit, e: 323d7d3c4beSMatthew Knepley if e.code is None or e.code == 0: 324d7d3c4beSMatthew Knepley return 325a0022257SSatish Balay msg ='*******************************************************************************\n'\ 326b1dada7fSMatthew Knepley +' CONFIGURATION FAILURE (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 327a0022257SSatish Balay +'*******************************************************************************\n' 328d7d3c4beSMatthew Knepley se = str(e) 329e9f3bb17SBarry Smith except Exception, e: 330a0022257SSatish Balay msg ='*******************************************************************************\n'\ 331fe09c992SBarry Smith +' CONFIGURATION CRASH (Please send configure.log to petsc-maint@mcs.anl.gov)\n' \ 332a0022257SSatish Balay +'*******************************************************************************\n' 333e9f3bb17SBarry Smith se = str(e) 334e9f3bb17SBarry Smith 335e9f3bb17SBarry Smith print msg 3369dd2fdb1SMatthew Knepley if not framework is None: 3379dd2fdb1SMatthew Knepley framework.logClear() 338e9f3bb17SBarry Smith if hasattr(framework, 'log'): 339f6614063SBarry Smith import traceback 340b1dada7fSMatthew Knepley try: 341f24f64feSBarry Smith framework.log.write(msg+se) 342f24f64feSBarry Smith traceback.print_tb(sys.exc_info()[2], file = framework.log) 343*f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 344da1d79b4SSatish Balay move_configure_log(framework) 345b1dada7fSMatthew Knepley except: 346b1dada7fSMatthew Knepley pass 347e9f3bb17SBarry Smith sys.exit(1) 3485a74f024SMatthew Knepley else: 3495a74f024SMatthew Knepley print se 3505a74f024SMatthew Knepley import traceback 3515a74f024SMatthew Knepley traceback.print_tb(sys.exc_info()[2]) 352*f73e6a6cSSatish Balay if hasattr(framework,'log'): framework.log.close() 3535d5a5a7bSMatthew Knepley 3545d5a5a7bSMatthew Knepleyif __name__ == '__main__': 355a030c540SBarry Smith petsc_configure([]) 356759acf64SBarry Smith 357