Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Fortran > Re: Allocatable...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 19 Topic 8191 of 8773
Post > Topic >>

Re: Allocatable arrays in derived types

by "Jugoslav Dujic" <jdujic@[EMAIL PROTECTED] > Apr 29, 2008 at 02:08 PM

relaxmike wrote:
| On 29 avr, 11:26, nos...@[EMAIL PROTECTED]
 (Richard Maine) wrote:
|| That is *A* difference. It is certainly not *THE* difference. [...]
|| No. [...]
|| Not typically. [...]
|| No. [...]
| 
| Despite appearances, I think that we do not disagree that much !
<snip>
| This is an abstract :
| 
| extra_mem ()
| {
|   struct array1_integer(kind=4) mydata;
|   static integer(kind=4) options.0[7] = {68, 255, 0, 0, 0, 1, 0};
|   mydata.data = 0B;
|   _gfortran_set_options (7, (void *) &options.0);
|   {
|     void * D.567;
|     mydata.dtype = 265;
|     mydata.dim[0].lbound = 1;
|     mydata.dim[0].ubound = 10;
|     mydata.dim[0].stride = 1;
|  [... with a "D.568 = __builtin_malloc (40);" and "D.567 = D.568;"]
|     mydata.data = D.567;
|     mydata.offset = -1;
| [...]
| 
| We can see the dtype (data type ?), the lower bound 1, the upper
| bound 10 (what is stride ? what is offset) and the memory location
| is probably in mydata.data.

"Stride" is the last thingo in the array triplet, i.e. index 
difference between subsequent array elements:

http://www-unix.mcs.anl.gov/dbpp/text/node84.html

"Offset" is an internal thingo, which is not essential, but can
speed up calculation. The point is to calculate it in advance,
so you can find the address of element x = A(1,2,3) faster, like:

*x = A(offset + 1 + 2*dim[1].ubound + 3*dim[2].ubound)

Without offset, you would have to involve lbounds into play
in general case, and every array access would have to involve
a couple of extra operations. (My math above is almost certainly 
wrong, but you get the idea).

| If we... compare the intermediate code with allocatable and pointer
| versions, one can see that only the "allocatable" version contains
| the following code, near the end of the source :
| 
|   if (mydata.data != 0B)
|     {
|       __builtin_free (mydata.data);
|     }
|   mydata.data = 0B;
| 
| which clearly shows how gfortran deallocate the array
| before exiting from the subroutine.

Exactly. Just as expected.

-- 
 Jugoslav
___________
www.xeffort.com

Please reply to the newsgroup.
You can find my real e-mail on my home page above.
 




 19 Posts in Topic:
Allocatable arrays in derived types
Gib Bogle <bogle@[EMAI  2008-04-29 19:57:51 
Re: Allocatable arrays in derived types
Arjen Markus <arjen.ma  2008-04-29 01:23:58 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 02:03:17 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 02:26:48 
Re: Allocatable arrays in derived types
"Jugoslav Dujic"  2008-04-29 12:24:18 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 04:14:21 
Re: Allocatable arrays in derived types
"Jugoslav Dujic"  2008-04-29 14:08:55 
Re: Allocatable arrays in derived types
"James Van Buskirk&q  2008-04-29 14:30:21 
Re: Allocatable arrays in derived types
relaxmike <michael.bau  2008-04-29 06:08:04 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 09:06:51 
Re: Allocatable arrays in derived types
glen herrmannsfeldt <g  2008-04-29 08:41:18 
Re: Allocatable arrays in derived types
nospam@[EMAIL PROTECTED]   2008-04-29 14:14:44 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-29 22:25:33 
Re: Allocatable arrays in derived types
"James Van Buskirk&q  2008-04-30 00:20:44 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-30 10:19:07 
Re: Allocatable arrays in derived types
Gib Bogle <bogle@[EMAI  2008-05-02 08:57:21 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-04-29 05:58:51 
Re: Allocatable arrays in derived types
Damian <damian@[EMAIL   2008-04-30 00:59:43 
Re: Allocatable arrays in derived types
paul.richard.thomas@[EMAI  2008-05-01 02:40:21 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 13:49:57 CDT 2008.