[SCons/0D] Update to enable Sundials linked with external BLAS/LAPACK.

With help from Nick Curtis and Ray Speth.
This commit is contained in:
Bryan W. Weber 2014-01-20 15:19:53 +00:00
parent 8c4312f31e
commit 4badbd1fb3
3 changed files with 40 additions and 4 deletions

View file

@ -841,6 +841,20 @@ if env['HAS_SUNDIALS'] and env['use_sundials'] != 'n':
env['sundials_version'] = '.'.join(sundials_version.strip().split('.')[:2])
print """INFO: Using Sundials version %s.""" % sundials_version.strip()
#Determine whether or not Sundials was built with BLAS/LAPACK
sundials_blas_lapack = get_expression_value(['"sundials/sundials_config.h"'],
'SUNDIALS_BLAS_LAPACK')
retcode, has_sundials_lapack = conf.TryRun(sundials_blas_lapack, '.cpp')
if retcode == 0:
config_error("Failed to determine Sundials BLAS/LAPACK.")
env['has_sundials_lapack'] = int(has_sundials_lapack.strip())
#In the case where a user is trying to link Cantera to an exteral BLAS/LAPACK
#library, but Sundials was configured without this support, print a Warning.
if not env['has_sundials_lapack'] and not env['BUILD_BLAS_LAPACK']:
print ('WARNING: External BLAS/LAPACK has been specified for Cantera'
'but Sundials was built without this support.')
env = conf.Finish()
@ -1129,6 +1143,11 @@ if env['use_sundials'] == 'y':
configh['SUNDIALS_VERSION'] = env['sundials_version'].replace('.','')
else:
configh['SUNDIALS_VERSION'] = 0
if env['has_sundials_lapack'] and not env['BUILD_BLAS_LAPACK']:
configh['SUNDIALS_USE_LAPACK'] = 1
else:
configh['SUNDIALS_USE_LAPACK'] = 0
cdefine('H298MODIFY_CAPABILITY', 'with_h298modify_capability')

View file

@ -108,4 +108,8 @@ typedef int ftnlen; // Fortran hidden string length type
// for species
%(H298MODIFY_CAPABILITY)s
// Enable Sundials to use an external BLAS/LAPACK library if it was
// built to use this option
%(SUNDIALS_USE_LAPACK)s
#endif

View file

@ -16,10 +16,15 @@ using namespace std;
#include "sundials/sundials_nvector.h"
#include "nvector/nvector_serial.h"
#include "cvodes/cvodes.h"
#include "cvodes/cvodes_dense.h"
#if SUNDIALS_USE_LAPACK
#include "cvodes/cvodes_lapack.h"
#else
#include "cvodes/cvodes_dense.h"
#include "cvodes/cvodes_band.h"
#endif
#include "cvodes/cvodes_diag.h"
#include "cvodes/cvodes_spgmr.h"
#include "cvodes/cvodes_band.h"
#define CV_SS 1
#define CV_SV 2
@ -361,7 +366,11 @@ void CVodesIntegrator::applyOptions()
{
if (m_type == DENSE + NOJAC) {
long int N = m_neq;
CVDense(m_cvode_mem, N);
#if SUNDIALS_USE_LAPACK
CVLapackDense(m_cvode_mem, N);
#else
CVDense(m_cvode_mem, N);
#endif
} else if (m_type == DIAG) {
CVDiag(m_cvode_mem);
} else if (m_type == GMRES) {
@ -370,7 +379,11 @@ void CVodesIntegrator::applyOptions()
long int N = m_neq;
long int nu = m_mupper;
long int nl = m_mlower;
CVBand(m_cvode_mem, N, nu, nl);
#if SUNDIALS_USE_LAPACK
CVLapackBand(m_cvode_mem, N, nu, nl);
#else
CVBand(m_cvode_mem, N, nu, nl);
#endif
} else {
throw CVodesErr("unsupported option");
}