Concerning the GMT C API, for modules which only write to stdout (grdinfo for example), I’d like to be able to capture that output. As I understand it, this needs virtual files which I’d not come across before (there is an intriguing mention of “the hidden option ->filename” in the documentation). Are there any examples of usage of this which might be helpful for the virtual file n00b?
Jim,
In the src dir there are a series of testapi_xxx.c that may be of some help. I don’t know any programs that read directly from the API memory other than the GMTMEX and GMT.jl. The first is C so it may be of help too, though GMT.jl also reads pretty much like C i the functions that interface with the GMT API. Sorry, I don’t remember more without diving into the code.
A further question on this having had a read around the code: so if one wants to capture stdout, create a virtual file, then add ->filename to the command-line options of the module (where filename was specified in the creation of the virtual file). But virtual file creation requires specification of the family of the data (GMT_IS_GRID and so on), and there seems to be no “generic” family, suggesting that this mechanism is solely for the capture of structured data. One would not use this to capture the verbose output of modules who’s data output is already directed to file, or the semi-structured output of grdinfo for example. Would that be a fair summary?
If so, not a problem, I can capture stdout in the usual generic POSIX fashion with dup etc.
My motivation here is for my Ruby interface to GMT, I’d like to always capture stdout (structured, unstructured, verbose output etc) and then pass it back to Ruby’s stdout abstraction for the caller to handle as they see fit.