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

Mixed precision: fms_mod #1147

Merged
merged 16 commits into from
Mar 29, 2023
Merged

Mixed precision: fms_mod #1147

merged 16 commits into from
Mar 29, 2023

Conversation

J-Lentz
Copy link
Contributor

@J-Lentz J-Lentz commented Mar 7, 2023

Description
monotonic_array in fms_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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • New check tests, if applicable, are included
  • make distcheck passes

Jesse Lentz added 9 commits March 1, 2023 14:29
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.
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
Copy link
Member

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.

Copy link
Contributor Author

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.

Comment on lines 120 to 123
module procedure string_from_logical
module procedure string_from_integer
module procedure string_from_r4, string_from_r8
end interface
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Contributor

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?

Copy link
Contributor

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

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 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>)
Copy link
Contributor

Choose a reason for hiding this comment

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

here too

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 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 \
Copy link
Contributor

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)?

Copy link
Contributor Author

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)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Contributor Author

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".

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

here too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Jesse Lentz added 4 commits March 23, 2023 14:28
@thomas-robinson thomas-robinson mentioned this pull request Mar 27, 2023
8 tasks
@rem1776 rem1776 merged commit 6b3855a into NOAA-GFDL:mixedmode Mar 29, 2023
rem1776 pushed a commit to rem1776/FMS that referenced this pull request May 25, 2023
rem1776 added a commit that referenced this pull request Jun 2, 2023
…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>
rem1776 added a commit that referenced this pull request Jun 16, 2023
…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>
@J-Lentz J-Lentz deleted the fms_mod branch July 19, 2023 18: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.

6 participants