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)){
signal(SIGTERM, handler);
void signalint_c(void (*handler)(int)){
signal(SIGINT, handler);
}
void signalusr1_c(void (*handler)(int)){

View File

@ -471,7 +471,7 @@ program DAMASK_grid
call materialpoint_restartWrite
endif
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 (signal) exit loadCaseLooping
endif skipping

View File

@ -10,13 +10,13 @@ module signals
private
logical, volatile, public, protected :: &
signals_SIGTERM = .false., & !< termination signal
signals_SIGINT = .false., & !< interrupt signal
signals_SIGUSR1 = .false., & !< 1. user-defined signal
signals_SIGUSR2 = .false. !< 2. user-defined signal
public :: &
signals_init, &
signals_setSIGTERM, &
signals_setSIGINT, &
signals_setSIGUSR1, &
signals_setSIGUSR2
@ -28,7 +28,7 @@ contains
!--------------------------------------------------------------------------------------------------
subroutine signals_init()
call signalterm_c(c_funloc(catchSIGTERM))
call signalint_c(c_funloc(catchSIGINT))
call signalusr1_c(c_funloc(catchSIGUSR1))
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.
!--------------------------------------------------------------------------------------------------
subroutine catchSIGTERM(signal) bind(C)
subroutine catchSIGINT(signal) bind(C)
integer(C_INT), value :: 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
signals_SIGTERM = state
print*, 'set SIGTERM to',state
signals_SIGINT = state
print*, 'set SIGINT to',state
end subroutine signals_setSIGTERM
end subroutine signals_setSIGINT
!--------------------------------------------------------------------------------------------------

View File

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