fixed bug causing acceptance of blank options in damask.conf for blasRoot

This commit is contained in:
Bret Dunlap 2014-02-10 15:30:18 +00:00
parent d8311d46b3
commit 0286246cbd
1 changed files with 20 additions and 20 deletions

38
configure vendored
View File

@ -40,6 +40,8 @@ if compiler == None: compiler ={True:'ifort',False:'gfortran'}[\
stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0] stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0]
#--- default option values -------------------------------------------------------------------------- #--- default option values --------------------------------------------------------------------------
BLAS_order = ['IMKL','ACML','LAPACK']
defaults={'F90':compiler,\ defaults={'F90':compiler,\
'FFTW_ROOT':'/usr/local',\ 'FFTW_ROOT':'/usr/local',\
'MSC_ROOT' :'/msc',\ 'MSC_ROOT' :'/msc',\
@ -52,6 +54,8 @@ defaults={'F90':compiler,\
[os.getenv('MKLROOT')==None]},\ [os.getenv('MKLROOT')==None]},\
'spectralOptions':{}} 'spectralOptions':{}}
print 'defaults at start',defaults
#--- if local config file exists, read, otherwise assume global config file ------------------------ #--- if local config file exists, read, otherwise assume global config file ------------------------
if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')): if os.path.isfile(os.path.join(os.getenv('HOME'),'.damask/damask.conf')):
configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf') configFile = os.path.join(os.getenv('HOME'),'.damask/damask.conf')
@ -63,25 +67,21 @@ try:
with open(configFile,'r') as f: with open(configFile,'r') as f:
print('\n-----\n reading default values from %s\n-----'%configFile) print('\n-----\n reading default values from %s\n-----'%configFile)
for line in f: for line in f:
items = re.split('[= ]',line) [key,value] = (re.split('[= ]',line)+[None,None])[:2]
value = value.rstrip()
if (not line.strip() or items[0].startswith('#')): if (not line.strip() or key.startswith('#')):
pass pass
elif items[0] == 'F90': if key == 'DAMASK_NUM_THREADS':
defaults['F90']=items[1].rstrip() defaults['DAMASK_NUM_THREADS'] = int(value)
elif items[0] == 'FFTW_ROOT':
defaults['FFTW_ROOT']=items[1].rstrip() for theKey in ['F90','FFTW_ROOT','HDF5_ROOT','MSC_ROOT','spectralOptions']:
elif items[0] == 'MSC_ROOT': if key == theKey:
defaults['MSC_ROOT']=items[1].rstrip() defaults[key] = value
elif items[0] == 'HDF5_ROOT': for theKey in reversed(BLAS_order):
defaults['HDF5_ROOT']=items[1].rstrip() if key == theKey+'_ROOT' and (value != None or value != ''):
elif items[0] == 'DAMASK_NUM_THREADS': defaults['blasType'] = key
defaults['DAMASK_NUM_THREADS']=int(items[1]) defaults['blasRoot'][key] = value
elif items[0] in [name+'_ROOT' for name in defaults['blasRoot']]:
defaults['blasType']=items[0][:-5]
defaults['blasRoot'][items[0][:-5]] =items[1].rstrip()
else:
defaults['spectralOptions'][items[0]]=items[1].rstrip()
except IOError: except IOError:
pass pass
@ -119,8 +119,8 @@ for i, arg in enumerate(sys.argv):
blasType = sys.argv[i+1].upper() blasType = sys.argv[i+1].upper()
else: else:
blasType = sys.argv[i][17:].upper() blasType = sys.argv[i][17:].upper()
if blasType not in ['LAPACK','ACML','IMKL']: if blasType not in BLAS_order:
blasType='LAPACK' blasType = 'LAPACK'
parser.set_defaults(blasRoot = [defaults['blasRoot'][blasType]][0]) parser.set_defaults(blasRoot = [defaults['blasRoot'][blasType]][0])
parser.set_defaults(spectraloptions = []) parser.set_defaults(spectraloptions = [])