You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When compiled with MPI, channelflow's randomReal(Real a, Real b) produces a cyclic sequence of numbers with period 12.
Without MPI, the sequence is pseudorandom as expected.
The code for randomReal() in mathdefs.h seems pretty suspect. Every call to this function resets the drand48 seed. Is the call to srand48 supposed to be inside an else following the if (&initialized)?
inline Real randomReal(Real a, Real b) {
#ifdef HAVE_MPI
int taskid = 0;
int initialized = 0;
MPI_Initialized(&initialized);
if (initialized)
MPI_Comm_rank(MPI_COMM_WORLD, &taskid);
srand48((longint)(taskid + 1) * 1000 * drand48());
return a + (b - a) * drand48();
#elsereturn a + (b - a) * drand48();
#endif
}
Actual Result
Here's a sequence of 40 calls to randomReal() with and without MPI (the latter done by inlining the non-MPI code in the loop, rather than recompiling channelflow without MPI). I added // cycle comments to mark where the cycle starts and when it recurs.
* Added coverage computation to unit and integration tests
The code is compiled passing '--coverage -g' during the 'Unit and
integration tests' stage. Once tests are run data is processed using
lcov and printed to stdout, if tests succeeded.
* Tests done for coverage are built in debug mode with -Og
* Added summary badges to the README file.
- Build status
- Total coverage
- License
Describe the bug
When compiled with MPI, channelflow's
randomReal(Real a, Real b)
produces a cyclic sequence of numbers with period 12.Without MPI, the sequence is pseudorandom as expected.
The code for
randomReal()
in mathdefs.h seems pretty suspect. Every call to this function resets the drand48 seed. Is the call tosrand48
supposed to be inside anelse
following theif (&initialized)
?Actual Result
Here's a sequence of 40 calls to
randomReal()
with and without MPI (the latter done by inlining the non-MPI code in the loop, rather than recompiling channelflow without MPI). I added// cycle
comments to mark where the cycle starts and when it recurs.Steps to reproduce the issue
The code that produces the above output
Information on your system
Channlelfow compiled and run on openSUSE LEAP 15.0 on an Intel x86-64 architecture with g++-7.3.1 and CMAKE comfiguration
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: