130b8aa07SMatthew G. Knepleyfrom __future__ import generators 230b8aa07SMatthew G. Knepleyimport config.base 330b8aa07SMatthew G. Knepley 430b8aa07SMatthew G. Knepleyclass Configure(config.base.Configure): 530b8aa07SMatthew G. Knepley def __init__(self, framework): 630b8aa07SMatthew G. Knepley config.base.Configure.__init__(self, framework) 730b8aa07SMatthew G. Knepley self.headerPrefix = '' 830b8aa07SMatthew G. Knepley self.substPrefix = '' 930b8aa07SMatthew G. Knepley return 1030b8aa07SMatthew G. Knepley 1130b8aa07SMatthew G. Knepley def __str1__(self): 1230b8aa07SMatthew G. Knepley desc = [] 134b774a58SToby Isaac if hasattr(self, 'integerSize'): 147e4baeb0SJose E. Roman desc.append(' Integer size: ' + str(self.integerSize//8) + ' bytes') 1530b8aa07SMatthew G. Knepley return '\n'.join(desc)+'\n' 1630b8aa07SMatthew G. Knepley 1730b8aa07SMatthew G. Knepley def setupHelp(self, help): 1830b8aa07SMatthew G. Knepley import nargs 19*73ac38ffSBarry Smith help.addArgument('PETSc', '-with-64-bit-indices=<bool>', nargs.ArgBool(None, 0, 'Use 64-bit integers (long long) for indexing in vectors and matrices\n This does not affect indexing for BLAS/LAPACK, see --with-64-bit-blas-indices')) 2030b8aa07SMatthew G. Knepley return 2130b8aa07SMatthew G. Knepley 2230b8aa07SMatthew G. Knepley def setupDependencies(self, framework): 2330b8aa07SMatthew G. Knepley config.base.Configure.setupDependencies(self, framework) 2430b8aa07SMatthew G. Knepley self.setCompilers = framework.require('config.setCompilers', self) 2530b8aa07SMatthew G. Knepley self.libraries = framework.require('config.libraries', None) 2630b8aa07SMatthew G. Knepley self.compilers = framework.require('config.compilers', None) 2730b8aa07SMatthew G. Knepley return 2830b8aa07SMatthew G. Knepley 29e951c290SBarry Smith def fortranPromoteInteger(self): 30e951c290SBarry Smith self.pushLanguage('FC') 31e951c290SBarry Smith flags = self.getCompilerFlags() 32e951c290SBarry Smith self.popLanguage() 33e951c290SBarry Smith # ifort compiler flag gfortran compiler flag 34e951c290SBarry Smith if '-integer-size 64' in flags or '-fdefault-integer-8' in flags: 35e951c290SBarry Smith return 1 36e951c290SBarry Smith return 0 37e951c290SBarry Smith 3830b8aa07SMatthew G. Knepley def configureIndexSize(self): 397de69702SBarry Smith '''Determine the size of PETSc indices (32 or 64-bit), from -with-64-bit-indices''' 4030b8aa07SMatthew G. Knepley if self.framework.argDB['with-64-bit-indices']: 4130b8aa07SMatthew G. Knepley self.integerSize = 64 4230b8aa07SMatthew G. Knepley self.addDefine('USE_64BIT_INDICES', 1) 4330b8aa07SMatthew G. Knepley if self.libraries.check('-lgcc_s.1', '__floatdidf'): 4430b8aa07SMatthew G. Knepley self.compilers.LIBS += ' '+self.libraries.getLibArgument('-lgcc_s.1') 4569bf3e1aSBarry Smith self.addMakeMacro('PETSC_INDEX_SIZE', '64') 46e951c290SBarry Smith if self.fortranPromoteInteger(): 47e951c290SBarry Smith self.addDefine('PROMOTE_FORTRAN_INTEGER', 1) 48ce040abeSJacob Faibussowitsch self.logPrintWarning('You have a Fortran compiler option to promote integer to 8 bytes. This is fragile and not supported by the MPI standard. You must ensure in your code that all calls to MPI routines pass 4-byte integers.') 4930b8aa07SMatthew G. Knepley else: 5030b8aa07SMatthew G. Knepley self.integerSize = 32 5169bf3e1aSBarry Smith self.addMakeMacro('PETSC_INDEX_SIZE', '32') 52e951c290SBarry Smith if self.fortranPromoteInteger(): 53e951c290SBarry Smith raise RuntimeError('Fortran compiler flag to promote integers to 8 bytes has been set, but PETSc is being built with 4-byte integers.') 5430b8aa07SMatthew G. Knepley return 5530b8aa07SMatthew G. Knepley 5630b8aa07SMatthew G. Knepley def configure(self): 5730b8aa07SMatthew G. Knepley self.executeTest(self.configureIndexSize) 5830b8aa07SMatthew G. Knepley return 59