Commit 81dffa8c authored by Jorn Bruggeman's avatar Jorn Bruggeman
Browse files

python driver: introduced get_error_state to handle stop

parent bbb6221b
......@@ -56,6 +56,8 @@ fabm.get_model_metadata.argtypes = [ctypes.c_char_p,ctypes.c_int,ctypes.c_char_p
fabm.get_model_metadata.restype = None
fabm.get_coupling.argtypes = [ctypes.c_int,ctypes.POINTER(ctypes.c_void_p),ctypes.POINTER(ctypes.c_void_p)]
fabm.get_coupling.restype = None
fabm.get_error_state.argtypes = []
fabm.get_error_state.restype = ctypes.c_int
# Read access to variable attributes
fabm.variable_get_metadata.argtypes = [ctypes.c_void_p,ctypes.c_int,ctypes.c_char_p,ctypes.c_char_p,ctypes.c_char_p]
......@@ -167,6 +169,9 @@ def createPrettyUnit(unit):
#unit = oldsupminus.sub(reploldminus,unit)
return unit
def hasError():
return fabm.get_error_state() != 0
def printTree(root,stringmapper,indent=''):
"""Print an indented tree of objects, encoded by dictionaries linking the names of children to
their subtree, or to their object. Objects are finally printed as string obtained by
......
......@@ -41,6 +41,7 @@
integer :: index_column_depth
real(c_double),pointer :: column_depth
type (type_link_list),save :: coupling_link_list
logical, save :: error_occurred = .false.
type (type_property_dictionary),save,private :: forced_parameters,forced_couplings
......@@ -188,6 +189,11 @@
call fabm_check_ready(model)
end subroutine check_ready
integer(c_int) function get_error_state() bind(c)
!DIR$ ATTRIBUTES DLLEXPORT :: get_error_state
get_error_state = logical2int(error_occurred)
end function get_error_state
integer(c_int) function model_count() bind(c)
!DIR$ ATTRIBUTES DLLEXPORT :: model_count
......@@ -592,8 +598,9 @@
class (type_python_driver),intent(inout) :: self
character(len=*), intent(in) :: location,message
error_occurred = .true.
write (*,*) trim(location)//': '//trim(message)
stop 1
!stop 1
end subroutine python_driver_fatal_error
subroutine python_driver_log_message(self,message)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment