Re: Question about KIND
- From: *** Hendrickson <***.hendrickson@xxxxxxx>
- Date: Mon, 30 Apr 2007 15:20:04 GMT
Gus Gassmann wrote:
I am writing a program with potentially very large arrays and I amThere's no portable way to do this. Compilers aren't required to
currently developing extensible vectors as objects (so I can re-
allocate if necessary). The current array bounds are stored with the
object (as integers). However, I am not clear as to what I should do
about the KIND of these pointers. Specifically:
TYPE extensible_vector
integer (kind=selected_int_kind(16)) :: lb, allocated_ub,
currently_used_ub
real (kind=selected_real_kind(15), allocatable, dimension (:) ::
vec
end TYPE extensible_vector
may fail to compile if selected_int_kind(16) is not available (e.g.,
lahey fortran 7.1 would return -1, and the compiler stops with an
error). Is there any way to switch between 4-byte and 8-byte pointers
at run-time? Or even just to allocate pointers as 8-byte objects when
available and use 4-byte storage plus an error otherwise?
I have started to look at "run-time polymorphism" and found a paper by
Decyk, Norton and Szymanski on the subject (Computer Physics
Commuications 1998). I can't say I have fully digested it. Does my
problem have anything to do with run-time polymorphism? Is the
mechanism described in that paper still the state of the art?
Any feedback would be greatly appreciated.
gus gassmann
provide "double precision" integers. They only have to provide an
integer that is the same byte size as single precision reals.
Are you sure you need 16 digit indexes into your arrays? 32 bit
integers are pretty big, won't they work?
As an aside, those things aren't "pointers" in the way Fortran uses
the word. You'll confuse people (maybe including yourself ;) ) if
you call them "pointers".
It's relatively easy to use "8 bytes" if it's available and "4 bytes"
otherwise. Something like
integer, parameter :: double_int = selected_int_kind(16)
integer, parameter :: single_int = selected_int_kind(7)
integer, parameter :: working_int = max(double_int, single_int)
integer (kind=working_int) :: lb, allocated_ub, currently_used_ub
...
IF(double_int < 0) print *, "whoops"
Most people would put the initial parameters in a module and USE that
as a way to save a few trees.
*** Hendrickson
.
- Follow-Ups:
- Re: Question about KIND
- From: Wade Ward
- Re: Question about KIND
- From: Gus Gassmann
- Re: Question about KIND
- From: Gus Gassmann
- Re: Question about KIND
- References:
- Question about KIND
- From: Gus Gassmann
- Question about KIND
- Prev by Date: Re: Question about KIND
- Next by Date: Re: Allocatable array of allocatable defined types?
- Previous by thread: Re: Question about KIND
- Next by thread: Re: Question about KIND
- Index(es):