This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Request on memory allocation


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)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]