-
Notifications
You must be signed in to change notification settings - Fork 435
EAMxx: fix numerical value of fill value #7557
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d8b2bf0
EAMxx: fix numerical value of fill value
bartgol d573296
EAMxx: fix fill_aware_combine to work with packs
bartgol 622e1db
EAMxx: move combine_ops testing to its own test
bartgol ed474f2
EAMxx: add testing for field operations that involves fill values
bartgol f02600c
EAMxx: use fill value only from RHS in field update
bartgol 5f4ef9c
EAMxx: use SFINAE in fill_aware_combine implementation
bartgol a6539e5
EAMxx: fix compiler warning in scorpio interface
bartgol File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <catch2/catch.hpp> | ||
|
||
#include "share/util/eamxx_combine_ops.hpp" | ||
#include "share/util/eamxx_universal_constants.hpp" | ||
#include "share/eamxx_types.hpp" | ||
|
||
#include "ekat/ekat_pack.hpp" | ||
|
||
#include <iomanip> | ||
|
||
namespace { | ||
|
||
TEST_CASE ("combine_ops") { | ||
using namespace scream; | ||
using pack_type = ekat::Pack<Real,SCREAM_PACK_SIZE>; | ||
|
||
constexpr auto Replace = CombineMode::Replace; | ||
constexpr auto Update = CombineMode::Update; | ||
constexpr auto Multiply = CombineMode::Multiply; | ||
constexpr auto Divide = CombineMode::Divide; | ||
constexpr auto Max = CombineMode::Max; | ||
constexpr auto Min = CombineMode::Min; | ||
constexpr auto fv_val = constants::fill_value<Real>; | ||
|
||
const pack_type two (2.0); | ||
const pack_type four (4.0); | ||
const pack_type six (6.0); | ||
const pack_type ten (10.0); | ||
const pack_type fv (constants::fill_value<Real>); | ||
const pack_type fv_times_ten (constants::fill_value<Real> * 10); | ||
|
||
pack_type x; | ||
|
||
x = two; | ||
combine<Replace>(two,x,1,0); | ||
REQUIRE ( (x==two).all() ); | ||
|
||
combine<Update>(two,x,2.0,1.0); | ||
REQUIRE ( (x==six).all() ); | ||
fill_aware_combine<Update>(fv,x,fv_val,2.0,1.0); | ||
if (not (x==six).all() ) { | ||
std::cout << "x: " << x << "\n"; | ||
std::cout << " x[0]: " << std::setprecision(18) << x[0] << "\n"; | ||
std::cout << "fv[0]: " << std::setprecision(18) << fv[0] << "\n"; | ||
} | ||
REQUIRE ( (x==six).all() ); | ||
|
||
x = two; | ||
combine<Multiply>(two,x,1,1); | ||
REQUIRE ( (x==four).all() ); | ||
fill_aware_combine<Multiply>(fv,x,fv_val,1,1); | ||
REQUIRE ( (x==four).all() ); | ||
|
||
x = four; | ||
combine<Divide>(two,x,1,1); | ||
REQUIRE ( (x==two).all() ); | ||
fill_aware_combine<Divide>(fv,x,fv_val,1,1); | ||
REQUIRE ( (x==two).all() ); | ||
|
||
x = two; | ||
combine<Max>(four,x,1,1); | ||
REQUIRE ( (x==four).all() ); | ||
fill_aware_combine<Max>(fv,x,fv_val,1,1); | ||
REQUIRE ( (x==four).all() ); | ||
|
||
x = four; | ||
combine<Min>(two,x,1,1); | ||
REQUIRE ( (x==two).all() ); | ||
x = fv_times_ten; | ||
fill_aware_combine<Min>(fv,x,fv_val,1,1); | ||
REQUIRE ( (x==fv_times_ten).all() ); | ||
} | ||
|
||
} // anonymous namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would all things below still yield the same result?
Real(fill_value<double>)
static_cast<float>(fill_value<double>)
static_cast<double>(fill_value<float>)
If not, should we leave some notes on which inside of EAMxx is the ultimate fill_value so that people can follow instructions to retrieve it?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Casting to Real should yield the same number, since fv_d==fv_f, and Real is either double or float. I am not sure what the 2nd and 3rd bullet referred to, as you probably forgot to put the type you cast to. But I assume you prob want to know whether, given fv_d and fv_f above, we have
fv_d == fv_d == fill_value<Real> == static_cast<Real>(fv_d) == static_cast<Real>(fv_f) == static_cast<double>(fv_f) == static_cast<float>(fv_d)
and so on, and the answer is "yes". They are ALL the same numerical value. It's even safe to dosince
fv
will be promoted to double without changing the numerical value.