From a2b5178b4535028e9aafd9c9f3cefe9954a33ea2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 17 Jan 2021 21:56:19 +0100 Subject: [PATCH] polishing --- PRIVATE | 2 +- src/DAMASK_interface.f90 | 68 +++++++++++++++++++++++----------------- src/grid/DAMASK_grid.f90 | 4 +-- 3 files changed, 43 insertions(+), 31 deletions(-) diff --git a/PRIVATE b/PRIVATE index b1a31a79c..047e5f361 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit b1a31a79cc90d458494068a96cfd3e9497aa330c +Subproject commit 047e5f3613e284a5ceb1f8b07119e8231bb94d4d diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index ffb8a0442..ab64dcf01 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -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 850ccf9e8..02d7b4cc3 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -453,19 +453,19 @@ program DAMASK_grid call MPI_Allreduce(interface_SIGUSR1,signal,1,MPI_LOGICAL,MPI_LOR,PETSC_COMM_WORLD,ierr) if (ierr /= 0) error stop 'MPI error' - call interface_setSIGUSR1(.false.) 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(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' - call interface_setSIGUSR2(.false.) 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