Re: Is it possible to call an NCL script and pass data to it from a C script?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 13 2013 - 07:36:55 MST

FYI: It is not necessary to download the source code to get the HLU Fortran and C examples.

You can go to the page:

http://www.ncl.ucar.edu/Applications/BasicExamples/

and click on any topic of interest, like "Contours".

This will bring up a page of thumbnails, each of which is an example.

Clicking on any one of these thumbnails will take you to the page
that has links to the NCL, Fortran, and C versions of these examples.

You can also generate any one of these examples by typing:

   ng4ex cn03c

This copies a C program called "cn03c.c" to your home directory and compiles and executes it.

--Mary

On Nov 11, 2013, at 7:55 AM, Wei Huang <huangwei@ucar.edu> wrote:

> Cathryn,
>
> If you have downloaded NCL source code,
> you may go to, say, for contour plot:
> ni/src/examples/contourplot
>
> to see examples which use NCL HLU library directly.
>
> There are examples using Fortran or C.
>
> Which certainly allows you to pass data (in memory)
> directly to call NCL (functions).
>
> Hope this help,
>
> Wei
>
> huangwei@ucar.edu
> VETS/CISL
> National Center for Atmospheric Research
> P.O. Box 3000 (1850 Table Mesa Dr.)
> Boulder, CO 80307-3000 USA
> (303) 497-8924
>
>
>
>
>
>
> On Nov 11, 2013, at 3:40 AM, Cathryn Meyer <cmeyer@wsi.com> wrote:
>
>> Thank you all for all of the suggestions but I am trying to get around writing to a file at all and to be able to pass just the data array straight from the C script to the NCL script via a function call or something similar. So, it seems like I won't be able to use NCL to do that. I was just wondering if it was possible as I hadn't found anything about it in the NCL documentation or other internet sources yet.
>>
>>
>> On Thu, Nov 7, 2013 at 6:22 PM, Dennis Shea <shea@ucar.edu> wrote:
>> Interlanguage communication is either non-trivial or cumbersome.
>>
>> My cumbersome suggestion is to
>> (1) Write a file from the C code (ascii, binary or netCDF)
>> cfile = "foo.{txt/bin/nc}"
>>
>> (2) Use the C 'system' procedure to pass the file name to
>> the NCL script. See NCL's description of Command Line Arguments
>>
>> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclCLO.shtml
>>
>> Not sure how to create the proper string in C but generically
>> system("ncl fname="'+cfile+"' myNCLscript.ncl")
>>
>> (3) the nclscript would have
>>
>> f = adddfile(fname,"r")
>> data = f->...
>> or
>> data = asciiread(fname ,...)
>> or
>> data = fbindirread(fname,...)
>>
>>
>>
>> On 11/7/13 9:54 AM, Rick Brownrigg wrote:
>> Hi Cathy,
>>
>> There is an API to NCL functionality that allows one to *read* NCL variables/filevariables and execute scripts. Unfortunately there's no way to programmatically create and write to NCL variables and files, outside of executing lines of script. I think you're likely to have to use some sort of file to pass your 2D array. Perhaps a named pipe? In any case, you might look at the docs to see what is possible:
>>
>> http://www.ncl.ucar.edu/Document/Manuals/Ref_Manual/NclApi.shtml
>>
>> Hope that helps…
>> Rick
>>
>> On Nov 7, 2013, at 9:39 AM, Cathryn Meyer <cmeyer@wsi.com> wrote:
>>
>> I have an already-existing NCL script that reads in 2D temperature data from a grib file and plots it. However I want to be able to call the NCL script from the C code that generates the temperature data and simply pass the 2D array of float values into the NCL script from within the C code instead of having to print them out to a file first that NCL reads in.
>>
>> Is this possible?
>>
>> Thanks,
>> Cathy
>>
>> --
>> Cathryn Meyer |
>> w: 978 983 6598 e: cathryn.meyer@weather.com
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>>
>>
>> --
>> Cathryn Meyer |
>> w: 978 983 6598 e: cathryn.meyer@weather.com
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 13 07:37:05 2013

This archive was generated by hypermail 2.1.8 : Fri Nov 22 2013 - 09:36:32 MST