Program coexample
  Use coquad1
  Implicit None
  Integer,Parameter :: wp = Selected_Real_Kind(15)
  Real(wp) res[*],true
  Double Precision secs
  Real(wp),Parameter :: a = 1.0_wp, b = 10.0_wp
  Integer,Parameter :: steps = 1000*1000*1000
  Integer(Selected_Int_Kind(18)) t1,t2,irate
  Call System_Clock(Count_Rate=irate)
  Call System_Clock(t1)
  Call co_rectangle_rule(f,a,b,steps,res)
  Call System_Clock(t2)
  If (This_Image()==1) Then
    Print *,'Calculated value:   ',res
    true = 1 - 0.1d0
    Print *,'True value (approx):',true
    Print *,'Relative error',Abs((res-true)/true)
    secs = (t2-t1)/Dble(irate)
    If (secs>=0.1d0) Then
      Print 1,secs,'seconds',Num_Images(),Num_Images()*secs
    Else
      Print 1,secs*1000,'milliseconds',Num_Images(),Num_Images()*secs
    End If
1   Format(1X,'Time taken ',F0.3,1X,A,' by ',I0,' images, = ',F0.2,' computing power')
  End If
Contains
  Real(wp) Function f(x)
    Real(wp),Intent(In) :: x
    f = 1/x**2
  End Function
End Program
