forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Nested Implied DO LOOP - order of indices

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
viroxa



Joined: 28 Jul 2017
Posts: 78

PostPosted: Mon Aug 07, 2017 4:34 pm    Post subject: Nested Implied DO LOOP - order of indices Reply with quote

Good evening, everyone,

is the order of indices within an implied DO LOOP important, regarding performance?

Example: Order of icoun, jcoun, kcoun
Code:
      ALLOCATE(bmatt(ndib1,ndib2,nlays))

!      Assemble array bmatt - contains layerwise results
!      Reshape is used, because implied DO LOOP returns 1D-array 
      bmatt=reshape([((assign_belem(...),jcoun=1,ndib1),kcoun=1,ndib2),icoun=1,nlays)],shape(bmatt))


Thanks!
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Aug 07, 2017 5:34 pm    Post subject: Reply with quote

It might well be, depending on how often the assignment is performed and how many dimensions there are in the array.

Fortran uses "column major" ordering and the compiler may optimise the process of calculating the address of each element. For FTN95 further optimisation may be applied when using /opt on the command line.

I suggest that you run a simple timing test, wrapping the assignment in a do loop with (say) 10000 passes. This will give you a sensible speed comparison between different orderings and different compiler command lines options.
Back to top
View user's profile Send private message AIM Address
viroxa



Joined: 28 Jul 2017
Posts: 78

PostPosted: Tue Aug 08, 2017 9:00 am    Post subject: Reply with quote

Thanks, I'll try that.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group