Naomi,
There is no portable way in Fortran to "associate" memory with an array
except through array pointers, or simply passing that memory as a dummy
argument. Fortran 2008 has the CONTIGUOUS attribute for pointers which
makes life somewhat better. Memory for allocatable arrays is always
allocated by the compiler, and this has to be due to automatic
deallocation and other stuff only the compiler can do. It is possible to
hack this by messing with array descriptors under the hood, and I have
done it, but it is not clear it is best.
I recommend carefully evaluating if this is necessary. Firstly, codes
rarely have to allocate deallocate large arrays "frequently". Reexamine
your code. If it is many small arrays, a compiler with a good allocator
should already have built-in tools to speed that up, or this can be
avoided by using indices into a large array instead (after all, a
pointer is just an integer).
Best,
Aleks
--
Aleksandar Donev, Ph.D.
Luis W. Alvarez Postdoctoral Fellow
Center for Computational Sciences and Engineering (https://ccse.lbl.gov)
Lawrence Berkeley National Laboratory (http://www.lbl.gov)
E-mail: [log in to unmask]
Phone: (510) 486-5782 Fax: (510) 486-6900
Address: MS 50A-1148, LBL, 1 Cyclotron Rd., Berkeley, CA 94720
Web: http://cims.nyu.edu/~donev/
|