Skip to content

Commit

Permalink
Add a test utest.c for the C interface
Browse files Browse the repository at this point in the history
  • Loading branch information
amontoison committed Sep 10, 2024
1 parent bd1b94e commit 5c4564c
Show file tree
Hide file tree
Showing 4 changed files with 578 additions and 9 deletions.
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 @@ -275,18 +275,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

0 comments on commit 5c4564c

Please sign in to comment.