From 1d8895ce23425c14f53776e3143b1cda67dcbb9d Mon Sep 17 00:00:00 2001 From: Manuel Schaich Date: Mon, 28 Oct 2024 19:06:04 +0000 Subject: [PATCH] CMake FortranCInterface --- uno/solvers/BQPD/BQPDSolver.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/uno/solvers/BQPD/BQPDSolver.cpp b/uno/solvers/BQPD/BQPDSolver.cpp index 3382b61c..afac9949 100644 --- a/uno/solvers/BQPD/BQPDSolver.cpp +++ b/uno/solvers/BQPD/BQPDSolver.cpp @@ -13,6 +13,11 @@ #include "tools/Logger.hpp" #include "options/Options.hpp" +#define FC_GLOBAL(name,NAME) NAME +#define WSC FC_GLOBAL(wsc,WSC) +#define KKTALPHAC FC_GLOBAL(kktalphac,KKTALPHAC) +#define BQPD FC_GLOBAL(bqpd,BQPD) + namespace uno { #define BIG 1e30 @@ -20,15 +25,15 @@ namespace uno { // fortran common block used in bqpd/bqpd.f extern struct { int kk, ll, kkk, lll, mxws, mxlws; - } wsc_; + } WSC; // fortran common for inertia correction in wdotd extern struct { double alpha; - } kktalphac_; + } KKTALPHAC; extern void - bqpd_(const int* n, const int* m, int* k, int* kmax, double* a, int* la, double* x, double* bl, double* bu, double* f, double* fmin, double* g, + BQPD(const int* n, const int* m, int* k, int* kmax, double* a, int* la, double* x, double* bl, double* bu, double* f, double* fmin, double* g, double* r, double* w, double* e, int* ls, double* alp, int* lp, int* mlp, int* peq, double* ws, int* lws, const int* mode, int* ifail, int* info, int* iprint, int* nout); } @@ -95,11 +100,11 @@ namespace uno { const WarmstartInformation& warmstart_information) { // initialize wsc_ common block (Hessian & workspace for BQPD) // setting the common block here ensures that several instances of BQPD can run simultaneously - wsc_.kk = static_cast(this->number_hessian_nonzeros); - wsc_.ll = static_cast(this->size_hessian_sparsity); - wsc_.mxws = static_cast(this->size_hessian_workspace); - wsc_.mxlws = static_cast(this->size_hessian_sparsity_workspace); - kktalphac_.alpha = 0; // inertia control + WSC.kk = static_cast(this->number_hessian_nonzeros); + WSC.ll = static_cast(this->size_hessian_sparsity); + WSC.mxws = static_cast(this->size_hessian_workspace); + WSC.mxlws = static_cast(this->size_hessian_sparsity_workspace); + KKTALPHAC.alpha = 0; // inertia control if (this->print_subproblem) { DEBUG << "objective gradient: " << linear_objective; @@ -142,7 +147,7 @@ namespace uno { const int mode_integer = static_cast(mode); // solve the LP/QP - bqpd_(&n, &m, &this->k, &this->kmax, this->jacobian.data(), this->jacobian_sparsity.data(), direction.primals.data(), this->lb.data(), + BQPD(&n, &m, &this->k, &this->kmax, this->jacobian.data(), this->jacobian_sparsity.data(), direction.primals.data(), this->lb.data(), this->ub.data(), &direction.subproblem_objective, &this->fmin, this->gradient_solution.data(), this->residuals.data(), this->w.data(), this->e.data(), this->active_set.data(), this->alp.data(), this->lp.data(), &this->mlp, &this->peq_solution, this->hessian_values.data(), this->hessian_sparsity.data(), &mode_integer, &this->ifail, this->info.data(), &this->iprint, &this->nout);