Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.

TRUNCATE command

nvaneck
New Contributor I
4,935 Views

Long before ALLOCATE/DEALLOCATE, we had to do memory allocation in assembly language. For large scale general purpose programs, like a statistical analysis package, we have to allocate large arrays to handle the design capacity for numbers of variables, size of analysis, etc. For instance, if you allow up to 32000 variables, matrices of up to 200 x 200 elements, you want to truncate it down to the actual size needed before you start allocating additional memory based on the size of the problemdiscovered.

At that time, at the Institue for Social Research at Michigan, when we created OSIRIS to run on an IBM 360 in about 100K it was especially important and we created a TRUNC subroutine to trucate the space to the actual problem size after setup interpretation and before additional critical memory was allocated.

It would be nice to have a truncate command for allocated memory. MOVE_ALLOC can accomplish it, but you need a short series of commands and data movement. Somethng like TRUNCATE (array(newsize))st leastfor linear arrays wouldbe very helpful anda lot more efficient and simpler to use.

Has this ever been considered?

0 Kudos
24 Replies
nvaneck
New Contributor I
708 Views

Thanks, Steve, Ian,

I've think I'm going to find it useful as a REALLOC routine in general...

 

Neal

0 Kudos
Steven_L_Intel1
Employee
708 Views

The MOVE_ALLOC/INTENT(IN) issue has been fixed for a release later this year.

0 Kudos
jimdempseyatthecove
Honored Contributor III
708 Views

nvaneck,

I do not know if your program has this behavior, it seems like you have unknown input data size (quantity) at the point of read-in of data and that it is impractical (number of code changes) to handle it other than with something like TRUNCATE. In the programs that I have experience with, the unknown sized data us usually read in one read loop. Might it be better to modify the read-in subroutine to read into the temporary, then copy to the properly allocated destination array? The temporary read-in array can be re-used multiple times (thus need only be allocated once).

Jim Dempsey

0 Kudos
nvaneck
New Contributor I
708 Views
Yes, Jim, for data reading that's exactly what I do. It's actually a case allowing maximum space for various arrays while interpreting user-supplied parameters. Once the setup is fully interpreted, actual required dimensions of remaining arrays are used, but some initial vectors and arrays can be large. Some of the time vectors can be left large as the code to move_alloc is not worth the recovery gain. The REALLOC solution handles the remaining ones. A global setting, i.e., setting maximum allowed variables, is under user control, which provides help if there is limited memory on the application machine (not likely anymore except in developing countries), and local maximums can also be set.
0 Kudos
Reply