Unfortunately, both STORAGE_SIZE() (section 13.7.160) and C_SIZEOF() (section 15.2.3.7)
are Fortran 2008, not Fortran 2003 or Fortran 95.
You may wish to check your compiler's documentation to see if either or both of these
procedures have been added to your compiler.
You also need to be aware that a Fortran compiler is free to organize the components of a
derived-type scalar or array element in any way that it sees fit. The amount of storage
used in memory is not necessarily the same as the amount of storage used for that same
entity in a register or in a file.
Short of using the Fortran 2008 procedures, there is no answer to the general problem.
You may wish to RTFM to see if this kind of information is in the documentation.
Sincerely,
Craig T. Dedo
17130 W. Burleigh Place
P. O. Box 423 Mobile Phone: (414) 412-5869
Brookfield, WI 53008-0423 E-mail: <[log in to unmask]>
USA
Linked-In: http://www.linkedin.com/in/craigdedo
> -----Original Message-----
> From: Fortran 90 List [mailto:[log in to unmask]] On Behalf Of
> Aleksandar Donev
> Sent: Thursday, December 16, 2010 13:06
> To: [log in to unmask]
> Subject: Re: size of a derived type
>
> On 12/16/10 13:46, Ted Stern wrote:
> > Is there another way to get this size
> > other than doing a compilation to check it?
> Not in F90 (except using file i/o of some sort---Dan can tell you), but
> yes in the newer revisions. There is C_SIZEOF intrinsic which works like
> the C sizeof (so it is meant for interoperable types). There is also the
> intrinsic STORAGE_SIZE, which I believe was added in F2003.
> Not sure how widely implemented they are.
> But I might add that using TRANSFER for this is not very nice :-)
> Best,
> Aleks
>
> --
> Aleksandar Donev, Assistant Professor of Mathematics
> Courant Institute of Mathematical Sciences
> Office: 909 Warren Weaver Hall, New York University
> E-mail: [log in to unmask]
> Phone: (212) 992-7315; Fax: (212) 995-4121
> Mailing address: 251 Mercer St, New York, NY 10012
> Web: http://cims.nyu.edu/~donev
|