Fix type handling of Fortran BMI adapter #915
Draft
+83
−119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The existing BMI adapter for Fortran modules will not behave correctly in situations when the size of Fortran types is modified from the "standard" expected size. This is because the adapter does not ask the module directly for variable item sizes when deciding what corresponding type to use for values inside the framework.
For example, consider this method from Bmi_Fortran_Adapter:
The adapter only asks for a variable's type and assumes the appropriate item size strictly based on the type name string: e.g., that an advertised
integerwill be the same size as a C++int. This is not guaranteed to be correct, as type resizing can be done at compile time, using flags like gfortran's-fdefault-real-8.Changes
get_analogous_cxx_typeto get the C++ type corresponding to not just the category (i.e., integer, float) but also the memory size of a variableget_analogous_cxx_typefor determining how types should be handledGetValue/SetValueimplementations, since updated implementations now violated the intended premise of "inner" functions for the class.Testing
Existing unit tests pass as they did previously(actually, they are ... there are a few failing (though seemingly unrelated) tests ... I'm investigating)Notes
Todos
Checklist
Testing checklist (automated report can be put here)
Target Environment support