Changeset 71
- Timestamp:
- May 29, 2012, 11:04:01 AM (13 years ago)
- Location:
- trunk/signal-checkpoint
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/signal-checkpoint/signal_checkpoint.F90
r70 r71 1 1 !--------------------------------------------------------------! 2 2 ! 2012/04/20 (C) Gabriel Moreau 3 ! Licence LGPLv2 or l etter3 ! Licence LGPLv2 or latter 4 4 ! $Id$ 5 5 !--------------------------------------------------------------! … … 12 12 13 13 implicit none 14 save 14 15 private 15 16 integer, external :: signal_checkpoint_trap_callback_intel_17 external :: signal_checkpoint_trap_callback_gfortran_18 16 19 17 integer, parameter :: SIGHUP = 1 ! Signal HUP … … 25 23 26 24 ! False public, only for trap procedure 27 integer, public :: INTERNAL_RECEIVED_COUNT_ = 0 ! Global Counter 28 integer, public :: INTERNAL_ERROR_ON_EXIT_ = 0 29 integer, public :: INTERNAL_SIGNAL_EXIT_ = 0 25 integer :: INTERNAL_RECEIVED_COUNT_ = 0 ! Global Counter 26 integer :: INTERNAL_ERROR_ON_EXIT_ = 0 30 27 31 28 public :: SIGHUP … … 48 45 logical, intent(in), optional :: EXIT 49 46 50 51 47 #ifdef __INTEL_COMPILER 52 48 integer :: ERR 53 49 54 50 if (present(EXIT)) then 55 INTERNAL_SIGNAL_EXIT_ = SIG_NUM 51 ERR = signal(SIG_NUM, trap_callback_intel_exit_, -1) 52 else 53 ERR = signal(SIG_NUM, trap_callback_intel_count_, -1) 56 54 end if 57 58 ERR = signal(SIG_NUM, signal_checkpoint_trap_callback_intel_, -1)59 55 #endif 60 56 … … 63 59 64 60 if (present(EXIT)) then 65 INTERNAL_SIGNAL_EXIT_ = SIG_NUM 61 call signal(SIG_NUM, trap_callback_exit_) 62 else 63 64 call signal(SIG_NUM, trap_callback_count_) 66 65 end if 67 68 call signal(SIG_NUM, signal_checkpoint_trap_callback_gfortran_)69 66 #endif 70 67 … … 76 73 logical :: IS_RECEIVED 77 74 78 IS_RECEIVED = ( INTERNAL_RECEIVED_COUNT_ > 0)75 IS_RECEIVED = ( INTERNAL_RECEIVED_COUNT_ > 0 ) 79 76 end function 80 77 … … 96 93 97 94 !--------------------------------------------------------------! 98 end module99 95 !--------------------------------------------------------------! 100 96 97 subroutine trap_callback_count_ !(SIG_NUM) 98 !integer, intent(in) :: SIG_NUM 101 99 102 !--------------------------------------------------------------!103 ! Internal trap procedure and function104 ! Must be external to be C compatible105 !--------------------------------------------------------------!106 107 subroutine signal_checkpoint_trap_callback_gfortran_ (SIG_NUM)108 use Signal_Checkpoint109 integer, intent(in) :: SIG_NUM110 111 ! print *, "SIG1 : ", SIG_NUM112 ! if (SIG_NUM == INTERNAL_SIGNAL_EXIT_) then113 ! print *, "SIG2 : ", INTERNAL_SIGNAL_EXIT_114 ! INTERNAL_ERROR_ON_EXIT_ = 1115 ! print *, "SIG3 : ", INTERNAL_SIGNAL_EXIT_116 ! end if117 100 INTERNAL_RECEIVED_COUNT_ = INTERNAL_RECEIVED_COUNT_ + 1 118 101 end subroutine … … 120 103 !--------------------------------------------------------------! 121 104 122 function signal_checkpoint_trap_callback_intel_ (SIG_NUM) result (ONE) 123 use Signal_Checkpoint 105 subroutine trap_callback_exit_ !(SIG_NUM) 106 !integer, intent(in) :: SIG_NUM 107 108 INTERNAL_ERROR_ON_EXIT_ = 1 109 call trap_callback_count_ 110 end subroutine 111 112 !--------------------------------------------------------------! 113 114 function trap_callback_intel_exit_ (SIG_NUM) result (ONE) 124 115 integer, intent(in) :: SIG_NUM 125 116 integer :: ONE 126 117 127 ! if (SIG_NUM == INTERNAL_SIGNAL_EXIT_) then 128 ! INTERNAL_ERROR_ON_EXIT_ = 1 129 ! end if 130 INTERNAL_RECEIVED_COUNT_ = INTERNAL_RECEIVED_COUNT_ + 1 118 call trap_callback_exit_ 131 119 ONE = 1 132 end 120 end function 133 121 134 122 !--------------------------------------------------------------! 123 124 function trap_callback_intel_count_ (SIG_NUM) result (ONE) 125 integer, intent(in) :: SIG_NUM 126 integer :: ONE 127 128 call trap_callback_count_ 129 ONE = 1 130 end function 131 135 132 !--------------------------------------------------------------! 133 end module 134 !--------------------------------------------------------------! -
trunk/signal-checkpoint/test_sgck1.f90
r70 r71 36 36 37 37 if (signal_checkpoint_ask_for_exit_code()) then 38 stop 1 38 print *, "stop with exit code 1" 39 stop 1 39 40 end if 40 41 end program
Note: See TracChangeset
for help on using the changeset viewer.