Back Home Next

Subchapters:

Makefile

Calling Fortran Procedures from IDL

You can easily call Fortran procedures/function from IDL. You need for example to call convram.f which is a Fortran routine like this:

      subroutine convram(nk,nl,param_in,tau_dust_PDR_alpha,
     $     tau_dust_HII_alpha,tab_resul)

        integer*2 nk,nl
        real*8  tab_resul(4,nl,nk),tau_dust_PDR_alpha(nl), tau_dust_HII_alpha(nk)

        STRUCTURE /param/
                          real*8 f_recouv
                          real*8 tau_dust_PDR_a
                          real*8 tau_dust_HII_a
                          real*8 delta_tau
                          real*8 R_PDR
                          real*8 CII
         END STRUCTURE

       record /param/ param_in

       [....]
        tab_resul(i,j,k) = ...
       [....]
        end

By the way, you see that even in F77, there are structures. You wanna use F77 to perform the calculation of tab_resul.
You can't call directly this procedure from IDL, you must use another function that will call it. Typically, this calling function, named in this example callconvram.f, will be like this (just take care of the number of arguments when calling convram):

      INTEGER*4 FUNCTION callconvram(ARGC, ARGV)

        INTEGER*4               ARGC    !Argument count
        INTEGER*4               ARGV(*) !Vector of pointers to argments

c
c     Here give the name of the function you want to call
c
        call convram( %val(ARGV(1)), %val(ARGV(2)),%val(ARGV(3)),
     $       %val(ARGV(4)),%val(ARGV(5)),%val(ARGV(6)))
        callconvram = 1
        return
      end

This must be compiled as a sharable library.  Have a look at your own <IDL_Directory>/external/sharelib for more complete examples (also for C). Or see an example of a Makefile for SUN.

Now you can call the procedure from IDL by:

        IDL> def_lib_fort,'callconvram',lib_name,entry_name
        IDL> resul =  CALL_EXTERNAL(LIB_NAME,ENTRY_NAME,nk,nl,param,tau_PDR, $
        IDL> tau_HII,rap)

 

IDL courses C. Morisset 2004 IA/UNAM V 2.2

Back Home Next