public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Hi I hava a problem with g77 and arrays
@ 2004-02-18 19:15 Lars Segerlund
  2004-02-20 21:22 ` Toon Moene
  0 siblings, 1 reply; 2+ messages in thread
From: Lars Segerlund @ 2004-02-18 19:15 UTC (permalink / raw)
  To: gcc-help


 I know a little about g77 and arrays by looking at g77 -S output, but I can't figure out why I cant allocate memory myself for a fortran array ? ( UGLY HACK IN PROGRESS ).

 What I do is I declare an array of the desired rank in my main fortran program like 

 real	a(1,1)

then call a c routine

 c_mem_rank_2( a, 10, 10 )

 ( in the c code, void c_mem_rank_2(float *a,int *b,int *c); )

 I then malloc( sizeof ( float*(*b)*(*c))) and assigns this to a. This looks great, now if I write data to a[] ( which is the way to look at it as far as I can read the gccint & g77 manual, a as a vector of length *b * *c ( 100 in this case )), it doesn't survive a return to the fortran prog.

 I really don't understand what I am doing wrong, since I think I have done something similar in the past, I just dont remember how ....

 Also if this doesn't work, I am thinking of using a character string instead, ( nicer passing of the arguments ), and an equivalence clause .. does anyone think this will do ?

 All I want to do is allocate some memory the quick and dirty way :-( 

 / regards, Lars Segerlund.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Hi I hava a problem with g77 and arrays
  2004-02-18 19:15 Hi I hava a problem with g77 and arrays Lars Segerlund
@ 2004-02-20 21:22 ` Toon Moene
  0 siblings, 0 replies; 2+ messages in thread
From: Toon Moene @ 2004-02-20 21:22 UTC (permalink / raw)
  To: Lars Segerlund; +Cc: gcc-help

Lars Segerlund wrote:

>  All I want to do is allocate some memory the quick and dirty way :-( 

I'm sorry I can't help you (I also don't understand why your approach 
doesn't work).

Do you really have to allocate (in the Fortran 90 sense) this array ? 
Is it used outside the routine it's allocated in ?

If not, you could use a automatic array (if you know the bounds at entry 
of the subroutine).  Automatic arrays are supported by g77.

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
GNU Fortran 95: http://gcc.gnu.org/fortran/ (under construction)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-02-20 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-18 19:15 Hi I hava a problem with g77 and arrays Lars Segerlund
2004-02-20 21:22 ` Toon Moene

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).