-
Notifications
You must be signed in to change notification settings - Fork 135
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
Mixed precision: fms_mod #1147
Mixed precision: fms_mod #1147
Conversation
Implement mixed mode for the `monotonic_array` function in `fms_mod`.
Implement a unit test for the `monotonic_array` function in `fms_mod`.
Merge the `string` branch, which contains an extended version of `string` and the new `stringify` interface from `fms_string_utils_mod`.
Remove the PRETTY() macro from the `fms_mod` test, as `string` has been updated to strip leading and trailing whitespace from its output.
To be consistent with mixed-mode code guidelines, define the kind macros in `test_fms_r4.fh` and `test_fms_r8.fh` rather than in `test_fms.F90`.
Replace the `C(x)` macro with a local variable that aliases the `FMS_MOD_TEST_KIND_` macro. Also, add underscores to the end of all macro names to be consistent with mixed-mode code guidelines.
Add more test cases to the `monotonic_array` unit test.
fms/include/fms.inc
Outdated
integer, intent(out), optional :: direction !< If the input array is: | ||
!! >> monotonic (small to large) then direction = +1. | ||
!! >> monotonic (large to small) then direction = -1. | ||
!! >> not monotonic then direction = 0. | ||
logical :: monotonic_array !< If the input array of real values either increases or decreases monotonically | ||
!! then TRUE is returned, otherwise FALSE is returned. | ||
logical :: MONOTONIC_ARRAY_ !< If the input array of real values either increases or decreases monotonically |
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 realize you didn't write this code @J-Lentz , but this seems very odd to me. I would just declare this function as logical, or have a return value and declare that return value as logical. This is somehow both and neither at the same time.
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.
Return variable has been replaced with ret
in c245ad6.
string_utils/fms_string_utils.F90
Outdated
module procedure string_from_logical | ||
module procedure string_from_integer | ||
module procedure string_from_r4, string_from_r8 | ||
end interface |
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.
Will the conflict with 2023.01-beta3?
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.
Updated fms_string_utils_mod
merged from main in 42c2d1c.
CMakeLists.txt
Outdated
mpp/include | ||
constants) | ||
constants | ||
test_fms/fms/include) |
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 sure if test_fms is needed for CMake yet. @rem1776, is this correct?
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.
Yeah that's correct we don't have cmake set up to run the tests so we don't need to compile them
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.
Removed from CMakeLists.txt
in 1a1f887.
CMakeLists.txt
Outdated
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mpp/include>) | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/string_utils/include> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/mpp/include> | ||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/test_fms/fms/include>) |
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.
here too
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.
Removed in 1a1f887.
@@ -32,6 +32,9 @@ noinst_LTLIBRARIES = libfms.la | |||
# Each convenience library depends on its source. | |||
libfms_la_SOURCES = \ | |||
fms.F90 \ | |||
include/fms.inc \ |
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.
are these also needed for fms_mod.$(FC_MODEXT)?
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.
real, intent(in) :: array(:) !< An array of real values. If the size(array) < 2 this function | ||
!! assumes the array is not monotonic, no fatal error will occur. | ||
|
||
function MONOTONIC_ARRAY_(array, direction) result(ret) |
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 guess this routine doesn't take into account elements having the same value, e.g. -2, -1, 0, 0, 1, 2
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.
Need to get my math concepts straight. Monotonic increasing/decreasing = strictly increasing/decreasing and not remaining constant. All's good.
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 believe monotonic functions, as commonly defined, can have plateaus of constant value. So this function seems to use a peculiar definition of "monotonic".
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.
There is a difference between a monotonic and a strictly monotonic function. If this function only enforces (X1 < X2), then it is testing for strict increasing monotonicity. If it is (X1 > X2), then it is enforcing strict decreasing monotonicity.
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.
Perhaps it's worth commenting in the code that monotonic refers to strictly monotonic.
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.
fms/include/fms_r4.fh
Outdated
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.
#def #undef #def #undef include format
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.
fms/include/fms_r8.fh
Outdated
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.
here too
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.
test_fms/fms/include/test_fms_r8.fh
Outdated
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.
here too
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.
Indicate in the Doxygen comments that `monotonic_array` checks for strict monotonicity.
…re, and fms_mod (#1239) * feat: mixed precision axis_utils2 (#1104) * feat: mixed precision fms_mod (#1147) * feat: horiz interp mixed precision (#1067) * mixed precision sat_vapor_pressure (#1095) * feat: add mixed precision axis_utils unit tests (#1172) * fix: move type definitions to before first usage to fix nvhpc bug (#1187) * fix: change allocatable type for intel errors (#1221) Co-authored-by: Caitlyn McAllister <65364559+mcallic2@users.noreply.github.com> Co-authored-by: Jesse Lentz <42011922+J-Lentz@users.noreply.github.com> Co-authored-by: MiKyung Lee <58964324+mlee03@users.noreply.github.com>
…re, and fms_mod (#1239) (#1258) * feat: mixed precision axis_utils2 (#1104) * feat: mixed precision fms_mod (#1147) * feat: horiz interp mixed precision (#1067) * mixed precision sat_vapor_pressure (#1095) * feat: add mixed precision axis_utils unit tests (#1172) * fix: move type definitions to before first usage to fix nvhpc bug (#1187) * fix: change allocatable type for intel errors (#1221) Co-authored-by: Caitlyn McAllister <65364559+mcallic2@users.noreply.github.com> Co-authored-by: Jesse Lentz <42011922+J-Lentz@users.noreply.github.com> Co-authored-by: MiKyung Lee <58964324+mlee03@users.noreply.github.com>
Description
monotonic_array
infms_mod
has been converted to mixed precision, and a unit test has been written for it.How Has This Been Tested?
Unit test compiles, runs, and passes on the AMD box with gcc and Intel.
Checklist:
make distcheck
passes