-
Notifications
You must be signed in to change notification settings - Fork 346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Let the API be aware of modern mode #1142
Comments
PaulWessel
added a commit
that referenced
this issue
Jul 10, 2019
Most of ouir experience with GMT_Call_Module is in gmt.c, where it is sandwiched bewteen GMT_Create_Session and GMT_Destroy_Session. However, direct users of the API, such as the GMT/MATLAB toolbox ,Julia, and potentially PyGMT, may issue many GMT_Call_Module commands between those Session calls. Thus, it is important that GMT_Call_Module can determine if we are in a classic or modern mode session. Up until now it did not. At least some of the trouble @joa-quim has in Julia is linked to the need to add extra calls to gmt_manage_session etc to make sure the modern run mode is set. This PR does away with this and moves the test for modern mode, as well as those pesky one-liner modern mode commands, inside GMT_Call_Module. ALl tests still pass. The testgmtshell.c, which I updated a bit, was really helpful in figuring out the details since it can simulate an API multi-command session by being fed strings of GMT and UNIX commands. Closes #1142.
5 tasks
obaney
pushed a commit
to obaney/gmt
that referenced
this issue
Aug 18, 2021
Co-authored-by: Dongdong Tian <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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):
can be run this way:
testgmtshell -v < classic.sh
and it will spit out
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):
then bash modern.sh gives the same plot but
testgmtshell -v < modern.sh
will print
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.
The text was updated successfully, but these errors were encountered: