View Issue Details

IDProjectCategoryView StatusLast Update
0000585ascendsolverpublic2015-04-07 03:23
Reportersagitter 
Assigned To 
PrioritynormalSeverityblockReproducibilityalways
Status newResolutionopen 
PlatformLinuxOSFedoraOS Version21/22/23
Product Version0.9.8 
Target VersionFixed in Version 
Summary0000585: Compile against Sundials-2.6.1
DescriptionSundials-2.6.1 does not provide sundials-config anymore.
This lack imposes changes of Ascend code to detect properly all Sundials libraries which IDA solver needs.

I'm trying to patch scons/sundials.py file and change Sundials libraries detection (please, see patch attached). However scons-check does not find the right Sundials version, IDA solver is disabled.

Please, I need help to discover how to fix this problem.
Steps To ReproduceThis is scons command used:

scons %{?_smp_mflags} \
 INSTALL_ROOT=%{buildroot} \
 INSTALL_PREFIX=%{_prefix} \
 INSTALL_SHARE=%{_datadir} \
 INSTALL_BIN=%{_bindir} \
 INSTALL_INCLUDE=%{_includedir} \
 INSTALL_LIB=%{_libdir} \
 DEBUG=0 \
 WITH_DOC_BUILD=no \
 WITH_DOC_INSTALL=no \
 WITH_PYTHON=yes \
 WITH_TCLTK=no \
 WITH_GRAPHVIZ=yes \
 IPOPT_CPPPATH=%{_includedir}/coin \
 IPOPT_LIBPATH=%{_libdir} \
 IPOPT_LIBS="-L%{_libdir} -lipopt -ldmumps -lblas -llapack" \
 WITH_CUNIT=yes \
 CUNIT_CPPPATH=%{_includedir}/CUnit \
 CUNIT_LIBPATH=%{_libdir} \
 CUNIT_PREFIX=%{_prefix} \
 WITH_SOLVERS=QRSLV,LSODE,LRSLV,DOPRI5,IDA,IPOPT \
 ABSOLUTE_PATHS=no \
 ascend ascxx pygtk models solvers
Additional InformationSundials-2.6.1 is not in Fedora repositories yet.
You can find Sundials-2.6.1's RPMs for testing on my own repos; these RPMs contain pkg-config files which should be useful to reach all Sundials libs.
To accessing execute these commands by root from Fedora 21 or a recent Fedora 22 (under development):

yum install dnf
dnf copr enable sagitter/copasi
dnf install sundials-devel
TagsNo tags attached.

Relationships

Activities

sagitter

2015-04-06 22:25

reporter  

ascend-idasolver.patch (5,123 bytes)
--- scons/sundials.orig.py	2014-07-10 17:14:38.000000000 +0200
+++ scons/sundials.py	2015-04-04 19:28:32.694785931 +0200
@@ -51,103 +51,36 @@
 	"""
 	try:
 		if platform.system()=="Windows":
-			try:
-				# one day, we'll provide a SUNDIALS installer so that people don't have to 
-				# build their own SUNDIALS. In that case, look for the settings in the registry
-				import _winreg
-				x=_winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
-				y= _winreg.OpenKey(x,r"SOFTWARE\SUNDIALS")
-				PATH,t = _winreg.QueryValueEx(y,"InstallPath")
-				LIB = os.path.join(PATH,"lib")
-				BIN = os.path.join(PATH,"bin")
-				INCLUDE = os.path.join(PATH,"include")
-				env['SUNDIALS_CPPPATH'] = [munge(INCLUDE)]
-				env['SUNDIALS_LIBPATH'] = [munge(BIN)]
-				env['SUNDIALS_LIBS'] = ['sundials_ida','sundials_nvecserial','m']
-			except WindowsError:
-				sundialsconfig = find_sundials_config(env)
-				if not sundialsconfig:
-					raise RuntimeError("Unable to locate sundials-config in Windows PATH")
-					# if someone has installed sundials with ./configure --prefix=/MinGW using MSYS, then
-				# this should work, but we would like to make this a lot more robust!
-				cmd = ['sh.exe',sundialsconfig,'-mida','-ts','-lc']
-				env1 = env.Clone()
-				env1['CPPPATH'] = None
-				env1['LIBPATH'] = None
-				env1['LIBS'] = None
-				#print "RUNNING sundials-config"
-				env1.ParseConfig(cmd)
-				env['SUNDIALS_CPPPATH'] = [munge(winpath(p)) for p in env1.get('CPPPATH')]
-				env['SUNDIALS_LIBPATH'] = [munge(winpath(p)) for p in env1.get('LIBPATH')]
-				env['SUNDIALS_LIBS'] = env1.get('LIBS')
-				env['HAVE_SUNDIALS'] = True		
+			pkgconfig = ['c:\\MSYS\\1.0\\bin\\sh.exe','/MinGW/bin/pkg-config']
 
-			env['HAVE_SUNDIALS'] = True
-									
 		else:
-			sundialsconfig = env.WhereIs("sundials-config")
-			if not sundialsconfig:
-				raise RuntimeError("Unable to locate 'sundials-config' in PATH")
-			cmd = ['sundials-config','-mida','-ts','-lc']
-			env1 = env.Clone()
-			env1['CPPPATH'] = None
-			env1['LIBPATH'] = None
-			env1['LIBS'] = None
-			env1.ParseConfig(cmd)
-
-			# tricky stuff to detect the necessary extra 'lapack' linkage if required
-			if os.path.exists("/etc/lsb-release"):
-				print "CHECKING SUNDIALS"
-				s = env.WhereIs('sundials-config')
-				if s == "/usr/bin/sundials-config":
-					print "STANDARD CONFIG"
-					# With Ubuntu 11.10 onwards, we need to explicitly add lapack (and blas?)
-					f = file("/etc/lsb-release")
-					v = {}
-					for l in f:
-						x = l.strip().split("=")
-						v[x[0]] = x[1]
-					print v
-					if v['DISTRIB_ID']=="Ubuntu" and float(v['DISTRIB_RELEASE'])>=11.10:
-						print "ADDING LAPACK"
-						env1['LIBS'].append("lapack")
-
-			env['SUNDIALS_CPPPATH'] = env1.get('CPPPATH')
-			env['SUNDIALS_LIBPATH'] = env1.get('LIBPATH')
-			env['SUNDIALS_LIBS'] = env1.get('LIBS')
-			env['HAVE_SUNDIALS'] = True
+			pkgconfig = ['/usr/bin/pkg-config']
+
+		cmd = pkgconfig + ['ida','--libs','--cflags']
+		env1 = env.Clone()
+		env1['CPPPATH'] = None
+		env1['LIBPATH'] = None
+		env1['LIBS'] = None
+		env1.ParseConfig(cmd)
+		env['SUNDIALS_CPPPATH'] = env1.get('CPPPATH')
+		env['SUNDIALS_LIBPATH'] = env1.get('LIBPATH')
+		env['SUNDIALS_LIBS'] = env1.get('LIBS')
+		env['HAVE_SUNDIALS'] = True
 
 		print "SUNDIALS_LIBS =",env.get('SUNDIALS_LIBS')
 		print "SUNDIALS_LIBPATH =",env.get('SUNDIALS_LIBPATH')
 		print "SUNDIALS_CPPPATH =",env.get('SUNDIALS_CPPPATH')
 
+									
 	except Exception, e:
 		print "FAILED SUNDIALS DETECTION (%s):" % platform.system(),e.__class__,str(e)
 		env['HAVE_SUNDIALS'] = False
 
-def find_sundials_config(env):
-  """
-  Try and figure out if sundials-config is installed on this machine, and if so, where.
-  """
-  if SCons.Util.can_read_reg:
-    # If we can read the registry, get the NSIS command from it
-    try:
-		# 0x20019 is KEY_READ, 
-		k = SCons.Util.RegOpenKeyEx(SCons.Util.hkey_mod.HKEY_LOCAL_MACHINE,'SOFTWARE\\SUNDIALS',0,0x20019)
-		val, tok = SCons.Util.RegQueryValueEx(k,None)
-		ret = val + os.path.sep + 'makensis.exe'
-		if os.path.exists(ret):
-			return '"' + ret + '"'
-		else:
-			return None
-    except:
-		pass # Couldn't find the key, just act like we can't read the registry
-  # Hope it's on the path, but note that we have to be careful with PATHEXT since sundials-config doesn't have an 
-  # an executable-signifying suffix (seems like a weakness with env.WhereIs in SCons??
-  return WhereIs('sundials-config',path=os.environ['PATH'],pathext="")	
-
 def exists(env):
-	if find_sundials_config(env) != None:
-		return 1
-	return 0
+	"""
+	Make sure this tool exists.
+	"""
+	if not subprocess.call('pkg-config --exists ipopt'):
+		return True
+	return False

--- solvers/ida/ida.orig.h	2014-07-10 17:15:33.000000000 +0200
+++ solvers/ida/ida.h	2015-04-05 21:49:58.487195791 +0200
@@ -48,7 +48,7 @@
 # define IDA_MTX_T DenseMat
 #endif
 
-#if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR==2
+#if SUNDIALS_VERSION_MAJOR==2 && SUNDIALS_VERSION_MINOR>=2
 # include <sundials/sundials_config.h>
 # include <sundials/sundials_nvector.h>
 # include <ida/ida_spgmr.h>

ascend-idasolver.patch (5,123 bytes)

Issue History

Date Modified Username Field Change
2015-04-06 22:25 sagitter New Issue
2015-04-06 22:25 sagitter File Added: ascend-idasolver.patch