Merge branch 'sigint-to-quit' into 'development'
better use SIGINT for actions triggered by the user See merge request damask/DAMASK!581
This commit is contained in:
commit
c9d7cf405c
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit ede67b6488f0a0a116fe5aa8b36980d11e0f29e7
|
Subproject commit df33ba9a1360439c5c18a241a1e439dab0cdcafd
|
|
@ -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)){
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -10,13 +10,13 @@ module signals
|
||||||
private
|
private
|
||||||
|
|
||||||
logical, volatile, public, protected :: &
|
logical, volatile, public, protected :: &
|
||||||
signals_SIGTERM, & !< termination signal
|
signals_SIGINT = .false., & !< interrupt signal
|
||||||
signals_SIGUSR1, & !< 1. user-defined signal
|
signals_SIGUSR1 = .false., & !< 1. user-defined signal
|
||||||
signals_SIGUSR2 !< 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,29 +28,26 @@ 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))
|
||||||
call signals_setSIGTERM(.false.)
|
|
||||||
call signals_setSIGUSR1(.false.)
|
|
||||||
call signals_setSIGUSR2(.false.)
|
|
||||||
|
|
||||||
end subroutine signals_init
|
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
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
@ -84,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
|
||||||
|
|
||||||
|
|
||||||
!--------------------------------------------------------------------------------------------------
|
!--------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue