[General boards] [Winter 2021 courses] [Fall 2020 courses] [Summer 2020 courses] [Older or newer terms]

MPI_Wtime doesn't work inside a f77 subroutine


#1

When I place every operation in the main program, Wtime returns the correct wall time. But if I wrap the lines in a subroutine, MPI_Wtime only returns 0. I’m wondering is it expected? I can send you a demo program to illustrate the issue if needed. Thanks in advance.

P.S. I can confirm that my variable is initialized using double-precision, and the operations between the two Wtime should take around 1 second.


#2

I have not timed parts of a subroutine, so whay don’t you send me by e-mail the demo code, and if there is something of general interest,
I will post here.


#3

I found out that the declaration
include “mpif.h”
must also be included in the subroutine.
If you do that, then it works.


#4

Thank you. I just found out the reason:
One must define REAL*8 MPI_WTIME, MPI_WTICK (which is included in mpif.h), otherwise, as the function starts with M, the compiler thinks it returns an integer instead of a real *8.