How to convert a C-utility into a subroutine and call it from gfortran?

Steve Kargl sgk@troutmask.apl.washington.edu
Tue Jun 19 14:49:00 GMT 2007


On Tue, Jun 19, 2007 at 02:16:43PM +0200, Tobias Burnus wrote:
> Hi Arjan,
> 
> I think you will have the following problem: You need to allocate the
> array in C and arrays are quite differently organized in C and Fortran.
> In C the array is only a chunk of data whereas in Fortran an array has
> also upper/lower bounds, strides etc.
> 
> I see two relatively simple solutions:
> 
> a) The size of the array is known (at run time or compile time): simply
> pass the arrays from fortran
> 
> b) Use two steps:
> - determine the size needed for the array
> - allocate the array in Fortran
> - pass that allocated array to C

c) Cray pointer and malloc.  See the gfortran manual.

(Note: This list is for the discussion of gfortran not general
programming questions.)

-- 
Steve



More information about the Fortran mailing list