Time Functions

The GNU Fortran compiler provides a sleep function to pause the programme for a given number of seconds:

! time.f90
program main
    call sleep(5) ! sleep 5 seconds
end program main

Use the iso_c_binding interface of modern Fortran, if you want to sleep for less than a second. The libc routine usleep pauses for the given interval measured in microseconds:

! posix_sleep.f90
program main
    use iso_c_binding
    implicit none
    integer(c_int32_t) :: t = 500000 _c_int32_t ! 500 milliseconds

    interface
        subroutine usleep(useconds) bind(c)
            use iso_c_binding
            implicit none
            integer(c_int32_t), value :: useconds
        end subroutine
    end interface

    do 1, 10:
        write (*, *) 'zzz ...'
        call usleep(t)
    end do
end program main