FORTRAN/C INTEROPERABILITY

FORTRAN/C INTEROPERABILITY | INTEROPERABILITY between FORTRAN & C | C , FORTRAN INTEROPERABILITY | Accessing FORTRAN classes in C

   CALLING C ROUTINES FROM FORTRAN         ===============================     Machine        C Routine name    -------        ------------------    ALPHA/DUNIX    lowercase letters_  (default)    ALPHA/VMS      anything    CRAY           UPPERCASE LETTERS    HP             lowercase letters   (?)    IBM/AIX        lowercase letters   (all IBM's ?)    SGI/IRIX       lowercase letters_    SUN            lowercase letters_    TITAN          UPPERCASE LETTERS    VAX/VMS        anything    VAX/ULTRIX     lowercase letters_  (default)    Variable passing mechanisms  ---------------------------  Fortran usually passes its variables by reference (passes pointers).   That means that you MUST give addresses in your calling C-program.   Function results, may be passed by value, for example, the following   code calls a FORTRAN function called "gamma":     double   x, y;    ..................    x = 2.0;     y = gamma_(&x)      Array storage order  -------------------  Fortran uses a column wise storage of matrices while C stores them  row wise. This means that when you want to pass a matrix from your  C-program to the fortran routine you must transpose the matrix  in your program before entering the routine. Of course, any output  from such a routine must be transposed again.    If you omit this step, then probably your program will run (because  it has data to compute on) but it will generate wrong answers.   Transposition is expensive, you may avoid it by adapting the source  code, when the FORTRAN source says A(j+1,i+1) it could mean a[i][j] in C,.   There are times when you don't want to modify already existing FORTRAN   and C code, in such cases you may have to write a transposition wrapper.  This can be advisable for reasons of clarity (i.e. keeping the   documentation the code and the math in sync.)    Array indexes  -------------  Remember that array indexes in Fortran starts by default at 1 while   in C they start at index 0; hence a passed array fortran_array[1:100]  must be used in the C-routine/program as c_array[0:99].    Variable type matching  ----------------------  Watch out especially with float's and double's. Make sure that the  size of the variable in the calling program is identical to the size  in the Fortran routine:       float  --- REAL     (this is typical, but not always the case)     double --- REAL*8

Related Links :

No comments:

Post a Comment


If you face any Problem in viewing code such as Incomplete "For Loops" or "Incorrect greater than or smaller" than equal to signs then please collect from My Web Site CLICK HERE


More Useful Topics...

 

History Of C..

In the beginning was Charles Babbage and his Analytical Engine, a machine
he built in 1822 that could be programmed to carry out different computations.
Move forward more than 100 years, where the U.S. government in
1942 used concepts from Babbage’s engine to create the ENIAC, the first
modern computer.
Meanwhile, over at the AT&T Bell Labs, in 1972 Dennis Ritchie was working
with two languages: B (for Bell) and BCPL (Basic Combined Programming
Language). Inspired by Pascal, Mr. Ritchie developed the C programming
language.

My 1st Program...


#include
#include
void main ()
{
clrscr ();
printf ("\n\n\n\n");
printf ("\t\t\t*******Pankaj *******\n");
printf ("\t\t\t********************************\n");
printf ("\t\t\t\"Life is Good...\"\n");
printf ("\t\t\t********************************");
getch ();
}

Next Step...


#include
#include

void main ()
{
clrscr ();
printf ("\n\n\n\n\n\n\n\n");
printf ("\t\t\t --------------------------- \n\n");

printf ("\t\t\t | IGCT, Info Computers, INDIA | \n\n");
printf ("\t\t\t --------------------------- ");

getch ();

}

Hits!!!