ccm_barrier

CCM barrier

Routine:

ccm_barrier

Purpose:

Block at the call to ccm_barrier until all tasks reach that point. Optionally, wait a given number of seconds and flush IO, (on machines that support flushing IO.)

Minimal calling sequence:

call ccm_barrier()

Required Arguments:

NONE

Call with all Optional Arguments:

call ccm_barrier(wait,io_flush,the_err)
wait :: real,intent (in)
Seconds to wait before continuing beyond this point.
io_flush :: logical,intent (in)
If possible, flush output before continuing.
the_err :: integer, intent (out)
Error code 0 = success, != 0 failure.
See Specifying Optional Arguments for the syntax for using optional arguments.

Notes:

Not all systems support flushing IO in Fortran. On such systems io_flush is ignored. The wait time is approximate.

Example:


program ccm_barrier_x1
    use ccm
    implicit none
    integer :: myid,numprocs,root
    character (len=8):: dstr
    character (len=10):: tstr
    call ccm_init(myid,numprocs)
    if(myid .eq. 0)then
      call date_and_time(date=dstr,time=tstr)
      write(*,*)" start at ",dstr(1:4)," ",dstr(5:6)," ",dstr(7:8)," ",tstr(1:2),":",tstr(3:4),":",tstr(5:10)
      write(*,*)"pause for 5 seconds "
    endif
 ! all processors call barrier
    call ccm_barrier(5.0)
    if(myid .eq. 0)then
      call date_and_time(date=dstr,time=tstr)
      write(*,*)"  done at ",dstr(1:4)," ",dstr(5:6)," ",dstr(7:8)," ",tstr(1:2),":",tstr(3:4),":",tstr(5:10)
    endif
    call ccm_barrier(io_flush=.true.)
    write(*,*)" my id= ",myid
    call ccm_barrier(io_flush=.true.)
    if(myid .eq. 0)write(*,*)"done"
    call ccm_barrier()
    call ccm_close()
end program

Example output on 4 processors


[ccm_host:~/ccm/source]% ccm_bcast_x1
  start at 2002 05 10 14:12:44.487
 pause for 5 seconds 
   done at 2002 05 10 14:12:49.499
  my id=   0
 done
  my id=   3
  my id=   2
  my id=   1
[ccm_host:~/ccm/source] % 

The call to ccm_init initializes the communication package. The time is them obtained and ccm_barrier is called to pause for 5 seconds. Ccm_barrier is called with io_flush=true. Then myid is printed and Ccm_barrier is again called to flush data. On systems that support flushing IO, the output from

"write(*,*)" my id= ",myid"

would occur before the output of "done" as:

  my id=   0
  my id=   3
  my id=   2
  my id=   1
  done
 


Error conditions:


Back to API and user's guide