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)
Looking at:http://www.gromacs.org/documentation/reference/online/xtc.html
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
called function.
matrix is (float[3][3]) which should interoperate fine with a
Fortran (3,3) array, except the subscripts will be in the opposite
order.
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*)
ftp://ftp.back2roots.org/pub/back2roots/cds/fred_fish/goldfish_vol2_9...
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.
-- glen
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?
--
larry gates
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
like
CALL WRITEXTC(IDW,NATXTC,STEP,TIMEXTC,BOX,X1XTC,PREC,NRET)
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
standard variables.
.
- Follow-Ups:
- Re: F.03 C Interoperability doubt. Argument types
- From: Richard Maine
- Re: F.03 C Interoperability doubt. Argument types
- From: Eduardo
- Re: F.03 C Interoperability doubt. Argument types
- References:
- F.03 C Interoperability doubt. Argument types
- From: Eduardo
- Re: F.03 C Interoperability doubt. Argument types
- From: glen herrmannsfeldt
- F.03 C Interoperability doubt. Argument types
- 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
- Index(es):
Relevant Pages
|