Second subroutine example
Programs can use the second() subroutine.
#include <stdio.h>
double second();
main()
{
double t1,t2;
t1 = second();
my_favorite_function();
t2 = second();
printf("my_favorite_function time: %7.9f\n",t2 - t1);
exit();
}
An example (main.f) of a FORTRAN program using the second() subroutine is as follows:
double precision t1
double precision t2
t1 = second()
my_favorite_subroutine()
t2 = second()
write(6,11) (t2 - t1)
11 format(f20.12)
end
To compile and use either main.c or main.f, use the following:
xlc -O3 -c second.c timer.s
xlf -O3 -o mainF main.f second.o timer.o
xlc -O3 -o mainC main.c second.o timer.o