Re: F.03 C Interoperability doubt. Argument types
- From: Eduardo <edumlopes@xxxxxxxxx>
- Date: Fri, 6 Feb 2009 08:53:12 -0800 (PST)
On Feb 5, 1:12 pm, glen herrmannsfeldt <g...@xxxxxxxxxxxxxxxx> wrote:
Eduardo <edumlo...@xxxxxxxxx> wrote:
I have the following function written in C (available code downloaded
from the net) that i need to call from my fortran subroutine written
using F.03 standards
int write_xtc(XDR *xd,
int natoms,int step,real time,
matrix box,rvec *x,real prec)
Since the Fortran and C routines have different names, it seems like
they might have used wrapper routines.
Within my subroutine these "matrix box" and and "*x" are allocatable
arrays. My problem is whether should i replace those real arguments
to pointers in my C subroutine AND create pointers in my f.03
subroutine to use as the arguments in the Call statement OR create
those variables and arrays in my f.03 subroutine as they are in the C
matrix is (float) which should interoperate fine with a
Fortran (3,3) array, except the subscripts will be in the opposite
In most cases, calling a C routine from Fortran, the address of
(C pointer to) a variable or array is automatically passed.
More interesting is (XDR*)
which presumably should be a C_PTR pointing to an appropriate
sized array. It might be that an INTEGER array of the appropriate
size would be fine.
Or is there any other way to approach this problem?
Well, the other approach is wrapper routines which come
between your Fortran and the C routines.
Thank you Glen, i was thinking on writting a wraper indeed since my
corresponding matrix array is of allocatable type and because of that
i asked about the possibility to modify the c routine.
What's your caller look like?
stab_val(stab)->str_nok = 1; /* what a wonderful hack! */
-- Larry Wall in stab.c from the perl source code
Hello Larry, this is how my previous (Fortran 77 standard) Call looks
X1XTC looks like this now
Real, Dimension(:), Allocatable, INTENT(INOUT)::X1XTC
Indeede BOX has a fixed form and the rest of the arguments are just
- Prev by Date: Re: Write position
- Next by Date: Re: F.03 C Interoperability doubt. Argument types
- Previous by thread: Re: F.03 C Interoperability doubt. Argument types
- Next by thread: Re: F.03 C Interoperability doubt. Argument types