Bug #1231

grdcontour - problems with new -N option

Added by Andreas 6 months ago. Updated 5 months ago.

Status:ClosedStart date:2018-04-04
Priority:NormalDue date:
Assignee:Paul% Done:

100%

Category:-
Target version:Candidate for next minor release
Affected version:6.x-svn Platform:

Description

Looks like the new -N option (and subsequent calls to grdview) in grdcontour cause some confusion.

Title causes confusion # 1

$ grdcontour -P -Bafg -BWesN+t"Title problem" @earth_relief_15m -JM10c -RIS -Ccol.cpt -N -A-
grdcontour [ERROR]: Error for input file: No such file (problem)
grdcontour [ERROR]: Syntax error: Must specify a single grid file
grdcontour [ERROR]: Failed to call grdcontour
ERROR: Caught signal number 11 (Segmentation fault) at
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7fcdd9af9917]
[0x2b6f8]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x2b1)[0x7fcdd99e70e1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fcdd97a1390]
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7fcdd9af9917]
/usr/local/lib/libgmt.so.6(GMT_grdcontour+0x18b8)[0x7fcdd9c8a348]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x135)[0x7fcdd99ff3f5]
grdcontour(main+0x84e)[0x4014fe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fcdd93e0830]
grdcontour(_start+0x29)[0x401709]

Title causes confusion # 2

$ grdcontour -P -Bafg -BWesN+t"Title -Nproblem" @earth_relief_15m -JM10c -RIS -Ccol.cpt -N -A- 1> /dev/null
grdview [ERROR]: File /usr/local/share/cpt/problem.cpt not found
[Session grdcontour (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)

Harsh error - if you forget to give CPT-file (-C) you get a crash

$ grdcontour -P -Bafg -BWesN @earth_relief_15m -JM10c -RIS -N -A-
grdview [ERROR]: Syntax error: Must specify color palette table
grdcontour [ERROR]: Failed to call grdview
ERROR: Caught signal number 11 (Segmentation fault) at
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7f7cb7cf9917]
[0x2b6f8]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x2b1)[0x7f7cb7be70e1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f7cb79a1390]
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7f7cb7cf9917]
/usr/local/lib/libgmt.so.6(GMT_grdcontour+0x18b8)[0x7f7cb7e8a348]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x135)[0x7f7cb7bff3f5]
grdcontour(main+0x84e)[0x4014fe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f7cb75e0830]
grdcontour(_start+0x29)[0x401709]

Tested with 6.0.0_r19994.

a.pdf (99.4 KB) Andreas, 2018-04-09 11:19

b.pdf (120 KB) Andreas, 2018-04-09 11:24

b.sh Magnifier (334 Bytes) Andreas, 2018-04-10 01:59

b_without_cpt_interval.pdf (117 KB) Andreas, 2018-04-10 01:59

b_with_cpt_interval.pdf (449 KB) Andreas, 2018-04-10 01:59

c.sh Magnifier (391 Bytes) Andreas, 2018-04-10 23:24

c.pdf (287 KB) Andreas, 2018-04-10 23:24

Associated revisions

Revision 19996
Added by Paul 6 months ago

Address issue #1231

History

#1 Updated by Paul 6 months ago

  • Status changed from New to In Progress
  • Assignee set to Paul
  • Target version set to Candidate for next minor release

Sure, always new issues with new options. Will have a look.

#2 Updated by Paul 6 months ago

  • Status changed from In Progress to Resolved
  • % Done changed from 0 to 100

Should work now. The problem is that the shell eats the quotes in the -B string and when we replicate it to pass it to the internal grdcontour call the spaces are exposed and words are seen as filenames. Should be fixed now in r19997 and added new test based on the first example (colorwithtitle.sh). Added gentle error if no cpt.

#3 Updated by Andreas 6 months ago

Tested - looks good!

#4 Updated by Paul 6 months ago

  • Status changed from Resolved to Closed

Another one bites the dust.

#5 Updated by Andreas 6 months ago

Some more on this. Let me know if you want me to open a new issue instead of reusing this.

If I specify a non-existing CPT to grdcontour, grdcontour doesnt care and uses it's own chosen(?) contour interval;

grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -Cnon_existing.cpt > ops.ps

Add the new option -N and you'll trigger PS-cake issues and segfault

$ grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -Cnon_existing.cpt -N > ops.ps && psconvert -Tf -A -Z ops.ps
Error: /undefined in A
Operand stack:
   0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1977   1   3   %oparray_pop   1976   1   3   %oparray_pop   1960   1   3   %oparray_pop   1852   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:1194/1684(ro)(G)--   --dict:0/20(G)--   --dict:78/200(L)--
Current allocation mode is local
Current file position is 4
psconvert [ERROR]: System call [gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -dMaxBitmap=2147483647 -dUseFastColor=true 'ops.ps' 2> './psconvert_75c.bb'] returned error 256.
ERROR: Caught signal number 11 (Segmentation fault) at
/lib/x86_64-linux-gnu/libc.so.6(fclose+0x4)[0x7f49bca2d264]
[0x0]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x2b1)[0x7f49bcfe70e1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f49bcda1390]
/lib/x86_64-linux-gnu/libc.so.6(fclose+0x4)[0x7f49bca2d264]
/usr/local/lib/libgmt.so.6(GMT_psconvert+0x8412)[0x7f49bd261962]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x135)[0x7f49bcfff3f5]
psconvert(main+0x84e)[0x4014fe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f49bc9e0830]
psconvert(_start+0x29)[0x401709]

Omit the CPT-name and it will plot fine(?)

$ grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -C -N > ops.ps

This small snippet of code

gmt begin ibcao
gmt makecpt -Crainbow -T-2000/1000 > col.cpt
gmt grdcontour -N -Ccol.cpt -Jm1:10000000 earth_relief_15m.grd -Bafg
gmt end

Gives me this:

$ sh t.sh
gmt [ERROR]: Option -K not allowed for modern GMT mode.
gmt [ERROR]: Failed to call grdview
ERROR: Caught signal number 11 (Segmentation fault) at
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7fd6090f9917]
[0x2b6f8]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x2b1)[0x7fd608fe70e1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7fd608da1390]
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7fd6090f9917]
/usr/local/lib/libgmt.so.6(GMT_grdcontour+0x31b7)[0x7fd60928bd17]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x135)[0x7fd608fff3f5]
gmt(main+0x84e)[0x4014fe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fd6089e0830]
gmt(_start+0x29)[0x401709]

#6 Updated by Paul 6 months ago

Thanks, I believe I fixed these in r20009. Let me know.

#7 Updated by Andreas 6 months ago

Still get segfault with non-existing CPT and -N in grdcontour:

$ grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -Cnon_existing.cpt -N > ops.ps
grdcontour [ERROR]: Syntax error -C: CPT file non_existing.cpt not found
grdcontour [ERROR]: Failed to call grdcontour
ERROR: Caught signal number 11 (Segmentation fault) at
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7f372a6f9ee7]
[0x2b6f8]
Stack backtrace:
/usr/local/lib/libgmt.so.6(sig_handler+0x2b1)[0x7f372a5e70e1]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f372a3a1390]
/usr/local/lib/libgmt.so.6(gmt_end_module+0x17)[0x7f372a6f9ee7]
/usr/local/lib/libgmt.so.6(GMT_grdcontour+0x3682)[0x7f372a88c7b2]
/usr/local/lib/libgmt.so.6(GMT_Call_Module+0x135)[0x7f372a5ff975]
grdcontour(main+0x84e)[0x4014fe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f3729fe0830]
grdcontour(_start+0x29)[0x401709]

Omit the CPT name and you will still get a good(?) plot. See a.pdf for the ouput of this command:

$ grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -C -N > a.ps && psconvert -Tf -A -Z a.ps

This code snippet no longer causes a crash, but I dont think it looks like the surface plot. Looks more like grdimage? Output shown in b.pdf

gmt begin b
gmt makecpt -Crainbow -T-2000/1000 > col.cpt
gmt grdcontour -RNO -N -Ccol.cpt -Jm1:10000000 earth_relief_15m.grd -Bafg
gmt end

#8 Updated by Joaquim 6 months ago

I think we have recursivity troubles here. It seams to crash inside the "Return" macro. Maybe because GMT→cpy is NULL in the reincarnation (it is NULL when the crash triggers the debugger).

#9 Updated by Paul 6 months ago

Sorry, I did not actually address Andreas point about this early so of course it still crashes. Weill try to have a look soon.

#10 Updated by Paul 6 months ago

Try r20010.

#11 Updated by Andreas 6 months ago

I see now that when I speak about 'grdimage-ish plots', its because I do not assign an interval in the makecpt -Tmin/max/interval command. Sorry. But still, why the grdimage look?

#12 Updated by Andreas 6 months ago

$ grdcontour -P -Jm1:20000000 @earth_relief_15m.grd -Bafg -RNO -C -N > a.ps && psconvert -Tf -A -Z a.ps

still plots, but maybe thats OK.

#13 Updated by Paul 6 months ago

Thanks, plugged that hole too. r20013.

#14 Updated by Andreas 6 months ago

Looking good Paul!

The only thing left is why a grdcontour -C<cpt> -N .. command, where the CPT-file has only slice dont get the -Qs look. See c.sh and c.pdf.

#15 Updated by Paul 6 months ago

Has to do with the CPT being continuous. I added new check that the cpt used via -N (or -C if not given to -N) must be discrete since we are doing a constant color for each slice. r20017.

#16 Updated by Andreas 5 months ago

Super - works!

Also available in: Atom PDF