This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: New sanity test for cpu_time() intrinsic function
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Uttam Pawar <uttamp at us dot ibm dot com>
- Cc: fortran at gcc dot gnu dot org
- Date: Tue, 15 Nov 2005 00:57:09 +0100
- Subject: Re: New sanity test for cpu_time() intrinsic function
- References: <1132011801.15127.5.camel@linux.site>
Hi Uttam,
Uttam Pawar wrote:
> I've written following sanity test for cpu_time intrinsic, does it look ok?
>
> $ cat test_cpu_time.f90
> program test_cpu_time
> real r1, r2
> integer n
>
> n=0
> call cpu_time(r1)
> ! if (r1 .lt. 0) then according to f95 standard, it mean processor cannot return
> ! meaningful value. This is not an error but a valid case which can be ignored, I think.
Since we're testing our implementation, it should be an error.
> if (r1 .eq. 0) then
> do i=1,1000000 ! this loop is meaningless, as the loop will take
> ! different amount of time depending upon processor
> ! and the environment.
> n = n +1
> end do
> call cpu_time(r2) ! The real test is that, the time r2 should be atleast
> ! same as r1 or greater but can not be smaller than r1.
> if (r2.lt.r1) call abort()
> endif
> end program test_cpu_time
As the loop will probably (well, hopefully) be optimized away, you might as
well do without the loop, and just call cpu_time a second time.
- Tobi