GenericMappingTools / GMT.jl

Generic Mapping Tools Library Wrapper for Julia
Other
194 stars 28 forks source link

Two GMT.jl threads conflict? #1386

Closed liming-he closed 3 months ago

liming-he commented 7 months ago

I have one command line with GMT.jl running a program. Trying to run the same code but for different part of data in another command line. I then found that the GMT.jl in the first command-line quitted with error. The GMT.jl won't work in the 2nd command line either. Question: could two GMT.jl work in the same machine?

Many thanks. LH =========error message from the 1st command line ===== Error: /undefined in e3 Operand stack:

Execution stack: %interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1974 1 3 %oparray_pop 1973 1 3 %oparray_pop 1961 1 3 %oparray_pop 1817 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- Dictionary stack: --dict:767/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)-- --dict:159/250(L)-- Current allocation mode is local Last OS error: No such file or directory Current file position is 461267 psconvert [ERROR]: System call ['/home/liming/.julia/artifacts/4883a6685d86b068da934537a444a6d170d71730/bin/gs' -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_liming.ps' 2> './psconvert_2099957c.bb'] returned error 256. ERROR: Something went wrong when calling the module. GMT error number = 79 Stacktrace: [1] error(s::String) @ Base ./error.jl:35 [2] gmt(::String) @ GMT ~/.julia/packages/GMT/Mxc9g/src/gmt_main.jl:161 [3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String) @ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:3929 [4] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::GMTgrid{Float32, 2}, ::Vararg{Any}) @ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:4214 [5] grdimage(cmd0::String, arg1::GMTgrid{Float32, 2}, arg2::Nothing, arg3::Nothing; first::Bool, kwargs::Base.Pairs{Symbol, Any, NTuple{9, Symbol}, NamedTuple{(:show, :interp, :frame, :coast, :colorbar, :par, :fmt, :savefig, :dpi), Tuple{Bool, String, NamedTuple{(:axes, :annot), Tuple{NTuple{4, Symbol}, Bool}}, NamedTuple{(:shore, :ocean, :coast, :frame, :show), Tuple{NamedTuple{(:level, :pen), Tuple{Int64, Tuple{Float64, Symbol}}}, Symbol, Bool, NamedTuple{(:axes, :grid, :annot, :ticks), Tuple{String, Int64, Int64, Int64}}, Bool}}, NamedTuple{(:pos, :color, :show, :frame), Tuple{NamedTuple{(:anchor, :length, :horizontal, :offset), Tuple{Symbol, Tuple{Float64, Float64}, Bool, Tuple{Int64, Float64}}}, GMT.GMTcpt, Bool, NamedTuple{(:ylabel, :ticks, :annot), Tuple{Symbol, Symbol, Symbol}}}}, NamedTuple{(:MAP_ANNOT_ORTHO, :MAP_TITLE_OFFSET), Tuple{Symbol, Float64}}, Symbol, String, Int64}}}) @ GMT ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:123 [6] grdimage @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:53 [inlined] [7] #grdimage#348 @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:218 [inlined] [8] grdimage @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:218 [inlined] [9] plot_a_layer(x::GMTgrid{Float32, 2}, file_out::String, x_min::Int64, x_max::Int64, x_step::Int64, y_label::String) @ Main ./REPL[3]:14 [10] process_layer_batch(x::GMTgrid{Float32, 2}, m::GMTgrid{Float32, 2}, data_path1::String, fig_path::String, this_variable::String, Pixel_type::String, x_min::Int64, x_max::Int64, x_step::Int64, y_label::String, year_list::Vector{DateTime}, freq::String) @ Main ./REPL[4]:41 [11] top-level scope @ ./REPL[58]:12

=========error message from the 2nd command line =========== gmtset [ERROR]: Could not create file gmt.conf ERROR 1: Point outside of projection domain sh: 1: cannot create ./psconvert_2123775c.bb: Permission denied psconvert [ERROR]: System call ['/home/liming/.julia/artifacts/4883a6685d86b068da934537a444a6d170d71730/bin/gs' -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_liming.ps' 2> './psconvert_2123775c.bb'] returned error 512. ERROR: Something went wrong when calling the module. GMT error number = 79 Stacktrace: [1] error(s::String) @ Base ./error.jl:35 [2] gmt(::String) @ GMT ~/.julia/packages/GMT/Mxc9g/src/gmt_main.jl:161 [3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String) @ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:3929 [4] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::GMTgrid{Float32, 2}, ::Vararg{Any}) @ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:4214 [5] grdimage(cmd0::String, arg1::GMTgrid{Float32, 2}, arg2::Nothing, arg3::Nothing; first::Bool, kwargs::Base.Pairs{Symbol, Any, NTuple{9, Symbol}, NamedTuple{(:show, :interp, :frame, :coast, :colorbar, :par, :fmt, :savefig, :dpi), Tuple{Bool, String, NamedTuple{(:axes, :annot), Tuple{NTuple{4, Symbol}, Bool}}, NamedTuple{(:shore, :ocean, :coast, :frame, :show), Tuple{NamedTuple{(:level, :pen), Tuple{Int64, Tuple{Float64, Symbol}}}, Symbol, Bool, NamedTuple{(:axes, :grid, :annot, :ticks), Tuple{String, Int64, Int64, Int64}}, Bool}}, NamedTuple{(:pos, :color, :show, :frame), Tuple{NamedTuple{(:anchor, :length, :horizontal, :offset), Tuple{Symbol, Tuple{Float64, Float64}, Bool, Tuple{Int64, Float64}}}, GMT.GMTcpt, Bool, NamedTuple{(:ylabel, :ticks, :annot), Tuple{Symbol, Symbol, Symbol}}}}, NamedTuple{(:MAP_ANNOT_ORTHO, :MAP_TITLE_OFFSET), Tuple{Symbol, Float64}}, Symbol, String, Int64}}}) @ GMT ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:123 [6] grdimage @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:53 [inlined] [7] #grdimage#348 @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:218 [inlined] [8] grdimage @ ~/.julia/packages/GMT/Mxc9g/src/grdimage.jl:218 [inlined] [9] plot_a_layer(x::GMTgrid{Float32, 2}, file_out::String, x_min::Int64, x_max::Int64, x_step::Int64, y_label::String) @ Main ./REPL[3]:14 [10] process_layer_batch(x::GMTgrid{Float32, 2}, m::GMTgrid{Float32, 2}, data_path1::String, fig_path::String, this_variable::String, Pixel_type::String, x_min::Int64, x_max::Int64, x_step::Int64, y_label::String, year_list::Vector{DateTime}, freq::String) @ Main ./REPL[4]:41 [11] top-level scope @ ./REPL[53]:12

joa-quim commented 7 months ago

So if I got it right you want to run parallel jobs. I'm afraid that is currently not possible if those jobs imply creating figures. The problem is that all figures are created in the tmp directory using the same name, so a second plotting command will actually corrupt the fist one and that is what you got with all those errors from Ghostscript.

Allowing this should be possible in principle but it needs a solution to create unique file names for each Julia session. I'll think more about this.

liming-he commented 7 months ago

Thanks for the clarification.

joa-quim commented 7 months ago

You could try this hack to see if works. The default PS file name is the one that you get with GMT.PSname[1]. The hack would be to manually set it to a different name right after the using GMT command. For example (with my values):

julia> GMT.PSname[1]
"c:\\TMP/GMTjl_j.ps"

# On the second session do
GMT.PSname[1] = "c:\\TMP/GMTjl_j2.ps"

Now the two names should not conflict (but there are some other tmp names used by some modules that would do, though their use is much less frequent).

joa-quim commented 7 months ago

Actually you can test it even a bit further. I committed a change in the master version where if the environment variable JULIA_GMT_MULTIFILE is set (doesn't matter what it contains, just that it is set) then you should be able to do what you asked. It would be nice if you could test it.

liming-he commented 7 months ago

I tested the first method (changing GMT.PSname[1]), and it worked great. I will try the 2nd method later - just do not want to break my system that just works.