Using R, matlab and IDL from within an NCL script

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed Nov 13 2013 - 08:59:26 MST

NCL Users:

In data processing, it is likely that people will have to use
multiple tools to accomplish a task. NCL is a great (imho)
file handler with excellent, high quality 2D graphics. Further,
it has many unique processing functions. However, there are
numerous (say) statistical functions that are not included in NCL.
How can functionality from another software tool (R, Matlab, IDL,
etc) be used from within an NCL script and the results from the
external software be returned for subsequent use within the
calling NCL script?

What we are requesting from the NCL community are some simple (toy)
examples where an external language is invoked in batch mode
from within NCL. The communication would be via a user generated
input file containing the necessary variable(s) and the name of
an output file which would contain the return results.

---
R/matlab/idl options input_file_name return_file_name external_script_name
---
Certainly, this approach is cumbersome but direct interlanguage
communication can be complicated and the necessary software
infrastructure is currently not available.
Generically, the approach would be something like:
    [1] Read/process/derive in NCL
    [2] Create a file (netCDF, text, binary) in NCL which contains
        the variables needed for some R/Matlab/IDL function.
    [3] Use NCL's 'system' to invoke the external software tool
        in batch mode. The external code reads the NCL
        generated file, computes the results and creates another
        output file which NCL reads. The structure of the NCL script
        and external command would be like the following:
        :
        NCL read/process/dreive code: derives 'aa' and 'yy'
        :
        iname = "foo_input.nc"       ; file containing input variables
        system("/bin/rm -f "+iname)
        ff    = addfile(iname, "c")
        ff->X = aa
        ff->Y = yy
        oname = "foo_output.txt"      ; user specified name for return
                                      ; here an ascii file
cmd = "R/matlab/idl options "+iname+" "+ oname+" external_script"
        system(cmd)
        gg = asciiread(oname, 0, ....)
           :
       ; continue in NCL
THX
_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Nov 13 08:59:32 2013

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