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

Initialisation of allocated arrays

tjt
Beginner
261 Views

Hi,

I have a f90 code containing a loop. I need to set a relatively large array to zero at the start of the loop. I found that this takes a surprisingly long time (~3 seconds per call and I have ~100000 iterations). I found that it is quicker to de-allocate the memory (coming up as 0 ms in profile) and then reallocate it but the arrays are only intialised to zero on the first allocation.

Is there a way to force allocated memory to have an assigned value? I tried the -zero compiler flag but this doesn't work

I know that, in a perfect world, is should assign a value to each declared variable/array but I am looking for a rough and ready way to save myself 300000 seconds...

Thanks in advance

TJT

0 Kudos
2 Replies
Steven_L_Intel1
Employee
261 Views

No, there is no way to do this automatically. The initialization has to happen somewhere. It should be fast to just assign the array to 0 if you enable vectorization - be sure to use the appropriate -x switch for best results.

You might also want to think of a different approach that doesn't require such a large array to be reset each iteration.

0 Kudos
tjt
Beginner
261 Views

Hi Steve,

Many thanks for the response. I will give the vectorisation a shot but can't do anything about the size of the array. The joy of scientific computing...

Tim.

0 Kudos
Reply