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

Add support for kpp format #497

Merged
merged 24 commits into from
Nov 10, 2023
Merged

Add support for kpp format #497

merged 24 commits into from
Nov 10, 2023

Conversation

rs028
Copy link
Collaborator

@rs028 rs028 commented May 17, 2023

This will let the model use chemical mechanisms in KPP format (issue #304).

Also includes minor and cosmetic changes to the Python scripts in build/ and tools/ (checked using pylint) and to some bash scripts.

This also changes the version number back to development towards the 1.3 release (1.3-dev).

@codecov
Copy link

codecov bot commented May 17, 2023

Codecov Report

Merging #497 (25cd946) into master (457b3e4) will not change coverage.
Report is 2 commits behind head on master.
The diff coverage is 100.00%.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #497   +/-   ##
=======================================
  Coverage   66.66%   66.66%           
=======================================
  Files          17       17           
  Lines        2049     2049           
=======================================
  Hits         1366     1366           
  Misses        683      683           
Flag Coverage Δ
build 52.70% <100.00%> (ø)
tests 66.83% <100.00%> (ø)
unittests 54.78% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/atchem2.f90 87.68% <100.00%> (ø)

Continue to review full report in Codecov by Sentry.

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

or re.match('^\s*select\s*', to_output, flags=re.IGNORECASE) \
or re.match('^\s*case\s*', to_output, flags=re.IGNORECASE) \
or re.match('^\s*type\s+', to_output, flags=re.IGNORECASE):
if re.search(r'\s*if.+then', to_output, flags=re.IGNORECASE) \
Copy link
Collaborator Author

@rs028 rs028 Aug 10, 2023

Choose a reason for hiding this comment

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

I changed this because the fix_style.py script changes IF-THEN-ELSE to lowercase, but it shouldn't make a difference given the IGNORECASE flag.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense

# at the top of mechanism.f90 for each errant species.
#
# TODO: This will break the expected format when mechanism.f90 is
# replaced by a parsable format
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This TODO comment was added with PR #347. I think it refers to the implementation of the function parser which then was abandoned in favor of the shared .so file (?)
If so, it's probably not something "to do" anymore?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so - fine to delete.

@codecov
Copy link

codecov bot commented Sep 14, 2023

Codecov Report

All modified lines are covered by tests ✅

Comparison is base (4373dc9) 52.00% compared to head (7d1fdc1) 52.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #497      +/-   ##
==========================================
+ Coverage   52.00%   52.05%   +0.04%     
==========================================
  Files          17       17              
  Lines        2096     2096              
  Branches      166      166              
==========================================
+ Hits         1090     1091       +1     
+ Misses        934      933       -1     
  Partials       72       72              
Files Coverage Δ
src/atchem2.f90 78.53% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rs028
Copy link
Collaborator Author

rs028 commented Sep 26, 2023

The procedure involves a new script kpp_conversion.py which converts the mechanism in KPP format to a .fac file, which is then processed as usual. Possibly not the most efficient way to do it, but the easiest to implement.

This only works for the KPP files created by the MCM website. There is a large variability in the possible format of kpp files so it is hard to do better without specific examples.

Two new tests are also added to verify that the conversion is correct: a reference test with a normal fac mechanism and an identical (ie using same config) test using a kpp mechanism. They give the same results.

@rs028 rs028 requested a review from spco September 26, 2023 12:52
or re.match('^\s*select\s*', to_output, flags=re.IGNORECASE) \
or re.match('^\s*case\s*', to_output, flags=re.IGNORECASE) \
or re.match('^\s*type\s+', to_output, flags=re.IGNORECASE):
if re.search(r'\s*if.+then', to_output, flags=re.IGNORECASE) \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Makes sense

# at the top of mechanism.f90 for each errant species.
#
# TODO: This will break the expected format when mechanism.f90 is
# replaced by a parsable format
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think so - fine to delete.

@spco
Copy link
Collaborator

spco commented Nov 7, 2023

I think this all makes sense. On formatting and style, I have thoughts we should use existing external tools rather than rolling our own if possible - will create a separate issue.

@rs028 rs028 merged commit d3ce21b into AtChem:master Nov 10, 2023
@rs028
Copy link
Collaborator Author

rs028 commented Nov 10, 2023

@spco thanks a lot!

@rs028 rs028 deleted the add_kpp_format branch November 10, 2023 02:36
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.

2 participants