[gradsusr] UDF in open grads 2
Arlindo da Silva
arlindo.dasilva at gmail.com
Thu Dec 1 23:29:23 EST 2011
On Thu, Dec 1, 2011 at 5:01 PM, Arlindo da Silva
<arlindo.dasilva at gmail.com>wrote:
> Henrique,
>
> This is a proposed API which has not been released. Your best bet is to
> download the opengrads sources and look at all the examples under
> extensions/. Start with the "hello, world" example under hello/. You can
> write extensions (UDFs or UDCs) in C, Fortran or even gs scripts.
>
>
At this point only the low level API is available. You can find some
information about this API here:
http://opengrads.org/wiki/index.php?title=Low-level_API_for_Writing_Extensions_in_GrADS_v2.0
For example, you could use this interface to re-implement any of the
regular grads intrinsic functions in src/gafunc.c. As I said, I have
purposedely not documented the grads internal data structures involved, you
need to know what you are doing to use this API. But with just a bit of
"monkey see, monkey do" you should be able to create meaningful extensions
with relatively minimum effort.
I should also mention that the IPC
extensions<http://opengrads.org/doc/udxt/libipc/>include some
functions
IPC_save()
IPC_load()
IPC_pipe()
that could be used to emulate the functionality of the older UDF in GrADS
v1.9. For example, IPC_save() can write any grads expression to a file
(using a header very similar to the header in traditional UDFs), and
IPC_load() can read similar files returning a grads expression. So, you can
use IPC_save() to write to disk the input data for your UDF; you can use
"!" to run you UDF applicatication, and IPC_load() to read the results of
your UDF application. IPC_pipe() is a bit trickier to use, but it is very
powerful (I used it to implement the GRIB-2 interface in GrADS v1.9).
Combine this with the gsUDF
capability<http://opengrads.org/doc/udxt/gsudf/>and you got yourself a
bonafide UDF as in the good old days. Read the
documentation above for more information.
Good Luck,
--
Arlindo da Silva
dasilva at alum.mit.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111201/235a04a1/attachment-0003.html
More information about the gradsusr
mailing list