3 #include <sys/resource.h>
8 #define cexit FORTRAN_UNPREFIXED(cexit, CEXIT)
9 #define print_stack FORTRAN_UNPREFIXED(print_stack, PRINT_STACK)
10 #define sizeOfLongInt FORTRAN_UNPREFIXED(sizeoflongint, SIZEOFLONGINT)
11 #define getmaxrss FORTRAN_UNPREFIXED(getmaxrss, GETMAXRSS)
12 #define set_stdout FORTRAN_UNPREFIXED(set_stdout, SET_STDOUT)
22 int bt_size = backtrace(bt, 50);
23 char **symbols = backtrace_symbols(bt, bt_size);
25 printf (
"backtrace(): obtained %d stack frames.\n", bt_size);
26 for (i=0; i<bt_size; i++) printf(
"%s\n", symbols[i]);
35 struct rusage r_usage;
37 getrusage(RUSAGE_SELF,&r_usage);
38 #if defined(__APPLE__) && defined(__MACH__)
39 return (
double)r_usage.ru_maxrss;
41 return (
double)(r_usage.ru_maxrss * 1024L);
47 return sizeof(
long int);
52 char *logfile = (
char *) malloc((flen+2+5+1)*
sizeof(char));
53 strncpy(logfile, f, flen);
55 for (i=flen-1; i>=0; i--)
if (logfile[i] !=
' ')
break;
61 if (logfile[0] !=
'\0') {
64 else if (envvar = getenv(
"NEK_LOGFILE")) {
65 if (*sid >= 0) sprintf(logfile,
"s%05d_", *sid);
66 strcat(logfile + strlen(logfile), envvar);
71 printf(
"redirecting stdout to %s\n",logfile);
72 freopen(logfile,
"w+", stdout);