-
Notifications
You must be signed in to change notification settings - Fork 139
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
Refactoring of CField struct to include gridindexingtype and interp_method #1673
base: analyticaladvection_in_jit
Are you sure you want to change the base?
Refactoring of CField struct to include gridindexingtype and interp_method #1673
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files@@ Coverage Diff @@
## analyticaladvection_in_jit #1673 +/- ##
===========================================================
Coverage 86.22% 86.22%
===========================================================
Files 67 67
Lines 11827 11828 +1
===========================================================
+ Hits 10198 10199 +1
Misses 1629 1629
Flags with carried forward coverage won't be shown. Click here to find out more.
|
gridindexingtype_mapping = {"nemo": 0, "mitgcm": 1, "mom5": 2, "pop": 3} | ||
interp_method_mapping = { | ||
"LINEAR": 0, | ||
"NEAREST": 1, | ||
"CGRID_VELOCITY": 2, | ||
"CGRID_TRACER": 3, | ||
"BGRID_VELOCITY": 4, | ||
"BGRID_W_VELOCITY": 5, | ||
"BGRID_TRACER": 6, | ||
"LINEAR_INVDIST_LAND_TRACER": 7, | ||
"PARTIALSLIP": 8, | ||
"FREESLIP": 9, | ||
} |
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.
This is still a bit ugly, because it mirrors the information from
Parcels/parcels/include/index_search.h
Lines 22 to 30 in 997e3f8
typedef enum | |
{ | |
LINEAR=0, NEAREST=1, CGRID_VELOCITY=2, CGRID_TRACER=3, BGRID_VELOCITY=4, BGRID_W_VELOCITY=5, BGRID_TRACER=6, LINEAR_INVDIST_LAND_TRACER=7, PARTIALSLIP=8, FREESLIP=9 | |
} InterpCode; | |
typedef enum | |
{ | |
NEMO = 0, MITGCM = 1, MOM5 = 2, POP = 3 | |
} GridIndexingType; |
It would be cleaner to either
- Use the string here in the CField, instead of an integer. I tried using
c_char_p
, but that didn't work (yet) - Somehow import the typedefs from
index_search.h
(above) here
In any case, I think we want to avoid happing two places where these mappings between strings and integers occur...
Following #1612, where we need to provide the
gridindexingtype
on theCField
struct for technical reasons, it makes sense to also use it throughout the rest of the C-code. Hence, this PR refactors the code to not require thegridindexingtype
andinterp_method
when calling a Field evaluation in C, but get them from theCField
itself