Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #pragma ident "@(#) libfi/element/clock.c 92.1 06/16/99 15:47:23"
00038 #include <fortran.h>
00039 #include <stdio.h>
00040 #include <string.h>
00041 #include <time.h>
00042 #include <sys/types.h>
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 #if !defined(__mips) && !defined(_LITTLE_ENDIAN)
00065 #pragma _CRI duplicate _CLOCK_ as CLOCK
00066 #pragma _CRI duplicate _CLOCK_ as $CLOCK
00067 #pragma _CRI duplicate _CLOCK_ as _CLOCK
00068 #endif
00069
00070 #define CLOCK_CHRS 8
00071
00072 #ifdef _UNICOS
00073 _f_int
00074 #else
00075 void
00076 #endif
00077 _CLOCK_(timeofday)
00078 _fcd timeofday;
00079 {
00080 #ifdef _UNICOS
00081 long clock;
00082 #endif
00083 struct tm *sp;
00084 time_t now;
00085 char str[CLOCK_CHRS + 1];
00086
00087 now = time((time_t *) NULL);
00088 sp = localtime(&now);
00089
00090 (void) sprintf(str, "%02d:%02d:%02d", sp->tm_hour, sp->tm_min,
00091 sp->tm_sec);
00092
00093
00094 #ifdef _UNICOS
00095 clock = *(long *) str;
00096
00097 if (_numargs() > 0)
00098 #ifdef _isfcd
00099 if (! _isfcd(timeofday)) {
00100 #elif defined(_UNICOS) && defined(_ADDR64)
00101 if (_numargs() == 1) {
00102 #endif
00103 **(long **) &timeofday = clock;
00104 }
00105 else
00106 #endif
00107 {
00108 unsigned int len;
00109 char *cp;
00110
00111 cp = _fcdtocp(timeofday);
00112 len = _fcdlen (timeofday);
00113
00114 (void) strncpy(cp, str, len);
00115
00116 if (len > CLOCK_CHRS)
00117 (void) memset(cp + CLOCK_CHRS, (_f_int) ' ',
00118 len - CLOCK_CHRS);
00119 }
00120
00121 #ifdef _UNICOS
00122 return ( (_f_int) clock );
00123 #endif
00124
00125 }