Opened 10 years ago

Closed 6 years ago

Last modified 6 years ago

#2496 closed defect (fixed)

r.random.surface error from RAN C library

Reported by: cmbarton Owned by: grass-dev@…
Priority: normal Milestone: 7.0.7
Component: Raster Version: svn-trunk
Keywords: r.random.surface Cc:
CPU: Unspecified Platform: MacOSX

Description

We just encountered a weird bug in r.random.surface. So far, it seems to showing up on the Mac intermittently but not on Linux. The message is...

ERROR: RAN1: j==-67 shouldn't happen

It was generated from a Python script that called r.random.surface in the following way:

grass.run_command("r.random.surface", quiet = "True", output = tempimpactg, distance = grazespatial, exponent = grazepatchy, high = maxgrazeimpact)

I'm running on an oldish (ca. 5 years) iMac but with the latest OS X 10.9,x (no upgrade to 10.10 yet). This happens on both GRASS 7.0 beta3 and 7.1, both compiled 11 August 2014.

Attachments (1)

r.random.surface.patch (1.3 KB ) - added by glynn 10 years ago.
ran1() replacement

Download all attachments as: .zip

Change History (23)

comment:1 by annakrat, 10 years ago

It comes from r.random.surface/random.c ran1 function, perhaps the new random functions could be used instead?

http://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/lrand48.c

This applies also to r.random.cells. See also discussion here.

comment:2 by cmbarton, 10 years ago

I don't know. But this bug causes our modeling script to crash so that we get no results.

comment:3 by glynn, 10 years ago

That appears to be a conversion of this Fortran function.

That's supposed to generate uniform random numbers in the [0,1) interval, and so can be replaced by G_drand48().

comment:4 by cmbarton, 10 years ago

If this is an easy fix, can someone let us know when it gets fixed? We need this for landscape modeling experiments we are trying to run.

thanks Michael

in reply to:  4 comment:5 by annakrat, 10 years ago

Replying to cmbarton:

If this is an easy fix, can someone let us know when it gets fixed? We need this for landscape modeling experiments we are trying to run.

It would be most welcome if somebody from your group would submit a patch which can be reviewed and eventually submitted.

comment:6 by cmbarton, 10 years ago

Unfortunately, no one here is a C programmer. We do Python, Java, and other things. But not C. :-(

Otherwise we might have figured it out and fixed it already.

Michael

by glynn, 10 years ago

Attachment: r.random.surface.patch added

ran1() replacement

in reply to:  3 comment:7 by glynn, 10 years ago

Replying to glynn:

so can be replaced by G_drand48().

Can someone test attachment:r.random.surface.patch ?

comment:8 by cmbarton, 10 years ago

Is it updated in trunk or 7.1 dev? I can recompile and test.

Michael

in reply to:  8 comment:9 by cmbarton, 10 years ago

Replying to cmbarton:

Is it updated in trunk or 7.1 dev? I can recompile and test.

Michael

Sorry. I see it is a patch. I will try with 7.0 and let you know.

Michael

comment:10 by cmbarton, 10 years ago

This patch seems to fix the problem. I'll know for sure after our script repeated enough times. Most of the times, r.random.surface failed on the first or second time run. Once it did not fail until the 62nd iteration. I'm up to 65 iterations with no errors yet. So it looks good.

Michael

comment:11 by neteler, 10 years ago

Will you submit the patch?

comment:12 by cmbarton, 10 years ago

I tested this with trunk. While I can do the mechanics of submitting this later this week for 7.0 and trunk, I'm a little hesitant since I'm not familiar with C and don't know if this should be applied to other r.random.x modules or not.

Michael

comment:13 by neteler, 10 years ago

Indeed, these files are 99% cloned:

  • r.random.cells/gasdev.c
  • r.random.surface/gasdev.c

and

  • r.random.cells/random.c
  • r.random.surface/random.c

comment:14 by cmbarton, 10 years ago

So multiple patches are needed for different modules? Different for GRASS 7.0 and 7.1 or the same?

Michael

in reply to:  14 comment:15 by neteler, 10 years ago

Replying to cmbarton:

So multiple patches are needed for different modules? Different for GRASS 7.0 and 7.1 or the same?

The same patch will work in 7.0 and 7.1.

comment:16 by cmbarton, 10 years ago

So just a patch for each module that uses this then.

comment:17 by martinl, 9 years ago

Milestone: 7.0.07.0.5

comment:18 by neteler, 8 years ago

Milestone: 7.0.57.0.6

comment:19 by neteler, 7 years ago

Milestone: 7.0.67.0.7

comment:20 by cmbarton, 6 years ago

We hit this unfixed bug again and while an error trap would help, we really just need to change the documentation it seems.

r.random.surface output=surf generates the error r.random.surface output=surf seed=0 (or seed=ANYTHING) does not generate an error, though seed<0 generates a warning r.random.surface output=surf seed=- does NOT generate an error

comment:21 by mmetz, 6 years ago

Resolution: fixed
Status: newclosed

In 73234:

r.random.cells, r.random.surface: use G_drand48(), fixes #2496

comment:22 by mmetz, 6 years ago

In 73235:

r.random.cells, r.random.surface: use G_drand48(), fixes #2496 (backport trunk r73234)

Note: See TracTickets for help on using tickets.