From 55861d4285709bc2df22799006fe8835e25721df Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Mon, 26 Oct 2020 15:35:12 -0400 Subject: Implemented Clp_copyNames in Fortran since it was dealing with two arrays of strings. --- src/clp.f90 | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 61 insertions(+), 5 deletions(-) (limited to 'src') 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 -- cgit v1.2.3