Changeset 71


Ignore:
Timestamp:
May 29, 2012, 11:04:01 AM (12 years ago)
Author:
g7moreau
Message:
  • Add exit functional return code
Location:
trunk/signal-checkpoint
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/signal-checkpoint/signal_checkpoint.F90

    r70 r71  
    11!--------------------------------------------------------------!
    22! 2012/04/20 (C) Gabriel Moreau
    3 ! Licence LGPLv2 or letter
     3! Licence LGPLv2 or latter
    44! $Id$
    55!--------------------------------------------------------------!
     
    1212
    1313implicit none
     14save
    1415private
    15 
    16 integer, external :: signal_checkpoint_trap_callback_intel_
    17 external          :: signal_checkpoint_trap_callback_gfortran_
    1816
    1917integer, parameter :: SIGHUP  =  1  ! Signal HUP
     
    2523
    2624! 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
     25integer :: INTERNAL_RECEIVED_COUNT_ = 0  ! Global Counter
     26integer :: INTERNAL_ERROR_ON_EXIT_  = 0
    3027
    3128public :: SIGHUP
     
    4845   logical, intent(in), optional :: EXIT
    4946
    50 
    5147#ifdef __INTEL_COMPILER
    5248   integer :: ERR
    5349
    5450   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)
    5654   end if
    57 
    58    ERR = signal(SIG_NUM, signal_checkpoint_trap_callback_intel_, -1)
    5955#endif
    6056
     
    6359
    6460   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_)
    6665   end if
    67 
    68    call signal(SIG_NUM, signal_checkpoint_trap_callback_gfortran_)
    6966#endif
    7067
     
    7673   logical :: IS_RECEIVED
    7774
    78    IS_RECEIVED = (INTERNAL_RECEIVED_COUNT_ > 0)
     75   IS_RECEIVED = ( INTERNAL_RECEIVED_COUNT_ > 0 )
    7976end function
    8077
     
    9693
    9794!--------------------------------------------------------------!
    98 end module
    9995!--------------------------------------------------------------!
    10096
     97subroutine trap_callback_count_ !(SIG_NUM)
     98   !integer, intent(in) :: SIG_NUM
    10199
    102 !--------------------------------------------------------------!
    103 ! Internal trap procedure and function
    104 ! Must be external to be C compatible
    105 !--------------------------------------------------------------!
    106 
    107 subroutine signal_checkpoint_trap_callback_gfortran_ (SIG_NUM)
    108    use Signal_Checkpoint
    109    integer, intent(in) :: SIG_NUM
    110 
    111 !       print *, "SIG1 : ", SIG_NUM
    112 !  if (SIG_NUM == INTERNAL_SIGNAL_EXIT_) then
    113 !      print *, "SIG2 : ", INTERNAL_SIGNAL_EXIT_
    114 !      INTERNAL_ERROR_ON_EXIT_ = 1
    115 !      print *, "SIG3 : ", INTERNAL_SIGNAL_EXIT_
    116 !   end if
    117100   INTERNAL_RECEIVED_COUNT_ = INTERNAL_RECEIVED_COUNT_ + 1
    118101end subroutine
     
    120103!--------------------------------------------------------------!
    121104
    122 function signal_checkpoint_trap_callback_intel_ (SIG_NUM) result (ONE)
    123    use Signal_Checkpoint
     105subroutine trap_callback_exit_ !(SIG_NUM)
     106   !integer, intent(in) :: SIG_NUM
     107
     108   INTERNAL_ERROR_ON_EXIT_ = 1
     109   call trap_callback_count_
     110end subroutine
     111
     112!--------------------------------------------------------------!
     113
     114function trap_callback_intel_exit_ (SIG_NUM) result (ONE)
    124115   integer, intent(in) :: SIG_NUM
    125116   integer :: ONE
    126117
    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_
    131119   ONE = 1
    132 end
     120end function
    133121
    134122!--------------------------------------------------------------!
     123
     124function 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
     130end function
     131
    135132!--------------------------------------------------------------!
     133end module
     134!--------------------------------------------------------------!
  • trunk/signal-checkpoint/test_sgck1.f90

    r70 r71  
    3636
    3737   if (signal_checkpoint_ask_for_exit_code()) then
    38       stop 1
     38     print *, "stop with exit code 1"
     39     stop 1
    3940   end if
    4041end program
Note: See TracChangeset for help on using the changeset viewer.