For Programmers: Free Programming Magazines  


Home > Archive > Fortran > March 2008 > how can I use C allocated memory in fortran ?









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how can I use C allocated memory in fortran ?
zhaopingsun@gmail.com

2008-03-21, 4:37 am

I must use the C allocated memory in FORTRAN ,I suppose the following
code can work ,but I failed

//c code----------------------------
void get_in_(int **x)
{
*x=(int *)malloc(sizeof(int)*10);
}

!fortran code ///////////////////////////////////////////////
program memtest
integer ,pointer :: p(:)
get_in(p) !I get segment fault here
end

GCC /GFORTRAN ON LINUX FC6

In my project , fortran code want get data form the C code , the C
code get POSIX shared memory and return to fortran , how could I do
this ?
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com