Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ralna/CUTEst
Browse files Browse the repository at this point in the history
  • Loading branch information
dalekopera committed Sep 9, 2024
2 parents a0ffe6d + 66eef8a commit bd1b94e
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 9 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/meson.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,16 @@ jobs:
shell: bash
run: |
INT64="false"
TESTS="true"
if [[ "${{matrix.int}}" == "64" ]]; then
INT64="true"
TESTS="false"
fi
if [[ "${{matrix.mode}}" == "static" ]]; then
MODE="static"
else
MODE="shared"
TESTS="false"
fi
QUADRUPLE="true"
if [[ "${{ matrix.compiler }}" == "intel-classic" || "${{ matrix.compiler }}" == "intel" ]]; then
Expand All @@ -146,7 +149,8 @@ jobs:
--prefix=$GITHUB_WORKSPACE/cutest \
-Ddefault_library=${MODE} \
-Dquadruple=${QUADRUPLE} \
-Dint64=${INT64}
-Dint64=${INT64} \
-Dtests=${TESTS}
- name: Build CUTEST
shell: bash
Expand Down
43 changes: 42 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fc_compiler = find_program(fc.cmd_array())
install_modules = get_option('modules')
build_quadruple = get_option('quadruple')
int64 = get_option('int64')
build_tests = get_option('tests')

libcutest_src = []
libcutest_f_src = []
Expand Down Expand Up @@ -88,7 +89,7 @@ subdir('src/stats')
# subdir('src/stenmin') # needs stumcd_
# subdir('src/tao') # needs petsc/finclude/petsctao.h and Fortran module petsctao
# subdir('src/tenmin') # needs tensor_
# subdir('src/test')
subdir('src/test')
subdir('src/tools')
# subdir('src/tron') # needs dnrm2_, dgpnrm2_
# subdir('src/uncmin') # needs optif9_
Expand Down Expand Up @@ -121,9 +122,11 @@ elif fc.get_id() == 'nvidia_hpc'
pp_options += ['-Mcpp', '-F']
endif
if int64
pp_flag += '-DINTEGER_64'
pp_options += '-DINTEGER_64'
endif
if host_machine.system() == 'windows'
pp_flag += '-DWINDOWS'
pp_options += '-DWINDOWS'
endif

Expand Down Expand Up @@ -210,3 +213,41 @@ if install_modules
script_modules = files('install_modules.py')
meson.add_install_script(script_modules)
endif

# Fortran tests
if build_tests

fortran_tests_folder = 'tests/Fortran'

foreach test: cutest_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,
link_with : libgalahad_precision,
link_language : 'fortran',
include_directories: libcutest_include,
install : true,
install_dir : fortran_tests_folder),
suite : [package, precision, 'fortran'],
workdir : join_paths(meson.project_source_root(), 'src', 'test'),
is_parallel : false)
endforeach
endif
5 changes: 5 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ option('int64',
type : 'boolean',
value : false,
description : 'option to compile CUTEst with 64-bit integer')

option('tests',
type : 'boolean',
value : false,
description : 'whether to generate the tests')
4 changes: 2 additions & 2 deletions src/test/ctest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ PROGRAM CUTEST_test_constrained_tools

WRITE( out, "( ' CALL CUTEST_csetup ' )" )
CALL CUTEST_csetup_r( status, input, out, buffer, n, m, X, X_l, X_u, &
Y, C_l, C_u, EQUATION, LINEAR, 1, 1, 1 )
Y, C_l, C_u, EQUATION, LINEAR, 1_ip_, 1_ip_, 1_ip_ )
IF ( status /= 0 ) GO TO 900
CALL WRITE_X( out, n, X, X_l, X_u )
CALL WRITE_Y( out, m, Y, C_l, C_u, EQUATION, LINEAR )
Expand Down Expand Up @@ -876,7 +876,7 @@ PROGRAM CUTEST_test_constrained_tools

WRITE( out, "( ' CALL CUTEST_csetup ' )" )
CALL CUTEST_csetup_r( status, input, out, buffer, n, m, X, X_l, X_u, &
Y, C_l, C_u, EQUATION, LINEAR, 1, 1, 1 )
Y, C_l, C_u, EQUATION, LINEAR, 1_ip_, 1_ip_, 1_ip_ )
IF ( status /= 0 ) GO TO 900

! ... and terminal exit
Expand Down
2 changes: 1 addition & 1 deletion src/test/ctest2.F90
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ PROGRAM CUTEST_test_constrained_tools

WRITE( out, "( ' CALL CUTEST_csetup ' )" )
CALL CUTEST_csetup_r( status, input, out, buffer, n, m, X, X_l, X_u, &
Y, C_l, C_u, EQUATION, LINEAR, 1, 1, 1 )
Y, C_l, C_u, EQUATION, LINEAR, 1_ip_, 1_ip_, 1_ip_ )
IF ( status /= 0 ) GO TO 900
CALL WRITE_X( out, n, X, X_l, X_u )
CALL WRITE_Y( out, m, Y, C_l, C_u, EQUATION, LINEAR )
Expand Down
4 changes: 2 additions & 2 deletions src/test/ctest_threaded.F90
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ PROGRAM CUTEST_test_constrained_tools
WRITE( out, "( ' CALL CUTEST_csetup ' )" )
CALL CUTEST_csetup_threaded_r( status, input, out, threads, BUFFER, &
n, m, X, X_l, X_u, &
Y, C_l, C_u, EQUATION, LINEAR, 1, 1, 1 )
Y, C_l, C_u, EQUATION, LINEAR, 1_ip_, 1_ip_, 1_ip_ )
IF ( status /= 0 ) GO to 900
CALL WRITE_X( out, n, X, X_l, X_u )
CALL WRITE_Y( out, m, Y, C_l, C_u, EQUATION, LINEAR )
Expand Down Expand Up @@ -827,7 +827,7 @@ PROGRAM CUTEST_test_constrained_tools
! calls and time report

! WRITE( out, "( ' CALL CUTEST_creport for thread 1' )" )
! CALL CUTEST_creport_threaded_r( status, CALLS, CPU, 1 )
! CALL CUTEST_creport_threaded_r( status, CALLS, CPU, 1_ip_ )
! WRITE( out, "( ' CALLS(1-7) =', 7( 1X, I0 ) )" ) INT( CALLS( 1 : 7 ) )
! WRITE( out, "( ' CPU(1-4) =', 4F7.2 )" ) CPU( 1 : 4 )

Expand Down
18 changes: 18 additions & 0 deletions src/test/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cutest_tests += [['cutest', 'single', 'ctest_single' , files('ctest.F90' , 'c_elfun_single.f', 'c_group_single.f', 'c_range_single.f')],
['cutest', 'single', 'ctest_threaded_single', files('ctest_threaded.F90', 'c_elfun_single.f', 'c_group_single.f', 'c_range_single.f')],
['cutest', 'single', 'utest_single' , files('utest.F90' , 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')],
['cutest', 'single', 'utest_threaded_single', files('utest_threaded.F90', 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')],
['cutest', 'single', 'lqp_test_single' , files('lqptest.F90' , 'q_elfun_single.f', 'q_group_single.f', 'q_range_single.f')],
['cutest', 'double', 'ctest_double' , files('ctest.F90' , 'c_elfun_double.f', 'c_group_double.f', 'c_range_double.f')],
['cutest', 'double', 'ctest_threaded_double', files('ctest_threaded.F90', 'c_elfun_double.f', 'c_group_double.f', 'c_range_double.f')],
['cutest', 'double', 'utest_double' , files('utest.F90' , 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')],
['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')]]

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')]]
endif
3 changes: 2 additions & 1 deletion src/test/utest.F90
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ PROGRAM CUTEST_test_unconstrained_tools
INTEGER ( KIND = ip_ ) :: i, n, HE_nel, HE_val_ne, HE_row_ne, status
INTEGER ( KIND = ip_ ) :: l_h2_1, l_h, lhe_ptr, H_ne, lhe_val, lhe_row
INTEGER ( KIND = ip_ ) :: nnz_vector, nnz_result, maxsbw, alloc_stat
INTEGER ( KIND = ip_ ) :: nsemib, lbandh
REAL ( KIND = rp_ ) :: f
LOGICAL :: grad, byrows, goth
CHARACTER ( len = 10 ) :: p_name
Expand Down Expand Up @@ -512,7 +513,7 @@ END SUBROUTINE WRITE_SRESULT

! SUBROUTINE WRITE_H_BAND( out, n, lbandh, H_band, nsemib, maxsbw )
SUBROUTINE WRITE_H_BAND( out, n, lbandh, H_band, nsemib )
INTEGER ( KIND = ip_ ) :: n, lbandh, out
INTEGER ( KIND = ip_ ) :: n, lbandh, nsemib, out
! INTEGER ( KIND = ip_ ) :: maxsbw
REAL ( KIND = rp_ ), DIMENSION( 0 : lbandh, n ):: H_band
INTEGER ( KIND = ip_ ) :: i, j
Expand Down
3 changes: 2 additions & 1 deletion src/test/utest_threaded.F90
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PROGRAM CUTEST_test_unconstrained_tools
INTEGER ( KIND = ip_ ) :: i, n, HE_nel, HE_val_ne, HE_row_ne, status
INTEGER ( KIND = ip_ ) :: l_h2_1, l_h, lhe_ptr, H_ne, lhe_val, lhe_row
INTEGER ( KIND = ip_ ) :: nnz_vector, nnz_result, maxsbw, alloc_stat
INTEGER ( KIND = ip_ ) :: nsemib, lbandh
REAL ( KIND = rp_ ) :: f
LOGICAL :: grad, byrows, goth
CHARACTER ( len = 10 ) :: p_name
Expand Down Expand Up @@ -517,7 +518,7 @@ END SUBROUTINE WRITE_SRESULT

! SUBROUTINE WRITE_H_BAND( out, n, lbandh, H_band, nsemib, maxsbw )
SUBROUTINE WRITE_H_BAND( out, n, lbandh, H_band, nsemib )
INTEGER ( KIND = ip_ ) :: n, lbandh, out
INTEGER ( KIND = ip_ ) :: n, lbandh, nsemib, out
! INTEGER ( KIND = ip_ ) :: maxsbw
REAL ( KIND = rp_ ), DIMENSION( 0 : lbandh, n ):: H_band
INTEGER ( KIND = ip_ ) :: i, j
Expand Down

0 comments on commit bd1b94e

Please sign in to comment.