Re: how can i call a compiled fortran code from IDL? [message #33956 is a reply to message #33952] |
Thu, 06 February 2003 06:27   |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
"mads" <madhu@erc.msstate.edu> writes:
> Hi,
> I have a compiled FORTRAN code and I need to call it from a procedure in
> IDL. The FORTRAN code does not require any i/p. It reads everything from a
> data file and creates a data file as o/p.
> Madhu
It's been a long, long time since I last did this, and there are probably more
modern ways to do it, but I was able in the past to use LINKIMAGE to link
Fortran procedures into IDL. The secret was to put a C wrapper around the
Fortran. For example, here is a C wrapper for some software that I'm still
using, where the IDL input and output arguments are converted via C into the
kind of things that Fortran can understand. (For some strange reason, when the
Fortran routine is called from C, it ends up with an extra "_" appended to its
name.) Probably something similar can be done with a DLM.
You can see all the C and Fortran code, plus make files for some different
platforms, at
ftp://sohoftp.nascom.nasa.gov/solarsoft/gen/idl_external/
Bill Thompson
#include <stdio.h>
void f_median_c(argc, argv)
int argc; /* The number of arguments */
void *argv[]; /* The arguments */
{
float *in, *out, *missing, *workspace;
long *ndim1, *ndim2, *n_width1, *n_width2;
/* Convert the IDL input parameters into FORTRAN parameters. */
in = (float *) argv[0];
out = (float *) argv[1];
ndim1 = (long *) argv[2];
ndim2 = (long *) argv[3];
n_width1 = (long *) argv[4];
n_width2 = (long *) argv[5];
missing = (float *) argv[6];
workspace = (float *) argv[7];
/* Call the FORTRAN routine F_MEDIAN. */
f_median_(in,out,ndim1,ndim2,n_width1,n_width2,missing,works pace);
return;
}
|
|
|