Re: Interfacing between Fortran and C - a little utility
- From: Arjen Markus <arjen.markus@xxxxxxxxxx>
- Date: Fri, 30 May 2008 03:00:47 -0700 (PDT)
On 30 mei, 11:43, rudra <bnrj.ru...@xxxxxxxxx> wrote:
hello AM,
for many reason, i found i can make my program better by using c
subroutines...but my poor knowledge on C prevents me for doing that.
can u give a small example of that using this utility?
Well, what it does is simply determine the values of
several macros as explained in the comments. You will
have to use these macros for setting up the Fortran-C interface.
First:
Create the program with the Fortran and C compilers you want to use.
Second:
Run it to get the values for these macros in an include file.
Third:
A C function "my_func" like below could then be interfaced to:
#include "ftcl_conventions.h"
#ifdef FOR_UNDERSCORE
#define my_func my_func_
#endif
#ifdef FOR_DBL_UNDERSCORE
#define my_func my_func__
#endif
#ifdef FOR_ALL_CAPS
#define my_func MY_FUNC
#endif
/* So far, so good: the macro my_func will be
replaced by the correct internal Fortran name
Now: the two aspects of the calling convention
*/
void FOR_CALL my_func(
char *string,
#ifdef IN_BETWEEN
int len_string,
#endif
int value
#ifndef IN_BETWEEN
,int len_string
#endif
) {
...
}
The macro FOR_CALL must have the value __stdcall on Windows
for some compilers, and the position of the hidden argument
that holds the length of a string argument can differ.
If you use this particular utility, you do not have to worry
about what the Fortran compiler produces yourself. The program
does this automatically for you.
Regards,
Arjen
.
- References:
- Interfacing between Fortran and C - a little utility
- From: Arjen Markus
- Re: Interfacing between Fortran and C - a little utility
- From: rudra
- Interfacing between Fortran and C - a little utility
- Prev by Date: Re: .true. help
- Next by Date: Re: .true. help
- Previous by thread: Re: Interfacing between Fortran and C - a little utility
- Next by thread: Fortran 77 alphabet character $
- Index(es):
Relevant Pages
|
|