-
Notifications
You must be signed in to change notification settings - Fork 12
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
[WIP] broke getGlobalRowView #216
Conversation
Codecov Report
@@ Coverage Diff @@
## master #216 +/- ##
=========================================
Coverage ? 34.38%
=========================================
Files ? 33
Lines ? 13444
Branches ? 0
=========================================
Hits ? 4623
Misses ? 8821
Partials ? 0
Continue to review full report at Codecov.
|
|
||
! check for throws and no-throws/values | ||
TEST_THROW(cgview => A%getGlobalRowIndicesView(gblrow)) | ||
TEST_THROW(csview => A%getGlobalRowValuesView(gblrow)) |
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.
@aprokop, to be consistent with Tpetra, we could make a non-member getGlobalRowView
procedure that mimics the C++ member version. Something like:
subroutine getGlobalRowView(A, gblrow, cgview, csview)
type(TpetraCrsMatrix), intent(in) :: A
integer(global_ordinal_type), intent(in) :: gblrow
real(scalar_type), dimension(:), pointer :: csview
integer(global_ordinal_type), dimension(:), pointer :: cgview
cgview => A%getGlobalRowIndicesView(gblrow)
csview => A%getGlobalRowValuesView(gblrow)
end subroutine
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.
Hmm, ok. @sethrj Is it possible to inject code fragment into the Fortran wrapper for a specific class?
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, there are several ways it could be done. If the function signature can be automatically converted correctly from C++ then it's best to use %extend
on the class, then you can add code to the proxy function with %fortranappend
or %fortranprepend
. Or, you can replace the function call in the proxy code entirely using %feature("shadow")
.
The most manual solution is to extend the fortran class by manually extending the proxy code. I think it would look like this: one fragment adds to the module code, the second injects code into the class type definition.
%extend TpetraCrsMatrix {
%proxycode {
subroutine tpetracrsmat_getGlobalRowView(A, gblrow, cgview, csview)
type(TpetraCrsMatrix), intent(in) :: A
integer(global_ordinal_type), intent(in) :: gblrow
real(scalar_type), dimension(:), pointer :: csview
integer(global_ordinal_type), dimension(:), pointer :: cgview
cgview => A%getGlobalRowIndicesView(gblrow)
csview => A%getGlobalRowValuesView(gblrow)
end subroutine
}
%insert("ftypes") {
getGlobalRowView => tpetracrsmat_getGlobalRowView
}
}
The workaround I posted is not valid with the latest SWIG versions. I've updated the contents of @tjfulle's test and pushed to a new branch at https://github.com/sethrj/ForTrilinos/tree/fix-getGlobalRowView . It looks like the test now fails to compile, so that's a plus. I think it'll just be a simple matter of creating a new SWIGTYPE for "arrayview by reference". |
Closing due to inactivity |
No description provided.