MATLAB crashes with grdimage

Hi,

I am using the GMT/Matlab toolbox. I am trying to plot a map with the earth relief of the Japan region. However, grdimage makes matlab shut down. I have been using the toolbox for a month already and other gmt modules are running fine.

I thought it was a matter of the earth_relif file resolution, so I have tried using earth_relief_01d.grd.
I have also downloaded the file in the current directory, but matlab still crashes.

This is the line that I am using for plotting:
gmt(‘grdimage ./earth_relief_01d.grd -JM15c -R118/125/20/26 -Baf -BWSen -Vd > ./test.ps’)

The output file is saved, but it is just showing the map frame.
These are the info that I get using -Vd

grdimage [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
grdimage [DEBUG]: Look for file 118/125/20/26 in /Users/sbrizzi/.gmt
grdimage [DEBUG]: Look for file 118/125/20/26 in /Users/sbrizzi/.gmt/cache
grdimage [DEBUG]: Look for file 118/125/20/26 in /Users/sbrizzi/.gmt/server
grdimage [DEBUG]: Got regular w/e/s/n for region (118/125/20/26)
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: Replace file ./earth_relief_01d.grd with path ./earth_relief_01d.grd
grdimage [DEBUG]: Replace file ./earth_relief_01d.grd with ./earth_relief_01d.grd
grdimage [DEBUG]: Projected grid is non-orthogonal, nonlinear, or dpi was changed
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: ./earth_relief_01d.grd is most likely a grid. Open in GMT as grid
grdimage [INFORMATION]: Read header from file ./earth_relief_01d.grd
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: Replace file ./earth_relief_01d.grd with path ./earth_relief_01d.grd
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: Replace file ./earth_relief_01d.grd with path ./earth_relief_01d.grd
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: Object ID 4 : Registered Grid File ./earth_relief_01d.grd as an Input resource with geometry Surface [n_objects = 1]
grdimage [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdimage [DEBUG]: gmtapi_import_grid: Passed ID = 4 and mode = 131073
grdimage [DEBUG]: Found readable file ./earth_relief_01d.grd
grdimage [DEBUG]: Calling nc_open on ./earth_relief_01d.grd, ncid = 65536, err = 0
grdimage [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdimage [DEBUG]: Calling nc_open on ./earth_relief_01d.grd, ncid = 65536, err = 0
grdimage [INFORMATION]: netCDF grid ./earth_relief_01d.grd has no default CPT.
grdimage [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdimage [DEBUG]: Call gmtgrdio_doctor_geo_increments on a geographic grid
grdimage [DEBUG]: Geographic input grid, longitudes span exactly 360
grdimage [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdimage [DEBUG]: Set_Object for family: 1
==> 1 API Objects at end of GMT_Read_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0  4 7f9d3e6a34c0 Grid       Grid       Input  0 Y N 1
--------------------------------------------------------
grdimage [INFORMATION]: Central meridian not given, default to 121.5
grdimage [DEBUG]: Projected values in meters: -389618 389618 2.25842e+06 2.98036e+06
grdimage [DEBUG]: Auto-frame interval for axis 0 item 0: d = 1  f = 0.25
grdimage [INFORMATION]: Auto-frame interval for x-axis (item 0): a1f0.25
grdimage [DEBUG]: Auto-frame interval for axis 1 item 0: d = 1  f = 0.25
grdimage [INFORMATION]: Auto-frame interval for y-axis (item 0): a1f0.25
grdimage [INFORMATION]: Map scale is 51.9491 km per cm or 1:5.19491e+06.
grdimage [DEBUG]: Running in PS mode classic
grdimage [DEBUG]: Opened PS file ./test.ps
grdimage [DEBUG]: Basemap order: Frame = above  Grid = above  Tick/Annot = below
grdimage [INFORMATION]: Allocate and read data from file ./earth_relief_01d.grd
grdimage [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdimage [DEBUG]: gmtapi_import_grid: Passed ID = 4 and mode = 131074
grdimage [INFORMATION]: Reading grid from file ./earth_relief_01d.grd
grdimage [DEBUG]: Calling nc_open on ./earth_relief_01d.grd, ncid = 65536, err = 0
grdimage [DEBUG]: packed z-range: [-12984,2599]
grdimage [DEBUG]: Calling nc_close on ncid 65536, err = 0
grdimage [DEBUG]: Geographic input grid, longitudes span less than 360
grdimage [DEBUG]: Chosen boundary condition for all edges: extended data
grdimage [INFORMATION]: gmt_grd_BC_set: All boundaries set via extended data.
grdimage [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdimage [DEBUG]: Set_Object for family: 1
==> 1 API Objects at end of GMT_Read_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0  4 7f9d3e6a34c0 Grid       Grid       Input  2 Y N 1
--------------------------------------------------------
grdimage [DEBUG]: CPT argument (null) understood to be a master table
grdimage [DEBUG]: Look for file google/turbo in /Users/sbrizzi/.gmt
grdimage [DEBUG]: Look for file google/turbo in /Users/sbrizzi/.gmt/cache
grdimage [DEBUG]: Look for file google/turbo in /Users/sbrizzi/.gmt/server
grdimage [DEBUG]: GMT: 0. Will try to find subdir=cpt stem = google/turbo suffix=.cpt
grdimage [DEBUG]: GMT: 1. gmt_getsharepath trying current dir
grdimage [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/sbrizzi/.gmt
grdimage [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/sbrizzi/.gmt/cpt
grdimage [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/gmt/share/cpt
grdimage [DEBUG]: Given full path to file /opt/gmt/share/cpt/google/turbo.cpt
grdimage [DEBUG]: Found readable file /opt/gmt/share/cpt/google/turbo.cpt
grdimage [DEBUG]: Object ID 5 : Registered CPT File /opt/gmt/share/cpt/google/turbo.cpt as an Input resource with geometry Volume [n_objects = 2]
grdimage [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
grdimage [DEBUG]: gmtapi_import_palette: Passed ID = 5 and mode = 8
grdimage [INFORMATION]: Reading CPT from File /opt/gmt/share/cpt/google/turbo.cpt
grdimage [DEBUG]: Reading CPT from /opt/gmt/share/cpt/google/turbo.cpt
grdimage [DEBUG]: GMT_End_IO: Input resource access is now disabled
grdimage [DEBUG]: Set_Object for family: 3
==> 2 API Objects at end of GMT_Read_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0  4 7f9d3e6a34c0 Grid       Grid       Input  2 Y N 1
* 1  5 7f9d3c4ad700 CPT        CPT        Input  2 Y N 1
--------------------------------------------------------
grdimage [INFORMATION]: Auto-stretching CPT file google/turbo to fit data range -6210 to 1234.5
grdimage [INFORMATION]: Project the input grid
grdimage [DEBUG]: Object ID 6 : Registered Grid Memory Reference 7f9d3e3aa810 as an Input resource with geometry Surface [n_objects = 3]
grdimage [DEBUG]: Successfully duplicated a Grid
==> 3 API Objects at end of GMT_Duplicate_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0  4 7f9d3e6a34c0 Grid       Grid       Input  2 Y N 1
* 1  5 7f9d3c4ad700 CPT        CPT        Input  2 Y N 1
* 2  6 7f9d3e3aa810 Grid       Grid       Input  0 Y N 1
--------------------------------------------------------
grdimage [DEBUG]: gmt_project_init: IN: Inc [0/0] n_columns/n_rows [12/11] dpi = 0 offset = 0
grdimage [DEBUG]: gmt_project_init: OUT: Inc [0/0] n_columns/n_rows [12/11] dpi = 0 offset = 0
grdimage [INFORMATION]: Grid projection from size 12x11 to 12x11
grdimage [DEBUG]: Successfully added data array to previously registered Grid container
==> 3 API Objects at end of GMT_Create_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0  4 7f9d3e6a34c0 Grid       Grid       Input  2 Y N 1
* 1  5 7f9d3c4ad700 CPT        CPT        Input  2 Y N 1
* 2  6 7f9d3e3aa810 Grid       Grid       Input  0 Y N 1
--------------------------------------------------------
grdimage [DEBUG]: gmt_grd_project: In [116/127/18/28] and out [-1.68728908886/7.59280089989/-1.77393691697/7.35498111981]
grdimage [DEBUG]: GMT_Destroy_Data: freed memory for a Grid for object 4
grdimage [DEBUG]: gmtlib_unregister_io: Unregistering object no 4 [n_objects = 2]
grdimage [DEBUG]: gmtlib_unregister_io: Object no 4 has non-NULL resource pointer
==> 2 API Objects at end of GMT_Destroy_Data

I am also attaching the matlab crash report.
Any help on how to fix this would be really appreciated!

EDIT: I forgot to mention that grdimage works perfectly if I run commands from the terminal

matlab_crash_report.txt (991.7 KB)

I’m not seeing any crash in your listing.
It works for me if I replace ./earth_relief_01d.grd by @earth_relief_01d.grd

Hi Joaquim,
thanks for your reply. I have tried again as you suggested but Matlab still shuts down and by shut down, I mean matlab closes as soon as I run the command and gives me a crash report.

While playing around with other modules working with earth_relief I have found out that running:

gmt(‘grdinfo @earth_relief_01m.grd -G’)

returns this error

Matlab [WARNING]: Remote dataset given to a data processing module but no registration was specified - default to gridline registration (if available)
grdblend [NOTICE]: Remote data courtesy of GMT data server oceania [http://oceania.generic-mapping-tools.org]

grdblend [NOTICE]: SRTM15 Earth Relief at 01x01 arc minutes reduced by Gaussian Cartesian filtering (1.9 km fullwidth) [Tozer et al., 2019].
grdblend [NOTICE]: → Download 30x30 degree grid tile (earth_relief_01m_g): S90W180

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).

–PAR= Temporarily override GMT default setting(s) (repeatable).
(See gmt.conf documentation for GMT default parameters).
[Session Matlab (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session Matlab (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session Matlab (0)]: Error returned from GMT API: GMT_OBJECT_NOT_FOUND (60)

Using @earth_relief_01d.grd works fine.

when running this example, everything works until the resolution of earth_relief is 06m. If I use 05m or higher, I get this error from -Vd:

Matlab [WARNING]: Remote dataset given to a data processing module but no registration was specified - default to gridline registration (if available)
grdtrack [DEBUG]: Look for file 284.9/296.6/-33.6/-30.9 in /Users/sbrizzi/.gmt
grdtrack [DEBUG]: Look for file 284.9/296.6/-33.6/-30.9 in /Users/sbrizzi/.gmt/cache
grdtrack [DEBUG]: Look for file 284.9/296.6/-33.6/-30.9 in /Users/sbrizzi/.gmt/server
grdtrack [DEBUG]: Got regular w/e/s/n for region (284.9/296.6/-33.6/-30.9)
grdtrack [DEBUG]: Found readable file ./tmp_track
grdtrack [DEBUG]: Replace file ./tmp_track with path ./tmp_track
grdtrack [DEBUG]: Replace file ./tmp_track with ./tmp_track
grdtrack [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdtrack [DEBUG]: Replace file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk with /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdtrack [INFORMATION]: Processing input grid(s)
grdtrack [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdtrack [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdtrack [DEBUG]: Found readable file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdtrack [DEBUG]: Object ID 193 : Registered Grid File /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk as an Input resource with geometry Surface [n_objects = 6]
grdtrack [DEBUG]: gmtapi_import_grid: Passed ID = 193 and mode = 131073
grdtrack [DEBUG]: Grid/Image dimensions imply w/e/s/n = 284.833/296.667/-33.6667/-30.8333, inc = 0.0833333/0.0833333, gridline registration, n_layers = 1
grdtrack [DEBUG]: Geographic input grid, longitudes span less than 360
grdtrack [DEBUG]: Chosen boundary condition for all edges: geographic
grdtrack [DEBUG]: Geographic input grid, longitudes span less than 360
grdtrack [DEBUG]: Set_Object for family: 1
==> 6 API Objects at end of GMT_Read_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0 30 600030a94ba0 Data Table Data Table Output 0 Y Y 0
* 1 64 600030acf4e0 Data Table Data Table Output 0 Y Y 0
* 2 100 600024bf1680 Data Table Data Table Output 0 Y N 0
* 3 107 600030ae22e0 Data Table Data Table Output 0 Y N 0
* 4 174 600024a32a60 Data Table Data Table Output 0 Y Y 0
* 5 193 60000bdc1020 Grid       Grid       Input  2 Y N 1
--------------------------------------------------------
grdtrack [WARNING]: (w - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdtrack [WARNING]: w reset from 284.9 to 284.833333333
grdtrack [WARNING]: (e - x_min) must equal (NX + eps) * x_inc), where NX is an integer and |eps| <= 0.0001.
grdtrack [WARNING]: e reset from 296.6 to 296.666666667
grdtrack [WARNING]: (s - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdtrack [WARNING]: s reset from -33.6 to -33.6666666667
grdtrack [WARNING]: (n - y_min) must equal (NY + eps) * y_inc), where NY is an integer and |eps| <= 0.0001.
grdtrack [WARNING]: n reset from -30.9 to -30.8333333333
grdtrack [DEBUG]: gmtapi_import_grid: Passed ID = 193 and mode = 131074
grdtrack [DEBUG]: Object ID 194 : Registered Grid Memory Copy 60000bdc2af0 as an Output resource with geometry Surface [n_objects = 7]
grdtrack [DEBUG]: Successfully created a new Grid container
grdtrack [DEBUG]: Set_Object for family: 1
==> 7 API Objects at end of GMT_Create_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0 30 600030a94ba0 Data Table Data Table Output 0 Y Y 0
* 1 64 600030acf4e0 Data Table Data Table Output 0 Y Y 0
* 2 100 600024bf1680 Data Table Data Table Output 0 Y N 0
* 3 107 600030ae22e0 Data Table Data Table Output 0 Y N 0
* 4 174 600024a32a60 Data Table Data Table Output 0 Y Y 0
* 5 193 60000bdc1020 Grid       Grid       Input  0 Y N 1
* 6 194 60000bdc2af0 Grid       Grid       Output 0 Y Y 1
--------------------------------------------------------
grdtrack [DEBUG]: VirtualFile name created: @GMTAPI@-S-O-G-G-G-Y-000194
grdtrack [DEBUG]: GMT_Call_Command string: gmt grdblend /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk -R284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333 -I05m -rg -G@GMTAPI@-S-O-G-G-G-Y-000194 -fg -Co+n
grdtrack [DEBUG]: Revised options: @earth_relief_05m_g/ -R284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333 -I05m -rg -G@GMTAPI@-S-O-G-G-G-Y-000194 -fg -Co+n
grdblend [DEBUG]: History: Process -R284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333
grdblend [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
grdblend [DEBUG]: Look for file 284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333 in /Users/sbrizzi/.gmt
grdblend [DEBUG]: Look for file 284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333 in /Users/sbrizzi/.gmt/cache
grdblend [DEBUG]: Look for file 284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333 in /Users/sbrizzi/.gmt/server
grdblend [DEBUG]: Got regular w/e/s/n for region (284.8333333333333/296.6666666666666/-33.66666666666666/-30.83333333333333)
grdblend [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Replace file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk with /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Map distance calculation will be using great circle approximation with authalic auxiliary latitudes and authalic (R_2) radius = 6371007.1809 m, in meter.
grdblend [DEBUG]: gmtapi_init_import: Passed family = Data Table and geometry = Non-Geographical
grdblend [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Found readable file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Object ID 195 : Registered Data Table File /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk as an Input resource with geometry Non-Geographical [n_objects = 8]
grdblend (gmt_api.c:7682(gmtapi_init_import)): FYI: gmt_M_free given a NULL pointer - ignored
grdblend [DEBUG]: gmtapi_init_import: Added 1 new sources
grdblend [DEBUG]: GMT_Init_IO: Returned first Input object ID = 195
grdblend [DEBUG]: GMT_Begin_IO: Mode value 1 not considered (ignored)
grdblend [DEBUG]: GMT_Begin_IO: Initialize record-by-record access for Input
grdblend [DEBUG]: gmtapi_next_io_source: Selected object 195
grdblend [DEBUG]: Given full path to file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Found readable file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: Calling nc_open on /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk, ncid = 0, err = -51
grdblend [DEBUG]: Found readable file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [INFORMATION]: Reading Data Table from file /var/folders/tp/_66ljs6566bds4nn78xxfpqm0000gn/T/=tiled_217_GX_I5dPwk
grdblend [DEBUG]: GMT_Begin_IO: Input resource access is now enabled [record-by-record]
grdblend [DEBUG]: Geographic input grid, longitudes span less than 360
grdblend [DEBUG]: Chosen boundary condition for all edges: geographic
grdblend [DEBUG]: Geographic input grid, longitudes span less than 360
grdblend [DEBUG]: Object ID 196 : Registered Grid Memory Reference 60000be06040 as an Input resource with geometry Surface [n_objects = 9]
grdblend [DEBUG]: Successfully created a new Grid container
grdblend [DEBUG]: Set_Object for family: 1
==> 9 API Objects at end of GMT_Create_Data
--------------------------------------------------------
K.. ID RESOURCE.... FAMILY.... ACTUAL.... DIR... S O M L
--------------------------------------------------------
* 0 30 600030a94ba0 Data Table Data Table Output 0 Y Y 0
* 1 64 600030acf4e0 Data Table Data Table Output 0 Y Y 0
* 2 100 600024bf1680 Data Table Data Table Output 0 Y N 0
* 3 107 600030ae22e0 Data Table Data Table Output 0 Y N 0
* 4 174 600024a32a60 Data Table Data Table Output 0 Y Y 0
* 5 193 60000bdc1020 Grid       Grid       Input  0 Y N 1
* 6 194 60000bdc2af0 Grid       Grid       Output 0 Y Y 1
* 7 195            0 Data Table Data Table Input  1 Y N 2
* 8 196 60000be06040 Grid       Grid       Input  0 Y N 2
--------------------------------------------------------
grdblend [DEBUG]: Look for file S90W180.earth_relief_05m_g.nc in /Users/sbrizzi/.gmt
grdblend [DEBUG]: Look for file S90W180.earth_relief_05m_g.nc in /Users/sbrizzi/.gmt/cache
grdblend [DEBUG]: Look for file S90W180.earth_relief_05m_g.nc in /Users/sbrizzi/.gmt/server
grdblend [INFORMATION]: Downloading earth_relief_05m_g/ tile 1 of 1 [S90W180]
grdblend [INFORMATION]: Convert SRTM tile from JPEG2000 to netCDF grid [/Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.nc]
grdblend [DEBUG]: Running: grdconvert /Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.jp2 -G/Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.nc=ns+s0.5+o0 -Z+s0.5+o-0 -fg -Vq --IO_NC4_DEFLATION_LEVEL=9 --GMT_HISTORY=readonly
grdblend [DEBUG]: GMT_Call_Command string: gmt grdconvert /Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.jp2 -G/Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.nc=ns+s0.5+o0 -Z+s0.5+o-0 -fg -Vq --IO_NC4_DEFLATION_LEVEL=9 --GMT_HISTORY=readonly
grdblend [DEBUG]: Revised options: /Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.jp2 -G/Users/sbrizzi/.gmt/server/earth/earth_relief/earth_relief_05m_g/S90W180.earth_relief_05m_g.nc=ns+s0.5+o0 -Z+s0.5+o-0 -fg -Vq --IO_NC4_DEFLATION_LEVEL=9 --GMT_HISTORY=readonly

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).

  --PAR=<value> Temporarily override GMT default setting(s) (repeatable).
     (See gmt.conf documentation for GMT default parameters).
[Session Matlab (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session Matlab (0)]: Error returned from GMT API: GMT_FILE_NOT_FOUND (16)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session Matlab (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)

It’s very likely that I’m wrong, but it looks like authorizations access. Does Matlab or GMT can read/write where things happen?

I can’t reproduce those problems either. What GMT version do you have installed?

I’m using GMT 6.4 and Matlab 2022b.
I’m thinking maybe something went wrong with the installation? Because I also get some errors when using gmt set (not that big of a deal though)

For example, if I run
gmt('gmtset COLOR_BACKGROUND black')
I get this:

gmtset [ERROR]: Unrecognized keyword COLOR_BACKGROUND.
gmtset [ERROR]:  1 GMT Defaults conversion errors from command options
GMT: Module return with failure while executing the command

I guess so?! do you have any suggestions on how to check this?

What does this print, when run from the command line (not from Matlab)?
gmt --show-bindir

/opt/gmt/bin

Ah, it’s a Mac. I thought it was Windows. That makes it much more difficult for me to help.

(just between us. Don’t you want to try GMT.jl, the Julia wrapper? It’s soooo much better (less the IDE))

Yes, I am using a Mac!

I guess I could give Julia a try, but I would like to explore all possible solutions using MATLAB before considering a switch to a new language.

I am currently working on developing a routine for global earthquakes extraction in subduction zones, and I was super excited to use GMT with MATLAB since I am already familiar with MATLAB but not with bash. I have made good progress with my work so far, and starting from scratch with Julia would not be ideal, despite its similarities to MATLAB.

(just between us, I am downloading Julia… :slightly_smiling_face:)

Yep, I surely understand but it’s actually quite easy to learn Julia when one knows Matlab. To start with just remember that ( ) it’s only for functions.

(1- use juliaup
2- install GMT with ] add GMT#GMT_jll to get the latest GMTdev build
)

Paul might be able to give some hints about the Matlab issues.

Thank you, Joaquim! I really appreciate it.
(but I still have a small hope that Paul can come up with a solution to this problem :slightly_smiling_face:)

Haven’t been messing with the GMT/MEX for a long time. Best hope is for you to build the gmtmex executable function yourself - following the gmtmex GitHub info first, then use GMT’s share/tool/ gmt_prepmex.sh to do the lib renaming and placing a GMT installation with gmtmex in /opt/gmt. You then use that as the path and it should work for gmtmex.

Hi Paul,

thanks for your reply!
I don’t think I got how I am supposed to proceed. I followed the instructions on GitHub to create the gmtmex file, so I have already run gmt_prepmex.sh to do the libraries renaming. Should I do this again? If you could walk me through all the steps, I’d really appreciate it!

Well, then you are ahead of mine. I suspect it then may be related to the MATLAB version. I dont think I have tried this on anything younger than 2021a.

I read on GitHub that you’ve build this with MATLAB 2021a and I am using 2022b, so I am gonna try with the 2021a version. I guess I should rebuild the mex file ( i.e., I cannot just add to the matlab path the gmtmex file I have), right?

I doubt it is a Matlab version issue but I also don’t know what it is. The BIG issue with Matlab versions is if they change their dependencies versions, and that is why the gmtmex normally needs to be built for particular Matlab versions.

Would you be able to try debugging with Xcode?

I really would not know where to start from to be honest :sweat_smile:
Is there any documentation online just to have an idea?
I was also thinking to get in touch with Mathworks, even though I fear it’d be really complicated to explain the issue…

Hmm, probably not such a good idea to bring this debug issue up on Mac. We have this general instructions but they look real scary and I don’t see an entry on how to debug the gmtmex, though it should very similar to debug GMT.jl. On Windows, after building a debug GMT version is just a 2 or 3 clicks thing but on unix wow.