better use SIGINT for actions triggered by the user

SIGTERM is send by MPI if one process fails, catching it results in
deadlocks
This commit is contained in:
Martin Diehl 2022-05-12 16:45:42 +02:00
parent 0b6ead1a48
commit 3f85027b9e
5 changed files with 19 additions and 19 deletions

@ -1 +1 @@
Subproject commit 3561f74a5852c32e2c3da4dc48090b517cfa8e90 Subproject commit df33ba9a1360439c5c18a241a1e439dab0cdcafd

View File

@ -58,8 +58,8 @@ void getusername_c(char username[], int *stat){
} }
void signalterm_c(void (*handler)(int)){ void signalint_c(void (*handler)(int)){
signal(SIGTERM, handler); signal(SIGINT, handler);
} }
void signalusr1_c(void (*handler)(int)){ void signalusr1_c(void (*handler)(int)){

View File

@ -471,7 +471,7 @@ program DAMASK_grid
call materialpoint_restartWrite call materialpoint_restartWrite
endif endif
if (signal) call signals_setSIGUSR2(.false.) if (signal) call signals_setSIGUSR2(.false.)
call MPI_Allreduce(signals_SIGTERM,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) call MPI_Allreduce(signals_SIGINT,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI)
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error' if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
if (signal) exit loadCaseLooping if (signal) exit loadCaseLooping
endif skipping endif skipping

View File

@ -10,13 +10,13 @@ module signals
private private
logical, volatile, public, protected :: & logical, volatile, public, protected :: &
signals_SIGTERM = .false., & !< termination signal signals_SIGINT = .false., & !< interrupt signal
signals_SIGUSR1 = .false., & !< 1. user-defined signal signals_SIGUSR1 = .false., & !< 1. user-defined signal
signals_SIGUSR2 = .false. !< 2. user-defined signal signals_SIGUSR2 = .false. !< 2. user-defined signal
public :: & public :: &
signals_init, & signals_init, &
signals_setSIGTERM, & signals_setSIGINT, &
signals_setSIGUSR1, & signals_setSIGUSR1, &
signals_setSIGUSR2 signals_setSIGUSR2
@ -28,7 +28,7 @@ contains
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine signals_init() subroutine signals_init()
call signalterm_c(c_funloc(catchSIGTERM)) call signalint_c(c_funloc(catchSIGINT))
call signalusr1_c(c_funloc(catchSIGUSR1)) call signalusr1_c(c_funloc(catchSIGUSR1))
call signalusr2_c(c_funloc(catchSIGUSR2)) call signalusr2_c(c_funloc(catchSIGUSR2))
@ -36,18 +36,18 @@ end subroutine signals_init
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Set global variable signals_SIGTERM to .true. !> @brief Set global variable signals_SIGINT to .true.
!> @details This function can be registered to catch signals send to the executable. !> @details This function can be registered to catch signals send to the executable.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine catchSIGTERM(signal) bind(C) subroutine catchSIGINT(signal) bind(C)
integer(C_INT), value :: signal integer(C_INT), value :: signal
print'(a,i0)', ' received signal ',signal print'(a,i0)', ' received signal ',signal
call signals_setSIGTERM(.true.) call signals_setSIGINT(.true.)
end subroutine catchSIGTERM end subroutine catchSIGINT
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
@ -81,17 +81,17 @@ end subroutine catchSIGUSR2
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Set global variable signals_SIGTERM. !> @brief Set global variable signals_SIGINT.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine signals_setSIGTERM(state) subroutine signals_setSIGINT(state)
logical, intent(in) :: state logical, intent(in) :: state
signals_SIGTERM = state signals_SIGINT = state
print*, 'set SIGTERM to',state print*, 'set SIGINT to',state
end subroutine signals_setSIGTERM end subroutine signals_setSIGINT
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------

View File

@ -15,7 +15,7 @@ module system_routines
getCWD, & getCWD, &
getHostName, & getHostName, &
getUserName, & getUserName, &
signalterm_C, & signalint_C, &
signalusr1_C, & signalusr1_C, &
signalusr2_C, & signalusr2_C, &
f_c_string, & f_c_string, &
@ -55,11 +55,11 @@ module system_routines
integer(C_INT), intent(out) :: stat integer(C_INT), intent(out) :: stat
end subroutine getUserName_C end subroutine getUserName_C
subroutine signalterm_C(handler) bind(C) subroutine signalint_C(handler) bind(C)
use, intrinsic :: ISO_C_Binding, only: C_FUNPTR use, intrinsic :: ISO_C_Binding, only: C_FUNPTR
type(C_FUNPTR), intent(in), value :: handler type(C_FUNPTR), intent(in), value :: handler
end subroutine signalterm_C end subroutine signalint_C
subroutine signalusr1_C(handler) bind(C) subroutine signalusr1_C(handler) bind(C)
use, intrinsic :: ISO_C_Binding, only: C_FUNPTR use, intrinsic :: ISO_C_Binding, only: C_FUNPTR