Odd omp_get_wtime()



I've run into a a peculiar behaviour in XL Fortran with the OpenMP function omp_get_wtime(). I've reduced it to a simple program that shows the behaviour:

module wtime_mod
contains
subroutine wtimer2(t)
real(8) :: t
t = omp_get_wtime()
end subroutine
end module

module main_mod
use omp_lib
use wtime_mod
implicit none
contains
subroutine wtimer1(t)
real(8) :: t
t = omp_get_wtime()
end subroutine
end module

program main
use main_mod
real(8) :: t1,t2
integer :: i,num_cpu = 4

call omp_set_num_threads(num_cpu)

do i = 1,10
call wtimer1(t1)
call wtimer2(t2)
write(*,*) 't1,t2: ',t1,t2
enddo
end

When this is run the time t1 changes with each call, but t2 remains fixed. The value returned by wtimer2(), which is USEd in module main_mod, only returns multiples of 128, i.e. it only changes every 128 sec.

I was just about to post this when I realized that module wtime_mod lacked 'use omp_lib'. Sure enough, adding that line makes it work properly. It's surprising, though, that the program as shown compiles and runs without an error.
.



Relevant Pages

  • Re: Fortran based MEX w/ COMMON/SAVE
    ... I believe dat (pointer to the array) and the ... SAVE at the begining of each subroutine is a bit unusual to me. ... > to unload it if there isn't a Fortran END or STOP statement. ... interaction w/ Matlab). ...
    (comp.soft-sys.matlab)
  • Re: Help Constructing Fictional Cross-Religious Movement
    ... You know how to do something in Fortran that I ... >don't know how to do despite being pretty familiar with it, COBOL ... > subroutine point ... >was finding a programming problem that seemed reasonably amenable to ...
    (rec.arts.sf.composition)
  • Re: Callbacks - Delphi and CVF
    ... | I have a FORTRAN DLL that does the computations and takes about hours ... | want to be able to access the callback functions address from every ... | subroutine in the fortran dll. ... SUBROUTINE ReportProgress ...
    (comp.lang.fortran)
  • Re: Callbacks - Delphi and CVF
    ... | I have a FORTRAN DLL that does the computations and takes about hours ... | want to be able to access the callback functions address from every ... | subroutine in the fortran dll. ... SUBROUTINE ReportProgress ...
    (comp.lang.fortran)
  • Re: Help Constructing Fictional Cross-Religious Movement
    ... Given that this is something that I'd really like to know how to do in Fortran -- and, while Fortran 2003 has objects, there are as yet no ... Consider the following subroutine, which defines what amounts to a ... entry getpoints ... was finding a programming problem that seemed reasonably amenable to object-oriented programming, and that I wanted to write starting from a blank slate. ...
    (rec.arts.sf.composition)