GMT.jl errors when trying to plot - problem with PNG?

[Cross-posted from Julia Discourse forum here ]

For some reason, I cannot get GMT.jl to work. When I attempt to do the “Hello, World” example plot I get the following message:

Error: /undefined in PSL_movie_label_completion

 (skipping the stacktrace...)

ERROR: Something went wrong when calling the module. GMT error number = 78

The “Hello round world” plot also only fails on the plot! command with PNG formatting. I think this is a problem with GMT.jl because I was able to successfully run several of the GMT examples straight from the shell with no errors. I drilled down into the tests and found that I get the exact same error for lines 342 and 343 in runtests.jl , which are

	logo(GMTjulia=2, savefig="logo.PNG")
	logo(GMTjulia=2, savefig="logo.PNG", fmt=:PNG)

And line 489

	grdcontour(G, axis="a", fmt="png", color=cpt, pen="+c", X=1, Y=1, N=true, U=[])

and line 1224

grdcontour(G, axis="a", color=cpt, pen="+c", fmt=:png, savefig="lixo")

I don’t know nearly enough to diagnose the problem, but it is suspicious to me that they all use PNG format. This is with GMT.jl v0.25.0 on Ubuntu 20.04 with GMT v6.0.0 from the repos. I also compiled Julia from source (to avoid another issue) and the versioninfo() is

Julia Version 1.5.2
Commit 539f3ce943* (2020-09-23 23:17 UTC)
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-10.0.1 (ORCJIT, haswell)
Environment:
  JULIA_NUM_THREADS = 8

Per a suggestion from the other thread, I tried opening the temporary postscript file that gets created, but it just hangs and never opens. Then I attempted to convert it using ps2pdf and received the same error as above

Error: /undefined in PSL_movie_label_completion
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:731/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--   --dict:162/250(L)--
Current allocation mode is local
Current file position is 23293
GPL Ghostscript 9.50: Unrecoverable error, exit code 1

I tried to upload the tmp postscript file per the suggestion from the other thread, but Discourse won’t allow me to upload .ps files.

Any thoughts?
Thank you in advance for your help.

You can zip the PS file and then attach. But please add also the command that generated it.

GMTjl_tmp.zip (6.8 KB)
Ah, okay. I have attached the file, and here is the command that created it

plot(1:10, rand(10), lw=1, lc=:blue, fmt=:png, marker=:square, 
     markeredgecolor=0, size=0.2, markerfacecolor=:red, title="Hello World", 
     xlabel="Spoons", ylabel="Forks", show=true)

@pwessel Can you see any obvious shit in this ps file? I can’t, but the ghost also complains. It was made with GMT6.0 and all machines where I tried to reproduce it have > 6.0 but I don’t see why it should fail in 6.0

Seems to be a mix of different GMT version PS. At the end of the PS header, this is set:

/PSL_movie_completion {} def

but at the end it uses the more recent name:

PSL_movie_label_completion /PSL_movie_label_completion {} def

and that is where it complaies that PSL_movie_label_completion is not defiend (which it isnt).

Proper PS has PSL_movie_label_completion set during the setup.

Would it be worth trying to build the latest version of GMT from source instead of using the stock version from the Ubuntu repo?

DOn’t know. Just confirming that GMT 6.0.0 only uses PSL_movie_completion so the above is a mixup. @Joaquim, might GMT.jl have its own PS include file with the prologue?

No way. GMT.jl only has .jl code

It’s very weird because the plot was made with a single julia call, that translates in two GMT calls, so the GMT version used must be the same.

Can you please try these two? The first calls GMT only once and the second makes a double call.

plot([0.0 0; 1 1], fmt=:png, show=1)
plot([0.0 0; 1 1], lw=1, marker=:square, fmt=:png, show=1)

(have to go throw the recyclable garbage (true one), so will be away for some minutes)

It might be something related to the plot and plot! commands. Both of the lines above fail for me with the same error 78 message. However, from the “Hello Round World” example from the GMT.jl docs, this command works and produces the correct temporary PS file

x = range(0, stop=2pi, length=180)
seno = sin.(x/0.2)*45;
coast(region=[0 360 -90 90], proj=(name=:laea, center=(300,30)), frame=:g,
      res=:crude, land=:navy, figsize=6)   #<-- This works

But the second part of that example fails with the same error message

plot!(collect(x)*60, seno, lw=0.5, lc=:red, fmt=:png, marker=:circle,
      markeredgecolor=0, size=0.05, markerfacecolor=:cyan, show=true)  #<-- This fails

All of those commands work for me. Might @mihalybaci have two GMT versions installed, somehow?

Doesn’t look like it, everything on my installed list shows 6.0.0.

Debug message does print something like this no?

plot([0.0 0; 1 1], fmt=:png, show=1, Vd=2)
"psxy  -JX12c/8c -Baf -BWSen -R-0.04/1.04/-0.04/1.04 -P -K > C:\\TMP\\GMTjl_tmp.ps"

Note that in spite saying psxy what gets called is gmt psxy

How can it create a good PS with gmt pscoast and not with gmt psxy?

Here is the full stack.

julia> plot([0.0 0; 1 1], lw=1, marker=:square, fmt=:png, show=1)
Error: /undefined in PSL_movie_label_completion
Operand stack:

Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1990   1   3   %oparray_pop   1989   1   3   %oparray_pop   1977   1   3   %oparray_pop   1833   1   3   %oparray_pop   --nostringval--   %errorexec_pop   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--
Dictionary stack:
   --dict:728/1123(ro)(G)--   --dict:0/20(G)--   --dict:75/200(L)--   --dict:160/250(L)--
Current allocation mode is local
Current file position is 22972
psconvert [ERROR]: System call [gs -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_tmp.ps' 2> './psconvert_38360c.bb'] returned error 256.
ERROR: Something went wrong when calling the module. GMT error number = 78
Stacktrace:
 [1] error(::String, ::Int32) at ./error.jl:42
 [2] gmt(::String) at /home/michael/.julia/packages/GMT/uSATO/src/gmt_main.jl:267
 [3] showfig(::Dict{Symbol,Any}, ::String, ::String, ::String, ::Bool, ::String) at /home/michael/.julia/packages/GMT/uSATO/src/common_options.jl:2621
 [4] finish_PS_module(::Dict{Symbol,Any}, ::Array{String,1}, ::String, ::Bool, ::Bool, ::Bool, ::Array{Float64,2}, ::Vararg{Any,N} where N) at /home/michael/.julia/packages/GMT/uSATO/src/common_options.jl:2760
 [5] common_plot_xyz(::String, ::Array{Float64,2}, ::String, ::Bool, ::Bool, ::Pair{Symbol,Any}, ::Vararg{Pair{Symbol,Any},N} where N) at /home/michael/.julia/packages/GMT/uSATO/src/psxy.jl:210
 [6] #plot#174 at /home/michael/.julia/packages/GMT/uSATO/src/plot.jl:116 [inlined]
 [7] top-level scope at REPL[973]:1

julia> 

Yes, that’s the stack trace of the command (psconvert) that tries to convert the faulty PS into PNG. But the problem is upward, when the PS file got mixed up with things that should not belong there.

If you can build GMT yourself, that will be only gains. Tons of things got added/improved/fixed since 6.0

So, I’m no closer to figuring out exactly why this bug occurred, but I did fix the problem by doing a complete uninstall of all GMT associated packages and performing a manual build and install of GMT v6.1.1, and the GSHHG and DCW data. Interestingly, I did at one point get a similar error that may help to pinpoint the cause. Just building the new GMT made this command work

plot(1:10, rand(10), lw=1, lc=:blue, fmt=:png, marker=:square,
     markeredgecolor=0, size=0.2, markerfacecolor=:red, title="Hello World",
     xlabel="Spoons", ylabel="Forks", show=true)

But this one failed with the same error message

coast(region=[0 360 -90 90], proj=(name=:laea, center=(300,30)), frame=:g,
      res=:crude, land=:navy, figsize=6)

When I built GMT, I only changed the install directory in ConfigUser.cmake and left the other options set to default so as to automatically download the data. So I tried to fix it by installing Ubuntu’s gmt-gshhg and gmt-dcw packages, but that did not work either. However, when I downloaded the data manually and specified the location in ConfigUser.cmake, all the errors when away and all the tests for GMT.jl passed.

One hypothesis is that the error number 78 message is related to the missing files. However, I don’t know why that would make

plot([0.0 0; 1 1], fmt=:png, show=1)

fail.

But in any case, I have a working version of GMT and GMT.jl now. Thank you for your help.

@mihalybaci, glad that you made it work. Thanks for the info you provided but it’s very hard for me from Windows to investigate it. It’s not useless, however, because this may come back in present or another disguised form.

Hi Joaquim:
I recently decided to upgrade my julia and GMT with xubuntu 20.04. I received the same error as described above.
I noticed that if I commented out the PSL_movie_* commands near the end of the postscript file, gs could process it without any difficulty.
I wonder if this is a GMT.jl bug since I grep’ed for the PSL_movie and found it is written in the GMT julia package in the GMT/FpKFD/src/common_options.jl file?
-Ed

Hmm, I suspect I know what is happening to you. Can you please try to edit the common_options.jl file and uncomment line 2665 and comment 2666? And the same for #L2673/2673?

The problem seems to be related to the fact that current GMT.jl closes PS files created by latest GMT whilst your older GMT (any latest version on Ubuntu is only new in their universe space but always years old in normal time) is expecting different commands to close the PS file.