This is the mail archive of the gcc-help@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]

Hi I hava a problem with g77 and arrays


 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.


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