-
Notifications
You must be signed in to change notification settings - Fork 6
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
Use nopass to simplify the interface for the user-defined function #1
Comments
The reason for it is so in the object-oriented interface you can put data required by the function in the class. Look at the oo example in the repo. type,extends(muller_solver_real64) :: my_solver
integer :: ifunc = 0
integer :: n = 1
end type my_solver
type(my_solver) :: solver
In my mind, the oo interface is how it should be used, and the functional one is just a wrapper for simple use cases. |
Doesn't this imply that you need a different version of the function for
each solver?
Op do 19 aug. 2021 om 17:38 schreef Jacob Williams ***@***.***
…:
The reason for it is so in the object-oriented interface you can put data
required by the function in the class. Look at the oo example in the repo.
type,extends(muller_solver_real64) :: my_solver
integer :: ifunc = 0
integer :: n = 1
end type my_solver
type(my_solver) :: solver
ifunc and n are used in the function.
In my mind, the oo interface is how it should be used, and the function
one is just a wrapper for simple use cases.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAN6YR3I6N52W75YLQO5DXDT5UQPJANCNFSM5CIE2INA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email>
.
|
No, since the function interface uses function func(me,x)
class(root_solver),intent(inout) :: me
real(wp),intent(in) :: x
real(wp) :: f
select type (me)
class is (my_solver)
f = me%n * sin(x)
me%ifunc = me%ifunc + 1
end select
end function func So the same function works for any method. But, you do have to use the annoying |
The abstract interface func has two arguments, "me" of type "class(root_solver)" and the proper argument of the function. The first serves no purpose for the evaluation of the function and can actually be suppressed:
This way the interface becomes the same as func2 and unifies the usage.
The text was updated successfully, but these errors were encountered: