Skip to content
8 changes: 4 additions & 4 deletions addon/pycThermopack/thermopack/thermo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2960,7 +2960,7 @@ def bubble_temperature(self, press, z):

y = np.array(y_c)
if ierr_c.value != 0:
raise Exception("bubble_temperature calculation failed")
raise Exception(f"bubble_temperature calculation failed (exit code {ierr_c.value})")
return temp, y

def bubble_pressure(self, temp, z):
Expand Down Expand Up @@ -2998,7 +2998,7 @@ def bubble_pressure(self, temp, z):

y = np.array(y_c)
if ierr_c.value != 0:
raise Exception("bubble_pressure calculation failed")
raise Exception(f"bubble_pressure calculation failed (exit code {ierr_c.value})")
return press, y

def dew_temperature(self, press, z):
Expand Down Expand Up @@ -3036,7 +3036,7 @@ def dew_temperature(self, press, z):

x = np.array(x_c)
if ierr_c.value != 0:
raise Exception("dew_temperature calculation failed")
raise Exception(f"dew_temperature calculation failed (exit code {ierr_c.value})")
return temp, x

def dew_pressure(self, temp, z):
Expand Down Expand Up @@ -3074,7 +3074,7 @@ def dew_pressure(self, temp, z):

x = np.array(x_c)
if ierr_c.value != 0:
raise Exception("bubble_pressure calculation failed")
raise Exception(f"bubble_pressure calculation failed (exit code {ierr_c.value})")
return press, x

def get_envelope_twophase(self, initial_pressure, z, maximum_pressure=1.5e7,
Expand Down
18 changes: 18 additions & 0 deletions src/error.f90
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,21 @@ subroutine StopError(s)
endif
if (dostop) call exit(err)
end subroutine StopError

!-------------------------------------------------------
!> Take an error message and exit code, concatenate to a single
!> error message, and forward call to stoperror
!>
!> \author VGJ 2025-05-08
!-------------------------------------------------------
subroutine stoperror_with_exitcode(msg, ierr)
implicit none
character(len=*), intent(in) :: msg
integer, intent(in) :: ierr
character(len=32) :: err_str
character(len=:), allocatable :: full_msg

write(err_str, '(I0)') ierr
full_msg = trim(msg) // new_line('a') // ' Exit code: ' // trim(adjustl(err_str))
call stoperror(full_msg)
end subroutine stoperror_with_exitcode
Loading
Loading