ALARM — Execute a routine after a given delay#
-
ALARM(SECONDS, HANDLER, STATUS)#
ALARM(SECONDS, HANDLER [, STATUS])
causes external subroutineHANDLER
to be executed after a delay ofSECONDS
by usingalarm(2)
to set up a signal andsignal(2)
to catch it. IfSTATUS
is supplied, it will be returned with the number of seconds remaining until any previously scheduled alarm was due to be delivered, or zero if there was no previously scheduled alarm.- Parameters
SECONDS – The type of the argument shall be a scalar
INTEGER
. It isINTENT(IN)
.HANDLER – Signal handler (
INTEGER FUNCTION
orSUBROUTINE
) or dummy/globalINTEGER
scalar. The scalar values may be eitherSIG_IGN=1
to ignore the alarm generated orSIG_DFL=0
to set the default action. It isINTENT(IN)
.STATUS – (Optional)
STATUS
shall be a scalar variable of the defaultINTEGER
kind. It isINTENT(OUT)
.
- Standard:
GNU extension
- Class:
Subroutine
- Syntax:
CALL ALARM(SECONDS, HANDLER [, STATUS])
- Example:
program test_alarm external handler_print integer i call alarm (3, handler_print, i) print *, i call sleep(10) end program test_alarm
This will cause the external routine
handler_print
to be called after 3 seconds.