diff --git a/PRIVATE b/PRIVATE index 3ab1053b8..72661176e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 3ab1053b8c83248dc8654a22a3caea815c0813db +Subproject commit 72661176e9055cf6ec106bb61c50482c5bc78de8 diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index c43e354a2..ab64dcf01 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -199,7 +199,7 @@ subroutine DAMASK_interface_init if (interface_restartInc > 0) & print'(a,i6.6)', ' Restart from increment: ', interface_restartInc - !call signalterm_c(c_funloc(catchSIGTERM)) + call signalterm_c(c_funloc(catchSIGTERM)) call signalusr1_c(c_funloc(catchSIGUSR1)) call signalusr2_c(c_funloc(catchSIGUSR2)) call interface_setSIGTERM(.false.) @@ -386,24 +386,14 @@ end function makeRelativePath subroutine catchSIGTERM(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0)', ' received signal ',signal call interface_setSIGTERM(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGTERM=TRUE' - end subroutine catchSIGTERM -!-------------------------------------------------------------------------------------------------- -!> @brief Set global variable interface_SIGTERM. -!-------------------------------------------------------------------------------------------------- -subroutine interface_setSIGTERM(state) - - logical, intent(in) :: state - interface_SIGTERM = state - -end subroutine interface_setSIGTERM - - !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR1 to .true. !> @details This function can be registered to catch signals send to the executable. @@ -411,24 +401,14 @@ end subroutine interface_setSIGTERM subroutine catchSIGUSR1(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0)', ' received signal ',signal call interface_setSIGUSR1(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGUSR1=TRUE' - end subroutine catchSIGUSR1 -!-------------------------------------------------------------------------------------------------- -!> @brief Set global variable interface_SIGUSR. -!-------------------------------------------------------------------------------------------------- -subroutine interface_setSIGUSR1(state) - - logical, intent(in) :: state - interface_SIGUSR1 = state - -end subroutine interface_setSIGUSR1 - - !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR2 to .true. !> @details This function can be registered to catch signals send to the executable. @@ -436,20 +416,52 @@ end subroutine interface_setSIGUSR1 subroutine catchSIGUSR2(signal) bind(C) integer(C_INT), value :: signal + + + print'(a,i0,a)', ' received signal ',signal call interface_setSIGUSR2(.true.) - print'(a,i0,a)', ' received signal ',signal, ', set SIGUSR2=TRUE' - end subroutine catchSIGUSR2 +!-------------------------------------------------------------------------------------------------- +!> @brief Set global variable interface_SIGTERM. +!-------------------------------------------------------------------------------------------------- +subroutine interface_setSIGTERM(state) + + logical, intent(in) :: state + + + interface_SIGTERM = state + print*, 'set SIGTERM to',state + +end subroutine interface_setSIGTERM + + +!-------------------------------------------------------------------------------------------------- +!> @brief Set global variable interface_SIGUSR. +!-------------------------------------------------------------------------------------------------- +subroutine interface_setSIGUSR1(state) + + logical, intent(in) :: state + + + interface_SIGUSR1 = state + print*, 'set SIGUSR1 to',state + +end subroutine interface_setSIGUSR1 + + !-------------------------------------------------------------------------------------------------- !> @brief Set global variable interface_SIGUSR2. !-------------------------------------------------------------------------------------------------- subroutine interface_setSIGUSR2(state) logical, intent(in) :: state + + interface_SIGUSR2 = state + print*, 'set SIGUSR2 to',state end subroutine interface_setSIGUSR2 diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 514443dbb..02d7b4cc3 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -61,10 +61,12 @@ program DAMASK_grid logical :: & guess, & !< guess along former trajectory stagIterate, & - cutBack = .false. + cutBack = .false.,& + signal integer :: & i, j, m, field, & errorID = 0, & + ierr,& cutBackLevel = 0, & !< cut back level \f$ t = \frac{t_{inc}}{2^l} \f$ stepFraction = 0, & !< fraction of current time interval l = 0, & !< current load case @@ -449,18 +451,27 @@ program DAMASK_grid print'(/,a,i0,a)', ' increment ', totalIncsCounter, ' NOT converged' endif; flush(IO_STDOUT) - if (mod(inc,loadCases(l)%f_out) == 0) then + call MPI_Allreduce(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' + if (mod(inc,loadCases(l)%f_out) == 0 .or. signal) then print'(1/,a)', ' ... writing results to file ......................................' flush(IO_STDOUT) call CPFEM_results(totalIncsCounter,time) endif - if (mod(inc,loadCases(l)%f_restart) == 0) then + if(signal) call interface_setSIGUSR1(.false.) + call MPI_Allreduce(interface_SIGUSR2,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' + if (mod(inc,loadCases(l)%f_restart) == 0 .or. signal) then call mech_restartWrite call CPFEM_restartWrite endif + if(signal) call interface_setSIGUSR2(.false.) + call MPI_Allreduce(interface_SIGTERM,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) + if (ierr /= 0) error stop 'MPI error' + if (signal) exit loadCaseLooping endif skipping - enddo incLooping + enddo incLooping enddo loadCaseLooping