comp.lang.idl-pvwave archive - RDF feed
type: channel
description: Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado
items: Tutorial on call_external

Tutorial on call_external
type: item
description: I have been asked by several people to post an example that illustrates how to "hook" a program into IDL from another language. The example below was copied from the IDL Users Manual (with some poetic license). It illustrates how to call a Fortran program to average an array of data. This is a fairly typical example which illustrates how IDL passes numeric values by reference. This is the natural passing mode in FORTRAN so you don't have to do anything special. In C however you have to remember to use pointers. I'll post a simple C example in the near future. There is one other important thing that is not illustrated below. Passing strings must be done differently. Again, I'll post an example of how to pass strings soon. This example has only been tested under VMS. As of the latest version of IDL (2.0.13) SUN users also have call_external capability. It would be nice if a SUN user would post a tutorial file similar to this one that shows ALL of the steps needed to run this program on a SUN. You should be able to cut and paste the three brief listings below into files my_avg.for, build_my_avg.com, and call_extern_ex.pro, respectively. Read carefully the notes in call_extern_ex.pro about the logical symbol my_avg_exe. -- Bruce **************** Here is the FORTRAN Program: my_avg.for ********************** REAL * 4 function MY_AVG(V,N) REAL*4 V(*) MY_AVG = 0.0 DO I=1,N MY_AVG = MY_AVG + V(I) END DO MY_AVG = MY_AVG / N RETURN END ***************** Here is the command file to compile the FORTRAN program****** ***************** and define a logical name that points to the executable****** ***************** I call this build_my_avg.com and invoke it by typing********* ****************** @build_my_avg ********* $ FORTRAN MY_AVG $ LINK MY_AVG, SYS$INPUT/OPT/SHARE UNIVERSAL = MY_AVG $! Replace D0:[GOTWOLS.IDL.FOR] below with the directory where your EXE file $! resides $ DEFINE MY_AVG_EXE D0:[GOTWOLS.IDL.FOR]MY_AVG.EXE ***************Here is an IDL "wrapper program that takes…
creator: gotwols
date: 1991-01-29T20:48:15-00:00