diff --git a/CHANGELOG.md b/CHANGELOG.md index cf25b99bf6..b766f5c334 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,11 +27,14 @@ Fixed scaling bug in `SUNMatScaleAddI_Sparse` for non-square matrices. Fixed missing soversions in some `SUNLinearSolver` and `SUNNonlinearSolver` CMake targets. +Added Fortran support for the LAPACK dense `SUNLinearSolver` implementations. + Fixed the build system support for MAGMA when using a NVIDIA HPC SDK installation of CUDA and fixed the targets used for rocBLAS and rocSPARSE. Added the fourth order ERK method `ARKODE_SOFRONIOU_SPALETTA_5_3_4`. + ## Changes to SUNDIALS in release 6.6.1 Updated the Tpetra NVector interface to support Trilinos 14. diff --git a/doc/arkode/guide/source/Introduction.rst b/doc/arkode/guide/source/Introduction.rst index 7fbe137950..c33aca7415 100644 --- a/doc/arkode/guide/source/Introduction.rst +++ b/doc/arkode/guide/source/Introduction.rst @@ -156,8 +156,11 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Added the fourth order ERK method ``ARKODE_SOFRONIOU_SPALETTA_5_3_4``. + Changes in v5.6.1 ----------------- diff --git a/doc/cvode/guide/source/Introduction.rst b/doc/cvode/guide/source/Introduction.rst index b28e54a07a..7a175c0ca0 100644 --- a/doc/cvode/guide/source/Introduction.rst +++ b/doc/cvode/guide/source/Introduction.rst @@ -129,6 +129,8 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Changes in v6.6.1 ----------------- diff --git a/doc/cvodes/guide/source/Introduction.rst b/doc/cvodes/guide/source/Introduction.rst index 567c0b0284..bb561ccca5 100644 --- a/doc/cvodes/guide/source/Introduction.rst +++ b/doc/cvodes/guide/source/Introduction.rst @@ -132,6 +132,8 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Changes in v6.6.1 ----------------- diff --git a/doc/ida/guide/source/Introduction.rst b/doc/ida/guide/source/Introduction.rst index 5fae985f15..9f54d64a68 100644 --- a/doc/ida/guide/source/Introduction.rst +++ b/doc/ida/guide/source/Introduction.rst @@ -90,6 +90,8 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Changes in v6.6.1 ----------------- diff --git a/doc/idas/guide/source/Introduction.rst b/doc/idas/guide/source/Introduction.rst index 4d1d3b3c4c..0073960dc2 100644 --- a/doc/idas/guide/source/Introduction.rst +++ b/doc/idas/guide/source/Introduction.rst @@ -107,6 +107,8 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Changes in v5.6.1 ----------------- diff --git a/doc/kinsol/guide/source/Introduction.rst b/doc/kinsol/guide/source/Introduction.rst index d91d300fbb..ee33d5a33a 100644 --- a/doc/kinsol/guide/source/Introduction.rst +++ b/doc/kinsol/guide/source/Introduction.rst @@ -102,6 +102,8 @@ Fixed scaling bug in ``SUNMatScaleAddI_Sparse`` for non-square matrices. Fixed missing soversions in some ``SUNLinearSolver`` and ``SUNNonlinearSolver`` CMake targets. +Added Fortran support for the LAPACK dense ``SUNLinearSolver`` implementation. + Changes in v6.6.1 ----------------- diff --git a/examples/sunlinsol/lapackdense/CMakeLists.txt b/examples/sunlinsol/lapackdense/CMakeLists.txt index ef9b00cf55..eb5ef45b0a 100644 --- a/examples/sunlinsol/lapackdense/CMakeLists.txt +++ b/examples/sunlinsol/lapackdense/CMakeLists.txt @@ -30,6 +30,16 @@ set(sunlinsol_lapackdense_dependencies test_sunlinsol ) +# If building F2003 tests +if (BUILD_FORTRAN_MODULE_INTERFACE) + set(sunlinsol_lapackdense_fortran_examples + "test_fsunlinsol_lapackdense_mod\;10 0 0\;" + "test_fsunlinsol_lapackdense_mod\;100 0 0\;" + "test_fsunlinsol_lapackdense_mod\;500 0 0\;" + "test_fsunlinsol_lapackdense_mod\;1000 0 0\;" + ) +endif() + # Add source directory to include directories include_directories(. ..) @@ -82,6 +92,52 @@ foreach(example_tuple ${sunlinsol_lapackdense_examples}) endforeach(example_tuple ${sunlinsol_lapackdense_examples}) +# Add the build and install targets for each example +foreach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) + + # parse the example tuple + list(GET example_tuple 0 example) + list(GET example_tuple 1 example_args) + list(GET example_tuple 2 example_type) + + # check if this example has already been added, only need to add + # example source files once for testing with different inputs + if(NOT TARGET ${example}) + # example source files + add_executable(${example} ${example}.f90 + ${SUNDIALS_SOURCE_DIR}/examples/utilities/test_utilities.f90 + ${SUNDIALS_SOURCE_DIR}/examples/sunlinsol/test_sunlinsol.f90) + + # folder to organize targets in an IDE + set_target_properties(${example} PROPERTIES FOLDER "Examples") + + # set fortran module directory to avoid name collisions + set_target_properties(${example} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + # libraries to link against + target_link_libraries(${example} + sundials_nvecserial + sundials_fnvecserial_mod + sundials_sunlinsollapackdense + sundials_fsunlinsollapackdense_mod + ${EXE_EXTRA_LINK_LIBS}) + + # check if example args are provided and set the test name + if("${example_args}" STREQUAL "") + set(test_name ${example}) + else() + string(REGEX REPLACE " " "_" test_name ${example}_${example_args}) + endif() + + # add example to regression tests + sundials_add_test(${test_name} ${example} + TEST_ARGS ${example_args} + EXAMPLE_TYPE ${example_type} + NODIFF) + endif() + +endforeach(example_tuple ${sunlinsol_lapackdense_fortran_examples}) + if(EXAMPLES_INSTALL) diff --git a/examples/sunlinsol/lapackdense/test_fsunlinsol_lapackdense_mod.f90 b/examples/sunlinsol/lapackdense/test_fsunlinsol_lapackdense_mod.f90 new file mode 100644 index 0000000000..797c77ced5 --- /dev/null +++ b/examples/sunlinsol/lapackdense/test_fsunlinsol_lapackdense_mod.f90 @@ -0,0 +1,185 @@ +! ----------------------------------------------------------------- +! Programmer(s): Daniel R. Reynolds @ SMU +! ----------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, Lawrence Livermore National Security +! and Southern Methodist University. +! All rights reserved. +! +! See the top-level LICENSE and NOTICE files for details. +! +! SPDX-License-Identifier: BSD-3-Clause +! SUNDIALS Copyright End +! ----------------------------------------------------------------- +! This file tests the Fortran 2003 interface to the SUNDIALS +! LAPACK-Dense SUNLinearSolver implementation. +! ----------------------------------------------------------------- + +module test_fsunlinsol_lapackdense + use, intrinsic :: iso_c_binding + use test_utilities + implicit none + + integer(C_LONG), private, parameter :: N = 100 + +contains + + integer(C_INT) function unit_tests() result(fails) + use, intrinsic :: iso_c_binding + use fsundials_nvector_mod + use fsundials_matrix_mod + use fsundials_linearsolver_mod + use fnvector_serial_mod + use fsunmatrix_dense_mod + use fsunlinsol_lapackdense_mod + use test_sunlinsol + + implicit none + + type(SUNLinearSolver), pointer :: LS ! test linear solver + type(SUNMatrix), pointer :: A, I ! test matrices + type(N_Vector), pointer :: x, b ! test vectors + real(C_DOUBLE), pointer :: colj(:), colIj(:) ! matrix column data + real(C_DOUBLE), pointer :: xdata(:) ! x vector data + real(C_DOUBLE) :: tmpr ! temporary real value + integer(C_LONG) :: j, k + integer(C_INT) :: tmp + + fails = 0 + + A => FSUNDenseMatrix(N, N, sunctx) + I => FSUNDenseMatrix(N, N, sunctx) + x => FN_VNew_Serial(N, sunctx) + b => FN_VNew_Serial(N, sunctx) + + ! fill A matrix with uniform random data in [0, 1/N) + do j=1, N + colj => FSUNDenseMatrix_Column(A, j-1) + do k=1, N + call random_number(tmpr) + colj(k) = tmpr / N + end do + end do + + ! create anti-identity matrix + j = N + do k=1, N + colj => FSUNDenseMatrix_Column(I, j-1) + colj(k) = ONE + j = j-1 + end do + + ! add anti-identity to ensure the solver needs to do row-swapping + do k=1, N + do j=1, N + colj => FSUNDenseMatrix_Column(A, j-1) + colIj => FSUNDenseMatrix_Column(I, j-1) + colj(k) = colj(k) + colIj(k) + end do + end do + + ! fill x vector with uniform random data in [0, 1) + xdata => FN_VGetArrayPointer(x) + do j=1, N + call random_number(tmpr) + xdata(j) = tmpr + end do + + ! create RHS vector for linear solve + fails = FSUNMatMatvec(A, x, b) + if (fails /= 0) then + call FSUNMatDestroy(A) + call FSUNMatDestroy(I) + call FN_VDestroy(x) + call FN_VDestroy(b) + return + end if + + ! create dense linear solver + LS => FSUNLinSol_LapackDense(x, A, sunctx) + + ! run tests + fails = fails + Test_FSUNLinSolInitialize(LS, 0) + fails = fails + Test_FSUNLinSolSetup(LS, A, 0) + fails = fails + Test_FSUNLinSolSolve(LS, A, x, b, 100*UNIT_ROUNDOFF, 0) + + fails = fails + Test_FSUNLinSolGetType(LS, SUNLINEARSOLVER_DIRECT, 0) + fails = fails + Test_FSUNLinSolLastFlag(LS, 0) + fails = fails + Test_FSUNLinSolSpace(LS, 0) + + ! cleanup + tmp = FSUNLinSolFree(LS) + call FSUNMatDestroy(A) + call FSUNMatDestroy(I) + call FN_VDestroy(x) + call FN_VDestroy(b) + + end function unit_tests + +end module + +integer(C_INT) function check_vector(X, Y, tol) result(failure) + use, intrinsic :: iso_c_binding + use fsundials_nvector_mod + use test_utilities + + implicit none + type(N_Vector) :: x, y + real(C_DOUBLE) :: tol, maxerr + integer(C_LONG) :: i, xlen, ylen + real(C_DOUBLE), pointer :: xdata(:), ydata(:) + + failure = 0 + + xdata => FN_VGetArrayPointer(x) + ydata => FN_VGetArrayPointer(y) + + xlen = FN_VGetLength(x) + ylen = FN_VGetLength(y) + + if (xlen /= ylen) then + print *, 'FAIL: check_vector: different data array lengths' + failure = 1 + return + end if + + do i = 1, xlen + failure = failure + FNEQTOL(xdata(i), ydata(i), tol) + end do + + if (failure > 0) then + maxerr = ZERO + do i = 1, xlen + maxerr = max(abs(xdata(i)-ydata(i))/abs(ydata(i)), maxerr) + end do + write(*,'(A,E14.7,A,E14.7,A)') & + "FAIL: check_vector failure: maxerr = ", maxerr, " (tol = ", tol, ")" + end if + +end function check_vector + +program main + !======== Inclusions ========== + use, intrinsic :: iso_c_binding + use test_fsunlinsol_lapackdense + + !======== Declarations ======== + implicit none + integer(C_INT) :: fails = 0 + + !============== Introduction ============= + print *, 'LAPACK-Dense SUNLinearSolver Fortran 2003 interface test' + + call Test_Init(c_null_ptr) + + fails = unit_tests() + if (fails /= 0) then + print *, 'FAILURE: n unit tests failed' + stop 1 + else + print *,'SUCCESS: all unit tests passed' + end if + + call Test_Finalize() + +end program main diff --git a/scripts/shared b/scripts/shared index 7304bc5df8..74cb6bfbba 100755 --- a/scripts/shared +++ b/scripts/shared @@ -490,6 +490,9 @@ echo " --- Add sunlinsol/lapackdense module to $tarfile" $tar $tarfile $distrobase/src/sunlinsol/lapackdense/CMakeLists.txt $tar $tarfile $distrobase/src/sunlinsol/lapackdense/sunlinsol_lapackdense.c +$tar $tarfile $distrobase/src/sunlinsol/lapackdense/fmod/CMakeLists.txt +$tar $tarfile $distrobase/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.c +$tar $tarfile $distrobase/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.f90 echo " --- Add sunlinsol/magmadense module to $tarfile" @@ -713,6 +716,7 @@ $tar $tarfile $distrobase/examples/sunlinsol/kokkos/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/lapackband/test_sunlinsol_lapackband.c $tar $tarfile $distrobase/examples/sunlinsol/lapackband/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/lapackdense/test_sunlinsol_lapackdense.c +$tar $tarfile $distrobase/examples/sunlinsol/lapackdense/test_fsunlinsol_lapackdense_mod.f90 $tar $tarfile $distrobase/examples/sunlinsol/lapackdense/CMakeLists.txt $tar $tarfile $distrobase/examples/sunlinsol/magmadense/test_sunlinsol_magmadense.cpp diff --git a/src/sunlinsol/lapackdense/CMakeLists.txt b/src/sunlinsol/lapackdense/CMakeLists.txt index e52a4b6825..c03f8c896e 100644 --- a/src/sunlinsol/lapackdense/CMakeLists.txt +++ b/src/sunlinsol/lapackdense/CMakeLists.txt @@ -37,3 +37,8 @@ sundials_add_library(sundials_sunlinsollapackdense ) message(STATUS "Added SUNLINSOL_LAPACKDENSE module") + +# Add module if F2003 interface is enabled +if(BUILD_FORTRAN_MODULE_INTERFACE) + add_subdirectory(fmod) +endif() diff --git a/src/sunlinsol/lapackdense/fmod/CMakeLists.txt b/src/sunlinsol/lapackdense/fmod/CMakeLists.txt new file mode 100644 index 0000000000..d7b281ec71 --- /dev/null +++ b/src/sunlinsol/lapackdense/fmod/CMakeLists.txt @@ -0,0 +1,32 @@ +# ---------------------------------------------------------------------- +# Programmer(s): Cody J. Balos @ LLNL +# ---------------------------------------------------------------------- +# SUNDIALS Copyright Start +# Copyright (c) 2002-2023, Lawrence Livermore National Security +# and Southern Methodist University. +# All rights reserved. +# +# See the top-level LICENSE and NOTICE files for details. +# +# SPDX-License-Identifier: BSD-3-Clause +# SUNDIALS Copyright End +# ---------------------------------------------------------------------- +# CMakeLists.txt file for the F2003 LAPACK dense SUNLinearSolver +# object library +# ---------------------------------------------------------------------- + +sundials_add_f2003_library(sundials_fsunlinsollapackdense_mod + SOURCES + fsunlinsol_lapackdense_mod.f90 fsunlinsol_lapackdense_mod.c + OBJECT_LIBRARIES + sundials_fgeneric_mod_obj + LINK_LIBRARIES + PUBLIC sundials_fsunmatrixdense_mod + OUTPUT_NAME + sundials_fsunlinsollapackdense_mod + VERSION + ${sunlinsollib_VERSION} + SOVERSION + ${sunlinsollib_SOVERSION} +) +message(STATUS "Added SUNLINSOL_LAPACKDENSE F2003 interface") diff --git a/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.c b/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.c new file mode 100644 index 0000000000..2ed9147d9f --- /dev/null +++ b/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.c @@ -0,0 +1,337 @@ +/* ---------------------------------------------------------------------------- + * This file was automatically generated by SWIG (http://www.swig.org). + * Version 4.0.0 + * + * This file is not intended to be easily readable and contains a number of + * coding conventions designed to improve portability and efficiency. Do not make + * changes to this file unless you know what you are doing--modify the SWIG + * interface file instead. + * ----------------------------------------------------------------------------- */ + +/* --------------------------------------------------------------- + * Programmer(s): Auto-generated by swig. + * --------------------------------------------------------------- + * SUNDIALS Copyright Start + * Copyright (c) 2002-2023, Lawrence Livermore National Security + * and Southern Methodist University. + * All rights reserved. + * + * See the top-level LICENSE and NOTICE files for details. + * + * SPDX-License-Identifier: BSD-3-Clause + * SUNDIALS Copyright End + * -------------------------------------------------------------*/ + +/* ----------------------------------------------------------------------------- + * This section contains generic SWIG labels for method/variable + * declarations/attributes, and other compiler dependent labels. + * ----------------------------------------------------------------------------- */ + +/* template workaround for compilers that cannot correctly implement the C++ standard */ +#ifndef SWIGTEMPLATEDISAMBIGUATOR +# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) +# define SWIGTEMPLATEDISAMBIGUATOR template +# elif defined(__HP_aCC) +/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ +/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ +# define SWIGTEMPLATEDISAMBIGUATOR template +# else +# define SWIGTEMPLATEDISAMBIGUATOR +# endif +#endif + +/* inline attribute */ +#ifndef SWIGINLINE +# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) +# define SWIGINLINE inline +# else +# define SWIGINLINE +# endif +#endif + +/* attribute recognised by some compilers to avoid 'unused' warnings */ +#ifndef SWIGUNUSED +# if defined(__GNUC__) +# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +# elif defined(__ICC) +# define SWIGUNUSED __attribute__ ((__unused__)) +# else +# define SWIGUNUSED +# endif +#endif + +#ifndef SWIG_MSC_UNSUPPRESS_4505 +# if defined(_MSC_VER) +# pragma warning(disable : 4505) /* unreferenced local function has been removed */ +# endif +#endif + +#ifndef SWIGUNUSEDPARM +# ifdef __cplusplus +# define SWIGUNUSEDPARM(p) +# else +# define SWIGUNUSEDPARM(p) p SWIGUNUSED +# endif +#endif + +/* internal SWIG method */ +#ifndef SWIGINTERN +# define SWIGINTERN static SWIGUNUSED +#endif + +/* internal inline SWIG method */ +#ifndef SWIGINTERNINLINE +# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE +#endif + +/* qualifier for exported *const* global data variables*/ +#ifndef SWIGEXTERN +# ifdef __cplusplus +# define SWIGEXTERN extern +# else +# define SWIGEXTERN +# endif +#endif + +/* exporting methods */ +#if defined(__GNUC__) +# if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# ifndef GCC_HASCLASSVISIBILITY +# define GCC_HASCLASSVISIBILITY +# endif +# endif +#endif + +#ifndef SWIGEXPORT +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# if defined(STATIC_LINKED) +# define SWIGEXPORT +# else +# define SWIGEXPORT __declspec(dllexport) +# endif +# else +# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) +# define SWIGEXPORT __attribute__ ((visibility("default"))) +# else +# define SWIGEXPORT +# endif +# endif +#endif + +/* calling conventions for Windows */ +#ifndef SWIGSTDCALL +# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) +# define SWIGSTDCALL __stdcall +# else +# define SWIGSTDCALL +# endif +#endif + +/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ +#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) +# define _CRT_SECURE_NO_DEPRECATE +#endif + +/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ +#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) +# define _SCL_SECURE_NO_DEPRECATE +#endif + +/* Deal with Apple's deprecated 'AssertMacros.h' from Carbon-framework */ +#if defined(__APPLE__) && !defined(__ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES) +# define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 +#endif + +/* Intel's compiler complains if a variable which was never initialised is + * cast to void, which is a common idiom which we use to indicate that we + * are aware a variable isn't used. So we just silence that warning. + * See: https://github.com/swig/swig/issues/192 for more discussion. + */ +#ifdef __INTEL_COMPILER +# pragma warning disable 592 +#endif + +/* Errors in SWIG */ +#define SWIG_UnknownError -1 +#define SWIG_IOError -2 +#define SWIG_RuntimeError -3 +#define SWIG_IndexError -4 +#define SWIG_TypeError -5 +#define SWIG_DivisionByZero -6 +#define SWIG_OverflowError -7 +#define SWIG_SyntaxError -8 +#define SWIG_ValueError -9 +#define SWIG_SystemError -10 +#define SWIG_AttributeError -11 +#define SWIG_MemoryError -12 +#define SWIG_NullReferenceError -13 + + + + +#include +#define SWIG_exception_impl(DECL, CODE, MSG, RETURNNULL) \ + { printf("In " DECL ": " MSG); assert(0); RETURNNULL; } + + +#include +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf +# define snprintf _snprintf +# endif +#endif + + +/* Support for the `contract` feature. + * + * Note that RETURNNULL is first because it's inserted via a 'Replaceall' in + * the fortran.cxx file. + */ +#define SWIG_contract_assert(RETURNNULL, EXPR, MSG) \ + if (!(EXPR)) { SWIG_exception_impl("$decl", SWIG_ValueError, MSG, RETURNNULL); } + + +#define SWIGVERSION 0x040000 +#define SWIG_VERSION SWIGVERSION + + +#define SWIG_as_voidptr(a) (void *)((const void *)(a)) +#define SWIG_as_voidptrptr(a) ((void)SWIG_as_voidptr(*a),(void**)(a)) + + +#include "sundials/sundials_linearsolver.h" + + +#include "sunlinsol/sunlinsol_lapackdense.h" + +SWIGEXPORT SUNLinearSolver _wrap_FSUNLinSol_LapackDense(N_Vector farg1, SUNMatrix farg2, void *farg3) { + SUNLinearSolver fresult ; + N_Vector arg1 = (N_Vector) 0 ; + SUNMatrix arg2 = (SUNMatrix) 0 ; + SUNContext arg3 = (SUNContext) 0 ; + SUNLinearSolver result; + + arg1 = (N_Vector)(farg1); + arg2 = (SUNMatrix)(farg2); + arg3 = (SUNContext)(farg3); + result = (SUNLinearSolver)SUNLinSol_LapackDense(arg1,arg2,arg3); + fresult = result; + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolGetType_LapackDense(SUNLinearSolver farg1) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + SUNLinearSolver_Type result; + + arg1 = (SUNLinearSolver)(farg1); + result = (SUNLinearSolver_Type)SUNLinSolGetType_LapackDense(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolGetID_LapackDense(SUNLinearSolver farg1) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + SUNLinearSolver_ID result; + + arg1 = (SUNLinearSolver)(farg1); + result = (SUNLinearSolver_ID)SUNLinSolGetID_LapackDense(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolInitialize_LapackDense(SUNLinearSolver farg1) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + int result; + + arg1 = (SUNLinearSolver)(farg1); + result = (int)SUNLinSolInitialize_LapackDense(arg1); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolSetup_LapackDense(SUNLinearSolver farg1, SUNMatrix farg2) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + SUNMatrix arg2 = (SUNMatrix) 0 ; + int result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (SUNMatrix)(farg2); + result = (int)SUNLinSolSetup_LapackDense(arg1,arg2); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolSolve_LapackDense(SUNLinearSolver farg1, SUNMatrix farg2, N_Vector farg3, N_Vector farg4, double const *farg5) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + SUNMatrix arg2 = (SUNMatrix) 0 ; + N_Vector arg3 = (N_Vector) 0 ; + N_Vector arg4 = (N_Vector) 0 ; + realtype arg5 ; + int result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (SUNMatrix)(farg2); + arg3 = (N_Vector)(farg3); + arg4 = (N_Vector)(farg4); + arg5 = (realtype)(*farg5); + result = (int)SUNLinSolSolve_LapackDense(arg1,arg2,arg3,arg4,arg5); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int64_t _wrap_FSUNLinSolLastFlag_LapackDense(SUNLinearSolver farg1) { + int64_t fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + sunindextype result; + + arg1 = (SUNLinearSolver)(farg1); + result = SUNLinSolLastFlag_LapackDense(arg1); + fresult = (sunindextype)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolSpace_LapackDense(SUNLinearSolver farg1, long *farg2, long *farg3) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + long *arg2 = (long *) 0 ; + long *arg3 = (long *) 0 ; + int result; + + arg1 = (SUNLinearSolver)(farg1); + arg2 = (long *)(farg2); + arg3 = (long *)(farg3); + result = (int)SUNLinSolSpace_LapackDense(arg1,arg2,arg3); + fresult = (int)(result); + return fresult; +} + + +SWIGEXPORT int _wrap_FSUNLinSolFree_LapackDense(SUNLinearSolver farg1) { + int fresult ; + SUNLinearSolver arg1 = (SUNLinearSolver) 0 ; + int result; + + arg1 = (SUNLinearSolver)(farg1); + result = (int)SUNLinSolFree_LapackDense(arg1); + fresult = (int)(result); + return fresult; +} + + + diff --git a/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.f90 b/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.f90 new file mode 100644 index 0000000000..a615f9ba43 --- /dev/null +++ b/src/sunlinsol/lapackdense/fmod/fsunlinsol_lapackdense_mod.f90 @@ -0,0 +1,280 @@ +! This file was automatically generated by SWIG (http://www.swig.org). +! Version 4.0.0 +! +! Do not make changes to this file unless you know what you are doing--modify +! the SWIG interface file instead. + +! --------------------------------------------------------------- +! Programmer(s): Auto-generated by swig. +! --------------------------------------------------------------- +! SUNDIALS Copyright Start +! Copyright (c) 2002-2023, Lawrence Livermore National Security +! and Southern Methodist University. +! All rights reserved. +! +! See the top-level LICENSE and NOTICE files for details. +! +! SPDX-License-Identifier: BSD-3-Clause +! SUNDIALS Copyright End +! --------------------------------------------------------------- + +module fsunlinsol_lapackdense_mod + use, intrinsic :: ISO_C_BINDING + use fsundials_linearsolver_mod + use fsundials_types_mod + use fsundials_context_mod + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + use fsundials_matrix_mod + use fsundials_nvector_mod + use fsundials_context_mod + use fsundials_types_mod + implicit none + private + + ! DECLARATION CONSTRUCTS + public :: FSUNLinSol_LapackDense + public :: FSUNLinSolGetType_LapackDense + public :: FSUNLinSolGetID_LapackDense + public :: FSUNLinSolInitialize_LapackDense + public :: FSUNLinSolSetup_LapackDense + public :: FSUNLinSolSolve_LapackDense + public :: FSUNLinSolLastFlag_LapackDense + public :: FSUNLinSolSpace_LapackDense + public :: FSUNLinSolFree_LapackDense + +! WRAPPER DECLARATIONS +interface +function swigc_FSUNLinSol_LapackDense(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNLinSol_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR) :: fresult +end function + +function swigc_FSUNLinSolGetType_LapackDense(farg1) & +bind(C, name="_wrap_FSUNLinSolGetType_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolGetID_LapackDense(farg1) & +bind(C, name="_wrap_FSUNLinSolGetID_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolInitialize_LapackDense(farg1) & +bind(C, name="_wrap_FSUNLinSolInitialize_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolSetup_LapackDense(farg1, farg2) & +bind(C, name="_wrap_FSUNLinSolSetup_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolSolve_LapackDense(farg1, farg2, farg3, farg4, farg5) & +bind(C, name="_wrap_FSUNLinSolSolve_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +type(C_PTR), value :: farg4 +real(C_DOUBLE), intent(in) :: farg5 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolLastFlag_LapackDense(farg1) & +bind(C, name="_wrap_FSUNLinSolLastFlag_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT64_T) :: fresult +end function + +function swigc_FSUNLinSolSpace_LapackDense(farg1, farg2, farg3) & +bind(C, name="_wrap_FSUNLinSolSpace_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +type(C_PTR), value :: farg2 +type(C_PTR), value :: farg3 +integer(C_INT) :: fresult +end function + +function swigc_FSUNLinSolFree_LapackDense(farg1) & +bind(C, name="_wrap_FSUNLinSolFree_LapackDense") & +result(fresult) +use, intrinsic :: ISO_C_BINDING +type(C_PTR), value :: farg1 +integer(C_INT) :: fresult +end function + +end interface + + +contains + ! MODULE SUBPROGRAMS +function FSUNLinSol_LapackDense(y, a, sunctx) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +type(SUNLinearSolver), pointer :: swig_result +type(N_Vector), target, intent(inout) :: y +type(SUNMatrix), target, intent(inout) :: a +type(C_PTR) :: sunctx +type(C_PTR) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(y) +farg2 = c_loc(a) +farg3 = sunctx +fresult = swigc_FSUNLinSol_LapackDense(farg1, farg2, farg3) +call c_f_pointer(fresult, swig_result) +end function + +function FSUNLinSolGetType_LapackDense(s) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNLinearSolver_Type) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(s) +fresult = swigc_FSUNLinSolGetType_LapackDense(farg1) +swig_result = fresult +end function + +function FSUNLinSolGetID_LapackDense(s) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(SUNLinearSolver_ID) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(s) +fresult = swigc_FSUNLinSolGetID_LapackDense(farg1) +swig_result = fresult +end function + +function FSUNLinSolInitialize_LapackDense(s) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(s) +fresult = swigc_FSUNLinSolInitialize_LapackDense(farg1) +swig_result = fresult +end function + +function FSUNLinSolSetup_LapackDense(s, a) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +type(SUNMatrix), target, intent(inout) :: a +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 + +farg1 = c_loc(s) +farg2 = c_loc(a) +fresult = swigc_FSUNLinSolSetup_LapackDense(farg1, farg2) +swig_result = fresult +end function + +function FSUNLinSolSolve_LapackDense(s, a, x, b, tol) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +type(SUNMatrix), target, intent(inout) :: a +type(N_Vector), target, intent(inout) :: x +type(N_Vector), target, intent(inout) :: b +real(C_DOUBLE), intent(in) :: tol +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 +type(C_PTR) :: farg4 +real(C_DOUBLE) :: farg5 + +farg1 = c_loc(s) +farg2 = c_loc(a) +farg3 = c_loc(x) +farg4 = c_loc(b) +farg5 = tol +fresult = swigc_FSUNLinSolSolve_LapackDense(farg1, farg2, farg3, farg4, farg5) +swig_result = fresult +end function + +function FSUNLinSolLastFlag_LapackDense(s) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT64_T) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_INT64_T) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(s) +fresult = swigc_FSUNLinSolLastFlag_LapackDense(farg1) +swig_result = fresult +end function + +function FSUNLinSolSpace_LapackDense(s, lenrwls, leniwls) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_LONG), dimension(*), target, intent(inout) :: lenrwls +integer(C_LONG), dimension(*), target, intent(inout) :: leniwls +integer(C_INT) :: fresult +type(C_PTR) :: farg1 +type(C_PTR) :: farg2 +type(C_PTR) :: farg3 + +farg1 = c_loc(s) +farg2 = c_loc(lenrwls(1)) +farg3 = c_loc(leniwls(1)) +fresult = swigc_FSUNLinSolSpace_LapackDense(farg1, farg2, farg3) +swig_result = fresult +end function + +function FSUNLinSolFree_LapackDense(s) & +result(swig_result) +use, intrinsic :: ISO_C_BINDING +integer(C_INT) :: swig_result +type(SUNLinearSolver), target, intent(inout) :: s +integer(C_INT) :: fresult +type(C_PTR) :: farg1 + +farg1 = c_loc(s) +fresult = swigc_FSUNLinSolFree_LapackDense(farg1) +swig_result = fresult +end function + + +end module diff --git a/swig/Makefile b/swig/Makefile index ce4f536a66..4a062e0445 100644 --- a/swig/Makefile +++ b/swig/Makefile @@ -23,7 +23,7 @@ KINSOL=fkinsol_mod GENERIC=fsundials_types_mod fsundials_nvector_mod fsundials_matrix_mod fsundials_linearsolver_mod fsundials_nonlinearsolver_mod fsundials_futils_mod fsundials_context_mod fsundials_profiler_mod fsundials_logger_mod NVECTOR=openmp pthreads serial parallel manyvector mpiplusx SUNMATRIX=band dense sparse -SUNLINSOL=band dense klu spbcgs spfgmr spgmr sptfqmr pcg +SUNLINSOL=band dense lapackdense klu spbcgs spfgmr spgmr sptfqmr pcg SUNNONLINSOL=newton fixedpoint INCLUDES=-I../include diff --git a/swig/sunlinsol/fsunlinsol_lapackdense_mod.i b/swig/sunlinsol/fsunlinsol_lapackdense_mod.i new file mode 100644 index 0000000000..8ab3d7792c --- /dev/null +++ b/swig/sunlinsol/fsunlinsol_lapackdense_mod.i @@ -0,0 +1,31 @@ +// --------------------------------------------------------------- +// Programmer: Cody J. Balos @ LLNL +// --------------------------------------------------------------- +// SUNDIALS Copyright Start +// Copyright (c) 2002-2023, Lawrence Livermore National Security +// and Southern Methodist University. +// All rights reserved. +// +// See the top-level LICENSE and NOTICE files for details. +// +// SPDX-License-Identifier: BSD-3-Clause +// SUNDIALS Copyright End +// --------------------------------------------------------------- +// Swig interface file +// --------------------------------------------------------------- + +%module fsunlinsol_lapackdense_mod + +// include code common to all nvector implementations +%include "fsunlinsol.i" + +%{ +#include "sunlinsol/sunlinsol_lapackdense.h" +%} + +// sunlinsol_impl macro defines some ignore and inserts with the linear solver name appended +%sunlinsol_impl(LapackDense) + +// Process and wrap functions in the following files +%include "sunlinsol/sunlinsol_lapackdense.h" +