Trouble with modern mode

Howdy,

I am trying to get my head around the modern mode so i can use some of the new functionality, particularly ‘movie’. I am running GMT6 on windows through cygwin.

My problem arises when trying to plot two commands to the same figure. When I run a script that starts with gmt begin it never works.

For example, using a script from the cook book:

gmt begin map
  gmt basemap -R0/6.5/0/7 -Jx2c -B 
  gmt plot @Table_5_11.txt -Sc0.3c -Gred 
gmt end show

gives the errors:

gmt.exe [ERROR]: Shared GMT module not found: basemap and
gmt.exe [ERROR]: Shared GMT module not found: plot
gmt.exe [ERROR]: Not available in classic mode

(i tried running it by pasting each line individually in the command window and by launching the script using ./plot_map_modern.sh)

but if i run each line separately like this:

gmt basemap -R0/6.5/0/7 -Jx2c -B -png map

and

gmt plot @Table_5_11.txt -Sc0.3c -Gred -png map

(adding the bit to write to files on each line) i get plots with the correct filename, but separately (the second command of course overwrites the file created in the first). I did this only to check if the modern mode was indeed working…

The modern mode only seems to work for plotting if I have the command only on one line. I also tried the’one line syntax’ examples in the manual and they work too.

So the question is: How do I get that first gmt begin command to work properly? What am I doing wrong? is it a cygwin thing?

Thanks,
-jose

p.s. the real script i am trying to run looks like this:

datafile=../data.nc
region=-R172/186/-40/-25 
echo $region
project=-JM180/0/6i 
border=-Bf1a5nSWe

gmt begin plot1 png -Vl
	gmt makecpt -Cjet -D -M -T-1000/1000/1  > tmp.cpt
	gmt grdimage $datafile?max_height $region $project $border -Ctmp.cpt -Q
	gmt coast $region $project $border -W -Df -Ggrey  -N1/1p,white
gmt end

and it gives me the same behaviour as above, i,e, i get plots if i d each line individually, but i can’t get one to plot on top of the other in the same file.

Windows binaries running modern mode in Cygwin is new territory.
Modern mode creates ~/.gmt/sessions temporary directories but does that taking into account the OS. But, cygwing tries to ignore that it’s running on Windows and probably the Win build binaries fail in something. The best is to use a MinGW derived bash. Like the one that comes with Github for windows.

It is definitively a “cygwin thing”. You could try adding -Vd to the commands and post the result and maybe there is a clue in there, but don’t expect us to be able to spend much time debugging on that sort of platform. I did some testing on Cygwin 6-10 years ago but with better solutions (Ubunto bash for Windows, MingGW) there is no point anymore.
BTW, for your modern script you need to remove the redirection to tmp.ctp and remote the -Ctmp.cpt from grdimage.

Perhaps adding

export GMT_SESSION_NAME=$$

at the start of your script works. See https://docs.generic-mapping-tools.org/latest/begin.html#note-on-unix-shells for why it may work.

@Joaquim @pwessel @seisman

Ok, thanks for info. I thought it might be something deep, which is unfortunate…

Will try the trick that @seisman suggested. I was reading that section last night, but was not sure if/how it applied to my situation.

I haven’t had a chance to fully investigate the Ubuntu/bash thing on windows. The few things i tried, didn’t really work properly, but i didn’t put much effort in to it…

and yes, @pwessel, noted about the > *.cpt, I had other version where I had removed it etc…

But I thought it was optional and that you could leave it in there and it would still work in modern? Like if you want to make sure the right cpt gets called in the right place and not rely on the automated thing. At least that is how I understood it from reading the docs.

As always, thanks so much for your efforts and helpful replies!

-jose

See makecpt -H for you concerns.

1 Like

@seisman just to let you know I tried the export trick and it worked!

thanks…!