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

From: Cathryn Meyer <cmeyer_at_nyahnyahspammersnyahnyah>
Date: Mon Nov 11 2013 - 03:40:24 MST

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
Received on Mon Nov 11 03:40:37 2013

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