-
Notifications
You must be signed in to change notification settings - Fork 16
[WIP] Rayleigh Damping mixed precision fix #32
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
base: develop
Are you sure you want to change the base?
Changes from 2 commits
70ea601
4c8403a
bad27a8
e4d65df
e077ab4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| FORWARD, | ||
| PARALLEL, | ||
| computation, | ||
| f64, | ||
| horizontal, | ||
| interval, | ||
| log, | ||
|
|
@@ -18,7 +19,7 @@ | |
| from ndsl.dsl.typing import Float, FloatField, FloatFieldK | ||
|
|
||
|
|
||
| SDAY = 86400.0 | ||
| SDAY = Float(86400.0) | ||
|
|
||
|
|
||
| # NOTE: The fortran version of this computes rf in the first timestep only. Then | ||
|
|
@@ -36,7 +37,7 @@ def compute_rf_vals(pfull, bdt, rf_cutoff, tau0, ptop): | |
| @gtscript.function | ||
| def compute_rff_vals(pfull, dt, rf_cutoff, tau0, ptop): | ||
| rffvals = compute_rf_vals(pfull, dt, rf_cutoff, tau0, ptop) | ||
| rffvals = 1.0 / (1.0 + rffvals) | ||
| rffvals = f64(1.0) / (f64(1.0) + rffvals) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In an f32 run, aren't you only promoting the constants here and not rffvals?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The upcaster will force in the rffvals: f64 = ...
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
| return rffvals | ||
|
|
||
|
|
||
|
|
@@ -155,14 +156,26 @@ class RayleighDamping: | |
| Fortran name: ray_fast. | ||
| """ | ||
|
|
||
| def __init__(self, stencil_factory: StencilFactory, rf_cutoff, tau, hydrostatic): | ||
| def __init__( | ||
| self, | ||
| stencil_factory: StencilFactory, | ||
| rf_cutoff: Float, | ||
| tau: Float, | ||
| hydrostatic: bool, | ||
| ): | ||
| orchestrate(obj=self, config=stencil_factory.config.dace_config) | ||
| grid_indexing = stencil_factory.grid_indexing | ||
| self._rf_cutoff = rf_cutoff | ||
| self._rf_cutoff = Float(rf_cutoff) | ||
| origin, domain = grid_indexing.get_origin_domain( | ||
| [X_INTERFACE_DIM, Y_INTERFACE_DIM, Z_DIM] | ||
| ) | ||
|
|
||
| if tau == 0: | ||
| raise NotImplementedError( | ||
| "Dynamical Core (fv_dynamics): RayleighDamping," | ||
| " with tau <= 0, is not implemented" | ||
| ) | ||
|
|
||
| ax_offsets = grid_indexing.axis_offsets(origin, domain) | ||
| local_axis_offsets = {} | ||
| for axis_offset_name, axis_offset_value in ax_offsets.items(): | ||
|
|
@@ -175,7 +188,7 @@ def __init__(self, stencil_factory: StencilFactory, rf_cutoff, tau, hydrostatic) | |
| domain=domain, | ||
| externals={ | ||
| "hydrostatic": hydrostatic, | ||
| "rf_cutoff": rf_cutoff, | ||
| "rf_cutoff": self._rf_cutoff, | ||
| "tau": tau, | ||
| **local_axis_offsets, | ||
| }, | ||
|
|
@@ -191,7 +204,7 @@ def __call__( | |
| dt: Float, | ||
| ptop: Float, | ||
| ): | ||
| rf_cutoff_nudge = self._rf_cutoff + min(100.0, 10.0 * ptop) | ||
| rf_cutoff_nudge = self._rf_cutoff + min(Float(100.0), Float(10.0) * ptop) | ||
|
|
||
| self._ray_fast_wind_compute( | ||
| u, | ||
|
|
||
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 seconds per day is used frequently in the the ndsl, dycore, and physics, would it be better to define it in the ndsl constants section to ensure uniformity?
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.
Yes we probably should be moving that to
constant