aboutsummaryrefslogtreecommitdiff
path: root/src/clp.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-10-29 12:36:45 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-10-29 12:36:45 -0400
commit9fac184765c3756de6b22cf110a6fc3f626d2fe1 (patch)
treeac1cfe33b873ece1a24a1d9453952d0fede87b03 /src/clp.f90
parent0f982e7efcf0a1eb1e3b8054206ad940cd3e2ea4 (diff)
downloadclp_fortran-9fac184765c3756de6b22cf110a6fc3f626d2fe1.tar.gz
clp_fortran-9fac184765c3756de6b22cf110a6fc3f626d2fe1.zip
Added handling of callbacks in a Fortran-esque manner
Diffstat (limited to 'src/clp.f90')
-rw-r--r--src/clp.f9025
1 files changed, 23 insertions, 2 deletions
diff --git a/src/clp.f90 b/src/clp.f90
index 2c8692a..cd34b95 100644
--- a/src/clp.f90
+++ b/src/clp.f90
@@ -1,5 +1,7 @@
module clp
use iso_c_binding
+ use clp_callback, only: fortran_cb
+ use clp_constants
implicit none
interface
@@ -498,10 +500,10 @@ module clp
use iso_c_binding
type(c_ptr) :: model
end subroutine
- subroutine Clp_registerCallBack(model,userCallBack) bind(C,name="Clp_registerCallBack")
+ subroutine Clp_registerCallBack_C(model,userCallBack) bind(C,name="Clp_registerCallBack")
use iso_c_binding
type(c_ptr), value :: model
- type(c_ptr), value :: userCallBack
+ type(c_funptr), value :: userCallBack
end subroutine
subroutine Clp_clearCallBack(model) bind(C,name="Clp_clearCallBack")
use iso_c_binding
@@ -1700,4 +1702,23 @@ contains
end subroutine Clp_integerInformation
+ subroutine Clp_registerCallback(model, cb)
+ use iso_c_binding
+ use clp_callback
+ implicit none
+
+ type(c_ptr) :: model
+ procedure(fortran_cb) :: cb
+
+ if(associated(current_callback)) then
+ Write(*,*) "*** WARNING: Clp Fortran Library supports only a single callback"
+ Write(*,*) "*** Reassigning current callback"
+ end if
+
+ current_callback => cb
+
+ call Clp_Registercallback_C(model, c_funloc(Clp_boundCallbackInterface))
+
+ end subroutine Clp_registerCallback
+
end module clp