diff --git a/CMakeLists.txt b/CMakeLists.txt index e9546d56..31715ba7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ option(enable_single "Enable single precision library" ON) option(enable_double "Enable double precision library" ON) option(enable_complex "Enable complex precision library" ON) option(enable_complex16 "Enable complex16 precision library" ON) -# option(enable_examples "Build examples" ON) +option(enable_examples "Build examples" ON) #-- BLAS option(TPL_ENABLE_INTERNAL_BLASLIB "Build the CBLAS library" ${enable_blaslib_DEFAULT}) @@ -219,11 +219,12 @@ if(enable_doc) add_subdirectory(DOC) endif() +###################################################################### +# # Generate various configure files with proper definitions +# +###################################################################### -# file(WRITE "make.defs" "# can be exposed to users" -# ${CMAKE_C_COMPILER} ) -# configure_file(${CMAKE_SOURCE_DIR}/make.inc.in ${CMAKE_SOURCE_DIR}/make.inc) configure_file(${SuperLU_SOURCE_DIR}/make.inc.in ${SuperLU_SOURCE_DIR}/make.inc) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/superlu.pc.in ${CMAKE_CURRENT_BINARY_DIR}/superlu.pc @ONLY) diff --git a/EXAMPLE/CMakeLists.txt b/EXAMPLE/CMakeLists.txt new file mode 100644 index 00000000..cf857b53 --- /dev/null +++ b/EXAMPLE/CMakeLists.txt @@ -0,0 +1,8 @@ +include_directories(${SuperLU_SOURCE_DIR}/SRC) + +add_executable(slinsol + EXCLUDE_FROM_ALL + slinsol.c) +target_link_libraries(slinsol superlu) +add_test(NAME slinsol + COMMAND slinsol "${CMAKE_CURRENT_SOURCE_DIR}/g20.rua") diff --git a/EXAMPLE/README b/EXAMPLE/README index 8330d0ef..2e1915ae 100644 --- a/EXAMPLE/README +++ b/EXAMPLE/README @@ -35,7 +35,7 @@ To run the small 5x5 sample program in Section 1 of the Users' Guide, type: % superlu To run the real version examples, type: - % dlinsol < g20.rua (or, % slinsol < g20.rua) + % dlinsol < g20.rua (or, % slinsol g20.rua) % dlinsolx < g20.rua (or, % slinsolx < g20.rua) % dlinsolx1 < g20.rua (or, % slinsolx1 < g20.rua) % dlinsolx2 < g20.rua (or, % slinsolx2 < g20.rua) diff --git a/EXAMPLE/slinsol.c b/EXAMPLE/slinsol.c index 1d8808f1..449c8444 100644 --- a/EXAMPLE/slinsol.c +++ b/EXAMPLE/slinsol.c @@ -1,4 +1,4 @@ -/*! \file +/* Copyright (c) 2003, The Regents of the University of California, through Lawrence Berkeley National Laboratory (subject to receipt of any required approvals from U.S. Dept. of Energy) @@ -16,11 +16,31 @@ at the top-level directory. * October 15, 2003 * */ + +/*! \file + * Example: use simple driver DGSSV to solve a linear system one time + */ +#include +#include +#include #include #include "slu_sdefs.h" int main(int argc, char *argv[]) { + // ensure right number of arguments are passed + if (argc != 2) { + printf("slinsol requires one additional argument, the path to the matrix file %i\n", argc); + return EXIT_FAILURE; + } + + // print out help + if (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0) { + printf("use simple driver DGSSV to solve a linear system one time\n"); + printf("requires one additional argument, the path to the matrix file\n"); + return EXIT_SUCCESS; + } + SuperMatrix A; NCformat *Astore; float *a; @@ -38,7 +58,7 @@ int main(int argc, char *argv[]) mem_usage_t mem_usage; superlu_options_t options; SuperLUStat_t stat; - FILE *fp = stdin; + FILE *fp = fopen(argv[1], "r"); #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Enter main()"); @@ -109,9 +129,10 @@ int main(int argc, char *argv[]) } } - if ( options.PrintStat ) StatPrint(&stat); - StatFree(&stat); + if (options.PrintStat) + StatPrint(&stat); + StatFree(&stat); SUPERLU_FREE (rhs); SUPERLU_FREE (xact); SUPERLU_FREE (perm_r); @@ -124,5 +145,6 @@ int main(int argc, char *argv[]) #if ( DEBUGlevel>=1 ) CHECK_MALLOC("Exit main()"); #endif -} + return EXIT_SUCCESS; +}