Gmt not reading FORMAT_GEO_MAP from gmt.conf

Hello,

I (seemingly) cannot get gmt to read the gmt.conf file. I feel like there must be another file somewhere overriding it, but I can’t find one. At the moment, I have gmt.conf in my current working directory. I have also tried it in my home directory and in the .gmt directory in my home directory (making sure gmt.conf is not in multiple of those places at once.)

I am running GMT 6.4 on Mac OS Sonoma (14.1.2). I installed GMT6 using MacPorts.

I’m running the tutorial 3 as a script, slightly modified (-R) so as to have the axis display fractions of a degree:

#!/bin/sh
gmt begin -Vd GMT_tut_3
 	gmt coast -R270/271/0/1 -JM6i -Bxya0.3g0.3 -Gchocolate -V
gmt end show

I generate a fresh gmt.conf file in the current working directory thus:

gmt defaults > gmt.conf

The default FORMAT_GEO_MAP is ddd:mm:ss, and gmt outputs the axis format correctly in ddd:mm:ss format.

When I change the FORMAT_GEO_MAP to +D in gmt.conf in the current working directory (and I save it!), the plot does not change; the axis is still output in ddd:mm:ss format. Furthermore, if I add this line to my script:

gmt get FORMAT_GEO_MAP

it does shows that FORMAT_GEO_MAP is still set to ddd:mm:ss.

Thus I think it is not reading the gmt.conf file. Why would this be? How can I fix it so that it reads the conf file?

The output of the -Vd is:

(base) ~/Documents/gmtTestLocal$ ./GMT_tut_3.sh 
gmt [DEBUG]: GMT_Create_Session: Terminal width = 178
gmt [DEBUG]: Obtained the ppid from parent: 6164
gmt [DEBUG]: Enter: gmtinit_new_GMT_ctrl
gmt [DEBUG]: GMT->session.SHAREDIR = /opt/local/lib/gmt6/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /Users/gwen
gmt [DEBUG]: GMT->session.USERDIR = /Users/gwen/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /Users/gwen/.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 /Users/gwen/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/gwen/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/local/lib/gmt6/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/local/lib/gmt6/share/gmt
gmt [DEBUG]: GMT: 6. 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]: Enter: gmt_reload_settings
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Found file gmt.conf
gmt [DEBUG]: Reading GMT Default parameters from file: gmt.conf
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: gmtinit_parse_map_annot_oblique: Converted separate,lon_horizontal,lat_horizontal,tick_extend to 14
gmt [DEBUG]: The PROJ_GEODESIC set to Vincenty
gmt [DEBUG]: Exit:  gmt_reload_settings
gmt [DEBUG]: Enter: gmtlib_plot_C_format
gmt [DEBUG]: Exit:  gmtlib_plot_C_format
gmt [DEBUG]: Enter: gmtinit_get_history
gmt [DEBUG]: GMT_Create_Session initialized GMT structure
gmt [DEBUG]: Loading core GMT shared library: libgmt.dylib
gmt [DEBUG]: Shared Library # 0 (core). Path = libgmt.dylib
gmt [DEBUG]: Loading GMT plugins from: /opt/local/lib/gmt6/lib/gmt/plugins
gmt [DEBUG]: Shared Library # 1 (supplements). Path = /opt/local/lib/gmt6/lib/gmt/plugins/supplements.so
gmt [DEBUG]: Revised options: -Vd GMT_tut_3
begin [INFORMATION]: Creating a workflow directory /Users/gwen/.gmt/sessions/gmt_session.6164
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]: The PROJ_GEODESIC set to Vincenty
begin [DEBUG]: gmtinit_parse_map_annot_oblique: Converted separate,lon_horizontal,lat_horizontal,tick_extend to 14
begin [DEBUG]: The PROJ_GEODESIC set to Vincenty
begin [DEBUG]: Set session name to be GMT_tut_3
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_GSHHS_c.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_GSHHS_c.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_river_c.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_river_c.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_border_c.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_border_c.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_GSHHS_l.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_GSHHS_l.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_river_l.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_river_l.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_border_l.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_border_l.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_GSHHS_i.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_GSHHS_i.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_river_i.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_river_i.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_border_i.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_border_i.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_GSHHS_h.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_GSHHS_h.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_river_h.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_river_h.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_border_h.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_border_h.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_GSHHS_f.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_GSHHS_f.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_river_f.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_river_f.nc
begin [DEBUG]: 1. GSHHG: GSHHGDIR set, trying /opt/local/share/gmt/gshhg/binned_border_f.nc
begin [DEBUG]: 1. GSHHG: OK, could access /opt/local/share/gmt/gshhg/binned_border_f.nc
begin [DEBUG]: gmtinit_print_map_annot_oblique: Converted 14 to separate,lon_horizontal,lat_horizontal,tick_extend
begin [DEBUG]: Begin Workflow.  Session ID = 6164. Directory /Users/gwen/.gmt/sessions/gmt_session.6164 created.
begin [DEBUG]: GMT now running in modern mode [Session ID = 6164]
gmt [DEBUG]: Entering GMT_Destroy_Session
gmt [WARNING]: GMT_COMPATIBILITY: Expects values from 6 to 6; reset to 6.
coast [INFORMATION]: Central meridian not given, default to 270.5
coast [INFORMATION]: Map scale is 7.30443 km per cm or 1:730443.
coast [INFORMATION]: -D option: Selected resolution -Df
coast [INFORMATION]: Selected ice front line as Antarctica coastline
coast [INFORMATION]: GSHHG version 2.3.7
coast [INFORMATION]: Derived from World Vector Shoreline, CIA WDB-II, and Atlas of the Cryosphere
coast [INFORMATION]: Processed by Paul Wessel and Walter H. F. Smith, 1994-2017
coast [INFORMATION]: Save current gridline information to gmt.history
gmt [WARNING]: GMT_COMPATIBILITY: Expects values from 6 to 6; reset to 6.
ddd:mm:ss
gmt [WARNING]: GMT_COMPATIBILITY: Expects values from 6 to 6; reset to 6.
(base) ~/Documents/gmtTestLocal$ 

I have found that putting the line
gmt set FORMAT_GEO_MAP +D
within the script will get me the output I want, and the line
gmt get FORMAT_GEO_MAP
in the script will then output +D as I want it to. But I can’t get it to work by setting it in gmt.conf. I’d appreciate any ideas you might have to help me solve this.

Thanks!

On Linux I can see the files a program opens with strace, do you have it on your system?

strace -f gmt get FORMAT_GEO_MAP |& grep openat | grep -v '\.so'

shows

openat(AT_FDCWD, "/proc/self/status", O_RDONLY) = 3
openat(AT_FDCWD, "/sys/devices/system/node", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/sys/devices/system/node/node0/meminfo", O_RDONLY) = 4
openat(AT_FDCWD, "/sys/devices/system/cpu", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
openat(AT_FDCWD, "/proc/self/status", O_RDONLY) = 3
openat(AT_FDCWD, "/sys/devices/system/cpu", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = 3
[pid 327670] openat(AT_FDCWD, "/usr/local/share/gmt/postscriptlight/PSL_custom_fonts.txt", O_RDONLY <unfinished ...>
[pid 327670] <... openat resumed>)      = 3
[pid 327670] openat(AT_FDCWD, "/usr/local/share/gmt/postscriptlight/PSL_custom_fonts.txt", O_RDONLY <unfinished ...>
[pid 327670] <... openat resumed>)      = 3
[pid 327670] openat(AT_FDCWD, "gmt.history", O_RDWR <unfinished ...>
[pid 327670] <... openat resumed>)      = -1 ENOENT (No such file or directory)
[pid 327670] openat(AT_FDCWD, "/sys/devices/system/cpu/online", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 327670] <... openat resumed>)      = 3
[pid 327670] openat(AT_FDCWD, "/etc/localtime", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 327670] <... openat resumed>)      = 3

A quick search tells me there is no strace on OSX, but everyone says that dtrace does the same (and most say it is better!) …

Interesting. I don’t know anything about those types of commands. I couldn’t get dtrace to work, but dtruss gave me some output:

sh-3.2$ sudo dtruss gmt get FORMAT_MAP_GEO 2>&1 | grep "gmt.conf"
access("gmt.conf\0", 0x4, 0x0)		 = -1 2
access("/Users/gwen/gmt.conf\0", 0x4, 0x0)		 = -1 2
access("/Users/gwen/.gmt/gmt.conf\0", 0x4, 0x0)		 = -1 2
access("/Users/gwen/.gmt/server/gmt.conf\0", 0x4, 0x0)		 = -1 2
access("/Users/gwen/.gmt/cache/gmt.conf\0", 0x4, 0x0)		 = -1 2
sh-3.2$ 

Not sure what it means…

I also notice these odd lines in the gmt debug:

gmt [DEBUG]: GMT->session.SHAREDIR = /opt/local/lib/gmt6/share/gmt
gmt [DEBUG]: GMT->session.HOMEDIR = /Users/gwen
gmt [DEBUG]: GMT->session.USERDIR = /Users/gwen/.gmt [created]
gmt [DEBUG]: GMT->session.CACHEDIR = /Users/gwen/.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 /Users/gwen/.gmt
gmt [DEBUG]: GMT: 3. gmt_getsharepath trying USERDIR subdir /Users/gwen/.gmt/postscriptlight
gmt [DEBUG]: GMT: 4. gmt_getsharepath trying SHAREDIR subdir /opt/local/lib/gmt6/share/gmt/postscriptlight
gmt [DEBUG]: GMT: 5. gmt_getsharepath trying SHAREDIR /opt/local/lib/gmt6/share/gmt
gmt [DEBUG]: GMT: 6. gmt_getsharepath failed

(1) Odd that this line says ‘created’; .gmt directory in my home directory was/is already there:
gmt [DEBUG]: GMT->session.USERDIR = /Users/gwen/.gmt [created]

(2) Why did gmt_getsharepath fail (last line), when .gmt directory is right there, and if it wasn’t, it should have been created? That is, it seems to have blown right past this line:
gmt [DEBUG]: GMT: 2. gmt_getsharepath trying USERDIR /Users/gwen/.gmt

Not sure I understand what you need. If I run this script and comment out either of the two FORMAT_MAP_GEO statements I get what I am asking for:

#!/bin/bash
gmt begin GMT_tut_3
	gmt defaults > gmt.conf
	#gmt set FORMAT_GEO_MAP ddd.xxx
	gmt set FORMAT_GEO_MAP +D
	gmt get FORMAT_GEO_MAP
	gmt coast -R270/271/0/1 -JM6i -Bxya0.3g0.3 -Gchocolate
gmt end show

and the right answer is returned by gmt get. This is GMT 6.5 (released within a week we hope) so it is possible we fixed some issue at some point. If you can build from master then you could try.

Thank you for looking into this.

It also works for me, as you show, that if I have the “gmt set FORMAT_GEO_MAP ddd.xxx” within the script, it gives the right output.

What I would like to do is first edit this line of the gmt.conf file:

FORMAT_GEO_MAP = ddd.xxx

And then have it output in that format without my having to write the format into the script. I would like this script to then run:

#!/bin/bash
gmt begin GMT_tut_3
	gmt coast -R270/271/0/1 -JM6i -Bxya0.3g0.3 -Gchocolate
gmt end show

And give me the output with the lat/lon values on the axes formatted as ddd.xxx.
My output is consistently ddd:mm:ss format, regardless of the gmt.conf file, unless I give the explicit formatting within the script each time.

Does that make sense?

Dont think GMT modern mode works like that. Maybe you need to switch to the classic theme. Not sure.

Modern mode doesn’t read the values in gmt.conf?

Maybe related? Changing global gmt.conf.

Thank you, @Andreas. That thread seems to indicate that gmt.conf located in ~/.gmt/ should be able to adjust the GMT parameters for a plot. So I’m unclear as to why mine won’t do it (my original question), and also as as to why @pwessel pwessel says above “Dont think GMT modern mode works like that.” Because in the other thread it sounds like it should. I’m not sure if I’m not communicating clearly or if I’m misunderstanding something.

I’ll go through your steps as well and see if I’m able to remember some more. Modern mode should read gmt.conf. I created an issue some time ago about modern mode one-liners not reading gmt.conf, bit I guess that’s not the issue here.

Does it help to turn GMT_THEME off, and then setting the parameters that you want?
E.g.:

$ gmt set GMT_THEME=off

Ooo, THANK YOU @Andreas for mentioning themes. I’ve never used them before, and I was trying to ignore them. But they solve (and like you say, probably caused) my problem.

I made a file: ~/.gmt/themes/gwen.conf

And inside the file I put FORMAT_GEO_MAP = +D

And my script now reads:

#!/bin/sh
gmt begin GMT_tut_3
        gmt set GMT_THEME gwen
        gmt coast -R270/271/0/1 -JM6i -Bxya0.3g0.3 -Gchocolate -V
        gmt get FORMAT_GEO_MAP
gmt end show

And now the map correctly outputs whatever I set FORMAT_GEO_MAP to in gwen.conf.

Thank you again!

1 Like

Glad it helped!