Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29246 Discussions

Allocatable memory and equivalence (with different types)

Geoff_Hall
Beginner
764 Views
We have a (F77) program that dynamically allocates a large chunk of memory that is managed as a buffer that could be used as either integer, real or double precision. The memory management was a previous compiler's proprietary system that we are looking to convert to CVF. In CVF/F90 I can allocate the memory and use a saved pointer to make it available across many separately compiled modules, but I can't get the pointer array definition to accept a different type. Is there a way around (or through) this in F90?

CVF also has a malloc / loc feature that might offer a possibility (not F90, but at this stage I'm not that fussed), but as far as I can see with that mechanism, I can't reference the memory like a standard array reference.

I'd appreciate any ideas on the dilemma. Thanks.
0 Kudos
2 Replies
Steven_L_Intel1
Employee
764 Views
In standard F90, no. But if you don't mind extensions...

integer i
real r,x
pointer (p,i)
pointer (p,r)

x = 1.4
p = loc(x)
write (*,*) i
end

Steve
0 Kudos
Geoff_Hall
Beginner
764 Views
Thanks Steve.
I had been using a "non-standard" construct in the first place. While it's much "nicer" (more maintainable, portable, etc) to use standard constructs, I do need to get a job done! Thanks.

Geoff
0 Kudos
Reply