-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from NOAA-GFDL/develop
Release 2024.04.00
- Loading branch information
Showing
5 changed files
with
354 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import gt4py.cartesian.gtscript as gtscript | ||
from gt4py.cartesian.gtscript import PARALLEL, computation, interval | ||
|
||
from ndsl.dsl.typing import Float, FloatField, FloatFieldIJ | ||
|
||
|
||
def copy_defn(q_in: FloatField, q_out: FloatField): | ||
""" | ||
Copy q_in to q_out. | ||
Args: | ||
q_in: input field | ||
q_out: output field | ||
""" | ||
with computation(PARALLEL), interval(...): | ||
q_out = q_in | ||
|
||
|
||
def adjustmentfactor_stencil_defn(adjustment: FloatFieldIJ, q_out: FloatField): | ||
""" | ||
Multiplies every element of q_out | ||
by every element of the adjustment | ||
field over the interval, replacing | ||
the elements of q_out by the result | ||
of the multiplication. | ||
Args: | ||
adjustment: adjustment field | ||
q_out: output field | ||
""" | ||
with computation(PARALLEL), interval(...): | ||
q_out = q_out * adjustment | ||
|
||
|
||
def set_value_defn(q_out: FloatField, value: Float): | ||
""" | ||
Sets every element of q_out to the | ||
value specified by value argument. | ||
Args: | ||
q_out: output field | ||
value: NDSL Float type | ||
""" | ||
with computation(PARALLEL), interval(...): | ||
q_out = value | ||
|
||
|
||
def adjust_divide_stencil(adjustment: FloatField, q_out: FloatField): | ||
""" | ||
Divides every element of q_out | ||
by every element of the adjustment | ||
field over the interval, replacing | ||
the elements of q_out by the result | ||
of the multiplication. | ||
Args: | ||
adjustment: adjustment field | ||
q_out: output field | ||
""" | ||
with computation(PARALLEL), interval(...): | ||
q_out = q_out / adjustment | ||
|
||
|
||
@gtscript.function | ||
def sign(a, b): | ||
""" | ||
Defines asignb as the absolute value | ||
of a, and checks if b is positive | ||
or negative, assigning the analogus | ||
sign value to asignb. asignb is returned | ||
Args: | ||
a: A number | ||
b: A number | ||
""" | ||
asignb = abs(a) | ||
if b > 0: | ||
asignb = asignb | ||
else: | ||
asignb = -asignb | ||
return asignb | ||
|
||
|
||
@gtscript.function | ||
def dim(a, b): | ||
""" | ||
Performs a check on the difference | ||
between the values in arguments | ||
a and b. The variable diff is set | ||
to the difference between a and b | ||
when the difference is positive, | ||
otherwise it is set to zero. The | ||
function returns the diff variable. | ||
""" | ||
diff = a - b if a - b > 0 else 0 | ||
return diff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.