Fortran Library Reference

alarm: Call Subroutine After a Specified Time

The function is called by:

INTEGER*4 alarm

n = alarm ( time, sbrtn )

time

INTEGER*4

Input 

Number of seconds to wait (0=do not call) 

sbrtn

Routine name 

Input 

Subprogram to execute must be listed in an external statement. 

Return value 

INTEGER*4

Output 

Time remaining on the last alarm  

Example: alarm--wait 9 seconds then call sbrtn:


    integer*4 alarm, time / 1 /
    common / alarmcom / i
    external sbrtn
    i = 9
    write(*,*) i
    nseconds =  alarm ( time, sbrtn )
    do n = 1,100000         ! Wait until alarm activates sbrtn.
         r = n              ! (any calculations that take enough time)
       x=sqrt(r)
    end do
    write(*,*) i
    end
    subroutine sbrtn
    common / alarmcom / i
    i = 3                     ! Do no I/O in this routine.
    return
    end

See also: alarm(3C), sleep(3F), and signal(3F). Note the following restrictions: