aboutsummaryrefslogtreecommitdiff
path: root/src/clp.f90
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2020-10-26 15:35:12 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2020-10-26 15:35:12 -0400
commit55861d4285709bc2df22799006fe8835e25721df (patch)
tree2e38d2d99516f573b2d3ef971e79c7bdd23d73de /src/clp.f90
parent8e4d4ae7b4f1d0b350e5c2942eb190bb555460a9 (diff)
downloadclp_fortran-55861d4285709bc2df22799006fe8835e25721df.tar.gz
clp_fortran-55861d4285709bc2df22799006fe8835e25721df.zip
Implemented Clp_copyNames in Fortran since it was dealing with two arrays of strings.
Diffstat (limited to 'src/clp.f90')
-rw-r--r--src/clp.f9066
1 files changed, 61 insertions, 5 deletions
diff --git a/src/clp.f90 b/src/clp.f90
index 2fe45a9..4efaa29 100644
--- a/src/clp.f90
+++ b/src/clp.f90
@@ -168,13 +168,13 @@ module clp
use iso_c_binding
type(c_ptr), value :: model
end subroutine
-
- subroutine Clp_copyNames(model,rowNames,columnNames) bind(C,name="Clp_copyNames")
+
+ subroutine Clp_copyNames_C(model,rowNames,columnNames) bind(C,name="Clp_copyNames")
use iso_c_binding
type(c_ptr), value :: model
- character(c_char) :: rowNames(*)
- character(c_char) :: columnNames(*)
- end subroutine
+ type(c_ptr), value :: rowNames
+ type(c_ptr), value :: columnNames
+ end subroutine
function Clp_numberRows(model) bind(C,name="Clp_numberRows")
use iso_c_binding
@@ -256,76 +256,91 @@ module clp
type(c_ptr), value :: model
integer(c_int) :: Clp_numberIterations
end function
+
subroutine Clp_setNumberIterations(model,numberIterations) bind(C,name="Clp_setNumberIterations")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int), value ::numberIterations
end subroutine
+
function maximumIterations(model) bind(C,name="maximumIterations")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int) :: maximumIterations
end function
+
subroutine Clp_setMaximumIterations(model,value) bind(C,name="Clp_setMaximumIterations")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int), value ::value
end subroutine
+
function Clp_maximumSeconds(model) bind(C,name="Clp_maximumSeconds")
use iso_c_binding
type(c_ptr), value :: model
real(c_double) :: Clp_maximumSeconds
end function
+
subroutine Clp_setMaximumSeconds(model,value) bind(C,name="Clp_setMaximumSeconds")
use iso_c_binding
type(c_ptr), value :: model
real(c_double), value :: value
end subroutine
+
function Clp_hitMaximumIterations(model) bind(C,name="Clp_hitMaximumIterations")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int) :: Clp_hitMaximumIterations
end function
+
function Clp_status(model) bind(C,name="Clp_status")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int) :: Clp_status
end function
+
subroutine Clp_setProblemStatus(model,problemStatus) bind(C,name="Clp_setProblemStatus")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int), value ::problemStatus
end subroutine
+
function Clp_secondaryStatus(model) bind(C,name="Clp_secondaryStatus")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int) :: Clp_secondaryStatus
end function
+
subroutine Clp_setSecondaryStatus(model,status) bind(C,name="Clp_setSecondaryStatus")
use iso_c_binding
type(c_ptr), value :: model
integer(c_int), value ::status
end subroutine
+
function Clp_optimizationDirection(model) bind(C,name="Clp_optimizationDirection")
use iso_c_binding
type(c_ptr), value :: model
real(c_double) :: Clp_optimizationDirection
end function
+
subroutine Clp_setOptimizationDirection(model,value) bind(C,name="Clp_setOptimizationDirection")
use iso_c_binding
type(c_ptr), value :: model
real(c_double), value :: value
end subroutine
+
function Clp_primalRowSolution(model) bind(C,name="Clp_primalRowSolution")
use iso_c_binding
type(c_ptr), value :: model
type(c_ptr) :: Clp_primalRowSolution
end function
+
function Clp_primalColumnSolution(model) bind(C,name="Clp_primalColumnSolution")
use iso_c_binding
type(c_ptr), value :: model
type(c_ptr) :: Clp_primalColumnSolution
end function
+
function Clp_dualRowSolution(model) bind(C,name="Clp_dualRowSolution")
use iso_c_binding
type(c_ptr), value :: model
@@ -1044,4 +1059,45 @@ contains
end subroutine Clp_problemName
+ subroutine Clp_copyNames(model,rowNames,columnNames)
+ use iso_c_binding
+ use clp_interface_utils
+ implicit none
+
+ type(c_ptr) :: model
+
+ character(len=*), dimension(:), intent(in) :: rowNames
+ character(len=*), dimension(:), intent(in) :: columnNames
+
+ type(c_ptr), dimension(:), pointer :: rn_c
+ type(c_ptr), dimension(:), pointer :: cn_c
+
+ integer::i
+
+ allocate(rn_c(size(rowNames)))
+ allocate(cn_c(size(columnNames)))
+
+ do i = 1, size(rowNames)
+ rn_c(i) = allocate_and_populate_c_string(rowNames(i))
+ end do
+
+ do i = 1, size(columnNames)
+ rn_c(i) = allocate_and_populate_c_string(columnNames(i))
+ end do
+
+ call Clp_copyNames_C(model, c_loc(rn_c), c_loc(cn_c))
+
+ do i = 1, size(rowNames)
+ call c_free(rn_c(i))
+ end do
+
+ do i = 1, size(columnNames)
+ call c_free(cn_c(i))
+ end do
+
+ deallocate(rn_c)
+ deallocate(cn_c)
+
+ end subroutine Clp_copyNames
+
end module clp