Hello,
I do not have the Fortran 95 standard and cannot find details on the
automatic deallocation of allocatable local arrays upon return from
procedures in my copy of the "Fortran 95 handbook". If I want to write a
routine that will allocate space and make this space say available to a
C program, how do I prevent automatic deallocation of the allocated
space to occur upon return from the procedure? Will a TARGET attribute
on the allocatable array help? Or do I have to make it an array pointer?
function f_malloc(n) result(c_pointer)
integer, intent(in) :: n
type(c_ptr) :: c_pointer
real, allocatable, TARGET :: buffer
allocate(buffer(n))
c_pointer=C_LOC(buffer)
return ! Will the buffer be automatically deallocated?
end function f_malloc
Thanks,
Aleksandar
--
__________________________________
Aleksandar Donev
Complex Materials Theory Group (http://cherrypit.princeton.edu/)
Princeton Materials Institute & Program in Applied and Computational Mathematics
@ Princeton University
Address:
419 Bowen Hall, 70 Prospect Avenue
Princeton University
Princeton, NJ 08540-5211
E-mail: [log in to unmask]
WWW: http://atom.princeton.edu/donev
Phone: (609) 258-2775
Fax: (609) 258-6878
__________________________________
|