Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test utest.c for the C interface #67

Merged
merged 6 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions include/cutest.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ typedef int ipc_;
#endif

typedef struct VarTypes {
int nbnds, neq, nlin, nrange, nlower, nupper,
nineq, nineq_lin, nineq_nlin, neq_lin,
neq_nlin;
int nbnds, neq, nlin, nrange, nlower, nupper,
nineq, nineq_lin, nineq_nlin, neq_lin,
neq_nlin;
} VarTypes;

/*
Expand Down Expand Up @@ -310,9 +310,9 @@ void CUTEST_usetup ( integer *status, const integer *funit,
void CUTEST_csetup ( integer *status, const integer *funit,
const integer *iout,
const integer *io_buffer, integer *n, integer *m,
doublereal *x, doublereal *bl, doublereal *bu,
doublereal *x, doublereal *bl, doublereal *bu,
doublereal *v, doublereal *cl, doublereal *cu,
logical *equatn, logical *linear, const integer *e_order,
logical *equatn, logical *linear, const integer *e_order,
const integer *l_order, const integer *v_order );

/* Unconstrained dimensioning and report routines */
Expand Down Expand Up @@ -500,7 +500,7 @@ void CUTEST_csgreh ( integer *status, const integer *n, const integer *m,
const logical *grlagf, integer *nnzj,
const integer *lcjac, doublereal *cjac,
integer *indvar, integer *indfun,
integer *ne, const integer *le, integer *iprnhi,
integer *ne, const integer *le, integer *iprnhi,
integer *iprhi, const integer *lirnhi,
integer *irnhi, const integer *lhi, doublereal *hi,
const logical *byrows );
Expand Down Expand Up @@ -565,9 +565,9 @@ void CUTEST_usetup_s ( integer *status, const integer *funit,
void CUTEST_csetup_s ( integer *status, const integer *funit,
const integer *iout,
const integer *io_buffer, integer *n, integer *m,
real *x, real *bl, real *bu,
real *x, real *bl, real *bu,
real *v, real *cl, real *cu,
logical *equatn, logical *linear, const integer *e_order,
logical *equatn, logical *linear, const integer *e_order,
const integer *l_order, const integer *v_order );

/* Unconstrained dimensioning and report routines */
Expand Down Expand Up @@ -701,7 +701,7 @@ void CUTEST_cdh_s ( integer *status, const integer *n, const integer *m,
void CUTEST_cdhc_s ( integer *status, const integer *n, const integer *m,
const real *x, const real *y,
const integer *lh1, real *h );
void CUTEST_cdhj_s ( integer *status, const integer *n, const integer *m,
void CUTEST_cdhj_s ( integer *status, const integer *n, const integer *m,
const real *x, const real *y0, const real *y,
const integer *lh1, real *h );
void CUTEST_cshp_s ( integer *status, const integer *n, integer *nnzh,
Expand Down Expand Up @@ -754,7 +754,7 @@ void CUTEST_csgreh_s ( integer *status, const integer *n, const integer *m,
const logical *grlagf, integer *nnzj,
const integer *lcjac, real *cjac,
integer *indvar, integer *indfun,
integer *ne, const integer *le, integer *iprnhi,
integer *ne, const integer *le, integer *iprnhi,
integer *iprhi, const integer *lirnhi,
integer *irnhi, const integer *lhi, real *hi,
const logical *byrows );
Expand Down Expand Up @@ -914,9 +914,9 @@ void CUTEST_usetup_q ( integer *status, const integer *funit,
void CUTEST_csetup_q ( integer *status, const integer *funit,
const integer *iout,
const integer *io_buffer, integer *n, integer *m,
quadreal *x, quadreal *bl, quadreal *bu,
quadreal *x, quadreal *bl, quadreal *bu,
quadreal *v, quadreal *cl, quadreal *cu,
logical *equatn, logical *linear, const integer *e_order,
logical *equatn, logical *linear, const integer *e_order,
const integer *l_order, const integer *v_order );

/* Unconstrained dimensioning and report routines */
Expand Down Expand Up @@ -1103,7 +1103,7 @@ void CUTEST_csgreh_q ( integer *status, const integer *n, const integer *m,
const logical *grlagf, integer *nnzj,
const integer *lcjac, quadreal *cjac,
integer *indvar, integer *indfun,
integer *ne, const integer *le, integer *iprnhi,
integer *ne, const integer *le, integer *iprnhi,
integer *iprhi, const integer *lirnhi,
integer *irnhi, const integer *lhi, quadreal *hi,
const logical *byrows );
Expand Down
39 changes: 39 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,42 @@ if build_tests
is_parallel : false)
endforeach
endif

# C tests
if build_tests

fortran_tests_folder = 'tests/C'

foreach test: cutest_c_tests
package = test[0]
precision = test[1]
name = test[2]
file = test[3]

if precision == 'single'
libgalahad_precision = libcutest_single
args_precision = pp_flag + '-DREAL_32'
endif
if precision == 'double'
libgalahad_precision = libcutest_double
args_precision = pp_flag
endif
if precision == 'quadruple'
libgalahad_precision = libcutest_quadruple
args_precision = pp_flag + '-DREAL_128' + '-DCUTEST_16btye_reals_exist'
endif

test(name,
executable(name, file,
fortran_args : args_precision,
c_args : args_precision,
link_with : libgalahad_precision,
link_language : 'fortran',
include_directories: libcutest_include,
install : true,
install_dir : fortran_tests_folder),
suite : [package, precision, 'C'],
workdir : join_paths(meson.project_source_root(), 'src', 'test'),
is_parallel : false)
endforeach
endif
5 changes: 5 additions & 0 deletions src/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@ cutest_tests += [['cutest', 'single', 'ctest_single' , files('ctest.F90'
['cutest', 'double', 'utest_threaded_double', files('utest_threaded.F90', 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')],
['cutest', 'double', 'lqp_test_double' , files('lqptest.F90' , 'q_elfun_double.f', 'q_group_double.f', 'q_range_double.f')]]

# cutest_c_tests += [['cutest', 'single', 'utest_c_single', files('utest.c', 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')],
# ['cutest', 'double', 'utest_c_double', files('utest.c', 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')]]

if build_quadruple
cutest_tests += [['cutest', 'quadruple', 'ctest_quadruple' , files('ctest.F90' , 'c_elfun_quadruple.f', 'c_group_quadruple.f', 'c_range_quadruple.f')],
['cutest', 'quadruple', 'ctest_threaded_quadruple', files('ctest_threaded.F90', 'c_elfun_quadruple.f', 'c_group_quadruple.f', 'c_range_quadruple.f')],
['cutest', 'quadruple', 'utest_quadruple' , files('utest.F90' , 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')],
['cutest', 'quadruple', 'utest_threaded_quadruple', files('utest_threaded.F90', 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')],
['cutest', 'quadruple', 'lqp_test_quadruple' , files('lqptest.F90' , 'q_elfun_quadruple.f', 'q_group_quadruple.f', 'q_range_quadruple.f')]]

# cutest_c_tests += [['cutest', 'quadruple', 'utest_c_quadruple', files('utest.c', 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')]]
endif
10 changes: 1 addition & 9 deletions src/test/utest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -286,18 +286,10 @@ PROGRAM CUTEST_test_unconstrained_tools
ALLOCATE( H_band( 0 : lbandh, n ), stat = alloc_stat )
IF ( alloc_stat /= 0 ) GO TO 990

goth = .FALSE.
WRITE( out, "( ' Call CUTEST_ubandh with goth = .FALSE.' )" )
CALL CUTEST_ubandh_r( status, n, X, nsemib, H_band, lbandh, maxsbw )
IF ( status /= 0 ) GO to 900
CALL WRITE_H_BAND( out, n, lbandh, H_band, nsemib )
! CALL WRITE_H_BAND( out, n, lbandh, H_band, nsemib, maxsbw )
goth = .TRUE.
WRITE( out, "( ' Call CUTEST_ubandh with goth = .TRUE.' )" )
WRITE( out, "( ' Call CUTEST_ubandh' )" )
CALL CUTEST_ubandh_r( status, n, X, nsemib, H_band, lbandh, maxsbw )
IF ( status /= 0 ) GO to 900
CALL WRITE_H_BAND( out, n, lbandh, H_band, nsemib )
! CALL WRITE_H_BAND( out, n, lbandh, H_band, nsemib, maxsbw )

! calls and time report

Expand Down
Loading
Loading