-
Notifications
You must be signed in to change notification settings - Fork 136
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: time_manager reals to r8 and clean up #1196
Conversation
time_manager/time_manager.F90
Outdated
|
||
if(.not.module_is_initialized) call time_manager_init | ||
|
||
! Convert time intervals to floating point days; risky for general performance? | ||
d1 = time1%days * dble(seconds_per_day) + dble(time1%seconds) + time1%ticks/dble(ticks_per_second) | ||
d2 = time2%days * dble(seconds_per_day) + dble(time2%seconds) + time2%ticks/dble(ticks_per_second) | ||
d1 = time1%days * real(seconds_per_day, r8_kind) + real(time1%seconds, r8_kind) & |
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(time1%days, r8_kind)
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.
@rem1776 this change :)
time_manager/time_manager.F90
Outdated
d2 = time2%days * dble(seconds_per_day) + dble(time2%seconds) + time2%ticks/dble(ticks_per_second) | ||
d1 = time1%days * real(seconds_per_day, r8_kind) + real(time1%seconds, r8_kind) & | ||
+ time1%ticks/real(ticks_per_second, r8_kind) | ||
d2 = time2%days * real(seconds_per_day, r8_kind) + real(time2%seconds, r8_kind) & |
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(time2%days, r8_kind)
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.
@rem1776 this one too
end function real_to_time_type | ||
end function real8_to_time_type | ||
|
||
function real4_to_time_type(x, err_msg) result(t) |
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 this function be needed if all reals are r8_kind in time_manager?
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 it's for external routines, if a module is compiled with r4 it'll call this to get a new time type. It gets converted/rounded anyway by safe_rtoi
time_manager/time_manager.F90
Outdated
div = d/dble(n) | ||
dseconds_per_day = real(seconds_per_day, r8_kind) | ||
dticks_per_second = real(ticks_per_second, r8_kind) | ||
d = time%days*dseconds_per_day*dticks_per_second + real(time%seconds, r8_kind)*dticks_per_second + & |
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(time%days,r8_kind)
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.
@rem1776 this one too
time_manager/time_manager.F90
Outdated
dticks_per_second = real(ticks_per_second, r8_kind) | ||
d = time%days*dseconds_per_day*dticks_per_second + real(time%seconds, r8_kind)*dticks_per_second + & | ||
real(time%ticks, r8_kind) | ||
div = d/real(n, r8_kind) | ||
|
||
days = int(div/(dseconds_per_day*dticks_per_second)) | ||
seconds = int(div/dticks_per_second - days*dseconds_per_day) |
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(days,r8_kind)
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.
and here
time_manager/time_manager.F90
Outdated
@@ -2528,7 +2049,7 @@ function increment_date_private(Time, years, months, days, hours, minutes, secon | |||
cmonth = cmonth + months | |||
|
|||
! Adjust year and month number when cmonth falls outside the range 1 to 12 | |||
cyear = cyear + floor((cmonth-1)/12.) | |||
cyear = cyear + floor((cmonth-1)/12.0_r8_kind) |
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(cmonth-1,r8_kind)
@@ -313,34 +322,50 @@ function get_cal_time(time_increment, units, calendar, permit_calendar_conversio | |||
increment_days = floor(dt/86400) | |||
increment_seconds = int(dt - increment_days*86400) | |||
else |
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.
lines 292 -323, time_increment and dt are reals doing math with ints
!------------------------------------------------------------------------ | ||
|
||
!> For mixed precision support, just casts to passed in increment to r8 | ||
function get_calendar_time_wrap(time_increment, units, calendar, permit_calendar_conversion) |
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.
wondering if this function is needed
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 was needed to compile with current mixed mode so I think it'll be needed
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.
do you think using class(*) for time_increment would work? Or is that going to make things messier..
@rem1776 could you also add mixed precision to the pr title? :) |
@rem1776 ignore recent comments, did not see that they were outdated! |
if (rval .le. big .and. -1.*rval .ge. -1.*big) then | ||
real(r8_kind) :: big | ||
big = real(huge(ival), r8_kind) | ||
if (rval .le. big .and. -1.0_r8_kind*rval .ge. -1.0_r8_kind*big) then |
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.
if (rval .le. big .and. -1.0_r8_kind*rval .ge. -1.0_r8_kind*big) then
I'm confused by this if
condition. Under what circumstance would the comparisons on the left and right of the .and.
ever differ from one another?
BREAKING CHANGE: In coupler_types.F90, `coupler_nd_field_type` and `coupler_nd_values_type` have been renamed to indicate real kind value: `coupler_nd_real4/8_field_type` and `coupler_nd_real4/8_values_type`. The `bc` field within `coupler_nd_bc_type` was modified to use r8_kind within the value and field types, and an additional field added `bc_r4` to use r4_kind values. Includes: * feat: eliminate use of real numbers for mixed precision in `block_control` (#1195) * feat: mixed precision field_manager (#1205) * feat: mixed precision random_numbers_mod (#1191) * feat: mixed precision time_manager reals to r8 and clean up (#1196) * feat: mixed Precision tracer_manager (#1212) * Mixed precision monin_obukhov (#1116) * Mixed precision: `monin_obukhov` unit tests (#1272) * mixed-precision diag_integral_mod (#1217) * mixed precision time_interp (#1252) * mixed precision interpolator_mod (#1305) * Mixed precision astronomy (#1092) * Mixed precision `data_override_mod` (#1323) * mixed precision exchange (#1341) * coupler mixed precision (#1353) * Mixed precision topography_mod (#1250) --------- Co-authored-by: rem1776 <Ryan.Mulhall@noaa.gov> Co-authored-by: MiKyung Lee <58964324+mlee03@users.noreply.github.com> Co-authored-by: mlee03 <Mikyung.Lee@lscamd50-d.gfdl.noaa.gov> Co-authored-by: Caitlyn McAllister <65364559+mcallic2@users.noreply.github.com> Co-authored-by: Jesse Lentz <42011922+J-Lentz@users.noreply.github.com>
Description
replaces default reals and
double precision
values with explicit r8_kinds.i created wrappers for get_cal_time and real_to_time_type so that they convert passed in r4's to r8 before calling the full routines. This makes all the real calculations done in r8_kind instead of default real precision.
I also cleaned up a lot of the old html comments since some were left in this module and made a small update to the test.
How Has This Been Tested?
oneapi 23.0, amd
Checklist:
make distcheck
passes