Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion slycot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ set(FSOURCES
src/delctg.f src/select.f
src/SLCT_DLATZM.f src/SLCT_ZLATZM.f

src/ftruefalse.f
src/ftruefalse.f src/XERBLA.f
)

set(F2PYSOURCE src/_wrapper.pyf)
Expand Down
5 changes: 5 additions & 0 deletions slycot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@
# Version information
from .version import version as __version__

# initialize error handling
from .exceptions import raise_xerbla
from . import _wrapper
_wrapper.raise_xerbla = raise_xerbla

from numpy.testing import Tester
test = Tester().test
bench = Tester().bench
8 changes: 8 additions & 0 deletions slycot/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,3 +257,11 @@ def raise_if_slycot_error(info, arg_list=None, docstring=None, checkvars=None):
warn(SlycotWarning("Caught unhandled nonzero IWARN value {}"
"".format(iwarn),
iwarn, info))


def raise_xerbla(srname, info):
"""Overrides LAPACK XERBLA routine to raise Exception instead of exiting
"""
message = ("The argument number {1} to {0} had an illegal value."
"".format(srname, -info))
raise SlycotParameterError(message, info)
19 changes: 19 additions & 0 deletions slycot/src/XERBLA.f
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
SUBROUTINE XERBLA(SRNAME, INFO)
C
C SLYCOT
C Override LAPACK XERBLA routine to raise Python Exception instead of
C exiting the process
C
CF2PY INTENT(CALLBACK, HIDE) RAISE_XERBLA
C
CHARACTER*(*) SRNAME
INTEGER INFO
C
EXTERNAL RAISE_XERBLA
C
CALL RAISE_XERBLA(SRNAME, INFO)
C
RETURN
C
END
C
9 changes: 7 additions & 2 deletions slycot/src/_helper.pyf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@ subroutine ftruefalse(ftrue,ffalse) ! in src/ftruefalse.f
logical intent(out) :: ffalse
end subroutine ftruefalse

! This file was auto-generated with f2py (version:2).
! See http://cens.ioc.ee/projects/f2py2e/
subroutine xerbla(srname,info) ! in src/XERBLA.f
use __user__routines
character*(*) :: srname
integer :: info
intent(callback) raise_xerbla
external raise_xerbla
end subroutine xerbla
25 changes: 18 additions & 7 deletions slycot/src/_wrapper.pyf
Original file line number Diff line number Diff line change
@@ -1,12 +1,23 @@
! -*- f90 -*-
! Note: the context of this file is case sensitive.

python module _wrapper ! in
interface ! in :wrapper
include "analysis.pyf"
include "math.pyf"
include "synthesis.pyf"
include "transform.pyf"
include "_helper.pyf"
python module __user__routines
interface
subroutine raise_xerbla(srname,info)
intent(callback,hide) raise_xerbla
character*(*) :: srname
integer :: info
end subroutine raise_xerbla
end interface
end python module __user__routines

python module _wrapper
interface
include "analysis.pyf"
include "math.pyf"
include "synthesis.pyf"
include "transform.pyf"
include "_helper.pyf"
end interface
end python module slycot