-
Notifications
You must be signed in to change notification settings - Fork 6
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
Collab/ndrop #172
Collab/ndrop #172
Conversation
Codecov Report
@@ Coverage Diff @@
## main #172 +/- ##
==========================================
+ Coverage 95.93% 96.30% +0.37%
==========================================
Files 28 28
Lines 4626 5202 +576
==========================================
+ Hits 4438 5010 +572
- Misses 188 192 +4
|
08a1621
to
d588e05
Compare
src/tests/CMakeLists.txt
Outdated
@@ -66,7 +66,7 @@ target_compile_options(mam4_nucleate_ice_unit_tests PRIVATE -Werror) | |||
# TODO: return to this test once we have more context for get_aer_num | |||
EkatCreateUnitTest(mam4_ndrop_unit_tests mam4_ndrop_unit_tests.cpp | |||
LIBS mam4xx_tests ${HAERO_LIBRARIES} EXCLUDE_TEST_SESSION) | |||
target_compile_options(mam4_ndrop_unit_tests PRIVATE -Werror) | |||
target_compile_options(mam4_ndrop_unit_tests PRIVATE) |
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.
You can delete this line, which no longer does anything.
maxsat.cpp | ||
update_from_newcld.cpp | ||
update_from_cldn_profile.cpp | ||
# update_from_explmix.cpp |
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.
Is update_from_explmix
still in progress? I noticed a comment in that file related to a thread team.
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.
The validation test is still in progress, but the subroutine was ported. We could remove this code from this PR.
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.
It's fine to leave the code in with this comment. I remember you and Mike telling me about this now.
// update_from_explmix(ensemble); | ||
} else if (func_name == "dropmixnuc") { | ||
dropmixnuc(ensemble); | ||
} |
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.
It seems like this code will silently do nothing if the function name doesn't match any of the names above. Might be good to put in an } else {
block to make sure that doesn't happen.
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.
This if statement is inside of a try statement that print an error.
auto func_name = settings.get("function");
try {
if {
} else if {
}...
...
} catch (std::exception &e) {
std::cerr << argv[0] << ": Error: " << e.what() << std::endl;
}
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.
True, but if func_name
doesn't match any of the names in the if
tests, no exception is thrown, right?
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.
You are correct. I will fix this.
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.
Done.
0.1999170945E005, 0.9524671355E005}; | ||
|
||
for (int i = 0; i < AeroConfig::num_modes(); ++i) { | ||
ss << "i = " << i; |
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.
Not a big deal, but you might find the fmt library a little more convenient for creating log messages. EKAT provides fmt
in addition to our logging library, so feel free to use it.
src/mam4xx/ndrop.hpp
Outdated
#include <haero/math.hpp> | ||
|
||
#include <mam4xx/aero_config.hpp> | ||
#include <mam4xx/conversions.hpp> | ||
#include <mam4xx/mam4_types.hpp> | ||
#include <mam4xx/ndrop.hpp> |
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.
Is this file including itself?
Slightly related: can you add a line to src/CMakeLists
to make sure that the ndrop.hpp
header is installed when we run make install
?
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.
Done.
src/mam4xx/ndrop.hpp
Outdated
const Real pi = haero::Constants::pi; | ||
|
||
// surface tension coefficient [m-K] (from mam4) | ||
// FIXME: any thoughts on what [m-K] means? |
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.
In my experience, fit coefficients often can't be interpreted physically, at least not directly. It seems to me that ssat_coeff
captures a power-law temperature dependence which is expressed in the form of this "surface tension" component. Note also the headache-inducing fractional-power (power law) units of ssat_coeff
.
// critical supersaturation at mode radius [fraction] | ||
// here we assume "value shouldn't matter much since naerosol is small" | ||
// ^(from mam4) | ||
// NOTE: excuse me... what?? |
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.
🤣
src/mam4xx/ndrop.hpp
Outdated
// @param [out] flux_fullact flux of activated aerosol fraction assuming | ||
// 100% activation [m/s] | ||
const Real zero = 0; | ||
const int nmodes = AeroConfig::num_modes(); |
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.
Should this (and statements like it) be constexpr int
instead of const int
to make sure that it can be used to provide a size for automatic arrays?
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.
I took a pass and left some minor comments. It looks really good! Nice work on this.
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.
Thanks to all who worked on this, it looks great. I am fine with merging this now.
… not match any of the function names in the validation driver.
This PR contains the C++ port of the Fortran subroutine ndrop We port and create validation tests for the following subroutines:
Ccncalc
: test for a single cell and another one for a column; passing with a relative error of 1e-5 and 2e-3get_activate_frac
: column test; passing with a relative error of 5e-5loadaer
: single cell test; passing with a relative error of 6e-8activate_modal
: single cell test; passing with a relative error of 7e-5explmix
: column tests; passing with a relative error of 1e-9 and 1e-10maxsat
: single cell test; passing with relative error of 1e-11update_from_newcld
: single cell tests; passing with relative errors of 1e-11, 1e-3, 2e-9update_from_cldn_profile
: single cell tests; passing with relative errors of 1e-12 and 9e-3dropmixnuc
: column tests; passing with relative error of 5e-5 and 6.9e-4update_from_explmix
will part of a future PR.
Notes:
ndrop
fortran code involves multiple columns; however, our porting was adapted for one column. As a result,ndrop/mam4xx
returns a per cell value for indexkk
, instead of returning a column-integrated variable ndropcol (column-integrated droplet number).dropmixnuc
), we pass work arrays as inputs.dropmixnuc
. Therefore, we addedteam_barriers
to synchronize threads and avoid race conditions.mam_idx
,mam_cnst_idx
,numptr_amode
,lmassptr_amode
,lspectype_amode
) are inputs inndrop/mam4xx
. In addition, conversion from Fortran indexing to C++ indexing is done inside of the functions. We did not modifyndrop/mam4
indexing arrays. For future work, we could work on merging these different mapping arrays.Closes #161