diff --git a/src/makedefs/definitions b/src/makedefs/definitions index 7d4732e5..419ba603 100644 --- a/src/makedefs/definitions +++ b/src/makedefs/definitions @@ -131,3 +131,15 @@ $(PACKAGE) = $(OBJ)/$(package)_main.o U_TEST = $(OBJ)/u_elfun.o $(OBJ)/u_group.o $(OBJ)/u_range.o C_TEST = $(OBJ)/c_elfun.o $(OBJ)/c_group.o $(OBJ)/c_range.o Q_TEST = $(OBJ)/q_elfun.o $(OBJ)/q_group.o $(OBJ)/q_range.o + +# valgrind options if needed + +#VALGRIND = --tool=memcheck --leak-check=full --show-reachable=yes \ +#VALGRIND = -v --tool=memcheck --leak-check=yes --show-reachable=yes \ +#--track-origins=yes -s +VALGRIND = -v --tool=memcheck --leak-check=full --show-reachable=yes \ +--track-origins=yes -s + +# gdb options if needed + +GDB = -silent -ex run -ex bt -ex exit diff --git a/src/test/ctest.c b/src/test/ctest.c index 538297ea..5a7d6c70 100644 --- a/src/test/ctest.c +++ b/src/test/ctest.c @@ -1189,6 +1189,7 @@ printf("hello\n"); //here free(classification); + free(p_name); free(X_type); free(H_row); free(H_col); @@ -1212,8 +1213,14 @@ printf("hello\n"); free(result); free(G_val); free(G_var); + for (i = 0; i < n; i++) + free(X_names[i]); free(X_names); + free(X_names_fortran); + for (i = 0; i < m; i++) + free(C_names[i]); free(C_names); + free(C_names_fortran); free(equation); free(linear); free(INDEX_nz_vector); @@ -1319,7 +1326,7 @@ void write_j_dense(ipc_ n, ipc_ m, ipc_ l_j2_1, ipc_ l_j2_2, rpc_ *J2_val) { printf("\n"); // Print matrix values - for (ipc_ i = 0; i < l_j2_1; i++) { + for (ipc_ i = 0; i < m; i++) { printf(" * %7d ", i + 1); for (ipc_ k = 0; k < 4 && j + k < n; k++) { printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); @@ -1340,7 +1347,7 @@ void write_jt_dense(ipc_ n, ipc_ m, ipc_ l_j2_1, ipc_ l_j2_2, rpc_ *J2_val) { printf("\n"); // Print matrix values - for (ipc_ i = 0; i < l_j2_1; i++) { + for (ipc_ i = 0; i < n; i++) { printf(" * %7d ", i + 1); for (ipc_ k = 0; k < 4 && j + k < m; k++) { printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); diff --git a/src/test/ctest_c.c b/src/test/ctest_c.c index 883b92d2..ce603e90 100644 --- a/src/test/ctest_c.c +++ b/src/test/ctest_c.c @@ -1186,6 +1186,7 @@ int main() { } free(classification); + free(p_name); free(X_type); free(H_row); free(H_col); @@ -1212,8 +1213,14 @@ int main() { free(result); free(G_val); free(G_var); + for (i = 0; i < n; i++) + free(X_names[i]); free(X_names); + free(X_names_fortran); + for (i = 0; i < m; i++) + free(C_names[i]); free(C_names); + free(C_names_fortran); free(equation); free(linear); free(INDEX_nz_vector); @@ -1316,10 +1323,11 @@ void write_j_dense(ipc_ n, ipc_ m, ipc_ l_j2_1, ipc_ l_j2_2, rpc_ *J2_val) { printf("\n"); // Print matrix values - for (ipc_ i = 0; i < l_j2_1; i++) { + for (ipc_ i = 0; i < m; i++) { printf(" * %7d ", i); for (ipc_ k = 0; k < 4 && j + k < n; k++) { - printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); + printf(" %12.4e", J2_val[j+k+n*i]); +// printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); } printf("\n"); } @@ -1337,10 +1345,11 @@ void write_jt_dense(ipc_ n, ipc_ m, ipc_ l_j2_1, ipc_ l_j2_2, rpc_ *J2_val) { printf("\n"); // Print matrix values - for (ipc_ i = 0; i < l_j2_1; i++) { + for (ipc_ i = 0; i < n; i++) { printf(" * %7d ", i); for (ipc_ k = 0; k < 4 && j + k < m; k++) { - printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); + printf(" %12.4e", J2_val[j+k+m*i]); +// printf(" %12.4e", J2_val[i+l_j2_1*(j+k)]); } printf("\n"); } diff --git a/src/test/makemaster b/src/test/makemaster index 0770f323..666e9a78 100644 --- a/src/test/makemaster +++ b/src/test/makemaster @@ -193,20 +193,64 @@ run_c_test_cutest_unconstrained: utools test_cutest_unconstrained cat ../test/c_test_unc.output rm $(OBJ)/run_c_test +run_c_test_cutest_unconstrained_sanitize: ctools test_cutest_unconstrained + echo " Exhaustive test of unconstrained C tools" + $(CP) ../test/utest.c $(OBJ)/utest.c + cd $(OBJ) ; $(CC) -o utest.o $(CFLAGS) -fsanitize=address -g utest.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) utest.o -L$(OBJ) $(LIBS) \ + -fsanitize=address -static-libasan + - $(OBJ)/run_c_test +# - $(OBJ)/run_c_test >& ../test/c_test_unc.output +# cat ../test/c_test_unc.output + rm $(OBJ)/run_c_test + +run_c_test_cutest_unconstrained_valgrind: ctools test_cutest_unconstrained + echo " Exhaustive test of unconstrained C tools" + $(CP) ../test/utest.c $(OBJ)/utest.c + cd $(OBJ) ; $(CC) -o utest.o $(CFLAGS) -g utest.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) utest.o -L$(OBJ) $(LIBS) + - valgrind $(VALGRIND) $(OBJ)/run_c_test +# - valgrind $(VALGRIND) $(OBJ)/run_c_test >& \ +# ../test/c_test_unc_valgrind.output +# cat ../test/c_test_unc_valgrind.output + rm $(OBJ)/run_c_test + run_c_test_cutest_constrained: ctools test_cutest_constrained echo " Exhaustive test of constrained C tools" $(CP) ../test/ctest.c $(OBJ)/ctest.c -# cd $(OBJ) ; $(CC) -o ctest.o $(CFLAGS) -fsanitize=address -g ctest.c cd $(OBJ) ; $(CC) -o ctest.o $(CFLAGS) ctest.c cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ $(NOFMAIN) $(C_TEST) ctest.o -L$(OBJ) $(LIBS) -# $(NOFMAIN) $(C_TEST) ctest.o -L$(OBJ) $(LIBS) \ -# -fsanitize=address -static-libasan -# - $(OBJ)/run_c_test - $(OBJ)/run_c_test >& ../test/c_test_con.output cat ../test/c_test_con.output rm $(OBJ)/run_c_test +run_c_test_cutest_constrained_sanitize: ctools test_cutest_constrained + echo " Exhaustive test of constrained C tools" + $(CP) ../test/ctest.c $(OBJ)/ctest.c + cd $(OBJ) ; $(CC) -o ctest.o $(CFLAGS) -fsanitize=address -g ctest.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) ctest.o -L$(OBJ) $(LIBS) \ + -fsanitize=address -static-libasan + - $(OBJ)/run_c_test +# - $(OBJ)/run_c_test >& ../test/c_test_con.output +# cat ../test/c_test_con.output + rm $(OBJ)/run_c_test + +run_c_test_cutest_constrained_valgrind: ctools test_cutest_constrained + echo " Exhaustive test of constrained C tools" + $(CP) ../test/ctest.c $(OBJ)/ctest.c + cd $(OBJ) ; $(CC) -o ctest.o $(CFLAGS) -g ctest.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) ctest.o -L$(OBJ) $(LIBS) + - valgrind $(VALGRIND) $(OBJ)/run_c_test +# - valgrind $(VALGRIND) $(OBJ)/run_c_test >& \ +# ../test/c_test_con_valgrind.output +# cat ../test/c_test_con_valgrind.output + rm $(OBJ)/run_c_test + run_c_test_c_cutest_unconstrained: utools test_cutest_unconstrained echo " Exhaustive test of 0-based unconstrained C tools" $(CP) ../test/utest_c.c $(OBJ)/utest_c.c @@ -217,17 +261,66 @@ run_c_test_c_cutest_unconstrained: utools test_cutest_unconstrained cat ../test/c_test_c_unc.output rm $(OBJ)/run_c_test +run_c_test_c_cutest_unconstrained_sanitize: utools test_cutest_unconstrained + echo " Exhaustive test of 0-based unconstrained C tools" + $(CP) ../test/utest_c.c $(OBJ)/utest_c.c + cd $(OBJ) ; $(CC) -o utest_c.o $(CFLAGS) -fsanitize=address \ + -g utest_c.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) utest_c.o -L$(OBJ) $(LIBS) \ + -fsanitize=address -static-libasan + - $(OBJ)/run_c_test +# - $(OBJ)/run_c_test >& ../test/c_test_c_unc.output +# cat ../test/c_test_c_unc.output + rm $(OBJ)/run_c_test + +run_c_test_c_cutest_unconstrained_valgrind: utools test_cutest_unconstrained + echo " Exhaustive test of 0-based unconstrained C tools" + $(CP) ../test/utest_c.c $(OBJ)/utest_c.c + cd $(OBJ) ; $(CC) -o utest_c.o $(CFLAGS) utest_c.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) utest_c.o -L$(OBJ) $(LIBS) + - valgrind $(VALGRIND) $(OBJ)/run_c_test +# - valgrind $(VALGRIND) $(OBJ)/run_c_test >& \ +# ../test/c_test_c_unc_valgrind.output +# cat ../test/c_test_c_unc_valgrind.output + rm $(OBJ)/run_c_test + run_c_test_c_cutest_constrained: ctools test_cutest_constrained echo " Exhaustive test of 0-based constrained C tools" $(CP) ../test/ctest_c.c $(OBJ)/ctest_c.c cd $(OBJ) ; $(CC) -o ctest_c.o $(CFLAGS) ctest_c.c cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ $(NOFMAIN) $(C_TEST) ctest_c.o -L$(OBJ) $(LIBS) + - $(OBJ)/run_c_test >& ../test/c_test_c_con.output + cat ../test/c_test_c_con.output + rm $(OBJ)/run_c_test + +run_c_test_c_cutest_constrained_sanitize: ctools test_cutest_constrained + echo " Exhaustive test of 0-based constrained C tools" + $(CP) ../test/ctest_c.c $(OBJ)/ctest_c.c + cd $(OBJ) ; $(CC) -o ctest_c.o $(CFLAGS) -fsanitize=address \ + -g ctest_c.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) ctest_c.o -L$(OBJ) $(LIBS) \ + -fsanitize=address -static-libasan - $(OBJ)/run_c_test # - $(OBJ)/run_c_test >& ../test/c_test_c_con.output # cat ../test/c_test_c_con.output rm $(OBJ)/run_c_test +run_c_test_c_cutest_constrained_valgrind: ctools test_cutest_constrained + echo " Exhaustive test of 0-based constrained C tools" + $(CP) ../test/ctest_c.c $(OBJ)/ctest_c.c + cd $(OBJ) ; $(CC) -o ctest_c.o $(CFLAGS) ctest_c.c + cd $(OBJ) ; $(FORTRAN) $(RUNFFLAGS) $(SPECIAL) -o run_c_test \ + $(NOFMAIN) $(C_TEST) ctest_c.o -L$(OBJ) $(LIBS) + - valgrind $(VALGRIND) $(OBJ)/run_c_test +# - valgrind $(VALGRIND) $(OBJ)/run_c_test >& \ +# ../test/c_test_c_con_valgrind.output +# cat ../test/c_test_c_con_valgrind.output + rm $(OBJ)/run_c_test + tools: ( cd ../tools ; $(MAKE) -f $(CUTEST)/makefiles/$(VERSION) \ cutest PRECIS=$(PRECIS) PWD=$(PWD)/../tools ) diff --git a/src/test/meson.build b/src/test/meson.build index a397e036..8d613c2c 100644 --- a/src/test/meson.build +++ b/src/test/meson.build @@ -11,11 +11,11 @@ cutest_tests += [['cutest', 'single', 'ctest_single' , files('ctest.F90' cutest_c_tests += [['cutest', 'single', 'ctest_c_single' , files('ctest.c' , 'c_elfun_single.f', 'c_group_single.f', 'c_range_single.f')], ['cutest', 'single', 'utest_c_single' , files('utest.c' , 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')], - ['cutest', 'single', 'ctest2_c_single', files('ctest_c.c', 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')], + ['cutest', 'single', 'ctest2_c_single', files('ctest_c.c', 'c_elfun_single.f', 'c_group_single.f', 'c_range_single.f')], ['cutest', 'single', 'utest2_c_single', files('utest_c.c', 'u_elfun_single.f', 'u_group_single.f', 'u_range_single.f')], ['cutest', 'double', 'ctest_c_double' , files('ctest.c' , 'c_elfun_double.f', 'c_group_double.f', 'c_range_double.f')], ['cutest', 'double', 'utest_c_double' , files('utest.c' , 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')], - ['cutest', 'double', 'ctest2_c_double', files('ctest_c.c', 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')]] + ['cutest', 'double', 'ctest2_c_double', files('ctest_c.c', 'c_elfun_double.f', 'c_group_double.f', 'c_range_double.f')]], ['cutest', 'double', 'utest2_c_double', files('utest_c.c', 'u_elfun_double.f', 'u_group_double.f', 'u_range_double.f')]] if build_quadruple @@ -27,6 +27,6 @@ if build_quadruple cutest_c_tests += [['cutest', 'quadruple', 'ctest_c_quadruple' , files('ctest.c' , 'c_elfun_quadruple.f', 'c_group_quadruple.f', 'c_range_quadruple.f')], ['cutest', 'quadruple', 'utest_c_quadruple' , files('utest.c' , 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')], - ['cutest', 'quadruple', 'ctest2_c_quadruple', files('ctest_c.c', 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')]] + ['cutest', 'quadruple', 'ctest2_c_quadruple', files('ctest_c.c', 'c_elfun_quadruple.f', 'c_group_quadruple.f', 'c_range_quadruple.f')]], ['cutest', 'quadruple', 'utest2_c_quadruple', files('utest_c.c', 'u_elfun_quadruple.f', 'u_group_quadruple.f', 'u_range_quadruple.f')]] endif diff --git a/src/test/utest.c b/src/test/utest.c index e812135b..02e25b37 100644 --- a/src/test/utest.c +++ b/src/test/utest.c @@ -441,6 +441,8 @@ int main() { // Cleanup and close files free(classification); free(p_name); + for (i = 0; i < n; i++) + free(X_names[i]); free(X_names); free(X_names_fortran); free(X); diff --git a/src/test/utest_c.c b/src/test/utest_c.c index 81fb93e3..3eeef4a9 100644 --- a/src/test/utest_c.c +++ b/src/test/utest_c.c @@ -441,6 +441,8 @@ int main() { // Cleanup and close files free(classification); free(p_name); + for (i = 0; i < n; i++) + free(X_names[i]); free(X_names); free(X_names_fortran); free(X); diff --git a/src/tools/cofsg.F90 b/src/tools/cofsg.F90 index 8fe5809c..ea761b74 100644 --- a/src/tools/cofsg.F90 +++ b/src/tools/cofsg.F90 @@ -1,4 +1,4 @@ -! THIS VERSION: CUTEST 2.3 - 2024-10-23 AT 08:30 GMT. +! THIS VERSION: CUTEST 2.3 - 2024-10-30 AT 08:40 GMT. #include "cutest_modules.h" #include "cutest_routines.h" @@ -44,7 +44,7 @@ SUBROUTINE CUTEST_cofsg_c_r( status, n, X, f, nnzg, lg, G_val, G_var, & CALL CUTEST_cofsg_r( status, n, X, f, nnzg, lg, G_val, G_var, & grad_fortran ) - G_var( : nnzg ) = G_var( : nnzg ) - 1 + IF ( grad_fortran ) G_var( : nnzg ) = G_var( : nnzg ) - 1 RETURN