[Pw_forum] Error encountered while attempting to allocate a d ata object.

Serguei Patchkovskii ps at ned.sims.nrc.ca
Mon Feb 2 16:08:00 CET 2004


On Mon, 2 Feb 2004, Paolo Giannozzi wrote:

> On Saturday 31 January 2004 21:37, Serguei Patchkovskii wrote:
>
> > Fortran-90 provides a portable way of specifying non-default kinds
> > (through the SELECTED_REAL_KIND and SELECTED_INTEGER_KIND
> > intrinsics). Why not use those, and make the code portable?
>
> those numbers are supposed to be the lengths of real, integer, complex
> numbers, in bytes. In most cases they coincide with the "kind" parameter,
> but in principle they aren't the same. I am not aware of any standard and
> portable way to obtain that information in fortran-90 (but I am not at all
> an
> expert in f90). The SIZE command reports the size in elements, not in
> bytes, of an array.

OK, I was off the mark here :-)

You are right - there is no way to obtain the byte size of Fortran types,
most because Fortran is defined to make sense on computers with no
concept of byte.

However, there is still a reasonably portable way to obtain byte sizes on
computers which do. Namely, you can use BIT_SIZE intrinsic to get the size
of the default integer type. Then, you can use INQUIRY(IOLENGTH) to establish
the sizes of all other types. The latter part may get a little tricky (record
sizes returned by INQUIRY may include padding) - so I am not at all sure it's
worth the trouble ...

Best regards,

Serguei

---
Dr. Serguei Patchkovskii

Tel: +1-(613)-990-0945
Fax: +1-(613)-947-2838
E-mail: Serguei.Patchkovskii at nrc.ca

Coordinator of Modelling Software
Theory and Computation Group
Steacie Institute for Molecular Sciences
National Research Council Canada
Room 2011, 100 Sussex Drive
Ottawa, Ontario
K1A 0R6 Canada





More information about the users mailing list