Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simple fix for Sundials 5.1 compatibility #814

Merged
merged 5 commits into from
Apr 3, 2020

Conversation

band-a-prend
Copy link
Contributor

Checklist

  • There is a clear use-case for this code change
  • The commit message has a short title & references relevant issues
  • Build passes (scons build & scons test) and unit tests address code coverage
  • The pull request is ready for review

If applicable, fill in the issue number this pull request is fixing

Fixes #

Changes proposed in this pull request

The Sundials 5.1 has no any changes in CVODES API in comparison with sundials 4.0, 4.1, 5.0 therefore the compatibility configuration fix is trivial.

*****************************
***    Testing Summary    ***
*****************************

Tests passed: 1046
Up-to-date tests skipped: 0
Tests failed: 0

*****************************

The Sundials 5.1 has no any changes in CVODES API
in comparison with sundials 4.0, 4.1, 5.0 therefore
the compatibility configuration fix is trivial.
@band-a-prend
Copy link
Contributor Author

P.s.

Tested for system installed sundials.

I tried to make changes like in 94a7003
,but the submodule fetch sundials major release 5.0 instead of 5.1.

@bryanwweber
Copy link
Member

bryanwweber commented Mar 3, 2020

@band-a-prend Thanks for submitting this! You can update the submodule by

cd ext/sundials
git fetch
git checkout **tag for 5.1.0**
cd ../..
git add .
git commit -m 'Update Sundials submodule'

After that, assuming no code in SUNDIALS has moved around, the other changes in 94a7003 should be straightforward.

@band-a-prend
Copy link
Contributor Author

band-a-prend commented Mar 4, 2020

Thank you for the clue. The command git fetch in submodule directory didn't result in any thing for me and checkout didn't work after it. I have to use git submodule update --remote -- . to clone submodule repo and then git checkout v5.1.0. After that and going to root directory of cantera project the commited diff noticed a change in submodule sha1.

I push changes now and hope to check build process on my local machine this evening.

@bryanwweber
Copy link
Member

Thanks @band-a-prend perhaps the remote was not configured for the submodule or something. Anyways, the change seems to be appropriate

@band-a-prend
Copy link
Contributor Author

I recheck currently build and tests, please wait.

@band-a-prend
Copy link
Contributor Author

band-a-prend commented Mar 4, 2020

Appropriate sha1-snapshot (b78e575639babe99aea9a0558d0f64732d6d729e) of sundials tag v5.1.0 is fetched now into ext/sundials by SConstruct script. The build with options python_package = 'full' f90_interface = 'y' system_eigen = 'y' system_sundials = 'n' extra_inc_dirs = '/usr/include/eigen3' is successfully done. Tests are passed:

*****************************
***    Testing Summary    ***
*****************************

Tests passed: 1046
Up-to-date tests skipped: 0
Tests failed: 0

*****************************

@speth
Copy link
Member

speth commented Mar 24, 2020

Given the increased rate of releases of SUNDIALS, and the fact that we haven't seen breaking changes (at least, that affect Cantera) in several recent minor releases, I think we should assume compatibility with at least minor versions, i.e. 5.x. A build-time warning for versions newer than the latest we have tested would probably still be useful.

@bryanwweber
Copy link
Member

Also, since we now support every released version back to 2.4, I think we should turn this into a LooseVersion check, rather than explicitly listing all of the satisfactory values. That will simplify that rather unwieldy line, I think. It could be something like

if LooseVersion(env['sundials_version']) >= LooseVersion('6.0'):
    error...

@band-a-prend
Copy link
Contributor Author

@bryanwweber,
I replaced version list with LooseVersion conditions

Copy link
Member

@bryanwweber bryanwweber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple of small changes

SConstruct Outdated
@@ -1048,6 +1048,7 @@ env['has_demangle'] = conf.CheckDeclaration("boost::core::demangle",
'#include <boost/core/demangle.hpp>', 'C++')

import SCons.Conftest, SCons.SConf
from distutils.version import LooseVersion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to import this, LooseVersion is imported somewhere in the builtutils, which is * imported in SConstruct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed.

SConstruct Outdated
@@ -1108,7 +1109,7 @@ if env['system_sundials'] == 'y':

# Ignore the minor version, e.g. 2.4.x -> 2.4
env['sundials_version'] = '.'.join(sundials_version.split('.')[:2])
if env['sundials_version'] not in ('2.4','2.5','2.6','2.7','3.0','3.1','3.2','4.0','4.1','5.0'):
if LooseVersion(env['sundials_version']) < LooseVersion('2.4') or LooseVersion(env['sundials_version']) >= LooseVersion('6.0'):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest creating a variable for LooseVersion(env['sundials_version']) here to shorten this line... the whole point was to make it shorter 😂 You could then reuse that variable on line 1118 in that other if statement comparing to 2.4.

Copy link
Contributor Author

@band-a-prend band-a-prend Mar 26, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I then also could safely reuse this shorter variable at line 1610 because it's within another one if env['system_sundials'] == 'y' condition check.

system_sundials_version seems as reasonable name this case: although this will not make expression significantly shorter but it will avoid evaluation of LooseVersion() again and again for if env['system_sundials'] == 'y' blocks.

the whole point was to make it shorter 😂

Yes, at this point of view this attempt certainly has failed. But it then should become more readable in comparison with rapidly expanding list of numbers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last commit is updated.

SConstruct Outdated
@@ -1108,13 +1108,14 @@ if env['system_sundials'] == 'y':

# Ignore the minor version, e.g. 2.4.x -> 2.4
env['sundials_version'] = '.'.join(sundials_version.split('.')[:2])
if env['sundials_version'] not in ('2.4','2.5','2.6','2.7','3.0','3.1','3.2','4.0','4.1','5.0'):
system_sundials_version = LooseVersion(env['sundials_version'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't necessarily associated with the system SUNDIALS though, so I think just sundials_ver would be sufficient and shorter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

We expect that minor version number release will not introduce breaking
changes, but the user should be warned that their version of SUNDIALS is
untested.
@codecov
Copy link

codecov bot commented Mar 27, 2020

Codecov Report

Merging #814 into master will not change coverage by %.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #814   +/-   ##
=======================================
  Coverage   71.39%   71.39%           
=======================================
  Files         372      372           
  Lines       43482    43482           
=======================================
  Hits        31045    31045           
  Misses      12437    12437           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c16c4b0...846a7a6. Read the comment docs.

@bryanwweber bryanwweber added Input Input parsing and conversion (for example, ck2yaml) help wanted and removed Input Input parsing and conversion (for example, ck2yaml) help wanted labels Apr 2, 2020
@speth speth merged commit 3a9f637 into Cantera:master Apr 3, 2020
@band-a-prend band-a-prend deleted the sundials branch September 27, 2020 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants