This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Request on memory allocation
- From: Toon Moene <toon at moene dot indiv dot nluug dot nl>
- To: Joerg Ettrich <joerg dot ettrich at numeca dot de>
- Cc: gcc at gcc dot gnu dot org
- Date: Tue, 12 Mar 2002 21:25:03 +0100
- Subject: Re: Request on memory allocation
- Organization: Moene Computational Physics, Maartensdijk, The Netherlands
- References: <200202271736.JAA07447@atrus.synopsys.com> <3C83AE05.E062D343@moene.indiv.nluug.nl> <3C8DB7EA.C76F1662@numeca.de>
Joerg Ettrich wrote:
> as I does not get any fuitful answer from comp.lang.fortran,
> I'll sent my question to you...
>
> As far as I know the g77 compiler does not support dynamic
> allocation of memory (like with malloc in C). I already
> did some applications in FORTRAN 77, thus I wasn't able
> to allocate memory dynamically. The last few days I went
> (partly) through the manuals of g77 (web page) and now I
> have some questions.
>
> - Is g77 able to realize dynamic memory allocation?
Only via automatic arrays; i.e., it's possible to write:
PROGRAM PROG
READ*,N,M
CALL MAIN(N,M)
END
SUBROUTINE MAIN(N,M)
C ALLOCATE WORK SPACE
REAL A(N,M), B(M,N), C(N), D(M)
...
END
> - Is it possible to put a C-routine (that does the
> allocation) together with some g77-fortran code,
> in order to realize dynamic memory allocation ?
I've seen code that does this (unfortunately, can't find it in my mail
boxes anymore). It's not straightforward and you have to watch out for
switching to platforms with 64-bit pointers and 32-bit ints ...
Hope this helps,
--
Toon Moene - mailto:toon@moene.indiv.nluug.nl - phoneto: +31 346 214290
Saturnushof 14, 3738 XG Maartensdijk, The Netherlands
Maintainer, GNU Fortran 77: http://gcc.gnu.org/onlinedocs/g77_news.html
Join GNU Fortran 95: http://g95.sourceforge.net/ (under construction)