Gmt end show fails to execute Ghoscript

Hi all,

I have been working on GMT with Mac without any issues, but I have just installed GMT6 on my Windows machine, and I am running into a problem with gmt end show. Using MobaXterm, I was trying to create a bathymetry figure but when the code hits the last line “gmt end show”, it exits with the following error:
psconvert [ERROR]: Cannot execute Ghostscript (gs).
end [ERROR]: Failed to call psconvert
end [ERROR]: process_figures returned error 78

I can confirm this is the problematic line because I ran the code line by line too and the error shows up when I run this line. Also, it seems like psconvert is properly installed because I have access to the help message when typing “gmt psconvert”

Has anyone ever encountered this error and been able to fix it? My script is accessible below, but the files that I’m using are not supported by the website to upload.

Any help provided would be greatly appreciated!
Vincent

gmt set MAP_TICK_LENGTH_PRIMARY 5p/3p  # tick length
gmt set MAP_FRAME_TYPE Plain
gmt set MAP_FRAME_WIDTH 0.5c
gmt set MAP_FRAME_PEN 2p
gmt set FORMAT_GEO_MAP D
# font
gmt set FONT Helvetica
gmt set FONT_ANNOT_PRIMARY 12p,Helvetica  # main works
gmt set FONT_TITLE 12p,Helvetica
gmt set FONT_LABEL 12p,Helvetica  # no use now
# offset
gmt set MAP_TITLE_OFFSET 0.0c
gmt set MAP_GRID_PEN_PRIMARY thinner,black
# ground color
gmt set COLOR_BACKGROUND 0/30/80
gmt set COLOR_FOREGROUND 255/0/0
gmt set COLOR_NAN 255/255/255

globath_data=GMRT_Cocos_6d_9m_8d_22m.nc
Galapagos_data=Ztopo.grd
Pboundaries=Pboundaries.csv
cpt=terra

# Corners of map obtained via gmt grdinfo GMRT_Cocos_6d_9m_8d_22m.nc
min_lon=-84.7727050781
max_lon=-83.1225585938

min_lat=6.14273943678
max_lat=8.43759812265

center_lon=-83.94763183595
center_lat=7.290168779715

# Elevation min and max in m: -3136.94213867, 348.577545166


gmt begin Galapagos2024_bathymetry
                #gmt plot -R200/230/57/72 -JB$center_lon/$center_lat/$min_lat/$max_lat/6i -Bxa10f5 -Bya4f2 -BWNes #-B+t'Bathymetry of the Cocos Ridge and Galapagos Islands Plateau' -Fs6i

                gmt basemap -R$min_lon/$max_lon/$min_lat/$max_lat -JB$center_lon/$center_lat/$min_lat/$max_lat/6i -Bxa2f1 -Bya2f1 -BWNes
                # Plot the bathymetry from GMRT
                gmt grdimage $globath_data -R$globath_data #-JB$center_lon/$center_lat/$min_lat/$max_lat/6i

                gmt plot $Pboundaries -i0,1 -W1 -Sf0.5/6p+t+l -Gblack -l"Trench"

                gmt grdimage $Galapagos_data

                gmt colorbar -C$cpt  -Dx4.5i/1.7i+w-8/0.5+jML+ef -L0.0 -Y3c -X6c

                gmt psconvert

gmt end show

Well, there is clearly a problem with ghostscript. What does this print?

gmt basemap -Rg -JX15c -Ba -Vd -png lixo

Hmm, this is very strange. On Windows the ghostscript executable is called gswin64c.exe, not gs.

Hi Joaquim, thank you for your prompt reply, here’s the output I get when running your command:

gmt [DEBUG]: Obtained the ppid from parent: 10
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /usr/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /home/vinces
gmt [DEBUG]: GMT->session.USERDIR = /home/vinces/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /home/vinces/.gmt/cache [created]
gmt [DEBUG]: GMT: 0. Will try to find subdir=postscriptlight stem = PSL_custom_fonts suffix=.txt
gmt [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /home/vinces/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /home/vinces/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /usr/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath failed
gmt [DEBUG]: Map distance calculation will be Cartesian
gmt [DEBUG]: Exit:  gmtinit_new_GMT_ctrl
gmt [DEBUG]: Enter: New_PSL_Ctrl
gmt [DEBUG]: Exit:  New_PSL_Ctrl
gmt [DEBUG]: Enter: gmt_manage_workflow
gmt [DEBUG]: Exit : gmt_manage_workflow
gmt [DEBUG]: Enter: PSL_beginsession
gmt [DEBUG]: Exit : PSL_beginsession
gmt [DEBUG]: Enter: PSL_setdefaults
gmt [DEBUG]: Exit : PSL_setdefaults
gmt [DEBUG]: Enter: gmtlib_io_init
gmt [DEBUG]: Exit : gmtlib_io_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: Enter: gmt_hash_init
gmt [DEBUG]: Exit:  gmt_hash_init
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Enter: gmt_getdefaults
gmt [DEBUG]: Found file gmt.conf
gmt [DEBUG]: Reading GMT Default parameters from file: gmt.conf
gmt [DEBUG]: Exit:  gmt_getdefaults
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit:  gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmt_get_history
gmt [DEBUG]: Initialize FFTW with 8 threads.
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.so
gmt [DEBUG]: Loading core GMT shared library: libgmt.so
gmt [DEBUG]: Loading GMT plugins from: /usr/lib/x86_64-linux-gnu/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /usr/lib/x86_64-linux-gnu/gmt/plugins/supplements.so
gmt [DEBUG]: Shared Library # 2 (mbsystem). Path =
begin [INFORMATION]: Creating a workflow directory /home/vinces/.gmt/sessions/gmt6.10
begin [DEBUG]: The PROJ_GEODESIC set to Vincenty
begin [DEBUG]: Found file gmt.conf
begin [DEBUG]: Reading GMT Default parameters from file: gmt.conf
begin [DEBUG]: Set session name to be lixo png
begin [DEBUG]: Begin Workflow.  Session ID = 10. Directory /home/vinces/.gmt/sessions/gmt6.10 created.
begin [DEBUG]: GMT now running in modern mode [Session ID = 10]
gmt [DEBUG]: Use PS filename /home/vinces/.gmt/sessions/gmt6.10/gmt_0.ps-
gmt [DEBUG]: get_current_panel: No current panel selected so not in subplot mode
psbasemap [DEBUG]: History: Process -Rg
psbasemap [DEBUG]: History: Process -JX15c
psbasemap [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
psbasemap [INFORMATION]: Constructing the basemap
psbasemap [DEBUG]: Projected values in meters: -180 180 -90 90
psbasemap [DEBUG]: Auto-frame interval for axis 0 item 0: d = 60  f = 15
psbasemap [INFORMATION]: Auto-frame interval for x-axis (item 0): a60f60
psbasemap [DEBUG]: Auto-frame interval for axis 1 item 0: d = 30  f = 10
psbasemap [INFORMATION]: Auto-frame interval for y-axis (item 0): a30f30
psbasemap [INFORMATION]: Map scale is 0.024 km per cm or 1:2400.
psbasemap [DEBUG]: Running in PS mode modern
psbasemap [DEBUG]: Use PS filename /home/vinces/.gmt/sessions/gmt6.10/gmt_0.ps-
psbasemap [DEBUG]: Create hidden PS file /home/vinces/.gmt/sessions/gmt6.10/gmt_0.ps-
psbasemap [DEBUG]: No figure file /home/vinces/.gmt/sessions/gmt6.10/gmt.figures - nothing to do
psbasemap [DEBUG]: Got session name as lixo and default graphics formats as png
psbasemap [DEBUG]: Entering plot_map_gridlines
psbasemap [DEBUG]: Exiting plot_map_gridlines
psbasemap [DEBUG]: plot_wesn_map_boundary n_sides = 4
psbasemap [DEBUG]: plot_wesn_map_boundary doing side 0 with flag = 1
psbasemap [DEBUG]: plot_wesn_map_boundary doing side 1 with flag = 0
psbasemap [DEBUG]: plot_wesn_map_boundary doing side 2 with flag = 0
psbasemap [DEBUG]: plot_wesn_map_boundary doing side 3 with flag = 10
psbasemap [DEBUG]: Current size of half-baked PS file /home/vinces/.gmt/sessions/gmt6.10/gmt_0.ps- = 21499.
psbasemap (Free_Ctrl): tried to free unallocated memory
psbasemap (Free_Ctrl): tried to free unallocated memory
psbasemap (Free_Ctrl): tried to free unallocated memory
psbasemap [DEBUG]: GMT now running in modern mode [Session ID = 10]
psbasemap (gmtlib_free_tmp_arrays): tried to free unallocated memory
end [DEBUG]: End Workflow.  Session ID = 10. Directory /home/vinces/.gmt/sessions/gmt6.10 removed.
end [DEBUG]: No figure file /home/vinces/.gmt/sessions/gmt6.10/gmt.figures - nothing to do
end [DEBUG]: No figure file /home/vinces/.gmt/sessions/gmt6.10/gmt.figures - nothing to do
end [DEBUG]: Got session name as lixo and default graphics formats as png
end [INFORMATION]: Process GMT figure queue: 1 figures found
end [INFORMATION]: Processing GMT figure #0 [lixo png ]
end [DEBUG]: gmtlib_get_cpt_level: Fig: 0 Subplot: 2 Panel: () Inset: 0
end [DEBUG]: psconvert: '/home/vinces/.gmt/sessions/gmt6.10/gmt_0.ps-' -Tg -Flixo -A
end [DEBUG]: GMT now running in modern mode [Session ID = 10]
end (gmtlib_free_tmp_arrays): tried to free unallocated memory
psconvert [DEBUG]: gmt_check_executable: Pass to popen: [gs --version 2> /dev/null]
psconvert [DEBUG]: gs --version 2> /dev/null failed
psconvert [ERROR]: Cannot execute Ghostscript (gs).
psconvert (gmtlib_free_tmp_arrays): tried to free unallocated memory
end [ERROR]: Failed to call psconvert
end [ERROR]: process_figures returned error 78
end [INFORMATION]: Destroying the current workflow directory /home/vinces/.gmt/sessions/gmt6.10
end [DEBUG]: Delete gmt.canvas.0
end [DEBUG]: Delete gmt.conf
end [DEBUG]: Delete gmt.frame
end [DEBUG]: Delete gmt.layers.0
end [DEBUG]: Delete gmt.session
end [DEBUG]: Delete gmt_0.ps-
end (gmtlib_free_tmp_arrays): tried to free unallocated memory
basemap [ERROR]: Unable to call module end for a one-liner plot.
basemap [DEBUG]: Entering GMT_Destroy_Session
psbasemap (gmtlib_free_tmp_arrays): tried to free unallocated memory

This is not Windows. Do you have ghostscript installed?

gmt/sessions/gmt6.10/gmt_0.ps-

GMT6.1? This sessions name gmt6.10 is weird too. It should be gmt_session.PIDnumber

Indeed, I use MobaXterm as a WSL to be able to run shell scripts. I am trying to install ghostscript but I am running into issues with a sudo password that I never set, I will come back to you when I figure this out.