Open hughaharper opened 1 year ago
👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. We appreciate that you took the time to contribute!
Please make sure you read our Contributing Guide and abide by our Code of Conduct.
Yep, and I'm surprised how you even managed to have your first figure. gcc
is really permissive in accessing invalid memory.
What happens is that at gravfft.c#L693
GMT_Report (API, GMT_MSG_INFORMATION, "Inverse FFT...\n");
if (GMT_FFT (API, Grid[0], GMT_FFT_INV, GMT_FFT_COMPLEX, K))
Return (GMT_RUNTIME_ERROR);
we do the inverse transform and the grid Grid[0]
looses the imaginary part and hence shrinks to half size. And when it later is fed to the fft
function at line 765 it crashes because Grid[0]
is too small (lost the imaginary part)
if (GMT_FFT (API, Grid[0], GMT_FFT_INV, GMT_FFT_COMPLEX, K)) {
gravfft
went into several cycles of rewriting/improving but this case seems to have escaped our tests and now it's not obvious on what to do to fix it.
I will have to find some time on the weekend to look at this and fix the issue. Would be nice to have a simple test script to aim for.
I have actually found what seemed to be a fix, but the two solutions differ by ~13 mGal and the difference is not constant.
Description of the problem
The gravfft module with the -T+m option produces an output moho geopotential grid with artifacts. I've also noticed the module behavior with this option activated is not deterministic, and may result in a segfault.
The module seems to work fine with the -D option or with the -Q and -T (no moho) options.
Full script that generated the error
To generate the moho geopotential grid:
The geographic range, flexural parameters, number of Parker expansion terms, and output potential field (-F option) are not important, and similar artifacts are produced regardless.
Actual outcome
Here is a visualization of the moho_g.nc grid:
Here is an example of the occasional segfault (running the above gravfft command with -V):
Expected outcome
Current workaround is to compute the flexural topography of the moho (-T and -Q options) then compute the geopotential with the -D option:
Here is a visualization of that grid: note that both grids are shown with the same colorscale (-40 - 40 mgal).
System information
gmt --version
): 6.4.0