void checksums(double *a, double *b, double *c, int n, int ntimes)
{
double aa,bb,cc,scalar,suma,sumb,sumc,epsilon;
int k,j, ibad=0;

//C Repeat the main loop, but with scalars only.
//C This is done to check the sum & make sure all
//C iterations have been executed correctly. 


aa = 2.0; bb = 2.0; cc = 0.0;
scalar = 3.0;
for(k=0; k<ntimes; k++){
     cc = aa;
     bb = scalar*cc;
     cc = aa + bb;
     aa = bb + scalar*cc;
     }

aa *= n;
bb *= n;
cc *= n;

//C Now sum up the arrays, excluding the first and last
//C elements, which are modified using the timing results
//C to confuse aggressive optimizers.
//HWS note: first-last item issue does not apply to C code.
suma = 0.0;
sumb = 0.0;
sumc = 0.0; //!$OMP PARALLEL DO REDUCTION(+:suma,sumb,sumc)

for(j=0; j<n; j++){ 
     suma = suma + a[j];
     sumb = sumb + b[j];
     sumc = sumc + c[j];
     }

epsilon = 1.0e-6; //implicitly double
if(fabs(suma-aa)/suma > epsilon){ 
     printf("Failed Validation on array a()\n");
     printf("Target Sum of a is = %g\n", aa);
     printf("Computed Sum of a is = %g\n",suma);
     ibad=1;
     }
if(fabs(sumb-bb)/sumb > epsilon){
     printf("Failed Validation on array b()\n");
     printf("Target Sum of a is = %g\n", bb);
     printf("Computed Sum of a is = %g\n",sumb);
     ibad=1;
     }
if(fabs(sumc-cc)/sumc > epsilon){
     printf("Failed Validation on array c()\n");
     printf("Target Sum of a is = %g\n", cc);
     printf("Computed Sum of a is = %g\n",sumc);
     ibad=1;
     }
if(!ibad) printf("====The solution is validated!====\n");

}//END checksums()


//SUBROUTINE checksums(a,b,c,n,ntimes)
//* IMPLICIT NONE 
//C .. 
//C .. Arguments .. 
//DOUBLE PRECISION a(*),b(*),c(*)
//INTEGER n,ntimes
//C ..
//C .. Local Scalars .. 
//DOUBLE PRECISION aa,bb,cc,scalar,suma,sumb,sumc,epsilon
//INTEGER k
//C ..
//C Repeat the main loop, but with scalars only.
//C This is done to check the sum & make sure all
//C iterations have been executed correctly. 
//aa = 2.0D0
//bb = 0.5D0
//cc = 0.0D0
//aa = 0.5D0*aa
//scalar = 0.5d0*aa
//DO k = 1,ntimes
//cc = aa
//bb = scalar*cc
//cc = aa + bb
//aa = bb + scalar*cc
//END DO
//aa = aa*DBLE(n-2)
//bb = bb*DBLE(n-2)
//cc = cc*DBLE(n-2)
//C Now sum up the arrays, excluding the first and last
//C elements, which are modified using the timing results
//C to confuse aggressive optimizers.
///suma = 0.0d0
//sumb = 0.0d0
///sumc = 0.0d0 !$OMP PARALLEL DO REDUCTION(+:suma,sumb,sumc)
//DO 110 j = 2,n-1 
//suma = suma + a(j)
//sumb = sumb + b(j)
//sumc = sumc + c(j) 
//110 CONTINUE
//epsilon = 1.D-6
//IF (ABS(suma-aa)/suma .GT. epsilon) THEN 
//PRINT *,'Failed Validation on array a()'
///PRINT *,'Target Sum of a is = ',aa
//PRINT *,'Computed Sum of a is = ',suma
//ELSEIF (ABS(sumb-bb)/sumb .GT. epsilon) THEN
//PRINT *,'Failed Validation on array b()'
//PRINT *,'Target Sum of b is = ',bb
//PRINT *,'Computed Sum of b is = ',sumb
//ELSEIF (ABS(sumc-cc)/sumc .GT. epsilon) THEN
//PRINT *,'Failed Validation on array c()'
//PRINT *,'Target Sum of c is = ',cc
//PRINT *,'Computed Sum of c is = ',sumc
//ELSE
//PRINT *,'Solution Validates!' ENDIF
//END 


