Description
How modern mode fails when using the API
It is interesting to simulate API sessions by using testgmtshell. What testgmtshell does is to call GMT_Create_Session, then execute all lines you give it (lines that starts with "gmt" are fed to GMT_Call_Module while the rest are fed to system), and then ends with a GMT_Destroy_Session call. For instance, a simple classic script like this (I called it classic.sh):
gmt pscoast -R0/30/0/30 -JM6i -P -K -Ggreen > t.ps
gmt psbasemap -R -J -O -Baf >> t.ps
can be run this way:
testgmtshell -v < classic.sh
and it will spit out
cmd = [gmt pscoast -R0/30/0/30 -JM6i -P -K -Ggreen > t.ps]
cmd = [gmt psbasemap -R -J -O -Baf >> t.ps]
and the plot t.ps is the same as you get if you run bash classic.sh. However, if we try the equivalent modern script (modern.sh):
gmt begin t ps
gmt pscoast -R0/30/0/30 -JM6i -Ggreen
gmt basemap -B
gmt end
then bash modern.sh gives the same plot but
testgmtshell -v < modern.sh
will print
cmd = [gmt begin t ps]
cmd = [ gmt pscoast -R0/30/0/30 -JM6i -Ggreen]
%!PS-Adobe-3.0
%%BoundingBox: 0 0 595 842
.....
end
%%EOF
cmd = [ gmt basemap -B]
TEST [ERROR]: Shared GMT module not found: basemap
TEST [ERROR]: basemap returned error 44
The reason is that GMT_Call_Module does not perform checks to detect that a modern session is running so it defaults to classic and hence the PostSCript goes to stdout and we get errors on modern names.
The API predates modern mode. I think this is @joa-quim issue with the Julia wrapper in a nutshell. We should discuss how we can address this issue. Perhaps we need another API function that can detect and set the right parameters so that a modern mode is detected. Alternatively, perhaps that bit of machinery should happen inside GMT_Call_Module.