Re: Using R, matlab and IDL from within an NCL script

From: Arindam Chakraborty <arch13_at_nyahnyahspammersnyahnyah>
Date: Sat Nov 16 2013 - 02:18:27 MST

Hi Dennis,
 Good idea. Thanks for sharing this. I've personally never tried to call
another language from within NCL. Won't it also be possible to call MATLAB
(for example) from NCL via an externally written function for NCL? What I
mean is:

Write an external function in fortran for NCL. This function will take data
from NCL. This then calls MATLAB using mex. And then the output from
mexCallMATLAB is again passed on to NCL function.

(please see this link:
http://www.mathworks.in/help/matlab/apiref/mexcallmatlab.html)

This can avoid file input/output.

regards,

--
*Arindam Chakraborty*
On Wed, Nov 13, 2013 at 9:29 PM, Dennis Shea <shea@ucar.edu> wrote:
> 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
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Sat Nov 16 02:19:03 2013

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