Question

I'm currently working on converting some Fortran code into parallel using openMP. I'm trying to use omp_get_wtime() to calculate how much actual time passes, but its returning ******. Other OpenMP functions work, yet for some reason this doesn't. I've removed all the code from in between the timer just to try to get something different. Removing the finish, and just displaying the start gives the same result. Any ideas of what I'm doing wrong would be much appreciated.

C$    USE OMP_LIB
   DOUBLE PRECISION START,FINISH

   START = OMP_GET_WTIME()
   FINISH=OMP_GET_WTIME()

   WRITE(OUT,850) FINISH-START
 850 FORMAT(25X,'ELAPSED TIME',I6)
Était-ce utile?

La solution

Your problem has nothing to do with the OMP_GET_WTIME function. Rather it stems from the fact that the I edit descriptor is used to display integers and you are feeding it with a double precision number instead. You should use one of the floating-point edit descriptors like, e.g. F10.6:

$ cat wtime.f
      USE OMP_LIB
      IMPLICIT NONE
      DOUBLE PRECISION START,FINISH

      START = OMP_GET_WTIME()
      CALL SLEEP(1)
      FINISH=OMP_GET_WTIME()

      WRITE(*,850) FINISH-START
 850  FORMAT(25X,'ELAPSED TIME',F10.6)
      END
$ ifort -openmp -o wtime.exe wtime.f
$ ./wtime.exe
                         ELAPSED TIME  1.000277
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top