diff --git a/tools/gen_wrappers.py b/tools/gen_wrappers.py index 4a5cd72e3cc7c8b5ea8f6499996539adba6dd908..36fb00b52bdfe978d614042e2396e92ad49ba656 100755 --- a/tools/gen_wrappers.py +++ b/tools/gen_wrappers.py @@ -44,7 +44,7 @@ parser.add_argument('args', nargs='*', action='store', help='Files to process') opts = parser.parse_args() # exclude inline functions from the interface -exclude_list = [ "inline", "spmIntSort" ] +exclude_list = [ "inline", "spmIntSort", "spmIntMSort" ] def polish_file(whole_file): """Preprocessing and cleaning of the header file. @@ -475,7 +475,7 @@ spm_enums = { 'description' : "SPM fortran 90 wrapper to define enums and datatypes", 'header' : " implicit none\n", 'footer' : enums_fortran_footer, - 'enums' : {} + 'enums' : { 'mtxtype' : " enumerator :: SpmSymPosDef = SpmConjTrans + 1\n enumerator :: HerPosDef = SpmConjTrans + 2\n" } }, } diff --git a/tools/wrappers/__init__.py b/tools/wrappers/__init__.py index 249cb8e59bc2f1fc5639fba80fe3141eb74a5770..c910afd6ba36daa575037c3bf59db421fcd61dcf 100644 --- a/tools/wrappers/__init__.py +++ b/tools/wrappers/__init__.py @@ -27,7 +27,7 @@ return_variables_dict = { } # global list used to determine derived types -derived_types = [ 'pastix_int_t', 'pastix_data_t', 'pastix_order_t'] +derived_types = [ 'spmatrix_t', 'spm_int_t', 'pastix_int_t', 'pastix_data_t', 'pastix_order_t'] # name arrays which will be translated to assumed-size arrays, e.g. pA(*) arrays_names_2D = ["pA", "pB", "pC", "pAB", "pQ", "pX", "pAs"] diff --git a/wrappers/fortran90/CMakeLists.txt b/wrappers/fortran90/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..a1a40c2260320c3f09784a7c5d484f344227cd8e --- /dev/null +++ b/wrappers/fortran90/CMakeLists.txt @@ -0,0 +1,57 @@ +### +# +# @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +# Univ. Bordeaux. All rights reserved. +# +# @version 6.0.0 +# @author Mathieu Faverge +# @date 2017-05-22 +# +### +cmake_minimum_required (VERSION 3.1) + +# Coherce CMake to install the generated .mod files +set(CMAKE_Fortran_MODULE_DIRECTORY ${CMAKE_BINARY_DIR}/mod_files) +install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/ DESTINATION include) + +add_library( spmf + src/spm_enums.F90 + src/spmf.f90 ) + +if ( SPM_INT64 ) + set_source_files_properties( + src/spm_enums.F90 + PROPERTIES COMPILE_DEFINITIONS "SPM_INT_KIND=8") +else() + set_source_files_properties( + src/spm_enums.F90 + PROPERTIES COMPILE_DEFINITIONS "SPM_INT_KIND=4") +endif() + +target_link_libraries( spmf spm ) +install(TARGETS spmf + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib ) + +# +# Add examples +# +#set (EXAMPLES +# fsimple.f90 +# flaplacian.f90 +# fstep-by-step.f90 +# ) +# +#foreach (_file ${EXAMPLES}) +# get_filename_component(_name_we ${_file} NAME_WE) +# add_executable(${_name_we} examples/${_file}) +# target_link_libraries(${_name_we} pastixf) +# +# install(TARGETS ${_name_we} RUNTIME DESTINATION examples ) +# install(FILES examples/${_file} DESTINATION examples ) +# +# add_test(fortran_${_name_we} ./${_name_we}) +# +#endforeach() + diff --git a/wrappers/fortran90/src/spm_enums.F90 b/wrappers/fortran90/src/spm_enums.F90 new file mode 100644 index 0000000000000000000000000000000000000000..5b7f9c93d6cb68a2aa2c0b5f54e95b03a24d5330 --- /dev/null +++ b/wrappers/fortran90/src/spm_enums.F90 @@ -0,0 +1,143 @@ + +! +! @file spm_enums.F90 +! +! SPM fortran 90 wrapper to define enums and datatypes +! +! @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +! Univ. Bordeaux. All rights reserved. +! +! @version 6.0.0 +! @author Mathieu Faverge +! @date 2017-01-01 +! +! This file has been automatically generated with gen_wrappers.py +! +module spm_enums + use iso_c_binding + implicit none + + ! enum verbose + enum, bind(C) + enumerator :: SpmVerboseNot = 0 + enumerator :: SpmVerboseNo = 1 + enumerator :: SpmVerboseYes = 2 + end enum + + ! enum coeftype + enum, bind(C) + enumerator :: SpmPattern = 0 + enumerator :: SpmFloat = 2 + enumerator :: SpmDouble = 3 + enumerator :: SpmComplex32 = 4 + enumerator :: SpmComplex64 = 5 + end enum + + ! enum fmttype + enum, bind(C) + enumerator :: SpmCSC = 0 + enumerator :: SpmCSR = 1 + enumerator :: SpmIJV = 2 + end enum + + ! enum error + enum, bind(C) + enumerator :: SPM_SUCCESS = 0 + enumerator :: SPM_ERR_UNKNOWN = 1 + enumerator :: SPM_ERR_ALLOC = 2 + enumerator :: SPM_ERR_NOTIMPLEMENTED = 3 + enumerator :: SPM_ERR_OUTOFMEMORY = 4 + enumerator :: SPM_ERR_THREAD = 5 + enumerator :: SPM_ERR_INTERNAL = 6 + enumerator :: SPM_ERR_BADPARAMETER = 7 + enumerator :: SPM_ERR_FILE = 8 + enumerator :: SPM_ERR_INTEGER_TYPE = 9 + enumerator :: SPM_ERR_IO = 10 + enumerator :: SPM_ERR_MPI = 11 + end enum + + ! enum driver + enum, bind(C) + enumerator :: SpmDriverRSA = 0 + enumerator :: SpmDriverHB = 1 + enumerator :: SpmDriverIJV = 2 + enumerator :: SpmDriverMM = 3 + enumerator :: SpmDriverLaplacian = 4 + enumerator :: SpmDriverXLaplacian = 5 + enumerator :: SpmDriverGraph = 6 + enumerator :: SpmDriverSPM = 7 + end enum + + ! enum rhstype + enum, bind(C) + enumerator :: SpmRhsOne = 0 + enumerator :: SpmRhsI = 1 + enumerator :: SpmRhsRndX = 2 + enumerator :: SpmRhsRndB = 3 + end enum + + ! enum layout + enum, bind(C) + enumerator :: SpmRowMajor = 101 + enumerator :: SpmColMajor = 102 + end enum + + ! enum trans + enum, bind(C) + enumerator :: SpmNoTrans = 111 + enumerator :: SpmTrans = 112 + enumerator :: SpmConjTrans = 113 + end enum + + ! enum mtxtype + enum, bind(C) + enumerator :: SpmGeneral = SpmNoTrans + enumerator :: SpmSymmetric = SpmTrans + enumerator :: SpmHermitian = SpmConjTrans + end enum + + ! enum uplo + enum, bind(C) + enumerator :: SpmUpper = 121 + enumerator :: SpmLower = 122 + enumerator :: SpmUpperLower = 123 + end enum + + ! enum diag + enum, bind(C) + enumerator :: SpmNonUnit = 131 + enumerator :: SpmUnit = 132 + end enum + + ! enum side + enum, bind(C) + enumerator :: SpmLeft = 141 + enumerator :: SpmRight = 142 + end enum + + ! enum normtype + enum, bind(C) + enumerator :: SpmOneNorm = 171 + enumerator :: SpmFrobeniusNorm = 174 + enumerator :: SpmInfNorm = 175 + enumerator :: SpmMaxNorm = 177 + end enum + + ! enum dir + enum, bind(C) + enumerator :: SpmDirForward = 391 + enumerator :: SpmDirBackward = 392 + end enum + + + integer, parameter :: spm_int_t = SPM_INT_KIND + +contains + + function spm_getintsize() + integer :: spm_getintsize + spm_getintsize = SPM_INT_KIND + return + end function spm_getintsize + +end module spm_enums diff --git a/wrappers/fortran90/src/spmf.f90 b/wrappers/fortran90/src/spmf.f90 new file mode 100644 index 0000000000000000000000000000000000000000..2b552dd50832ba8ff1fc45c23d0162eb1504fa6d --- /dev/null +++ b/wrappers/fortran90/src/spmf.f90 @@ -0,0 +1,711 @@ + +! +! @file spmf.f90 +! +! SPM Fortran 90 wrapper +! +! @copyright 2017 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, +! Univ. Bordeaux. All rights reserved. +! +! @version 6.0.0 +! @author Mathieu Faverge +! @date 2017-01-01 +! +! This file has been automatically generated with gen_wrappers.py +! +module spmf + use iso_c_binding + use spm_enums + implicit none + + type, bind(c) :: spmatrix_t + integer(c_int) :: mtxtype + integer(c_int) :: flttype + integer(c_int) :: fmttype + integer(kind=spm_int_t) :: gN + integer(kind=spm_int_t) :: n + integer(kind=spm_int_t) :: gnnz + integer(kind=spm_int_t) :: nnz + integer(kind=spm_int_t) :: gNexp + integer(kind=spm_int_t) :: nexp + integer(kind=spm_int_t) :: gnnzexp + integer(kind=spm_int_t) :: nnzexp + integer(kind=spm_int_t) :: dof + type(c_ptr) :: dofs + integer(c_int) :: layout + type(c_ptr) :: colptr + type(c_ptr) :: rowptr + type(c_ptr) :: loc2glob + type(c_ptr) :: values + end type spmatrix_t + + interface + subroutine spmInit_c(spm) & + bind(c, name='spmInit') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + end subroutine spmInit_c + end interface + + interface + subroutine spmExit_c(spm) & + bind(c, name='spmExit') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + end subroutine spmExit_c + end interface + + interface + function spmCopy_c(spm) & + bind(c, name='spmCopy') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr) :: spmCopy_c + type(c_ptr), value :: spm + end function spmCopy_c + end interface + + interface + subroutine spmBase_c(spm, baseval) & + bind(c, name='spmBase') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + integer(kind=c_int), value :: baseval + end subroutine spmBase_c + end interface + + interface + function spmFindBase_c(spm) & + bind(c, name='spmFindBase') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=spm_int_t) :: spmFindBase_c + type(c_ptr), value :: spm + end function spmFindBase_c + end interface + + interface + function spmConvert_c(ofmttype, ospm) & + bind(c, name='spmConvert') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmConvert_c + integer(kind=c_int), value :: ofmttype + type(c_ptr), value :: ospm + end function spmConvert_c + end interface + + interface + subroutine spmUpdateComputedFields_c(spm) & + bind(c, name='spmUpdateComputedFields') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + end subroutine spmUpdateComputedFields_c + end interface + + interface + subroutine spmGenFakeValues_c(spm) & + bind(c, name='spmGenFakeValues') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + end subroutine spmGenFakeValues_c + end interface + + interface + function spmNorm_c(ntype, spm) & + bind(c, name='spmNorm') + use iso_c_binding + import spmatrix_t + implicit none + real(kind=c_double) :: spmNorm_c + integer(c_int), value :: ntype + type(c_ptr), value :: spm + end function spmNorm_c + end interface + + interface + function spmMatVec_c(trans, alpha, spm, x, beta, y) & + bind(c, name='spmMatVec') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmMatVec_c + integer(c_int), value :: trans + type(c_ptr), value :: alpha + type(c_ptr), value :: spm + type(c_ptr), value :: x + type(c_ptr), value :: beta + type(c_ptr), value :: y + end function spmMatVec_c + end interface + + interface + function spmMatMat_c(trans, n, alpha, A, B, ldb, beta, C, ldc) & + bind(c, name='spmMatMat') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=c_int) :: spmMatMat_c + integer(c_int), value :: trans + integer(kind=spm_int_t), value :: n + type(c_ptr), value :: alpha + type(c_ptr), value :: A + type(c_ptr), value :: B + integer(kind=spm_int_t), value :: ldb + type(c_ptr), value :: beta + type(c_ptr), value :: C + integer(kind=spm_int_t), value :: ldc + end function spmMatMat_c + end interface + + interface + subroutine spmScalMatrix_c(alpha, spm) & + bind(c, name='spmScalMatrix') + use iso_c_binding + import spmatrix_t + implicit none + real(kind=c_double), value :: alpha + type(c_ptr), value :: spm + end subroutine spmScalMatrix_c + end interface + + interface + subroutine spmScalVector_c(flt, alpha, n, x, incx) & + bind(c, name='spmScalVector') + use iso_c_binding + import spm_int_t + implicit none + integer(c_int), value :: flt + real(kind=c_double), value :: alpha + integer(kind=spm_int_t), value :: n + type(c_ptr), value :: x + integer(kind=spm_int_t), value :: incx + end subroutine spmScalVector_c + end interface + + interface + function spmSort_c(spm) & + bind(c, name='spmSort') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmSort_c + type(c_ptr), value :: spm + end function spmSort_c + end interface + + interface + function spmMergeDuplicate_c(spm) & + bind(c, name='spmMergeDuplicate') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=spm_int_t) :: spmMergeDuplicate_c + type(c_ptr), value :: spm + end function spmMergeDuplicate_c + end interface + + interface + function spmSymmetrize_c(spm) & + bind(c, name='spmSymmetrize') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=spm_int_t) :: spmSymmetrize_c + type(c_ptr), value :: spm + end function spmSymmetrize_c + end interface + + interface + function spmCheckAndCorrect_c(spm) & + bind(c, name='spmCheckAndCorrect') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr) :: spmCheckAndCorrect_c + type(c_ptr), value :: spm + end function spmCheckAndCorrect_c + end interface + + interface + function spmGenRHS_c(type, nrhs, spm, x, ldx, b, ldb) & + bind(c, name='spmGenRHS') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=c_int) :: spmGenRHS_c + integer(c_int), value :: type + integer(kind=spm_int_t), value :: nrhs + type(c_ptr), value :: spm + type(c_ptr), value :: x + integer(kind=spm_int_t), value :: ldx + type(c_ptr), value :: b + integer(kind=spm_int_t), value :: ldb + end function spmGenRHS_c + end interface + + interface + function spmCheckAxb_c(eps, nrhs, spm, x0, ldx0, b, ldb, x, ldx) & + bind(c, name='spmCheckAxb') + use iso_c_binding + import spm_int_t + import spmatrix_t + implicit none + integer(kind=c_int) :: spmCheckAxb_c + real(kind=c_double), value :: eps + integer(kind=spm_int_t), value :: nrhs + type(c_ptr), value :: spm + type(c_ptr), value :: x0 + integer(kind=spm_int_t), value :: ldx0 + type(c_ptr), value :: b + integer(kind=spm_int_t), value :: ldb + type(c_ptr), value :: x + integer(kind=spm_int_t), value :: ldx + end function spmCheckAxb_c + end interface + + interface + function spmIntConvert_c(n, input) & + bind(c, name='spmIntConvert') + use iso_c_binding + import spm_int_t + implicit none + type(c_ptr) :: spmIntConvert_c + integer(kind=spm_int_t), value :: n + type(c_ptr), value :: input + end function spmIntConvert_c + end interface + + interface + function spmLoad_c(spm, infile) & + bind(c, name='spmLoad') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmLoad_c + type(c_ptr), value :: spm + type(c_ptr), value :: infile + end function spmLoad_c + end interface + + interface + function spmSave_c(spm, outfile) & + bind(c, name='spmSave') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmSave_c + type(c_ptr), value :: spm + type(c_ptr), value :: outfile + end function spmSave_c + end interface + + interface + function spmReadDriver_c(driver, filename, spm) & + bind(c, name='spmReadDriver') + use iso_c_binding + import spmatrix_t + implicit none + integer(kind=c_int) :: spmReadDriver_c + integer(c_int), value :: driver + type(c_ptr), value :: filename + type(c_ptr), value :: spm + end function spmReadDriver_c + end interface + + interface + function spmParseLaplacianInfo_c(filename, flttype, dim1, dim2, dim3, & + alpha, beta) & + bind(c, name='spmParseLaplacianInfo') + use iso_c_binding + import spm_int_t + implicit none + integer(kind=c_int) :: spmParseLaplacianInfo_c + type(c_ptr), value :: filename + type(c_ptr), value :: flttype + type(c_ptr), value :: dim1 + type(c_ptr), value :: dim2 + type(c_ptr), value :: dim3 + type(c_ptr), value :: alpha + type(c_ptr), value :: beta + end function spmParseLaplacianInfo_c + end interface + + interface + subroutine spm2Dense_c(spm) & + bind(c, name='spm2Dense') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + end subroutine spm2Dense_c + end interface + + interface + subroutine spmPrint_c(spm, f) & + bind(c, name='spmPrint') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + type(c_ptr), value :: f + end subroutine spmPrint_c + end interface + + interface + subroutine spmPrintInfo_c(spm, f) & + bind(c, name='spmPrintInfo') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr), value :: spm + type(c_ptr), value :: f + end subroutine spmPrintInfo_c + end interface + + interface + function spmExpand_c(spm) & + bind(c, name='spmExpand') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr) :: spmExpand_c + type(c_ptr), value :: spm + end function spmExpand_c + end interface + + interface + function spmDofExtend_c(spm, type, dof) & + bind(c, name='spmDofExtend') + use iso_c_binding + import spmatrix_t + implicit none + type(c_ptr) :: spmDofExtend_c + type(c_ptr), value :: spm + integer(kind=c_int), value :: type + integer(kind=c_int), value :: dof + end function spmDofExtend_c + end interface + +contains + + ! Wrappers of the C functions. + subroutine spmInit(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + + call spmInit_c(c_loc(spm)) + end subroutine spmInit + + subroutine spmExit(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + + call spmExit_c(c_loc(spm)) + end subroutine spmExit + + subroutine spmCopy(spm, spmo) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + type(spmatrix_t), intent(out), pointer :: spmo + + call c_f_pointer(spmCopy_c(c_loc(spm)), spmo) + end subroutine spmCopy + + subroutine spmBase(spm, baseval) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + integer(kind=c_int), intent(in) :: baseval + + call spmBase_c(c_loc(spm), baseval) + end subroutine spmBase + + subroutine spmFindBase(spm, value) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + integer(kind=spm_int_t), intent(out) :: value + + value = spmFindBase_c(c_loc(spm)) + end subroutine spmFindBase + + subroutine spmConvert(ofmttype, ospm, info) + use iso_c_binding + implicit none + integer(kind=c_int), intent(in) :: ofmttype + type(spmatrix_t), intent(inout), target :: ospm + integer(kind=c_int), intent(out) :: info + + info = spmConvert_c(ofmttype, c_loc(ospm)) + end subroutine spmConvert + + subroutine spmUpdateComputedFields(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + + call spmUpdateComputedFields_c(c_loc(spm)) + end subroutine spmUpdateComputedFields + + subroutine spmGenFakeValues(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + + call spmGenFakeValues_c(c_loc(spm)) + end subroutine spmGenFakeValues + + subroutine spmNorm(ntype, spm, value) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: ntype + type(spmatrix_t), intent(in), target :: spm + real(kind=c_double), intent(out) :: value + + value = spmNorm_c(ntype, c_loc(spm)) + end subroutine spmNorm + + subroutine spmMatVec(trans, alpha, spm, x, beta, y, info) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: trans + type(c_ptr), intent(in), target :: alpha + type(spmatrix_t), intent(in), target :: spm + type(c_ptr), intent(in), target :: x + type(c_ptr), intent(in), target :: beta + type(c_ptr), intent(inout), target :: y + integer(kind=c_int), intent(out) :: info + + info = spmMatVec_c(trans, alpha, c_loc(spm), x, beta, y) + end subroutine spmMatVec + + subroutine spmMatMat(trans, n, alpha, A, B, ldb, beta, C, ldc, info) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: trans + integer(kind=spm_int_t), intent(in) :: n + type(c_ptr), intent(in), target :: alpha + type(spmatrix_t), intent(in), target :: A + type(c_ptr), intent(in), target :: B + integer(kind=spm_int_t), intent(in) :: ldb + type(c_ptr), intent(in), target :: beta + type(c_ptr), intent(inout), target :: C + integer(kind=spm_int_t), intent(in) :: ldc + integer(kind=c_int), intent(out) :: info + + info = spmMatMat_c(trans, n, alpha, c_loc(A), B, ldb, beta, C, ldc) + end subroutine spmMatMat + + subroutine spmScalMatrix(alpha, spm) + use iso_c_binding + implicit none + real(kind=c_double), intent(in) :: alpha + type(spmatrix_t), intent(inout), target :: spm + + call spmScalMatrix_c(alpha, c_loc(spm)) + end subroutine spmScalMatrix + + subroutine spmScalVector(flt, alpha, n, x, incx) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: flt + real(kind=c_double), intent(in) :: alpha + integer(kind=spm_int_t), intent(in) :: n + type(c_ptr), intent(inout), target :: x + integer(kind=spm_int_t), intent(in) :: incx + + call spmScalVector_c(flt, alpha, n, x, incx) + end subroutine spmScalVector + + subroutine spmSort(spm, info) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + integer(kind=c_int), intent(out) :: info + + info = spmSort_c(c_loc(spm)) + end subroutine spmSort + + subroutine spmMergeDuplicate(spm, value) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + integer(kind=spm_int_t), intent(out) :: value + + value = spmMergeDuplicate_c(c_loc(spm)) + end subroutine spmMergeDuplicate + + subroutine spmSymmetrize(spm, value) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + integer(kind=spm_int_t), intent(out) :: value + + value = spmSymmetrize_c(c_loc(spm)) + end subroutine spmSymmetrize + + subroutine spmCheckAndCorrect(spm, spmo) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + type(spmatrix_t), intent(out), pointer :: spmo + + call c_f_pointer(spmCheckAndCorrect_c(c_loc(spm)), spmo) + end subroutine spmCheckAndCorrect + + subroutine spmGenRHS(type, nrhs, spm, x, ldx, b, ldb, info) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: type + integer(kind=spm_int_t), intent(in) :: nrhs + type(spmatrix_t), intent(in), target :: spm + type(c_ptr), intent(inout), target :: x + integer(kind=spm_int_t), intent(in) :: ldx + type(c_ptr), intent(inout), target :: b + integer(kind=spm_int_t), intent(in) :: ldb + integer(kind=c_int), intent(out) :: info + + info = spmGenRHS_c(type, nrhs, c_loc(spm), x, ldx, b, ldb) + end subroutine spmGenRHS + + subroutine spmCheckAxb(eps, nrhs, spm, x0, ldx0, b, ldb, x, ldx, info) + use iso_c_binding + implicit none + real(kind=c_double), intent(in) :: eps + integer(kind=spm_int_t), intent(in) :: nrhs + type(spmatrix_t), intent(in), target :: spm + type(c_ptr), intent(inout), target :: x0 + integer(kind=spm_int_t), intent(in) :: ldx0 + type(c_ptr), intent(inout), target :: b + integer(kind=spm_int_t), intent(in) :: ldb + type(c_ptr), intent(in), target :: x + integer(kind=spm_int_t), intent(in) :: ldx + integer(kind=c_int), intent(out) :: info + + info = spmCheckAxb_c(eps, nrhs, c_loc(spm), x0, ldx0, b, ldb, x, ldx) + end subroutine spmCheckAxb + + subroutine spmIntConvert(n, input, value) + use iso_c_binding + implicit none + integer(kind=spm_int_t), intent(in) :: n + integer(kind=c_int), intent(inout), target :: input + integer(kind=spm_int_t), intent(out), pointer :: value + + call c_f_pointer(spmIntConvert_c(n, c_loc(input)), value) + end subroutine spmIntConvert + + subroutine spmLoad(spm, info) + use iso_c_binding + implicit none + type(spmatrix_t), intent(inout), target :: spm + integer(kind=c_int), intent(out) :: info + + info = spmLoad_c(c_loc(spm), c_null_ptr) + end subroutine spmLoad + + subroutine spmSave(spm, info) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + integer(kind=c_int), intent(out) :: info + + info = spmSave_c(c_loc(spm), c_null_ptr) + end subroutine spmSave + + subroutine spmReadDriver(driver, filename, spm, info) + use iso_c_binding + implicit none + integer(c_int), intent(in) :: driver + character(kind=c_char), intent(in), target :: filename + type(spmatrix_t), intent(inout), target :: spm + integer(kind=c_int), intent(out) :: info + + info = spmReadDriver_c(driver, c_loc(filename), c_loc(spm)) + end subroutine spmReadDriver + + subroutine spmParseLaplacianInfo(filename, flttype, dim1, dim2, dim3, alpha, & + beta, info) + use iso_c_binding + implicit none + character(kind=c_char), intent(in), target :: filename + integer(c_int), intent(inout), target :: flttype + integer(kind=spm_int_t), intent(inout), target :: dim1 + integer(kind=spm_int_t), intent(inout), target :: dim2 + integer(kind=spm_int_t), intent(inout), target :: dim3 + real(kind=c_double), intent(inout), target :: alpha + real(kind=c_double), intent(inout), target :: beta + integer(kind=c_int), intent(out) :: info + + info = spmParseLaplacianInfo_c(c_loc(filename), c_loc(flttype), & + c_loc(dim1), c_loc(dim2), c_loc(dim3), c_loc(alpha), c_loc(beta)) + end subroutine spmParseLaplacianInfo + + subroutine spm2Dense(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + + call spm2Dense_c(c_loc(spm)) + end subroutine spm2Dense + + subroutine spmPrint(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + + call spmPrint_c(c_loc(spm), c_null_ptr) + end subroutine spmPrint + + subroutine spmPrintInfo(spm) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + + call spmPrintInfo_c(c_loc(spm), c_null_ptr) + end subroutine spmPrintInfo + + subroutine spmExpand(spm, spmo) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + type(spmatrix_t), intent(out), pointer :: spmo + + call c_f_pointer(spmExpand_c(c_loc(spm)), spmo) + end subroutine spmExpand + + subroutine spmDofExtend(spm, type, dof, spmo) + use iso_c_binding + implicit none + type(spmatrix_t), intent(in), target :: spm + integer(kind=c_int), intent(in) :: type + integer(kind=c_int), intent(in) :: dof + type(spmatrix_t), intent(out), pointer :: spmo + + call c_f_pointer(spmDofExtend_c(c_loc(spm), type, dof), spmo) + end subroutine spmDofExtend + + +end module spmf diff --git a/wrappers/python/spm/__spm__.py b/wrappers/python/spm/__spm__.py index 02e151fac67d3762bc45bcb1348c9b68ca5809ea..a575b2f7ec77c7a9aeded96b868280a4bd27d25c 100644 --- a/wrappers/python/spm/__spm__.py +++ b/wrappers/python/spm/__spm__.py @@ -143,10 +143,6 @@ def pyspm_spmIntConvert( n, input ): libspm.spmIntConvert.restype = POINTER(__spm_int__) return libspm.spmIntConvert( n, input ) -def pyspm_spmIntMSortIntAsc( pbase, n ): - libspm.spmIntMSortIntAsc.argtypes = [ c_void_p, __spm_int__ ] - libspm.spmIntMSortIntAsc( pointer( pbase ), n ) - def pyspm_spmLoad( spm ): libspm.spmLoad.argtypes = [ POINTER(pyspm_spmatrix_t), c_void_p ] libspm.spmLoad.restype = c_int