Intel® Fortran Compiler Classic and Intel® Fortran Compiler Developer Guide and Reference

ID 767251
Date 3/22/2024
Public
Document Table of Contents

ALARM

Portability Function: Causes a subroutine to begin execution after a specified amount of time has elapsed.

Module

USE IFPORT

result = ALARM (time,proc)

time

(Input) Integer. Specifies the time delay, in seconds, between the call to ALARM and the time when proc is to begin execution. If time is 0, the alarm is turned off and no routine is called.

proc

(Input) Name of the procedure to call. The procedure takes no arguments and must be declared EXTERNAL.

Results

The return value is INTEGER(4). It is zero if no alarm is pending. If an alarm is pending (has already been set by a previous call to ALARM), it returns the number of seconds remaining until the previously set alarm is to go off, rounded up to the nearest second.

After ALARM is called and the timer starts, the calling program continues for time seconds. The calling program then suspends and calls proc, which runs in another thread. When proc finishes, the alarm thread terminates, the original thread resumes, and the calling program resets the alarm. Once the alarm goes off, it is disabled until set again.

If proc performs I/O or otherwise uses the Fortran library, you need to compile it with one of the multithread libraries.

The thread that proc runs in has a higher priority than any other thread in the process. All other threads are essentially suspended until proc terminates, or is blocked on some other event, such as I/O.

No alarms can occur after the main process ends. If the main program finishes or any thread executes an EXIT call, than any pending alarm is deactivated before it has a chance to run.

Example

USE IFPORT
INTEGER(4) numsec, istat
EXTERNAL subprog
numsec = 4
write *, "subprog will begin in ", numsec, " seconds"
ISTAT = ALARM (numsec, subprog)

See Also