2010/3/15 Vinícius Almeida <span dir="ltr">&lt;<a href="mailto:viniciusaalmeida@gmail.com">viniciusaalmeida@gmail.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">Hi Arlindo,<br><br>My name is Vinicius Almeida and I am student of the Federal University of Rio de Janeiro, Brazil.<br><br>I was reading the GrADS documentation for User Defined Functions from the OpenGrads website but I found myself confused while trying to write my own function.<br>

<br></div></blockquote><div><br></div><div>What exactly did you read? I am yet to write detailed documentation for writing extensions in v2.0, mainly because COLA does not endorse the OpenGrADS interface. Here is a simple example for the Low Level API,</div>
<div><br></div><div>  <a href="http://opengrads.org/wiki/index.php?title=Low-level_API_for_Writing_Extensions_in_GrADS_v2.0">http://opengrads.org/wiki/index.php?title=Low-level_API_for_Writing_Extensions_in_GrADS_v2.0</a></div>
<div><br></div><div>There are plenty more examples under src/extensions with the opengrads bundle source tarball. </div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">I have clearly understood that I can write it anyway, I mean, using any programming language and then compile it to a .GEX file. Is it right?</div></blockquote><div><br></div><div>In principle yes, in practice you will need at least a C wrapper and from there you can interface to any language (as most languages provide an interface to C). However, you can now write user defined functions using a gs script, see this:</div>
<div><br></div><div>       <a href="http://opengrads.org/doc/udxt/gsudf/">http://opengrads.org/doc/udxt/gsudf/</a></div><div><br></div><div>These are real UDFs to be used with &quot;display&quot;, although they are written as gs scripts.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr">But I did not figure out the procedure I am meant to follow to have it enabled in GrADS display option. So I would like to know, if possible, which are the steps I should follow to write it (what is the structure of it) and how I should compile into a .GEX file.<br>

<br></div></blockquote><div><br></div><div>See the examples under src/extensions and the URL above. Once you write an extension and compile it into a .gex file you need an entry into the UDX table so that GrADS can find your extension.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div dir="ltr">It would be useful if you could give me a example in some programming language (python, fortran,...) and what should I do to make it works.<br>
<br></div></blockquote><div><br></div><div>Make sure you understand the difference between the opengrads interfaces (pygrads, gerl, tclgrads) and the user defined functions/commands. So far, no UDF/UDC has been written in python, although in principle it could. But if you are interested in python, in most cases you can skip the extensions and do most things through pygrads.</div>
<div><br></div><div>     Arlindo</div><div><br></div></div>-- <br>Arlindo da Silva<br><a href="mailto:dasilva@alum.mit.edu">dasilva@alum.mit.edu</a><br>