get_zeits.c 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. ! NASA/GSFC, Data Assimilation Office, Code 910.3, GEOS/DAS !
  3. !-----------------------------------------------------------------------
  4. ! CVS get_zeits.c,v 1.12 2012-01-31 19:42:07 jacob Exp
  5. ! CVS MCT_2_8_0
  6. !-----------------------------------------------------------------------
  7. !BOP
  8. !
  9. ! !ROUTINE: get_zeits - a C interface to times for Fortran calls
  10. !
  11. ! !DESCRIPTION:
  12. !
  13. ! !INTERFACE: */
  14. /*
  15. System times() dependencies:
  16. */
  17. #include <sys/types.h>
  18. #ifndef NOTIMES
  19. #include <sys/times.h>
  20. #endif
  21. #include <time.h> /* POSIX standard says CLOCKS_PER_SEC is here */
  22. #include "config.h"
  23. /*
  24. * CLK_TCK is obsolete - replace with CLOCKS_PER_SEC
  25. */
  26. #define ZCLK_TCK ((double)CLOCKS_PER_SEC)
  27. /* Prototype: */
  28. void FC_FUNC(get_zeits,GET_ZEITS)(double *zts);
  29. void FC_FUNC(get_ztick,GET_ZTICK)(double *tic);
  30. /*!REVISION HISTORY:
  31. ! 12Mar98 - Jing Guo <guo@thunder> - initial prototype/prolog/code
  32. ! 06Jul99 - J.W. Larson <jlarson@dao> - support for AIX platform
  33. !EOP */
  34. /* Implementations: */
  35. void FC_FUNC(get_zeits,GET_ZEITS)(zts)
  36. double *zts;
  37. {
  38. #ifndef NOTIMES
  39. struct tms tm;
  40. double secs;
  41. secs=1./ZCLK_TCK;
  42. zts[0]=times(&tm)*secs;
  43. zts[1]=tm.tms_utime*secs;
  44. zts[2]=tm.tms_stime*secs;
  45. zts[3]=tm.tms_cutime*secs;
  46. zts[4]=tm.tms_cstime*secs;
  47. #else
  48. zts[0]=0.;
  49. zts[1]=0.;
  50. zts[2]=0.;
  51. zts[3]=0.;
  52. zts[4]=0.;
  53. #endif
  54. }
  55. void FC_FUNC(get_ztick,GET_ZTICK)(tic)
  56. double *tic;
  57. {
  58. tic[0]=1./ZCLK_TCK;
  59. }