Skip to content

Commit

Permalink
Export Fortran symbols (#250)
Browse files Browse the repository at this point in the history
Fixes #249
  • Loading branch information
jschueller authored and stevengj committed Mar 15, 2019
1 parent 18cadf7 commit 2f1c1ae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
14 changes: 4 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ matrix:
- guile-2.0-dev
- liboctave-dev
- cmake
- g++-mingw-w64-i686
- gcc-mingw-w64-i686
- binutils-mingw-w64-i686
- g++-mingw-w64-x86-64
- gcc-mingw-w64-x86-64
- binutils-mingw-w64-x86-64
- gfortran
- binutils-mingw-w64-x86-64
- g++-mingw-w64-x86-64
- gfortran-mingw-w64-x86-64

script:
- pip install mkdocs python-markdown-math --user
Expand All @@ -28,10 +25,7 @@ matrix:
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON ..
- make install -j2 && ctest -j2 --output-on-failure
- rm -rf * ~/.local
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-i686-w64-mingw32.cmake ..
- make install -j2
- rm -rf * ~/.local
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
- cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DNLOPT_FORTRAN=ON -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
- make install -j2

- os: osx
Expand Down
8 changes: 4 additions & 4 deletions src/api/f77api.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ static void f77_mfunc_wrap(unsigned m, double *result, unsigned n, const double

/*-----------------------------------------------------------------------*/

#define F77_GET(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(T *val, nlopt_opt *opt) { *val = (T) nlopt_get_##name(*opt); }
#define F77_SET(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, *val); }
#define F77_GET(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_get_##name,NLO_GET_##NAME)(T *val, nlopt_opt *opt) { *val = (T) nlopt_get_##name(*opt); }
#define F77_SET(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, *val); }
#define F77_GETSET(name,NAME,T) F77_GET(name,NAME,T) F77_SET(name,NAME,T)

#define F77_GETA(name,NAME,T) void F77_(nlo_get_##name,NLO_GET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_get_##name(*opt, val); }
#define F77_SETA(name,NAME,T) void F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, val); }
#define F77_GETA(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_get_##name,NLO_GET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_get_##name(*opt, val); }
#define F77_SETA(name,NAME,T) NLOPT_EXTERN(void) F77_(nlo_set_##name,NLO_SET_##NAME)(int *ret, nlopt_opt *opt, T *val) { *ret = (int) nlopt_set_##name(*opt, val); }
#define F77_GETSETA(name,NAME,T) F77_GETA(name,NAME,T) F77_SETA(name,NAME,T) F77_SET(name##1,NAME##1,T)

/*-----------------------------------------------------------------------*/
Expand Down
28 changes: 14 additions & 14 deletions src/api/f77funcs_.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
The return value of a function is converted to the first argument
of a subroutine. */

void F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) {
NLOPT_EXTERN(void) F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) {
if (*n < 0)
*opt = NULL;
else {
Expand All @@ -40,19 +40,19 @@ void F77_(nlo_create, NLO_CREATE) (nlopt_opt * opt, int *alg, int *n) {
}
}

void F77_(nlo_copy, NLO_COPY) (nlopt_opt * nopt, nlopt_opt * opt) {
NLOPT_EXTERN(void) F77_(nlo_copy, NLO_COPY) (nlopt_opt * nopt, nlopt_opt * opt) {
*nopt = nlopt_copy(*opt);
}

void F77_(nlo_destroy, NLO_DESTROY) (nlopt_opt * opt) {
NLOPT_EXTERN(void) F77_(nlo_destroy, NLO_DESTROY) (nlopt_opt * opt) {
nlopt_destroy(*opt);
}

void F77_(nlo_optimize, NLO_OPTIMIZE) (int *ret, nlopt_opt * opt, double *x, double *optf) {
NLOPT_EXTERN(void) F77_(nlo_optimize, NLO_OPTIMIZE) (int *ret, nlopt_opt * opt, double *x, double *optf) {
*ret = (int) nlopt_optimize(*opt, x, optf);
}

void F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) {
NLOPT_EXTERN(void) F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) {
f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data));
if (!d) {
*ret = (int) NLOPT_OUT_OF_MEMORY;
Expand All @@ -63,7 +63,7 @@ void F77_(nlo_set_min_objective, NLO_SET_MIN_OBJECTIVE) (int *ret, nlopt_opt * o
*ret = (int) nlopt_set_min_objective(*opt, f77_func_wrap, d);
}

void F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) {
NLOPT_EXTERN(void) F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * opt, nlopt_f77_func f, void *f_data) {
f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data));
if (!d) {
*ret = (int) NLOPT_OUT_OF_MEMORY;
Expand All @@ -77,12 +77,12 @@ void F77_(nlo_set_max_objective, NLO_SET_MAX_OBJECTIVE) (int *ret, nlopt_opt * o
F77_GET(algorithm, ALGORITHM, int) F77_GET(dimension, DIMENSION, int)
F77_GETSETA(lower_bounds, LOWER_BOUNDS, double) F77_GETSETA(upper_bounds, UPPER_BOUNDS, double)

void F77_(nlo_remove_inequality_constraints, NLO_REMOVE_INEQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt)
NLOPT_EXTERN(void) F77_(nlo_remove_inequality_constraints, NLO_REMOVE_INEQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt)
{
*ret = (int) nlopt_remove_inequality_constraints(*opt);
}

void F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) {
NLOPT_EXTERN(void) F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) {
f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data));
if (!d) {
*ret = (int) NLOPT_OUT_OF_MEMORY;
Expand All @@ -93,7 +93,7 @@ void F77_(nlo_add_inequality_constraint, NLO_ADD_INEQUALITY_CONSTRAINT) (int *re
*ret = (int) nlopt_add_inequality_constraint(*opt, f77_func_wrap, d, *tol);
}

void F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) {
NLOPT_EXTERN(void) F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) {
f77_func_data *d;
if (*m < 0) {
*ret = (int) NLOPT_INVALID_ARGS;
Expand All @@ -113,11 +113,11 @@ void F77_(nlo_add_inequality_mconstraint, NLO_ADD_INEQUALITY_MCONSTRAINT) (int *
*ret = (int) nlopt_add_inequality_mconstraint(*opt, (unsigned) *m, f77_mfunc_wrap, d, tol);
}

void F77_(nlo_remove_equality_constraints, NLO_REMOVE_EQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) {
NLOPT_EXTERN(void) F77_(nlo_remove_equality_constraints, NLO_REMOVE_EQUALITY_CONSTRAINTS) (int *ret, nlopt_opt * opt) {
*ret = (int) nlopt_remove_equality_constraints(*opt);
}

void F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) {
NLOPT_EXTERN(void) F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, nlopt_opt * opt, nlopt_f77_func fc, void *fc_data, double *tol) {
f77_func_data *d = (f77_func_data *) malloc(sizeof(f77_func_data));
if (!d) {
*ret = (int) NLOPT_OUT_OF_MEMORY;
Expand All @@ -128,7 +128,7 @@ void F77_(nlo_add_equality_constraint, NLO_ADD_EQUALITY_CONSTRAINT) (int *ret, n
*ret = (int) nlopt_add_equality_constraint(*opt, f77_func_wrap, d, *tol);
}

void F77_(nlo_add_equality_mconstraint, NLO_ADD_EQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) {
NLOPT_EXTERN(void) F77_(nlo_add_equality_mconstraint, NLO_ADD_EQUALITY_MCONSTRAINT) (int *ret, nlopt_opt * opt, int *m, nlopt_f77_mfunc mfc, void *mfc_data, double *tol) {
f77_func_data *d;
if (*m < 0) {
*ret = (int) NLOPT_INVALID_ARGS;
Expand All @@ -153,15 +153,15 @@ F77_GETSET(ftol_rel, FTOL_REL, double)
F77_GETSET(ftol_abs, FTOL_ABS, double)
F77_GETSET(xtol_rel, XTOL_REL, double) F77_GETSETA(xtol_abs, XTOL_ABS, double) F77_GETSET(maxeval, MAXEVAL, int) F77_GET(numevals, NUMEVALS, int) F77_GETSET(maxtime, MAXTIME, double)
F77_GETSET(force_stop, FORCE_STOP, int)
void F77_(nlo_force_stop, NLO_FORCE_STOP) (int *ret, nlopt_opt * opt)
NLOPT_EXTERN(void) F77_(nlo_force_stop, NLO_FORCE_STOP) (int *ret, nlopt_opt * opt)
{
*ret = (int) nlopt_force_stop(*opt);
}

F77_SET(local_optimizer, LOCAL_OPTIMIZER, nlopt_opt)
F77_GETSET(population, POPULATION, unsigned) F77_GETSET(vector_storage, vector_storage, unsigned)
F77_SETA(default_initial_step, DEFAULT_INITIAL_STEP, double) F77_SETA(initial_step, INITIAL_STEP, double) F77_SET(initial_step1, INITIAL_STEP1, double)
void F77_(nlo_get_initial_step, NLO_GET_INITIAL_STEP) (int *ret, nlopt_opt * opt, const double *x, double *dx)
NLOPT_EXTERN(void) F77_(nlo_get_initial_step, NLO_GET_INITIAL_STEP) (int *ret, nlopt_opt * opt, const double *x, double *dx)
{
*ret = (int) nlopt_get_initial_step(*opt, x, dx);
}

0 comments on commit 2f1c1ae

Please sign in to comment.