begin procedure accel-init
   if (.not.SIC%OPENMP%ACTIVE) then
      say ""
      say "OPENMP parallelization not available"
      say ""
      return
   endif
   if (exist(accel)) delete /var accel
   if (.not.exist(accel)) then
      define structure accel /global
      define integer accel%mcpu /global
      let accel%mcpu SIC%OPENMP%MTHREADS
      define real accel%times[accel%mcpu] accel%accels[accel%mcpu] /global
      define integer accel%threads[accel%mcpu] /global
      define logical accel%aborted /global
      define character*512 accel%cline /global
      let accel%threads[i] i
   endif
end procedure accel-init
!
begin procedure accel-mainloop
   for ncpu 1 to accel%mcpu
      sic parallel 'ncpu'
      sic cpu
      sic\execute 'accel%cline'
      sic cpu
      let accel%times[ncpu] SIC%CPU%RAW%ELAPSED
   next ncpu
   !
   let accel%accels accel%times[1]/accel%times
end procedure accel-mainloop
!
begin procedure accel-plot
   gtvl\clear
   greg1\limits /var accel%threads accel%threads
   set\panel 1 /nxy 1  /def
   greg1\label "Number of threads" /x
   greg1\label "Acceleration"      /y
   !
   greg1\pencil /c 3 /w 3
   greg1\connect accel%threads accel%threads
   greg1\draw text 0 0.5 "- Theoretical limit on acceleration" /b 8
   !
   greg1\pencil /c 1 /w 3
   greg1\connect accel%threads accel%accels
   greg1\draw text 0 1.0 "- Real acceleration" /b 8
   !
   greg1\pencil /def
end procedure accel-plot
!
begin procedure accel-output
   !
   say ""
   say "************************************************************"
   say ""
   say "Acceleration Results:"
   say "Threads    Time(s)      Acceleration"
   for ncpu 1 to accel%mcpu
      say 'ncpu' 'accel%times[ncpu]' 'accel%accels[ncpu]' /format i5 f12.2 f13.2
   next ncpu
   say ""
   say "************************************************************"
   say ""
   !
end procedure accel-output
!
begin procedure accel-main
   @ accel-mainloop
   @ accel-plot
   @ accel-output
end procedure accel-main
!
@ accel-init
let accel%cline ""
for iarg 1 to pro%narg
   let accel%cline 'accel%cline'" "'pro%arg[iarg]'
next iarg
@ accel-main
