#include<stdio.h>
#include <sys/time.h>
#include <sys/resource.h>

#define HP 0
#define OTHER 1
#define SYS HP

#define Mlowcase(C) ( (C) | 32 )
#define NEG_ONE -1.00000000000000000
#define NTIMES 50

double *Times00=NULL;
double *mark00=NULL;
char **Tlabels00=NULL;
int DISABLED00=(-1);

#if (SYS == HP)
#include <unistd.h>
long ClockTick;
#endif

/*************************** clock00 ******************************/
/* This routine used for PVM.  It should return wall clock time,  */
/* and the argument is cputime.                                   */
/******************************************************************/
double clock00(cputime)
double  *cputime;
{
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/times.h>
   struct timeval tp;
#if (SYS == HP)
   struct tms tmsS;
#else
   struct rusage ruse;
#endif

   if ( gettimeofday(&tp, NULL) )  /* info for wall clock time */
      fprintf(stderr, "\nTIMER00 ERROR: gettimeofday not working\n");

#if (SYS == HP)
   if ( times( &tmsS ) == -1 )
      fprintf(stderr, "\nTIMER00 ERROR: times not working\n");
   *cputime = tmsS.tms_utime * ClockTick;
#else
   if ( getrusage(RUSAGE_SELF, &ruse) ) /* info for cputime */
      fprintf(stderr, "\nTIMER00 ERROR: getrusage not working\n");
   *cputime = ruse.ru_utime.tv_sec + ruse.ru_utime.tv_usec / 1000000.0;
#endif

   return( (double) (tp.tv_sec + tp.tv_usec/1000000.0) ); /* returns wall clock time */
}
