- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page