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

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Nov 07 2013 - 10:22:23 MST

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
>
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Nov 7 10:22:25 2013

This archive was generated by hypermail 2.1.8 : Mon Nov 11 2013 - 09:45:33 MST